Implement most of shield functionality using the armour implementation as a backbone

This commit is contained in:
Oliver-Akins 2025-01-19 16:13:28 -07:00
parent 27d924e336
commit 9d48794b83
9 changed files with 60 additions and 29 deletions

View file

@ -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;
};