forked from jatloe/RandomWebsite1
-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathnormalview.html
More file actions
244 lines (244 loc) · 10 KB
/
normalview.html
File metadata and controls
244 lines (244 loc) · 10 KB
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
<!DOCTYPE html>
<html>
<head>
<link rel="icon" href="jatloesmile-hd.png">
<title>Base Conversion Game</title>
<style>
#welcome{
text-align: center;
}
.center{
margin: auto;
width: 20%;
text-align: center;
border-style: solid;
border-color: #add8e6;
border-width: 3px;
padding: 10px;
}
#binPrompt{
font-size: 20px;
margin: 0;
}
#prestiges{
font-size: 16px;
margin: 0;
}
#ternPrompt{
font-size: 20px;
margin: 0;
}
#ternPrestiges{
font-size: 16px;
margin: 0;
}
</style>
</head>
<body onload="setWelcome();">
<h1 id="welcome">Welcome, null.</h1>
<center><p style="font-size:24px" id="keyboardInput">Keyboard inputting for binary, press B/T to switch</p></center>
<div class="center" id="binaryConversion">
<p id="prestiges">You have 0 prestiges.</p>
<p id="binPrompt">Convert null to binary.</p> <br>
<button type="button" onclick="binInput(1)">Input 1</button>
<button type="button" onclick="binInput(0)">Input 0</button> <br> <br>
<button type="button" onclick="addOne()" id="addbutton">You have 1 points.</button>
<span id="buttonAppear"></span>
</div>
<br> <br>
<div class="center" id="ternaryConversion">
<p id="ternPrestiges">You have 0 prestiges.</p>
<p id="ternPrompt">Convert null to ternary.</p> <br>
<button type="button" onclick="ternInput(2)">Input 2</button>
<button type="button" onclick="ternInput(1)">Input 1</button>
<button type="button" onclick="ternInput(0)">Input 0</button> <br> <br>
<button type="button" onclick="ternAddOne()" id="ternaddbutton">You have 1 points.</button>
<span id="ternButtonAppear"></span>
</div>
</body>
<script>
let presnum=0;
let buttonclicks=1;
let binaryanswer=[1];
let binarysum=2;
let onindex=0;
let digits=2;
let boost=1;
let prestiges=0;
let ternonindex=0;
let ternarysum=6;
let ternaryanswer=[2];
let terndigits=2;
let ternboost=1;
let ternprestiges = 0;
let ternpresnum=0;
let ternbuttonclicks=1;
let inputbase="binary";
function setWelcome(){
var user = window.localStorage.getItem("user");
document.getElementById("welcome").innerHTML="Welcome, " + user + ".";
setBinary();
setternary();
document.getElementById("ternaryConversion").style.visibility="hidden";
document.getElementById("keyboardInput").style.visibility="hidden";
}
function setBinary(){
binarysum=Math.pow(2,digits-1);
onindex=0;
for (let i=1;i<digits-1;i++) {
binaryanswer[i]=Math.floor(Math.random() * 2);
binarysum+=Math.pow(2,digits-1-i)*binaryanswer[i];
}
binaryanswer.push(Math.floor(Math.random() * 2));
binarysum+=binaryanswer[digits-1];
document.getElementById("binPrompt").innerHTML="Convert " + binarysum + " to binary.";
}
function setternary(){
ternaryanswer[0]=Math.floor(Math.random() * 2) + 1;
ternarysum=Math.pow(3,terndigits-1)*ternaryanswer[0];
ternonindex=0;
for (let i=1;i<terndigits-1;i++) {
ternaryanswer[i]=Math.floor(Math.random() * 3);
ternarysum+=Math.pow(3,terndigits-1-i)*ternaryanswer[i];
}
ternaryanswer.push(Math.floor(Math.random() * 3));
ternarysum+=ternaryanswer[terndigits-1];
document.getElementById("ternPrompt").innerHTML="Convert " + ternarysum + " to ternary.";
}
function addOne(){
buttonclicks=buttonclicks+Math.floor(Math.log(buttonclicks+3));
document.getElementById("addbutton").innerHTML="You have " + buttonclicks + " points.";
}
function ternAddOne(){
ternbuttonclicks=ternbuttonclicks+Math.floor(Math.log(ternbuttonclicks+3));
document.getElementById("ternaddbutton").innerHTML="You have " + ternbuttonclicks + " points.";
}
function binInput(x){
if (x==binaryanswer[onindex]) {
if (onindex<digits-1) {
onindex+=1;
document.getElementById("binPrompt").innerHTML = document.getElementById("binPrompt").innerHTML + x;
} else {
buttonclicks=buttonclicks*Math.pow(2,digits)*boost*ternboost;
digits+=1;
setBinary();
document.getElementById("addbutton").innerHTML="You have " + buttonclicks + " points.";
if (Math.log10(buttonclicks)>=(20+(prestiges*5)+Math.pow(Math.floor(prestiges/10)+1,10)-1)) {
buttonFunction(Math.floor(Math.log10(buttonclicks)));
}
}
} else {
gameEnd("Rip, refresh to try again.");
}
}
function ternInput(x){
if (x==ternaryanswer[ternonindex]) {
if (ternonindex<terndigits-1) {
ternonindex+=1;
document.getElementById("ternPrompt").innerHTML = document.getElementById("ternPrompt").innerHTML + x;
} else {
ternbuttonclicks=ternbuttonclicks*Math.pow(3,digits)*ternboost;
terndigits+=1;
setternary();
document.getElementById("ternaddbutton").innerHTML="You have " + ternbuttonclicks + " points.";
if (Math.log10(ternbuttonclicks)>=(15+(ternprestiges*5)+Math.pow(Math.floor(ternprestiges/5)+1,10)-1)) {
ternButtonFunction(Math.floor(Math.log10(ternbuttonclicks)));
}
}
} else {
gameEnd("Rip, refresh to try again.");
}
}
document.onkeyup = function(e) {
if (e.which == 66) {
inputbase="binary";
document.getElementById("keyboardInput").innerHTML="Keyboard inputting for binary, press B/T to switch";
} else if (e.which == 84) {
if (prestiges>=3) {
inputbase="ternary";
document.getElementById("keyboardInput").innerHTML="Keyboard inputting for ternary, press B/T to switch";
}
} else if (e.which == 49 || e.which == 97) {
if (inputbase=="binary") {
binInput(1);
} else if (inputbase=="ternary") {
ternInput(1);
} else {
console.log("Unintended input base: " + inputbase);
}
} else if (e.which == 48 || e.which == 96) {
if (inputbase=="binary") {
binInput(0);
} else if (inputbase=="ternary") {
ternInput(0);
} else {
console.log("Unintended input base: " + inputbase);
}
} else if (e.which == 50 || e.which == 98) {
if (inputbase=="ternary") {
ternInput(2);
}
}
};
function buttonFunction(num){
document.getElementById("buttonAppear").innerHTML = '<button onclick="prestige()">Prestige for x' + num.toString() + ' multiplier</button>';
presnum = num;
}
function ternButtonFunction(num){
document.getElementById("ternButtonAppear").innerHTML = '<button onclick="ternPrestige()">Prestige for x' + num.toString() + ' multiplier</button>';
ternpresnum = num;
}
function prestige(){
if(isFinite(buttonclicks) == false) {
gameEnd("Good job! You won.");
const request = new XMLHttpRequest();
request.open("POST", "https://cors-anywhere.herokuapp.com/https://discord.com/api/webhooks/928783200011030648/81yqhaCjRa6wt1DGermGQ-gtjv8qZg6_BRm0by9VCTOxHKW0EhRSYPF5AaM7Lc_4bZj0");
request.setRequestHeader('Content-type', 'application/json');
const params = {
content: window.localStorage.getItem("user") + " just beat the game!"
}
request.send(JSON.stringify(params));
return 0;
}
buttonclicks=1;
binaryanswer=[1];
binarysum=2;
onindex=0;
digits=2;
setBinary();
boost=boost * presnum;
presnum=1;
document.getElementById("buttonAppear").innerHTML = '';
document.getElementById("addbutton").innerHTML="You have " + buttonclicks + " points.";
prestiges=prestiges+1;
document.getElementById("prestiges").innerHTML="You have " + prestiges + " prestiges.";
if(prestiges == 3) {
document.getElementById("ternaryConversion").style.visibility="visible";
document.getElementById("keyboardInput").style.visibility="visible";
}
}
function ternPrestige(){
ternbuttonclicks=1;
ternaryanswer=[3];
ternarysum=6;
ternonindex=0;
terndigits=2;
setternary();
ternboost=ternboost * ternpresnum;
ternpresnum=1;
document.getElementById("ternButtonAppear").innerHTML = '';
document.getElementById("ternaddbutton").innerHTML="You have " + ternbuttonclicks + " points.";
ternprestiges=ternprestiges+1;
document.getElementById("ternPrestiges").innerHTML="You have " + ternprestiges + " prestiges.";
}
function gameEnd(text){
var elem = document.getElementById("binaryConversion");
elem.parentNode.removeChild(elem);
var elem2 = document.getElementById("ternaryConversion");
elem2.parentNode.removeChild(elem2);
var elem3 = document.getElementById("keyboardInput");
elem3.parentNode.removeChild(elem3);
document.getElementById("welcome").innerHTML = text;
}
</script>
</html>