Implement most of shield functionality using the armour implementation as a backbone
This commit is contained in:
parent
27d924e336
commit
9d48794b83
9 changed files with 60 additions and 29 deletions
|
|
@ -143,6 +143,7 @@ export class HeroSummaryCardV1 extends GenericAppMixin(HandlebarsApplicationMixi
|
|||
static async prepareArmor(ctx) {
|
||||
ctx.armours = {};
|
||||
const equipped = ctx.actor.system.equippedArmour;
|
||||
const shield = ctx.actor.system.equippedShield;
|
||||
const defenses = ctx.actor.system.defense;
|
||||
for (const slot of Object.values(gameTerms.Anatomy)) {
|
||||
const item = equipped[slot];
|
||||
|
|
@ -150,9 +151,16 @@ export class HeroSummaryCardV1 extends GenericAppMixin(HandlebarsApplicationMixi
|
|||
name: item?.name ?? ``,
|
||||
uuid: item?.uuid ?? ``,
|
||||
defense: defenses[slot],
|
||||
shielded: false,
|
||||
shielded: shield?.system.location.has(slot) ?? false,
|
||||
};
|
||||
};
|
||||
|
||||
ctx.shield = {
|
||||
name: shield?.name ?? ``,
|
||||
uuid: shield?.uuid ?? ``,
|
||||
bonus: shield?.system.protection ?? 0,
|
||||
};
|
||||
|
||||
return ctx;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -165,7 +165,8 @@ export class HeroData extends foundry.abstract.TypeDataModel {
|
|||
};
|
||||
|
||||
get equippedShield() {
|
||||
return null;
|
||||
const shields = this.parent.itemTypes.shield;
|
||||
return shields.find(item => item.system.equipped);
|
||||
};
|
||||
|
||||
get defense() {
|
||||
|
|
@ -175,7 +176,13 @@ export class HeroData extends foundry.abstract.TypeDataModel {
|
|||
defenses[slot] = armour[slot]?.system.protection ?? 0;
|
||||
};
|
||||
|
||||
// TODO: add shield defenses
|
||||
const shield = this.equippedShield;
|
||||
if (shield) {
|
||||
for (const location of [...shield.system.location.values()]) {
|
||||
const slot = location.toLowerCase();
|
||||
defenses[slot] += shield.system.protection;
|
||||
};
|
||||
};
|
||||
|
||||
return defenses;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -32,6 +32,7 @@ Hooks.once(`init`, () => {
|
|||
// #region Datamodels
|
||||
CONFIG.Actor.dataModels.hero = HeroData;
|
||||
CONFIG.Item.dataModels.armour = ProtectorData;
|
||||
CONFIG.Item.dataModels.shield = ProtectorData;
|
||||
CONFIG.Item.dataModels.weapon = WeaponData;
|
||||
// #endregion
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue