feat: add support for festive weapon variants

on schema update, festive variants are linked. on content injection, if if finds a festive variant, it adds price rows for Festive and Strange Festive.
This commit is contained in:
xenticore
2025-04-02 18:54:39 -04:00
parent 3101f57f62
commit fa7276a53c
3 changed files with 148 additions and 6 deletions

View File

@@ -38,6 +38,7 @@ export class ItemSchema {
slot: ItemSlot,
tradable: Boolean,
hasAustraliumVariant: Boolean,
festiveVariant: number | null
canKillstreakify: Boolean
};
}
@@ -70,6 +71,25 @@ export function getTradableStatusByName(schema: ItemSchema, name: string, exclud
return true
}
export function linkFestiveVariants(items: Array<{item_class: string, defindex: number, item_name: string}>, schema: ItemSchema): void {
if(!schema) return
items.filter(item =>
item.item_class != null &&
item.item_class.startsWith('tf_weapon') &&
item.item_name.startsWith('Festive ')
).forEach(festive => {
const originalName = festive.item_name.slice(8); // "Festive " is 8 chars
const original = items.find(item => item.item_name === originalName && item.defindex > 30 && (item.defindex < 15000 || item.defindex >= 16000));
if (original) {
if(schema[original.defindex]) {
schema[original.defindex].festiveVariant = festive.defindex;
console.log(`original:${original.defindex},festive:${festive.defindex}`);
}
}
});
}
export async function wipeSchema(): Promise<void> {
await setStorageValue(storage_version, __VERSION__)
await setStorageValue(storage_schema, null)
@@ -149,6 +169,8 @@ export async function prepareSchema(): Promise<ItemSchema> {
}
});
linkFestiveVariants(responseItems, cacheItems)
await setStorageValue(storage_schema, (cacheItems));
itemSchema = cacheItems
await setStorageValue(storage_version, __VERSION__);