From 86b651cc11833497646cefb64d9071375307a545 Mon Sep 17 00:00:00 2001 From: Dapoolp Date: Sat, 26 Jul 2025 14:40:34 +0200 Subject: [PATCH] Fix async/await roll postEvaluate --- module/dice/d20Roll.mjs | 6 +++--- module/dice/damageRoll.mjs | 4 ++-- module/dice/dhRoll.mjs | 4 ++-- module/dice/dualityRoll.mjs | 26 +++++++++++++++----------- 4 files changed, 22 insertions(+), 18 deletions(-) diff --git a/module/dice/d20Roll.mjs b/module/dice/d20Roll.mjs index bee7717c..ce400110 100644 --- a/module/dice/d20Roll.mjs +++ b/module/dice/d20Roll.mjs @@ -140,8 +140,8 @@ export default class D20Roll extends DHRoll { return modifiers; } - static async postEvaluate(roll, config = {}) { - const data = await super.postEvaluate(roll, config); + static postEvaluate(roll, config = {}) { + const data = super.postEvaluate(roll, config); if (config.targets?.length) { config.targets.forEach(target => { const difficulty = config.roll.difficulty ?? target.difficulty ?? target.evasion; @@ -184,7 +184,7 @@ export default class D20Roll extends DHRoll { static async reroll(rollString, _target, message) { let parsedRoll = game.system.api.dice.D20Roll.fromData(rollString); parsedRoll = await parsedRoll.reroll(); - const newRoll = await game.system.api.dice.D20Roll.postEvaluate(parsedRoll, { + const newRoll = game.system.api.dice.D20Roll.postEvaluate(parsedRoll, { targets: message.system.targets, roll: { advantage: message.system.roll.advantage?.type, diff --git a/module/dice/damageRoll.mjs b/module/dice/damageRoll.mjs index 6c99dae4..48313c5b 100644 --- a/module/dice/damageRoll.mjs +++ b/module/dice/damageRoll.mjs @@ -25,10 +25,10 @@ export default class DamageRoll extends DHRoll { config.roll = this.unifyDamageRoll(parts); } - static async postEvaluate(roll, config = {}) { + static postEvaluate(roll, config = {}) { return { ...roll, - ...(await super.postEvaluate(roll.roll, config)), + ...super.postEvaluate(roll.roll, config), damageTypes: [...(roll.damageTypes ?? [])], roll: roll.roll, type: config.type, diff --git a/module/dice/dhRoll.mjs b/module/dice/dhRoll.mjs index 3236710b..4bc1a5bd 100644 --- a/module/dice/dhRoll.mjs +++ b/module/dice/dhRoll.mjs @@ -47,7 +47,7 @@ export default class DHRoll extends Roll { static async buildEvaluate(roll, config = {}, message = {}) { if (config.evaluate !== false) await roll.evaluate(); - config.roll = await this.postEvaluate(roll, config); + config.roll = this.postEvaluate(roll, config); } static async buildPost(roll, config, message) { @@ -67,7 +67,7 @@ export default class DHRoll extends Roll { } else config.message = await this.toMessage(roll, config); } - static async postEvaluate(roll, config = {}) { + static postEvaluate(roll, config = {}) { return { total: roll.total, formula: roll.formula, diff --git a/module/dice/dualityRoll.mjs b/module/dice/dualityRoll.mjs index c229999e..bb982b9c 100644 --- a/module/dice/dualityRoll.mjs +++ b/module/dice/dualityRoll.mjs @@ -166,8 +166,20 @@ export default class DualityRoll extends D20Roll { return modifiers; } - static async postEvaluate(roll, config = {}) { - const data = await super.postEvaluate(roll, config); + static async buildEvaluate(roll, config = {}, message = {}) { + await super.buildEvaluate(roll, config, message); + + await setDiceSoNiceForDualityRoll( + roll, + config.roll.advantage.type, + config.roll.hope.dice, + config.roll.fear.dice, + config.roll.advantage.dice + ); + } + + static postEvaluate(roll, config = {}) { + const data = super.postEvaluate(roll, config); data.hope = { dice: roll.dHope.denomination, @@ -198,14 +210,6 @@ export default class DualityRoll extends D20Roll { if (roll._rallyIndex && roll.data?.parent) roll.data.parent.deleteEmbeddedDocuments('ActiveEffect', [roll._rallyIndex]); - await setDiceSoNiceForDualityRoll( - roll, - data.advantage.type, - data.hope.dice, - data.fear.dice, - data.advantage.dice - ); - return data; } @@ -237,7 +241,7 @@ export default class DualityRoll extends D20Roll { await parsedRoll.evaluate(); - const newRoll = await game.system.api.dice.DualityRoll.postEvaluate(parsedRoll, { + const newRoll = game.system.api.dice.DualityRoll.postEvaluate(parsedRoll, { targets: message.system.targets, roll: { advantage: message.system.roll.advantage?.type,