-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathdice.js
More file actions
32 lines (31 loc) · 810 Bytes
/
dice.js
File metadata and controls
32 lines (31 loc) · 810 Bytes
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
function diceroller()
{
var times = [];
times[0] = document.getElementById('comp1').value;
if (ignore2.checked == 1){}
else{times[1] = document.getElementById('comp2').value;}
if (ignore3.checked == 1){}
else{times[2] = document.getElementById('comp3').value;}
var rolls = document.getElementById('rolls').value;
//for (var i=0;i<number.length;i++)
//{
// times[i] = comparison1
//}
while (times.length > 0) {
var n = 0;
var checkpoint = times[n];
var amount = 0;
while (rolls > 0) {
var dice = Math.floor(Math.random() * 6) + 1;
if (dice >= checkpoint) {
amount = amount + 1
}
rolls = rolls - 1;
}
times.shift();
rolls = amount;
amount = 0;
// console.log(rolls);
document.getElementById("output").value = rolls;
}
}