fix: don't abort quest update when quest completion rewards are missing. #937

Merged
OrdisPrime merged 1 commits from quest-progression into main 2025-02-09 14:37:26 -08:00
2 changed files with 10 additions and 7 deletions

View File

@ -30,11 +30,12 @@ export const updateQuestController: RequestHandler = async (req, res) => {
const questCompletionItems = getQuestCompletionItems(questKeyName); const questCompletionItems = getQuestCompletionItems(questKeyName);
logger.debug(`quest completion items`, questCompletionItems); logger.debug(`quest completion items`, questCompletionItems);
if (questCompletionItems) {
const inventoryChanges = await addItems(inventory, questCompletionItems); const inventoryChanges = await addItems(inventory, questCompletionItems);
inventory.ActiveQuest = "";
updateQuestResponse.InventoryChanges = inventoryChanges; updateQuestResponse.InventoryChanges = inventoryChanges;
} }
inventory.ActiveQuest = "";
}
//TODO: might need to parse the custom data and add the associated items to inventory //TODO: might need to parse the custom data and add the associated items to inventory
if (updateQuestRequest.QuestKeys[0].CustomData) { if (updateQuestRequest.QuestKeys[0].CustomData) {

View File

@ -189,11 +189,13 @@ export const getNode = (nodeName: string): IRegion => {
}; };
export const getQuestCompletionItems = (questKey: string) => { export const getQuestCompletionItems = (questKey: string) => {
const items = (questCompletionItems as unknown as Record<string, ITypeCount[] | undefined>)[questKey]; const items = (questCompletionItems as unknown as Record<string, ITypeCount[]> | undefined)?.[questKey];
if (!items) {
throw new Error(`Quest ${questKey} not found in questCompletionItems`);
}
if (!items) {
logger.error(
`Quest ${questKey} not found in questCompletionItems, quest completion items have not been given. This is a temporary solution`
);
}
return items; return items;
}; };