From 474b2b6df7366f567a4e10a74ea9108af1839a17 Mon Sep 17 00:00:00 2001 From: Sven Balzer <4653051+Kyuusokuna@users.noreply.github.com> Date: Tue, 11 Feb 2025 12:20:29 +0100 Subject: [PATCH] allow (un)equipping items --- src/ActorSheet.hbs | 6 ++++++ src/main.css | 6 +++++- src/main.mjs | 16 ++++++++++++---- 3 files changed, 23 insertions(+), 5 deletions(-) diff --git a/src/ActorSheet.hbs b/src/ActorSheet.hbs index ca0c8d4..0e9341a 100644 --- a/src/ActorSheet.hbs +++ b/src/ActorSheet.hbs @@ -313,6 +313,7 @@
{{localize "DSA41.inventar.bewaffnung"}}
+
{{localize "DSA41.weight"}}
@@ -336,6 +337,7 @@
+
{{this.system.gewicht}}
@@ -346,6 +348,7 @@
{{localize "DSA41.inventar.ruestungen"}}
+
{{localize "DSA41.weight"}}
@@ -360,6 +363,7 @@ {{this.name}}
+
{{this.system.gewicht}}
@@ -370,6 +374,7 @@
{{localize "DSA41.inventar.gegenstaende"}}
+
{{localize "DSA41.weight"}}
@@ -384,6 +389,7 @@ {{this.name}}
+
{{this.system.gewicht}}
diff --git a/src/main.css b/src/main.css index 4723daa..9cb4888 100644 --- a/src/main.css +++ b/src/main.css @@ -457,11 +457,15 @@ html { } &[data-tab="tab3"] { - grid-template-columns: minmax(min-content, max-content) auto minmax(min-content, max-content) min-content; + grid-template-columns: minmax(min-content, max-content) auto min-content minmax(min-content, max-content) min-content; & > * { grid-column: 1 / -1; } + + & [data-equipped="false"] { + color: #464c5f; + } } &[data-tab="tab4"] { diff --git a/src/main.mjs b/src/main.mjs index 9f787dc..6fde228 100644 --- a/src/main.mjs +++ b/src/main.mjs @@ -434,7 +434,7 @@ class DSA41_CharacterData extends TypeDataModel { this.computed.parade.wert = this.computed.parade.basiswert + this.modifikator_parade; this.computed.fernkampf.wert = this.computed.fernkampf.basiswert + this.modifikator_fernkampf; - const equipped_ruestungen = this.parent.items.filter((x) => x.type === "Ruestung"); + const equipped_ruestungen = this.parent.items.filter((x) => x.type === "Ruestung" && x.system.angelegt === true); for (const item of equipped_ruestungen) { this.computed.kampf.ruestungen[item._id] = { item: item }; @@ -464,7 +464,7 @@ class DSA41_CharacterData extends TypeDataModel { this.computed.kampf.talente[talent.name].talent_parade = talent.system.parade; } - const equipped_bewaffnung = this.parent.items.filter((x) => x.type === "Bewaffnung"); + const equipped_bewaffnung = this.parent.items.filter((x) => x.type === "Bewaffnung" && x.system.angelegt === true); const equipped_nahkampfwaffen = equipped_bewaffnung.filter((x) => x.system.nahkampfwaffe.aktiv); const equipped_parierwaffen = equipped_bewaffnung.filter((x) => x.system.parierwaffe.aktiv); const equipped_schilde = equipped_bewaffnung.filter((x) => x.system.schild.aktiv); @@ -586,6 +586,8 @@ class DSA41_GegenstandData extends TypeDataModel { class DSA41_RuestungData extends TypeDataModel { static defineSchema() { return { + angelegt: new BooleanField({ initial: false }), + gewicht: new NumberField({ integer: false, initial: 0, min: 0 }), preis: new NumberField({ integer: true, initial: 0, min: 0 }), @@ -607,11 +609,11 @@ class DSA41_RuestungData extends TypeDataModel { class DSA41_BewaffnungData extends TypeDataModel { static defineSchema() { return { + angelegt: new BooleanField({ initial: false }), + gewicht: new NumberField({ integer: false, initial: 0, min: 0 }), preis: new NumberField({ integer: true, initial: 0, min: 0 }), - angelegt: new BooleanField(), - nahkampfwaffe: new SchemaField({ aktiv: new BooleanField(), @@ -1065,6 +1067,12 @@ class DSA41_ActorSheet extends DSA41_ApplicationMixin(ActorSheetV2) { const item = this.document.items.get(item_id); item.delete(); }, + + "toggle_equipped": async function(event, target) { + const item_id = event.target.closest("[data-item-id]").dataset.itemId; + const item = this.document.items.get(item_id); + item.update({ "system.angelegt": !item.system.angelegt }); + }, }, };