From ace726a1fc8f3da6168b15cc5c7fd248895a7bc4 Mon Sep 17 00:00:00 2001 From: LeRatierBretonnier Date: Sat, 13 Jun 2026 16:51:52 +0200 Subject: [PATCH] fix: use try/finally for spellDefense cleanup instead of delete delete on game.lethalFantasy.spellDefense was breaking roll flow on Foundry's proxied game object. Use try/finally with assignment to false instead, which is safe on any object type. Initialize saveSpell local var from one-shot flag so D30 chart lookup correctly uses arcane_spell_defense for spell saves without requiring user to click the pre-checked checkbox. --- module/documents/roll.mjs | 7 +++++-- 1 file changed, 5 insertions(+), 2 deletions(-) diff --git a/module/documents/roll.mjs b/module/documents/roll.mjs index ec55385..66216ca 100644 --- a/module/documents/roll.mjs +++ b/module/documents/roll.mjs @@ -127,6 +127,7 @@ export default class LethalFantasyRoll extends Roll { * @returns {Promise} The roll result or null if the dialog was cancelled. */ static async prompt(options = {}) { + try { let dice = "1D20" let maxValue = 20 let baseFormula = "1D20" @@ -140,8 +141,6 @@ export default class LethalFantasyRoll extends Roll { let pointBlank = false let letItFly = false let saveSpell = game.lethalFantasy?.spellDefense ?? false - // Consume one-shot flag so it doesn't leak to subsequent non-spell saves - if (game.lethalFantasy) delete game.lethalFantasy.spellDefense let beyondSkill = false let hasStaticModifier = false let hasExplode = true @@ -681,6 +680,10 @@ export default class LethalFantasyRoll extends Roll { if (Hooks.call("fvtt-lethal-fantasy.Roll", options, rollData, rollBase) === false) return return rollBase + } finally { + // Clear one-shot flag so it doesn't leak to subsequent non-spell saves + if (game.lethalFantasy) game.lethalFantasy.spellDefense = false + } } /* ***********************************************************/