allow (un)equipping items

This commit is contained in:
Sven Balzer 2025-02-11 12:20:29 +01:00
parent 437a27ad28
commit 474b2b6df7
3 changed files with 23 additions and 5 deletions

View File

@ -313,6 +313,7 @@
<div class="list-header"> <div class="list-header">
<div>{{localize "DSA41.inventar.bewaffnung"}}</div> <div>{{localize "DSA41.inventar.bewaffnung"}}</div>
<div></div> <div></div>
<div></div>
<div class="center">{{localize "DSA41.weight"}}</div> <div class="center">{{localize "DSA41.weight"}}</div>
<div></div> <div></div>
</div> </div>
@ -336,6 +337,7 @@
</div> </div>
</div> </div>
<div></div> <div></div>
<div class="center fas fa-sword" data-action="toggle_equipped" data-equipped="{{system.angelegt}}"></div>
<div class="center">{{this.system.gewicht}}</div> <div class="center">{{this.system.gewicht}}</div>
<div class="center fas fa-trash" data-action="item-delete"></div> <div class="center fas fa-trash" data-action="item-delete"></div>
</div> </div>
@ -346,6 +348,7 @@
<div class="list-header"> <div class="list-header">
<div class="row">{{localize "DSA41.inventar.ruestungen"}}</div> <div class="row">{{localize "DSA41.inventar.ruestungen"}}</div>
<div></div> <div></div>
<div></div>
<div class="center">{{localize "DSA41.weight"}}</div> <div class="center">{{localize "DSA41.weight"}}</div>
</div> </div>
@ -360,6 +363,7 @@
<span class="center">{{this.name}}</span> <span class="center">{{this.name}}</span>
</div> </div>
<div></div> <div></div>
<div class="center fas fa-shield-halved" data-action="toggle_equipped" data-equipped="{{system.angelegt}}"></div>
<div class="center">{{this.system.gewicht}}</div> <div class="center">{{this.system.gewicht}}</div>
<div class="center fas fa-trash" data-action="item-delete"></div> <div class="center fas fa-trash" data-action="item-delete"></div>
</div> </div>
@ -370,6 +374,7 @@
<div class="list-header"> <div class="list-header">
<div>{{localize "DSA41.inventar.gegenstaende"}}</div> <div>{{localize "DSA41.inventar.gegenstaende"}}</div>
<div></div> <div></div>
<div></div>
<div class="center">{{localize "DSA41.weight"}}</div> <div class="center">{{localize "DSA41.weight"}}</div>
</div> </div>
@ -384,6 +389,7 @@
<span class="center">{{this.name}}</span> <span class="center">{{this.name}}</span>
</div> </div>
<div></div> <div></div>
<div></div>
<div class="center">{{this.system.gewicht}}</div> <div class="center">{{this.system.gewicht}}</div>
<div class="center fas fa-trash" data-action="item-delete"></div> <div class="center fas fa-trash" data-action="item-delete"></div>
</div> </div>

View File

@ -457,11 +457,15 @@ html {
} }
&[data-tab="tab3"] { &[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; grid-column: 1 / -1;
} }
& [data-equipped="false"] {
color: #464c5f;
}
} }
&[data-tab="tab4"] { &[data-tab="tab4"] {

View File

@ -434,7 +434,7 @@ class DSA41_CharacterData extends TypeDataModel {
this.computed.parade.wert = this.computed.parade.basiswert + this.modifikator_parade; this.computed.parade.wert = this.computed.parade.basiswert + this.modifikator_parade;
this.computed.fernkampf.wert = this.computed.fernkampf.basiswert + this.modifikator_fernkampf; 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) { for (const item of equipped_ruestungen) {
this.computed.kampf.ruestungen[item._id] = { item: item }; 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; 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_nahkampfwaffen = equipped_bewaffnung.filter((x) => x.system.nahkampfwaffe.aktiv);
const equipped_parierwaffen = equipped_bewaffnung.filter((x) => x.system.parierwaffe.aktiv); const equipped_parierwaffen = equipped_bewaffnung.filter((x) => x.system.parierwaffe.aktiv);
const equipped_schilde = equipped_bewaffnung.filter((x) => x.system.schild.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 { class DSA41_RuestungData extends TypeDataModel {
static defineSchema() { static defineSchema() {
return { return {
angelegt: new BooleanField({ initial: false }),
gewicht: new NumberField({ integer: false, initial: 0, min: 0 }), gewicht: new NumberField({ integer: false, initial: 0, min: 0 }),
preis: new NumberField({ integer: true, 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 { class DSA41_BewaffnungData extends TypeDataModel {
static defineSchema() { static defineSchema() {
return { return {
angelegt: new BooleanField({ initial: false }),
gewicht: new NumberField({ integer: false, initial: 0, min: 0 }), gewicht: new NumberField({ integer: false, initial: 0, min: 0 }),
preis: new NumberField({ integer: true, initial: 0, min: 0 }), preis: new NumberField({ integer: true, initial: 0, min: 0 }),
angelegt: new BooleanField(),
nahkampfwaffe: new SchemaField({ nahkampfwaffe: new SchemaField({
aktiv: new BooleanField(), aktiv: new BooleanField(),
@ -1065,6 +1067,12 @@ class DSA41_ActorSheet extends DSA41_ApplicationMixin(ActorSheetV2) {
const item = this.document.items.get(item_id); const item = this.document.items.get(item_id);
item.delete(); 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 });
},
}, },
}; };