Refactor ScavCaseRewardGenerator.getScavCaseRewardCountsAndPrices()

This commit is contained in:
Dev 2023-05-19 17:40:06 +01:00
parent dcd1da28a6
commit 08f2bdb27e
2 changed files with 23 additions and 20 deletions

View File

@ -275,26 +275,22 @@ export class ScavCaseRewardGenerator
*/ */
protected getScavCaseRewardCountsAndPrices(scavCaseDetails: IHideoutScavCase): ScavCaseRewardCountsAndPrices protected getScavCaseRewardCountsAndPrices(scavCaseDetails: IHideoutScavCase): ScavCaseRewardCountsAndPrices
{ {
return { const rewardTypes: (keyof ScavCaseRewardCountsAndPrices)[] = ["common", "rare", "superrare"];
common: { const result: Partial<ScavCaseRewardCountsAndPrices> = {};
minCount: scavCaseDetails.EndProducts["Common"].min,
maxCount: scavCaseDetails.EndProducts["Common"].max, // Create reward min/max counts for each type
minPriceRub: this.scavCaseConfig.rewardItemValueRangeRub["common"].min, for (const rewardType of rewardTypes)
maxPriceRub: this.scavCaseConfig.rewardItemValueRangeRub["common"].max {
}, result[rewardType] =
rare: { {
minCount: scavCaseDetails.EndProducts["Rare"].min, minCount: scavCaseDetails.EndProducts[rewardType].min,
maxCount: scavCaseDetails.EndProducts["Rare"].max, maxCount: scavCaseDetails.EndProducts[rewardType].max,
minPriceRub: this.scavCaseConfig.rewardItemValueRangeRub["rare"].min, minPriceRub: this.scavCaseConfig.rewardItemValueRangeRub[rewardType].min,
maxPriceRub: this.scavCaseConfig.rewardItemValueRangeRub["rare"].max maxPriceRub: this.scavCaseConfig.rewardItemValueRangeRub[rewardType].max
}, };
superrare: { }
minCount: scavCaseDetails.EndProducts["Superrare"].min,
maxCount: scavCaseDetails.EndProducts["Superrare"].max, return result as ScavCaseRewardCountsAndPrices;
minPriceRub: this.scavCaseConfig.rewardItemValueRangeRub["superrare"].min,
maxPriceRub: this.scavCaseConfig.rewardItemValueRangeRub["superrare"].max
}
};
} }
/** /**

View File

@ -241,6 +241,13 @@ class ItemHelper
return [false, undefined]; return [false, undefined];
} }
public isItemInDb(tpl: string): boolean
{
const itemDetails = this.getItem(tpl);
return itemDetails[0];
}
/** /**
* get normalized value (0-1) based on item condition * get normalized value (0-1) based on item condition
* @param item * @param item