From ae0ca2018f7249fce7445795753c9b13bda27162 Mon Sep 17 00:00:00 2001 From: Sven Balzer <4653051+Kyuusokuna@users.noreply.github.com> Date: Sat, 24 May 2025 15:55:41 +0200 Subject: [PATCH] add simple zauber rolls --- src/ActorSheet.hbs | 2 +- src/Chat/Zauber.hbs | 39 +++++++++++++++++++++++++++++++++ src/Dialogs/Zauber.hbs | 4 ++++ src/lang/de.json | 6 ++++-- src/main.css | 18 ++++++++++++++++ src/main.mjs | 49 ++++++++++++++++++++++++++++++++++++++++++ 6 files changed, 115 insertions(+), 3 deletions(-) create mode 100644 src/Chat/Zauber.hbs create mode 100644 src/Dialogs/Zauber.hbs diff --git a/src/ActorSheet.hbs b/src/ActorSheet.hbs index ddace65..4bb1fe9 100644 --- a/src/ActorSheet.hbs +++ b/src/ActorSheet.hbs @@ -580,7 +580,7 @@
-
+
{{>die-type type=system.attribute1}} {{>die-type type=system.attribute2}} {{>die-type type=system.attribute3}} diff --git a/src/Chat/Zauber.hbs b/src/Chat/Zauber.hbs new file mode 100644 index 0000000..872208f --- /dev/null +++ b/src/Chat/Zauber.hbs @@ -0,0 +1,39 @@ +
+

{{zauber.name}} ({{localize (concat "DSA41.chat.zauberfertigkeitswert_short")}}: {{zauber.system.zauberfertigkeitswert}}{{#if (ne modifikator 0)}} + {{modifikator}}{{/if}})

+
+
+
{{localize (concat "DSA41.chat.attribute")}}
+
{{localize (concat "DSA41.chat.value")}}
+
{{localize (concat "DSA41.chat.roll")}}
+
{{localize (concat "DSA41.chat.zauberfertigkeitswert_short")}}
+
+
+
{{localize (concat "DSA41.attributes.long." attribute1.type)}}
+
{{attribute1.value}}
+
{{roll1}}
+
{{needed_zfw_roll1}}
+
+
+
{{localize (concat "DSA41.attributes.long." attribute2.type)}}
+
{{attribute2.value}}
+
{{roll2}}
+
{{needed_zfw_roll2}}
+
+
+
{{localize (concat "DSA41.attributes.long." attribute3.type)}}
+
{{attribute3.value}}
+
{{roll3}}
+
{{needed_zfw_roll3}}
+
+
+ +
+ {{localize (concat "DSA41.chat.result")}}: + {{#if (lt leftover_zfw 0)}} + {{localize (concat "DSA41.chat.failure")}} + {{else}} + {{localize (concat "DSA41.chat.success")}} + {{/if}} + ({{localize (concat "DSA41.chat.zauberfertigkeitswert_short")}}: {{leftover_zfw}}) +
+
diff --git a/src/Dialogs/Zauber.hbs b/src/Dialogs/Zauber.hbs new file mode 100644 index 0000000..604c2f6 --- /dev/null +++ b/src/Dialogs/Zauber.hbs @@ -0,0 +1,4 @@ +
+ {{localize "DSA41.kampf.modifikator"}} + +
diff --git a/src/lang/de.json b/src/lang/de.json index 1d7c258..0971e9c 100644 --- a/src/lang/de.json +++ b/src/lang/de.json @@ -79,7 +79,8 @@ "value": "Wert", "roll": "Wurf", - "talentwert_short": "TaW", + "talentwert_short": "TaW", + "zauberfertigkeitswert_short": "ZfW", "targets": "Ziele", "trefferpunkte_apply": "Zuweisen" @@ -146,7 +147,8 @@ "constitution": "Konstitution", "strength": "Körperkraft", - "talent": "Talent", + "talent": "Talent", + "zauber": "Zauber", "attacke": "Attacke", "parade": "Parade", diff --git a/src/main.css b/src/main.css index 8a097eb..e0714a0 100644 --- a/src/main.css +++ b/src/main.css @@ -644,6 +644,24 @@ html { } } +.zauber_chat_message { + & .info { + display: grid; + grid-template-columns: repeat(4, minmax(min-content, 1fr)); + text-wrap: nowrap; + + & > * { + display: grid; + grid-column: 1 / -1; + grid-template-columns: subgrid; + + & > *:not(:first-child) { + text-align: center; + } + } + } +} + #tooltip.DSA41 { max-width: 650px; diff --git a/src/main.mjs b/src/main.mjs index ee1a5f8..ff7a0cf 100644 --- a/src/main.mjs +++ b/src/main.mjs @@ -147,6 +147,7 @@ Hooks.once("init", async function() { "CHAT_HEADER": "systems/dsa-4th-edition/src/Chat/Header.hbs", "TrefferpunkteTargets": "systems/dsa-4th-edition/src/Chat/TrefferpunkteTargets.hbs", "talent_chat": "systems/dsa-4th-edition/src/Chat/Talent.hbs", + "zauber_chat": "systems/dsa-4th-edition/src/Chat/Zauber.hbs", }); }); @@ -1142,6 +1143,7 @@ class DSA41_Dialog extends DSA41_ApplicationMixin(ApplicationV2) { static PARTS = { Eigenschaft: { template: "systems/dsa-4th-edition/src/Dialogs/Attribute.hbs" }, Talent: { template: "systems/dsa-4th-edition/src/Dialogs/Talent.hbs" }, + Zauber: { template: "systems/dsa-4th-edition/src/Dialogs/Zauber.hbs" }, Attacke: { template: "systems/dsa-4th-edition/src/Dialogs/Attacke.hbs" }, Parade: { template: "systems/dsa-4th-edition/src/Dialogs/Parade.hbs" }, @@ -1437,6 +1439,53 @@ class DSA41_ActorSheet extends DSA41_ApplicationMixin(ActorSheetV2) { } if (roll_type == "zauber") { + const title = game.i18n.localize("DSA41.roll_types." + roll_type) + ": " + item.name; + const data = await DSA41_Dialog.wait("Zauber", { window: {title: title}, item: item }); + + const zauberfertigkeitswert = item.system.zauberfertigkeitswert - data.modifikator; + const roll_modifier = zauberfertigkeitswert < 0 ? -zauberfertigkeitswert: 0; + + const roll1 = (await new Roll("1d20").evaluate()).total + roll_modifier; + const roll2 = (await new Roll("1d20").evaluate()).total + roll_modifier; + const roll3 = (await new Roll("1d20").evaluate()).total + roll_modifier; + + const attribute1 = this.document.system.computed.attributes[item.system.attribute1]; + const attribute2 = this.document.system.computed.attributes[item.system.attribute2]; + const attribute3 = this.document.system.computed.attributes[item.system.attribute3]; + + const needed_zfw_roll1 = Math.max(roll1 - attribute1, 0); + const needed_zfw_roll2 = Math.max(roll2 - attribute2, 0); + const needed_zfw_roll3 = Math.max(roll3 - attribute3, 0); + + const leftover_zfw = Math.max(zauberfertigkeitswert, 0) - needed_zfw_roll1 - needed_zfw_roll2 - needed_zfw_roll3; + + const context = { + zauber: item, + modifikator: -data.modifikator, + + attribute1: { type: item.system.attribute1, value: attribute1 }, + attribute2: { type: item.system.attribute2, value: attribute3 }, + attribute3: { type: item.system.attribute3, value: attribute3 }, + + roll1: roll1, + roll2: roll2, + roll3: roll3, + + needed_zfw_roll1: -needed_zfw_roll1, + needed_zfw_roll2: -needed_zfw_roll2, + needed_zfw_roll3: -needed_zfw_roll3, + + leftover_zfw: Math.min(leftover_zfw, item.system.zauberfertigkeitswert), + }; + + const message = await ChatMessage.create( + { + content: await renderTemplate("zauber_chat", context), + speaker: { actor: this.actor }, + sound: CONFIG.sounds.dice, + }, + ); + return; }