forked from jatloe/RandomWebsite1
-
Notifications
You must be signed in to change notification settings - Fork 0
/
catloe.html
182 lines (182 loc) · 7.47 KB
/
catloe.html
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
<!DOCTYPE html>
<html>
<head>
<link rel="icon" href="jatloesmile-hd.png">
<title>Catloe's page!</title>
<style>
.side{
display: inline;
}
#message{
font-size: 24px;
font-style: italic;
}
#catloeContainer {
height: 97px;
width: 97px;
}
</style>
</head>
<body>
<p>V0.21</p> <br>
<p id="message">meow!</p>
<div id="catloeContainer"><img src="catloe.png" alt="Catloe" id="catloe" onclick="catloemovemain()"></div><br>
<button type="button" onclick="pet()" id="pet" class="side">Pet</button>
<button type="button" onclick="feed()" id="feed" class="side">Feed</button>
<button type="button" onclick="hug()" id="hug">Hug</button>
<input type="text" id="useranswer" size="10" maxlength="10" placeholder="Answer" style="display:none;" oninput="answerChange()"> <br>
<p id="stats">You pet catloe 0 times, fed catloe 0 times, and hugged catloe 0 times.</p>
</body>
<script>
let moving = false;
let pets = 0;
let feeds = 0;
let hugs = 0;
let answer = 665;
let mathing = false;
function updateStats() {
document.getElementById("stats").innerHTML = "You pet catloe " + pets.toString() + " times, fed catloe " + feeds.toString() + " times, and hugged catloe " + hugs.toString() + " times.";
if( (pets == 4 && feeds == 2 && hugs == 0) || (pets == 0 && feeds == 6 && hugs == 9) ) {
document.getElementById("stats").innerHTML += " Nice."
}
if( (pets == 1 && feeds == 8 && hugs == 7) ) {
document.getElementById("stats").innerHTML += " ONE EIGHT SEVEN"
}
if( (pets == 6 && feeds == 6 && hugs == 5) ) {
document.getElementById("stats").innerHTML += " SIX SIX FIVE"
}
if(Math.random() < 0.2) {
mathing = true;
mathtime();
document.getElementById("pet").disabled = true;
document.getElementById("feed").disabled = true;
document.getElementById("hug").disabled = true;
}
}
function pet() {
document.getElementById("message").innerHTML = "purr";
pets += 1;
updateStats();
document.getElementById("pet").disabled = true;
setTimeout(() => {
if(mathing == false) {
document.getElementById("pet").disabled = false;
}
}, 500);
}
function feed() {
if(feeds>=10) {
document.getElementById("message").innerHTML = "I'm full already! mewmewmew";
} else {
document.getElementById("message").innerHTML = "nomnomnom";
feeds += 1;
}
updateStats();
document.getElementById("feed").disabled = true;
setTimeout(() => {
if(mathing == false) {
document.getElementById("feed").disabled = false;
}
}, 500);
}
function hug() {
document.getElementById("message").innerHTML = "mew :)";
hugs += 1;
updateStats();
document.getElementById("hug").disabled = true;
setTimeout(() => {
if(mathing == false) {
document.getElementById("hug").disabled = false;
}
}, 500);
}
function catloemovemain() {
if(document.getElementById("catloe").style.transform == "scale(1)" || document.getElementById("catloe").style.transform == "") {
scales = [0.975,0.95,0.925,0.9,0.88,0.86,0.84,0.83,0.82,0.81,0.8,0.81,0.82,0.83,0.84,0.86,0.88,0.9,0.925,0.95,0.975,1];
for (let i = 0; i <= 21; i++) {
setTimeout(() => {catloemove(scales[i])}, i*15);
}
}
}
function catloemove(num) {
document.getElementById("catloe").style.transform = "scale(" + num.toString() + ")";
}
function mathtime(seed=Math.random()*4) {
let thing = seed;
if(thing < 1) {
let num1 = Math.floor(Math.random() * 90)+10;
let num2 = Math.floor(Math.random() * 9)+1;
answer = num1*num2;
document.getElementById("message").innerHTML = "Math time! What is " + num1.toString() + " times " + num2.toString() + "?";
document.getElementById("useranswer").style.display = "";
} else if(thing < 2) {
let words = ["math","meow","think","good","job","word","cool","happy","pencil","pen","paper","wood"];
let word = words[Math.floor(Math.random()*words.length)];
let wordbutlist = word.split("");
let scrambled = word;
while(scrambled == word) {
wordbutlist = word.split("");
scrambled = "";
while(wordbutlist.length != 0) {
let newletter = wordbutlist[Math.floor(Math.random()*wordbutlist.length)]
scrambled += newletter;
const index = wordbutlist.indexOf(newletter);
if (index > -1) {
wordbutlist.splice(index, 1); // 2nd parameter means remove one item only
}
}
}
answer = word;
document.getElementById("message").innerHTML = "Unscramble " + scrambled + "!";
document.getElementById("useranswer").style.display = "";
} else if(thing < 2.5) {
let letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
let num = Math.floor(Math.random()*letters.length);
let letter = letters[num];
answer = num + 1;
document.getElementById("message").innerHTML = "What is the position of " + letter + " in the alphabet?";
document.getElementById("useranswer").style.display = "";
} else if(thing < 3) {
let letters = "ABCDEFGHIJKLMNOPQRSTUVWXYZ".split("");
let num = Math.floor(Math.random()*letters.length);
let letter = letters[num];
answer = letter;
let thingy = "th";
if(num == 0 || num == 20) {
thingy = "st";
}
if(num == 1 || num == 21) {
thingy = "nd";
}
if(num == 2 || num == 22) {
thingy = "rd";
}
document.getElementById("message").innerHTML = "What is the " + (num+1).toString() + thingy + " letter in the alphabet?";
document.getElementById("useranswer").style.display = "";
} else if(thing < 3.5) {
let startingnum = Math.floor(Math.random()*50)+1;
let diff = Math.floor(Math.random()*20)+1;
answer = startingnum+4*diff;
document.getElementById("message").innerHTML = "mathemolympiad's challenge: What's next? " + startingnum.toString() + "," + (startingnum+diff).toString() + "," + (startingnum+2*diff).toString() + "," + (startingnum+3*diff).toString();
document.getElementById("useranswer").style.display = "";
} else if(thing < 4) {
let startingnum = Math.floor(Math.random()*10)+1;
let diff = Math.floor(Math.random()*4)+2;
answer = startingnum*diff*diff*diff*diff;
document.getElementById("message").innerHTML = "mathemolympiad's challenge: What's next? " + startingnum.toString() + "," + (startingnum*diff).toString() + "," + (startingnum*diff*diff).toString() + "," + (startingnum*diff*diff*diff).toString();
document.getElementById("useranswer").style.display = "";
}
}
function answerChange() {
if(document.getElementById("useranswer").value.toLowerCase() == answer.toString().toLowerCase()) {
document.getElementById("message").innerHTML = "Correct!";
document.getElementById("useranswer").value = "";
document.getElementById("useranswer").style.display = "none";
document.getElementById("pet").disabled = false;
document.getElementById("feed").disabled = false;
document.getElementById("hug").disabled = false;
mathing = false;
}
}
</script>
</html>