From 3946a8116ce5e36eaf1bc3011feb52001beba146 Mon Sep 17 00:00:00 2001 From: Sven Balzer <4653051+Kyuusokuna@users.noreply.github.com> Date: Tue, 12 Nov 2024 00:45:58 +0100 Subject: [PATCH] add dialog to attacke for custom modifier --- src/Dialogs/Attacke.hbs | 28 ++++++++++++++++ ...nkampfAngriff.hbs => FernkampfAttacke.hbs} | 0 src/main.mjs | 32 ++++++++++++++++--- 3 files changed, 56 insertions(+), 4 deletions(-) create mode 100644 src/Dialogs/Attacke.hbs rename src/Dialogs/{FernkampfAngriff.hbs => FernkampfAttacke.hbs} (100%) diff --git a/src/Dialogs/Attacke.hbs b/src/Dialogs/Attacke.hbs new file mode 100644 index 0000000..34e54b1 --- /dev/null +++ b/src/Dialogs/Attacke.hbs @@ -0,0 +1,28 @@ +
+ {{localize "DSA41.kampf.modifikator"}} + {{>editable-input type="number" name="modifikator" class="colspan2" value=(lookup formData "modifikator") }} + +
+ {{options.item.basis_attacke}}{{localize "DSA41.bewaffnung.nahkampfwaffe.basis"}} + + + {{options.item.talent_attacke}}{{localize "DSA41.talente.label"}} + + {{#if (ne options.item.modifikator_attacke 0)}} + + {{options.item.modifikator_attacke}}{{localize "DSA41.bewaffnung.nahkampfwaffe.modifikator"}} + {{/if}} + + {{#if (ne options.item.parierwaffe_attacke 0)}} + + {{options.item.parierwaffe_attacke}}{{localize "DSA41.bewaffnung.parierwaffe.label"}} + {{/if}} + + {{#if (ne options.item.schild_attacke 0)}} + + {{options.item.schild_attacke}}{{localize "DSA41.bewaffnung.schild.label"}} + {{/if}} + + {{#if (lt options.item.tp_kk 0)}} + + {{options.item.tp_kk}}{{localize "DSA41.attributes.long.strength"}} + {{/if}} + + + {{formData.modifikator}}{{localize "DSA41.kampf.modifikator"}} +
+
diff --git a/src/Dialogs/FernkampfAngriff.hbs b/src/Dialogs/FernkampfAttacke.hbs similarity index 100% rename from src/Dialogs/FernkampfAngriff.hbs rename to src/Dialogs/FernkampfAttacke.hbs diff --git a/src/main.mjs b/src/main.mjs index a08a00c..8f00392 100644 --- a/src/main.mjs +++ b/src/main.mjs @@ -590,10 +590,11 @@ function DSA41_ApplicationMixin(BaseApplication) { class DSA41_Dialog extends DSA41_ApplicationMixin(ApplicationV2) { static PARTS = { + Attacke: { template: "systems/dsa-4th-edition/src/Dialogs/Attacke.hbs" }, Parade: { template: "systems/dsa-4th-edition/src/Dialogs/Parade.hbs" }, Trefferpunkte: { template: "systems/dsa-4th-edition/src/Dialogs/Trefferpunkte.hbs" }, - FernkampfAngriff: { template: "systems/dsa-4th-edition/src/Dialogs/FernkampfAngriff.hbs" }, + FernkampfAttacke: { template: "systems/dsa-4th-edition/src/Dialogs/FernkampfAttacke.hbs" }, FernkampfTrefferpunkte: { template: "systems/dsa-4th-edition/src/Dialogs/FernkampfTrefferpunkte.hbs" }, footer: { template: "templates/generic/form-footer.hbs" }, @@ -680,17 +681,40 @@ class DSA41_ActorSheet extends DSA41_ApplicationMixin(ActorSheetV2) { flavor += " <= " + success_value; } + if (roll_type == "attacke") { + const item = this.document.system.computed.kampf.waffen[item_id]; + const title = game.i18n.localize("DSA41.roll_types." + roll_type) + ": " + item.name; + const data = await DSA41_Dialog.wait("Attacke", { window: { title: title }, item: item }); + + let flavor = game.i18n.localize("DSA41.roll_types." + roll_type); + if (typeof success_value !== 'undefined') { + flavor += " <= " + (Number(success_value) + data.modifikator); + } + + let roll = new Roll(roll_formula, this.document.system); + roll.toMessage({ + speaker: ChatMessage.getSpeaker({ actor: this.document }), + flavor: flavor, + }); + + return; + } if (roll_type == "parade") { const item = this.document.system.computed.kampf.waffen[item_id]; const title = game.i18n.localize("DSA41.roll_types." + roll_type) + ": " + item.name; const data = await DSA41_Dialog.wait("Parade", { window: { title: title }, item: item }); + let flavor = game.i18n.localize("DSA41.roll_types." + roll_type); + if (typeof success_value !== 'undefined') { + flavor += " <= " + (Number(success_value) + data.modifikator); + } + if (data.crit == "on") { roll_formula = "round((" + roll_formula + ") / 2)"; } - - let roll = new Roll(roll_formula + " + " + data.modifikator, this.document.system); + + let roll = new Roll(roll_formula, this.document.system); roll.toMessage({ speaker: ChatMessage.getSpeaker({ actor: this.document }), flavor: flavor, @@ -719,7 +743,7 @@ class DSA41_ActorSheet extends DSA41_ApplicationMixin(ActorSheetV2) { if (roll_type == "fernkampf-attacke") { const title = game.i18n.localize("DSA41.roll_types." + roll_type) + ": " + item.name; - const data = await DSA41_Dialog.wait("FernkampfAngriff", { window: { title: title }, item: this.document.system.computed.kampf.fernkampf_waffen[item_id] }); + const data = await DSA41_Dialog.wait("FernkampfAttacke", { window: { title: title }, item: this.document.system.computed.kampf.fernkampf_waffen[item_id] }); const groessen_modifikator = Math.max(data.ziel_groesse + data.deckung + data.ziel_bewegung, -2); const andere_modifikator = data.entfernung + data.wind + data.modifikator;