-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathstoneAgeSurvival.html
222 lines (222 loc) · 13 KB
/
stoneAgeSurvival.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
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
<!DOCTYPE html>
<html>
<head>
<meta charset="utf-8">
<title>Stone Age Survival</title>
<style type="text/css">
button:not([id="goHome"]) {
width: 50px;
height: 50px;
border-radius: 25px;
background-color: red;
font-size: 20px;
}
button:hover:not([id="goHome"]) {
background-color: darkred;
cursor: pointer;
}
span {
font-size: 30px;
}
</style>
</head>
<body>
<a id="goHome" href='index.html' style="width: 100px; height: 35px; font-size: 25px; font-weight: 200;">Back</a><br />
<center>
<h1>One of these 100 buttons is a win button, the other 99, well, other thing happen. Try not to die!</h1>
<button onclick="clickButton(1)" id="1"></button> <button onclick="clickButton(2)" id="2"></button> <button onclick="clickButton(3)" id="3"></button> <button onclick="clickButton(4)" id="4"></button> <button onclick="clickButton(5)" id="5"></button> <button onclick="clickButton(6)" id="6"></button> <button onclick="clickButton(7)" id="7"></button> <button onclick="clickButton(8)" id="8"></button> <button onclick="clickButton(9)" id="9"></button> <button onclick="clickButton(10)" id="10"></button> <br><button onclick="clickButton(11)" id="11"></button> <button onclick="clickButton(12)" id="12"></button> <button onclick="clickButton(13)" id="13"></button> <button onclick="clickButton(14)" id="14"></button> <button onclick="clickButton(15)" id="15"></button> <button onclick="clickButton(16)" id="16"></button> <button onclick="clickButton(17)" id="17"></button> <button onclick="clickButton(18)" id="18"></button> <button onclick="clickButton(19)" id="19"></button> <button onclick="clickButton(20)" id="20"></button> <br><button onclick="clickButton(21)" id="21"></button> <button onclick="clickButton(22)" id="22"></button> <button onclick="clickButton(23)" id="23"></button> <button onclick="clickButton(24)" id="24"></button> <button onclick="clickButton(25)" id="25"></button> <button onclick="clickButton(26)" id="26"></button> <button onclick="clickButton(27)" id="27"></button> <button onclick="clickButton(28)" id="28"></button> <button onclick="clickButton(29)" id="29"></button> <button onclick="clickButton(30)" id="30"></button> <br><button onclick="clickButton(31)" id="31"></button> <button onclick="clickButton(32)" id="32"></button> <button onclick="clickButton(33)" id="33"></button> <button onclick="clickButton(34)" id="34"></button> <button onclick="clickButton(35)" id="35"></button> <button onclick="clickButton(36)" id="36"></button> <button onclick="clickButton(37)" id="37"></button> <button onclick="clickButton(38)" id="38"></button> <button onclick="clickButton(39)" id="39"></button> <button onclick="clickButton(40)" id="40"></button> <br><button onclick="clickButton(41)" id="41"></button> <button onclick="clickButton(42)" id="42"></button> <button onclick="clickButton(43)" id="43"></button> <button onclick="clickButton(44)" id="44"></button> <button onclick="clickButton(45)" id="45"></button> <button onclick="clickButton(46)" id="46"></button> <button onclick="clickButton(47)" id="47"></button> <button onclick="clickButton(48)" id="48"></button> <button onclick="clickButton(49)" id="49"></button> <button onclick="clickButton(50)" id="50"></button> <br><button onclick="clickButton(51)" id="51"></button> <button onclick="clickButton(52)" id="52"></button> <button onclick="clickButton(53)" id="53"></button> <button onclick="clickButton(54)" id="54"></button> <button onclick="clickButton(55)" id="55"></button> <button onclick="clickButton(56)" id="56"></button> <button onclick="clickButton(57)" id="57"></button> <button onclick="clickButton(58)" id="58"></button> <button onclick="clickButton(59)" id="59"></button> <button onclick="clickButton(60)" id="60"></button> <br><button onclick="clickButton(61)" id="61"></button> <button onclick="clickButton(62)" id="62"></button> <button onclick="clickButton(63)" id="63"></button> <button onclick="clickButton(64)" id="64"></button> <button onclick="clickButton(65)" id="65"></button> <button onclick="clickButton(66)" id="66"></button> <button onclick="clickButton(67)" id="67"></button> <button onclick="clickButton(68)" id="68"></button> <button onclick="clickButton(69)" id="69"></button> <button onclick="clickButton(70)" id="70"></button> <br><button onclick="clickButton(71)" id="71"></button> <button onclick="clickButton(72)" id="72"></button> <button onclick="clickButton(73)" id="73"></button> <button onclick="clickButton(74)" id="74"></button> <button onclick="clickButton(75)" id="75"></button> <button onclick="clickButton(76)" id="76"></button> <button onclick="clickButton(77)" id="77"></button> <button onclick="clickButton(78)" id="78"></button> <button onclick="clickButton(79)" id="79"></button> <button onclick="clickButton(80)" id="80"></button> <br><button onclick="clickButton(81)" id="81"></button> <button onclick="clickButton(82)" id="82"></button> <button onclick="clickButton(83)" id="83"></button> <button onclick="clickButton(84)" id="84"></button> <button onclick="clickButton(85)" id="85"></button> <button onclick="clickButton(86)" id="86"></button> <button onclick="clickButton(87)" id="87"></button> <button onclick="clickButton(88)" id="88"></button> <button onclick="clickButton(89)" id="89"></button> <button onclick="clickButton(90)" id="90"></button> <br><button onclick="clickButton(91)" id="91"></button> <button onclick="clickButton(92)" id="92"></button> <button onclick="clickButton(93)" id="93"></button> <button onclick="clickButton(94)" id="94"></button> <button onclick="clickButton(95)" id="95"></button> <button onclick="clickButton(96)" id="96"></button> <button onclick="clickButton(97)" id="97"></button> <button onclick="clickButton(98)" id="98"></button> <button onclick="clickButton(99)" id="99"></button> <button onclick="clickButton(100)" id="100"></button> <br>
<h1>Result:</h1>
<h1 id="result"></h1>
<span id="alive">People Alive: 5</span> <span id="food">Food: 100</span> <span id="water">Water: 100</span> <span id="tools">Tools: 5</span>
</center>
<script type="text/javascript">
function random(start,end){
return Math.floor(Math.random()*(end-start+1))+start
}
</script>
<script type="text/javascript">
var alive = 5
var food = 100
var water = 100
var tools = 5
var result = ""
var resurrect = random(1,100)
var resurrect2 = random(1,100)
var win = Math.floor(Math.random()*100)+1
var stopped = false
function choseYes(thing){
switch (thing){
case 'poisonousBerries':
var chance1 = random(1,3)
if (chance1 == 1){
alive--
result = "The berries were poisonous. One person died. "
}
else {
food += random(7,10)
result = "The berries were normal. You add them to you food supply. "
}
break;
case "move":
var chance2 = random(1,2)
if (chance2 == 1){
result = "You moved, and good stuff happened. You get some food and water."
food += random(4,6)
water += random(4,6)
}
else {
result = "You moved, but found nothing at your new home. You move back, costing you some food and water."
food -= 5
water -= 5
}
break
case "stream":
if (tools<=0){
result = "You have no more tools."
break
}
water += random(9,12)
tools --
result = "You gathered water."
break
case "hunt":
if (tools<=1){
result = "You don't have enough tools"
break
}
tools -= 2
var chance3 = random(1,4)
if (chance3 == 1){
result = "You found nothing :("
break
}
else if (chance3 == 2){
result = "One person got lost and died."
alive --
break
}
else {
result = "You found and killed a lot of animals."
food += random(23,28)
break
}
}
stopped = false
if (alive <= 0){
result = "<br /> Everyone's dead, so you lose."
document.getElementById("result").innerHTML = result
stopped = true
document.getElementById("alive").innerHTML = "People Alive: Everyone's dead."
return
}
if (water < 0){
water = 0
result += "<br /> You have no more water! One person died."
alive--
}
if (food < 0){
food = 0
result += "<br /> You have no more food! One person died."
alive--
}
document.getElementById("water").innerHTML = "Water: "+water
document.getElementById("food").innerHTML = "Food "+food
document.getElementById("tools").innerHTML = "Tools "+tools
document.getElementById("result").innerHTML = result
document.getElementById("alive").innerHTML = "People Alive: "+alive
if (alive <= 0){
result = "<br> Everyone's dead, so you lose."
document.getElementById("result").innerHTML = result
stopped = true
document.getElementById("alive").innerHTML = "People Alive: Everyone's dead."
return
}
}
function choseNo() {
result = "Nope. "
stopped = false
document.getElementById("result").innerHTML = result
document.getElementById("food").innerHTML = "Food "+food
document.getElementById("tools").innerHTML = "Tools "+tools
document.getElementById("alive").innerHTML = "People Alive: "+alive
document.getElementById("water").innerHTML = "Water: "+water
}
function clickButton(n) {
result = ""
food -= alive
water -= alive
if (stopped == true){
return
}
document.getElementById(n).style.backgroundColor = "gray"
document.getElementById(n).disabled = true
if (n == win){
result = "YOU WIN!"
stopped = true
document.getElementById("result").innerHTML = result
return
}
var chance = Math.floor(Math.random()*10)+1
switch (chance){
case 1:
result = "You harvested a few berry bushes, but you can't tell if the berries are poisonous or not. Do you eat them? <br> <button onclick=\"choseYes('poisonousBerries')\">Yes</button> <button onclick=\"choseNo()\">No</button> "
stopped = true
break
case 2:
result = "One person suggests you move! Do you? <br> <button onclick=\"choseYes('move')\">Yes</button> <button onclick=\"choseNo()\">No</button> "
stopped = true
break
case 3:
result = "You find a stream, but you need to use a tool to gather water. Do you gather water? <br> <button onclick=\"choseYes('stream')\">Yes</button> <button onclick=\"choseNo()\">No</button> "
stopped = true
break
case 4:
result = "You have nothing else to do, so you made tools."
tools += random(1,3)
break
case 5:
result = "You go hunting! You need 2 tools to go. Do you go? <br> <button onclick=\"choseYes('hunt')\">Yes</button> <button onclick=\"choseNo()\">No</button> "
stopped = true
break
}
if (n == resurrect){
result += "<br> And what the heck you managed to resurrect one of your dead friends."
alive ++
}
if (n == resurrect2){
result += "<br> And what the heck you managed to resurrect one of your dead friends."
alive ++
}
if (alive <= 0){
result = "<br> Everyone's dead, so you lose."
document.getElementById("result").innerHTML = result
stopped = true
document.getElementById("alive").innerHTML = "People Alive: Everyone's dead."
return
}
if (water < 0){
water = 0
result += "<br> You have no more water! One person died."
alive --
}
if (food < 0){
food = 0
result += "<br> You have no more food! One person died."
alive --
}
document.getElementById("water").innerHTML = "Water: "+water
document.getElementById("food").innerHTML = "Food "+food
document.getElementById("tools").innerHTML = "Tools "+tools
document.getElementById("result").innerHTML = result
document.getElementById("alive").innerHTML = "People Alive: "+alive
if (alive <= 0){
result = "<br> Everyone's dead, so you lose."
document.getElementById("result").innerHTML = result
stopped = true
document.getElementById("alive").innerHTML = "People Alive: Everyone's dead."
return
}
}
</script>
</body>
</html>