Code: Select all
while([function with an input of a 1d8, no advantage] != 8) {}
< /code>
Die Idee ist, dass, da es einfach unmöglich ist, eine 8 zu bekommen, die während der Schleife für immer fortgesetzt wird. Ich habe jedes Mal höchstens ein paar Sekunden gewartet. < /P>
explosiveDiceRoll()
Code: Select all
multiDiceRoll()
Code: Select all
1d8
8,8 - SHOULD NOT EQUAL
[ 8 ]
< /code>
function explosiveDiceRoll(maxRoll) {
let roll = diceRoll(maxRoll);
let sum = roll;
while(roll === maxRoll) { //Reroll and add everytime it hits the max roll
roll = diceRoll(maxRoll);
if(roll === 0) console.log("zero error");
sum += roll
}
return sum;
}
< /code>
function multiDiceRoll(diceString,advantage) {
diceString = diceString.split("d");
// console.log(diceString);
let diceAmount= diceString[0];
let diceType = diceString[1];
console.log(`${diceAmount}d${diceType}`);
let results = [];
for(let i = 0; i
export function diceRoll(maxRoll) {
return Math.ceil(Math.random()*maxRoll);
}