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
+1
View File
@@ -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.
+11 -7
View File
@@ -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
+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);
@@ -0,0 +1,28 @@
<div class="resource-outer-grid-1col">
<label for="actor.system.health.value"
class="resource-label"
data-tooltip="{{localize 'DG.Attributes.Tooltip.HP'}}">
{{localize 'DG.Attributes.HP' }} (<span>{{actor.system.health.protection}} <i class="fas fa-shield-alt"></i></span>)
</label>
<div class="resource-inner-grid-3col">
<input class="centered"
type="text"
name="system.health.value"
value="{{actor.system.health.value}}"
data-dtype="Number" />
<span>/</span>
{{#if (ne actor.type "unnatural") }}
<div class="max-resource-value"
data-tooltip="{{localize 'DG.Tooltip.MaximumHP'}}">
<div>{{numberFormat actor.system.health.max decimals=0 sign=false}}</div>
</div>
{{else}}
<input class="centered"
type="text"
name="system.health.max"
value="{{actor.system.health.max}}"
data-dtype="Number"
data-tooltip="{{localize 'DG.Tooltip.MaximumHP'}}" />
{{/if}}
</div>
</div>
@@ -0,0 +1,28 @@
<div class="resource-outer-grid-1col">
<label for="system.wp.value"
class="resource-label"
data-tooltip="{{localize 'DG.Attributes.Tooltip.WP'}}">
{{localize 'DG.Attributes.WP' }}
</label>
<div class="resource-inner-grid-3col">
<input class="centered"
type="text"
name="system.wp.value"
value="{{actor.system.wp.value}}"
data-dtype="Number" />
<span>/</span>
{{#if (ne actor.type "unnatural") }}
<div class="max-resource-value"
data-tooltip="{{localize 'DG.Tooltip.MaximumWP'}}">
<div>{{numberFormat actor.system.wp.max decimals=0 sign=false}}</div>
</div>
{{else}}
<input class="centered"
type="text"
name="system.wp.max"
value="{{actor.system.wp.max}}"
data-dtype="Number"
data-tooltip="{{localize 'DG.Tooltip.MaximumWP'}}" />
{{/if}}
</div>
</div>
+2 -38
View File
@@ -30,46 +30,10 @@
</div>
<div class="resources grid grid-3col">
{{!-- HP --}}
<div class="resource-outer-grid-1col">
<label for="actor.system.health.value"
class="resource-label"
data-tooltip="{{localize 'DG.Attributes.Tooltip.HP'}}">
{{localize 'DG.Attributes.HP' }} (<span>{{actor.system.health.protection}} <i class="fas fa-shield-alt"></i></span>)
</label>
<div class="resource-inner-grid-3col">
<input class="centered"
type="text"
name="system.health.value"
value="{{actor.system.health.value}}"
data-dtype="Number" />
<span>/</span>
<div class="max-resource-value"
data-tooltip="{{localize 'DG.Tooltip.MaximumHP'}}">
<div>{{numberFormat actor.system.health.max decimals=0 sign=false}}</div>
</div>
</div>
</div>
{{> "systems/deltagreen/templates/actor/partials/health-partial.html" }}
{{#if (ne actor.type "vehicle") }}
{{!-- WP --}}
<div class="resource-outer-grid-1col">
<label for="system.wp.value"
class="resource-label"
data-tooltip="{{localize 'DG.Attributes.Tooltip.WP'}}">
{{localize 'DG.Attributes.WP' }}
</label>
<div class="resource-inner-grid-3col">
<input class="centered"
type="text"
name="system.wp.value"
value="{{actor.system.wp.value}}"
data-dtype="Number" />
<span>/</span>
<div class="max-resource-value"
data-tooltip="{{localize 'DG.Tooltip.MaximumWP'}}">
<div>{{numberFormat actor.system.wp.max decimals=0 sign=false}}</div>
</div>
</div>
</div>
{{> "systems/deltagreen/templates/actor/partials/willpower-partial.html" }}
{{!-- Sanity --}}
{{> "systems/deltagreen/templates/actor/partials/sanity-partial.html" }}
{{/if}}