Implements rudimentary item management
parent
edf6dcab1a
commit
39917a0f89
|
|
@ -20,6 +20,7 @@ async function preloadHandlebarsTemplates() {
|
|||
'systems/DSA_4-1/templates/ui/partial-talent-editable.hbs',
|
||||
'systems/DSA_4-1/templates/ui/partial-die.hbs',
|
||||
'systems/DSA_4-1/templates/ui/partial-advantage-button.hbs',
|
||||
'systems/DSA_4-1/templates/ui/partial-equipment-button.hbs',
|
||||
'systems/DSA_4-1/templates/ui/partial-array-editor.hbs'
|
||||
]);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -156,6 +156,7 @@ export class CharacterSheet extends ActorSheet {
|
|||
#addEquipmentsToContext(context) {
|
||||
context.equipments = [];
|
||||
const actorData = context.data;
|
||||
context.carryingweight = 0;
|
||||
Object.values(actorData.items).forEach( (item, index) => {
|
||||
if (item.type === "Equipment") {
|
||||
context.equipments.push({
|
||||
|
|
@ -164,8 +165,11 @@ export class CharacterSheet extends ActorSheet {
|
|||
quantity: item.system.quantity,
|
||||
name: item.name,
|
||||
})
|
||||
context.carryingweight += item.system.quantity * item.system.weight;
|
||||
}
|
||||
})
|
||||
context.maxcarryingcapacity = actorData.system.attribute.kk.aktuell
|
||||
context.carryingpercentage = (context.carryingweight / context.maxcarryingcapacity)*100;
|
||||
}
|
||||
|
||||
prepareEigenschaftRoll(actorData, name) {
|
||||
|
|
@ -323,7 +327,7 @@ export class CharacterSheet extends ActorSheet {
|
|||
})
|
||||
|
||||
html.on('click', '.equipment .name', (evt) => {
|
||||
this.openEmbeddedDocument(evt.target.dataset.id);
|
||||
this.openEmbeddedDocument(evt.target.parentElement.dataset.id);
|
||||
evt.stopPropagation();
|
||||
})
|
||||
|
||||
|
|
@ -358,6 +362,17 @@ export class CharacterSheet extends ActorSheet {
|
|||
li.addEventListener("dragstart", handler, false);
|
||||
});
|
||||
|
||||
new ContextMenu(html, '.equipment', [
|
||||
{
|
||||
name: "Aus dem Inventar entfernen",
|
||||
icon: '<i class="fa-solid fa-trash"></i>',
|
||||
callback: (event) => {
|
||||
this.object.deleteEmbeddedDocuments('Item', [event[0].dataset.id])
|
||||
},
|
||||
condition: () => true
|
||||
}
|
||||
]);
|
||||
|
||||
}
|
||||
|
||||
#handleDroppedSkill(actor, skill) {
|
||||
|
|
|
|||
|
|
@ -65,9 +65,22 @@ export class GroupSheet extends ActorSheet {
|
|||
}
|
||||
)
|
||||
}
|
||||
console.log(groupData, context.characters)
|
||||
return await context;
|
||||
|
||||
|
||||
context.equipments = [];
|
||||
const actorData = context.data;
|
||||
Object.values(actorData.items).forEach( (item, index) => {
|
||||
if (item.type === "Equipment") {
|
||||
context.equipments.push({
|
||||
index: index,
|
||||
id: item._id,
|
||||
quantity: item.system.quantity,
|
||||
name: item.name,
|
||||
})
|
||||
}
|
||||
})
|
||||
|
||||
return await context;
|
||||
}
|
||||
|
||||
/** @override */
|
||||
|
|
@ -97,6 +110,16 @@ export class GroupSheet extends ActorSheet {
|
|||
})
|
||||
ui.notifications.info(`${character.name} ist der Heldengruppe ${group.name} beigetreten`)
|
||||
}
|
||||
if (data.type === "Equipment") {
|
||||
const uuid = await foundry.utils.parseUuid(data.uuid);
|
||||
const equipment = await (game.actors.get(uuid.id))
|
||||
ui.notifications.info(`${equipment.name} befindet sich nun im Inventar der Heldengruppe ${group.name}`)
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
openEmbeddedDocument(documentId) {
|
||||
this.object.items.get(documentId).sheet.render(true)
|
||||
}
|
||||
|
||||
activateListeners(html) {
|
||||
|
|
@ -122,5 +145,22 @@ export class GroupSheet extends ActorSheet {
|
|||
(await game.actors.get(id)).sheet.render(true);
|
||||
}
|
||||
})
|
||||
|
||||
|
||||
html.on('click', '.equipment .name', (evt) => {
|
||||
this.openEmbeddedDocument(evt.target.dataset.id);
|
||||
evt.stopPropagation();
|
||||
})
|
||||
|
||||
new ContextMenu(html, '.equipment', [
|
||||
{
|
||||
name: "Aus dem Gruppeninventar entfernen",
|
||||
icon: '<i class="fa-solid fa-trash"></i>',
|
||||
callback: (event) => {
|
||||
this.object.deleteEmbeddedDocuments('Item', [event[0].dataset.id])
|
||||
},
|
||||
condition: () => true
|
||||
}
|
||||
]);
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -52,6 +52,39 @@
|
|||
overflow: auto;
|
||||
}
|
||||
|
||||
.backpack {
|
||||
position: absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
padding: 8px;
|
||||
|
||||
.resource {
|
||||
|
||||
position: relative;
|
||||
border: 1px inset #ccc;
|
||||
background-color: rgba(0,0,0,0.2);
|
||||
height: 8px;
|
||||
|
||||
span.fill {
|
||||
position:absolute;
|
||||
left: 0;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
background: linear-gradient(to bottom, #0bad29 0%,#11f128 50%,#0cde24 51%,#6ff77b 100%);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
.equipment:hover {
|
||||
.item-name {
|
||||
text-shadow: 0 0 10px rgb(255 0 0);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -5,14 +5,17 @@
|
|||
position: relative;
|
||||
top: 5px;
|
||||
|
||||
.tab.meta.active {
|
||||
|
||||
position: absolute;
|
||||
.tab.active {
|
||||
padding: 4px;
|
||||
top: 0;
|
||||
bottom: 0;
|
||||
left: 0;
|
||||
right: 0;
|
||||
padding: 4px;
|
||||
}
|
||||
|
||||
.tab.meta.active {
|
||||
|
||||
position: absolute;
|
||||
display: grid;
|
||||
grid-auto-columns: 1fr 1fr;
|
||||
grid-template-columns: 80px auto;
|
||||
|
|
|
|||
|
|
@ -18,16 +18,19 @@
|
|||
position: absolute;
|
||||
left: 0;
|
||||
right: 0;
|
||||
top: 27px;
|
||||
top: 76px;
|
||||
height: 32px;
|
||||
padding: 0 16px;
|
||||
}
|
||||
|
||||
.sheet-body {
|
||||
position: absolute;
|
||||
top: 112px;
|
||||
left: 2px;
|
||||
bottom: 2px;
|
||||
right: 2px;
|
||||
top: 98px;
|
||||
left: 0;
|
||||
bottom: 0;
|
||||
right: 0;
|
||||
padding: 8px;
|
||||
margin: 8px;
|
||||
|
||||
div.tab {
|
||||
height: 100%;
|
||||
|
|
@ -41,6 +44,7 @@
|
|||
overflow-x: auto;
|
||||
height: 100%;
|
||||
width: 100%;
|
||||
gap: 8px;
|
||||
|
||||
&.minimal {
|
||||
display: unset!important;
|
||||
|
|
@ -167,4 +171,10 @@
|
|||
|
||||
}
|
||||
|
||||
.equipment:hover {
|
||||
.item-name {
|
||||
text-shadow: 0 0 10px rgb(255 0 0);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
|||
|
|
@ -146,14 +146,16 @@
|
|||
</div>
|
||||
<div class="tab backpack" data-group="primary" data-tab="backpack">
|
||||
|
||||
<ul>
|
||||
<div class="capacity">
|
||||
<label>Tragkraft: {{this.carryingweight}} von maximal {{this.maxcarryingcapacity}} Stein</label>
|
||||
<div class="resource">
|
||||
<span class="fill" style="width: {{this.carryingpercentage}}%"></span>
|
||||
</div>
|
||||
</div>
|
||||
|
||||
{{#each equipments}}
|
||||
<li class="equipment">
|
||||
<span class="quantity">{{this.quantity}}</span>
|
||||
<span class="name" data-id="{{this.id}}">{{this.name}}</span>
|
||||
</li>
|
||||
{{> "systems/DSA_4-1/templates/ui/partial-equipment-button.hbs" this}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
|
||||
</div>
|
||||
<div class="tab spells" data-group="primary" data-tab="spells">
|
||||
|
|
|
|||
|
|
@ -68,6 +68,11 @@
|
|||
{{/if}}
|
||||
</div>
|
||||
<div class="tab inventory" data-group="primary" data-tab="inventory">
|
||||
<ul>
|
||||
{{#each equipments}}
|
||||
{{> 'systems/DSA_4-1/templates/ui/partial-equipment-button.hbs' this}}
|
||||
{{/each}}
|
||||
</ul>
|
||||
</div>
|
||||
</section>
|
||||
|
||||
|
|
|
|||
|
|
@ -0,0 +1,4 @@
|
|||
<div class="equipment" data-id="{{this.id}}">
|
||||
<span class="quantity">{{this.quantity}}</span>
|
||||
<span class="item-name">{{this.name}}</span>
|
||||
</div>
|
||||
Loading…
Reference in New Issue