-
Notifications
You must be signed in to change notification settings - Fork 20
/
Copy pathbase.js
3168 lines (3032 loc) · 129 KB
/
base.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
289
290
291
292
293
294
295
296
297
298
299
300
301
302
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
557
558
559
560
561
562
563
564
565
566
567
568
569
570
571
572
573
574
575
576
577
578
579
580
581
582
583
584
585
586
587
588
589
590
591
592
593
594
595
596
597
598
599
600
601
602
603
604
605
606
607
608
609
610
611
612
613
614
615
616
617
618
619
620
621
622
623
624
625
626
627
628
629
630
631
632
633
634
635
636
637
638
639
640
641
642
643
644
645
646
647
648
649
650
651
652
653
654
655
656
657
658
659
660
661
662
663
664
665
666
667
668
669
670
671
672
673
674
675
676
677
678
679
680
681
682
683
684
685
686
687
688
689
690
691
692
693
694
695
696
697
698
699
700
701
702
703
704
705
706
707
708
709
710
711
712
713
714
715
716
717
718
719
720
721
722
723
724
725
726
727
728
729
730
731
732
733
734
735
736
737
738
739
740
741
742
743
744
745
746
747
748
749
750
751
752
753
754
755
756
757
758
759
760
761
762
763
764
765
766
767
768
769
770
771
772
773
774
775
776
777
778
779
780
781
782
783
784
785
786
787
788
789
790
791
792
793
794
795
796
797
798
799
800
801
802
803
804
805
806
807
808
809
810
811
812
813
814
815
816
817
818
819
820
821
822
823
824
825
826
827
828
829
830
831
832
833
834
835
836
837
838
839
840
841
842
843
844
845
846
847
848
849
850
851
852
853
854
855
856
857
858
859
860
861
862
863
864
865
866
867
868
869
870
871
872
873
874
875
876
877
878
879
880
881
882
883
884
885
886
887
888
889
890
891
892
893
894
895
896
897
898
899
900
901
902
903
904
905
906
907
908
909
910
911
912
913
914
915
916
917
918
919
920
921
922
923
924
925
926
927
928
929
930
931
932
933
934
935
936
937
938
939
940
941
942
943
944
945
946
947
948
949
950
951
952
953
954
955
956
957
958
959
960
961
962
963
964
965
966
967
968
969
970
971
972
973
974
975
976
977
978
979
980
981
982
983
984
985
986
987
988
989
990
991
992
993
994
995
996
997
998
999
1000
/*
As you can see, i'm not a javascript master
The code is full of functions :o
Btw, there are very very few comments that explain the code >:) HAHAHAHA
Hope you enjoyed the game
(I want you to read this after finishing the game or things in this game may be spoiled to you)
*/
var enemy_attack_timer;
var healthtimeout;
var skilltimeout;
var potiontimeout;
var invulnerabilitydelay;
function randomnumber(min,max) {
return Math.floor(Math.random()*(max-min)+min);
}
function closemessage() {
$(".alert").fadeOut("fast");
$(".modal").fadeOut("fast");
}
function updategold() {
$("#gold-bar").html(goldbar);
$("#iron-bar").html(ironbar);
if(ironmining>0 && ironmining<=59) {
ibpt=ironmining;
ibtime=3600;
}
else if(ironmining>59 && ironmining<=219) {
ibpt=Math.round((ironmining-59)/2.3);
if(ibpt==0) {
ibpt=1;
}
ibtime=60;
}
else if(ironmining>219 && ironmining<4717) {
ibpt=Math.round((ironmining-219)/4.5);
if(ibpt==0) {
ibpt=1;
}
ibtime=1;
}
else if(ironmining>=4717) {
ibpt=1000;
ibtime=1;
}
if(goldmining<30) {
goldmining=30;
}
if(buyfactory==true) {
gbps=Math.round(goldmining/10);
}
}
function updateitems() {
$("#otheritems").html("");
for(i=0;i<items.length;i++) {
thisitem=items[i];
if(thisitem.owned>0 && thisitem.showstorage) {
if(thisitem.owned!=1) {
plural=thisitem.plural;
}
else {
plural="";
}
thestorage=$("#otheritems").html();
$("#otheritems").html(thestorage+"<br>"+thisitem.owned+" "+thisitem.name+plural);
}
}
cut=$("#otheritems").html().substring(4);
$("#otheritems").html(cut);
$(".iron-mining-amount").html(ironmining);
$(".ibpt").html(ibpt);
$(".skilllvl").html(skilllvl);
$(".thunder-damage").html(20+skilllvl*7);
$(".invuln-time").html((3+(skilllvl*3)));
$(".upgrade-price").html(skilllvl*skilllvl*500+500);
$(".irontime").html(second2name(ibtime));
$(".gold-mining").html(goldmining);
$(".gbps").html(gbps);
ironprice=10+Math.floor(ironmining*ironmining/150);
$(".1-iron-cost").html(ironprice);
$(".10-iron-cost").html(ironprice*10);
$(".100-iron-cost").html(ironprice*100);
goldprice=10+Math.floor(goldmining*goldmining/75);
$(".1-gold-cost").html(goldprice);
$(".10-gold-cost").html(goldprice*10);
$(".100-gold-cost").html(goldprice*100);
if(enchant_attack==0 && enchant_defense==0 && enchant_countdown==0 && enchant_life==0) {
$(".enchants").html("Your sword is enchanted with:<br>Your sword is not enchanted at all.");
}
else {
enchant_html="Your sword is enchanted with:<br>";
if(enchant_attack>0) { enchant_html=enchant_html+"Attack "+enchant_attack+" (+"+(enchant_attack*7)+" damage)<br>"; }
if(enchant_defense>0) { enchant_html=enchant_html+"Defense "+enchant_defense+" (Absorbs "+(enchant_defense*2)+"% damage)<br>"; }
if(enchant_countdown>0) { enchant_html=enchant_html+"Countdown "+enchant_countdown+" (Countdowns are a little bit faster)<br>"; }
if(enchant_life>0) { enchant_html=enchant_html+"Life "+enchant_life+" (Increases HP by "+enchant_life*2+" each time you attack)<br>"; }
$(".enchants").html(enchant_html);
}
$(".enchant-attack-price").html(enchant_attack*enchant_attack*2000+2000);
$(".enchant-defense-price").html(enchant_defense*enchant_defense*2500+2500);
$(".enchant-countdown-price").html(enchant_countdown*enchant_countdown*5000+5000);
$(".enchant-life-price").html(enchant_life*enchant_life*2500+2500);
$(".button-enchant-attack").attr("value","Attack "+(enchant_attack+1));
$(".button-enchant-defense").attr("value","Defense "+(enchant_defense+1));
$(".button-enchant-life").attr("value","Life "+(enchant_life+1));
if(enchant_countdown==0) {
$(".button-enchant-countdown").attr("value","Countdown 1");
}
else {
$(".button-enchant-countdown").attr("disabled","disabled");
$(".enchant-sword-countdown").html("Countdown 1 is the highest level of countdown enchantment");
}
if(enchant_defense==10) { $(".button-enchant-defense").attr("disabled","disabled"); }
if(enchant_life==10) {
$(".button-enchant-life").attr("disabled","disabled");
$(".enchant-sword-life").html("Life 10 is the highest level of life enchantment");
}
if(airplanecountdown==0) {
if(typeof flyingabcd !== 'undefined') {
clearInterval(flyingabcd);
}
reachedclouds=true;
}
if(airplanecountdown<0) {
airplanecountdown=0;
}
if(digcountdown==0) {
clearInterval(digabcd);
dig(false);
digcountdown=999999999;
}
if(digcountdown<0) {
digcountdown=0;
}
if(helmet==0) {
$(".button-buy-helmet").val("Buy a leather helmet");
}
else if(helmet==1) {
$(".button-buy-helmet").val("Buy a chain helmet");
}
else if(helmet==2) {
$(".button-buy-helmet").val("Buy an iron helmet");
}
else if(helmet==3) {
$(".button-buy-helmet").val("Buy a diamond helmet");
}
else {
$(".helmet-area").html("Sorry, I have no better helmet for you");
}
if(chestplate==0) {
$(".button-buy-chestplate").val("Buy a leather chestplate");
}
else if(chestplate==2) {
$(".button-buy-chestplate").val("Buy a chain chestplate");
}
else if(chestplate==4) {
$(".button-buy-chestplate").val("Buy an iron chestplate");
}
else if(chestplate==6) {
$(".button-buy-chestplate").val("Buy a diamond chestplate");
}
else {
$(".chestplate-area").html("Sorry, I have no better chestplate for you");
}
if(pants==0) {
$(".button-buy-pants").val("Buy leather pants");
}
else if(pants==1.5) {
$(".button-buy-pants").val("Buy chain pants");
}
else if(pants==3) {
$(".button-buy-pants").val("Buy iron pants");
}
else if(pants==4.5) {
$(".button-buy-pants").val("Buy diamond pants");
}
else {
$(".pants-area").html("Sorry, I have no better pants for you");
}
if(boots==0) {
$(".button-buy-boots").val("Buy leather boots");
}
else if(boots==0.5) {
$(".button-buy-boots").val("Buy chain boots");
}
else if(boots==1) {
$(".button-buy-boots").val("Buy iron boots");
}
else if(boots==1.5 ) {
$(".button-buy-boots").val("Buy diamond boots");
}
else {
$(".boots-area").html("Sorry, I have no better boots for you");
}
$(".buy-helmet-price").html((helmet*helmet)*1000+1000);
$(".buy-chestplate-price").html((chestplate*chestplate)*1000+1000);
$(".buy-pants-price").html((pants*pants)*1000+1000);
$(".buy-boots-price").html((boots*boots)*1000+1000);
$(".absorb-percent").html(helmet+chestplate+pants+boots);
$(".current-cookie").html(items[19].owned);
$(".cps").html(cursor/10);
$(".cursor-button").val("Cursor ["+cursor+"]");
$(".cursor-price").html(15*Math.pow(1.15,cursor));
$(".airplanecd").html(airplanecountdown);
$(".digcd").html(digcountdown);
if(items[2].owned>=1) {
$(".wooden-sword-shop").hide();
$(".stone-sword-shop").show();
}
if(items[4].owned>=1) {
$(".stone-sword-shop").hide();
$(".no-sword-upgrade").show();
}
if(items[5].owned>=1) {
$(".iron-sword-shop").hide();
$(".diamond-sword-shop").show();
}
if(items[6].owned>=1) {
$(".diamond-sword-shop").hide();
$(".need-iron").show();
}
if(pizzaeaten==="poisoned") {
pizzaeaten=true;
}
}
function checkbuilding() {
if(goldbar>=50) {
$(".theshop").removeClass("hidden");
}
if(items[1].owned>=1) {
$(".sign").removeClass("hidden");
}
if(passthief) {
$(".sign").css("cursor","default");
$(".dig-step-1").removeClass("hidden");
$(".anothershop").removeClass("hidden");
$(".gate").removeClass("hidden");
}
if(passworms) {
$(".dig-step-1").css("cursor","default").attr("title","");
$(".dig-step-2").removeClass("hidden");
$(".underworld-building").removeClass("hidden");
}
if(passgate) {
$(".gate").html('\n\
\n\
\n\
\n\
\n\
_ ______\n\
| | |\n\
| | |\n\
| | |\n\
| | |\n\
| | |\n\
|_|______|');
$(".gate").attr("title","Unlocked Gate");
$(".gate").css("cursor","default");
$(".enchant").removeClass("hidden");
$(".hill").removeClass("hidden");
$(".chest").removeClass("hidden");
$(".castle").removeClass("hidden");
}
if(items[8].owned==1&&items[9].owned==14 || hasportal) {
$(".laboratory").removeClass("hidden");
$(".portal").removeClass("hidden");
$(".airplane").removeClass("hidden");
items[9].owned=0;
hasportal=true;
}
if(reachedclouds) {
planeascii='.--. _ ,---. ___\n\
\\# `----------"---=<_)_)_>-.\n\
`,_/________.-----,_____,.-`\n\
o\' `-===\' `o, ';
$("#wrapper").css("top","500px");
$(".banner-plane").addClass("reachedclouds");
$(".cloud-4").removeClass("hidden");
$(".airplane").html(planeascii);
$(".airplane").css({"top":"-450px", "left":"1100px", "cursor":"default"});
}
if(items[24].owned==1) {
$(".sand").removeClass("hidden");
}
if(gethole) {
$(".hole").removeClass("hidden");
}
}
function updatestatus() {
if(items[3].owned!=1){plural=items[3].plural;}else{plural="";}
$(".pizzacount").html(items[3].owned+" pizza"+plural);
$(".currentsword").html(currentsword);
}
function checkitem() {
for(i=0;i<items.length;i++) {
thisitem=items[i];
itemnamenospace=thisitem.name.replace(" ","-");
if(goldbar>=thisitem.price) {
$(".buy-"+itemnamenospace).removeAttr("disabled");
}
else {
$(".buy-"+itemnamenospace).attr("disabled","disabled");
}
}
if(goldbar < 400) { $(".buy-pizza-20").attr("disabled","disabled"); } else { $(".buy-pizza-20").removeAttr("disabled"); }
if(goldbar < 100) { $(".buy-iron-bar").attr("disabled","disabled"); } else { $(".buy-iron-bar").removeAttr("disabled"); }
if(goldbar < 20) { $(".training-button").attr("disabled","disabled"); }else { $(".training-button").removeAttr("disabled"); }
if(ironbar < ironprice) { $(".buy-1-mining").attr("disabled","disabled"); } else { $(".buy-1-mining").removeAttr("disabled"); }
if(ironbar < (ironprice*10)) { $(".buy-10-mining").attr("disabled","disabled"); } else { $(".buy-10-mining").removeAttr("disabled"); }
if(ironbar < (ironprice*100)) { $(".buy-100-mining").attr("disabled","disabled"); } else { $(".buy-100-mining").removeAttr("disabled"); }
if(goldbar < (skilllvl+1)) { $(".upgrade-price").attr("disabled","disabled"); } else { $(".upgrade-price").removeAttr("disabled"); }
if(goldbar < 5000) { $(".buy-factory-button").attr("disabled","disabled"); } else { $(".buy-factory-button").removeAttr("disabled"); }
if(ironbar < goldprice) { $(".buy-1-mining-gold").attr("disabled","disabled"); } else { $(".buy-1-mining").removeAttr("disabled"); }
if(ironbar < goldprice*10) { $(".buy-10-mining-gold").attr("disabled","disabled"); } else { $(".buy-10-mining").removeAttr("disabled"); }
if(ironbar < goldprice*100) { $(".buy-100-mining-gold").attr("disabled","disabled"); } else { $(".buy-100-mining").removeAttr("disabled"); }
}
function buy(item,number) {
for(i=0;i<items.length;i++) {
thisitem=items[i];
if(item==thisitem.name) {
if(goldbar>=thisitem.price*number) {
valid=true;
if(i==2) {
currentsword="Wooden Sword";
$(".wooden-sword-shop").hide();
$(".stone-sword-shop").show();
}
else if(i==4) {
if(items[2].owned!=0) {
currentsword="Stone Sword";
$(".stone-sword-shop").hide();
$(".no-sword-upgrade").show();
}
else {
valid=false;
}
}
else if(i==5) {
if(items[4].owned!=0) {
currentsword="Iron Sword";
$(".iron-sword-shop").hide();
$(".diamond-sword-shop").show();
}
else {
alert('I need a sword stone too! Maybe this iron sword is too expensive for you, but it\'s useful!');
valid=false;
}
}
else if(i==6) {
if(items[5].owned!=0) {
currentsword="Diamond Sword";
$(".diamond-sword-shop").hide();
$(".need-iron").show();
}
else {
valid=false;
}
}
if(valid) {
goldbar-=thisitem.price*number;
thisitem.owned+=number;
checkthings();
}
}
break;
}
}
}
function buyminingmachine(amount) {
theprice=ironprice*amount;
if(ironbar>=theprice) {
ironbar-=theprice;
ironmining+=amount;
checkthings();
clearInterval(a);
a=setInterval(function() {
ironbar+=ibpt;
checkthings();
},ibtime*1000);
}
}
function buyminingmachinegold(amount) {
theprice=goldprice*amount;
if(ironbar>=theprice) {
ironbar-=theprice;
goldmining+=amount;
checkthings();
}
}
function enchantsword(type) {
if(type=="attack") {
price=enchant_attack*enchant_attack*2000+2000;
if(goldbar>=price) {
goldbar-=price;
enchant_attack++;
checkthings();
}
}
else if(type=="defense") {
if(enchant_defense<10) {
price=enchant_defense*enchant_defense*2500+2500;
if(goldbar>=price) {
goldbar-=price;
enchant_defense++;
checkthings();
}
}
}
else if(type=="countdown") {
if(enchant_countdown==0) {
price=enchant_countdown*enchant_countdown*5000+5000;
if(goldbar>=price) {
goldbar-=price;
enchant_countdown++;
checkthings();
}
}
}
else if(type=="life") {
if(enchant_life<10) {
price=enchant_life*enchant_life*2500+2500;
if(goldbar>=price) {
goldbar-=price;
enchant_life++;
checkthings();
}
}
}
}
$(document).ready(function() {
setTimeout(() => $('.bubble').fadeOut(), 5000);
$('.leversion').html("1.3");
//closemessage();
//makealert("beta-notice","Beta version notice","As you can see on the left bottom corner of the page, this game is still in beta version (although it is beta but the game is finished)<br><br>So, please let me know if there are some bugs or not working features via <a href=\"http://reddit.com/r/thegoldfactory\">reddit</a> (especially for the saving feature)<br><br>Plus, when i'm typing this, I haven't completed the game without cheating ;) So, the game may be impossible to win. Please let me know if the game is really impossible to win<br><br>Enjoy the game! :D",true);
goldbar=0; //0
ironbar=0; //0
gbps=1;
goldmining=30;
ibpt=0;
ibtime=3600;
ironmining=0;
items=[];
items.push({"name":"torch","price":10,"owned":0,"plural":"es","showstorage":true}); //0
items.push({"name":"shovel","price":50,"owned":0,"plural":"s","showstorage":true}); //1
items.push({"name":"wooden sword","price":150,"owned":0,"plural":"s","showstorage":false}); //2
items.push({"name":"pizza","price":20,"owned":0,"plural":"s","showstorage":false}); //3
items.push({"name":"stone sword","price":500,"owned":0,"plural":"s","showstorage":false}); //4
items.push({"name":"iron sword","price":1500,"owned":0,"plural":"s","showstorage":false}); //5
items.push({"name":"diamond sword","price":4000,"owned":0,"plural":"s","showstorage":false}); //6
items.push({"name":"health potion","price":50,"owned":0,"plural":"s","showstorage":true}); //7
items.push({"name":"ancient scroll","price":0,"owned":0,"plural":"s","showstorage":true}); //8
items.push({"name":"nether stone","price":0,"owned":0,"plural":"s","showstorage":true}); //9
items.push({"name":"lava bucket","price":0,"owned":0,"plural":"s","showstorage":true}); //10
items.push({"name":"empty potion","price":0,"owned":0,"plural":"s","showstorage":true}); //11
items.push({"name":"poison potion","price":0,"owned":0,"plural":"s","showstorage":true}); //12
items.push({"name":"confusion potion","price":0,"owned":0,"plural":"s","showstorage":true}); //13
items.push({"name":"invisibility potion","price":0,"owned":0,"plural":"s","showstorage":true});
items.push({"name":"instant countdown potion","price":0,"owned":0,"plural":"s","showstorage":true});
items.push({"name":"suicide potion","price":0,"owned":0,"plural":"s","showstorage":true}); //16
items.push({"name":"cookie potion","price":0,"owned":0,"plural":"s","showstorage":true}); //17
items.push({"name":"X potion","price":0,"owned":0,"plural":"s","showstorage":true}); //18
items.push({"name":"cookie","price":0,"owned":0,"plural":"s","showstorage":true}); //19
items.push({"name":"secret potion","price":0,"owned":0,"plural":"s","showstorage":true}); //20
items.push({"name":"key","price":0,"owned":0,"plural":"s","showstorage":true}); //21
items.push({"name":"emerald sword","price":0,"owned":0,"plural":"s","showstorage":false}); //22
items.push({"name":"music disc","price":0,"owned":0,"plural":"s","showstorage":true}); //23
items.push({"name":"glasses","price":0,"owned":0,"plural":"s","showstorage":false}); //24
swords=[];
swords.push({"name":"wooden sword","power":6});
swords.push({"name":"stone sword","power":11});
swords.push({"name":"iron sword","power":15});
swords.push({"name":"diamond sword","power":22});
swords.push({"name":"emerald sword","power":30});
enchant_attack=0; //0
enchant_defense=0; //deprecated :o
enchant_countdown=0; //0
enchant_life=0; //0
helmet=0;
chestplate=0;
pants=0;
boots=0;
theusername="You";
theuserdesc="This is you.";
cipherstep=0;
cheststep=0;
searchtimes=0;
shovelbroken=0;
cursor=0;
pizzaeaten=false;
poisoned=false;
chestunderground=false;
talk=0;
wob=false;
buyfactory=false; //false
skill="none"; //"none"
skilllvl=0; //0
additionalattack=0;
clickcloudcount=0;
openchestcount=0;
candybox=false;
hpactive=0;
airplanecountdown=999999999; //999999999
digcountdown=999999999;
digstep=0;
currentsword="none"; //"none"
passthief=false; //false
passworms=false; //false
passgate=false; //false
unlockenchant=false; //false
unlockchest=false; //false
beatboss=false; //false
hasairplane=false; //false
reachedclouds=false; //false
defeatinvisiblebot=false; //false
gethole=false;
win=false;
hasportal=false;
activatemachine=false;
autosave=true;
autosavetime=30;
if(localStorage.thegoldfactorygamesave) {
dosave('loadlocalstorage');
}
setInterval(function() {
if(autosave) {
autosavetime--;
$("#autosavetime").html(autosavetime);
if(autosavetime==0) {
autosavetime=30;
dosave('autolocalstorage');
}
}
},1000);
asdasdf=digstep;
digstep=0;
for(i=0;i<asdasdf;i++) {
dig(false,true);
}
if(airplanecountdown<=30) {
flyingabcd=setInterval(function(){airplanecountdown--;},60000);
}
if(digcountdown<=30) {
digabcd=setInterval(function(){digcountdown--;},60000);
}
$("#gold-factory").click(function() {
if(!passgate&&!buyfactory) {
closemessage();
makealert("gold-factory","The Gold Factory","Status: You work here, and you get 1 gold bar per second as the salary<br><br><input type=\"button\" value=\"Make the boss happier\" onclick=\"makebosshappy()\"> and receive bonus!",true)
}
else if(passgate&&!buyfactory) {
closemessage();
makealert("buy-factory","The Gold Factory","Status: You work here, and you get 1 gold bar per second as the salary<br><br><input type=\"button\" value=\"Make the boss happier\" onclick=\"makebosshappy()\">and receive bonus!<br><input type=\"button\" value=\"Buy this factory\" onclick=\"buythefactory()\" class=\"buy-factory-button\"> for 5000 goldbars and get more goldbars each second!",true)
}
else if(passgate&&buyfactory) {
closemessage();
makealert("buy-factory-new","The Gold Factory","Status: You are the boss! :o<br><br>Currently you have <span class=\"gold-mining\">"+goldmining+"</span> mining machines<br>Production: <span class=\"gbps\">"+gbps+"</span> goldbars / second<br><br><input type=\"button\" value=\"Buy 1 mining machine\" onclick=\"buyminingmachinegold(1)\" class=\"buy-1-mining-gold\"> (<span class=\"1-gold-cost\">"+goldprice+"</span> Iron Bars)<br><input type=\"button\" value=\"Buy 10 mining machines\" onclick=\"buyminingmachinegold(10)\" class=\"buy-10-mining-gold\"> (<span class=\"10-gold-cost\">"+goldprice*10+"</span> Iron Bars)<br><input type=\"button\" value=\"Buy 100 mining machines\" onclick=\"buyminingmachinegold(100)\" class=\"buy-100-mining-gold\"> (<span class=\"100-gold-cost\">"+goldprice*100+"</span> Iron Bars)<br><br>Tips: Buying 100 machines once is cheaper than buying 1 machine 100 times",true)
}
});
$(".theshop").click(function() {
closemessage();
$(".alert-theshop").fadeIn("fast");
$(".modal").fadeIn("fast");
});
$(".anothershop").click(function() {
closemessage();
$(".alert-anothershop").fadeIn("fast");
$(".modal").fadeIn("fast");
});
$(".sign").click(function() {
if(!passthief) {
closemessage();
$(".alert-sign").fadeIn("fast");
$(".modal").fadeIn("fast");
}
});
$(".dig-step-1").click(function() {
if(passthief && !passworms) {
closemessage();
$(".alert-dig-step-1").fadeIn("fast");
$(".modal").fadeIn("fast");
}
});
$(".training-center").click(function() {
if(passworms) {
closemessage();
if(skill!="none") {
makealert("training-center","Training Center","Welcome to the training center!<br>Here you can test your skills or study a new power<br><br><input type=\"button\" value=\"Test my skill\" onclick=\"testskill()\" class=\"training-button\"> (20 Gold Bars)<br><input type=\"button\" value=\"Upgrade my skill\" onclick=\"upgradeskill()\" class=\"upgrade-skill\">",true)
}
else {
makealert("training-center","Training Center","Welcome to the training center!<br>Here you can test your skills or study a new power<br><br><input type=\"button\" value=\"Test my skill\" onclick=\"testskill()\" class=\"training-button\"> (20 Gold Bars)<br><input type=\"button\" value=\"Learn a new skill\" onclick=\"learnnewskill()\" class=\"new-skill\">",true)
}
}
});
$(".mining").click(function() {
if(passworms) {
closemessage();
irontime=second2name(ibtime);
makealert("mining","Iron Mine","Iron mine allows you to get some iron bar(s) each hour / min / sec<br><br>Currently you have <span class=\"iron-mining-amount\">"+ironmining+"</span> mining machine(s)<br>Production: <span class=\"ibpt\">"+ibpt+"</span> iron bar(s) / <span class=\"irontime\">"+irontime+"</span><br><br><input type=\"button\" value=\"Buy 1 mining machine\" onclick=\"buyminingmachine(1)\" class=\"buy-1-mining\"> (<span class=\"1-iron-cost\">"+ironprice+"</span> Iron Bars)<br><input type=\"button\" value=\"Buy 10 mining machines\" onclick=\"buyminingmachine(10)\" class=\"buy-10-mining\"> (<span class=\"10-iron-cost\">"+ironprice*10+"</span> Iron Bars)<br><input type=\"button\" value=\"Buy 100 mining machines\" onclick=\"buyminingmachine(100)\" class=\"buy-100-mining\"> (<span class=\"100-iron-cost\">"+ironprice*100+"</span> Iron Bars)<br><br>Tips: Buying 100 machines once is cheaper than buying 1 machine 100 times",true)
}
});
$(".gate").click(function() {
if(passthief&&!passgate) {
closemessage();
makealert("locked-gate","Locked Gate","This gate is locked, you need to make a key to unlock it.<br><br><input type=\"button\" value=\"Make a key and unlock the gate\" onclick=\"makekey()\" class=\"make-key\"> (100 Iron Bars) (the key is complex :d)",true)
}
});
$(".enchant").click(function() {
if(passgate&&!unlockenchant) {
closemessage();
powerhp();
battle=makebattle(Math.round(Math.random()*100),"Monster",150,150,"Spatula??",15,"A monster",3,power,hp,hp,currentsword,false,"vs-monster");
html="<div class=\"alert alert-battle-monster\"><b>Monster!</b><br>There is a dangerous monster in the enchanting shop!<br><br>"+battle.html+"</div>";
$("#otheralerts").append(html);
battle.init();
closemessage();
$(".alert-battle-monster").fadeIn("fast");
}
else if(passgate&&unlockenchant) {
if(items[6].owned==0 && items[22].owned==0) {
closemessage();
makealert("enchant-shop","Enchanting Shop","You can only enchant diamond and emerald sword, sorry :(",true)
}
else {
closemessage();
makealert("enchant-shop","Enchanting Shop","Welcome to the enchanting shop! Here you can enchant your sword<br><br><span class=\"enchants\"></span><br><br><div class='enchant-sword-attack'>Enchant with <input type=\"button\" value=\"Attack 1\" onclick=\"enchantsword('attack')\" class=\"button-enchant-attack\"> (<span class=\"enchant-attack-price\"></span> gold bars)</div><!--br>Enchant with <input type=\"button\" value=\"Defense 1\" onclick=\"enchantsword('defense')\" class=\"button-enchant-defense\"> (<span class=\"enchant-defense-price\"></span> gold bars)--><div class='enchant-sword-countdown'>Enchant with <input type=\"button\" value=\"Countdown 1\" onclick=\"enchantsword('countdown')\" class=\"button-enchant-countdown\"> (<span class=\"enchant-countdown-price\"></span> gold bars)</div><div class='enchant-sword-life'>Enchant with <input type=\"button\" value=\"Life 1\" onclick=\"enchantsword('life')\" class=\"button-enchant-life\"> (<span class=\"enchant-life-price\"></span> gold bars)</div><br><br>Or, <input type=\"button\" value=\"visit the armor section\" onclick=\"armorshop()\" class=\"button-armor-shop\"> of the shop",true)
checkthings();
}
}
});
$(".chest").click(function() {
if(passgate&&!unlockchest) {
closemessage();
powerhp();
battle=makebattle(Math.round(Math.random()*100),"Ghost",400,400,"Invisible hands",27,"This ghost is gurading the chest",4,power,hp,hp,currentsword,false,"vs-ghost");
html="<div class=\"alert alert-battle-ghost\"><b>Ghost</b><br>The chest is guarded by a ghost<br><br>"+battle.html+"</div>";
$("#otheralerts").append(html);
battle.init();
closemessage();
$(".alert-battle-ghost").fadeIn("fast");
}
else if(passgate&&unlockchest) {
openchestcount++;
closemessage();
if(openchestcount==1) {
message="The chest is empty now";
}
else if(openchestcount==2) {
message="The chest is empty now, told ya before";
}
else if(openchestcount==3) {
message="THE CHEST IS EMPTY!!!!!";
}
else if(openchestcount==4) {
message="PLS BELIEVE ME!!!";
}
else if(openchestcount==5) {
message="I've told you";
}
else if(openchestcount==6) {
message="Now I hate you";
}
else if(openchestcount==7) {
message="Oh, no, sorry, the chest is not empty, there are 1000 gold bars hidden inside the chest :D";
goldbar+=1000;
}
else if(openchestcount>=8) {
message="The chest is empty now (really)";
}
$(".alert-chest-empty").remove();
makealert("chest-empty","Empty",message,true)
}
});
$(".castle").click(function() {
if(passgate) {
entercastle();
}
/*
For future update, I guess:
if(passgate && !beatboss) {
entercastle();
}
else if(passgate && beatboss) {
makealert("castle","Castle","You are at the castle entrance<br><br><div class=\"castle-steps\"><span class=\"castle-entrance\">Castle Entrance</span> <span class=\"castle-hall grey\">Castle Hall</span> <span class=\"castle-room grey\">King's Room</span></div><br><br>",true);
}
*/
});
$(".laboratory").click(function() {
if(passgate) {
makealert("laboratory","Laboratory","<div style='max-height:300px; overflow-y:auto;'><del title=\"No, i'm not CrazyRussianHacker\">What's up everybody, welcome back to my laboratory, safety is number 1 priority</del><br>In this laboratory, you can make potions from resources you have (<a href='potions.html' target='_blank'>Potions guide</a>)<br><br><input type=\"button\" value=\"Put\" onclick=\"putitem()\"> <input type='text' id='quantity' placeholder='0' size='1'> <select id='itemlist'></select><br>Item(s) going to be mixed:<br><div id='goingtobemixed'></div><br><input type=\"button\" value=\"Mix!\" onclick=\"mixitems()\"></div>",true);
/*
For future update, I guess
makealert("laboratory","Laboratory","<div style='max-height:300px; overflow-y:auto;'><del title=\"No, i'm not CrazyRussianHacker\">What's up everybody, welcome back to my laboratory, safety is number 1 priority</del><br>In this laboratory, you can make potions and items from resources you have (<a href='lab.html' target='_blank'>Laboratory guide</a>)<br><br><input type=\"button\" value=\"Put\" onclick=\"putitem()\"> <input type='text' id='quantity' placeholder='0' size='1'> <select id='itemlist'></select><br>Item(s) going to be mixed:<br><div id='goingtobemixed'></div><br><input type=\"button\" value=\"Mix!\" onclick=\"mixitems()\"></div>",true);
*/
thecauldron("make",0,0);
updateitemlist();
}
});
$(".portal").click(function() {
if(passgate) {
enterportal(1,"a");
}
});
$(".airplane").click(function() {
if(reachedclouds) {
}
else if(passgate&&!hasairplane) {
makealert("buy-airplane","Airplane","This airplane is for sale, you can buy it<br><br><input type=\"button\" value=\"Buy\" onclick=\"buyairplane()\"> the airplane (5,000,000 iron bars)",true);
}
else if(passgate&&hasairplane&&airplanecountdown==999999999) {
makealert("fly","Fly!!!","Are you ready to fly?<br><br><input type=\"button\" value=\"Fly now!!!\" onclick=\"fly()\">",true);
}
else if(passgate&&hasairplane&&airplanecountdown<=30) {
makealert("fly-countdown","Fly!!!","Your plane is currently flying<br>Time left: <span class='airplanecd'>"+airplanecountdown+" </span> minute(s) left",true);
}
});
$(".cloud-4").click(function() {
man="\n\
\n\
O\n\
/|\\\n\
|\n\
/ \\";
if(items[20].owned>0) {
givesecretpotion="<input type=\"button\" value=\"Give him a secret potion\" onclick=\"theman('givesecretpotion');\" class='give-secret-potion'>";
}
else {
givesecretpotion="";
}
makealert("castle-clouds","The castle","You enter the castle and see a man standing inside the castle<br><br><pre class='theman'>"+man+"</pre><br><br><input type=\"button\" value=\"Talk to him\" onclick=\"theman('talk');\" class='talk-with-dude'><input type=\"button\" value=\"Fight with him\" onclick=\"theman('fight');\" class='fight-with-dude'>"+givesecretpotion,true);
});
$(".small-hole").click(function() {
if(digcountdown<=30) {
dig(true,false);
}
else {
if(digstep<5) {
makealert("small-hole","A small hole","It seems that you can dig here<br><br><input type=\"button\" value=\"Dig the hole!\" onclick=\"dig(true,false)\"> (Make sure you have a shovel!)",true);
}
}
});
$(".nametag").click(function() {
makealert("name-tag","Name tag","You found a name tag!<br>You can change your name and description in battles<br><br>Name: <input type='text' id='yourname' value='"+theusername+"'><br>Description: <input type='text' id='yourdesc' value='"+theuserdesc+"'><br><br>Warning: Putting very long name / description or putting some wild characters may mess up the game",true);
namedesc=setInterval(function() {
theusername=$("#yourname").val();
theuserdesc=$("#yourdesc").val();
},100);
});
$(".chest-dig").click(function() {
if(!chestunderground) {
chestascii='\n\
__________\n\
/\\____;;___\\\n\
| / /\n\
`. ())oo() .\n\
|\\(%()*^^()^\\\n\
%| |-%-------|\n\
% \\ | % )) |\n\
% \\|%________|\n\
%%%%';
makealert("chest-underground","Chest","You found a chest, the chest contains some resources and items!<br><br><pre>"+chestascii+"</pre>",true);
goldbar+=5000;
ironbar+=5000;
items[7].owned+=5;
chestunderground=true;
checkthings();
}
else {
makealert("chest-underground","Chest","The chest is empty, 100% sure",true);
}
});
$(".pizzas").click(function() {
if(!pizzaeaten) {
makealert("pizza-alert","Pizzas?","You found some pizzas, you don't know they are rotten or not<br>Do you want to eat them?<br><br><input type='button' value='Eat the pizzas' onclick='eatpizza()'>",true);
}
else if(pizzaeaten) {
if(!poisoned) {
makealert("pizza-alert","Pizzas","There are some leftovers, and you decided not to eat them",true);
}
else {
makealert("pizzas-rotten","Nom.. nom..","You eat the pizzas, but... they are rotten!<br>You are poisoned, this causes you to die easily in battles even if you have a lot of hp<br><br>Luckily you can heal yourself by drinking 10 health potions<br><br><input type=\"button\" value=\"Drink 10 health potions\" onclick=\"healme()\">",true);
}
}
});
$(".laptop").click(function() {
makealert("cookieclicker","Cookie Clicker (not full version)","Play the full game here: <a href='http://orteil.dashnet.org/cookieclicker/' target='_blank'>http://orteil.dashnet.org/cookieclicker/</a><br><br><span style='font-size:20px;'><span class='current-cookie'>"+items[19].owned+"</span> cookie(s)</span><br><span class='cps'>"+cursor/10+" </span> per second<br><br><input type=\"button\" value=\"Bake a cookie\" onclick=\"cookieclicker('bake')\"><br><br><span style='font-size:20px;'>Shop:</span><br><br><input type=\"button\" value=\"Cursor ["+cursor+"]\" onclick=\"alert('This is not the full version of Cookie Clicker, therefore you cant buy cursors')\" class='cursor-button'> (<span class='cursor-price'>"+Math.round(15*Math.pow(1.15,cursor))+"</span> cookies)<br><!--input type=\"button\" value=\"Grandma [0]\" onclick=\"alert('This is not the full version of Cookie Clicker')\"> (100 cookies)00-->",true);
/*
Actually I want to allow you guys to buy cursors,
But when I implement it, i got some decimal digit issues like 99985.2000000000002 cookies
ALso cursors' price can't be rounded using Math.round() dunno why, lol
*/
});
$(".sign-dig").click(function() {
makealert("sign-underground-alert","A sign","\"Nothing more to dig, this is the end. But maybe there will be updates in the future\"",true);
});
$(".theportal").click(function() {
exitmagicportal();
});
$(".thefox").click(function() {
closemessage();
powerhp();
battle=makebattle(Math.round(Math.random()*100),"The Fox",2000,2000,"Unknown",1,"A fox!",10,power,hp,hp,currentsword,false,"vs-fox");
html="<div class=\"alert alert-battle-fox\"><b>The Fox</b><br>You choose to kill the fox<br><br>"+battle.html+"<br><br><input type=\"button\" value=\"Or stop attacking the innocent fox\" onclick=\"myhealthpoint(true,0); closemessage();\"></div>";
$("#otheralerts").append(html);
battle.init();
$(".alert-battle-fox").fadeIn("fast");
});
$(".thehouse").click(function() {
computer=" _________________\n\
| |\n\
| <span class=\"click\" onclick=\"computeraction('disc')\">___________</span> |\n\
| <span class=\"click\" onclick=\"computeraction('disc')\">| ..... |</span> |\n\
______________________________________ | <span class=\"click\" onclick=\"computeraction('disc')\">|___________|</span> |\n\
| __________________________________ | | ___________ |\n\
| | | | | | ..... | |\n\
| | | | | |___________| |\n\
| | | | | <span class=\"click\" onclick=\"computeraction('error')\">__</span> __ _ |\n\
| | | | | <span class=\"click\" onclick=\"computeraction('error')\">|__|</span> |__| |_| |\n\
| | | | | |\n\
| | | | | |\n\
| | | | | |\n\
| | | | | |\n\
| | | | | <span class=\"click\" onclick=\"computeraction('power')\">.|.</span> |\n\
| | | | | <span class=\"click\" onclick=\"computeraction('power')\">( )</span> |\n\
| | | | | <span class=\"click\" onclick=\"computeraction('power')\">'-'</span> |\n\
| |__________________________________| | | |\n\
|______________________________________| | |\n\
| | '. | |\n\
| | '-.-'-.-'-.-| |\n\
) ( | |\n\
/ \\ | |\n\
/________\\ |_________________|";
makealert("the-house-enter","The house","<div style='max-height:300px; width:538px; overflow-y:auto;'>You entered the house, and you see a computer in front of you<br><br><pre class='computer-ascii'>"+computer+"</pre><div class='ylvis-the-fox'></div></div>",true);
});
$(".sand").click(function() {
makealert("sand","Sand","There are tons of sand here, you don't know who put it there and what is buried there.<br><br><input type='button' value='Search for something!' onclick='searchsand()'> <span class='search-result'></span><br><input type='button' value='Bury yourself inside the sand!' onclick='burysand()'>",true);
});
$(".boss").click(function() {
if(!win) {
story="\n\
\n\
_\n\
.•' '•. \"Who is standing there? O\n\
/ \\ Hmmmm..... That's weird :/\" /|\\\n\
| | |\n\
| | / \\\n\
\\ / <input type='button' value='Next >' onclick='guy(1)'> \n\
'•. .•'\n\
/ \\\n\
/ | | \\\n\
/ /| |\\ \\\n\
/ / | | \\ \\\n\
";
makealert("boss-conversation","Someone","Someone is standing there<br><br><pre class='boss-story'>"+story+"</pre>",true);
}
else {
makealert("chest-from-boss","Chest","<br><input type='button' onclick='openthechestfromsomeone()' value='Interact with chest'>",true);
}
});
$(".old-machine").click(function() {
if(activatemachine) {
makealert("old-machine","An old machine","The machine a hole and a text 'Insert some gold bars here', you don't really know what this machine does, but maybe it will be useful<br><br><input type='button' value='Put 10 gold bars inside the machine' onclick='givemachinegoldbar(10)'><br><input type='button' value='Put 100 gold bars inside the machine' onclick='givemachinegoldbar(100)'><br><input type='button' value='Put 1000 gold bars inside the machine' onclick='givemachinegoldbar(1000)'><br><input type='button' value='Put 10000 gold bars inside the machine' onclick='givemachinegoldbar(10000)'><br><input type='button' value='Put 100000 gold bars inside the machine' onclick='givemachinegoldbar(100000)'><br>",true);
}
else {
makealert("old-machine","An old machine","This old machine seems to need some fuel to work, maybe a lava bucket can be the fuel.<br><br><input type='button' value='Pour a bucket of lava to the machine' onclick='givelavabuckettothemachine()'>",true);
}
});
a=setInterval(function() {
ironbar+=ibpt;
checkthings();
},ibtime*1000);
checkthings();
setInterval(function() {
goldbar+=gbps;
checkthings();
},1000);
});
function checkthings() {
updategold();
checkbuilding();
updateitems();
checkitem();
updatestatus();
if(wob) {
$('body').addClass("wob");
}
else {
$('body').removeClass("wob");
}
}
function makealert(id,title,text,show) {
$(".alert-"+id).remove();
html="<div class=\"alert alert-"+id+"\"><b>"+title+"</b><br>"+text+"<div class=\"close-message-button-"+id+"\"><br><br><input type=\"button\" value=\"Close this window\" onclick=\"closemessage()\" class='button-close-window-"+id+"'></div></div>";
$("#otheralerts").append(html);
if(show) {
closemessage();
$(".alert-"+id).fadeIn("fast");
$(".modal").fadeIn("fast");
}
}
function givemachinegoldbar(howmany) {
if(howmany%10==0) {
if(goldbar>=howmany) {
goldbar-=howmany;
howmany/=10;
ironbar+=howmany;
checkthings();
alert('The machine gives you '+howmany+' iron bar(s)!');
}
else {
alert('Not enough gold bars!');
}
}
}
function givelavabuckettothemachine() {
if(!activatemachine) {
if(items[10].owned>=1) {
items[10].owned-=1;
activatemachine=true;
makealert("lava-success","The machine worked!","You successfully make the machine work!",true);
}
else {
alert('You have no lava bucket!');
}
}
}
function clickcloud() {
clickcloudcount++;
if(clickcloudcount==10) {
goldbar+=100;
makealert("falling-gold","Gold!","100 gold bars are falling from the sky!",true);
checkthings();
}
}
function powerhp() {
for(i=0;i<swords.length;i++) {
thissword=swords[i];
if(currentsword.toLowerCase()==thissword.name) {
power=thissword.power+additionalattack;
break;
}
}
power+=enchant_attack*7;
hp=100;
hp+=Math.floor(items[3].owned/3.5);
thisismyhp=100;