From 9e21aa177be547179a9e6766c698c6ff401be210 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Mon, 17 Nov 2025 23:19:23 +0100 Subject: [PATCH] Added a CountdownAutomation setting to enable/disable countdown automation --- lang/en.json | 4 ++++ module/applications/ui/countdowns.mjs | 13 ++++++++----- module/data/settings/Automation.mjs | 5 +++++ templates/settings/automation-settings/general.hbs | 1 + 4 files changed, 18 insertions(+), 5 deletions(-) diff --git a/lang/en.json b/lang/en.json index eb691050..bb5c20ef 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2293,6 +2293,10 @@ "gm": { "label": "GM" }, "players": { "label": "Players" } }, + "countdownAutomation": { + "label": "Countdown Automation", + "hint": "Automatically progress countdowns based on their progression settings" + }, "levelupAuto": { "label": "Levelup Automation", "hint": "When you've made your choices and finish levelup, the numerical changes are automatically applied to your character." diff --git a/module/applications/ui/countdowns.mjs b/module/applications/ui/countdowns.mjs index 25cf0a72..5631f246 100644 --- a/module/applications/ui/countdowns.mjs +++ b/module/applications/ui/countdowns.mjs @@ -91,12 +91,12 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application /** Returns countdown data filtered by ownership */ #getCountdowns() { const setting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns); - const values = Object.entries(setting.countdowns).map(([key, countdown]) => ({ - key, - countdown, - ownership: DhCountdowns.#getPlayerOwnership(game.user, setting, countdown) + const values = Object.entries(setting.countdowns).map(([key, countdown]) => ({ + key, + countdown, + ownership: DhCountdowns.#getPlayerOwnership(game.user, setting, countdown) })); - return values.filter((v) => v.ownership !== CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE); + return values.filter(v => v.ownership !== CONST.DOCUMENT_OWNERSHIP_LEVELS.NONE); } /** @override */ @@ -214,6 +214,9 @@ export default class DhCountdowns extends HandlebarsApplicationMixin(Application } static async updateCountdowns(progressType) { + const { countdownAutomation } = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation); + if (!countdownAutomation) return; + const countdownSetting = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Countdowns); const updatedCountdowns = Object.keys(countdownSetting.countdowns).reduce((acc, key) => { const countdown = countdownSetting.countdowns[key]; diff --git a/module/data/settings/Automation.mjs b/module/data/settings/Automation.mjs index fbded2de..2aec990f 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' }) }), + countdownAutomation: new fields.BooleanField({ + required: true, + initial: true, + label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.countdownAutomation.label' + }), levelupAuto: new fields.BooleanField({ required: true, initial: true, diff --git a/templates/settings/automation-settings/general.hbs b/templates/settings/automation-settings/general.hbs index 8921ab6a..d49ef9b8 100644 --- a/templates/settings/automation-settings/general.hbs +++ b/templates/settings/automation-settings/general.hbs @@ -13,6 +13,7 @@ {{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.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}} {{formGroup settingFields.schema.fields.effects.fields.rangeDependent value=settingFields._source.effects.rangeDependent localize=true}}