From adfb0e721341ddd397c987d9ebc53bb5eb3e0a6d Mon Sep 17 00:00:00 2001 From: Chris Ryan Date: Thu, 27 Nov 2025 23:31:55 +1000 Subject: [PATCH] Hide formula display; code removal; start to add Fear die as a choice for Fate roll --- module/data/chat-message/actorRoll.mjs | 2 +- module/dice/fateRoll.mjs | 57 ++----------------- module/enrichers/FateRollEnricher.mjs | 7 ++- templates/dialogs/dice-roll/rollSelection.hbs | 20 ++++++- 4 files changed, 29 insertions(+), 57 deletions(-) diff --git a/module/data/chat-message/actorRoll.mjs b/module/data/chat-message/actorRoll.mjs index 61262529..340d7a9e 100644 --- a/module/data/chat-message/actorRoll.mjs +++ b/module/data/chat-message/actorRoll.mjs @@ -50,7 +50,7 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel { }), damage: new fields.ObjectField(), costs: new fields.ArrayField(new fields.ObjectField()), - successConsumed: new fields.BooleanField({ initial: false }) + successConsumed: new fields.BooleanField({ initial: false }), }; } diff --git a/module/dice/fateRoll.mjs b/module/dice/fateRoll.mjs index 616a11db..783691a8 100644 --- a/module/dice/fateRoll.mjs +++ b/module/dice/fateRoll.mjs @@ -34,6 +34,11 @@ export default class FateRoll extends D20Roll { return false; } + + get fateDie() { + return "Hope"; + } + static getHooks(hooks) { return [...(hooks ?? []), 'Fate']; } @@ -67,61 +72,9 @@ export default class FateRoll extends D20Roll { data.hope = { dice: roll.dHope.denomination, value: roll.dHope.total, - rerolled: { - any: roll.dHope.results.some(x => x.rerolled), - rerolls: roll.dHope.results.filter(x => x.rerolled) - } }; return data; } - // static async reroll(rollString, target, message) { - // let parsedRoll = game.system.api.dice.DualityRoll.fromData({ ...rollString, evaluated: false }); - // const term = parsedRoll.terms[target.dataset.dieIndex]; - // await term.reroll(`/r1=${term.total}`); - // if (game.modules.get('dice-so-nice')?.active) { - // const diceSoNiceRoll = { - // _evaluated: true, - // dice: [ - // new foundry.dice.terms.Die({ - // ...term, - // faces: term._faces, - // results: term.results.filter(x => !x.rerolled) - // }) - // ], - // options: { appearance: {} } - // }; - - // const diceSoNicePresets = await getDiceSoNicePresets(`d${term._faces}`, `d${term._faces}`); - // const type = target.dataset.type; - // if (diceSoNicePresets[type]) { - // diceSoNiceRoll.dice[0].options = diceSoNicePresets[type]; - // } - - // await game.dice3d.showForRoll(diceSoNiceRoll, game.user, true); - // } - - // await parsedRoll.evaluate(); - - // const newRoll = game.system.api.dice.DualityRoll.postEvaluate(parsedRoll, { - // targets: message.system.targets, - // roll: { - // advantage: message.system.roll.advantage?.type, - // difficulty: message.system.roll.difficulty ? Number(message.system.roll.difficulty) : null - // } - // }); - // newRoll.extra = newRoll.extra.slice(2); - - // const tagTeamSettings = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.TagTeamRoll); - // Hooks.call(`${CONFIG.DH.id}.postRollDuality`, { - // source: { actor: message.system.source.actor ?? '' }, - // targets: message.system.targets, - // tagTeamSelected: Object.values(tagTeamSettings.members).some(x => x.messageId === message._id), - // roll: newRoll, - // rerolledRoll: - // newRoll.result.duality !== message.system.roll.result.duality ? message.system.roll : undefined - // }); - // return { newRoll, parsedRoll }; - // } } diff --git a/module/enrichers/FateRollEnricher.mjs b/module/enrichers/FateRollEnricher.mjs index 0fb4f335..997315eb 100644 --- a/module/enrichers/FateRollEnricher.mjs +++ b/module/enrichers/FateRollEnricher.mjs @@ -1,15 +1,15 @@ -import { abilities } from '../config/actorConfig.mjs'; import { getCommandTarget, rollCommandToJSON } from '../helpers/utils.mjs'; export default function DhFateRollEnricher(match, _options) { const roll = rollCommandToJSON(match[1], match[0]); if (!roll) return match[0]; - return getFateMessage(roll.result, roll.flavor ?? 'FLAVOR'); + return getFateMessage(roll.result, roll?.flavor); } function getFateMessage(roll, flavor) { - const label = flavor ?? 'fate'; + const label = flavor ?? 'Fate'; + console.log("ROLL", roll); const dataLabel = game.i18n.localize('DAGGERHEART.GENERAL.fate'); @@ -19,6 +19,7 @@ function getFateMessage(roll, flavor) { data-title="${label}" data-label="${dataLabel}" data-hope="${roll?.hope ?? 'd12'}" + data-fear="${roll?.fear ?? 'd12'}" ${label} `; diff --git a/templates/dialogs/dice-roll/rollSelection.hbs b/templates/dialogs/dice-roll/rollSelection.hbs index d59c330f..4f0c99c7 100644 --- a/templates/dialogs/dice-roll/rollSelection.hbs +++ b/templates/dialogs/dice-roll/rollSelection.hbs @@ -69,6 +69,8 @@ {{/if}} {{/if}} {{#if (eq @root.rollType 'FateRoll')}} + {{#if (eq @root.roll.fateDie 'Hope')}} +
@@ -78,6 +80,20 @@
+ {{/if}} + + {{#if (eq @root.roll.fateDie 'Fear')}} +
+ +
+ {{localize "DAGGERHEART.GENERAL.fear"}} + +
+
+ {{/if}} + {{/if}} @@ -154,7 +170,9 @@ {{> 'systems/daggerheart/templates/dialogs/dice-roll/costSelection.hbs'}} {{/if}} - {{localize "DAGGERHEART.GENERAL.formula"}}: {{@root.formula}} + {{#if (ne @root.rollType 'FateRoll')}} + {{localize "DAGGERHEART.GENERAL.formula"}}: {{@root.formula}} + {{/if}}