add toggleLethality action

This commit is contained in:
jalensailin
2025-07-18 22:48:02 -04:00
parent c0c86f0c6d
commit faa11087e5
2 changed files with 14 additions and 14 deletions
+5 -8
View File
@@ -23,6 +23,7 @@ export default class DeltaGreenActorSheet extends DGSheetMixin(ActorSheetV2) {
specialTrainingAction: DeltaGreenActorSheet._onSpecialTrainingAction,
applySkillImprovements: DeltaGreenActorSheet._applySkillImprovements,
browsePack: DeltaGreenActorSheet._browsePack,
toggleLethality: DeltaGreenActorSheet._toggleLethality,
},
});
@@ -763,10 +764,6 @@ export default class DeltaGreenActorSheet extends DGSheetMixin(ActorSheetV2) {
});
}
html.find(".toggle-lethality").click((event) => {
this._toggleLethality(event);
});
// let user check off the 'bond damaged' checkbox right from the sheet
html.find(".bond-has-been-damaged-agent-sheet-checkbox").click((ev) => {
const el = $(ev.currentTarget).parents(".item");
@@ -836,10 +833,10 @@ export default class DeltaGreenActorSheet extends DGSheetMixin(ActorSheetV2) {
}
}
_toggleLethality(event) {
const itemId = event.target.getAttribute("item-id");
const isLethal = event.target.getAttribute("is-lethal") === "true";
const item = this.actor.items.find((i) => i.id === itemId);
static _toggleLethality(event, target) {
const { itemId } = target.dataset;
const isLethal = target.dataset.isLethal?.length === 0;
const item = this.actor.items.get(itemId);
item.update({ "system.isLethal": !isLethal });
}
+9 -6
View File
@@ -59,16 +59,19 @@
<span class="centered-item-property">
{{#if item.system.lethality }}
{{#if item.system.isLethal }}
<a class="item-control toggle-lethality dg-red"
<a class="item-control dg-red"
data-action="toggleLethality"
data-item-id="{{item._id}}"
data-is-lethal
title="Toggle Lethality (Current Lethality: {{item.system.lethality}}%)">
<i class="fas fa-skull-crossbones"
item-id="{{item._id}}"
is-lethal="true"></i>
<i class="fas fa-skull-crossbones"></i>
</a>
{{else}}
<a class="item-control toggle-lethality"
<a class="item-control"
data-action="toggleLethality"
data-item-id="{{item._id}}"
title="Toggle Lethality (Currently No Lethality)">
<i class="fas fa-user-injured" item-id="{{item._id}}" is-lethal="false"></i>
<i class="fas fa-user-injured"></i>
</a>
{{/if}}
{{/if}}