Add the capacity display (closes #96)

This commit is contained in:
Oliver-Akins 2024-03-17 12:54:15 -06:00
parent b6ca477be7
commit aab71df1fc
3 changed files with 16 additions and 4 deletions

View file

@ -10,6 +10,10 @@ export class CommonItemData extends foundry.abstract.TypeDataModel {
nullable: false,
integer: true,
}),
uses_inventory_slot: new fields.BooleanField({
initial: true,
nullable: false,
}),
buy: new fields.NumberField({
initial: null,
nullable: true,

View file

@ -58,6 +58,7 @@ export class PlayerSheetv2 extends GenericActorSheet {
canAddAspect: !await actor.proxyFunction.bind(actor)(`atAspectLimit`),
stats: this.#statData,
itemFilters: this.#itemFilters,
capacity: this.#inventoryCapacity,
};
console.log(ctx)
return ctx;
@ -134,6 +135,14 @@ export class PlayerSheetv2 extends GenericActorSheet {
return filters;
};
get #inventoryCapacity() {
return {
used: this.actor.items
.reduce((sum, i) => sum + i.system.uses_inventory_slot ? i.system.quantity : 0, 0),
max: this.actor.system.inventory_slots,
};
};
_updateObject(...args) {
console.log(args)
super._updateObject(...args);

View file

@ -5,10 +5,9 @@
{{> dotdungeon.pc.v2.item-list }}
<div class="e-1dp panel capacity-panel">
<h2>Capacity</h2>
{{!-- This will need some aria love --}}
<span class="used">X</span>
<span>/</span>
<span class="total">Y</span>
<span class="used">{{computed.capacity.used}}</span>
<span aria-label="inventory slots used out of">/</span>
<span class="total">{{computed.capacity.max}}</span>
</div>
<div class="e-1dp panel bytes-panel">
<label