From 410fd1943824f6daaa6c6a025037ea6f338226d6 Mon Sep 17 00:00:00 2001 From: WBHarry Date: Wed, 3 Dec 2025 19:13:52 +0100 Subject: [PATCH] Fixed adding and editing effects on a homebrew feature --- lang/en.json | 3 ++- .../sheets-configs/setting-feature-config.mjs | 17 +++++++++++++++-- module/data/actor/companion.mjs | 2 +- templates/settings/downtime-config/effects.hbs | 2 +- 4 files changed, 19 insertions(+), 5 deletions(-) diff --git a/lang/en.json b/lang/en.json index ce4140f0..d2e67c15 100755 --- a/lang/en.json +++ b/lang/en.json @@ -2094,6 +2094,7 @@ "missingDragDropThing": "Drop {thing} here", "multiclass": "Multiclass", "newCategory": "New Category", + "newThing": "New {thing}", "none": "None", "noTarget": "No current target", "partner": "Partner", @@ -2383,7 +2384,7 @@ "newDowntimeMove": "Downtime Move", "downtimeMove": "Downtime Move", "armorFeature": "Armor Feature", - "weaponFeature": "Weapon Feaure", + "weaponFeature": "Weapon Feature", "newFeature": "New ItemFeature", "downtimeMoves": "Downtime Moves", "itemFeatures": "Item Features", diff --git a/module/applications/sheets-configs/setting-feature-config.mjs b/module/applications/sheets-configs/setting-feature-config.mjs index 832954ad..920d658e 100644 --- a/module/applications/sheets-configs/setting-feature-config.mjs +++ b/module/applications/sheets-configs/setting-feature-config.mjs @@ -158,7 +158,14 @@ export default class SettingFeatureConfig extends HandlebarsApplicationMixin(App this.render(); } else { const action = this.move.actions.get(id); - await new DHActionConfig(action, async updatedMove => { + await new DHActionConfig(action, async (updatedMove, effectData) => { + if (effectData?.length) { + const currentEffects = foundry.utils.getProperty(this.settings, `${this.movePath}.effects`); + await this.settings.updateSource({ + [`${this.movePath}.effects`]: [...currentEffects, ...effectData] + }); + } + await this.settings.updateSource({ [`${this.actionsPath}.${id}`]: updatedMove }); this.move = foundry.utils.getProperty(this.settings, this.movePath); this.render(); @@ -167,7 +174,13 @@ export default class SettingFeatureConfig extends HandlebarsApplicationMixin(App } static async removeItem(_, target) { - await this.settings.updateSource({ [`${this.actionsPath}.-=${target.dataset.id}`]: null }); + const { type, id } = target.dataset; + if (type === 'effect') { + await this.settings.updateSource({ [`${this.movePath}.effects.-=${id}`]: null }); + } else { + await this.settings.updateSource({ [`${this.actionsPath}.-=${target.dataset.id}`]: null }); + } + this.move = foundry.utils.getProperty(this.settings, this.movePath); this.render(); } diff --git a/module/data/actor/companion.mjs b/module/data/actor/companion.mjs index a66cd028..cd81fab5 100644 --- a/module/data/actor/companion.mjs +++ b/module/data/actor/companion.mjs @@ -1,7 +1,7 @@ import BaseDataActor from './base.mjs'; import DhLevelData from '../levelData.mjs'; import ForeignDocumentUUIDField from '../fields/foreignDocumentUUIDField.mjs'; -import { ActionField, ActionsField } from '../fields/actionField.mjs'; +import { ActionField } from '../fields/actionField.mjs'; import { adjustDice, adjustRange } from '../../helpers/utils.mjs'; import DHCompanionSettings from '../../applications/sheets-configs/companion-settings.mjs'; import { resourceField, bonusField } from '../fields/actorField.mjs'; diff --git a/templates/settings/downtime-config/effects.hbs b/templates/settings/downtime-config/effects.hbs index f09fdb05..4e4bbd5b 100644 --- a/templates/settings/downtime-config/effects.hbs +++ b/templates/settings/downtime-config/effects.hbs @@ -8,7 +8,7 @@
{{#each move.effects}} - {{> "systems/daggerheart/templates/settings/components/settings-item-line.hbs" id=this.id type="effect" }} + {{> "systems/daggerheart/templates/settings/components/settings-item-line.hbs" actionId=../move.id id=this.id type="effect" }} {{/each}}