From ceb36aaa80423e82435fa613c8adf4c384ee79e4 Mon Sep 17 00:00:00 2001 From: Stephanie Gredell Date: Sun, 7 Sep 2025 19:48:47 -0700 Subject: [PATCH] add error handling to relics --- src/engine/battle.js | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/engine/battle.js b/src/engine/battle.js index 8748e67..6057f78 100644 --- a/src/engine/battle.js +++ b/src/engine/battle.js @@ -282,7 +282,13 @@ export function makeBattleContext(root) { } export function attachRelics(root, relicIds) { - root.relicStates = relicIds.map(id => ({ id, hooks: RELICS[id].hooks || {}, state: structuredClone(RELICS[id].state || {}) })); + root.relicStates = relicIds.filter(id => { + if (!RELICS[id]) { + console.error(`Relic with ID '${id}' not found in RELICS data`); + return false; + } + return true; + }).map(id => ({ id, hooks: RELICS[id].hooks || {}, state: structuredClone(RELICS[id].state || {}) })); const relicCtx = { ...root,