v1.5-fixes #538

Merged
uberwald merged 11 commits from VincentVk/foundryvtt-reve-de-dragon:v1.5-fixes into v1.5 2022-06-06 23:17:23 +02:00
Showing only changes of commit 218c88a924 - Show all commits

View File

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