Fixed DowntimeMoves and ItemFeatures reset functions (#1568)

This commit is contained in:
WBHarry 2026-01-21 13:47:03 +01:00 committed by GitHub
parent f659d08d58
commit 38fb00bd10
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
4 changed files with 34 additions and 7 deletions

View file

@ -2506,6 +2506,7 @@
"itemFeatures": "Item Features",
"nrChoices": "# Moves Per Rest",
"resetMovesTitle": "Reset {type} Downtime Moves",
"resetItemFeaturesTitle": "Reset {type}",
"resetMovesText": "Are you sure you want to reset?",
"FIELDS": {
"maxFear": { "label": "Max Fear" },

View file

@ -36,7 +36,8 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
addItem: this.addItem,
editItem: this.editItem,
removeItem: this.removeItem,
resetMoves: this.resetMoves,
resetDowntimeMoves: this.resetDowntimeMoves,
resetItemFeatures: this.resetItemFeatures,
addDomain: this.addDomain,
toggleSelectedDomain: this.toggleSelectedDomain,
deleteDomain: this.deleteDomain,
@ -232,7 +233,7 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
this.render();
}
static async resetMoves(_, target) {
static async resetDowntimeMoves(_, target) {
const confirmed = await foundry.applications.api.DialogV2.confirm({
window: {
title: game.i18n.format('DAGGERHEART.SETTINGS.Homebrew.resetMovesTitle', {
@ -266,7 +267,7 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
...move,
name: game.i18n.localize(move.name),
description: game.i18n.localize(move.description),
actions: move.actions.reduce((acc, key) => {
actions: Object.keys(move.actions).reduce((acc, key) => {
const action = move.actions[key];
acc[key] = {
...action,
@ -293,6 +294,31 @@ export default class DhHomebrewSettings extends HandlebarsApplicationMixin(Appli
this.render();
}
static async resetItemFeatures(_, target) {
const confirmed = await foundry.applications.api.DialogV2.confirm({
window: {
title: game.i18n.format('DAGGERHEART.SETTINGS.Homebrew.resetItemFeaturesTitle', {
type: game.i18n.localize(`DAGGERHEART.GENERAL.${target.dataset.type}`)
})
},
content: game.i18n.localize('DAGGERHEART.SETTINGS.Homebrew.resetMovesText')
});
if (!confirmed) return;
await this.settings.updateSource({
[`itemFeatures.${target.dataset.type}`]: Object.keys(
this.settings.itemFeatures[target.dataset.type]
).reduce((acc, key) => {
acc[`-=${key}`] = null;
return acc;
}, {})
});
this.render();
}
static async addDomain(event) {
event.preventDefault();
const content = new foundry.data.fields.StringField({

View file

@ -10,7 +10,7 @@
<legend>
{{localize "DAGGERHEART.APPLICATIONS.Downtime.longRest.title"}}
<a data-action="addItem" data-type="longRest"><i class="fa-solid fa-plus"></i></a>
<a data-action="resetMoves" data-type="longRest"><i class="fa-solid fa-arrow-rotate-left"></i></a>
<a data-action="resetDowntimeMoves" data-type="longRest"><i class="fa-solid fa-arrow-rotate-left"></i></a>
</legend>
<div class="form-group setting-group-field">
@ -31,7 +31,7 @@
<legend>
{{localize "DAGGERHEART.APPLICATIONS.Downtime.shortRest.title"}}
<a data-action="addItem" data-type="shortRest"><i class="fa-solid fa-plus"></i></a>
<a data-action="resetMoves" data-type="shortRest"><i class="fa-solid fa-arrow-rotate-left"></i></a>
<a data-action="resetDowntimeMoves" data-type="shortRest"><i class="fa-solid fa-arrow-rotate-left"></i></a>
</legend>
<div class="form-group setting-group-field">

View file

@ -8,7 +8,7 @@
<legend>
{{localize "DAGGERHEART.GENERAL.weaponFeatures"}}
<a data-action="addItem" data-type="weaponFeatures"><i class="fa-solid fa-plus"></i></a>
<a data-action="resetMoves" data-type="weaponFeatures"><i class="fa-solid fa-arrow-rotate-left"></i></a>
<a data-action="resetItemFeatures" data-type="weaponFeatures"><i class="fa-solid fa-arrow-rotate-left"></i></a>
</legend>
<div class="settings-items">
@ -22,7 +22,7 @@
<legend>
{{localize "DAGGERHEART.GENERAL.armorFeatures"}}
<a data-action="addItem" data-type="armorFeatures"><i class="fa-solid fa-plus"></i></a>
<a data-action="resetMoves" data-type="armorFeatures"><i class="fa-solid fa-arrow-rotate-left"></i></a>
<a data-action="resetItemFeatures" data-type="armorFeatures"><i class="fa-solid fa-arrow-rotate-left"></i></a>
</legend>
<div class="settings-items">