Tweak the way armour shows up on the sheet so that it's a bit easier to deal with

This commit is contained in:
Eldritch-Oliver 2025-10-15 22:35:44 -06:00
parent 8ed6f49c8d
commit 1d13f38f81
3 changed files with 51 additions and 16 deletions

View file

@ -3,6 +3,7 @@ import { GenericAppMixin } from "../mixins/GenericApp.mjs";
import { LaidOutAppMixin } from "../mixins/LaidOutAppMixin.mjs";
import { localizer } from "../../utils/Localizer.mjs";
import { editItemFromElement, deleteItemFromElement } from "../utils.mjs";
import { gameTerms } from "../../gameTerms.mjs";
const { HandlebarsApplicationMixin } = foundry.applications.api;
const { ActorSheetV2 } = foundry.applications.sheets;
@ -131,11 +132,34 @@ export class BookGeistSheet extends
};
async _prepareItemsContext(ctx) {
ctx.defense = {
locations: `None`,
protection: 0,
shield: false,
const armours = this.actor.system.equippedArmour;
const shield = this.actor.system.equippedShield;
let defenses = [];
for (const [location, armour] of Object.entries(armours)) {
if (!armour) { continue }
const defense = {
name: localizer(`RipCrypt.common.anatomy.${location}`),
tooltip: null,
protection: 0,
shielded: false,
};
if (armour) {
defense.armourUUID = armour.uuid;
defense.tooltip = armour.name,
defense.protection = armour.system.protection;
}
if (shield?.system.location.has(location)) {
defense.shieldUUID = shield.uuid;
defense.shielded = true;
defense.protection += shield.system.protection;
};
if (defense.protection > 0) {
defenses.push(defense);
};
};
ctx.defenses = defenses
ctx.traits = []; // Array<{name: string}>
for (const item of this.actor.items) {