From 9d8318f9d6105be1b0367cba8ceb638808d56bd6 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Mon, 21 Apr 2025 01:28:09 +0200 Subject: [PATCH 1/2] add doesQuestCompletionFinishSet --- src/services/questService.ts | 29 +++++++++++++++++++++++------ 1 file changed, 23 insertions(+), 6 deletions(-) diff --git a/src/services/questService.ts b/src/services/questService.ts index d5ac28dc..d0da6788 100644 --- a/src/services/questService.ts +++ b/src/services/questService.ts @@ -191,6 +191,25 @@ const getQuestCompletionItems = (questKey: string): ITypeCount[] | undefined => return items; }; +// Checks that `questKey` is in `requirements`, and if so, that all other quests in `requirements` are also already completed. +const doesQuestCompletionFinishSet = ( + inventory: TInventoryDatabaseDocument, + questKey: string, + requirements: string[] +): boolean => { + let holds = false; + for (const requirement of requirements) { + if (questKey == requirement) { + holds = true; + } else { + if (!inventory.QuestKeys.find(x => x.ItemType == requirement)?.Completed) { + return false; + } + } + } + return holds; +}; + const handleQuestCompletion = async ( inventory: TInventoryDatabaseDocument, questKey: string, @@ -218,12 +237,10 @@ const handleQuestCompletion = async ( // Whispers in the Walls is unlocked once The New + Heart of Deimos are completed. if ( - (questKey == "/Lotus/Types/Keys/NewWarQuest/NewWarQuestKeyChain" && - inventory.QuestKeys.find( - x => x.ItemType == "/Lotus/Types/Keys/InfestedMicroplanetQuest/InfestedMicroplanetQuestKeyChain" - )?.Completed) || - (questKey == "/Lotus/Types/Keys/InfestedMicroplanetQuest/InfestedMicroplanetQuestKeyChain" && - inventory.QuestKeys.find(x => x.ItemType == "/Lotus/Types/Keys/NewWarQuest/NewWarQuestKeyChain")?.Completed) + doesQuestCompletionFinishSet(inventory, questKey, [ + "/Lotus/Types/Keys/NewWarQuest/NewWarQuestKeyChain", + "/Lotus/Types/Keys/InfestedMicroplanetQuest/InfestedMicroplanetQuestKeyChain" + ]) ) { await createMessage(inventory.accountOwnerId, [ { -- 2.47.2 From 5dc25c6f206d550e1a684cda5247dad2e13a95d6 Mon Sep 17 00:00:00 2001 From: Sainan <63328889+Sainan@users.noreply.github.com> Date: Mon, 21 Apr 2025 01:29:52 +0200 Subject: [PATCH 2/2] unlock the hex quest when the lotus eaters + duviri paradox are done --- src/services/questService.ts | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/src/services/questService.ts b/src/services/questService.ts index d0da6788..053f6eb4 100644 --- a/src/services/questService.ts +++ b/src/services/questService.ts @@ -254,6 +254,25 @@ const handleQuestCompletion = async ( ]); } + // The Hex (Quest) is unlocked once The Lotus Eaters + The Duviri Paradox are completed. + if ( + doesQuestCompletionFinishSet(inventory, questKey, [ + "/Lotus/Types/Keys/1999PrologueQuest/1999PrologueQuestKeyChain", + "/Lotus/Types/Keys/DuviriQuest/DuviriQuestKeyChain" + ]) + ) { + await createMessage(inventory.accountOwnerId, [ + { + sndr: "/Lotus/Language/NewWar/P3M1ChooseMara", + msg: "/Lotus/Language/1999Quest/1999QuestInboxBody", + att: ["/Lotus/Types/Keys/1999Quest/1999QuestKeyChain"], + sub: "/Lotus/Language/1999Quest/1999QuestInboxSubject", + icon: "/Lotus/Interface/Icons/Npcs/Operator.png", + highPriority: true + } + ]); + } + const questCompletionItems = getQuestCompletionItems(questKey); logger.debug(`quest completion items`, questCompletionItems); if (questCompletionItems) { -- 2.47.2