diff --git a/module/actor.js b/module/actor.js index ba777e43..71beea7e 100644 --- a/module/actor.js +++ b/module/actor.js @@ -1686,12 +1686,18 @@ export class RdDActor extends Actor { dmg = 0; // Reset it if ( update.data.deterioration >= 10) { update.data.deterioration = 0; - if ( update.data.protection.toString().length == 1 ) - update.data.protection = "1d"+update.data.protection+"-0"; - else { - let regex = /d\(d+)\-(\d+)/g; - let res = regex.exec( update.data.protection ); - update.data.protection = "1d"+res[1]+"-"+(parseInt(res[2])+1); + let res = /\d+^/.exec(update.data.protection); + if ( res ) + update.data.protection = "1d"+update.data.protection; + // if ( update.data.protection.toString().length == 1 ) + // update.data.protection = "1d"+update.data.protection; + else if (res = /(\d+d\d+)(\-\d+)?/.exec( update.data.protection )) + { + let malus = Misc.toInt(res[2]) - 1; + update.data.protection = res[1] + malus; + } + else{ + ui.notifications.warn(`La valeur d'armure de votre ${item.name} est incorrecte`) } ChatMessage.create( {content: "Détérioration d'armure: " + update.data.protection } ); } diff --git a/templates/item-armure-sheet.html b/templates/item-armure-sheet.html index 7ca1a573..e2bcb8af 100644 --- a/templates/item-armure-sheet.html +++ b/templates/item-armure-sheet.html @@ -10,7 +10,7 @@
- +