This commit is contained in:
Dev 2024-04-01 11:07:07 +01:00
commit 90825aa8b3

View File

@ -116,7 +116,7 @@ export class RepeatableQuestRewardGenerator
// Possible improvement -> draw trader-specific items e.g. with this.itemHelper.isOfBaseclass(val._id, ItemHelper.BASECLASS.FoodDrink) // Possible improvement -> draw trader-specific items e.g. with this.itemHelper.isOfBaseclass(val._id, ItemHelper.BASECLASS.FoodDrink)
let roublesBudget = rewardRoubles; let roublesBudget = rewardRoubles;
const rewardItemPool = this.chooseRewardItemsWithinBudget(repeatableConfig, roublesBudget, traderId); let rewardItemPool = this.chooseRewardItemsWithinBudget(repeatableConfig, roublesBudget, traderId);
this.logger.debug( this.logger.debug(
`Generating daily quest for ${traderId} with budget ${roublesBudget} for ${rewardNumItems} items`, `Generating daily quest for ${traderId} with budget ${roublesBudget} for ${rewardNumItems} items`,
); );
@ -213,7 +213,8 @@ export class RepeatableQuestRewardGenerator
if (roublesBudget > 0) if (roublesBudget > 0)
{ {
// Filter possible reward items to only items with a price below the remaining budget // Filter possible reward items to only items with a price below the remaining budget
if (!this.filterRewardPoolWithinBudget(rewardItemPool, roublesBudget, 0)) rewardItemPool = this.filterRewardPoolWithinBudget(rewardItemPool, roublesBudget, 0);
if (rewardItemPool.length === 0)
{ {
this.logger.debug(` Reward pool empty with ${roublesBudget} remaining`); this.logger.debug(` Reward pool empty with ${roublesBudget} remaining`);
break; // No reward items left, exit break; // No reward items left, exit
@ -269,15 +270,13 @@ export class RepeatableQuestRewardGenerator
rewardItems: ITemplateItem[], rewardItems: ITemplateItem[],
roublesBudget: number, roublesBudget: number,
minPrice: number, minPrice: number,
): boolean ): ITemplateItem[]
{ {
rewardItems.filter((item) => return rewardItems.filter((item) =>
{ {
const itemPrice = this.presetHelper.getDefaultPresetOrItemPrice(item._id); const itemPrice = this.presetHelper.getDefaultPresetOrItemPrice(item._id);
return itemPrice < roublesBudget && itemPrice > minPrice; return itemPrice < roublesBudget && itemPrice > minPrice;
}); });
return (rewardItems.length > 0);
} }
/** /**
@ -357,7 +356,12 @@ export class RepeatableQuestRewardGenerator
const minPrice = Math.min(25000, 0.5 * roublesBudget); const minPrice = Math.min(25000, 0.5 * roublesBudget);
let rewardableItemPoolWithinBudget = rewardableItemPool.map((x) => x[1]); let rewardableItemPoolWithinBudget = rewardableItemPool.map((x) => x[1]);
if (!this.filterRewardPoolWithinBudget(rewardableItemPoolWithinBudget, roublesBudget, minPrice)) rewardableItemPoolWithinBudget = this.filterRewardPoolWithinBudget(
rewardableItemPoolWithinBudget,
roublesBudget,
minPrice,
);
if (rewardableItemPoolWithinBudget.length === 0)
{ {
this.logger.warning( this.logger.warning(
this.localisationService.getText("repeatable-no_reward_item_found_in_price_range", { this.localisationService.getText("repeatable-no_reward_item_found_in_price_range", {