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 { LaidOutAppMixin } from "../mixins/LaidOutAppMixin.mjs";
import { localizer } from "../../utils/Localizer.mjs"; import { localizer } from "../../utils/Localizer.mjs";
import { editItemFromElement, deleteItemFromElement } from "../utils.mjs"; import { editItemFromElement, deleteItemFromElement } from "../utils.mjs";
import { gameTerms } from "../../gameTerms.mjs";
const { HandlebarsApplicationMixin } = foundry.applications.api; const { HandlebarsApplicationMixin } = foundry.applications.api;
const { ActorSheetV2 } = foundry.applications.sheets; const { ActorSheetV2 } = foundry.applications.sheets;
@ -131,11 +132,34 @@ export class BookGeistSheet extends
}; };
async _prepareItemsContext(ctx) { async _prepareItemsContext(ctx) {
ctx.defense = { const armours = this.actor.system.equippedArmour;
locations: `None`, 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, protection: 0,
shield: false, 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}> ctx.traits = []; // Array<{name: string}>
for (const item of this.actor.items) { for (const item of this.actor.items) {

View file

@ -34,15 +34,26 @@
</div> </div>
{{/if}} {{/if}}
<div>Defense</div> <div>Defense</div>
<div> <ul>
Armour {{#each defenses as |defense|}}
{{rc-ifOut defense.protection}} <li
/ class="defense"
{{defense.locations}} data-tooltip="{{defense.tooltip}}"
{{#if defense.shield}} data-ctx-menu="item"
, <span>Shield</span> data-item-id="{{defense.armourUUID}}"
{{/if}} >
</div> {{defense.name}} ({{defense.protection}}{{#if defense.shielded}},
<rc-icon
name="icons/shield/solid.v1"
var:size="14px"
var:fill="currentColor"
data-ctx-menu="item"
data-item-id="{{defense.shieldUUID}}"
/>
{{/if}})
</li>
{{/each}}
</ul>
<div>Traits</div> <div>Traits</div>
<ul class="traits"> <ul class="traits">
{{#each traits as |trait|}} {{#each traits as |trait|}}

View file

@ -81,14 +81,14 @@
grid-template-rows: repeat(3, auto); grid-template-rows: repeat(3, auto);
gap: 2px; gap: 2px;
.traits { ul {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
gap: 8px; gap: 4px;
list-style-type: none; list-style-type: none;
} }
.trait { li {
display: flex; display: flex;
flex-direction: row; flex-direction: row;
align-items: center; align-items: center;