diff --git a/module/documents/roll-prompt.mjs b/module/documents/roll-prompt.mjs index bba33b2..59e10ab 100644 --- a/module/documents/roll-prompt.mjs +++ b/module/documents/roll-prompt.mjs @@ -570,6 +570,10 @@ export async function prompt(options = {}) { rollBase.options.D30result = options.D30result rollBase.options.D30message = options.D30message rollBase.options.badResult = badResult + rollBase.options.rollType = options.rollType + rollBase.options.actorId = options.actorId + rollBase.options.actorName = options.actorName + rollBase.options.actorImage = options.actorImage rollBase.options.rollData = foundry.utils.duplicate(rollData) rollBase.options.defenderId = options.defenderId rollBase.options.defenderTokenId = options.defenderTokenId diff --git a/module/hooks/chat-reaction.mjs b/module/hooks/chat-reaction.mjs index 1fc7c8d..4e78bf8 100644 --- a/module/hooks/chat-reaction.mjs +++ b/module/hooks/chat-reaction.mjs @@ -549,7 +549,6 @@ Hooks.on("createChatMessage", async (message) => { if (choice === "rerollDefense" && canRerollDefense) { const oldDefenseRoll = defenseRoll const reroll = await LethalFantasyUtils.rerollConfiguredRoll(defenseRerollContext) - canRerollDefense = false if (!reroll) continue defenseRoll = reroll.options?.rollTotal || reroll.total || oldDefenseRoll try { @@ -566,12 +565,13 @@ Hooks.on("createChatMessage", async (message) => { } catch(e) { console.error("Mulligan message creation failed (non-fatal):", e) } - // Apply new D30 result on the restart + // Apply new D30 result on the restart — the new D30 always takes effect, + // and if it's another mulligan the reroll button reappears. if (reroll.options?.D30message) { defenseD30message = reroll.options.D30message defenseD30Processed = false } - // Restart the full comparison so both sides can react to the new roll + canRerollDefense = LethalFantasyUtils.hasD30Reroll(defenseD30message) mulliganRestart = true break } @@ -755,7 +755,6 @@ Hooks.on("createChatMessage", async (message) => { if (choice === "rerollAttack" && canRerollAttack && attackRerollContext) { const oldAttackRoll = attackRollFinal const reroll = await LethalFantasyUtils.rerollConfiguredRoll(attackRerollContext) - canRerollAttack = false if (!reroll) continue attackRollFinal = reroll.options?.rollTotal || reroll.total || oldAttackRoll try { @@ -772,14 +771,14 @@ Hooks.on("createChatMessage", async (message) => { } catch(e) { console.error("Mulligan message creation failed (non-fatal):", e) } - // Apply new D30 result on the restart + // Apply new D30 result on the restart — the new D30 always takes effect, + // and if it's another mulligan the reroll button reappears. if (reroll.options?.D30message) { attackD30message = reroll.options.D30message attackD30Processed = false - // Invalidate pre-computed effects — the new D30 message must be processed fresh d30AttackPrecomputedStale = true } - // Restart the full comparison so both sides can react to the new roll + canRerollAttack = LethalFantasyUtils.hasD30Reroll(attackD30message) mulliganRestart = true break }