Fix issue with scav case rewards failing + made function reward level handling more robust

This commit is contained in:
Dev 2023-05-22 12:25:19 +01:00
parent 682e87e446
commit 2f919c795c
2 changed files with 14 additions and 14 deletions

View File

@ -55,14 +55,14 @@ export class ScavCaseRewardGenerator
const dbItems = this.getDbItems(); const dbItems = this.getDbItems();
// Get items that fit the price criteria as set by the scavCase config // Get items that fit the price criteria as set by the scavCase config
const commonPricedItems = this.getFilteredItemsByPrice(dbItems, rewardItemCounts.common); const commonPricedItems = this.getFilteredItemsByPrice(dbItems, rewardItemCounts.Common);
const rarePricedItems = this.getFilteredItemsByPrice(dbItems, rewardItemCounts.rare); const rarePricedItems = this.getFilteredItemsByPrice(dbItems, rewardItemCounts.Rare);
const superRarePricedItems = this.getFilteredItemsByPrice(dbItems, rewardItemCounts.superrare); const superRarePricedItems = this.getFilteredItemsByPrice(dbItems, rewardItemCounts.Superrare);
// Get randomly picked items from each item collction, the count range of which is defined in hideout/scavcase.json // Get randomly picked items from each item collction, the count range of which is defined in hideout/scavcase.json
const randomlyPickedCommonRewards = this.pickRandomRewards(commonPricedItems, rewardItemCounts.common, "common"); const randomlyPickedCommonRewards = this.pickRandomRewards(commonPricedItems, rewardItemCounts.Common, "common");
const randomlyPickedRareRewards = this.pickRandomRewards(rarePricedItems, rewardItemCounts.rare, "rare"); const randomlyPickedRareRewards = this.pickRandomRewards(rarePricedItems, rewardItemCounts.Rare, "rare");
const randomlyPickedSuperRareRewards = this.pickRandomRewards(superRarePricedItems, rewardItemCounts.superrare, "superrare"); const randomlyPickedSuperRareRewards = this.pickRandomRewards(superRarePricedItems, rewardItemCounts.Superrare, "superrare");
// Add randomised stack sizes to ammo and money rewards // Add randomised stack sizes to ammo and money rewards
const commonRewards = this.randomiseContainerItemRewards(randomlyPickedCommonRewards, "common"); const commonRewards = this.randomiseContainerItemRewards(randomlyPickedCommonRewards, "common");
@ -269,14 +269,14 @@ export class ScavCaseRewardGenerator
} }
/** /**
* Gathers the reward options from config and scavcase.json into a single object * Gathers the reward min and max count params for each reward quality level from config and scavcase.json into a single object
* @param scavCaseDetails scavcase.json values * @param scavCaseDetails scavcase.json values
* @returns ScavCaseRewardCountsAndPrices object * @returns ScavCaseRewardCountsAndPrices object
*/ */
protected getScavCaseRewardCountsAndPrices(scavCaseDetails: IHideoutScavCase): ScavCaseRewardCountsAndPrices protected getScavCaseRewardCountsAndPrices(scavCaseDetails: IHideoutScavCase): ScavCaseRewardCountsAndPrices
{ {
const rewardTypes: (keyof ScavCaseRewardCountsAndPrices)[] = ["common", "rare", "superrare"]; const rewardTypes = Object.keys(scavCaseDetails.EndProducts) as Array<keyof ScavCaseRewardCountsAndPrices>; // Default is ["Common", "Rare", "Superrare"];
const result: Partial<ScavCaseRewardCountsAndPrices> = {}; const result: Partial<ScavCaseRewardCountsAndPrices> = {}; // Make partial object as we're going to add all the data immediately after
// Create reward min/max counts for each type // Create reward min/max counts for each type
for (const rewardType of rewardTypes) for (const rewardType of rewardTypes)
@ -285,8 +285,8 @@ export class ScavCaseRewardGenerator
{ {
minCount: scavCaseDetails.EndProducts[rewardType].min, minCount: scavCaseDetails.EndProducts[rewardType].min,
maxCount: scavCaseDetails.EndProducts[rewardType].max, maxCount: scavCaseDetails.EndProducts[rewardType].max,
minPriceRub: this.scavCaseConfig.rewardItemValueRangeRub[rewardType].min, minPriceRub: this.scavCaseConfig.rewardItemValueRangeRub[rewardType.toLowerCase()].min,
maxPriceRub: this.scavCaseConfig.rewardItemValueRangeRub[rewardType].max maxPriceRub: this.scavCaseConfig.rewardItemValueRangeRub[rewardType.toLowerCase()].max
}; };
} }

View File

@ -1,8 +1,8 @@
export interface ScavCaseRewardCountsAndPrices export interface ScavCaseRewardCountsAndPrices
{ {
common: RewardCountAndPriceDetails, Common: RewardCountAndPriceDetails,
rare: RewardCountAndPriceDetails, Rare: RewardCountAndPriceDetails,
superrare: RewardCountAndPriceDetails Superrare: RewardCountAndPriceDetails
} }
export interface RewardCountAndPriceDetails export interface RewardCountAndPriceDetails