From 3c75c0f6c624e123970e6ce9897971194efe042a Mon Sep 17 00:00:00 2001 From: Chris Ryan Date: Tue, 9 Dec 2025 12:13:26 +1000 Subject: [PATCH] Fixed enricher button; localization fixes; debug cleanup --- daggerheart.mjs | 11 ++++++++++- lang/en.json | 3 ++- module/enrichers/FateRollEnricher.mjs | 28 ++++++++++++--------------- 3 files changed, 24 insertions(+), 18 deletions(-) diff --git a/daggerheart.mjs b/daggerheart.mjs index 82e98214..3e4d05c8 100644 --- a/daggerheart.mjs +++ b/daggerheart.mjs @@ -259,7 +259,16 @@ Hooks.on('chatMessage', (_, message) => { const { result: rollCommand, flavor } = result; - const fateType = rollCommand.type ?? "Hope"; + const fateTypeFromRollCommand = rollCommand?.type ? + (rollCommand?.type?.toLowerCase() == "fear" ? "Fear" : + (rollCommand?.type?.toLowerCase() == "hope" ? "Hope" : "BAD")) : "Hope"; + + if (fateTypeFromRollCommand == "BAD") { + ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateParsing')); + return false; + } + + const fateType = fateTypeFromRollCommand; const target = getCommandTarget({ allowNull: true }); const title = fateType + ' Fate Roll'; diff --git a/lang/en.json b/lang/en.json index 881b499b..c47019f9 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2685,7 +2685,8 @@ "noAssignedPlayerCharacter": "You have no assigned character.", "noSelectedToken": "You have no selected token", "onlyUseableByPC": "This can only be used with a PC token", - "dualityParsing": "Duality roll not properly formated", + "dualityParsing": "Duality roll not properly formatted", + "fateParsing": "Fate roll not properly formatted", "attributeFaulty": "The supplied Attribute doesn't exist", "domainCardWrongDomain": "You don't have access to that Domain", "domainCardToHighLevel": "The Domain Card is too high level to be selected", diff --git a/module/enrichers/FateRollEnricher.mjs b/module/enrichers/FateRollEnricher.mjs index ffc2b8ec..84d820db 100644 --- a/module/enrichers/FateRollEnricher.mjs +++ b/module/enrichers/FateRollEnricher.mjs @@ -1,29 +1,30 @@ import { getCommandTarget, rollCommandToJSON } from '../helpers/utils.mjs'; export default function DhFateRollEnricher(match, _options) { - console.log("match", match); const roll = rollCommandToJSON(match[1], match[0]); if (!roll) return match[0]; - console.log("roll", roll); return getFateMessage(roll.result, roll?.flavor); } function getFateMessage(roll, flavor) { - console.log("roll", roll); - const label = flavor ?? 'Fate'; - const fateType = roll?.type ?? 'Hope' + const fateType = roll?.type ?? 'Hope'; + const fateTypeLocalized = fateType === "Hope" ? game.i18n.localize("DAGGERHEART.GENERAL.hope") : game.i18n.localize("DAGGERHEART.GENERAL.fear"); + + const title = flavor ?? fateTypeLocalized + ' ' + + game.i18n.localize('DAGGERHEART.GENERAL.fate') + ' ' + + game.i18n.localize('DAGGERHEART.GENERAL.roll'); const dataLabel = game.i18n.localize('DAGGERHEART.GENERAL.fate'); const fateElement = document.createElement('span'); fateElement.innerHTML = ` `; @@ -39,7 +40,7 @@ export const renderFateButton = async event => { target, title: button.dataset.title, label: button.dataset.label, - fateType: button.dataset.fateType + fateType: button.dataset.fatetype }, event ); @@ -59,12 +60,7 @@ export const enrichedFateRoll = async ( fateType: fateType }; - if (target) { - await target.diceRoll(config); - } else { - // For no target, call FateRoll directly with basic data - config.data = { experiences: {}, traits: {}, fateType: fateType }; - config.source = { actor: null }; - await CONFIG.Dice.daggerheart.FateRoll.build(config); - } + config.data = { experiences: {}, traits: {}, fateType: fateType }; + config.source = { actor: target?.uuid }; + await CONFIG.Dice.daggerheart.FateRoll.build(config); };