Added a CountdownAutomation setting to enable/disable countdown automation

This commit is contained in:
WBHarry 2025-11-17 23:19:23 +01:00
parent dccb0bfa2d
commit 9e21aa177b
4 changed files with 18 additions and 5 deletions

View file

@ -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];

View file

@ -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,