add doesQuestCompletionFinishSet
This commit is contained in:
parent
218df461e1
commit
9d8318f9d6
@ -191,6 +191,25 @@ const getQuestCompletionItems = (questKey: string): ITypeCount[] | undefined =>
|
|||||||
return items;
|
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 (
|
const handleQuestCompletion = async (
|
||||||
inventory: TInventoryDatabaseDocument,
|
inventory: TInventoryDatabaseDocument,
|
||||||
questKey: string,
|
questKey: string,
|
||||||
@ -218,12 +237,10 @@ const handleQuestCompletion = async (
|
|||||||
|
|
||||||
// Whispers in the Walls is unlocked once The New + Heart of Deimos are completed.
|
// Whispers in the Walls is unlocked once The New + Heart of Deimos are completed.
|
||||||
if (
|
if (
|
||||||
(questKey == "/Lotus/Types/Keys/NewWarQuest/NewWarQuestKeyChain" &&
|
doesQuestCompletionFinishSet(inventory, questKey, [
|
||||||
inventory.QuestKeys.find(
|
"/Lotus/Types/Keys/NewWarQuest/NewWarQuestKeyChain",
|
||||||
x => x.ItemType == "/Lotus/Types/Keys/InfestedMicroplanetQuest/InfestedMicroplanetQuestKeyChain"
|
"/Lotus/Types/Keys/InfestedMicroplanetQuest/InfestedMicroplanetQuestKeyChain"
|
||||||
)?.Completed) ||
|
])
|
||||||
(questKey == "/Lotus/Types/Keys/InfestedMicroplanetQuest/InfestedMicroplanetQuestKeyChain" &&
|
|
||||||
inventory.QuestKeys.find(x => x.ItemType == "/Lotus/Types/Keys/NewWarQuest/NewWarQuestKeyChain")?.Completed)
|
|
||||||
) {
|
) {
|
||||||
await createMessage(inventory.accountOwnerId, [
|
await createMessage(inventory.accountOwnerId, [
|
||||||
{
|
{
|
||||||
|
Loading…
x
Reference in New Issue
Block a user