diff --git a/CHANGELOG.md b/CHANGELOG.md index b381778..d4416e7 100644 --- a/CHANGELOG.md +++ b/CHANGELOG.md @@ -11,6 +11,7 @@ ### **Bug Fixes:** +- [#269](https://github.com/deltagreen-foundryvtt/delta-green-foundry-vtt-system/issues/269) - Added calculation for max HP and max WP for unnatural and allow to edit them. - [#274](https://github.com/deltagreen-foundryvtt/delta-green-foundry-vtt-system/issues/274) - Automated fail marking now works after dice so nice resolve roll. - [#268](https://github.com/deltagreen-foundryvtt/delta-green-foundry-vtt-system/issues/268) - Removed unnecessary tooltips. - [#278](https://github.com/deltagreen-foundryvtt/delta-green-foundry-vtt-system/issues/278) - It shows the tooltip only once for skills without proficiency. diff --git a/module/actor/actor.js b/module/actor/actor.js index b0133ad..fc1690d 100644 --- a/module/actor/actor.js +++ b/module/actor/actor.js @@ -126,14 +126,18 @@ export default class DeltaGreenActor extends Actor { statistic.x5 = statistic.value * 5; } - system.wp.max = system.statistics.pow.value; + if (system.wp.maxNeedsUpdate) { + system.wp.max = system.statistics.pow.value; + } - try { - system.health.max = Math.ceil( - (system.statistics.con.value + system.statistics.str.value) / 2, - ); - } catch { - system.health.max = 10; + if (system.health.maxNeedsUpdate) { + try { + system.health.max = Math.ceil( + (system.statistics.con.value + system.statistics.str.value) / 2, + ); + } catch { + system.health.max = 10; + } } // calculate total armor rating diff --git a/module/sheets/base-actor-sheet.js b/module/sheets/base-actor-sheet.js index 470a4fe..2413187 100644 --- a/module/sheets/base-actor-sheet.js +++ b/module/sheets/base-actor-sheet.js @@ -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); diff --git a/templates/actor/partials/health-partial.html b/templates/actor/partials/health-partial.html new file mode 100644 index 0000000..d03ec45 --- /dev/null +++ b/templates/actor/partials/health-partial.html @@ -0,0 +1,28 @@ +