Fix price multiplier

This commit is contained in:
Platinum 2024-02-07 21:02:29 +11:00
parent 4ef0112d3c
commit 1cc4eaf237

View File

@ -77,8 +77,10 @@ class TheBlacklistMod implements IPostDBLoadModAsync {
const item = itemTable[handbookItem.Id]; const item = itemTable[handbookItem.Id];
const originalPrice = prices[item._id]; const originalPrice = prices[item._id];
// We found a custom price override to use. That's all we care about for this item. Move on to the next item. const customItemConfig = this.config.customItemConfigs.find(conf => conf.itemId === item._id);
if (this.updateItemUsingCustomItemConfig(item, prices, originalPrice, ragfairConfig)) {
// We found a custom item config override to use. That's all we care about for this item. Move on to the next item.
if (customItemConfig && this.updateItemUsingCustomItemConfig(customItemConfig, item, prices, originalPrice, ragfairConfig)) {
return; return;
} }
@ -107,6 +109,10 @@ class TheBlacklistMod implements IPostDBLoadModAsync {
return; return;
} }
if (!isNaN(customItemConfig?.priceMultiplier)) {
prices[item._id] *= customItemConfig.priceMultiplier;
}
this.debug(`Updated ${item._id} - ${item._name} flea price from ${originalPrice} to ${prices[item._id]}.`); this.debug(`Updated ${item._id} - ${item._name} flea price from ${originalPrice} to ${prices[item._id]}.`);
this.blacklistedItemsUpdatedCount++; this.blacklistedItemsUpdatedCount++;
@ -122,13 +128,8 @@ class TheBlacklistMod implements IPostDBLoadModAsync {
} }
} }
private updateItemUsingCustomItemConfig(item: ITemplateItem , prices: Record<string, number>, originalPrice: number, ragfairConfig: IRagfairConfig): boolean { // Returns true if we updated something using the customItemConfig so we can skip to the next handbook item.
const customItemConfig = this.config.customItemConfigs.find(conf => conf.itemId === item._id); private updateItemUsingCustomItemConfig(customItemConfig, item: ITemplateItem , prices: Record<string, number>, originalPrice: number, ragfairConfig: IRagfairConfig): boolean {
if (!customItemConfig) {
return false;
}
if (customItemConfig?.blacklisted) { if (customItemConfig?.blacklisted) {
this.debug(`Blacklisted item ${item._id} - ${item._name} due to its customItemConfig.`); this.debug(`Blacklisted item ${item._id} - ${item._name} due to its customItemConfig.`);
@ -146,12 +147,6 @@ class TheBlacklistMod implements IPostDBLoadModAsync {
return true; return true;
} }
if (!isNaN(customItemConfig?.priceMultiplier)) {
prices[item._id] *= customItemConfig.priceMultiplier;
return true;
}
return false; return false;
} }