fix: use try/finally for spellDefense cleanup instead of delete
Release Creation / build (release) Successful in 47s
Release Creation / build (release) Successful in 47s
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.
This commit is contained in:
@@ -127,6 +127,7 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
* @returns {Promise<Object|null>} The roll result or null if the dialog was cancelled.
|
* @returns {Promise<Object|null>} The roll result or null if the dialog was cancelled.
|
||||||
*/
|
*/
|
||||||
static async prompt(options = {}) {
|
static async prompt(options = {}) {
|
||||||
|
try {
|
||||||
let dice = "1D20"
|
let dice = "1D20"
|
||||||
let maxValue = 20
|
let maxValue = 20
|
||||||
let baseFormula = "1D20"
|
let baseFormula = "1D20"
|
||||||
@@ -140,8 +141,6 @@ export default class LethalFantasyRoll extends Roll {
|
|||||||
let pointBlank = false
|
let pointBlank = false
|
||||||
let letItFly = false
|
let letItFly = false
|
||||||
let saveSpell = game.lethalFantasy?.spellDefense ?? 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 beyondSkill = false
|
||||||
let hasStaticModifier = false
|
let hasStaticModifier = false
|
||||||
let hasExplode = true
|
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
|
if (Hooks.call("fvtt-lethal-fantasy.Roll", options, rollData, rollBase) === false) return
|
||||||
|
|
||||||
return rollBase
|
return rollBase
|
||||||
|
} finally {
|
||||||
|
// Clear one-shot flag so it doesn't leak to subsequent non-spell saves
|
||||||
|
if (game.lethalFantasy) game.lethalFantasy.spellDefense = false
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/* ***********************************************************/
|
/* ***********************************************************/
|
||||||
|
|||||||
Reference in New Issue
Block a user