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

@@ -237,6 +237,42 @@ async function inject() {
}))
}
// Check item schema for Festive variant of current defindex
if(itemSchema[itemIndex].festiveVariant != null) {
promises.push(new Promise(async (resolve) => {
logDebug(`Fetching price for Festive ${itemName}`)
var data: ItemPriceData | null
try {
data = await fetchPrice(token, `${itemSchema[itemIndex].festiveVariant};6`, currentTime);
updateTime = new Date(data.update)
} catch {
log(`Festive ${itemName} is unpriced or unavailable, skipping...`)
}
const priceRow = createPriceRow($T("Festive"), data, keyPrice, locale, "https://wiki.teamfortress.com/wiki/Festive_weapons")
priceRows.push({quality: 97, row: priceRow})
resolve()
return
}))
promises.push(new Promise(async (resolve) => {
logDebug(`Fetching price for Strange Festive ${itemName}`)
var data: ItemPriceData | null
try {
data = await fetchPrice(token, `${itemSchema[itemIndex].festiveVariant};11`, currentTime);
updateTime = new Date(data.update)
} catch {
log(`Strange Festive ${itemName} is unpriced or unavailable, skipping...`)
}
const priceRow = createPriceRow($T("Strange Festive"), data, keyPrice, locale, "https://wiki.teamfortress.com/wiki/Festive_weapons")
priceRows.push({quality: 98, row: priceRow})
resolve()
return
}))
}
Promise.all(promises).then(() => {
priceRows.sort((a, b) => {
// Sort 6 first always, then numerically