fix: protection stacking + remove misleading def from combat card

getProtection(): replace threshold sum<4 with hasRealArmor check.
Old logic broke when two sub-4 items (e.g. shield 2 + light armor 3)
summed >=4 and lost the base+4 bonus — causing protection to decrease
when equipping them together.

actor-sheet.hbs: remove defenseTotal from top-right combat card.
This value excluded Mêlée skill, making it always wrong vs
the per-weapon defense shown in the combat tab.
This commit is contained in:
2026-06-27 22:04:04 +02:00
parent e270d5704b
commit 24aac79101
2 changed files with 8 additions and 10 deletions
+8 -6
View File
@@ -221,16 +221,18 @@ export class MournbladeCYD2Actor extends Actor {
}
/* -------------------------------------------- */
getProtection() {
let equipProtection = 0
let sum = 0
let hasRealArmor = false
for (let armor of this.items) {
if (armor.type == "protection" && armor.system.equipped) {
equipProtection += Number(armor.system.protection)
const val = Number(armor.system.protection)
sum += val
if (val >= 4) hasRealArmor = true
}
}
if (equipProtection < 4) {
return 4 + equipProtection // Cas des boucliers + sans armure
}
return equipProtection // Uniquement la protection des armures + boucliers
if (sum === 0) return 4 // Aucune protection → base 4
if (hasRealArmor) return sum // Au moins une vraie armure → somme directe
return 4 + sum // Que des boucliers/protections légères → base + bonus
}
getProtectionTotal() {
return this.getProtection()
-4
View File
@@ -111,10 +111,6 @@
<label>{{localize "MNBL.initShort"}}</label>
<span>{{combat.initTotal}}</span>
</div>
<div class="stat-field">
<label>{{localize "MNBL.defShort"}}</label>
<span>{{combat.defenseTotal}}</span>
</div>
<div class="stat-field">
<label>{{localize "MNBL.protShort"}}</label>
<span>{{protectionTotal}}</span>