RC-116 | Weapons showing as equipped when they shouldn't be

This commit is contained in:
Oliver-Akins 2025-01-26 15:16:29 -07:00
parent 0c39efe32f
commit dd8ba4df83
2 changed files with 28 additions and 5 deletions

View file

@ -174,14 +174,32 @@ export class HeroSummaryCardV1 extends GenericAppMixin(HandlebarsApplicationMixi
const limit = ctx.actor.system.limit.weapons; const limit = ctx.actor.system.limit.weapons;
const embedded = ctx.actor.itemTypes.weapon; const embedded = ctx.actor.itemTypes.weapon;
ctx.weapons = []; 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({ ctx.weapons.push({
data: embedded[i], data: item,
empty: embedded.at(i) === undefined, empty: false,
index: i + 1, index,
class: i % 2 === 1 ? `row-alt` : ``, 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; return ctx;
}; };

View file

@ -32,6 +32,11 @@ export class WeaponData extends CommonItemData {
trim: true, trim: true,
choices: gameTerms.Access, choices: gameTerms.Access,
}), }),
equipped: new fields.BooleanField({
initial: false,
required: true,
nullable: false,
}),
}; };
}; };