Damage multiplier

This commit is contained in:
2022-01-09 20:00:11 +01:00
parent 06cf860505
commit 0b77238dc2
6 changed files with 29 additions and 6 deletions

View File

@@ -381,8 +381,9 @@ export class BoLUtility {
}
/* -------------------------------------------- */
static getDamageFormula(damageString) {
static getDamageFormula(damageString, modifier=0, multiplier = 1) {
if (damageString[0] == 'd') { damageString = "1" + damageString } // Help parsing
if (modifier == null) modifier = 0;
var myReg = new RegExp('(\\d+)[dD]([\\d]+)([MB]*)?([\\+\\d]*)?', 'g');
let res = myReg.exec(damageString);
let nbDice = parseInt(res[1]);
@@ -400,7 +401,7 @@ export class BoLUtility {
modIndex = 4;
}
}
let formula = nbDice + "d" + res[2] + postForm + ((res[modIndex]) ? res[modIndex] : "");
let formula = "(" + nbDice + "d" + res[2] + postForm + "+" + modifier +") *" + multiplier;
return formula;
}
/* -------------------------------------------- */