Add Craft as it's own section item. Display the attack range

This commit is contained in:
Eldritch-Oliver 2025-10-13 21:29:56 -06:00
parent 28345bdef0
commit cd69228e68
3 changed files with 52 additions and 15 deletions

View file

@ -124,7 +124,6 @@ export class BookGeistSheet extends
};
async _prepareItemsContext(ctx) {
ctx.attacks = [];
ctx.defense = {
locations: `None`,
protection: 0,
@ -136,9 +135,15 @@ export class BookGeistSheet extends
switch (item.type) {
case `weapon`: {
if (!item.system.equipped) { continue };
ctx.attacks ??= [];
ctx.attacks.push(this._prepareWeapon(item));
break;
};
case `craft`: {
ctx.crafts ??= [];
ctx.crafts.push(this._prepareCraft(item));
break;
};
case `trait`: {
ctx.traits.push(this._prepareTrait(item));
break;
@ -148,14 +153,25 @@ export class BookGeistSheet extends
};
_prepareWeapon(weapon) {
const hasShortRange = weapon.system.range.short != null;
const hasLongRange = weapon.system.range.long != null;
const isRanged = hasShortRange || hasLongRange;
return {
uuid: weapon.uuid,
name: weapon.name,
damage: weapon.system.damage,
isRanged,
range: weapon.system.range,
};
};
_prepareCraft(craft) {
return {
uuid: craft.uuid,
name: craft.name,
};
};
_prepareTrait(trait) {
return {
uuid: trait.uuid,

View file

@ -1,4 +1,5 @@
<div class="items">
{{#if attacks}}
<div>Attacks</div>
<div>
{{#each attacks as |attack|}}
@ -8,11 +9,30 @@
data-item-id="{{attack.uuid}}"
>
{{attack.name}}
{{attack.damage}}
{{#if attack.isRanged}}
<span class="range">
({{attack.range.short}} / {{attack.range.long}})
</span>
{{/if}}
</div>
{{else}}
Unarmed!
{{/each}}
</div>
{{/if}}
{{#if crafts}}
<div>Craft</div>
<div>
{{#each crafts as |craft|}}
<div
class="craft"
data-ctx-menu="item"
data-item-id="{{craft.uuid}}"
>
{{craft.name}}
</div>
{{/each}}
</div>
{{/if}}
<div>Defense</div>
<div>
Armour

View file

@ -19,6 +19,7 @@
display: flex;
justify-content: center;
align-items: center;
flex-shrink: 0;
img {
width: 150px;