From aab71df1fcef7cdbd0e4d88d10e95eb74f2bcf67 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Sun, 17 Mar 2024 12:54:15 -0600 Subject: [PATCH] Add the capacity display (closes #96) --- module/models/Item/CommonItemData.mjs | 4 ++++ module/sheets/Actors/PC/PlayerSheetV2.mjs | 9 +++++++++ .../char-sheet/v2/partials/inventory/player.v2.pc.hbs | 7 +++---- 3 files changed, 16 insertions(+), 4 deletions(-) diff --git a/module/models/Item/CommonItemData.mjs b/module/models/Item/CommonItemData.mjs index fb32dc7..abcbb5a 100644 --- a/module/models/Item/CommonItemData.mjs +++ b/module/models/Item/CommonItemData.mjs @@ -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, diff --git a/module/sheets/Actors/PC/PlayerSheetV2.mjs b/module/sheets/Actors/PC/PlayerSheetV2.mjs index 0b5b47c..feac28a 100644 --- a/module/sheets/Actors/PC/PlayerSheetV2.mjs +++ b/module/sheets/Actors/PC/PlayerSheetV2.mjs @@ -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); diff --git a/templates/actors/char-sheet/v2/partials/inventory/player.v2.pc.hbs b/templates/actors/char-sheet/v2/partials/inventory/player.v2.pc.hbs index 5dc0340..0270e40 100644 --- a/templates/actors/char-sheet/v2/partials/inventory/player.v2.pc.hbs +++ b/templates/actors/char-sheet/v2/partials/inventory/player.v2.pc.hbs @@ -5,10 +5,9 @@ {{> dotdungeon.pc.v2.item-list }}

Capacity

- {{!-- This will need some aria love --}} - X - / - Y + {{computed.capacity.used}} + / + {{computed.capacity.max}}