This commit is contained in:
WBHarry 2026-01-16 16:04:54 +01:00
parent 57548b4cc4
commit 16d839a881
6 changed files with 34 additions and 59 deletions

View file

@ -10,7 +10,7 @@ import { enricherConfig, enricherRenderSetup } from './module/enrichers/_module.
import { getCommandTarget, rollCommandToJSON } from './module/helpers/utils.mjs'; import { getCommandTarget, rollCommandToJSON } from './module/helpers/utils.mjs';
import { BaseRoll, DHRoll, DualityRoll, D20Roll, DamageRoll, FateRoll } from './module/dice/_module.mjs'; import { BaseRoll, DHRoll, DualityRoll, D20Roll, DamageRoll, FateRoll } from './module/dice/_module.mjs';
import { enrichedDualityRoll } from './module/enrichers/DualityRollEnricher.mjs'; import { enrichedDualityRoll } from './module/enrichers/DualityRollEnricher.mjs';
import { enrichedFateRoll, getFateType } from './module/enrichers/FateRollEnricher.mjs'; import { enrichedFateRoll, getFateTypeData } from './module/enrichers/FateRollEnricher.mjs';
import { import {
handlebarsRegistration, handlebarsRegistration,
runMigrations, runMigrations,
@ -322,29 +322,26 @@ Hooks.on('chatMessage', (_, message) => {
if (message.startsWith('/fr')) { if (message.startsWith('/fr')) {
const result = const result =
message.trim().toLowerCase() === '/fr' ? { result: {} } : rollCommandToJSON(message.replace(/\/fr\s?/, '')); message.trim().toLowerCase() === '/fr' ? { result: {} } : rollCommandToJSON(message.replace(/\/fr\s?/, ''));
if (!result) { if (!result) {
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateParsing')); ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateParsing'));
return false; return false;
} }
const { result: rollCommand, flavor } = result; const { result: rollCommand, flavor } = result;
const fateTypeData = getFateTypeData(rollCommand?.type);
const fateTypeFromRollCommand = getFateType(rollCommand?.type); if (!fateTypeData)
return ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateTypeParsing'));
if (fateTypeFromRollCommand == 'BAD') {
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateTypeParsing'));
return false;
}
const fateType = fateTypeFromRollCommand;
const { value: fateType, label: fateTypeLabel } = fateTypeData;
const target = getCommandTarget({ allowNull: true }); const target = getCommandTarget({ allowNull: true });
const title = fateType + ' Fate Roll'; const title = flavor ?? game.i18n.localize('DAGGERHEART.GENERAL.fateRoll');
enrichedFateRoll({ enrichedFateRoll({
target, target,
title, title,
label: 'test', label: fateTypeLabel,
fateType fateType
}); });
return false; return false;

View file

@ -2679,7 +2679,7 @@
"riskItAllFailure": "The fear die rolled higher. You have crossed through the veil of death.", "riskItAllFailure": "The fear die rolled higher. You have crossed through the veil of death.",
"blazeOfGlory": "Blaze of Glory Effect Added!", "blazeOfGlory": "Blaze of Glory Effect Added!",
"riskItAllDialogButton": "Clear Stress And Hit Points.", "riskItAllDialogButton": "Clear Stress And Hit Points.",
"riskItAllSuccessWithEnoughHope": "Hope roll value is more than the marked Stress and Hit Points. Both are cleared fully.", "riskItAllSuccessWithEnoughHope": "The Hope value is more than the marked Stress and Hit Points. Both are cleared fully.",
"riskItAllSuccess": "The hope die rolled higher, clear up to {hope} Stress And Hit Points." "riskItAllSuccess": "The hope die rolled higher, clear up to {hope} Stress And Hit Points."
}, },
"dicePool": { "dicePool": {

View file

@ -123,7 +123,7 @@ export default class D20RollDialog extends HandlebarsApplicationMixin(Applicatio
context.formula = this.roll.constructFormula(this.config); context.formula = this.roll.constructFormula(this.config);
if (this.actor?.system?.traits) context.abilities = this.getTraitModifiers(); if (this.actor?.system?.traits) context.abilities = this.getTraitModifiers();
context.showReaction = !this.config.roll?.type || context.rollType === 'DualityRoll'; context.showReaction = !this.config.skips?.reaction && context.rollType === 'DualityRoll';
context.reactionOverride = this.reactionOverride; context.reactionOverride = this.reactionOverride;
} }

View file

@ -84,7 +84,7 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV
label: game.i18n.localize('DAGGERHEART.GENERAL.dualityDice'), label: game.i18n.localize('DAGGERHEART.GENERAL.dualityDice'),
actionType: null, actionType: null,
advantage: null, advantage: null,
customConfig: { skips: { resources: true } } customConfig: { skips: { resources: true, reaction: true } }
}); });
if (!config.roll.result) return; if (!config.roll.result) return;

View file

@ -4,56 +4,35 @@ 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];
const fateTypeFromRoll = getFateType(roll?.type);
if (fateTypeFromRoll == 'BAD') {
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateTypeParsing'));
return;
}
return getFateMessage(roll.result, roll?.flavor); return getFateMessage(roll.result, roll?.flavor);
} }
export function getFateType(fateTypeValue) { export function getFateTypeData(fateTypeValue) {
const fateTypeFromValue = fateTypeValue const value = fateTypeValue ? fateTypeValue.capitalize() : 'Hope';
? fateTypeValue.toLowerCase() == 'fear' const lowercased = fateTypeValue?.toLowerCase?.() ?? 'hope';
? 'Fear' switch (lowercased) {
: fateTypeValue.toLowerCase() == 'hope' case 'hope':
? 'Hope' case 'fear':
: 'BAD' return { value, label: game.i18n.localize(`DAGGERHEART.GENERAL.${lowercased}`) };
: 'Hope'; default:
return null;
return fateTypeFromValue; }
} }
function getFateMessage(roll, flavor) { function getFateMessage(roll, flavor) {
const fateType = getFateType(roll?.type); const fateTypeData = getFateTypeData(roll?.type);
if (fateType == 'BAD') { if (!fateTypeData)
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateTypeParsing')); return ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateTypeParsing'));
return '';
}
const fateTypeLocalized = const { value: fateType, label: fateTypeLabel } = fateTypeData;
fateType === 'Hope' const title = flavor ?? game.i18n.localize('DAGGERHEART.GENERAL.fateRoll');
? 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'); const fateElement = document.createElement('span');
fateElement.innerHTML = ` fateElement.innerHTML = `
<button type="button" class="fate-roll-button${roll?.inline ? ' inline' : ''}" <button type="button" class="fate-roll-button${roll?.inline ? ' inline' : ''}"
data-title="${title}" data-title="${title}"
data-label="${dataLabel}" data-label="${fateTypeLabel}"
data-fateType="${fateType}" data-fateType="${fateType}"
> >
${title} ${title}
@ -68,19 +47,17 @@ export const renderFateButton = async event => {
target = getCommandTarget({ allowNull: true }); target = getCommandTarget({ allowNull: true });
console.log('button', button); console.log('button', button);
const fateTypeFromButton = getFateType(button.dataset?.fatetype); const fateTypeData = getFateTypeData(button.dataset?.fatetype);
if (fateTypeFromButton == 'BAD') { if (!fateTypeData) ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateTypeParsing'));
ui.notifications.error(game.i18n.localize('DAGGERHEART.UI.Notifications.fateTypeParsing')); const { value: fateType, label: fateTypeLabel } = fateTypeData;
return;
}
await enrichedFateRoll( await enrichedFateRoll(
{ {
target, target,
title: button.dataset.title, title: button.dataset.title,
label: button.dataset.label, label: button.dataset.label,
fateType: fateTypeFromButton fateType: fateType
}, },
event event
); );
@ -93,7 +70,8 @@ export const enrichedFateRoll = async ({ target, title, label, fateType }, event
headerTitle: label, headerTitle: label,
roll: {}, roll: {},
hasRoll: true, hasRoll: true,
fateType: fateType fateType: fateType,
skips: { reaction: true }
}; };
config.data = { experiences: {}, traits: {}, fateType: fateType }; config.data = { experiences: {}, traits: {}, fateType: fateType };

View file

@ -30,7 +30,7 @@
</div> </div>
<div class="code-mirror-wrapper {{#if trigger.revealed}}revealed{{/if}}"> <div class="code-mirror-wrapper {{#if trigger.revealed}}revealed{{/if}}">
{{formInput @root.fields.triggers.element.fields.command value=trigger.command elementType="code-mirror" name=(concat "triggers." index ".command") aria=(object label=(localize "Test")) }} {{formInput @root.fields.triggers.element.fields.command value=trigger.command elementType="code-mirror" name=(concat "triggers." index ".command") }}
</div> </div>
</fieldset> </fieldset>
{{/each}} {{/each}}