Fix détérioration armure
Support des armures sous forme: * entier * 0 * d4, d4-1 * 1d4, 1d4-1 Détérioration diminuée de 10 (au lieu de remise à 0) Décrémentation correcte de l'armure
This commit is contained in:
parent
e22b6c52f1
commit
218c88a924
@ -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`);
|
||||
|
Loading…
Reference in New Issue
Block a user