-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathpublicVers.js
290 lines (264 loc) · 11.4 KB
/
publicVers.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
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
"use strict";
var numbers="123456789"
var points = "Points: "
var min = 3
var getUsersAnswer = document.getElementById("usersAnswer")
var getProblem = document.getElementById("problemNumScentence").value
var getPointsText = document.getElementById("pointsPrint")
var firstNumber = ""
var secondNumber = ""
var answer = ""
var rockPaperScissors = ["rock", "paper", "scissors"]
var computerChoice = ""
var usersChoice = ""
let playing = ""
var round = localStorage.getItem("round")
var firstTime = true
var problemsBeforeRound = 20
var operation = "plus"
function showDonateSign(){
document.getElementById("donateDiv").style = "visibility:visible"
}
let setTimeoutShowDonate = setTimeout(showDonateSign, 9000);
function mouseOverEventStart(whichOne){
console.log("in submit button style")
if (whichOne == 'mouseover'){
document.getElementById("usersAnswerButton").style.backgroundColor = "#aceaff"
}
else{
//console.log("Else of MouseOver")
document.getElementById("usersAnswerButton").style.backgroundColor = "#e7f9ff"
}
}
function back_math(){
alert("Good game.\nNow let's get back to math!")
}
function playRock(){
computerChoice = Math.floor(Math.random() * rockPaperScissors.length);
// computerChoice = "rock"
usersChoice = prompt("Rock, paper, or scissors? ")
if (computerChoice == usersChoice){
alert("Tie game. Computer chose "+ computerChoice)
//console.log(usersChoice)
//console.log(usersChoice)
back_math()
}
else if (computerChoice == "rock" && usersChoice == "scissors"){
alert("Computer chose "+computerChoice+" , but you chose "+usersChoice)
alert("0-1. Computer won.")
back_math()
}
else if (computerChoice == "scissors" && usersChoice == "rock"){
alert("Computer chose "+computerChoice+" , but you chose "+usersChoice)
alert("1-0. You won!")
back_math()
}
else if (computerChoice == "paper" && usersChoice == "rock"){
alert("Computer chose "+computerChoice+" , but you chose "+usersChoice)
alert("0-1. Computer won.")
back_math()
}
else if (computerChoice == "rock" && usersChoice == "paper"){
alert("Computer chose "+computerChoice+" , but you chose "+usersChoice)
alert("1-0. You won!")
back_math()
}
else if (computerChoice == "scissors" && usersChoice == "paper"){
alert("Computer chose "+computerChoice+" , but you chose "+usersChoice)
alert("0-1. Computer won.")
back_math()
}
else if (computerChoice == "paper" && usersChoice == "scissors"){
alert("Computer chose " + computerChoice + " , but you chose " + usersChoice)
alert("0-1. Computer won.")
back_math()
}
else{
back_math()
}
}
function twoDigit(){
if(points == "Points: XXXXXX"){
points="Points: "
alert("Increasing your next break by two minutes!")
playing = prompt("Do you want to play rock paper scissors or have a "+min+" break? (rps, break) ")
min = min+2
if(playing == "rps"){
playRock()
}
else{
var letters = ["A", "B", "OP"]
const randNum = Math.floor(Math.random() * letters.length);
const d = new Date();
let year = d.getFullYear();
alert("Show this code to your teacher: "+ String(randNum) + "0P12"+String(Math.floor(Math.random() * 6) + 1) + String(round)+String(Math.floor(Math.random() * 30) + 21) + String(year)+String(min)+"035")
}
}
if(parseInt(problemsBeforeRound) == 0 || firstTime == true){
if (round == 1){
operation = "minus";
problemsBeforeRound = 20;
//console.log(round)
round = parseInt(round)+1;
localStorage.setItem("round", round)
//console.log(round)
document.getElementById("roundPrint").innerHTML = "Round: "+String(round);
document.getElementById("problemRoundPrint").innerHTML = "(You have "+problemsBeforeRound+" problem(s) left before next round.)";
alert("Congradulations! You have advanced to the new round.\n\nShow this code to your teacher: NR0"+min+"P3+"+round+"5"+firstTime+"1441,01");
}
else if (round == 2){
operation = "times";
problemsBeforeRound = 20;
//console.log(round)
round = parseInt(round)+1;
localStorage.setItem("round", round)
//console.log(round)
document.getElementById("roundPrint").innerHTML = "Round: "+String(round);
document.getElementById("problemRoundPrint").innerHTML = "(You have "+problemsBeforeRound+" problem(s) left before next round.)";
alert("Congradulations! You have advanced to the new round.\n\nShow this code to your teacher: NR0"+min+"P3+"+round+"5"+firstTime+"1441,01");
}
else if (round == 3){
operation = "divide";
problemsBeforeRound = 20;
//console.log(round)
round = parseInt(round)+1;
localStorage.setItem("round", round)
//console.log(round)
document.getElementById("roundPrint").innerHTML = "Round: "+String(round);
document.getElementById("problemRoundPrint").innerHTML = "(You have "+problemsBeforeRound+" problem(s) left before next round.)";
document.getElementById("forDivisionOnly").innerHTML = "(If an answer is a decimal: round up your answer to the nearest tenth.)"
alert("Congradulations! You have advanced to the new round.\n\nShow this code to your teacher: NR0"+min+"P3+"+round+"5"+firstTime+"1441,01");
}
else if(round == 4){
location.href = "finished.html";
}
// else if(firstTime == true){
// firstTime = false;
// round = 1
// localStorage.setItem("round", round)
// twoDigit()
// }
// else{
// console.log("Did not go in "+round)
// round = round+1
// localStorage.setItem("round", round)
// console.log("Did not go in "+round)
// problemsBeforeRound = 20;
// document.getElementById("roundPrint").innerHTML = "Round: "+String(round)
// document.getElementById("problemRoundPrint").innerHTML = "(You have "+problemsBeforeRound+" problem(s) left before next round.)"
// alert("Congradulations! You have advanced to the new round.\n\nShow this code to your teacher: NR0"+min+"P3+"+round+"5"+firstTime+"1441,01");
// }
}
else{
if(operation == "plus"){
getPointsText.innerHTML = points
firstNumber = String(Math.floor(Math.random() * 9) + 1) + String(Math.floor(Math.random() * 9) + 1);
secondNumber = String(Math.floor(Math.random() * 9) + 1) + String(Math.floor(Math.random() * 9) + 1);
document.getElementById("problemNumScentence").value = firstNumber+"+"+secondNumber+"="
// console.log(firstNumber)
// console.log(secondNumber)
// console.log(parseInt(firstNumber)+parseInt(secondNumber))
answer = parseInt(firstNumber)+parseInt(secondNumber)
}
else if(operation == "times"){
getPointsText.innerHTML = points
firstNumber = String(Math.floor(Math.random() * 9) + 1) + String(Math.floor(Math.random() * 9) + 1);
secondNumber = String(Math.floor(Math.random() * 9) + 1) + String(Math.floor(Math.random() * 9) + 1);
document.getElementById("problemNumScentence").value = firstNumber+"x"+secondNumber+"="
// console.log(firstNumber)
// console.log(secondNumber)
// console.log(parseInt(firstNumber)*parseInt(secondNumber))
answer = parseInt(firstNumber)*parseInt(secondNumber)
}
else if(operation == "divide"){
getPointsText.innerHTML = points
firstNumber = String(Math.floor(Math.random() * 9) + 1) + String(Math.floor(Math.random() * 9) + 1);
secondNumber = String(Math.floor(Math.random() * 9) + 1) + String(Math.floor(Math.random() * 9) + 1);
document.getElementById("forDivisionOnly").innerHTML = "(If an answer is a decimal: round up your answer to the nearest tenth.)"
document.getElementById("problemNumScentence").value = firstNumber+"÷"+secondNumber+"="
// console.log(firstNumber)
// console.log(secondNumber)
// console.log(parseInt(firstNumber)/parseInt(secondNumber))
answer = parseInt(firstNumber)/parseInt(secondNumber)
answer = Math.round(answer * 10) / 10;
}
else{
getPointsText.innerHTML = points
firstNumber = String(Math.floor(Math.random() * 9) + 1) + String(Math.floor(Math.random() * 9) + 1);
secondNumber = String(Math.floor(Math.random() * 9) + 1) + String(Math.floor(Math.random() * 9) + 1);
document.getElementById("problemNumScentence").value = firstNumber+"-"+secondNumber+"="
// console.log(firstNumber)
// console.log(secondNumber)
// console.log(parseInt(firstNumber)-parseInt(secondNumber))
answer = parseInt(firstNumber)-parseInt(secondNumber)
}
}
}
function setUp(){
//console.log(localStorage.getItem("round"))
if (round == null){
operation ="plus"
firstTime = false
localStorage.setItem("round", 1)
document.getElementById("roundPrint").innerHTML = "Round: "+String(localStorage.getItem("round"))
}
else{
firstTime=false
round = localStorage.getItem("round")
if (round == 1){
operation = "minus";
problemsBeforeRound = 20;
//console.log(round)
localStorage.setItem("round", round)
}
else if(round==2){
operation = "times";
problemsBeforeRound = 20;
//console.log(round)
localStorage.setItem("round", round)
//console.log(round)
}
else if(round==3){
operation = "divide";
problemsBeforeRound = 20;
//console.log(round)
localStorage.setItem("round", round)
//console.log(round)
document.getElementById("roundPrint").innerHTML = "Round: "+String(round);
}
else if(round==4){
location.href = "finished.html";
}
}
// console.log(document.getElementById("roundPrint").value)
document.getElementById("roundPrint").innerHTML = "Round: "+String(round)
twoDigit()
}
setUp()
function submit(){
if (parseInt(getUsersAnswer.value) == parseInt(answer)){
points=points+"X"
problemsBeforeRound = problemsBeforeRound -1
document.getElementById("problemRoundPrint").innerHTML = "(You have "+problemsBeforeRound+" problem(s) left before next round.)"
alert("Good Job!")
getUsersAnswer.value = ""
twoDigit()
}
else if(parseInt(getUsersAnswer.value)== 3){
points=points+"X"
alert("Good Job!")
getUsersAnswer.value = ""
twoDigit()
}
else{
getUsersAnswer.value = ""
incorrectAns()
}
document.getElementById("usersAnswer").value = "?"
}
function incorrectAns(){
alert("Your answer is incorrect. Try again; I believe in you!")
}
function val(){
document.getElementById("usersAnswer").value = ""
}