Trying to sort out the button for the fate roll

This commit is contained in:
Chris Ryan 2025-12-04 21:52:39 +10:00
parent 21c831b54e
commit 73bc30f552

View file

@ -1,13 +1,16 @@
import { getCommandTarget, rollCommandToJSON } from '../helpers/utils.mjs'; import { getCommandTarget, rollCommandToJSON } from '../helpers/utils.mjs';
export default function DhFateRollEnricher(match, _options) { export default function DhFateRollEnricher(match, _options) {
console.log("match", match);
const roll = rollCommandToJSON(match[1], match[0]); const roll = rollCommandToJSON(match[1], match[0]);
if (!roll) return match[0]; if (!roll) return match[0];
console.log("roll", roll);
return getFateMessage(roll.result, roll?.flavor); return getFateMessage(roll.result, roll?.flavor);
} }
function getFateMessage(roll, flavor) { function getFateMessage(roll, flavor) {
console.log("roll", roll);
const label = flavor ?? 'Fate'; const label = flavor ?? 'Fate';
const dataLabel = game.i18n.localize('DAGGERHEART.GENERAL.fate'); const dataLabel = game.i18n.localize('DAGGERHEART.GENERAL.fate');
@ -17,7 +20,7 @@ function getFateMessage(roll, flavor) {
<button type="button" class="fate-roll-button${roll?.inline ? ' inline' : ''}" <button type="button" class="fate-roll-button${roll?.inline ? ' inline' : ''}"
data-title="${label}" data-title="${label}"
data-label="${dataLabel}" data-label="${dataLabel}"
data-hope="${roll?.hope ?? 'd12'}" data-fateType="${roll?.hope ?? roll?.fear ?? 'Hope'}"
${label} ${label}
</button> </button>
`; `;
@ -34,7 +37,7 @@ export const renderFateButton = async event => {
target, target,
title: button.dataset.title, title: button.dataset.title,
label: button.dataset.label, label: button.dataset.label,
fateType fateType: button.dataset.fateType
}, },
event event
); );