From 76d8b944d51a58dc311a59ab4e961c241bc1c0a5 Mon Sep 17 00:00:00 2001 From: Dev Date: Tue, 10 Oct 2023 16:18:55 +0100 Subject: [PATCH] Store `AvailableAfter value in statusTimer of timelocked quest Send locked quest to client when requested Delete `availableAfter` property when accepting a quest --- project/src/controllers/QuestController.ts | 15 +++++++++------ project/src/helpers/QuestHelper.ts | 5 +++++ 2 files changed, 14 insertions(+), 6 deletions(-) diff --git a/project/src/controllers/QuestController.ts b/project/src/controllers/QuestController.ts index 68c045a8..57dc9343 100644 --- a/project/src/controllers/QuestController.ts +++ b/project/src/controllers/QuestController.ts @@ -145,8 +145,6 @@ export class QuestController if (unlockTime > this.timeUtil.getTimestamp()) { this.logger.debug(`Quest ${quest.QuestName} is locked for another ${unlockTime - this.timeUtil.getTimestamp()} seconds`); - haveCompletedPreviousQuest = false; - break; } } } @@ -435,11 +433,13 @@ export class QuestController // Add diff of quests before completion vs after for client response const questDelta = this.questHelper.getDeltaQuests(beforeQuests, this.getClientQuests(sessionID)); - completeQuestResponse.profileChanges[sessionID].quests = questDelta; - - // Send newly available + failed quests into function + + // Check newly available + failed quests for timegates and add them to profile this.addTimeLockedQuestsToProfile(pmcData, [...questDelta, ...questsToFail], body.qid); + // Inform client of quest changes + completeQuestResponse.profileChanges[sessionID].quests = questDelta; + // Check if it's a repeatable quest. If so, remove from Quests and repeatable.activeQuests list + move to repeatable.inactiveQuests for (const currentRepeatable of pmcData.RepeatableQuests) { @@ -546,7 +546,10 @@ export class QuestController qid: quest._id, startTime: 0, status: QuestStatus.AvailableAfter, - statusTimers: {}, + statusTimers: { + // eslint-disable-next-line @typescript-eslint/naming-convention + "9": this.timeUtil.getTimestamp() + }, availableAfter: availableAfterTimestamp }); } diff --git a/project/src/helpers/QuestHelper.ts b/project/src/helpers/QuestHelper.ts index 62e18b4b..3e34fa88 100644 --- a/project/src/helpers/QuestHelper.ts +++ b/project/src/helpers/QuestHelper.ts @@ -328,6 +328,11 @@ export class QuestHelper existingQuest.statusTimers[newState] = this.timeUtil.getTimestamp(); existingQuest.completedConditions = []; + if (existingQuest.availableAfter) + { + delete existingQuest.availableAfter; + } + return existingQuest; }