From 554aceda26b9f4861a881f1b257f52eea6a2d07b Mon Sep 17 00:00:00 2001 From: Dev Date: Thu, 31 Oct 2024 10:55:06 +0000 Subject: [PATCH] Moved quest reward game edition checks into own function --- project/src/helpers/QuestHelper.ts | 26 ++++++++++++++++++++++---- 1 file changed, 22 insertions(+), 4 deletions(-) diff --git a/project/src/helpers/QuestHelper.ts b/project/src/helpers/QuestHelper.ts index 1d8bdf06..ffeb19f6 100644 --- a/project/src/helpers/QuestHelper.ts +++ b/project/src/helpers/QuestHelper.ts @@ -932,10 +932,7 @@ export class QuestHelper { const gameVersion = pmcProfile.Info.GameVersion; for (const reward of questDetails.rewards[questStateAsString]) { // Handle quest reward availability for different game versions, notAvailableInGameEditions currently not used - if (reward.availableInGameEditions?.length > 0 && !reward.availableInGameEditions?.includes(gameVersion)){ - continue; - } - if (reward.notAvailableInGameEditions?.length > 0 && reward.notAvailableInGameEditions?.includes(gameVersion)){ + if (!this.questRewardIsForGameEdition(reward, gameVersion)) { continue; } @@ -999,6 +996,27 @@ export class QuestHelper { return this.getQuestRewardItems(questDetails, state); } + /** + * Does the provided quest reward have a game version requirement to be given and does it match + * @param reward Reward to check + * @param gameVersion Version of game to check reward against + * @returns True if it has requirement, false if it doesnt pass check + */ + protected questRewardIsForGameEdition(reward: IQuestReward, gameVersion: string) { + if (reward.availableInGameEditions?.length > 0 && !reward.availableInGameEditions?.includes(gameVersion)) { + // Reward has edition whitelist and game version isnt in it + return false; + } + + if (reward.notAvailableInGameEditions?.length > 0 && reward.notAvailableInGameEditions?.includes(gameVersion)) { + // Reward has edition blacklist and game version is in it + return false; + } + + // No whitelist/blacklist or reward isnt blacklisted/whitelisted + return true; + } + /** * WIP - Find hideout craft id and add to unlockedProductionRecipe array in player profile * also update client response recipeUnlocked array with craft id