Fixes from 29th of june

This commit is contained in:
2023-06-30 17:21:11 +02:00
parent 270c7c4a91
commit b535a86116
13 changed files with 51 additions and 81 deletions

View File

@@ -388,18 +388,22 @@ export class Hero6Utility {
// Ensure we have no space at all
//hero6Formula = hero6Formula.replace(/\s/g, '')
let hasHalfDice = ""
if (hero6Formula.match("1/2d6")) {
hero6Formula = hero6Formula.replace("1/2d6", "d6")
hasHalfDice = "+round(1d6/2)"
let newFormula = hero6Formula
let form1 = hero6Formula.match(/\s*(\d*)\s*1\/2d6/)
if ( form1 ) {
let nbDice = form1[1] || 0
newFormula = nbDice+"d6+round(1d6/2)"
}
if (hero6Formula.match(".5")) {
hero6Formula = hero6Formula.replace(".5", "")
hasHalfDice = "+round(1d6/2)"
let form3 = hero6Formula.match(/\s*(\d*)\.5d6/)
if ( form3 ) {
let nbDice = form3[1] || 0
newFormula = nbDice+"d6+round(1d6/2)"
}
let foundryFormula = hero6Formula + hasHalfDice
foundryFormula = foundryFormula.replace(' ', '')
console.log("Parsed formula : ", hero6Formula, foundryFormula)
return foundryFormula
console.log("Parsed formula : ", hero6Formula, newFormula)
return newFormula
}
/* -------------- ----------------------------- */