Fix Armure et détérioration

regex incorrecte
This commit is contained in:
Vincent Vandemeulebrouck 2020-12-18 22:14:48 +01:00
parent ef2cb49542
commit 3975d7f529
2 changed files with 13 additions and 7 deletions

View File

@ -1686,12 +1686,18 @@ export class RdDActor extends Actor {
dmg = 0; // Reset it dmg = 0; // Reset it
if ( update.data.deterioration >= 10) { if ( update.data.deterioration >= 10) {
update.data.deterioration = 0; update.data.deterioration = 0;
if ( update.data.protection.toString().length == 1 ) let res = /\d+^/.exec(update.data.protection);
update.data.protection = "1d"+update.data.protection+"-0"; 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{ else{
let regex = /d\(d+)\-(\d+)/g; ui.notifications.warn(`La valeur d'armure de votre ${item.name} est incorrecte`)
let res = regex.exec( update.data.protection );
update.data.protection = "1d"+res[1]+"-"+(parseInt(res[2])+1);
} }
ChatMessage.create( {content: "Détérioration d'armure: " + update.data.protection } ); ChatMessage.create( {content: "Détérioration d'armure: " + update.data.protection } );
} }

View File

@ -10,7 +10,7 @@
<section class="sheet-body"> <section class="sheet-body">
<div class="form-group"> <div class="form-group">
<label for="xp">Protection</label> <label for="xp">Protection</label>
<input class="attribute-value" type="text" name="data.protection" value="{{data.protection}}" data-dtype="Number"/> <input class="attribute-value" type="text" name="data.protection" value="{{data.protection}}" data-dtype="String"/>
</div> </div>
<div class="form-group"> <div class="form-group">
<label for="xp">Encombrement </label> <label for="xp">Encombrement </label>