From f91994a62ee635ac843e26b0a52f1a6ae3a87ad0 Mon Sep 17 00:00:00 2001 From: Nikhil Nagarajan Date: Thu, 10 Jul 2025 10:58:28 -0400 Subject: [PATCH] Troubleshooting Created test button in 'duality-roll.hbs' and functionality in chatLog.mjs --- module/applications/ui/chatLog.mjs | 20 ++++++++++++++++++++ templates/ui/chat/duality-roll.hbs | 3 +++ 2 files changed, 23 insertions(+) diff --git a/module/applications/ui/chatLog.mjs b/module/applications/ui/chatLog.mjs index d17c26dc..38c28241 100644 --- a/module/applications/ui/chatLog.mjs +++ b/module/applications/ui/chatLog.mjs @@ -58,6 +58,9 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo html.querySelectorAll('.action-use-button').forEach(element => element.addEventListener('click', event => this.actionUseButton.call(this, event, data.message)) ); + html.querySelectorAll('.reroll-button').forEach(element => + element.addEventListener('click', event => this.rerollEvent.call(this, event, data.message)) + ); }; setupHooks() { @@ -297,4 +300,21 @@ export default class DhpChatLog extends foundry.applications.sidebar.tabs.ChatLo action.use(); }; + + //Reroll Functionality + rerollEvent = async(_,event,message)=> { + const originalMessage = message; + + if (originalMessage && originalMessage.isRoll) { + console.log("Reroll button clicked for message:", originalMessage.id); + + // Rerolling the original roll and send it to chat. + originalMessage.roll.reroll().then(newRoll => { + newRoll.toMessage({ + speaker: ChatMessage.getSpeaker({ actor: originalMessage.speaker.actor }), + flavor: `(Reroll) ${originalMessage.flavor}` + }); + }); + } + } } diff --git a/templates/ui/chat/duality-roll.hbs b/templates/ui/chat/duality-roll.hbs index 4242c515..397bfe50 100644 --- a/templates/ui/chat/duality-roll.hbs +++ b/templates/ui/chat/duality-roll.hbs @@ -152,3 +152,6 @@ +
+ +
\ No newline at end of file