Fixed adding and editing effects on a homebrew feature

This commit is contained in:
WBHarry 2025-12-03 19:13:52 +01:00
parent 8f917c3640
commit 410fd19438
4 changed files with 19 additions and 5 deletions

View file

@ -2094,6 +2094,7 @@
"missingDragDropThing": "Drop {thing} here", "missingDragDropThing": "Drop {thing} here",
"multiclass": "Multiclass", "multiclass": "Multiclass",
"newCategory": "New Category", "newCategory": "New Category",
"newThing": "New {thing}",
"none": "None", "none": "None",
"noTarget": "No current target", "noTarget": "No current target",
"partner": "Partner", "partner": "Partner",
@ -2383,7 +2384,7 @@
"newDowntimeMove": "Downtime Move", "newDowntimeMove": "Downtime Move",
"downtimeMove": "Downtime Move", "downtimeMove": "Downtime Move",
"armorFeature": "Armor Feature", "armorFeature": "Armor Feature",
"weaponFeature": "Weapon Feaure", "weaponFeature": "Weapon Feature",
"newFeature": "New ItemFeature", "newFeature": "New ItemFeature",
"downtimeMoves": "Downtime Moves", "downtimeMoves": "Downtime Moves",
"itemFeatures": "Item Features", "itemFeatures": "Item Features",

View file

@ -158,7 +158,14 @@ export default class SettingFeatureConfig extends HandlebarsApplicationMixin(App
this.render(); this.render();
} else { } else {
const action = this.move.actions.get(id); 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 }); await this.settings.updateSource({ [`${this.actionsPath}.${id}`]: updatedMove });
this.move = foundry.utils.getProperty(this.settings, this.movePath); this.move = foundry.utils.getProperty(this.settings, this.movePath);
this.render(); this.render();
@ -167,7 +174,13 @@ export default class SettingFeatureConfig extends HandlebarsApplicationMixin(App
} }
static async removeItem(_, target) { 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.move = foundry.utils.getProperty(this.settings, this.movePath);
this.render(); this.render();
} }

View file

@ -1,7 +1,7 @@
import BaseDataActor from './base.mjs'; import BaseDataActor from './base.mjs';
import DhLevelData from '../levelData.mjs'; import DhLevelData from '../levelData.mjs';
import ForeignDocumentUUIDField from '../fields/foreignDocumentUUIDField.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 { adjustDice, adjustRange } from '../../helpers/utils.mjs';
import DHCompanionSettings from '../../applications/sheets-configs/companion-settings.mjs'; import DHCompanionSettings from '../../applications/sheets-configs/companion-settings.mjs';
import { resourceField, bonusField } from '../fields/actorField.mjs'; import { resourceField, bonusField } from '../fields/actorField.mjs';

View file

@ -8,7 +8,7 @@
<div class="settings-items"> <div class="settings-items">
{{#each move.effects}} {{#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}} {{/each}}
</div> </div>
</fieldset> </fieldset>