forked from MillaJAB/Simon-TXRD-Edition
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathinteractions.js
263 lines (238 loc) · 6.27 KB
/
interactions.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
184
185
186
187
188
189
190
191
192
193
194
195
196
197
198
199
200
201
202
203
204
205
206
207
208
209
210
211
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
// Need to fix when spastic user behavior happens with a bunch of button presses while the computer is taking its turn.
var toggle = false;
var count = 0;
$("#counterText").hide();
var userTurn = false;
var strict = false;
var answerKey = [];
var playerAnswer = [];
var checkAnswer = 0;
$(document).ready(function() {
// Makes the team text rounded
$(".simpleArc").arctext({radius: 280});
$(".harsherArc").arctext({radius: 180});
});
// Flips the On/Off toggle visually and resets everything when turned off
$("#onOffToggle").click(function() {
if (toggle) {
offPosition();
} else {
toggle = true;
turnOn();
}
});
function offPosition() {
toggle = false;
strict = false;
$("#counterText").hide();
$("#onOffToggle").css("margin-left", "2px");
$("#light").css("opacity", "0.5");
resetVariables();
};
function turnOn() {
$("#onOffToggle").css("margin-left", "27px");
$("#counterText").html(" - -");
$("#counterText").show();
}
function resetVariables() {
count = 0;
userTurn = false;
answerKey = [];
playerAnswer = [];
checkAnswer = 0;
}
//Displays the round number
$("#startButton").click(function() {
if (toggle) {
if ($("#counterText").html() == "WIN") {
resetVariables();
$("#counterText").css("font-size", "67px").css("margin-left", "23px").css("position", "fixed").css("margin-top", "0px");
$("#counterText").html("WIN");
}
if (count == 0) {
displayCount();
setTimeout(function (){
count++;
displayCount();
}, 500);
gameRunning();
}
}
})
function beepShiz() {
userTurn = false;
for (i = 0; i < answerKey.length; i++) {
(function(i){
setTimeout(function(){
if (answerKey[i] == 1) {
greenActivated();
} else if (answerKey[i] == 2) {
pinkActivated();
} else if (answerKey[i] == 3) {
blackActivated();
} else if (answerKey[i] == 4) {
redActivated();
} else if (answerKey[i] == 5) {
blueActivated();
} else {
console.log("weirdness check");
}
}, i * 1000);
}(i));
}
userTurn = true;
}
function round() {
var team = (Math.floor(Math.random() * 5) + 1);
answerKey.push(team);
beepShiz();
}
function displayCount() {
if (count < 10) {
$("#counterText").html("0" + count);
} else {
$("#counterText").html(count);
}
}
function gameRunning() {
setTimeout(function (){
if (toggle) {
round();
}
}, 600);
}
$("#greenCircle").click(function() {
if (toggle && userTurn) {
greenActivated();
playerAnswer.push(1);
}
})
$("#pinkCircle").click(function() {
if (toggle && userTurn) {
pinkActivated();
playerAnswer.push(2);
}
})
$("#blackCircle").click(function() {
if (toggle && userTurn) {
blackActivated();
playerAnswer.push(3);
}
})
$("#redCircle").click(function() {
if (toggle && userTurn) {
redActivated();
playerAnswer.push(4);
}
})
$("#blueCircle").click(function() {
if (toggle && userTurn) {
blueActivated();
playerAnswer.push(5);
}
})
function greenActivated() {
$("#greenCircle").css("background-color", "#33ff33");
setTimeout(function (){
$("#greenCircle").css("background-color", "green");
}, 400);
document.getElementById("beep1").play();
}
function pinkActivated() {
$("#pinkCircle").css("background-color", "white");
$("#hellcatText").css("color", "hotpink");
setTimeout(function (){
$("#pinkCircle").css("background-color", "hotpink");
$("#hellcatText").css("color", "white");
}, 400);
document.getElementById("beep2").play();
}
function blackActivated() {
$("#blackCircle").css("background-color", "gold");
setTimeout(function (){
$("#blackCircle").css("background-color", "black");
}, 400);
document.getElementById("beep3").play();
}
function redActivated() {
$("#redCircle").css("background-color", "white");
$("#rhinestoneText").css("color", "red");
$("#cowgirlsText").css("color", "red");
setTimeout(function (){
$("#redCircle").css("background-color", "red");
$("#rhinestoneText").css("color", "white");
$("#cowgirlsText").css("color", "white");
}, 400);
document.getElementById("beep4").play();
}
function blueActivated() {
$("#blueCircle").css("background-color", "#66a3ff");
$("#rollerText").css("color", "blue");
$("#rollerText").css("-webkit-text-stroke-color", "blue");
setTimeout(function (){
$("#blueCircle").css("background-color", "blue");
$("#rollerText").css("color", "#66c2ff");
$("#rollerText").css("-webkit-text-stroke-color", "white");
}, 400);
document.getElementById("beep2").play();
}
//Checks if user is right or wrong on each color circle click.
$(".colorCircles").click(function() {
if (userTurn && toggle) {
if (playerAnswer[checkAnswer] == answerKey[checkAnswer]) {
checkAnswer++;
if (playerAnswer.length == answerKey.length) {
userTurn = false;
if (count < 20) {
resetAnswerTrackers();
count++;
setTimeout(function (){
displayCount();
}, 400);
setTimeout(function (){
round();
}, 1500);
} else {
$("#counterText").css("font-size", "52px").css("margin-left", "9px").css("position", "absolute").css("margin-top", "10px");
$("#counterText").html("WIN");
}
}
} else {
userTurn = false;
var replay = count;
count = "XX";
displayCount();
$("#counterText").fadeIn(200).fadeOut(200).fadeIn(200).fadeOut(200).fadeIn(200);
resetAnswerTrackers();
if (!strict) {
setTimeout(function () {
count = replay;
displayCount();
beepShiz();
}, 2000);
} else {
checkAnswer = 0;
answerKey = [];
setTimeout(function () {
count = 1;
displayCount();
gameRunning();
}, 2000);
}
}
}
})
function resetAnswerTrackers() {
checkAnswer = 0;
playerAnswer = [];
}
//Toggles Strict mode on and off
$("#buttonTopAdj").click(function() {
if (strict) {
$("#light").css("opacity", "0.5");
strict = false;
} else {
$("#light").css("opacity", "1");
strict = true;
}
})