add dialog to select Trefferzone on damage application

This commit is contained in:
Sven Balzer 2025-02-04 22:59:44 +01:00
parent add059a902
commit 53bff7a4a6
2 changed files with 26 additions and 2 deletions

View File

@ -0,0 +1,12 @@
<div class="trefferzone_dialog">
<select name="trefferzone" class="colspan4">
<option value="kopf" {{#if (eq formData.trefferzone "kopf") }}selected{{/if}}>{{localize "DSA41.ruestungen.kopf"}} </option>
<option value="brust" {{#if (eq formData.trefferzone "brust") }}selected{{/if}}>{{localize "DSA41.ruestungen.brust"}} </option>
<option value="ruecken" {{#if (eq formData.trefferzone "ruecken") }}selected{{/if}}>{{localize "DSA41.ruestungen.ruecken"}} </option>
<option value="bauch" {{#if (eq formData.trefferzone "bauch") }}selected{{/if}}>{{localize "DSA41.ruestungen.bauch"}} </option>
<option value="linker_arm" {{#if (eq formData.trefferzone "linker_arm") }}selected{{/if}}>{{localize "DSA41.ruestungen.linker_arm"}} </option>
<option value="rechter_arm" {{#if (eq formData.trefferzone "rechter_arm") }}selected{{/if}}>{{localize "DSA41.ruestungen.rechter_arm"}} </option>
<option value="linkes_bein" {{#if (eq formData.trefferzone "linkes_bein") }}selected{{/if}}>{{localize "DSA41.ruestungen.linkes_bein"}} </option>
<option value="rechtes_bein" {{#if (eq formData.trefferzone "rechtes_bein")}}selected{{/if}}>{{localize "DSA41.ruestungen.rechtes_bein"}}</option>
</select>
</div>

View File

@ -139,7 +139,7 @@ class DSA41_ChatMessage extends ChatMessage {
}
for (const element of html.querySelectorAll("[data-action]")) {
element.addEventListener("click", event => {
element.addEventListener("click", async event => {
const target = event.target;
const action = target.dataset.action;
if (action === null) return;
@ -151,7 +151,17 @@ class DSA41_ChatMessage extends ChatMessage {
const target_actor = fromUuidSync(target_actor_id);
if (!target_actor) return;
target_actor.update({ "system.lebenspunkte.aktuell": target_actor.system.lebenspunkte.aktuell - this.rolls[0].total });
const dialog_data = await DSA41_Dialog.wait("Trefferzone", { window: {title: "Trefferzone"} });
const trefferzone = dialog_data.trefferzone;
const rolled_damage = this.rolls[0].total;
const target_hp = target_actor.system.lebenspunkte.aktuell;
const target_rs = target_actor.system.computed.kampf.ruestungen_gesamt[trefferzone];
const damage = Math.max(rolled_damage - target_rs, 0);
const new_hp = target_hp - damage;
target_actor.update({ "system.lebenspunkte.aktuell": new_hp });
}
});
}
@ -747,6 +757,8 @@ class DSA41_Dialog extends DSA41_ApplicationMixin(ApplicationV2) {
FernkampfAttacke: { template: "systems/dsa-4th-edition/src/Dialogs/FernkampfAttacke.hbs" },
FernkampfTrefferpunkte: { template: "systems/dsa-4th-edition/src/Dialogs/FernkampfTrefferpunkte.hbs" },
Trefferzone: { template: "systems/dsa-4th-edition/src/Dialogs/Trefferzone.hbs" },
footer: { template: "templates/generic/form-footer.hbs" },
};