-
Notifications
You must be signed in to change notification settings - Fork 0
/
tempScript.js
43 lines (34 loc) · 920 Bytes
/
tempScript.js
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
33
34
35
36
37
38
39
40
41
42
43
var player = true;
var DiceImages = ["\"./ dice_1.png\"", "\"./ dice_2.png\"", "\"./ dice_3.png\"", "\"./ dice_4.png\"", "\"./ dice_5.png\"", "\"./ dice_6.png\"",];
var dice1 = 0;
var dice2 = 0;
score1 = 0;
score2 = 0;
var scoreHolder = 0;
console.log(DiceImages[0]);
function game() {
if (player) {
dice1 = Math.floor(Math.random() * 5) + 1;
dice2 = Math.floor(Math.random() * 5) + 1;
}
//test
console.log(dice1);
console.log(dice2);
if (dice1 == dice2) {
if (dice1 == 1 && dice2 == 1) {
scoreHolder = 0;
player = !player;
game();
}
else {
scoreHolder = scoreHolder + dice1 + dice2;
game();
}
}
else {
scoreHolder = scoreHolder + dice1 + dice2;
player = !player;
game();
}
document.getElementById(player1_score).innerHTML = scoreHolder;
}