forked from public/foundryvtt-reve-de-dragon
Gestion de l'armure
Correction de la détérioration d'une armure variable Séparation du code d'armure dans l'Item RdDArmureItem
This commit is contained in:
@ -3149,8 +3149,8 @@ export class RdDActor extends RdDBaseActor {
|
||||
const armures = this.items.filter(it => it.type == "armure" && it.system.equipe);
|
||||
for (const armure of armures) {
|
||||
protection += await RdDDice.rollTotal(armure.system.protection.toString());
|
||||
if (dmg > 0) {
|
||||
this._deteriorerArmure(armure, dmg);
|
||||
if (dmg > 0 && attackerRoll.dmg.encaisserSpecial != "noarmure") {
|
||||
armure.deteriorerArmure(dmg);
|
||||
dmg = 0;
|
||||
}
|
||||
}
|
||||
@ -3168,35 +3168,6 @@ export class RdDActor extends RdDBaseActor {
|
||||
return protection;
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
_deteriorerArmure(armure, dmg) {
|
||||
armure = duplicate(armure);
|
||||
if (!ReglesOptionelles.isUsing('deteriorationArmure') || armure.system.protection == '0') {
|
||||
return;
|
||||
}
|
||||
armure.system.deterioration = (armure.system.deterioration ?? 0) + dmg;
|
||||
if (armure.system.deterioration >= 10) {
|
||||
armure.system.deterioration -= 10;
|
||||
let res = /(\d+)?d(\d+)(\-\d+)?/.exec(armure.system.protection);
|
||||
if (res) {
|
||||
let malus = Misc.toInt(res[3]) - 1;
|
||||
let armure = Misc.toInt(res[2]);
|
||||
if (armure + malus <= 0) {
|
||||
armure.system.protection = 0;
|
||||
} else {
|
||||
armure.system.protection = '' + (res[1] ?? '1') + 'd' + armure + malus;
|
||||
}
|
||||
}
|
||||
else if (/\d+/.exec(armure.system.protection)) {
|
||||
armure.system.protection = "1d" + armure.system.protection;
|
||||
}
|
||||
else {
|
||||
ui.notifications.warn(`La valeur d'armure de votre ${armure.name} est incorrecte`);
|
||||
}
|
||||
ChatMessage.create({ content: "Votre armure s'est détériorée, elle protège maintenant de " + armure.system.protection });
|
||||
}
|
||||
this.updateEmbeddedDocuments('Item', [armure]);
|
||||
}
|
||||
|
||||
/* -------------------------------------------- */
|
||||
async encaisser() {
|
||||
|
Reference in New Issue
Block a user