diff --git a/HeroSystem6eHeroic/HeroSystem6eHeroic.html b/HeroSystem6eHeroic/HeroSystem6eHeroic.html index 552d17ba47..fa90754d2e 100644 --- a/HeroSystem6eHeroic/HeroSystem6eHeroic.html +++ b/HeroSystem6eHeroic/HeroSystem6eHeroic.html @@ -7063,15 +7063,35 @@ // Convert dice roll to equivalent BODY damage. let computed =0; - const theDice = results.results.STUN.dice; - for (let element of theDice) { - if (element === 1) { - computed = computed+0; - } else if (element === 6) { - computed = computed+2; - } else { - computed = computed+1; - } + const theDice = results.results.STUN.rolls; + + // For each type of dice (d3 or d6) calculate BODY + + for(let groupOfDice of theDice) { + console.log(groupOfDice); + if (groupOfDice.sides == 3) { + // calculate normal damage of d3 dice + for (let element of groupOfDice.results) { + if (element === 3) { + computed = computed+1; + } else if (element === 2) { + computed = computed + Math.floor(Math.random()*2); // Flip a coin. 0 or 1 BODY corresponding to a '3' or '4' on a d6. + } else { + computed = computed; // Do nothing. + } + } + } else { + // calculate normal damage of d6 dice + for (let element of groupOfDice.results) { + if (element === 1) { + computed = computed+0; + } else if (element === 6) { + computed = computed+2; + } else { + computed = computed+1; + } + } + } } // Get hit location message if system used. @@ -7114,15 +7134,35 @@ // Convert dice roll to equivalent BODY damage. let computed =0; - const theDice = results.results.STUN.dice; - for (let element of theDice) { - if (element === 1) { - computed = computed+0; - } else if (element === 6) { - computed = computed+2; - } else { - computed = computed+1; - } + const theDice = results.results.STUN.rolls; + + // For each type of dice (d3 or d6) calculate BODY + + for(let groupOfDice of theDice) { + console.log(groupOfDice); + if (groupOfDice.sides == 3) { + // calculate normal damage of d3 dice + for (let element of groupOfDice.results) { + if (element === 3) { + computed = computed+1; + } else if (element === 2) { + computed = computed + Math.floor(Math.random()*2); // Flip a coin. 0 or 1 BODY corresponding to a '3' or '4' on a d6. + } else { + computed = computed; // Do nothing. + } + } + } else { + // calculate normal damage of d6 dice + for (let element of groupOfDice.results) { + if (element === 1) { + computed = computed+0; + } else if (element === 6) { + computed = computed+2; + } else { + computed = computed+1; + } + } + } } // Get hit location message if system used. @@ -7168,7 +7208,7 @@ if (parseInt(values.strength)%5>2) { // Get the last die value, which was rolled with a d3. - let theDiceD3 = theDiceD6.pop(); + let theDiceD3 = theDiceD6.pop(); // Take the d3 off of the array. if (theDiceD3 == 3) { computed = computed +1; @@ -7179,6 +7219,7 @@ } } + // Calculate BODY damage of d6 dice. for (let element of theDiceD6) { if (element === 1) { computed = computed+0;