fix: don't abort quest update when quest completion rewards are missing. (#937)
All checks were successful
Build / build (22) (push) Successful in 34s
Build / build (20) (push) Successful in 54s
Build Docker image / docker (push) Successful in 31s
Build / build (18) (push) Successful in 1m20s

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: #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); const questCompletionItems = getQuestCompletionItems(questKeyName);
logger.debug(`quest completion items`, questCompletionItems); 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 = ""; inventory.ActiveQuest = "";
updateQuestResponse.InventoryChanges = inventoryChanges;
} }
//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

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;
}; };