From dd8ba4df8399ef6ec73c1fb218bb97be748c7e20 Mon Sep 17 00:00:00 2001 From: Oliver-Akins Date: Sun, 26 Jan 2025 15:16:29 -0700 Subject: [PATCH] RC-116 | Weapons showing as equipped when they shouldn't be --- module/Apps/ActorSheets/HeroSummaryCardV1.mjs | 28 +++++++++++++++---- module/data/Item/Weapon.mjs | 5 ++++ 2 files changed, 28 insertions(+), 5 deletions(-) diff --git a/module/Apps/ActorSheets/HeroSummaryCardV1.mjs b/module/Apps/ActorSheets/HeroSummaryCardV1.mjs index d45de3a..41d9191 100644 --- a/module/Apps/ActorSheets/HeroSummaryCardV1.mjs +++ b/module/Apps/ActorSheets/HeroSummaryCardV1.mjs @@ -174,14 +174,32 @@ export class HeroSummaryCardV1 extends GenericAppMixin(HandlebarsApplicationMixi const limit = ctx.actor.system.limit.weapons; const embedded = ctx.actor.itemTypes.weapon; ctx.weapons = []; - for (let i = 0; i < limit; i++) { + for (const item of embedded) { + if (!item.system.equipped) { continue }; + + const index = ctx.weapons.length; ctx.weapons.push({ - data: embedded[i], - empty: embedded.at(i) === undefined, - index: i + 1, - class: i % 2 === 1 ? `row-alt` : ``, + data: item, + empty: false, + index, + class: index % 2 === 1 ? `row-alt` : ``, }); + + if (ctx.weapons.length >= limit) { break }; }; + + if (ctx.weapons.length < limit) { + for (let i = ctx.weapons.length - 1; i <= limit; i++) { + const itemIndex = ctx.weapons.length; + ctx.weapons.push({ + data: null, + empty: true, + index: itemIndex, + class: itemIndex % 2 === 1 ? `row-alt` : ``, + }); + }; + }; + return ctx; }; diff --git a/module/data/Item/Weapon.mjs b/module/data/Item/Weapon.mjs index a81b951..3292069 100644 --- a/module/data/Item/Weapon.mjs +++ b/module/data/Item/Weapon.mjs @@ -32,6 +32,11 @@ export class WeaponData extends CommonItemData { trim: true, choices: gameTerms.Access, }), + equipped: new fields.BooleanField({ + initial: false, + required: true, + nullable: false, + }), }; };