diff --git a/assets/icons/shield-solid.svg b/assets/icons/shield-solid.svg new file mode 100644 index 0000000..e9194e7 --- /dev/null +++ b/assets/icons/shield-solid.svg @@ -0,0 +1,3 @@ + diff --git a/langs/en-ca.json b/langs/en-ca.json index 7a985f3..dd85173 100644 --- a/langs/en-ca.json +++ b/langs/en-ca.json @@ -5,6 +5,7 @@ }, "Item": { "armour": "Armour", + "shield": "Shield", "weapon": "Weapon" } }, @@ -102,6 +103,9 @@ "warn": { "cannot-go-negative": "\"{name}\" is unable to be a negative number." } + }, + "tooltips": { + "shield-bonus": "Shield Bonus: {value}" } } } diff --git a/module/Apps/ActorSheets/HeroSummaryCardV1.mjs b/module/Apps/ActorSheets/HeroSummaryCardV1.mjs index 0b46279..7317cf6 100644 --- a/module/Apps/ActorSheets/HeroSummaryCardV1.mjs +++ b/module/Apps/ActorSheets/HeroSummaryCardV1.mjs @@ -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; }; diff --git a/module/data/Actor/Hero.mjs b/module/data/Actor/Hero.mjs index c94fc40..da9a775 100644 --- a/module/data/Actor/Hero.mjs +++ b/module/data/Actor/Hero.mjs @@ -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; }; diff --git a/module/hooks/init.mjs b/module/hooks/init.mjs index 6fc94ea..7bfafe9 100644 --- a/module/hooks/init.mjs +++ b/module/hooks/init.mjs @@ -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 diff --git a/system.json b/system.json index 526138b..57cd8d1 100644 --- a/system.json +++ b/system.json @@ -45,6 +45,7 @@ }, "Item": { "armour": {}, + "shield": {}, "weapon": {} } } diff --git a/templates/Apps/HeroSummaryCardV1/content.hbs b/templates/Apps/HeroSummaryCardV1/content.hbs index 25f9bb6..23a524c 100644 --- a/templates/Apps/HeroSummaryCardV1/content.hbs +++ b/templates/Apps/HeroSummaryCardV1/content.hbs @@ -33,31 +33,26 @@ > {{#each armours as | slot |}}