-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathBeerClicks.js
183 lines (143 loc) · 5.77 KB
/
BeerClicks.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
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
164
165
166
167
168
169
170
171
172
173
174
175
176
177
178
179
180
181
182
183
$("#Red-div img").click(function(){
$("#Red-div-input").toggle(300);
});
$("#Black-div img").click(function(){
$("#Black-div-input").toggle(300);
});
$("#start-img").click(function() {
$("#start-info").fadeOut(300);
$(".jumbotron").slideUp(500);
$("#play-info").slideDown(500);
ShuffleArray(newGame.allCards);
});
$("#end-img").click(function() {
$("#play-info").fadeOut(500);
$("#play").slideDown(700);
$("input").blur();
newGame.cards.forEach(element => {
var input = document.getElementById(element.name + "-div-input");
var arr = input.getElementsByTagName("option");
for (let index = 0; index < newGame.games.length + 1; index++) {
if (arr[index].selected == true) {
newGame.updateCard(element.name, newGame.games[index-1])
break;
}
}
});
BlackEnd();
RedEnd();
});
function BlackEnd() {
var input = document.getElementById("Black-div-input");
var arr = input.getElementsByTagName("option");
for (let index = 0; index < newGame.games.length + 1; index++) {
if (arr[index].selected == true) {
newGame.updateCard("Two", newGame.games[index-1], "Black")
newGame.updateCard("Three", newGame.games[index-1], "Black")
newGame.updateCard("Four", newGame.games[index-1], "Black")
newGame.updateCard("Five", newGame.games[index-1], "Black")
break;
}
}
}
function RedEnd() {
var input = document.getElementById("Red-div-input");
var arr = input.getElementsByTagName("option");
for (let index = 0; index < newGame.games.length + 1; index++) {
if (arr[index].selected == true) {
newGame.updateCard("Two", newGame.games[index-1], "Red")
newGame.updateCard("Three", newGame.games[index-1], "Red")
newGame.updateCard("Four", newGame.games[index-1], "Red")
newGame.updateCard("Five", newGame.games[index-1], "Red")
break;
}
}
}
$("#play-img").click(function(){
newGame.GetRandomCard();
var img = document.getElementById("play-img");
img.src = newGame.currentCard.image;
$("#play-name").fadeOut(100);
document.getElementById("play-name").innerHTML = newGame.currentCard.action.name;
$("#play-name").fadeIn(100);
var play = document.getElementById("play-div");
play.children[3].innerHTML = newGame.currentCard.action.info;
play.children[4].innerHTML = newGame.allCards.length + " kort kvar.";
if (newGame.allCards.length == 1) {
$("#play-img-side").fadeOut(300);
} else if (newGame.allCards.length == 0) {
$("#play-img").fadeOut(3000);
}
});
$("#standard-btn").click(function(){
newGame.allCards.forEach(element => {
if (element.name == "Ace") {
element.action = tum;
} else if (element.name == "King") {
element.action = question;
} else if (element.name == "Queen") {
element.action = woopWoop;
} else if (element.name == "Knight") {
element.action = category;
} else if (element.name == "Ten") {
element.action = rule;
} else if (element.name == "Nine") {
element.action = taliTali;
} else if (element.name == "Eight") {
element.action = eightGame;
} else if (element.name == "Seven") {
element.action = sevenGame;
} else if (element.name == "Six") {
element.action = woopWoop;
} else if ((element.name == "Five" || element.name == "Four" ||
element.name == "Three" ||element.name == "Two") && element.color == "Red") {
element.action = giveAway;
} else if ((element.name == "Five" || element.name == "Four" ||
element.name == "Three" ||element.name == "Two") && element.color == "Black") {
element.action = drink;
}
});
Cards();
Black();
Red();
});
newGame.cards.forEach(element => {
$("#" + element.name + "-div img").click(function(){
$("#" + element.name + "-div-input").toggle(300);
});
});
function Cards() {
newGame.cards.forEach(element => {
$("#" + element.name + "-div-input").slideDown(300);
var input = document.getElementById(element.name + "-div-input");
var arr = input.getElementsByTagName("option");
for (let index = 0; index < newGame.games.length + 1; index++) {
if (arr[index].innerHTML == element.action.name) {
arr[index].selected = true;
break;
}
}
});
}
function Black() {
$("#Black-div-input").slideDown(300);
var input = document.getElementById("Black-div-input");
var arr = input.getElementsByTagName("option");
for (let index = 0; index < newGame.games.length + 1; index++) {
if (arr[index].innerHTML == drink.name) {
arr[index].selected = true;
break;
}
}
}
function Red() {
$("#Red-div-input").slideDown(300);
var input = document.getElementById("Red-div-input");
var arr = input.getElementsByTagName("option");
for (let index = 0; index < newGame.games.length + 1; index++) {
if (arr[index].innerHTML == giveAway.name) {
arr[index].selected = true;
break;
}
}
}