mirror of
https://github.com/sp-tarkov/server.git
synced 2025-02-12 15:50:42 -05:00
Added code to handle cleaning up of repeatable change requirements
This commit is contained in:
parent
8f001ff8f0
commit
cf6868b3b9
@ -562,7 +562,10 @@ export class RepeatableQuestController {
|
||||
|
||||
this.removeQuestFromProfile(fullProfile, questToReplace._id);
|
||||
|
||||
// Add new quests replacement cost to profile
|
||||
// Delete the replaced quest change requirement from profile
|
||||
this.cleanUpRepeatableChangeRequirements(repeatablesOfTypeInProfile, questToReplace._id);
|
||||
|
||||
// Add replacement quests change requirement data to profile
|
||||
repeatablesOfTypeInProfile.changeRequirement[newRepeatableQuest._id] = {
|
||||
changeCost: newRepeatableQuest.changeCost,
|
||||
changeStandingCost: this.randomUtil.getArrayValue([0, 0.01]),
|
||||
@ -620,6 +623,25 @@ export class RepeatableQuestController {
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Clean up the repeatables `changeRequirement` dictionary of expired data
|
||||
* @param repeatablesOfTypeInProfile The repeatables that have the replaced and new quest
|
||||
* @param replacedQuestId Id of the replaced quest
|
||||
*/
|
||||
protected cleanUpRepeatableChangeRequirements(
|
||||
repeatablesOfTypeInProfile: IPmcDataRepeatableQuest,
|
||||
replacedQuestId: string,
|
||||
): void {
|
||||
if (repeatablesOfTypeInProfile.activeQuests.length === 1) {
|
||||
// Only one repeatable quest being replaced (e.g. scav_daily), remove everything ready for new quest requirement to be added
|
||||
// Will assist in cleanup of existing profiles data
|
||||
repeatablesOfTypeInProfile.changeRequirement = {};
|
||||
} else {
|
||||
// Multiple active quests of this type (e.g. daily or weekly) are active, just remove the single replaced quest
|
||||
delete repeatablesOfTypeInProfile.changeRequirement[replacedQuestId];
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* Find a repeatable (daily/weekly/scav) from a players profile by its id
|
||||
* @param questId Id of quest to find
|
||||
|
Loading…
x
Reference in New Issue
Block a user