Weapon attacke management, step1

This commit is contained in:
2021-12-25 23:26:27 +01:00
parent 498b5bc4a6
commit a8d4d40106
8 changed files with 277 additions and 6 deletions

View File

@ -179,6 +179,30 @@ export class BoLUtility {
});
}
/* -------------------------------------------- */
static getDamageFormula( damageString) {
if (damageString[0] == 'd') {damageString = "1" + damageString} // Help parsing
var myReg = new RegExp('(\\d+)[dD]([\\d]+)([MB]*)?([\\+\\d]*)?', 'g');
let res = myReg.exec(damageString);
let nbDice = parseInt(res[1]);
let postForm = 'kh'+nbDice;
let modIndex = 3;
if ( res[3]) {
if ( res[3] == 'M') {
postForm = 'kl'+nbDice;
nbDice++;
modIndex = 4;
}
if ( res[3] == 'B') {
postForm = 'kh'+nbDice;
nbDice++;
modIndex = 4;
}
}
let formula = nbDice+"d"+res[2] + postForm + ((res[modIndex]) ? res[modIndex] : "");
return formula;
}
/* -------------------------------------------- */
static async confirmDelete(actorSheet, li) {
let itemId = li.data("item-id");