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 |}}
-
{{ slot.defense }}
+
+ + {{ slot.defense }} + + {{#if slot.shielded}} + + {{/if}} +
{{ rc-i18n (concat "RipCrypt.common.anatomy." @key) }}
{{/each}} - -
- {{ rc-i18n "RipCrypt.common.shield" }} -
diff --git a/templates/Apps/HeroSummaryCardV1/style.css b/templates/Apps/HeroSummaryCardV1/style.css index c947bdc..15344d6 100644 --- a/templates/Apps/HeroSummaryCardV1/style.css +++ b/templates/Apps/HeroSummaryCardV1/style.css @@ -237,11 +237,17 @@ /* Positioning */ .head, .body, .legs { grid-column: 1; } - .arms, .shield { grid-column: 2; } + .arms { grid-column: 2; } .head { grid-row: 1; } .body, .arms { grid-row: 2; } - .legs, .shield { grid-row: 3; } - .shield { align-self: end; } + .legs { grid-row: 3; } + + .shield { + --distance: -7px; + position: absolute; + top: var(--distance); + right: var(--distance); + } .armour-items { display: contents; diff --git a/templates/css/components/icon.css b/templates/css/components/icon.css index 07b155c..31ddda5 100644 --- a/templates/css/components/icon.css +++ b/templates/css/components/icon.css @@ -14,5 +14,10 @@ svg { width: var(--size, 1rem); height: var(--size, 1rem); fill: var(--fill); - stroke: var(--stroke); +} + +path { + stroke: var(--stroke); + stroke-width: var(--stroke-width); + stroke-linejoin: var(--stroke-linejoin); }