From d18ef883dad8a0324a0039f80eba89b1625052b3 Mon Sep 17 00:00:00 2001 From: Dev Date: Fri, 13 Sep 2024 10:38:55 +0100 Subject: [PATCH] Add configurable craft time of cultist circle --- project/assets/configs/hideout.json | 12 +++++++ project/src/helpers/HideoutHelper.ts | 31 ++++++++++++++++++- .../src/models/spt/config/IHideoutConfig.ts | 7 +++++ 3 files changed, 49 insertions(+), 1 deletion(-) diff --git a/project/assets/configs/hideout.json b/project/assets/configs/hideout.json index 500ab337..50106891 100644 --- a/project/assets/configs/hideout.json +++ b/project/assets/configs/hideout.json @@ -16,6 +16,18 @@ "min": 0.7, "max": 1.4 }, + "craftTimeThreshholds": [ + { + "min": 1, + "max": 25000, + "timeSeconds": 21600 + },{ + "min": 25001, + "max": 99999999, + "timeSeconds": 43200 + } + ], + "craftTimeOverride": 40, "directRewards": { "66572c82ad599021091c6118": ["5c0e874186f7745dc7616606"], "66572be36a723f7f005a066e": ["5b3b713c5acfc4330140bd8d"], diff --git a/project/src/helpers/HideoutHelper.ts b/project/src/helpers/HideoutHelper.ts index 126e5e11..b80fe269 100644 --- a/project/src/helpers/HideoutHelper.ts +++ b/project/src/helpers/HideoutHelper.ts @@ -122,15 +122,44 @@ export class HideoutHelper { pmcData: IPmcData, recipeId: string, sacrificedItems: Item[], + rewardAmountRoubles: number, ): void { // TODO: hard coded 5 hour (18000) craft + no fuel use, where can we get this data - const cultistProduction = this.initProduction(recipeId, 30, false, true); + const cultistProduction = this.initProduction( + recipeId, + this.getCircleCraftTime(rewardAmountRoubles), + false, + true, + ); cultistProduction.GivenItemsInStart = sacrificedItems; // Add circle production to profile pmcData.Hideout.Production[recipeId] = cultistProduction; } + /** + * Get the circle craft time as seconds, value is based on reward item value + * @param rewardAmountRoubles Value of rewards in roubles + * @returns craft time seconds + */ + protected getCircleCraftTime(rewardAmountRoubles: number): number { + // Edge case, check if override exists + if (this.hideoutConfig.cultistCircle.craftTimeOverride !== -1) { + return this.hideoutConfig.cultistCircle.craftTimeOverride; + } + + const thresholds = this.hideoutConfig.cultistCircle.craftTimeThreshholds; + const matchingThreshold = thresholds.find( + (craftThreshold) => craftThreshold.min <= rewardAmountRoubles && craftThreshold.max >= rewardAmountRoubles, + ); + if (!matchingThreshold) { + // No craft time found, default to 12 hours + return this.timeUtil.getHoursAsSeconds(12); + } + + return matchingThreshold.timeSeconds; + } + /** * This convenience function initializes new Production Object * with all the constants. diff --git a/project/src/models/spt/config/IHideoutConfig.ts b/project/src/models/spt/config/IHideoutConfig.ts index 61dc853a..915e1fe1 100644 --- a/project/src/models/spt/config/IHideoutConfig.ts +++ b/project/src/models/spt/config/IHideoutConfig.ts @@ -20,6 +20,9 @@ export interface ICultistCircleSettings { maxRewardItemCount: number; maxAttemptsToPickRewardsWithinBudget: number; rewardPriceMultiplerMinMax: MinMax; + craftTimeThreshholds: CraftTimeThreshhold[]; + /** -1 means no override */ + craftTimeOverride: number; /** Specific reward pool when player sacrificed one specific item */ directRewards: Record; directRewardStackSize: Record; @@ -29,3 +32,7 @@ export interface ICultistCircleSettings { additionalRewardItemPool: string[]; currencyRewards: Record; } + +export interface CraftTimeThreshhold extends MinMax { + timeSeconds: number; +}