From 1e62131a7c92e0c018c0bcfab2efd1599d782ca7 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Tue, 27 Jan 2026 20:22:45 +0100 Subject: [PATCH] Added an automation setting for chat command resources --- daggerheart.mjs | 2 +- lang/en.json | 4 ++++ module/data/settings/Automation.mjs | 5 +++++ module/enrichers/DualityRollEnricher.mjs | 11 +++++++---- templates/settings/automation-settings/general.hbs | 2 ++ 5 files changed, 19 insertions(+), 5 deletions(-) diff --git a/daggerheart.mjs b/daggerheart.mjs index b1b2a0ca..f75ff1da 100644 --- a/daggerheart.mjs +++ b/daggerheart.mjs @@ -309,7 +309,7 @@ Hooks.on('chatMessage', (_, message) => { ? CONFIG.DH.ACTIONS.advantageState.disadvantage.value : undefined; const difficulty = rollCommand.difficulty; - const grantResources = Boolean(rollCommand.grantResources); + const grantResources = rollCommand.grantResources; const target = getCommandTarget({ allowNull: true }); const title = diff --git a/lang/en.json b/lang/en.json index 4d6815c3..ad503ff0 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2466,6 +2466,10 @@ "gm": { "label": "GM" }, "players": { "label": "Players" } }, + "chatCommandAutomation": { + "label": "Chat Command Resource Automation", + "hint": "Default chat commands to grant resources such as hope and fear when possible" + }, "countdownAutomation": { "label": "Countdown Automation", "hint": "Automatically progress countdowns based on their progression settings" diff --git a/module/data/settings/Automation.mjs b/module/data/settings/Automation.mjs index 436f0eb7..c3b88bb8 100644 --- a/module/data/settings/Automation.mjs +++ b/module/data/settings/Automation.mjs @@ -18,6 +18,11 @@ export default class DhAutomation extends foundry.abstract.DataModel { label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.hopeFear.players.label' }) }), + chatCommandAutomation: new fields.BooleanField({ + required: true, + initial: false, + label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.chatCommandAutomation.label' + }), countdownAutomation: new fields.BooleanField({ required: true, initial: true, diff --git a/module/enrichers/DualityRollEnricher.mjs b/module/enrichers/DualityRollEnricher.mjs index 3e4a39ce..81304f72 100644 --- a/module/enrichers/DualityRollEnricher.mjs +++ b/module/enrichers/DualityRollEnricher.mjs @@ -86,6 +86,9 @@ export const enrichedDualityRoll = async ( { reaction, traitValue, target, difficulty, title, label, advantage, grantResources, customConfig }, event ) => { + const { chatCommandAutomation } = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation); + const shouldGrantResources = grantResources === undefined ? chatCommandAutomation : grantResources; + const config = { event: event ?? {}, title: title, @@ -94,12 +97,12 @@ export const enrichedDualityRoll = async ( roll: { trait: traitValue && target ? traitValue : null, difficulty: difficulty, - advantage, - // type: reaction ? 'reaction' : null //not needed really but keeping it for troubleshooting + advantage + // type: reaction ? 'reaction' : null //not needed really but keeping it for troubleshooting }, skips: { - resources: !grantResources, - triggers: !grantResources + resources: !shouldGrantResources, + triggers: !shouldGrantResources }, type: 'trait', hasRoll: true, diff --git a/templates/settings/automation-settings/general.hbs b/templates/settings/automation-settings/general.hbs index bd91b2b1..1173273a 100644 --- a/templates/settings/automation-settings/general.hbs +++ b/templates/settings/automation-settings/general.hbs @@ -13,6 +13,8 @@ {{formGroup settingFields.schema.fields.summaryMessages.fields.damage value=settingFields._source.summaryMessages.damage localize=true}} {{formGroup settingFields.schema.fields.summaryMessages.fields.effects value=settingFields._source.summaryMessages.effects localize=true}} + + {{formGroup settingFields.schema.fields.chatCommandAutomation value=settingFields._source.chatCommandAutomation localize=true}} {{formGroup settingFields.schema.fields.countdownAutomation value=settingFields._source.countdownAutomation localize=true}} {{formGroup settingFields.schema.fields.actionPoints value=settingFields._source.actionPoints localize=true}} {{formGroup settingFields.schema.fields.hordeDamage value=settingFields._source.hordeDamage localize=true}}