From 3975d7f52948d5b5b233a44a1b29b4bf72faeb4c Mon Sep 17 00:00:00 2001 From: Vincent Vandemeulebrouck Date: Fri, 18 Dec 2020 22:14:48 +0100 Subject: [PATCH] =?UTF-8?q?Fix=20Armure=20et=20d=C3=A9t=C3=A9rioration?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit regex incorrecte --- module/actor.js | 18 ++++++++++++------ templates/item-armure-sheet.html | 2 +- 2 files changed, 13 insertions(+), 7 deletions(-) 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 @@
- +