diff --git a/module/actor.js b/module/actor.js index a6e5f525..7bb90623 100644 --- a/module/actor.js +++ b/module/actor.js @@ -3277,11 +3277,11 @@ export class RdDActor extends Actor { protection = Math.max(protection - penetration, 0); protection += this.getProtectionNaturelle(); // Gestion des cas particuliers sur la fenĂȘtre d'encaissement - if (attackerRoll.dmg.encaisserSpecial && attackerRoll.dmg.encaisserSpecial == "noarmure") { + if (attackerRoll.dmg.encaisserSpecial == "noarmure") { protection = 0; } - if (attackerRoll.dmg.encaisserSpecial && attackerRoll.dmg.encaisserSpecial == "chute" && Number(protection) > 2) { - protection = 2; + if (attackerRoll.dmg.encaisserSpecial == "chute") { + protection = Math.min(protection, 2); } console.log("Final protect", protection, attackerRoll); return protection; @@ -3289,20 +3289,25 @@ export class RdDActor extends Actor { /* -------------------------------------------- */ _deteriorerArmure(item, dmg) { - if (!ReglesOptionelles.isUsing('deteriorationArmure')) { + let itemData = duplicate(Misc.data(item)); + if (!ReglesOptionelles.isUsing('deteriorationArmure') || itemData.data.protection == '0') { return; } - let itemData = duplicate(Misc.data(item)); itemData.data.deterioration = (itemData.data.deterioration ?? 0) + dmg; if (itemData.data.deterioration >= 10) { - itemData.data.deterioration = 0; - let res = /\d+/.exec(itemData.data.protection); - if (!res) { - itemData.data.protection = "1d" + itemData.data.protection; + itemData.data.deterioration -= 10; + let res = /(\d+)?d(\d+)(\-\d+)?/.exec(itemData.data.protection); + if (res) { + let malus = Misc.toInt(res[3]) - 1; + let armure = Misc.toInt(res[2]); + if (armure+malus <= 0){ + itemData.data.protection = 0; + } else { + itemData.data.protection = '' + (res[1]??'1') + 'd' + armure + malus; + } } - else if (res = /(\d+d\d+)(\-\d+)?/.exec(itemData.data.protection)) { - let malus = Misc.toInt(res[2]) - 1; - itemData.data.protection = res[1] + malus; + else if (/\d+/.exec(itemData.data.protection)) { + itemData.data.protection = "1d" + itemData.data.protection; } else { ui.notifications.warn(`La valeur d'armure de votre ${item.name} est incorrecte`);