diff --git a/src/services/questService.ts b/src/services/questService.ts index e53126c5..1916ca0c 100644 --- a/src/services/questService.ts +++ b/src/services/questService.ts @@ -22,10 +22,10 @@ export const updateQuestKey = ( throw new Error("more than 1 quest key not supported"); } - const questKeyIndex = inventory.QuestKeys.findIndex(questKey => questKey.ItemType === questKeyUpdate[0].ItemType); - + let questKeyIndex = inventory.QuestKeys.findIndex(questKey => questKey.ItemType === questKeyUpdate[0].ItemType); if (questKeyIndex === -1) { - throw new Error(`quest key ${questKeyUpdate[0].ItemType} not found`); + // it's possible the quest key was not in already in the inventory but the quest was still available due to unlockAllQuests + questKeyIndex = inventory.QuestKeys.push({ ItemType: questKeyUpdate[0].ItemType }) - 1; } inventory.QuestKeys[questKeyIndex] = questKeyUpdate[0];