Added flavor for DualityRollEnrichment

This commit is contained in:
WBHarry 2025-07-30 17:00:23 +02:00
parent b9334447de
commit 25fc663caa
4 changed files with 24 additions and 17 deletions

View file

@ -2,19 +2,21 @@ import { abilities } from '../config/actorConfig.mjs';
import { getCommandTarget, rollCommandToJSON } from '../helpers/utils.mjs';
export default function DhDualityRollEnricher(match, _options) {
const roll = rollCommandToJSON(match[1]);
const roll = rollCommandToJSON(match[1], match[0]);
if (!roll) return match[0];
return getDualityMessage(roll);
return getDualityMessage(roll.result, roll.flavor);
}
function getDualityMessage(roll) {
function getDualityMessage(roll, flavor) {
const trait = roll.trait && abilities[roll.trait] ? game.i18n.localize(abilities[roll.trait].label) : null;
const label = roll.trait
? game.i18n.format('DAGGERHEART.GENERAL.rollWith', { roll: trait })
: roll.reaction
? game.i18n.localize('DAGGERHEART.GENERAL.reactionRoll')
: game.i18n.localize('DAGGERHEART.GENERAL.duality');
const label =
flavor ??
(roll.trait
? game.i18n.format('DAGGERHEART.GENERAL.rollWith', { roll: trait })
: roll.reaction
? game.i18n.localize('DAGGERHEART.GENERAL.reactionRoll')
: game.i18n.localize('DAGGERHEART.GENERAL.duality'));
const dataLabel = trait
? game.i18n.localize(abilities[roll.trait].label)
@ -48,7 +50,7 @@ function getDualityMessage(roll) {
>
${roll.reaction ? '<i class="fa-solid fa-reply"></i>' : '<i class="fa-solid fa-circle-half-stroke"></i>'}
${label}
${roll.difficulty || advantageLabel ? `(${[roll.difficulty, advantageLabel ? game.i18n.localize(`DAGGERHEART.GENERAL.${advantageLabel}.short`) : null].filter(x => x).join(' ')})` : ''}
${!flavor && (roll.difficulty || advantageLabel) ? `(${[roll.difficulty, advantageLabel ? game.i18n.localize(`DAGGERHEART.GENERAL.${advantageLabel}.short`) : null].filter(x => x).join(' ')})` : ''}
</button>
`;

View file

@ -7,19 +7,19 @@ export { DhDamageEnricher, DhDualityRollEnricher, DhEffectEnricher, DhTemplateEn
export const enricherConfig = [
{
pattern: /^@Damage\[(.*)\]$/g,
pattern: /^@Damage\[(.*)\]({.*})?$/g,
enricher: DhDamageEnricher
},
{
pattern: /\[\[\/dr\s?(.*?)\]\]/g,
pattern: /\[\[\/dr\s?(.*?)\]\]({.*})?/g,
enricher: DhDualityRollEnricher
},
{
pattern: /^@Effect\[(.*)\]$/g,
pattern: /^@Effect\[(.*)\]({.*})?$/g,
enricher: DhEffectEnricher
},
{
pattern: /^@Template\[(.*)\]$/g,
pattern: /^@Template\[(.*)\]({.*})?$/g,
enricher: DhTemplateEnricher
}
];