Brian said: Aaron said: You definitely can. The real question is how you want to interact with it. // Mark G's pseudo code in javascript:
var rerollThreats = function (critThreat) {
var theRoll = randomInteger(20);
theRoll = (theRoll >= critThreat) ? randomInteger(20) : theRoll;
return theRoll;
}; You would also need to display the original roll (or otherwise indicate that the reroll ocurred), since this is about confirming a critical. If you roll 20, 10 and only display the 10, it would be pretty useless for crits. Good point. I was just translating the pseudo code, but you're absolutely right. Maybe something like: // Mark G's pseudo code in javascript:
var rerollThreats = function (critThreat) {
var roll = randomInteger(20),
res = {
first: roll,
second: (roll >= critThreat) ? randomInteger(20) : NaN,
value: 0,
rerolled: false
};
res.value = (res.rerolled = !_.isNaN(res.second) ) ? res.second : res.first;
return res;
};