From 01aa1b4bdddb9039c4fae093a6887576618ccab3 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Fri, 13 Jun 2025 01:12:01 +0200 Subject: [PATCH] Fixed duality roll buttons --- daggerheart.mjs | 7 ++++--- module/documents/actor.mjs | 4 ++-- module/enrichers/DualityRollEnricher.mjs | 10 +++++----- 3 files changed, 11 insertions(+), 10 deletions(-) diff --git a/daggerheart.mjs b/daggerheart.mjs index f70aa594..6e266ace 100644 --- a/daggerheart.mjs +++ b/daggerheart.mjs @@ -135,7 +135,7 @@ Hooks.on(socketEvent.GMUpdate, async (action, uuid, update) => { const renderDualityButton = async event => { const button = event.currentTarget, - attributeValue = button.dataset.attribute?.toLowerCase(), + traitValue = button.dataset.trait?.toLowerCase(), target = getCommandTarget(); if (!target) return; @@ -143,7 +143,8 @@ const renderDualityButton = async event => { event: event, title: button.dataset.label, roll: { - modifier: attributeValue ? target.system.attributes[attributeValue].data.value : null, + modifier: traitValue ? target.system.traits[traitValue].value : null, + label: button.dataset.label, type: button.dataset.actionType ?? null // Need check }, chatMessage: { @@ -239,7 +240,7 @@ Hooks.on('chatMessage', (_, message) => { const hopeAndFearRoll = `1${rollCommand.hope ?? 'd12'}+1${rollCommand.fear ?? 'd12'}`; const advantageRoll = `${rollCommand.advantage && !rollCommand.disadvantage ? '+d6' : rollCommand.disadvantage && !rollCommand.advantage ? '-d6' : ''}`; - const attributeRoll = `${trait?.data?.value ? `${trait.data.value > 0 ? `+${trait.data.value}` : `${trait.data.value}`}` : ''}`; + const attributeRoll = `${trait?.value ? `${trait.value > 0 ? `+${trait.value}` : `${trait.value}`}` : ''}`; const roll = await Roll.create(`${hopeAndFearRoll}${advantageRoll}${attributeRoll}`).evaluate(); setDiceSoNiceForDualityRoll( diff --git a/module/documents/actor.mjs b/module/documents/actor.mjs index e1bfd4fc..4f7082a2 100644 --- a/module/documents/actor.mjs +++ b/module/documents/actor.mjs @@ -271,8 +271,8 @@ export default class DhpActor extends Actor { } formatRollModifier(roll) { - const modifier = roll.modifier ? Number.parseInt(roll.modifier) : null; - return roll.modifier !== null + const modifier = roll.modifier !== null ? Number.parseInt(roll.modifier) : null; + return modifier !== null ? [ { value: modifier, diff --git a/module/enrichers/DualityRollEnricher.mjs b/module/enrichers/DualityRollEnricher.mjs index 93c3a999..6c5ca961 100644 --- a/module/enrichers/DualityRollEnricher.mjs +++ b/module/enrichers/DualityRollEnricher.mjs @@ -9,13 +9,13 @@ export function dualityRollEnricher(match, _options) { } export function getDualityMessage(roll) { - const attributeLabel = - roll.attribute && abilities[roll.attribute] + const traitLabel = + roll.trait && abilities[roll.trait] ? game.i18n.format('DAGGERHEART.General.Check', { - check: game.i18n.localize(abilities[roll.attribute].label) + check: game.i18n.localize(abilities[roll.trait].label) }) : null; - const label = attributeLabel ?? game.i18n.localize('DAGGERHEART.General.Duality'); + const label = traitLabel ?? game.i18n.localize('DAGGERHEART.General.Duality'); const dualityElement = document.createElement('span'); dualityElement.innerHTML = ` @@ -23,7 +23,7 @@ export function getDualityMessage(roll) { data-label="${label}" data-hope="${roll.hope ?? 'd12'}" data-fear="${roll.fear ?? 'd12'}" - ${roll.attribute && abilities[roll.attribute] ? `data-attribute="${roll.attribute}"` : ''} + ${roll.trait && abilities[roll.trait] ? `data-trait="${roll.trait}"` : ''} ${roll.advantage ? 'data-advantage="true"' : ''} ${roll.disadvantage ? 'data-disadvantage="true"' : ''} >