From 8e588b3c471a06a4637e10f59ae3b3d41ea61c9c Mon Sep 17 00:00:00 2001 From: Nikhil Nagarajan Date: Thu, 11 Dec 2025 15:12:45 -0500 Subject: [PATCH] Idea sorted. Tweaking Needed. --- module/data/actor/character.mjs | 31 ++++++++++++++++++------------- 1 file changed, 18 insertions(+), 13 deletions(-) diff --git a/module/data/actor/character.mjs b/module/data/actor/character.mjs index ba85ffa4..9c1c2d40 100644 --- a/module/data/actor/character.mjs +++ b/module/data/actor/character.mjs @@ -608,27 +608,21 @@ export default class DhCharacter extends BaseDataActor { } } - const armor = this.armor; - this.armorScore = armor ? armor.system.armor.max : 0; - this.damageThresholds = { - major: armor - ? armor.system.baseThresholds.major + this.levelData.level.current - : this.levelData.level.current, - severe: armor - ? armor.system.baseThresholds.severe + this.levelData.level.current - : this.levelData.level.current * 2 - }; + this.resources.hope.max -= Object.keys(this.scars).length; this.resources.hitPoints.max += this.class.value?.system?.hitPoints ?? 0; } //Armor Resource Getter - prepareArmorResources() { + _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; + if(!itemArmor){ + console.warn(`[FAIL] ${item.name} (${item.type}): No 'system.armor' data detected.`); + continue; + } let isValid=false; //Flag to see if valid if(item.type === 'armor'){ //Armor Type if(item.system.equipped) isValid = true; @@ -672,7 +666,18 @@ 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 = this.prepareArmorResources(); + this.resources.armor = this._prepareArmorResources(); + + const armor = this.armor; + this.armorScore = this.resources.armor.max; + this.damageThresholds = { + major: armor + ? armor.system.baseThresholds.major + this.levelData.level.current + : this.levelData.level.current, + severe: armor + ? armor.system.baseThresholds.severe + this.levelData.level.current + : this.levelData.level.current * 2 + }; this.attack.damage.parts[0].value.custom.formula = `@prof${this.basicAttackDamageDice}${this.rules.attack.damage.bonus ? ` + ${this.rules.attack.damage.bonus}` : ''}`; }