-
Notifications
You must be signed in to change notification settings - Fork 68
/
castle.js
4116 lines (3789 loc) · 138 KB
/
castle.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
'use strict';
/**************************************************************
* Helper Functions
*
* This section contains the non-Molpy functions.
*************************************************************/
function addCSSRule(sheet, selector, rules, index) {
if(sheet.insertRule) {
sheet.insertRule(selector + '{' + rules + '}', index);
}
else {
sheet.addRule(selector, rules, index);
}
}
jQuery.fn.canColorBorder = function() {
return this.each(function() {
var borderColorButton = $("<div class='ui-border-color-button'></div>");
borderColorButton.click(Molpy.CycleBorderClick);
$(this).append(borderColorButton);
});
};
function ONGsnip(time) {
var new_time=dayjs(time.valueOf()-time.minute()*60000-time.second()*1000-time.millisecond())
//had to do it that way to avoid DST weirdness
if(time.minute() >= 30 && Math.abs(Molpy.newpixNumber) <= 240 && Molpy.currentStory == -1) {
new_time=dayjs(new_time.valueOf()+30*60000);
}
return new_time;
}
Molpy.extend = function(obj, args, overwrite){
for(var i in args){
if(!obj[i] || overwrite == true) obj[i] = args[i];
}
}
/**************************************************************
* Molpy Initialization
*************************************************************/
Molpy.Up = function() {
Molpy.molpish = 0;
Molpy.Wake = function() {
Molpy.molpish = 0;
Molpy.HardcodedData();//split some stuff into separate file
/**************************************************************
* Variables
*
* Main variables used for game engine.
*************************************************************/
Molpy.Life = 0; //number of gameticks that have passed
Molpy.fps = 30; //this is just for paint, not updates
Molpy.time = dayjs();
Molpy.newpixNumber = 1; //to track which background to load, and other effects...
Molpy.ONGstart = ONGsnip(dayjs()); //contains the time of the previous ONG
Molpy.NPlength = 1800; //seconds in current NewPix
Molpy.mNPlength = 1800; //milliseconds in milliNewPix
Molpy.updateFactor = 1; //increase to update more often
Molpy.options = [];
Molpy.lateness = 0;
Molpy.ketchupTime = 0;
Molpy.ninjad = 0; //ninja flag for newpixbots
Molpy.npbONG = 0; //activation flag for newpixbots
Molpy.beachClicks = 0; //number of times beach has been clicked for sand
Molpy.ninjaFreeCount = 0; //newpix with no clicks in ninja period (but with clicks later)
Molpy.ninjaStealth = 0; //streak of uninterrupted ninja-free newpix
Molpy.saveCount = 0; //number of times game has been saved
Molpy.loadCount = 0; //number of times gave has been loaded
Molpy.needRebuildLootList = 0; // When loading data, loot lists need rebuilt
Molpy.autosaveCountup = 0;
Molpy.largestNPvisited={0:1}
for(var i=0;i<Molpy.fracParts.length;i++){Molpy.largestNPvisited[Molpy.fracParts[i]]=0}
Molpy.currentStory=-1
Object.defineProperty(Molpy,'highestNPvisited', {
get: function(){
if(Molpy.currentStory>=0){
return Molpy.largestNPvisited[Molpy.fracParts[Molpy.currentStory]]
} else {
return Molpy.largestNPvisited[0]
}
},
set: function(val){
if(Molpy.currentStory>=0){
Molpy.largestNPvisited[Molpy.fracParts[Molpy.currentStory]]=val
} else {
Molpy.largestNPvisited[0]=val
}
}
}); //keep track of where the player has been
Molpy.toolsBuilt = 0;
Molpy.toolsBuiltTotal = 0;
Molpy.totalDiscov = 0;
Molpy.dispObjects = {shop: [], tools: [], boosts: [], badges: [], tagged: [], search: [], faves: []} // Lists of objects currently being displayed
Molpy.mouseIsOver = null;
Molpy.DefinePersist();
Molpy.DefineGUI();
Molpy.Anything = 1;
Molpy.floatEpsilon = 0.0000001; // Because floating point errors
/**************************************************************
* Math
*
* In which the mathematical methods of sandcastles are described
*************************************************************/
Molpy.glassNotifyFactor = 1000000000;
Molpy.GlassNotifyFlush = function() {
Molpy.chipAddAmount = Math.round(Molpy.chipAddAmount);
Molpy.chipWasteAmount = Math.round(Molpy.chipWasteAmount);
Molpy.blockAddAmount = Math.round(Molpy.blockAddAmount);
Molpy.blockWasteAmount = Math.round(Molpy.blockWasteAmount);
if(Molpy.chipAddAmount > 0 && !Molpy.Boosts['AA'].power
&& Molpy.chipAddAmount * Molpy.glassNotifyFactor > Molpy.Boosts['GlassChips'].power)
Molpy.Notify('Gained ' + Molpify(Molpy.chipAddAmount, 3) + ' Glass Chip' + plural(Molpy.chipAddAmount), 0);
if(Molpy.chipAddAmount < 0
&& (-Molpy.chipAddAmount * Molpy.glassNotifyFactor) > Molpy.Boosts['GlassChips'].power)
Molpy.Notify('Consumed ' + Molpify(-Molpy.chipAddAmount, 3) + ' Glass Chip' + plural(-Molpy.chipAddAmount), 0);
Molpy.chipAddAmount = 0;
if(Molpy.chipWasteAmount > 0)
Molpy.Notify('Not enough Chip Storage for ' + Molpify(Molpy.chipWasteAmount) + ' Glass Chip' + plural(Molpy.chipWasteAmount), 1);
Molpy.chipWasteAmount = 0;
if(Molpy.blockAddAmount > 0 && !Molpy.Boosts['AA'].power
&& Molpy.blockAddAmount * Molpy.glassNotifyFactor > Molpy.Boosts['GlassBlocks'].power)
Molpy.Notify('Gained ' + Molpify(Molpy.blockAddAmount, 3) + ' Glass Block' + plural(Molpy.blockAddAmount), 0);
if(Molpy.blockAddAmount < 0
&& (-Molpy.blockAddAmount * Molpy.glassNotifyFactor) > Molpy.Boosts['GlassBlocks'].power)
Molpy.Notify('Consumed ' + Molpify(-Molpy.blockAddAmount, 3) + ' Glass Block' + plural(-Molpy.blockAddAmount), 1);
Molpy.blockAddAmount = 0;
if(Molpy.blockWasteAmount > 0)
Molpy.Notify('Not enough Block Storage for ' + Molpify(Molpy.blockWasteAmount, 3) + ' Glass Block' + plural(Molpy.blockWasteAmount), 1);
Molpy.blockWasteAmount = 0;
};
Molpy.globalSpmNPMult = 1;
Molpy.globalGpmNPMult = 1;
Molpy.lastClick = 0;
Molpy.ClickBeach = function(event, leopard, recursion) {
Molpy.Anything = 1;
Molpy.previewNP = 0;
if(!Molpy.layoutLocked && !leopard) {
Molpy.Notify('You cannnot click here while the layout is unlocked but you can use your leopard',1);
return;
}
Molpy.beachClicks += 1;
Molpy.Boosts['Sand'].clickBeach();
Molpy.Boosts['TF'].clickBeach();
Molpy.Boosts['Mustard'].clickBeach();
Molpy.Boosts['DQ'].clickBeach();
Molpy.Boosts['Blueness'].clickBeach();
Molpy.CheckClickAchievements();
if(Molpy.ninjad == 0 && (!isFinite(Molpy.CastleTools['NewPixBot'].amount) || Molpy.CastleTools['NewPixBot'].amount)) {
if(Molpy.npbONG == 1) {
Molpy.StealthClick();
var saveRitual = false;
if(Molpy.Boosts['Ritual Sacrifice'].IsEnabled && Molpy.Boosts['Ninja Ritual'].power >= 25 && Molpy.Boosts['Ninja Ritual'].power < 101) {
if(Molpy.Spend({Goats: 5})) {
saveRitual = true;
Molpy.Notify('Sacrificed 5 Goats to continue Ninja Ritual');
} else {
Molpy.Notify('You need 5 Goats for Ritual Sacrifice',1);
}
}
if(Molpy.Boosts['Ritual Rift'].IsEnabled && !saveRitual) {
var ritualRiftCost = Math.floor(Molpy.Boosts['Ninja Ritual'].power / 10);
if(Molpy.Spend({FluxCrystals: ritualRiftCost})) {
saveRitual = true;
Molpy.Notify('Warped back in time with ' + Molpify(ritualRiftCost) + ' Flux Crystals to continue Ninja Ritual.');
} else {
Molpy.Notify('Not enough Flux Crystals for Ritual Rift.',1);
}
}
if(!saveRitual){
Molpy.Boosts['Ninja Ritual'].Level = 0;
}
} else if(Molpy.npbONG == 0) {
if(Molpy.NinjaUnstealth()) {
if(Molpy.CastleTools['NewPixBot'].currentActive) {
Molpy.EarnBadge('Ninja');
}
if(Molpy.CastleTools['NewPixBot'].currentActive >= 10) {
Molpy.EarnBadge('Ninja Strike');
}
}
if(Molpy.Got('Ninja Ritual')) {
Molpy.NinjaRitual();
if(Molpy.Boosts['Ninja Ritual'].Level > 10)
Molpy.UnlockBoost('Western Paradox');
if(Molpy.Boosts['Ninja Ritual'].Level > 24)
Molpy.UnlockBoost('Ritual Sacrifice');
if(Molpy.Boosts['Ninja Ritual'].Level > 39 && Molpy.Boosts['Time Lord'].bought > 8)
Molpy.UnlockBoost('Ritual Rift');
}
else if(Molpy.Has('Goats', 10)) Molpy.UnlockBoost('Ninja Ritual');
if(Molpy.CastleTools['NewPixBot'].currentActive >= 1000) {
Molpy.EarnBadge('KiloNinja Strike');
if(Molpy.CastleTools['NewPixBot'].currentActive >= 1e6) {
Molpy.EarnBadge('MegaNinja Strike');
if(Molpy.CastleTools['NewPixBot'].currentActive >= 1e9) {
Molpy.EarnBadge('GigaNinja Strike');
}
}
}
}
} else if(Molpy.Got('VJ')) {
var sawmod = Molpy.Got('Short Saw') ? 20 : 100;
if(Molpy.beachClicks % sawmod == 0) {
Molpy.Notify(Molpy.Boosts['VJ'].name);
Molpy.Boosts['Castles'].build(Molpy.Boosts['VJ'].getReward(1));
Molpy.Boosts['VJ'].power++;
Molpy.Boosts['VJ'].Refresh();
var sawType = 'Plain';
if(Molpy.Got('Swedish Chef')) sawType = 'Swedish Chef';
if(Molpy.Got('Phonesaw')) sawType = 'PhoneSaw';
if(Molpy.Got('Ninjasaw')) sawType = 'Ninjasaw';
if(Molpy.Got('Glass Saw')) {
var p = Molpy.Boosts['Glass Saw'].power;
if(p > 0) {
sawType = 'Glass Saw';
var maxGlass = Molpy.GlassCeilingCount() * 10000000 * p;
var absMaxGlass = maxGlass;
var rate = Molpy.ChipsPerBlock();
maxGlass = Math.min(maxGlass, Math.floor(Molpy.Level('TF') / rate));
var leave = 0;
var bl = Molpy.Boosts['GlassBlocks'];
if(Molpy.Got('Buzz Saw') && Molpy.Boosts['Stretchable Block Storage'].IsEnabled) {
sawType = 'Buzz Saw';
maxGlass = Math.max(maxGlass, 0) || 0;
} else {
if(Molpy.Boosts['AA'].power && Molpy.Boosts['Glass Blower'].IsEnabled) {
leave = Molpy.Boosts['Glass Chiller'].power * (1 + Molpy.Boosts['AC'].power) / 2 * 10; // 10 mnp space
}
maxGlass = Math.min(maxGlass, bl.bought * 50 - bl.power - leave);
maxGlass = Math.max(maxGlass, 0) || 0;
var backoff = 1;
while(bl.power + maxGlass > bl.bought * 50) {
maxGlass -= backoff;
backoff *= 2;
}
}
if(!isFinite(maxGlass)) {
Molpy.EarnBadge('Infinite Saw');
}
if(!isFinite(bl.Level)) Molpy.UnlockBoost('Buzz Saw');
Molpy.Add('GlassBlocks', Math.floor(maxGlass*Molpy.Papal('GlassSaw')), Molpy.Got('Buzz Saw'));
Molpy.Spend('TF', maxGlass * rate);
if(Molpy.Has('TF', absMaxGlass * rate * 10))
Molpy.Boosts['Glass Saw'].power = p * (10 + 5 * Molpy.Got('Buzz Saw'));
else if(Molpy.Has('TF', absMaxGlass * rate * 2))
Molpy.Boosts['Glass Saw'].power = p * (2 + Molpy.Got('Buzz Saw'));
if(maxGlass && p > 1e15 && maxGlass / absMaxGlass < .01) {
Molpy.UnlockBoost(['Buzz Saw', 'Stretchable Block Storage']);
}
} else {
if(!p) Molpy.Boosts['Glass Saw'].power = 1;
}
Molpy.Boosts['Glass Saw'].Refresh();
}
}
}
if(Molpy.Got('Bag Puns') && Molpy.Boosts['VJ'].bought != 1) {
if(Molpy.beachClicks % 20 == 0) {
Molpy.Notify(GLRschoice(Molpy.bp));
if(++Molpy.Boosts['Bag Puns'].power > 100) Molpy.UnlockBoost('VJ');
Molpy.Boosts['Bag Puns'].Refresh();
}
}
if(Molpy.Got('Spare Tools')) {
GLRschoice(Molpy.tfOrder).create(1).Refresh();
}
Molpy.ninjad = 1;
if(Molpy.oldBeachClass != 'beachongwarning') Molpy.UpdateBeachClass('beachsafe');
Molpy.HandleClickNP();
if(Molpy.Got('Temporal Rift') && Molpy.Boosts['Temporal Rift'].countdown < 5 && flandom(2) == 1) {
Molpy.Notify('You accidentally slip through the temporal rift!');
Molpy.RiftJump();
}
Molpy.Donkey();
if(!recursion && Molpy.Got('Doubletap')) Molpy.ClickBeach(event, leopard, 1);
Molpy.Boosts['Sand'].toCastles();
Molpy.mustardCleanup();
};
g('beach').onclick = Molpy.ClickBeach;
Molpy.StealthClick = function() {
Molpy.Anything = 1;
//clicking first time, after newpixbot
Molpy.EarnBadge('No Ninja');
Molpy.ninjaFreeCount++;
var ninjaInc = 1;
if(Molpy.Got('Active Ninja') && Molpy.NPlength > 1800) {
ninjaInc *= 3;
}
if(!Molpy.Boosts['Ninja Lockdown'].IsEnabled) {
if(Molpy.Got('Ninja League')) {
ninjaInc *= 100;
}
if(Molpy.Got('Ninja Legion')) {
ninjaInc *= 1000;
}
if(Molpy.Got('Ninja Ninja Duck')) {
ninjaInc *= 10;
}
ninjaInc *= Molpy.Papal('Ninja');
}
Molpy.ninjaStealth += ninjaInc;
if(Molpy.Got('Ninja Builder')) {
var stealthBuild = Molpy.CalcStealthBuild(1, 1);
Molpy.Boosts['Castles'].build(stealthBuild + 1);
var fn = 'Factory Ninja';
if(Molpy.Got(fn)) {
var runs = Molpy.ActivateFactoryAutomation();
if(runs == 0 && Molpy.Boosts['Sand'].sandPermNP == Infinity) Molpy.EarnBadge('Pure Genius');
!Molpy.Boosts[fn].power--;
if(!Molpy.Boosts[fn].power) Molpy.LockBoost(fn);
}
} else {
Molpy.Boosts['Castles'].build(1); //neat!
}
if(Molpy.ninjaStealth >= 6) {
Molpy.EarnBadge('Ninja Stealth');
Molpy.UnlockBoost('Stealthy Bot');
}
if(Molpy.ninjaStealth >= 16) {
Molpy.EarnBadge('Ninja Dedication');
Molpy.UnlockBoost('Ninja Builder');
}
if(Molpy.ninjaStealth >= 26) {
Molpy.EarnBadge('Ninja Madness');
Molpy.UnlockBoost('Ninja Hope');
}
if(Molpy.ninjaStealth >= 36) {
Molpy.EarnBadge('Ninja Omnipresence');
}
if(Molpy.ninjaStealth > 4000) {
Molpy.EarnBadge('Ninja Pact');
}
if(Molpy.ninjaStealth > 4000000) {
Molpy.EarnBadge('Ninja Unity');
}
if(Molpy.Level('DQ') > 1 && Molpy.ninjaStealth == 13000013) {
Molpy.UnlockBoost('Ventus Vehemens');
}
if(Molpy.Got('Stealth Cam')) Molpy.Shutter();
};
Molpy.CalcStealthBuild = function(vj, spend) {
var stealthBuild = Molpy.ninjaStealth;
if(Molpy.Got('Ninja Assistants')) stealthBuild *= Molpy.CastleTools['NewPixBot'].amount;
if(Molpy.Got('Skull and Crossbones')) {
stealthBuild = Math.floor(stealthBuild * Math.pow(1.05, Math.max(-1, Molpy.SandTools['Flag'].amount - 40)));
}
if(Molpy.Boosts['Glass Jaw'].IsEnabled) {
if(Molpy.Has('GlassBlocks', 1)) {
if(spend) Molpy.Spend('GlassBlocks', 1);
stealthBuild *= 100;
}
}
if(Molpy.Got('Ninja Climber')) {
stealthBuild *= Molpy.SandTools['Ladder'].amount;
if(spend) {
Molpy.RatesRecalculate();
}
}
if(vj && Molpy.Boosts['Ninjasaw'].power && Molpy.Boosts['VJ'].IsEnabled) {
if(Molpy.Has('GlassBlocks', 50)) {
if(spend) Molpy.Spend('GlassBlocks', 50);
stealthBuild *= Molpy.Boosts['VJ'].getReward();
}
}
return stealthBuild;
};
var prevKey = '';
Molpy.KeyDown = function(e) {
// Ignore Shift, Control, Alt
if(e.keyCode >= 0x10 && e.keyCode <= 0x14)
return;
var key;
if(e.keyCode >= 0x60 && e.keyCode <= 0x69) // Numpad
key = String.fromCharCode(e.keyCode - 0x30);
else
key = String.fromCharCode(e.keyCode || e.charCode);
if(key == '5' && prevKey.toLowerCase() == 'f') {
Molpy.ClickBeach(e, 1);
Molpy.EarnBadge('Use Your Leopard');
}
prevKey = key;
};
window.onkeydown = Molpy.KeyDown;
Molpy.NinjaUnstealth = function() {
if(!Molpy.ninjaStealth) return 0; //Nothing to lose!
if(Molpy.Got('Impervious Ninja')) {
var payment = Math.floor(Molpy.Boosts['GlassChips'].power * .01);
if(payment >= 100) {
Molpy.Spend('GlassChips', payment);
Molpy.Notify('Ninja Forgiven', 0);
Molpy.Boosts['Impervious Ninja'].power--;
if(Molpy.Boosts['Impervious Ninja'].power <= 0) {
Molpy.LockBoost('Impervious Ninja');
}
return 0; //Safe
}
}
if(Molpy.Got('Ninja Hope') && Molpy.Boosts['Ninja Hope'].power) {
if(Molpy.Has('Castles', 10)) {
Molpy.Destroy('Castles', 10);
Molpy.Boosts['Ninja Hope'].power--;
Molpy.Notify('Ninja Forgiven', 0);
return 0;
}
}
if(Molpy.Got('Ninja Penance') && Molpy.Boosts['Ninja Penance'].power) {
if(Molpy.Has('Castles', 30)) {
Molpy.Destroy('Castles', 30);
Molpy.Boosts['Ninja Penance'].power--;
Molpy.Notify('Ninja Forgiven', 0);
return 0;
}
}
Molpy.Boosts['Ninja Hope'].power = 1;
Molpy.Boosts['Ninja Penance'].power = 2;
if(Molpy.ninjaStealth) Molpy.Notify('Ninja Unstealthed', 1);
if(Molpy.ninjaStealth >= 7 && Molpy.Got('Ninja Hope')) {
Molpy.UnlockBoost('Ninja Penance');
}
if(Molpy.ninjaStealth >= 30 && Molpy.ninjaStealth < 36) {
Molpy.EarnBadge('Ninja Shortcomings');
}
Molpy.ninjaStealth = 0;
return 1;
};
Molpy.HandleClickNP = function() {
var NP = Molpy.newpixNumber;
if(NP == 404) Molpy.EarnBadge('Badge Not Found');
if(NP == -404) Molpy.EarnBadge('Badge Found');
if(NP == 2101) Molpy.EarnBadge('War was beginning.');
};
/* In which we calculate how much sand per milliNewPix we dig
+++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++*/
Molpy.recalculateRates = 1;
Molpy.RatesRecalculate = function(times) {
Molpy.recalculateRates = Math.max(Molpy.recalculateRates,(times||1))
}
Molpy.calculateRates = function() {
if (Molpy.recalculateRates > 1) Molpy.recalculateRates--;
else Molpy.recalculateRates = 0;
Molpy.CastleTools['NewPixBot'].calculateNinjaTime();
Molpy.Boosts['Sand'].calculateSandRates();
Molpy.Boosts['Castles'].calculateGlobalMult();
Molpy.Boosts['TF'].calculateLoadedPermNP();
Molpy.CalcReportJudgeLevel();
Molpy.shopNeedRepaint = 1;
};
Molpy.CalcReportJudgeLevel = function() {
var judy = Molpy.JudgementDipReport()[0];
if(Molpy.judgeLevel == -1){ //just loaded
if(judy > 0) Molpy.Notify("Judgement Dip Level: " + Molpify(judy - 1, 2), 0);
} else if(judy > Molpy.judgeLevel)//increase
{
if(Molpy.judgeLevel < 2 && judy > 2) { //jumped from safe to multiple levels of judgement
Molpy.Notify('Judgement Dip is upon us!');
Molpy.Notify("Judgement Dip Level: " + Molpify(judy - 1, 2), 0);
} else if(judy > 2) {
Molpy.Notify('Things got worse!!');
Molpy.Notify("Judgement Dip Level: " + Molpify(judy - 1, 2), 0);
} else if(judy == 2) {
Molpy.Notify('Judgement Dip is upon us!', 0);
} else if(judy == 1) {
Molpy.Notify("You sense trouble. The bots are restless.", 0);
}
} else if(judy < Molpy.judgeLevel) { //decrease
if(judy > 1) {
Molpy.Notify('Things got better');
Molpy.Notify("Judgement Dip Level: " + Molpify(judy - 1, 2), 0);
} else if(judy == 1) {
Molpy.Notify("You feel relief but fear lingers.", 0);
} else if(judy == 0) {
if(Molpy.Boosts['NavCode'].IsEnabled) {
Molpy.Notify('Your alterations to the navigation code have saved the day!', 0);
} else {
Molpy.Notify('You feel safe.', 0);
}
}
}
Molpy.judgeLevel = judy;
if(Molpy.judgeLevel) Molpy.EarnBadge('Judgement Dip Warning');
if(Molpy.judgeLevel > 1) Molpy.EarnBadge('Judgement Dip');
};
/**************************************************************
* Boost Shop
*************************************************************/
Molpy.shopNeedRepaint = 1;
Molpy.sandToolPriceFactor = 1.1;
Molpy.SandTools = [];
Molpy.SandToolsById = [];
Molpy.SandToolsN = 0;
Molpy.CastleTools = [];
Molpy.CastleToolsById = [];
Molpy.CastleToolsN = 0;
Molpy.SandToolsOwned = 0;
Molpy.CastleToolsOwned = 0;
Molpy.priceFactor = 1;
Molpy.mustardTools = 0;
Molpy.MustardCheck = function() {
Molpy.mustardTools = 0;
for(var i in Molpy.SandToolsById){
if(isNaN(Molpy.SandToolsById[i].amount)) Molpy.mustardTools ++;
}
for(var i in Molpy.CastleToolsById){
if(isNaN(Molpy.CastleToolsById[i].amount)) Molpy.mustardTools ++;
}
if(Molpy.mustardTools == 12) Molpy.EarnBadge('Mustard Tools');
};
Molpy.SandTool = function(args) {
// Assign all properties passed in
for(var prop in args) {
if(typeof args[prop] !== 'undefined' )
this[prop] = args[prop];
}
this.id = Molpy.SandToolsN;
this.name = args.name;
args.commonName = args.commonName.split('|');
this.single = args.commonName[0];
this.plural = args.commonName[1];
this.actionName = args.commonName[2];
this.desc = args.desc;
this.basePrice = args.price;
this.price = this.basePrice;
this.spmNP = args.spmNP;
this.totalSand = 0;
this.storedSpmNP = 0;
this.storedTotalSpmNP = 0;
this.gpmNP = args.gpmNP;
this.totalGlass = 0;
this.storedGpmNP = 0;
this.storedTotalGpmNP = 0;
this.nextThreshold = args.nextThreshold;
this.pic = args.pic;
this.icon = args.icon || 'generic';
this.background = args.background;
this.buyFunction = args.buyFunction;
this.drawFunction = args.drawFunction;
this.divElement = null;
this.amount = 0;
this.bought = 0;
this.temp = 0;
this.buy = function() {
Molpy.Anything = 1;
if(Molpy.ProtectingPrice()) return;
var times = Math.pow(4, Molpy.options.sandmultibuy);
var bought = 0;
var spent = 0;
this.findPrice();
while(times-- > 0) {
var price = this.price * Molpy.priceFactor;
if(!isFinite(price)) {
Molpy.UnlockBoost('TF');
Molpy.EarnBadge(this.name + ' Shop Failed');
} else if(Molpy.Has('Castles', price)) {
Molpy.Spend('Castles', price, 1);
this.amount++;
this.bought++;
bought++;
spent += price;
this.findPrice();
if(this.buyFunction) this.buyFunction(this);
if(this.drawFunction) this.drawFunction();
Molpy.toolsNeedRepaint = 1;
Molpy.RatesRecalculate();
Molpy.SandToolsOwned++;
Molpy.CheckBuyUnlocks(1);
}
}
if(Molpy.Got('TDE')) {
var tdf = Molpy.TDFactor(1) - 1;
var dups = Math.floor(bought * tdf);
this.amount += dups;
this.temp += dups;
bought += dups;
this.findPrice();
}
if(bought) {
Molpy.Notify('Spent ' + Molpify(spent, 3) + ' Castle' + plural(spent) + ', Bought '
+ Molpify(bought, 3) + ' ' + (bought > 1 ? this.plural : this.single), 0);
}
};
this.create = function(n) {
this.amount += n;
this.bought += n;
Molpy.SandToolsOwned += n;
if(Molpy.Got('Crystal Dragon') && Molpy.Got('TDE')) {
var tdf = Molpy.TDFactor() - 1;
var dups = Math.floor(n * tdf);
this.amount += dups;
this.temp += dups;
Molpy.SandToolsOwned += dups;
}
return this;
};
this.sell = function() {
Molpy.Anything = 1;
if(this.amount > 0) {
this.amount--;
this.findPrice();
if(this.temp > 0) {
this.temp--;
Molpy.Notify('Temporal Duplicate Destroyed!');
} else {
var d = 1;
if(Molpy.Got('Family Discount')) d = .2;
d *= Molpy.Boosts['ASHF'].startPower();
Molpy.Boosts['Castles'].build(Math.floor(this.price * 0.5 * d), 1);
}
if(this.sellFunction) this.sellFunction();
if(this.drawFunction) this.drawFunction();
Molpy.toolsNeedRepaint = 1;
Molpy.RatesRecalculate();
Molpy.SandToolsOwned--;
Molpy.UnlockBoost('No Sell');
Molpy.CheckBuyUnlocks(1);
}
};
this.destroyTemp = function() {
var cost = this.temp * 5;
if(Molpy.Has('GlassBlocks', cost)) {
Molpy.Spend('GlassBlocks', cost);
var destroy = Math.min(this.amount, this.temp);
this.amount = Math.max(0, this.amount - this.temp);
this.temp = 0;
this.Refresh();
Molpy.Boosts['CDSP'].Refresh();
Molpy.Add('AD', cost);
Molpy.CheckDragon();
Molpy.MustardCheck();
}
};
this.isAffordable = function() {
if(Molpy.ProtectingPrice()) return 0;
var price = Math.floor(Molpy.priceFactor * this.basePrice * Math.pow(Molpy.sandToolPriceFactor, this.amount));
return isFinite(price) && Molpy.Has('Castles', price);
};
this.Refresh = function() {
Molpy.toolsNeedRepaint = 1;
Molpy.RatesRecalculate();
this.findPrice();
if(this.drawFunction) this.drawFunction();
};
this.findPrice = function() {
if(this.amount > 9000)
this.price = Infinity;
else
this.price = Math.floor(this.basePrice * Math.pow(Molpy.sandToolPriceFactor, this.amount));
};
// Methods for Div Creation
this.getFullClass = function() {
return 'floatbox tool sand shop';
}
this.getHeading = function() {return '';}
this.getFormattedName = function() {
var fname = '' + format(this.name);
if(isNaN(this.amount))
fname = 'Mustard ' + fname;
else if(Molpy.Got('Glass Ceiling ' + (this.id * 2)))
fname = 'Glass ' + fname;
return fname;
};
this.getOwned = function() {
return Molpify(this.amount, 3);
}
this.getPrice = function() {
var price = '';
if(isFinite(Molpy.priceFactor * this.price) || !Molpy.Got('TF'))
price = {Castles: (Math.floor(EvalMaybeFunction(this.price, this, 1) * Molpy.priceFactor))};
else if(!isNaN(this.price))
price = {GlassChips: 1000 * (this.id * 2 + 1)};
return price;
}
this.getBuySell = function() {
var numBuy = Math.pow(4, Molpy.options.sandmultibuy);
var noBuy = this.isAffordable() ? '' : ' unbuyable';
var buysell = '';
if(isFinite(Molpy.priceFactor * this.price) || !(Molpy.Earned(this.name + ' Shop Failed') && Molpy.Got('TF'))) {
buysell = '<a class="buySpan' + noBuy + '" onclick="Molpy.SandToolsById[' + this.id + '].buy();">Buy '
+ numBuy + '</a>' + (Molpy.Boosts['No Sell'].power ? '' : ' <a class="sellSpan" onclick="Molpy.SandToolsById[' + this.id + '].sell();">Sell</a>');
}
return buysell;
}
this.getProduction = function() {
var production = '';
if(isNaN(this.amount))
production = 'Mustard/click: ' + Molpify((Molpy.Got('Cress')&&Molpy.IsEnabled('Cress')) ? (Molpy.Boosts['Goats'].power/1000) : 1 , 3);
else if(this.storedTotalGpmNP)
production = 'Glass/mNP: ' + Molpify(this.storedTotalGpmNP, (this.storedTotalGpmNP < 10 ? 3 : 1));
else
production = 'Sand/mNP: ' + Molpify(this.storedTotalSpmNP, (this.storedTotalSpmNP < 10 ? 3 : 1));
return production;
}
this.getDesc = function() {
var desc = '';
if(Molpy.IsStatsVisible()) {
if(isFinite(Molpy.priceFactor * this.price) || !Molpy.Got('TF')
|| !Molpy.Got('Glass Ceiling ' + (this.id * 2))) {
desc = 'Total Sand ' + this.actionName + ': ' + Molpify(this.totalSand, 1) + '<br>Sand/mNP per '
+ this.single + ': ' + Molpify(this.storedSpmNP, (this.storedSpmNP < 10 ? 3 : 1));
} else {
desc = 'Total Chips ' + this.actionName + ': ' + Molpify(this.totalGlass, 1)
+ '<br>Glass/mNP per ' + this.single + ': '
+ Molpify(this.storedGpmNP, (this.storedGpmNP < 10 ? 3 : 1));
}
desc += '<br>Total ' + this.plural + ' bought: ' + Molpify(this.bought);
Molpy.EarnBadge('The Fine Print'); //TODO this probably needs to go somewhere else
} else {
desc = this.desc;
}
return desc;
}
// Args:
// forceNew (T/F): force recreation of the object's div
// hover (T/F): add hover mechanics to the div
// nohide (T/F): don't automatically hide the description when the div is created, useful for clicking a div's buttons
this.getDiv = function(args) {
if(this.divElement) {
if(!args.forceNew)
return this.divElement;
this.divElement.remove();
}
this.divElement = Molpy.newObjectDiv('tool', this, {hover: (args.hover || false), nohide: (args.nohide || false)});
return this.divElement;
}
this.hasDiv = function() {
if(this.divElement) return true;
return false;
}
// Methods for Div Updates
this.repaint = function() {
if(!this.divElement) return;
var parent = this.divElement.parent();
var index = this.divElement.index();
Molpy.removeDiv(this);
// If mouse is currently hovering over this, it will start hovered
var nh = false;
var overID = '' + this.name + this.id;
if(Molpy.mouseIsOver == overID) nh = true;
this.getDiv({forceNew: true, hover: true, nohide: nh});
parent.children().eq(index).before(this.divElement);
}
this.updateAll = function() {
this.updateBuy();
this.updatePrice();
this.updateProduction();
}
this.updateBuy = function() {
if(!this.divElement) return;
this.divElement.find('.buySpan').toggleClass('unbuyable', !this.isAffordable());
};
this.updatePrice = function() {
if(!this.divElement) return;
this.divElement.find('.price').innerHTML = Molpy.createPriceHTML(this.getPrice());
}
this.updateProduction = function() {
if(!this.divElement) return;
this.divElement.find('.production').innerHTML = this.getProduction();
}
// Create CSS style for tool
if(this.gifIcon){
addCSSRule(document.styleSheets[1], '.darkscheme .tool_' + this.icon + '.icon', "background-image:url('img/tool_" + this.icon + "_light_icon.gif' )");
addCSSRule(document.styleSheets[1], '.lightscheme .tool_' + this.icon + '.icon', "background-image:url('img/tool_" + this.icon + "_dark_icon.gif' )");
} else if(this.icon) {
addCSSRule(document.styleSheets[1], '.darkscheme .tool_' + this.icon + '.icon', "background-image:url('img/tool_" + this.icon + "_light_icon.png' )");
addCSSRule(document.styleSheets[1], '.lightscheme .tool_' + this.icon + '.icon', "background-image:url('img/tool_" + this.icon + "_dark_icon.png' )");
}
if(this.heresy){
addCSSRule(document.styleSheets[1], '.darkscheme.heresy .tool_' + this.icon + '.icon', "background-image:url('img/tool_" + this.icon + "_light_heresy_icon.png' )");
addCSSRule(document.styleSheets[1], '.lightscheme.heresy .tool_' + this.icon + '.icon', "background-image:url('img/tool_" + this.icon + "_dark_heresy_icon.png' )");
}
Molpy.SandTools[this.name] = this;
Molpy.SandToolsById[this.id] = this;
Molpy.SandToolsN++;
return this;
};
Molpy.CastleTool = function(args) {
// Assign all properties passed in
for(var prop in args) {
if(typeof args[prop] !== 'undefined' )
this[prop] = args[prop];
}
this.id = Molpy.CastleToolsN;
this.name = args.name;
args.commonName = args.commonName.split('|');
this.single = args.commonName[0];
this.plural = args.commonName[1];
this.actionDName = args.commonName[2];
this.actionBName = args.commonName[3];
this.desc = args.desc;
this.price0 = args.price0;
this.price1 = args.price1;
this.prevPrice = args.price0;
this.nextPrice = args.price1;
this.price = this.prevPrice + this.nextPrice; //fib!
this.destroyC = args.destroyC;
this.buildC = args.buildC;
this.destroyG = args.destroyG;
this.buildG = args.buildG;
this.totalCastlesBuilt = 0;
this.totalCastlesDestroyed = 0;
this.totalCastlesWasted = 0; //those destroyed for no gain
this.totalGlassBuilt = 0;
this.totalGlassDestroyed = 0;
this.currentActive = 0;
this.nextThreshold = args.nextThreshold;
this.pic = args.pic;
this.icon = args.icon || 'generic';
this.background = args.background;
this.buyFunction = args.buyFunction;
this.drawFunction = args.drawFunction;
this.destroyFunction = args.destroyFunction;
this.divElement = null;
this.amount = 0;
this.bought = 0;
this.temp = 0;
this.buy = function() {
Molpy.Anything = 1;
if(Molpy.ProtectingPrice()) return;
var times = Math.pow(4, Molpy.options.castlemultibuy);
var bought = 0;
var spent = 0;
while(times-- > 0) {
var price = Math.floor(Molpy.priceFactor * this.price);
if(!isFinite(price)) {
Molpy.UnlockBoost('TF');
Molpy.EarnBadge(this.name + ' Shop Failed');
} else if(Molpy.Has('Castles', price)) {
Molpy.Spend('Castles', price, 1);
this.amount++;
this.bought++;
bought++;
spent += price;
this.findPrice();
if(this.buyFunction) this.buyFunction(this);
if(this.drawFunction) this.drawFunction();
Molpy.toolsNeedRepaint = 1;
Molpy.RatesRecalculate();
Molpy.CastleToolsOwned++;
Molpy.CheckBuyUnlocks(1);
}
}
if(Molpy.Got('TDE')) {
var tdf = Molpy.TDFactor(1) - 1;
var dups = Math.floor(bought * tdf);
this.amount += dups;
this.temp += dups;
bought += dups;
this.findPrice();
if(this.temp > 32) Molpy.UnlockBoost('AD');
}
if(bought) {
Molpy.Notify('Spent ' + Molpify(spent, 3) + ' Castle' + plural(spent) + ', Bought '
+ Molpify(bought, 3) + ' ' + (bought > 1 ? this.plural : this.single), 0);
}
};
this.create = function(n) {
this.amount += n;
this.bought += n;
Molpy.CastleToolsOwned += n;
if(Molpy.Got('Crystal Dragon') && Molpy.Got('TDE')) {
var tdf = Molpy.TDFactor() - 1;
var dups = Math.floor(n * tdf);
this.amount += dups;
this.temp += dups;
Molpy.CastleToolsOwned += dups;
}
return this;
};
this.sell = function() {
Molpy.Anything = 1;
this.findPrice();
if(this.amount > 0) {
if(this.temp > 0) {
this.temp--;
Molpy.Notify('Temporal Duplicate Destroyed!');
} else {
var d = 1;
if(Molpy.Got('Family Discount')) d = .2;
d *= Molpy.Boosts['ASHF'].startPower();
Molpy.Boosts['Castles'].build(this.prevPrice * d, 1);
}
this.amount--;
this.findPrice();
if(this.sellFunction) this.sellFunction();
if(this.drawFunction) this.drawFunction();
Molpy.toolsNeedRepaint = 1;
Molpy.RatesRecalculate();
Molpy.CastleToolsOwned--;
Molpy.UnlockBoost('No Sell');
Molpy.CheckBuyUnlocks(1);
}
};
this.destroyTemp = function() {
var cost = this.temp * 10;
if(Molpy.Has('GlassBlocks', cost)) {
Molpy.Spend('GlassBlocks', cost);
var destroy = Math.min(this.amount, this.temp);
this.amount = Math.max(0, this.amount - this.temp);
this.temp = 0;
this.Refresh();
Molpy.Add('AD', cost);
Molpy.CheckDragon();
Molpy.MustardCheck();
}
else
{
Molpy.Notify('Not nearly glassy enough.', 1);
}
};