From cbd268ea1f51ab59a1cede31fb28c6f91d3c112c Mon Sep 17 00:00:00 2001
From: WBHarry <89362246+WBHarry@users.noreply.github.com>
Date: Sat, 24 Jan 2026 11:10:30 +0100
Subject: [PATCH] [Feature] DR Command Resources (#1572)
* Dr chatcommand and buttons now grant resources via automation by default. Optionally turned off via parameter noResources=true
* .
---
daggerheart.mjs | 4 +++-
module/dice/dualityRoll.mjs | 2 +-
module/enrichers/DualityRollEnricher.mjs | 16 ++++++++++++----
3 files changed, 16 insertions(+), 6 deletions(-)
diff --git a/daggerheart.mjs b/daggerheart.mjs
index 3abcd210..c3a5c348 100644
--- a/daggerheart.mjs
+++ b/daggerheart.mjs
@@ -296,6 +296,7 @@ Hooks.on('chatMessage', (_, message) => {
? CONFIG.DH.ACTIONS.advantageState.disadvantage.value
: undefined;
const difficulty = rollCommand.difficulty;
+ const grantResources = Boolean(rollCommand.grantResources);
const target = getCommandTarget({ allowNull: true });
const title = traitValue
@@ -312,7 +313,8 @@ Hooks.on('chatMessage', (_, message) => {
title,
label: game.i18n.localize('DAGGERHEART.GENERAL.dualityRoll'),
actionType: null,
- advantage
+ advantage,
+ grantResources
});
return false;
}
diff --git a/module/dice/dualityRoll.mjs b/module/dice/dualityRoll.mjs
index aaca7400..30b569ac 100644
--- a/module/dice/dualityRoll.mjs
+++ b/module/dice/dualityRoll.mjs
@@ -261,7 +261,7 @@ export default class DualityRoll extends D20Roll {
}
static async handleTriggers(roll, config) {
- if (!config.source?.actor) return;
+ if (!config.source?.actor || config.skips?.triggers) return;
const updates = [];
const dualityUpdates = await game.system.registeredTriggers.runTrigger(
diff --git a/module/enrichers/DualityRollEnricher.mjs b/module/enrichers/DualityRollEnricher.mjs
index 536847f7..67728a37 100644
--- a/module/enrichers/DualityRollEnricher.mjs
+++ b/module/enrichers/DualityRollEnricher.mjs
@@ -47,6 +47,7 @@ function getDualityMessage(roll, flavor) {
${roll?.trait && abilities[roll.trait] ? `data-trait="${roll.trait}"` : ''}
${roll?.advantage ? 'data-advantage="true"' : ''}
${roll?.disadvantage ? 'data-disadvantage="true"' : ''}
+ ${roll?.grantResources ? 'data-grant-resources="true"' : ''}
>
${roll?.reaction ? '' : ''}
${label}
@@ -63,7 +64,8 @@ export const renderDualityButton = async event => {
traitValue = button.dataset.trait?.toLowerCase(),
target = getCommandTarget({ allowNull: true }),
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(
{
@@ -73,14 +75,15 @@ export const renderDualityButton = async event => {
difficulty,
title: button.dataset.title,
label: button.dataset.label,
- advantage
+ advantage,
+ grantResources
},
event
);
};
export const enrichedDualityRoll = async (
- { reaction, traitValue, target, difficulty, title, label, advantage },
+ { reaction, traitValue, target, difficulty, title, label, advantage, grantResources },
event
) => {
const config = {
@@ -93,12 +96,17 @@ export const enrichedDualityRoll = async (
advantage,
type: reaction ? 'reaction' : null
},
+ skips: {
+ resources: !grantResources,
+ triggers: !grantResources
+ },
type: 'trait',
hasRoll: true
};
if (target) {
- await target.diceRoll(config);
+ const result = await target.diceRoll(config);
+ result.resourceUpdates.updateResources();
} else {
// For no target, call DualityRoll directly with basic data
config.data = { experiences: {}, traits: {}, rules: {} };