forked from FryGuy93/zoo-clicker
-
Notifications
You must be signed in to change notification settings - Fork 0
/
main.js
288 lines (239 loc) · 13.3 KB
/
main.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
var zoodollars = 0;
var ips = 0;
var onehundred = 1000000000;
var btnUpgLvl = 1;
var btnUpgCost = 10;
function addFunds(number){
zoodollars = zoodollars + number;
document.getElementById("zoodollars").innerHTML = zoodollars;
};
//Ants
var ants = 0;
function buyAnt(){
var antCost = Math.floor(8 * Math.pow(1.1,ants)); //works out the cost of this cursor
if(zoodollars >= antCost){ //checks that the player can afford the cursor
ants = ants + 1; //increases number of ants
zoodollars = zoodollars - antCost; //removes the zoodollars spent
document.getElementById('ants').innerHTML = ants; //updates the number of ants for the user
document.getElementById('zoodollars').innerHTML = zoodollars; //updates the number of zoodollars for the user
totalAntsIncome = ants * 1; // Multiply the current number of animals owned by the income. Enter income manually.
document.getElementById('totalAntsIncome').innerHTML = totalAntsIncome; // Updates the total income for user.
ips = ips + 1;
document.getElementById('ips').innerHTML = ips;
};
var nextCost = Math.floor(8 * Math.pow(1.1,ants)); //works out the cost of the next cursor
document.getElementById('antCost').innerHTML = nextCost; //updates the cursor cost for the user
};
//Butterflys
var butterflys = 0;
function buyButterfly(){
var butterflyCost = Math.floor(16 * Math.pow(1.1,butterflys)); //works out the cost of this cursor
if(zoodollars >= butterflyCost){ //checks that the player can afford the cursor
butterflys = butterflys + 1; //increases number of butterflys
zoodollars = zoodollars - butterflyCost; //removes the zoodollars spent
document.getElementById('butterflys').innerHTML = butterflys; //updates the number of butterflys for the user
document.getElementById('zoodollars').innerHTML = zoodollars; //updates the number of zoodollars for the user
totalButterflysIncome = butterflys * 2; // Multiply the current number of animals owned by the income. Enter income manually.
document.getElementById('totalButterflysIncome').innerHTML = totalButterflysIncome; // Updates the total income for user.
ips = ips + 2;
document.getElementById('ips').innerHTML = ips;
};
var nextCost = Math.floor(16 * Math.pow(1.1,butterflys)); //works out the cost of the next cursor
document.getElementById('butterflyCost').innerHTML = nextCost; //updates the cursor cost for the user
};
//Caterpillars
var caterpillars = 0;
function buyCaterpillar(){
var caterpillarCost = Math.floor(32 * Math.pow(1.1,caterpillars)); //works out the cost of this cursor
if(zoodollars >= caterpillarCost){ //checks that the player can afford the cursor
caterpillars = caterpillars + 1; //increases number of caterpillars
zoodollars = zoodollars - caterpillarCost; //removes the zoodollars spent
document.getElementById('caterpillars').innerHTML = caterpillars; //updates the number of caterpillars for the user
document.getElementById('zoodollars').innerHTML = zoodollars; //updates the number of zoodollars for the user
totalCaterpillarsIncome = caterpillars * 3; // Multiply the current number of animals owned by the income. Enter income manually.
document.getElementById('totalCaterpillarsIncome').innerHTML = totalCaterpillarsIncome; // Updates the total income for user.
ips = ips + 3;
document.getElementById('ips').innerHTML = ips;
};
var nextCost = Math.floor(32 * Math.pow(1.1,caterpillars)); //works out the cost of the next cursor
document.getElementById('caterpillarCost').innerHTML = nextCost; //updates the cursor cost for the user
};
//Dolphins
var dolphins = 0;
function buyDolphin(){
var dolphinCost = Math.floor(64 * Math.pow(1.1,dolphins)); //works out the cost of this cursor
if(zoodollars >= dolphinCost){ //checks that the player can afford the cursor
dolphins = dolphins + 1; //increases number of dolphins
zoodollars = zoodollars - dolphinCost; //removes the zoodollars spent
document.getElementById('dolphins').innerHTML = dolphins; //updates the number of dolphins for the user
document.getElementById('zoodollars').innerHTML = zoodollars; //updates the number of zoodollars for the user
totalDolphinsIncome = dolphins * 4; // Multiply the current number of animals owned by the income. Enter income manually.
document.getElementById('totalDolphinsIncome').innerHTML = totalDolphinsIncome; // Updates the total income for user.
ips = ips + 4;
document.getElementById('ips').innerHTML = ips;
};
var nextCost = Math.floor(64 * Math.pow(1.1,dolphins)); //works out the cost of the next cursor
document.getElementById('dolphinCost').innerHTML = nextCost; //updates the cursor cost for the user
};
//Dolphins End
//Emus
var emus = 0;
function buyEmu(){
var emuCost = Math.floor(128 * Math.pow(1.1,emus)); //works out the cost of this cursor
if(zoodollars >= emuCost){ //checks that the player can afford the cursor
emus = emus + 1; //increases number of emus
zoodollars = zoodollars - emuCost; //removes the zoodollars spent
document.getElementById('emus').innerHTML = emus; //updates the number of emus for the user
document.getElementById('zoodollars').innerHTML = zoodollars; //updates the number of zoodollars for the user
totalEmusIncome = emus * 5; // Multiply the current number of animals owned by the income. Enter income manually.
document.getElementById('totalEmusIncome').innerHTML = totalEmusIncome; // Updates the total income for user.
ips = ips + 5;
document.getElementById('ips').innerHTML = ips;
};
var nextCost = Math.floor(128 * Math.pow(1.1,emus)); //works out the cost of the next cursor
document.getElementById('emuCost').innerHTML = nextCost; //updates the cursor cost for the user
};
//Emus End
//Falcons
var falcons = 0;
function buyFalcon(){
var falconCost = Math.floor(256 * Math.pow(1.1,falcons)); //works out the cost of this cursor
if(zoodollars >= falconCost){ //checks that the player can afford the cursor
falcons = falcons + 1; //increases number of falcons
zoodollars = zoodollars - falconCost; //removes the zoodollars spent
document.getElementById('falcons').innerHTML = falcons; //updates the number of falcons for the user
document.getElementById('zoodollars').innerHTML = zoodollars; //updates the number of zoodollars for the user
totalFalconsIncome = falcons * 10; // Multiply the current number of animals owned by the income. Enter income manually.
document.getElementById('totalFalconsIncome').innerHTML = totalFalconsIncome; // Updates the total income for user.
ips = ips + 10;
document.getElementById('ips').innerHTML = ips;
};
var nextCost = Math.floor(256 * Math.pow(1.1,falcons)); //works out the cost of the next cursor
document.getElementById('falconCost').innerHTML = nextCost; //updates the cursor cost for the user
};
//Falcons End
//Giraffes
var giraffes = 0;
function buyGiraffe(){
var giraffeCost = Math.floor(512 * Math.pow(1.1,giraffes)); //works out the cost of this cursor
if(zoodollars >= giraffeCost){ //checks that the player can afford the cursor
giraffes = giraffes + 1; //increases number of giraffes
zoodollars = zoodollars - giraffeCost; //removes the zoodollars spent
document.getElementById('giraffes').innerHTML = giraffes; //updates the number of giraffes for the user
document.getElementById('zoodollars').innerHTML = zoodollars; //updates the number of zoodollars for the user
totalGiraffesIncome = giraffes * 25; // Multiply the current number of animals owned by the income. Enter income manually.
document.getElementById('totalGiraffesIncome').innerHTML = totalGiraffesIncome; // Updates the total income for user.
ips = ips + 25;
document.getElementById('ips').innerHTML = ips;
};
var nextCost = Math.floor(512 * Math.pow(1.1,giraffes)); //works out the cost of the next cursor
document.getElementById('giraffeCost').innerHTML = nextCost; //updates the cursor cost for the user
};
//Giraffes End
function save(){
var allItems = [
zoodollars,
ants,
butterflys,
caterpillars,
dolphins,
emus,
falcons,
giraffes,
ips
];
localStorage['saveGame'] = btoa(JSON.stringify(allItems));
};
function load(){
var allItems = JSON.parse(atob(localStorage['saveGame']));
zoodollars = allItems[0];
ants = allItems[1];
butterflys = allItems[2];
caterpillars = allItems[3];
dolphins = allItems[4];
emus = allItems[5];
falcons = allItems[6];
giraffes = allItems[7];
ips = allItems[8];
document.getElementById("zoodollars").innerHTML = zoodollars;
document.getElementById("ants").innerHTML = ants;
document.getElementById("butterflys").innerHTML = butterflys;
document.getElementById("caterpillars").innerHTML = caterpillars;
document.getElementById("dolphins").innerHTML = dolphins;
document.getElementById("emus").innerHTML = emus;
document.getElementById("falcons").innerHTML = falcons;
document.getElementById("giraffes").innerHTML = giraffes;
document.getElementById("ips").innerHTML = ips;
// Calc ants cost
var nextAntsCost = Math.floor(8 * Math.pow(1.1,ants));
document.getElementById('antCost').innerHTML = nextAntsCost;
// Set ants total income
var totalAntsIncome = ants * 1;
document.getElementById('totalAntsIncome').innerHTML = totalAntsIncome;
// Calc butterfly cost
var nextButterflysCost = Math.floor(16 * Math.pow(1.1,butterflys));
document.getElementById('butterflyCost').innerHTML = nextButterflysCost;
// Set butterflys total income
var totalButterflysIncome = butterflys * 2;
document.getElementById('totalButterflysIncome').innerHTML = totalButterflysIncome;
// Calc caterpillar cost
var nextCaterpillarsCost = Math.floor(32 * Math.pow(1.1,caterpillars));
document.getElementById('caterpillarCost').innerHTML = nextCaterpillarsCost;
// Set caterpillars total income
var totalCaterpillarsIncome = caterpillars * 3;
document.getElementById('totalCaterpillarsIncome').innerHTML = totalCaterpillarsIncome;
// Calc dolphin cost
var nextDolphinsCost = Math.floor(64 * Math.pow(1.1,dolphins));
document.getElementById('dolphinCost').innerHTML = nextDolphinsCost;
// Set dolphins total income
var totaDolphinsIncome = dolphins * 4;
document.getElementById('totaDolphinsIncome').innerHTML = totaDolphinsIncome;
// Calc emu cost
var nextEmusCost = Math.floor(128 * Math.pow(1.1,emus));
document.getElementById('emusCost').innerHTML = nextEmusCost;
// Set emu total income
var totalEmusIncome = emus * 5;
document.getElementById('totaEmusIncome').innerHTML = totaEmusIncome;
// Calc falcons cost
var nextFalconsCost = Math.floor(256 * Math.pow(1.1,emus));
document.getElementById('falconsCost').innerHTML = nextFalconsCost;
// Set falcons total income
var totalFalconsIncome = falcons * 10;
document.getElementById('totaFalconsIncome').innerHTML = totaFalconsIncome;
// Calc giraffes cost
var nextGiraffesCost = Math.floor(512 * Math.pow(1.1,emus));
document.getElementById('giraffesCost').innerHTML = nextGiraffesCost;
// Set giraffes total income
var totalGiraffesIncome = giraffes * 25;
document.getElementById('totaGiraffesIncome').innerHTML = totaGiraffesIncome;
//var ips = totalAntsIncome + totalButterflysIncome + totalCaterpillarsIncome + totalDolphinsIncome + totaEmusIncome + totalFalconsIncome + totaGiraffesIncome;
//document.getElementById('ips').innerHTML = ips;
};
function addFunds2(){
addFunds(btnUpgLvl * 1);
document.getElementById("zoodollars").innerHTML = zoodollars;
};
function upgradeFunds(){
if(zoodollars >= btnUpgCost){
btnUpgLvl = btnUpgLvl + 1;
zoodollars = zoodollars - btnUpgCost;
btnUpgCost = Math.floor(10 * Math.pow(1.1,btnUpgLvl));
document.getElementById("btnUpg").innerHTML = "Upgrade - Lvl: " + btnUpgLvl + ", Cost: " + btnUpgCost;
document.getElementById("zoodollars").innerHTML = zoodollars;
};
};
//Update stats
window.setInterval(function(){
addFunds(ants * 1);
addFunds(butterflys * 2);
addFunds(caterpillars * 3);
addFunds(dolphins * 4);
addFunds(emus * 5);
addFunds(falcons * 10);
addFunds(giraffes * 25);
}, 1000);
function checkDollars(){
if(zoodollars == onehundred){
alert("You're A Billionaire Bruh.");
};
}