From 557033a2c302001caf0fefda12307f3cd70e664f Mon Sep 17 00:00:00 2001 From: Nikhil Nagarajan Date: Thu, 11 Dec 2025 14:14:44 -0500 Subject: [PATCH] Armor breached. Order 66 --- module/data/actor/character.mjs | 40 ++++++++++++++++++++++++++++----- 1 file changed, 34 insertions(+), 6 deletions(-) diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs index c5ab914c..ba85ffa4 100644 --- a/module/data/actor/character.mjs +++ b/module/data/actor/character.mjs @@ -609,7 +609,7 @@ export default class DhCharacter extends BaseDataActor { } const armor = this.armor; - this.armorScore = armor ? armor.system.baseScore : 0; + this.armorScore = armor ? armor.system.armor.max : 0; this.damageThresholds = { major: armor ? armor.system.baseThresholds.major + this.levelData.level.current @@ -621,6 +621,38 @@ export default class DhCharacter extends BaseDataActor { this.resources.hope.max -= Object.keys(this.scars).length; this.resources.hitPoints.max += this.class.value?.system?.hitPoints ?? 0; } +//Armor Resource Getter + prepareArmorResources() { + let totalValue=0; + let totalMax=0; + + for(const item of this.parent.items){ + const itemArmor = item.system.armor; //To check if follows schema + if(!itemArmor) continue; + let isValid=false; //Flag to see if valid + if(item.type === 'armor'){ //Armor Type + if(item.system.equipped) isValid = true; + } + else if (itemArmor.armorResourceToggle){ + if(item.type === 'weapon'){ //Weapon Type + if(item.system.equipped) isValid = true; + } + else{ + isValid=true; //Other items like Loot,Consumables(will need to tweak consumable to activate after consume) + } + } + + if(isValid){ + totalMax += (itemArmor.max); + totalValue += (itemArmor.value); + } + } + return { + value: totalValue, + max: totalMax, + isReversed: true + } + } prepareDerivedData() { let baseHope = this.resources.hope.value; @@ -640,11 +672,7 @@ export default class DhCharacter extends BaseDataActor { this.resources.hope.value = Math.min(baseHope, this.resources.hope.max); this.attack.roll.trait = this.rules.attack.roll.trait ?? this.attack.roll.trait; - this.resources.armor = { - value: this.armor?.system?.marks?.value ?? 0, - max: this.armorScore, - isReversed: true - }; + this.resources.armor = this.prepareArmorResources(); this.attack.damage.parts[0].value.custom.formula = `@prof${this.basicAttackDamageDice}${this.rules.attack.damage.bonus ? ` + ${this.rules.attack.damage.bonus}` : ''}`; }