From 00fb647f0fc756eae3c9fb1a6e087678979dee99 Mon Sep 17 00:00:00 2001
From: Sven Balzer <4653051+Kyuusokuna@users.noreply.github.com>
Date: Thu, 17 Oct 2024 19:59:31 +0200
Subject: [PATCH] add basic attribute and combat rolls
---
src/ActorSheet.html | 63 +++++++++++++++++++---
src/lang/de.json | 129 +++++++++++++++++++++++++++++++++++++++++---
src/main.css | 35 ++++++++----
src/main.mjs | 89 ++++++++++++++++++++++++++++--
4 files changed, 289 insertions(+), 27 deletions(-)
diff --git a/src/ActorSheet.html b/src/ActorSheet.html
index 685c355..4ee9f65 100644
--- a/src/ActorSheet.html
+++ b/src/ActorSheet.html
@@ -38,8 +38,8 @@
{{#*inline "die-value"}}
-
{{localize (concat "DSA41.attributes.short." type)}}
-
{{lookup @root.actor.system.computed.attributes.with_modifiers type}}
+ {{#if header}}
{{header}}
{{/if}}
+
{{value}}
{{/inline}}
@@ -54,7 +54,7 @@
@@ -134,7 +137,7 @@
{{#each actor.itemTypes.Bewaffnung}}
-
+
{{this.name}}
@@ -202,8 +205,9 @@
+
{{this.system.gewicht}}
-
{{>editable-checkbox value=this.system.angelegt}}
+
{{/each}}
@@ -243,5 +247,48 @@
+
+
+
+
+
+ {{#each actor.system.computed.kampf.waffen}}
+
+
+

+
+ {{item.name}}
+
+
+
{{>die-value type="attacke" data-roll="1d20" value=attacke}}
+
{{>die-value type="parade" data-roll="1d20" value=parade}}
+
{{>die-value type="trefferpunkte" data-roll=trefferpunkte}}
+
+ {{/each}}
+
+
+
+
+ {{#each actor.itemTypes.Ruestung}}
+
+
+

+
{{this.name}}
+
+
{{this.system.gewicht}}
+
{{>editable-checkbox value=this.system.angelegt}}
+
+ {{/each}}
+
+
+
\ No newline at end of file
diff --git a/src/lang/de.json b/src/lang/de.json
index 084060d..f232a45 100644
--- a/src/lang/de.json
+++ b/src/lang/de.json
@@ -15,10 +15,26 @@
"weight": "Gewicht",
"price": "Preis",
+ "roll_types": {
+ "courage": "Mut",
+ "cleverness": "Klugheit",
+ "intuition": "Intuition",
+ "charisma": "Charisma",
+ "dexterity": "Fingerfertigkeit",
+ "agility": "Gewandheit",
+ "constitution": "Konstitution",
+ "strength": "Körperkraft",
+
+ "attacke": "Attacke",
+ "parade": "Parade",
+ "trefferpunkte": "Trefferpunkte"
+ },
+
"character": {
"eigenschaften": "Eigenschaften",
"talente": "Talente",
- "inventar": "Inventar"
+ "inventar": "Inventar",
+ "kampf": "Kampf"
},
"attributes": {
@@ -63,8 +79,33 @@
"label_parade_total": "Parade",
"name": {
- "anderthalbhaender": "Anderthalbhänder",
- "armbrust": "Armbrust"
+ "anderthalbhaender": "Anderthalbhänder",
+ "armbrust": "Armbrust",
+ "belagerungswaffen": "Belagerungswaffen",
+ "blasrohr": "Blasrohr",
+ "bogen": "Bogen",
+ "diskus": "Diskus",
+ "dolche": "Dolche",
+ "fechtwaffen": "Fechtwaffen",
+ "hiebwaffen": "Hiebwaffen",
+ "infanteriewaffen": "Infanteriewaffen",
+ "kettenstaebe": "Kettenstäbe",
+ "kettenwaffen": "Kettenwaffen",
+ "lanzenreiten": "Lanzenreiten",
+ "peitsche": "Peitsche",
+ "raufen": "Raufen",
+ "ringen": "Ringen",
+ "saebel": "Saebel",
+ "schleuder": "Schleuder",
+ "schwerter": "Schwerter",
+ "speere": "Speere",
+ "staebe": "Stäbe",
+ "wurfbeile": "Wurfbeile",
+ "wurfmesser": "Wurfmesser",
+ "wurfspeere": "Wurfspeere",
+ "zweihandflegel": "Zweihandflegel",
+ "zweihand_hiebwaffen": "Zweihand-Hiebwaffen",
+ "zweihandschwerter": "Zweihandschwerter/-säbel"
}
},
@@ -128,8 +169,29 @@
"label": "Wissenstalente",
"name": {
- "anatomie": "Anatomie",
- "baukunst": "Baukunst"
+ "anatomie": "Anatomie",
+ "baukunst": "Baukunst",
+ "brett_kartenspiel": "Brett-/Kartenspiel",
+ "geographie": "Geographie",
+ "geschichtswissen": "Geschichtswissen",
+ "gesteinskunde": "Gesteinskunde",
+ "goetter_kulte": "Götter/Kulte",
+ "heraldik": "Heraldik",
+ "huettenkunde": "Hüttenkunde",
+ "kriegskunst": "Kriegskunst",
+ "kryptographie": "Kryptographie",
+ "magiekunde": "Magiekunde",
+ "mechanik": "Mechanik",
+ "pflanzenkunde": "Pflanzenkunde",
+ "philosophie": "Philosophie",
+ "rechnen": "Rechnen",
+ "rechtskunde": "Rechtskunde",
+ "sagen_legenden": "Sagen/Legenden",
+ "schaetzen": "Schätzen",
+ "sprachenkunde": "Sprachenkunde",
+ "staatskunst": "Staatskunst",
+ "sternkunde": "Sternenkunde",
+ "tierkunde": "Tierkunde"
}
},
@@ -147,8 +209,53 @@
"label": "Handwerkstalente",
"name": {
- "abrichten": "Abrichten",
- "ackerbau": "Ackerbau"
+ "abrichten": "Abrichten",
+ "ackerbau": "Ackerbau",
+ "alchimie": "Alchimie",
+ "bergbau": "Bergbau",
+ "bogenbau": "Bogenbau",
+ "boote_fahren": "Boote Fahren",
+ "brauer": "Brauer",
+ "drucker": "Drucker",
+ "fahrzeug_lenken": "Fahrzeug Lenken",
+ "falschspiel": "Falschspiel",
+ "feinmechanik": "Feinmechanik",
+ "feuersteinbearbeitung": "Feuersteinbearbeitung",
+ "fleischer": "Fleischer",
+ "gerber": "Gerber/Kürschner",
+ "glaskunst": "Glaskunst",
+ "grobschmied": "Grobschmied",
+ "handel": "Handel",
+ "hauswirtschaft": "Hauswirtschaft",
+ "heilkunde_gift": "Heilkunde Gift",
+ "heilkunde_krankheiten": "Heilkunde Krankheiten",
+ "heilkunde_seele": "Heilkunde Seele",
+ "heilkunde_wunden": "Heilkunde Wunden",
+ "holzbearbeitung": "Holzbearbeitung",
+ "instrumentenbauer": "Instrumentenbauer",
+ "kartographie": "Kartographie",
+ "kochen": "Kochen",
+ "kristallzucht": "Kristallzucht",
+ "lederarbeiten": "Lederarbeiten",
+ "malen_zeichnen": "Malen/Zeichnen",
+ "maurer": "Maurer",
+ "metallguss": "Metallguss",
+ "musizieren": "Musizieren",
+ "schloesser_knacken": "Schlösser Knacken",
+ "schnapps_brennen": "Schnapps Brennen",
+ "schneidern": "Schneidern",
+ "seefahrt": "Seefahrt",
+ "seiler": "Seiler",
+ "steinmetz": "Steinmetz",
+ "juwelier": "Steinschneider/Juwelier",
+ "stellmacher": "Stellmacher",
+ "stoffe_faerben": "Stoffe Faerben",
+ "taetowieren": "Tätowieren",
+ "toepfern": "Töpfern",
+ "viehzucht": "Viehzucht",
+ "webkunst": "Webkunst",
+ "winzer": "Winzer",
+ "zimmermann": "Zimmermann"
}
}
},
@@ -233,6 +340,14 @@
"bewaffnung": "Bewaffnung",
"ruestungen": "Rüstungen",
"gegenstaende": "Gegenstände"
+ },
+
+ "kampf": {
+ "bewaffnung": "Bewaffnung",
+ "attacke": "Attacke",
+ "parade": "Parade",
+ "trefferpunkte": "Trefferpunkte",
+ "ruestungen": "Rüstungen"
}
}
}
\ No newline at end of file
diff --git a/src/main.css b/src/main.css
index ea0ca52..4b54ee4 100644
--- a/src/main.css
+++ b/src/main.css
@@ -49,7 +49,7 @@
-.die {
+.sheet .die {
width: 48px;
height: 48px;
line-height: 48px;
@@ -62,14 +62,30 @@
color: #fff;
}
-.die-courage { background-color: #b22319; }
-.die-cleverness { background-color: #8158a3; }
-.die-intuition { background-color: #388834; }
-.die-charisma { background-color: #0c0c0c; }
-.die-dexterity { background-color: #d4b366; }
-.die-agility { background-color: #678ec3; }
-.die-constitution { background-color: #a3a3a3; }
-.die-strength { background-color: #d5a877; }
+.sheet .die-courage { background-color: #b22319; }
+.sheet .die-cleverness { background-color: #8158a3; }
+.sheet .die-intuition { background-color: #388834; }
+.sheet .die-charisma { background-color: #0c0c0c; }
+.sheet .die-dexterity { background-color: #d4b366; }
+.sheet .die-agility { background-color: #678ec3; }
+.sheet .die-constitution { background-color: #a3a3a3; }
+.sheet .die-strength { background-color: #d5a877; }
+
+.sheet .die-attacke { background-color: #b22319; }
+.sheet .die-parade { background-color: #388834; }
+.sheet .die-trefferpunkte { background-color: #0c0c0c; }
+
+.sheet .item-open,
+.sheet .item-delete,
+.sheet .roll {
+ cursor: pointer;
+}
+
+.sheet .item-open:hover,
+.sheet .item-delete:hover,
+.sheet .roll:hover {
+ transform: scale(1.05);
+}
.character-image {
@@ -101,6 +117,7 @@
.item-name {
gap: 0.5rem;
+ flex: 0 1 auto;
}
.item-sub {
diff --git a/src/main.mjs b/src/main.mjs
index cb0d67c..4b3177b 100644
--- a/src/main.mjs
+++ b/src/main.mjs
@@ -1,6 +1,4 @@
Hooks.once("init", function() {
- console.log("INIT");
-
CONFIG.Combat.initiative.formula = "1d6 + @computed.ini_basiswert[INI-Basiswert]";
CONFIG.Actor.dataModels.Player = DSA41_CharacterData;
@@ -240,6 +238,11 @@ class DSA41_CharacterData extends foundry.abstract.TypeDataModel {
without_modifiers: {},
with_modifiers: {},
},
+
+ kampf: {
+ talente: {},
+ waffen: {},
+ },
};
for (const [attribute, values] of Object.entries(this.attributes)) {
@@ -257,7 +260,54 @@ class DSA41_CharacterData extends foundry.abstract.TypeDataModel {
this.computed.pa_basiswert = Math.round((this.computed.attributes.without_modifiers.intuition + this.computed.attributes.without_modifiers.agility + this.computed.attributes.without_modifiers.strength) / 5);;
this.computed.fk_basiswert = Math.round((this.computed.attributes.without_modifiers.intuition + this.computed.attributes.without_modifiers.dexterity + this.computed.attributes.without_modifiers.strength) / 5);;
-
+ for(const [name, values] of Object.entries(this.kampf_talente)) {
+ this.computed.kampf.talente[name] = {};
+ this.computed.kampf.talente[name].attacke = this.computed.at_basiswert + values.attacke;
+ this.computed.kampf.talente[name].parade = this.computed.pa_basiswert + values.parade;
+ }
+
+ let equipped_bewaffnung = this.parent.items.filter((x) => x.type === "Bewaffnung");
+ let equipped_nahkampfwaffen = equipped_bewaffnung.filter((x) => x.system.nahkampfwaffe.aktiv);
+ let equipped_parierwaffen = equipped_bewaffnung.filter((x) => x.system.parierwaffe.aktiv);
+ let equipped_schilde = equipped_bewaffnung.filter((x) => x.system.schild.aktiv);
+ let equipped_fernkampfwaffen = equipped_bewaffnung.filter((x) => x.system.fernkampfwaffe.aktiv);
+
+ for(const item of equipped_nahkampfwaffen) {
+ this.computed.kampf.waffen[item._id] = {};
+ this.computed.kampf.waffen[item._id].item = item;
+
+ if (item.system.nahkampfwaffe.aktiv) {
+ const talent = item.system.nahkampfwaffe.kampftalente;
+
+ this.computed.kampf.waffen[item._id].attacke = this.computed.kampf.talente[talent].attacke + item.system.nahkampfwaffe.modifikator_attacke;
+ this.computed.kampf.waffen[item._id].parade = this.computed.kampf.talente[talent].parade + item.system.nahkampfwaffe.modifikator_attacke;
+
+ const tp_kk = Math.trunc((this.computed.attributes.with_modifiers.strength - item.system.nahkampfwaffe.schwellenwert) / item.system.nahkampfwaffe.schadensschritte);
+
+ if (tp_kk >= 0) {
+ this.computed.kampf.waffen[item._id].trefferpunkte = item.system.nahkampfwaffe.basis + " + " + tp_kk;
+ } else {
+ this.computed.kampf.waffen[item._id].trefferpunkte = item.system.nahkampfwaffe.basis + "" + tp_kk;
+
+ this.computed.kampf.waffen[item._id].attacke += tp_kk;
+ this.computed.kampf.waffen[item._id].parade += tp_kk;
+ }
+
+ for (const parierwaffe of equipped_parierwaffen) {
+ if (parierwaffe._id === item._id) continue;
+
+ this.computed.kampf.waffen[item._id].attacke += parierwaffe.system.parierwaffe.modifikator_attacke;
+ this.computed.kampf.waffen[item._id].parade += parierwaffe.system.parierwaffe.modifikator_parade;
+ }
+
+ for (const schild of equipped_schilde) {
+ if (schild._id === item._id) continue;
+
+ this.computed.kampf.waffen[item._id].attacke += schild.system.schild.modifikator_attacke;
+ this.computed.kampf.waffen[item._id].parade += schild.system.schild.modifikator_parade;
+ }
+ }
+ }
}
}
@@ -380,6 +430,39 @@ class DSA41_ActorSheet extends ActorSheet {
get template() {
return "systems/dsa-4th-edition/src/ActorSheet.html";
}
+
+ activateListeners(html) {
+ super.activateListeners(html);
+
+ html.on("click", ".item-open", async (event) => {
+ const item_id = event.currentTarget.closest("[data-item-id]").dataset.itemId;
+ const item = this.object.items.get(item_id);
+ item.sheet.render(true)
+ });
+
+ html.on("click", ".item-delete", async (event) => {
+ const item_id = event.currentTarget.closest("[data-item-id]").dataset.itemId;
+ const item = this.object.items.get(item_id);
+ item.delete();
+ });
+
+ html.on("click", ".roll", async (event) => {
+ const roll_formula = event.currentTarget.closest("[data-roll]").dataset.roll;
+ const roll_type = event.currentTarget.closest("[data-roll]").dataset.rollType;
+ const success_value = event.currentTarget.closest("[data-roll]").dataset.successValue;
+
+ let flavor = game.i18n.localize("DSA41.roll_types." + roll_type);
+ if (typeof success_value !== 'undefined') {
+ flavor += " <= " + success_value;
+ }
+
+ let roll = new Roll(roll_formula, this.object.system);
+ roll.toMessage({
+ speaker: ChatMessage.getSpeaker({ actor: this.object }),
+ flavor: flavor,
+ });
+ });
+ }
}
class DSA41_ItemSheet extends ItemSheet {