From aeb208e7770ed61d9f92c982fcf0e62b7199a827 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Thu, 24 Jul 2025 13:58:29 +0200 Subject: [PATCH] Fixed reroll correcting automation hope/fear/stress --- module/applications/ui/chatLog.mjs | 9 ++++++--- module/dice/dhRoll.mjs | 5 +++++ module/dice/dualityRoll.mjs | 6 ++++++ 3 files changed, 17 insertions(+), 3 deletions(-) diff --git a/module/applications/ui/chatLog.mjs b/module/applications/ui/chatLog.mjs index bcdff961..19834680 100644 --- a/module/applications/ui/chatLog.mjs +++ b/module/applications/ui/chatLog.mjs @@ -47,13 +47,13 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo element.addEventListener('click', this.onToggleTargets) ); html.querySelectorAll('.ability-use-button').forEach(element => - element.addEventListener('click', event => this.abilityUseButton(this, event, data.message)) + element.addEventListener('click', event => this.abilityUseButton(event, data.message)) ); html.querySelectorAll('.action-use-button').forEach(element => - element.addEventListener('click', event => this.actionUseButton(this, event, data.message)) + element.addEventListener('click', event => this.actionUseButton(event, data.message)) ); html.querySelectorAll('.reroll-button').forEach(element => - element.addEventListener('click', event => this.rerollEvent(this, event, data.message)) + element.addEventListener('click', event => this.rerollEvent(event, data.message)) ); }; @@ -287,6 +287,9 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo game.system.api.dice[ message.type === 'dualityRoll' ? 'DualityRoll' : target.dataset.type === 'damage' ? 'DHRoll' : 'D20Roll' ]; + + if (!game.modules.get('dice-so-nice')?.active) foundry.audio.AudioHelper.play({ src: CONFIG.sounds.dice }); + const { newRoll, parsedRoll } = await rollClass.reroll(originalRoll_parsed, target, message); await game.messages.get(message._id).update({ diff --git a/module/dice/dhRoll.mjs b/module/dice/dhRoll.mjs index c50c126a..52759316 100644 --- a/module/dice/dhRoll.mjs +++ b/module/dice/dhRoll.mjs @@ -193,6 +193,11 @@ export const registerRollDiceHooks = () => { if (config.roll.isCritical) updates.push({ key: 'stress', value: -1 }); if (config.roll.result.duality === -1) updates.push({ key: 'fear', value: 1 }); + if (config.rerolledRoll.isCritical || config.rerolledRoll.result.duality === 1) + updates.push({ key: 'hope', value: -1 }); + if (config.rerolledRoll.isCritical) updates.push({ key: 'stress', value: 1 }); + if (config.rerolledRoll.result.duality === -1) updates.push({ key: 'fear', value: -1 }); + if (updates.length) { const target = actor.system.partner ?? actor; if (!['dead', 'unconcious'].some(x => actor.statuses.has(x))) { diff --git a/module/dice/dualityRoll.mjs b/module/dice/dualityRoll.mjs index 151d63df..91f2456c 100644 --- a/module/dice/dualityRoll.mjs +++ b/module/dice/dualityRoll.mjs @@ -232,6 +232,12 @@ export default class DualityRoll extends D20Roll { }); newRoll.extra = newRoll.extra.slice(2); + Hooks.call(`${CONFIG.DH.id}.postRollDuality`, { + source: { actor: message.system.source.actor ?? '' }, + targets: message.system.targets, + roll: newRoll, + rerolledRoll: message.system.roll + }); return { newRoll, parsedRoll }; } }