Darn, I suspected it... well I found a solution to at least minimize the possibility of mistake. I compiled the html using PUG that allows me to write small chunck of code that are converted into html. I use a mixin (function) to generate the result from each number and write it in the correct place. Solution: Pug sourcecode: Mixin // - LETHALITY DAMAGE
mixin lethaldamage(results,mult)
// parse the results and mult to be sure they integer
- const val = parseInt(results)
- const multfactor= parseInt(mult)
// define tenth and units
- const tenths = Math.floor(val/10)
- const units = val%10
// if either unit or tenth is 0, assign 10, otherwise use the value
// the damage is given by the sum of units and tenths, and it is doubled on a critical
- const dmgs = (((tenths>0)?tenths:10)+((units>0)?units:10))*multfactor
// the sign '|' tells pug that the text coming after it has to be written wysiwyg, the command '#{}' allows to reference the variable val
|
| {{#rollTotal() lethality #{val} }}
// write the damage for each val
.sheet-template-row
span.inlinerollresult Damage: #{dmgs}
|
| {{/rollTotal() lethality #{val} }}
| Main template.pug file // critical multiplier
-const mult_crit = 2
// pug doesn't have 'for(i=1;i<=100;i++)' there are workarounds, but I decided to use the internal function each to make the loop
each _, i in Array(100)
// +<functionname>(arg1,arg2) call the function, I had to do i+1 cause it starts counting at 0
+lethaldamage(i+1,mult_crit) The output html after compiling the code is: {{#rollTotal() lethality 1}}
<div class="sheet-template-row"> <span class="inlinerollresult">Damage: 22</span></div>
{{/rollTotal() lethality 1}}
...
{{#rollTotal() lethality 67 }}
<div class="sheet-template-row"> <span class="inlinerollresult">Damage: 26</span></div>
{{/rollTotal() lethality 67 }}
...
{{#rollTotal() lethality 100}}
<div class="sheet-template-row"> <span class="inlinerollresult">Damage: 40</span></div>
{{/rollTotal() lethality 100}}
It is a pretty easy work around and you don't need to check all lines of code if you have written the function correctly, the final result of the lethality roll can be seen here . Hope this might help other people with a similar problem