diff --git a/project/src/generators/RepeatableQuestGenerator.ts b/project/src/generators/RepeatableQuestGenerator.ts index 18204a54..531792a1 100644 --- a/project/src/generators/RepeatableQuestGenerator.ts +++ b/project/src/generators/RepeatableQuestGenerator.ts @@ -1144,9 +1144,20 @@ export class RepeatableQuestGenerator const rewardableItemPool = this.getRewardableItems(repeatableConfig, traderId); const minPrice = Math.min(25000, 0.5 * roublesBudget); - let rewardableItemPoolWithinBudget = rewardableItemPool.filter((x) => - this.itemHelper.getItemPrice(x[0]) < roublesBudget && this.itemHelper.getItemPrice(x[0]) > minPrice - ).map((x) => x[1]); + let rewardableItemPoolWithinBudget = rewardableItemPool.filter((item) => + { + // Get default preset if it exists + const defaultPreset = this.presetHelper.getDefaultPreset(item[0]); + + // Bundle up tpls we want price for + const tpls = defaultPreset ? defaultPreset._items.map((x) => x._tpl) : [item[0]]; + + // Get price of tpls + const itemPrice = this.itemHelper.getItemAndChildrenPrice(tpls); + + return itemPrice < roublesBudget && itemPrice > minPrice; + }).map((x) => x[1]); + if (rewardableItemPoolWithinBudget.length === 0) { this.logger.warning( diff --git a/project/src/helpers/ItemHelper.ts b/project/src/helpers/ItemHelper.ts index 3291e4c0..6075c5cf 100644 --- a/project/src/helpers/ItemHelper.ts +++ b/project/src/helpers/ItemHelper.ts @@ -159,6 +159,18 @@ export class ItemHelper ]; } + /** + * Returns the items total price based on the handbook or as a fallback from the prices.json if the item is not + * found in the handbook. If the price can't be found at all return 0 + * @param tpls item tpls to look up the price of + * @returns Total price in roubles + */ + public getItemAndChildrenPrice(tpls: string[]): number + { + // Run getItemPrice for each tpl in tpls array, return sum + return tpls.reduce((total, tpl) => total + this.getItemPrice(tpl), 0); + } + /** * Returns the item price based on the handbook or as a fallback from the prices.json if the item is not * found in the handbook. If the price can't be found at all return 0