-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathindex.js
255 lines (199 loc) · 8.33 KB
/
index.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
var beans = 0;
var total = 0;
//pots
var pots = 0;
var potcost = 10
var potvalue = 2
//gardens
var gardens = 0;
var garcost = 50
var garvalue = 10
//farms
var farms = 0;
var farcost = 200;
var farvalue = 50;
//offices
var offices = 0;
var offcost = 500;
var offvalue = 200
//factories
var factories = 0;
var faccost = 2000;
var facvalue = 1000;
//megafactories
var megas = 0;
var megcost = 5000;
var megvalue = 3000;
function opentab(evt, tabName) {
// Declare all variables
var i, tabcontent, tablinks;
// Get all elements with class="tabcontent" and hide them
tabcontent = document.getElementsByClassName("tabcontent");
for (i = 0; i < tabcontent.length; i++) {
tabcontent[i].style.display = "none";
}
// Get all elements with class="tablinks" and remove the class "active"
tablinks = document.getElementsByClassName("tablinks");
for (i = 0; i < tablinks.length; i++) {
tablinks[i].className = tablinks[i].className.replace(" active", "");
}
// Show the current tab, and add an "active" class to the button that opened the tab
document.getElementById(tabName).style.display = "block";
evt.currentTarget.className += " active";
}
function loaded(){
//"G" gives 100 beans, debug
document.addEventListener("keydown",function(e){
if (e.code == "KeyG"){
beans+=100
document.getElementById("beancount").innerHTML = "Beans: "+beans
}
})
document.getElementById("defaultTab").click()
//managers
harvestmanager()
potsmanager()
gardenmanager()
farmmanager()
officemanager()
factorymanager()
megamanager()
}
//manages the Harvest Beans button
function harvestmanager(){
//clicked, add a bean
document.getElementById("harvest").addEventListener("click",function(ev){
beans++;
document.getElementById("beancount").innerHTML = "Beans: "+beans
})
}
//manages the Potted Bean Plants
function potsmanager(){
//every second, add the necessary beans
setInterval(function(){
beans+= pots*potvalue
document.getElementById("beancount").innerHTML = "Beans: "+beans
},1000)
//clicked, add a pot if affordable
document.getElementById("pots").addEventListener("click",function(ev){
if (beans >= potcost){
beans -= potcost
potcost *=2
document.getElementById("beancount").innerHTML = "Beans: "+beans
document.getElementById("potcost").innerHTML = potcost + " beans"
pots++
document.getElementById("potted_p").innerHTML = "Potted Bean Plants: " + pots
document.getElementById("totalpotvalue").innerHTML = potvalue*pots + " beans per second total"
total = potvalue*pots + garvalue*gardens + farvalue*farms + offvalue*offices + facvalue*factories + megvalue*megas
document.getElementById("total").innerHTML = "Total Beans per second: "+total
}
})
}
//manages the Bean Gardens
function gardenmanager(){
//every second, add the necessary beans
setInterval(function(){
beans+= gardens*garvalue
document.getElementById("beancount").innerHTML = "Beans: "+beans
},1000)
//clicked, add a pot if affordable
document.getElementById("gardens").addEventListener("click",function(ev){
if (beans >= garcost){
beans -= garcost
garcost*=2
document.getElementById("beancount").innerHTML = "Beans: "+beans
document.getElementById("garcost").innerHTML = garcost + " beans"
gardens++
document.getElementById("garden_p").innerHTML = "Bean Gardens: " + gardens
document.getElementById("totalgarvalue").innerHTML = garvalue*gardens + " beans per second total"
total = potvalue*pots + garvalue*gardens + farvalue*farms + offvalue*offices + facvalue*factories + megvalue*megas
document.getElementById("total").innerHTML = "Total Beans per second: "+total
}
})
}
//manages the Farms
function farmmanager(){
//every second, add the necessary beans
setInterval(function(){
beans+= farms*farvalue
document.getElementById("beancount").innerHTML = "Beans: "+beans
},1000)
//clicked, add a pot if affordable
document.getElementById("farms").addEventListener("click",function(ev){
if (beans >= farcost){
beans -= farcost
farcost*=2
document.getElementById("beancount").innerHTML = "Beans: "+beans
document.getElementById("farcost").innerHTML = farcost + " beans"
farms++
document.getElementById("farm_p").innerHTML = "Bean Farms: " + farms
document.getElementById("totalfarvalue").innerHTML = farvalue*farms + " beans per second total"
total = potvalue*pots + garvalue*gardens + farvalue*farms + offvalue*offices
document.getElementById("total").innerHTML = "Total Beans per second: "+total
}
})
}
//manages the Offices
function officemanager(){
//every second, add the necessary beans
setInterval(function(){
beans+= offices * offvalue
document.getElementById("beancount").innerHTML = "Beans: "+beans
},1000)
//clicked, add a pot if affordable
document.getElementById("office").addEventListener("click",function(ev){
if (beans >= offcost){
beans -= offcost
offcost*=2
document.getElementById("beancount").innerHTML = "Beans: "+beans
document.getElementById("offcost").innerHTML = offcost + " beans"
offices++
document.getElementById("office_p").innerHTML = "Bean Offices: " + offices
document.getElementById("totaloffvalue").innerHTML = offvalue*offices + " beans per second total"
total = potvalue*pots + garvalue*gardens + farvalue*farms + offvalue*offices + facvalue*factories + megvalue*megas
document.getElementById("total").innerHTML = "Total Beans per second: "+total
}
})
}
function factorymanager(){
//every second, add the necessary beans
setInterval(function(){
beans+= factories * facvalue
document.getElementById("beancount").innerHTML = "Beans: "+beans
},1000)
//clicked, add a pot if affordable
document.getElementById("factory").addEventListener("click",function(ev){
if (beans >= faccost){
beans -= faccost
faccost*=2
document.getElementById("beancount").innerHTML = "Beans: "+beans
document.getElementById("faccost").innerHTML = faccost + " beans"
factories++
document.getElementById("factory_p").innerHTML = "Bean Factories: " + factories
document.getElementById("totalfacvalue").innerHTML = facvalue*factories + " beans per second total"
total = potvalue*pots + garvalue*gardens + farvalue*farms + offvalue*offices + facvalue*factories + megvalue*megas
document.getElementById("total").innerHTML = "Total Beans per second: "+total
}
})
}
function megamanager(){
//every second, add the necessary beans
setInterval(function(){
beans+= megas * megvalue
document.getElementById("beancount").innerHTML = "Beans: "+beans
},1000)
//clicked, add a pot if affordable
document.getElementById("mega").addEventListener("click",function(ev){
if (beans >= megcost){
beans -= megcost
megcost*=2
document.getElementById("beancount").innerHTML = "Beans: "+beans
document.getElementById("megcost").innerHTML = megcost + " beans"
megas++
document.getElementById("mega_p").innerHTML = "Bean Mega Factories: " + factories
document.getElementById("totalmegvalue").innerHTML = megvalue*megas + " beans per second total"
total = potvalue*pots + garvalue*gardens + farvalue*farms + offvalue*offices + facvalue*factories + megvalue*megas
document.getElementById("total").innerHTML = "Total Beans per second: "+total
}
})
}