Moved quest reward game edition checks into own function

This commit is contained in:
Dev 2024-10-31 10:55:06 +00:00
parent 2204181363
commit 554aceda26

View File

@ -932,10 +932,7 @@ export class QuestHelper {
const gameVersion = pmcProfile.Info.GameVersion;
for (const reward of <IQuestReward[]>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