Hide formula display; code removal; start to add Fear die as a choice for Fate roll

This commit is contained in:
Chris Ryan 2025-11-27 23:31:55 +10:00
parent 96224cf234
commit adfb0e7213
4 changed files with 29 additions and 57 deletions

View file

@ -50,7 +50,7 @@ export default class DHActorRoll extends foundry.abstract.TypeDataModel {
}), }),
damage: new fields.ObjectField(), damage: new fields.ObjectField(),
costs: new fields.ArrayField(new fields.ObjectField()), costs: new fields.ArrayField(new fields.ObjectField()),
successConsumed: new fields.BooleanField({ initial: false }) successConsumed: new fields.BooleanField({ initial: false }),
}; };
} }

View file

@ -34,6 +34,11 @@ export default class FateRoll extends D20Roll {
return false; return false;
} }
get fateDie() {
return "Hope";
}
static getHooks(hooks) { static getHooks(hooks) {
return [...(hooks ?? []), 'Fate']; return [...(hooks ?? []), 'Fate'];
} }
@ -67,61 +72,9 @@ export default class FateRoll extends D20Roll {
data.hope = { data.hope = {
dice: roll.dHope.denomination, dice: roll.dHope.denomination,
value: roll.dHope.total, value: roll.dHope.total,
rerolled: {
any: roll.dHope.results.some(x => x.rerolled),
rerolls: roll.dHope.results.filter(x => x.rerolled)
}
}; };
return data; 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 };
// }
} }

View file

@ -1,15 +1,15 @@
import { abilities } from '../config/actorConfig.mjs';
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) {
const roll = rollCommandToJSON(match[1], match[0]); const roll = rollCommandToJSON(match[1], match[0]);
if (!roll) return match[0]; if (!roll) return match[0];
return getFateMessage(roll.result, roll.flavor ?? 'FLAVOR'); return getFateMessage(roll.result, roll?.flavor);
} }
function getFateMessage(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'); const dataLabel = game.i18n.localize('DAGGERHEART.GENERAL.fate');
@ -19,6 +19,7 @@ function getFateMessage(roll, flavor) {
data-title="${label}" data-title="${label}"
data-label="${dataLabel}" data-label="${dataLabel}"
data-hope="${roll?.hope ?? 'd12'}" data-hope="${roll?.hope ?? 'd12'}"
data-fear="${roll?.fear ?? 'd12'}"
${label} ${label}
</button> </button>
`; `;

View file

@ -69,6 +69,8 @@
{{/if}} {{/if}}
{{/if}} {{/if}}
{{#if (eq @root.rollType 'FateRoll')}} {{#if (eq @root.rollType 'FateRoll')}}
{{#if (eq @root.roll.fateDie 'Hope')}}
<div class="dice-option"> <div class="dice-option">
<img class="dice-icon" src="{{concat 'systems/daggerheart/assets/icons/dice/hope/' @root.roll.dHope.denomination '.svg'}}" alt=""> <img class="dice-icon" src="{{concat 'systems/daggerheart/assets/icons/dice/hope/' @root.roll.dHope.denomination '.svg'}}" alt="">
<div class="dice-select"> <div class="dice-select">
@ -78,6 +80,20 @@
</select> </select>
</div> </div>
</div> </div>
{{/if}}
{{#if (eq @root.roll.fateDie 'Fear')}}
<div class="dice-option">
<img class="dice-icon" src="{{concat 'systems/daggerheart/assets/icons/dice/fear/' @root.roll.dFear.denomination '.svg'}}" alt="">
<div class="dice-select">
<span class="label">{{localize "DAGGERHEART.GENERAL.fear"}}</span>
<select name="roll.dice.dFear">
{{selectOptions diceOptions selected=@root.roll.dFear.denomination}}
</select>
</div>
</div>
{{/if}}
{{/if}} {{/if}}
</div> </div>
@ -154,7 +170,9 @@
{{> 'systems/daggerheart/templates/dialogs/dice-roll/costSelection.hbs'}} {{> 'systems/daggerheart/templates/dialogs/dice-roll/costSelection.hbs'}}
{{/if}} {{/if}}
<span class="formula-label"><b>{{localize "DAGGERHEART.GENERAL.formula"}}:</b> {{@root.formula}}</span> {{#if (ne @root.rollType 'FateRoll')}}
<span class="formula-label"><b>{{localize "DAGGERHEART.GENERAL.formula"}}:</b> {{@root.formula}}</span>
{{/if}}
<div class="roll-dialog-controls"> <div class="roll-dialog-controls">
<select class="roll-mode-select" name="selectedRollMode"> <select class="roll-mode-select" name="selectedRollMode">