
I'm trying to program a particular type of exploding dice. Roll a d10. If it's 10, roll and add another d10, etc. However, if the first (and only the first) roll is a 1, roll again and subtract from 0. This negative die also explodes on 10, making the number more negative. Here's the code. The problem I seem to be having is that when a 1 or 10 is rolled, the function is supposed to call itself recursively, but that's not happening. I've left my troubleshooting log() calls in. function runeRoll(iter) {
var d10 = randomInteger(10);
log(d10);
log(d10 > 1 && d10 < 10);
log("iter: " + iter);
if(d10 > 1 && d10 < 10) return d10;
if(d10 === 1 && iter > 0); return d10;
if(d10 === 1 && iter === 0); return -1 * runeRoll(++iter);
if(d10 === 10) return d10 += runeRoll(++iter);
}
I call the function with runeRoll(0).