RC-106 | Add equipped armour display
This commit is contained in:
parent
07f3b24897
commit
d1ce144114
5 changed files with 67 additions and 0 deletions
|
|
@ -72,6 +72,7 @@ export class HeroSummaryCardV1 extends GenericAppMixin(HandlebarsApplicationMixi
|
|||
|
||||
ctx = await HeroSummaryCardV1.prepareGuts(ctx);
|
||||
ctx = await HeroSummaryCardV1.prepareWeapons(ctx);
|
||||
ctx = await HeroSummaryCardV1.prepareArmor(ctx);
|
||||
ctx = await HeroSummaryCardV1.prepareFatePath(ctx);
|
||||
ctx = await HeroSummaryCardV1.prepareAbilityRow(ctx);
|
||||
ctx = await HeroSummaryCardV1.prepareSpeed(ctx);
|
||||
|
|
@ -136,6 +137,20 @@ export class HeroSummaryCardV1 extends GenericAppMixin(HandlebarsApplicationMixi
|
|||
return ctx;
|
||||
};
|
||||
|
||||
static async prepareArmor(ctx) {
|
||||
ctx.armours = {};
|
||||
const equipped = ctx.actor.system.equippedArmour;
|
||||
for (const slot of gameTerms.Anatomy) {
|
||||
const item = equipped[slot];
|
||||
ctx.armours[slot] = {
|
||||
name: item?.name ?? ``,
|
||||
uuid: item?.uuid ?? ``,
|
||||
defense: 0,
|
||||
};
|
||||
};
|
||||
return ctx;
|
||||
};
|
||||
|
||||
static async prepareWeapons(ctx) {
|
||||
const limit = ctx.actor.system.limit.weapons;
|
||||
const embedded = ctx.actor.itemTypes.weapon;
|
||||
|
|
|
|||
|
|
@ -147,4 +147,37 @@ export class HeroData extends foundry.abstract.TypeDataModel {
|
|||
run: (this.ability.gait + 3) * 2,
|
||||
};
|
||||
};
|
||||
|
||||
// #region Getters
|
||||
get equippedArmour() {
|
||||
const armours = this.parent.itemTypes.armour;
|
||||
const slots = Object.fromEntries(
|
||||
gameTerms.Anatomy.map(v => [v, null]),
|
||||
);
|
||||
for (const armour of armours) {
|
||||
if (!armour.system.equipped) { continue };
|
||||
for (const locationTag of [...armour.system.location.values()]) {
|
||||
const location = locationTag.toLowerCase();
|
||||
slots[location] = armour;
|
||||
};
|
||||
};
|
||||
return slots;
|
||||
};
|
||||
|
||||
get equippedShield() {
|
||||
return null;
|
||||
};
|
||||
|
||||
get defense() {
|
||||
const defenses = {};
|
||||
const armour = this.equippedArmour;
|
||||
for (const slot in armour) {
|
||||
defenses[slot] = armour[slot]?.system.protection ?? 0;
|
||||
};
|
||||
|
||||
// TODO: add shield defenses
|
||||
|
||||
return defenses;
|
||||
};
|
||||
// #endregion
|
||||
};
|
||||
|
|
|
|||
|
|
@ -20,6 +20,11 @@ export class ArmourData extends foundry.abstract.TypeDataModel {
|
|||
required: true,
|
||||
},
|
||||
),
|
||||
equipped: new fields.BooleanField({
|
||||
initial: false,
|
||||
required: true,
|
||||
nullable: false,
|
||||
}),
|
||||
};
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -54,15 +54,19 @@
|
|||
<ul class="armour-items">
|
||||
<li class="row-alt">
|
||||
<span class="label">{{ rc-i18n "RipCrypt.common.anatomy.head" }}</span>
|
||||
<span class="value ellipses">{{ armours.head.name }}</span>
|
||||
</li>
|
||||
<li>
|
||||
<span class="label">{{ rc-i18n "RipCrypt.common.anatomy.body" }}</span>
|
||||
<span class="value ellipses">{{ armours.body.name }}</span>
|
||||
</li>
|
||||
<li class="row-alt">
|
||||
<span class="label">{{ rc-i18n "RipCrypt.common.anatomy.arms" }}</span>
|
||||
<span class="value ellipses">{{ armours.arms.name }}</span>
|
||||
</li>
|
||||
<li>
|
||||
<span class="label">{{ rc-i18n "RipCrypt.common.anatomy.legs" }}</span>
|
||||
<span class="value ellipses">{{ armours.legs.name }}</span>
|
||||
</li>
|
||||
<li class="row-alt">
|
||||
<span class="label">{{ rc-i18n "RipCrypt.common.shield" }}</span>
|
||||
|
|
|
|||
|
|
@ -250,6 +250,16 @@
|
|||
display: flex;
|
||||
flex-direction: row-reverse;
|
||||
justify-content: space-between;
|
||||
align-items: center;
|
||||
flex-wrap: nowrap;
|
||||
padding: 0 2px;
|
||||
gap: 4px;
|
||||
min-width: 0;
|
||||
}
|
||||
|
||||
.label {
|
||||
text-overflow: initial;
|
||||
flex-shrink: 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue