Merged min

This commit is contained in:
WBHarry 2026-01-24 11:14:11 +01:00
commit 0d84516813
4 changed files with 23 additions and 11 deletions

View file

@ -298,13 +298,15 @@ Hooks.on('chatMessage', (_, message) => {
? CONFIG.DH.ACTIONS.advantageState.disadvantage.value ? CONFIG.DH.ACTIONS.advantageState.disadvantage.value
: undefined; : undefined;
const difficulty = rollCommand.difficulty; const difficulty = rollCommand.difficulty;
const grantResources = Boolean(rollCommand.grantResources);
const target = getCommandTarget({ allowNull: true }); const target = getCommandTarget({ allowNull: true });
const title = flavor ?? const title =
traitValue ? game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', { (flavor ?? traitValue)
ability: game.i18n.localize(SYSTEM.ACTOR.abilities[traitValue].label) ? game.i18n.format('DAGGERHEART.UI.Chat.dualityRoll.abilityCheckTitle', {
}) ability: game.i18n.localize(SYSTEM.ACTOR.abilities[traitValue].label)
: game.i18n.localize('DAGGERHEART.GENERAL.duality'); })
: game.i18n.localize('DAGGERHEART.GENERAL.duality');
enrichedDualityRoll({ enrichedDualityRoll({
reaction, reaction,
@ -314,7 +316,8 @@ Hooks.on('chatMessage', (_, message) => {
title, title,
label: game.i18n.localize('DAGGERHEART.GENERAL.dualityRoll'), label: game.i18n.localize('DAGGERHEART.GENERAL.dualityRoll'),
actionType: null, actionType: null,
advantage advantage,
grantResources
}); });
return false; return false;
} }

View file

@ -85,6 +85,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,
grantResources: false,
customConfig: { skips: { resources: true, reaction: true } } customConfig: { skips: { resources: true, reaction: true } }
}); });

View file

@ -274,7 +274,7 @@ export default class DualityRoll extends D20Roll {
} }
static async handleTriggers(roll, config) { static async handleTriggers(roll, config) {
if (!config.source?.actor) return; if (!config.source?.actor || config.skips?.triggers) return;
const updates = []; const updates = [];
const dualityUpdates = await game.system.registeredTriggers.runTrigger( const dualityUpdates = await game.system.registeredTriggers.runTrigger(

View file

@ -47,6 +47,7 @@ function getDualityMessage(roll, flavor) {
${roll?.trait && abilities[roll.trait] ? `data-trait="${roll.trait}"` : ''} ${roll?.trait && abilities[roll.trait] ? `data-trait="${roll.trait}"` : ''}
${roll?.advantage ? 'data-advantage="true"' : ''} ${roll?.advantage ? 'data-advantage="true"' : ''}
${roll?.disadvantage ? 'data-disadvantage="true"' : ''} ${roll?.disadvantage ? 'data-disadvantage="true"' : ''}
${roll?.grantResources ? 'data-grant-resources="true"' : ''}
> >
${roll?.reaction ? '<i class="fa-solid fa-reply"></i>' : '<i class="fa-solid fa-circle-half-stroke"></i>'} ${roll?.reaction ? '<i class="fa-solid fa-reply"></i>' : '<i class="fa-solid fa-circle-half-stroke"></i>'}
${label} ${label}
@ -63,7 +64,8 @@ export const renderDualityButton = async event => {
traitValue = button.dataset.trait?.toLowerCase(), traitValue = button.dataset.trait?.toLowerCase(),
target = getCommandTarget({ allowNull: true }), target = getCommandTarget({ allowNull: true }),
difficulty = button.dataset.difficulty, difficulty = button.dataset.difficulty,
advantage = button.dataset.advantage ? Number(button.dataset.advantage) : undefined; advantage = button.dataset.advantage ? Number(button.dataset.advantage) : undefined,
grantResources = Boolean(button.dataset?.grantResources);
await enrichedDualityRoll( await enrichedDualityRoll(
{ {
@ -73,14 +75,15 @@ export const renderDualityButton = async event => {
difficulty, difficulty,
title: button.dataset.title, title: button.dataset.title,
label: button.dataset.label, label: button.dataset.label,
advantage advantage,
grantResources
}, },
event event
); );
}; };
export const enrichedDualityRoll = async ( export const enrichedDualityRoll = async (
{ reaction, traitValue, target, difficulty, title, label, advantage, customConfig }, { reaction, traitValue, target, difficulty, title, label, advantage, grantResources, customConfig },
event event
) => { ) => {
const config = { const config = {
@ -93,13 +96,18 @@ export const enrichedDualityRoll = async (
advantage, advantage,
type: reaction ? 'reaction' : null type: reaction ? 'reaction' : null
}, },
skips: {
resources: !grantResources,
triggers: !grantResources
},
type: 'trait', type: 'trait',
hasRoll: true, hasRoll: true,
...(customConfig ?? {}) ...(customConfig ?? {})
}; };
if (target) { if (target) {
await target.diceRoll(config); const result = await target.diceRoll(config);
result.resourceUpdates.updateResources();
} else { } else {
// For no target, call DualityRoll directly with basic data // For no target, call DualityRoll directly with basic data
config.data = { experiences: {}, traits: {}, rules: {} }; config.data = { experiences: {}, traits: {}, rules: {} };