fix (#269): allow to edit max wp and hp for unnatural

This commit is contained in:
Samuel Lopez
2025-12-05 08:47:20 +01:00
committed by samulopez
parent 590cbd1664
commit 5c2caa5146
6 changed files with 94 additions and 46 deletions
+24 -1
View File
@@ -36,7 +36,11 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) {
static BASE_PARTS = /** @type {const} */ ({
header: {
template: `${this.TEMPLATE_PATH}/parts/header.html`,
templates: [`${this.TEMPLATE_PATH}/partials/sanity-partial.html`],
templates: [
`${this.TEMPLATE_PATH}/partials/health-partial.html`,
`${this.TEMPLATE_PATH}/partials/willpower-partial.html`,
`${this.TEMPLATE_PATH}/partials/sanity-partial.html`,
],
},
tabs: {
template: `templates/generic/tab-navigation.hbs`, // From FoundryVTT
@@ -59,6 +63,25 @@ export default class DGActorSheet extends DGSheetMixin(ActorSheetV2) {
},
});
/** @override */
async _processSubmitData(event, form, submitData, options) {
const submittedData = foundry.utils.expandObject(submitData);
// we need to update max WP if POW has changed (only for unnatural, but doesn't hurt others)
submittedData.system.wp.maxNeedsUpdate =
submittedData.system?.statistics.pow.value !==
this.actor.system.statistics.pow.value;
// we need to update max HP if STR or CON have changed (only for unnatural, but doesn't hurt others)
submittedData.system.health.maxNeedsUpdate =
submittedData.system?.statistics.str.value !==
this.actor.system.statistics.str.value ||
submittedData.system?.statistics.con.value !==
this.actor.system.statistics.con.value;
return super._processSubmitData(event, form, submittedData, options);
}
/** @override */
async _prepareContext(options) {
const context = await super._prepareContext(options);