Skip to content

Commit

Permalink
Moved profile quest management code into its own function
Browse files Browse the repository at this point in the history
  • Loading branch information
Chomp committed Dec 12, 2024
1 parent dd5d26f commit 4b26200
Showing 1 changed file with 16 additions and 8 deletions.
24 changes: 16 additions & 8 deletions project/src/controllers/RepeatableQuestController.ts
Original file line number Diff line number Diff line change
Expand Up @@ -560,14 +560,7 @@ export class RepeatableQuestController {
`Removing: ${repeatableConfig.name} quest: ${questToReplace._id} from trader: ${questToReplace.traderId} as its been replaced`,
);

// Find quest we're replacing in pmc profile quests array and remove it
this.questHelper.findAndRemoveQuestFromArrayIfExists(questToReplace._id, pmcData.Quests);

// Find quest we're replacing in scav profile quests array and remove it
this.questHelper.findAndRemoveQuestFromArrayIfExists(
questToReplace._id,
fullProfile.characters.scav?.Quests ?? [],
);
this.removeQuestFromProfile(fullProfile, questToReplace._id);

// Add new quests replacement cost to profile
repeatablesOfTypeInProfile.changeRequirement[newRepeatableQuest._id] = {
Expand Down Expand Up @@ -612,6 +605,21 @@ export class RepeatableQuestController {
return output;
}

/**
* Remove the provided quest from pmc and scav character profiles
* @param fullProfile Profile to remove quest from
* @param questToReplaceId Quest id to remove from profile
*/
protected removeQuestFromProfile(fullProfile: ISptProfile, questToReplaceId: string): void {
// Find quest we're replacing in pmc profile quests array and remove it
this.questHelper.findAndRemoveQuestFromArrayIfExists(questToReplaceId, fullProfile.characters.pmc.Quests);

// Find quest we're replacing in scav profile quests array and remove it
if (fullProfile.characters.scav) {
this.questHelper.findAndRemoveQuestFromArrayIfExists(questToReplaceId, fullProfile.characters.scav.Quests);
}
}

/**
* Find a repeatable (daily/weekly/scav) from a players profile by its id
* @param questId Id of quest to find
Expand Down

0 comments on commit 4b26200

Please sign in to comment.