add resetBreakingPoint action

This commit is contained in:
jalensailin
2025-07-18 22:48:02 -04:00
parent 189394a460
commit 175d1d20bb
2 changed files with 15 additions and 14 deletions
+13 -13
View File
@@ -18,6 +18,7 @@ export default class DeltaGreenActorSheet extends DGSheetMixin(ActorSheetV2) {
actions: {
itemAction: DeltaGreenActorSheet._onItemAction,
roll: DeltaGreenActorSheet._onRoll,
resetBreakingPoint: DeltaGreenActorSheet._resetBreakingPoint,
},
});
@@ -613,19 +614,6 @@ export default class DeltaGreenActorSheet extends DGSheetMixin(ActorSheetV2) {
});
}
// Custom Sheet Macros
html.find(".btn-reset-breaking-point").click((event) => {
event.preventDefault();
let currentBreakingPoint = 0;
currentBreakingPoint =
this.actor.system.sanity.value - this.actor.system.statistics.pow.value;
const updatedData = foundry.utils.duplicate(this.actor.system);
updatedData.sanity.currentBreakingPoint = currentBreakingPoint;
this.actor.update({ system: updatedData });
});
html.find(".typed-skill-add").click((event) => {
event.preventDefault();
@@ -836,6 +824,18 @@ export default class DeltaGreenActorSheet extends DGSheetMixin(ActorSheetV2) {
});
}
/** Resets the actor's current breaking point based on their sanity and POW statistics. */
static _resetBreakingPoint() {
const systemData = this.actor.system;
const newBreakingPoint =
systemData.sanity.value - systemData.statistics.pow.value;
const updatedData = foundry.utils.duplicate(systemData);
updatedData.sanity.currentBreakingPoint = newBreakingPoint;
this.actor.update({ system: updatedData });
}
// trigger an update on all bonds that have had their damaged flag checked off
async _updateBondsRemoveAllDamagedCheckmarks() {
for (const i of this.actor.items) {
+2 -1
View File
@@ -14,7 +14,8 @@
name="system.sanity.currentBreakingPoint"
value="{{actor.system.sanity.currentBreakingPoint}}"
data-dtype="Number" />
<a class="btn-tiny btn-reset-breaking-point"
<a class="btn-tiny"
data-action="resetBreakingPoint"
title="{{localize 'DG.Tooltip.BreakPointReset'}}">{{localize 'DG.Mental.Reset'}}</a>
</div>