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

Temporary fix until quest completion items are added. This is wip.
Your account has to own the quest keys for the quest system to work.

Reviewed-on: OpenWF/SpaceNinjaServer#937
Co-authored-by: Ordis <134585663+OrdisPrime@users.noreply.github.com>
Co-committed-by: Ordis <134585663+OrdisPrime@users.noreply.github.com>
This commit is contained in:
Ordis 2025-02-09 14:37:25 -08:00 committed by OrdisPrime
parent a03c987f69
commit 30061fb0e3
2 changed files with 10 additions and 7 deletions

View File

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

View File

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