You've already forked tf2wikipricing
feat: add botkiller variants to schema cache
This commit is contained in:
@@ -39,6 +39,7 @@ export class ItemSchema {
|
||||
tradable: Boolean,
|
||||
hasAustraliumVariant: Boolean,
|
||||
festiveVariant: number | null
|
||||
botkillerVariants: Array<number> | null
|
||||
canKillstreakify: Boolean
|
||||
};
|
||||
}
|
||||
@@ -84,7 +85,27 @@ export function linkFestiveVariants(items: Array<{item_class: string, defindex:
|
||||
if (original) {
|
||||
if(schema[original.defindex]) {
|
||||
schema[original.defindex].festiveVariant = festive.defindex;
|
||||
console.log(`original:${original.defindex},festive:${festive.defindex}`);
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
export function linkBotkillerVariants(items: Array<{item_class: string, defindex: number, item_name: string, item_type_name: string}>, schema: ItemSchema): void {
|
||||
if(!schema) return
|
||||
items.filter(item =>
|
||||
item.item_class != null &&
|
||||
item.item_class.startsWith('tf_weapon') &&
|
||||
item.item_name.includes('Botkiller')
|
||||
).forEach(botkiller => {
|
||||
const originalName = botkiller.item_type_name
|
||||
const original = items.find(item => item.item_name === originalName && item.defindex > 30 && (item.defindex < 15000 || item.defindex >= 16000));
|
||||
if (original) {
|
||||
if(schema[original.defindex]) {
|
||||
if(schema[original.defindex].botkillerVariants == null) {
|
||||
// init array
|
||||
schema[original.defindex].botkillerVariants = new Array<number>()
|
||||
}
|
||||
schema[original.defindex].botkillerVariants.push(botkiller.defindex)
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -170,6 +191,7 @@ export async function prepareSchema(): Promise<ItemSchema> {
|
||||
});
|
||||
|
||||
linkFestiveVariants(responseItems, cacheItems)
|
||||
linkBotkillerVariants(responseItems, cacheItems)
|
||||
|
||||
await setStorageValue(storage_schema, (cacheItems));
|
||||
itemSchema = cacheItems
|
||||
|
||||
Reference in New Issue
Block a user