From cd184cdf010dcd4de38abae4b2bbb7ebb1226ae2 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Tue, 27 Jan 2026 20:45:14 +0100 Subject: [PATCH] Added automation settings for wether to have deathmove automation --- lang/en.json | 5 +++-- module/applications/dialogs/deathMove.mjs | 20 ++++++++++++------- .../settings/automationSettings.mjs | 4 ++-- module/data/settings/Automation.mjs | 19 ++++++++++++++++++ .../{rules.hbs => deathMoves.hbs} | 15 +++++++++++--- 5 files changed, 49 insertions(+), 14 deletions(-) rename templates/settings/automation-settings/{rules.hbs => deathMoves.hbs} (65%) diff --git a/lang/en.json b/lang/en.json index ad503ff0..47aba990 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2111,7 +2111,6 @@ "tier4": "tier 4", "domains": "Domains", "downtime": "Downtime", - "itemFeatures": "Item Features", "roll": "Roll", "rules": "Rules", "partyMembers": "Party Members", @@ -2120,7 +2119,8 @@ "questions": "Questions", "configuration": "Configuration", "base": "Base", - "triggers": "Triggers" + "triggers": "Triggers", + "deathMoves": "Deathmoves" }, "Tiers": { "singular": "Tier", @@ -2144,6 +2144,7 @@ "armorSlots": "Armor Slots", "artistAttribution": "Artwork By: {artist}", "attack": "Attack", + "automation": "Automation", "basics": "Basics", "bonus": "Bonus", "burden": "Burden", diff --git a/module/applications/dialogs/deathMove.mjs b/module/applications/dialogs/deathMove.mjs index 3eadede6..e10fe46b 100644 --- a/module/applications/dialogs/deathMove.mjs +++ b/module/applications/dialogs/deathMove.mjs @@ -43,7 +43,7 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV return context; } - async handleAvoidDeath() { + async handleAvoidDeath(useAutomation) { const target = this.actor.uuid; const config = await enrichedFateRoll({ target, @@ -53,6 +53,7 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV }); if (!config.roll.fate) return; + if (!useAutomation) return ''; let returnMessage = game.i18n.localize('DAGGERHEART.UI.Chat.deathMove.avoidScar'); if (config.roll.fate.value <= this.actor.system.levelData.level.current) { @@ -75,7 +76,7 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV return returnMessage; } - async handleRiskItAll() { + async handleRiskItAll(useAutomation) { const config = await enrichedDualityRoll({ reaction: true, traitValue: null, @@ -90,6 +91,7 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV }); if (!config.roll.result) return; + if (!useAutomation) return ''; const clearAllStressAndHitpointsUpdates = [ { key: 'hitPoints', clear: true }, @@ -128,7 +130,9 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV return chatMessage; } - async handleBlazeOfGlory() { + async handleBlazeOfGlory(useAutomation) { + if (!useAutomation) return ''; + this.actor.createEmbeddedDocuments('ActiveEffect', [ { name: game.i18n.localize('DAGGERHEART.CONFIG.DeathMoves.blazeOfGlory.name'), @@ -160,19 +164,21 @@ export default class DhDeathMove extends HandlebarsApplicationMixin(ApplicationV let result = ''; + const deathMoveAutomation = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.Automation) + .deathMoves.automation; if (CONFIG.DH.GENERAL.deathMoves.blazeOfGlory === this.selectedMove) { - result = await this.handleBlazeOfGlory(); + result = await this.handleBlazeOfGlory(deathMoveAutomation.blazeOfGlory); } if (CONFIG.DH.GENERAL.deathMoves.avoidDeath === this.selectedMove) { - result = await this.handleAvoidDeath(); + result = await this.handleAvoidDeath(deathMoveAutomation.avoidDeath); } if (CONFIG.DH.GENERAL.deathMoves.riskItAll === this.selectedMove) { - result = await this.handleRiskItAll(); + result = await this.handleRiskItAll(deathMoveAutomation.riskItAll); } - if (!result) return; + if (result === undefined) return; const autoExpandDescription = game.settings.get(CONFIG.DH.id, CONFIG.DH.SETTINGS.gameSettings.appearance) .expandRollMessage?.desc; diff --git a/module/applications/settings/automationSettings.mjs b/module/applications/settings/automationSettings.mjs index 4407897d..e720733e 100644 --- a/module/applications/settings/automationSettings.mjs +++ b/module/applications/settings/automationSettings.mjs @@ -34,7 +34,7 @@ export default class DhAutomationSettings extends HandlebarsApplicationMixin(App tabs: { template: 'systems/daggerheart/templates/sheets/global/tabs/tab-navigation.hbs' }, header: { template: 'systems/daggerheart/templates/settings/automation-settings/header.hbs' }, general: { template: 'systems/daggerheart/templates/settings/automation-settings/general.hbs' }, - rules: { template: 'systems/daggerheart/templates/settings/automation-settings/rules.hbs' }, + rules: { template: 'systems/daggerheart/templates/settings/automation-settings/deathMoves.hbs' }, roll: { template: 'systems/daggerheart/templates/settings/automation-settings/roll.hbs' }, footer: { template: 'systems/daggerheart/templates/settings/automation-settings/footer.hbs' } }; @@ -42,7 +42,7 @@ export default class DhAutomationSettings extends HandlebarsApplicationMixin(App /** @inheritdoc */ static TABS = { main: { - tabs: [{ id: 'general' }, { id: 'rules' }, { id: 'roll' }], + tabs: [{ id: 'general' }, { id: 'deathMoves' }, { id: 'roll' }], initial: 'general', labelPrefix: 'DAGGERHEART.GENERAL.Tabs' } diff --git a/module/data/settings/Automation.mjs b/module/data/settings/Automation.mjs index c3b88bb8..623eaafc 100644 --- a/module/data/settings/Automation.mjs +++ b/module/data/settings/Automation.mjs @@ -60,6 +60,25 @@ export default class DhAutomation extends foundry.abstract.DataModel { initial: true, label: 'DAGGERHEART.SETTINGS.Automation.FIELDS.resourceScrollTexts.label' }), + deathMoves: new fields.SchemaField({ + automation: new fields.SchemaField({ + avoidDeath: new fields.BooleanField({ + required: true, + initial: true, + label: 'DAGGERHEART.CONFIG.DeathMoves.avoidDeath.name' + }), + riskItAll: new fields.BooleanField({ + required: true, + initial: true, + label: 'DAGGERHEART.CONFIG.DeathMoves.riskItAll.name' + }), + blazeOfGlory: new fields.BooleanField({ + required: true, + initial: true, + label: 'DAGGERHEART.CONFIG.DeathMoves.blazeOfGlory.name' + }) + }) + }), defeated: new fields.SchemaField({ enabled: new fields.BooleanField({ required: true, diff --git a/templates/settings/automation-settings/rules.hbs b/templates/settings/automation-settings/deathMoves.hbs similarity index 65% rename from templates/settings/automation-settings/rules.hbs rename to templates/settings/automation-settings/deathMoves.hbs index 24f0b262..59cbcdbd 100644 --- a/templates/settings/automation-settings/rules.hbs +++ b/templates/settings/automation-settings/deathMoves.hbs @@ -1,8 +1,17 @@
+
+ + {{localize "DAGGERHEART.GENERAL.automation"}} + + + {{formGroup settingFields.schema.fields.deathMoves.fields.automation.fields.avoidDeath value=settingFields._source.deathMoves.automation.avoidDeath localize=true}} + {{formGroup settingFields.schema.fields.deathMoves.fields.automation.fields.riskItAll value=settingFields._source.deathMoves.automation.riskItAll localize=true}} + {{formGroup settingFields.schema.fields.deathMoves.fields.automation.fields.blazeOfGlory value=settingFields._source.deathMoves.automation.blazeOfGlory localize=true}} +
{{localize "DAGGERHEART.SETTINGS.Automation.defeated.title"}}