-
Notifications
You must be signed in to change notification settings - Fork 168
/
fc_main.js
3113 lines (2918 loc) · 91.6 KB
/
fc_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
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
// Add polyfills:
(function (global) {
var global_isFinite = global.isFinite;
Object.defineProperty(Number, "isFinite", {
value: function isFinite(value) {
return typeof value === "number" && global_isFinite(value);
},
configurable: true,
enumerable: false,
writable: true,
});
})(this);
function registerMod(mod_id = "frozen_cookies") {
// register with the modding API
Game.registerMod(mod_id, {
init: function () {
Game.registerHook("reincarnate", function () {
// called when the player has reincarnated after an ascension
if (FrozenCookies.autoBulk != 0) {
if (FrozenCookies.autoBulk == 1) {
// Buy x10
document.getElementById("storeBulk10").click();
}
if (FrozenCookies.autoBulk == 2) {
// Buy x100
document.getElementById("storeBulk100").click();
}
}
});
Game.registerHook("draw", updateTimers); // called every draw tick
Game.registerHook("ticker", function () {
// called when determining news ticker text (about every ten seconds); should return an array of possible choices to add
return [
"News: Debate about whether using Frozen Cookies constitutes cheating continues to rage. Violence escalating.",
"News: Supreme Court rules Frozen Cookies not unauthorized cheating after all.",
];
});
Game.registerHook("reset", function (hard) {
// the parameter will be true if it's a hard reset, and false (not passed) if it's just an ascension
if (hard) {
emptyCaches();
// if the user is starting fresh, code will likely need to be called to reinitialize some historical data here as well
}
});
/* other hooks that can be used
Game.registerHook('logic', function () { // called every logic tick. seems to correspond with fps
});
Game.registerHook('reincarnate', function () {
});
Game.registerHook('check', function () { // called every few seconds when we check for upgrade/achiev unlock conditions; you can also use this for other checks that you don't need happening every logic frame. called about every five seconds?
});
Game.registerHook('cps', function (cps) { // called when determining the CpS; parameter is the current CpS; should return the modified CpS. called on change or about every ten seconds
return cps;
});
Game.registerHook('cookiesPerClick', function (cookiesPerClick) { // called when determining the cookies per click; parameter is the current value; should return the modified value. called on change or about every ten seconds
return cookiesPerClick;
});
Game.registerHook('click', function () { // called when the big cookie is clicked
});
Game.registerHook('create', function () { // called after the game declares all buildings, upgrades and achievs; use this to declare your own - note that saving/loading functionality for custom content is not explicitly implemented and may be unpredictable and broken
});
*/
},
save: saveFCData,
load: setOverrides, // called whenever a game save is loaded. If the mod has data in the game save when the mod is initially registered, this hook is also called at that time as well.
});
// If Frozen Cookes was loaded and there was previous Frozen Cookies data in the game save, the "load" hook ran so the setOverrides function was called and things got initialized.
// However, if there wasn't previous Frozen Cookies data in the game save, the "load" hook wouldn't have been called. So, we have to manually call setOverrides here to start Frozen Cookies.
if (!FrozenCookies.loadedData) {
setOverrides();
}
logEvent(
"Load",
"Initial Load of Frozen Cookies v " +
FrozenCookies.branch +
"." +
FrozenCookies.version +
". (You should only ever see this once.)"
);
}
function setOverrides(gameSaveData) {
// load settings and initialize variables
// If gameSaveData wasn't passed to this function, it means that there was nothing for this mod in the game save when the mod was loaded
// In that case, set the "loadedData" var to an empty object. When the loadFCData() function runs and finds no data from the game save,
// it pulls data from local storage or sets default values
if (gameSaveData) {
FrozenCookies.loadedData = JSON.parse(gameSaveData);
} else {
FrozenCookies.loadedData = {};
}
loadFCData();
FrozenCookies.frequency = 100;
FrozenCookies.efficiencyWeight = 1.0;
// Becomes 0 almost immediately after user input, so default to 0
FrozenCookies.timeTravelAmount = 0;
// Force redraw every 10 purchases
FrozenCookies.autobuyCount = 0;
// Set default values for calculations
FrozenCookies.hc_gain = 0;
FrozenCookies.hc_gain_time = Date.now();
FrozenCookies.last_gc_state =
(Game.hasBuff("Frenzy") ? Game.buffs["Frenzy"].multCpS : 1) *
clickBuffBonus();
FrozenCookies.last_gc_time = Date.now();
FrozenCookies.lastCPS = Game.cookiesPs;
FrozenCookies.lastBaseCPS = Game.cookiesPs;
FrozenCookies.lastCookieCPS = 0;
FrozenCookies.lastUpgradeCount = 0;
FrozenCookies.currentBank = {
cost: 0,
efficiency: 0,
};
FrozenCookies.targetBank = {
cost: 0,
efficiency: 0,
};
FrozenCookies.disabledPopups = true;
FrozenCookies.trackedStats = [];
FrozenCookies.lastGraphDraw = 0;
FrozenCookies.calculatedCpsByType = {};
// Allow autoCookie to run
FrozenCookies.processing = false;
FrozenCookies.priceReductionTest = false;
FrozenCookies.cookieBot = 0;
FrozenCookies.autoclickBot = 0;
FrozenCookies.autoFrenzyBot = 0;
FrozenCookies.frenzyClickBot = 0;
// Smart tracking details
FrozenCookies.smartTrackingBot = 0;
FrozenCookies.minDelay = 1000 * 10; // 10s minimum reporting between purchases with "smart tracking" on
FrozenCookies.delayPurchaseCount = 0;
// Caching
emptyCaches();
//Whether to currently display achievement popups
FrozenCookies.showAchievements = true;
if (!blacklist[FrozenCookies.blacklist]) {
FrozenCookies.blacklist = 0;
}
// Set `App`, on older version of CC it's not set to anything, so default it to `undefined`
if (!window.App) window.App = undefined;
Beautify = fcBeautify;
Game.sayTime = function (time, detail) {
return timeDisplay(time / Game.fps);
};
if (typeof Game.tooltip.oldDraw != "function") {
Game.tooltip.oldDraw = Game.tooltip.draw;
Game.tooltip.draw = fcDraw;
}
if (typeof Game.oldReset != "function") {
Game.oldReset = Game.Reset;
Game.Reset = fcReset;
}
Game.Win = fcWin;
// Remove the following when turning on tooltop code
nextPurchase(true);
Game.RefreshStore();
Game.RebuildUpgrades();
beautifyUpgradesAndAchievements();
// Replace Game.Popup references with event logging
eval(
"Game.shimmerTypes.golden.popFunc = " +
Game.shimmerTypes.golden.popFunc
.toString()
.replace(/Game\.Popup\((.+)\)\;/g, 'logEvent("GC", $1, true);')
);
eval(
"Game.UpdateWrinklers = " +
Game.UpdateWrinklers.toString().replace(
/Game\.Popup\((.+)\)\;/g,
'logEvent("Wrinkler", $1, true);'
)
);
eval(
"FrozenCookies.safeGainsCalc = " +
Game.CalculateGains.toString()
.replace(/eggMult\+=\(1.+/, "eggMult++; // CENTURY EGGS SUCK")
.replace(/Game\.cookiesPs/g, "FrozenCookies.calculatedCps")
.replace(/Game\.globalCpsMult/g, "mult")
);
// Give free achievements!
if (!Game.HasAchiev("Third-party")) {
Game.Win("Third-party");
}
function loadFCData() {
// Set all cycleable preferences
_.keys(FrozenCookies.preferenceValues).forEach(function (preference) {
FrozenCookies[preference] = preferenceParse(
preference,
FrozenCookies.preferenceValues[preference].default
);
});
// Separate because these are user-input values
FrozenCookies.cookieClickSpeed = preferenceParse("cookieClickSpeed", 0);
FrozenCookies.frenzyClickSpeed = preferenceParse("frenzyClickSpeed", 0);
FrozenCookies.HCAscendAmount = preferenceParse("HCAscendAmount", 0);
FrozenCookies.minCpSMult = preferenceParse("minCpSMult", 1);
FrozenCookies.maxSpecials = preferenceParse("maxSpecials", 1);
// building max values
FrozenCookies.cursorMax = preferenceParse("cursorMax", 500);
FrozenCookies.farmMax = preferenceParse("farmMax", 500);
FrozenCookies.manaMax = preferenceParse("manaMax", 100);
// Get historical data
FrozenCookies.frenzyTimes =
JSON.parse(
FrozenCookies.loadedData["frenzyTimes"] ||
localStorage.getItem("frenzyTimes")
) || {};
// FrozenCookies.non_gc_time = Number(FrozenCookies.loadedData['nonFrenzyTime']) || Number(localStorage.getItem('nonFrenzyTime')) || 0;
// FrozenCookies.gc_time = Number(FrozenCookies.loadedData['frenzyTime']) || Number(localStorage.getItem('frenzyTime')) || 0;;
FrozenCookies.lastHCAmount = preferenceParse("lastHCAmount", 0);
FrozenCookies.lastHCTime = preferenceParse("lastHCTime", 0);
FrozenCookies.prevLastHCTime = preferenceParse("prevLastHCTime", 0);
FrozenCookies.maxHCPercent = preferenceParse("maxHCPercent", 0);
if (Object.keys(FrozenCookies.loadedData).length > 0) {
logEvent("Load", "Restored Frozen Cookies settings from previous save");
}
}
function preferenceParse(setting, defaultVal) {
var value = defaultVal;
if (setting in FrozenCookies.loadedData) {
// first look in the data from the game save
value = FrozenCookies.loadedData[setting];
} else if (localStorage.getItem(setting)) {
// if the setting isn't there, check localStorage
value = localStorage.getItem(setting);
}
return Number(value); // if not overridden by game save or localStorage, defaultVal is returned
}
FCStart();
}
function decodeHtml(html) {
// used to convert text with an HTML entity (like "é") into readable text
var txt = document.createElement("textarea");
txt.innerHTML = html;
return txt.value;
}
function emptyCaches() {
FrozenCookies.recalculateCaches = true;
FrozenCookies.caches = {};
FrozenCookies.caches.nextPurchase = {};
FrozenCookies.caches.recommendationList = [];
FrozenCookies.caches.buildings = [];
FrozenCookies.caches.upgrades = [];
}
function scientificNotation(value) {
if (
value === 0 ||
!Number.isFinite(value) ||
(Math.abs(value) >= 1 && Math.abs(value) <= 1000)
) {
return rawFormatter(value);
}
value = parseFloat(value);
value = value.toExponential(2);
value = value.replace("+", "");
return value;
}
var numberFormatters = [
rawFormatter,
formatEveryThirdPower([
"",
" million",
" billion",
" trillion",
" quadrillion",
" quintillion",
" sextillion",
" septillion",
" octillion",
" nonillion",
" decillion",
" undecillion",
" duodecillion",
" tredecillion",
" quattuordecillion",
" quindecillion",
" sexdecillion",
" septendecillion",
" octodecillion",
" novemdecillion",
" vigintillion",
" unvigintillion",
" duovigintillion",
" trevigintillion",
" quattuorvigintillion",
" quinvigintillion",
" sexvigintillion",
" septenvigintillion",
" octovigintillion",
" novemvigintillion",
" trigintillion",
" untrigintillion",
" duotrigintillion",
" tretrigintillion",
" quattuortrigintillion",
" quintrigintillion",
" sextrigintillion",
" septentrigintillion",
" octotrigintillion",
" novemtrigintillion",
]),
formatEveryThirdPower([
"",
" M",
" B",
" T",
" Qa",
" Qi",
" Sx",
" Sp",
" Oc",
" No",
" De",
" UnD",
" DoD",
" TrD",
" QaD",
" QiD",
" SxD",
" SpD",
" OcD",
" NoD",
" Vg",
" UnV",
" DoV",
" TrV",
" QaV",
" QiV",
" SxV",
" SpV",
" OcV",
" NoV",
" Tg",
" UnT",
" DoT",
" TrT",
" QaT",
" QiT",
" SxT",
" SpT",
" OcT",
" NoT",
]),
formatEveryThirdPower(["", " M", " G", " T", " P", " E", " Z", " Y"]),
scientificNotation,
];
function fcBeautify(value) {
var negative = value < 0;
value = Math.abs(value);
var formatter = numberFormatters[FrozenCookies.numberDisplay];
var output = formatter(value)
.toString()
.replace(/\B(?=(\d{3})+(?!\d))/g, ",");
return negative ? "-" + output : output;
}
// Runs numbers in upgrades and achievements through our beautify function
function beautifyUpgradesAndAchievements() {
function beautifyFn(str) {
return Beautify(parseInt(str.replace(/,/, ""), 10));
}
var numre = /\d\d?\d?(?:,\d\d\d)*/;
Object.values(Game.AchievementsById).forEach(function (ach) {
ach.desc = ach.desc.replace(numre, beautifyFn);
});
// These might not have any numbers in them, but just in case...
Object.values(Game.UpgradesById).forEach(function (upg) {
upg.desc = upg.desc.replace(numre, beautifyFn);
});
}
function timeDisplay(seconds) {
if (seconds === "---" || seconds === 0) {
return "Done!";
} else if (seconds == Number.POSITIVE_INFINITY) {
return "Never!";
}
seconds = Math.floor(seconds);
var days, hours, minutes;
days = Math.floor(seconds / (24 * 60 * 60));
days = days > 0 ? Beautify(days) + "d " : "";
seconds %= 24 * 60 * 60;
hours = Math.floor(seconds / (60 * 60));
hours = hours > 0 ? hours + "h " : "";
seconds %= 60 * 60;
minutes = Math.floor(seconds / 60);
minutes = minutes > 0 ? minutes + "m " : "";
seconds %= 60;
seconds = seconds > 0 ? seconds + "s" : "";
return (days + hours + minutes + seconds).trim();
}
function fcDraw(from, text, origin) {
if (typeof text == "string") {
if (text.includes("Devastation")) {
text = text.replace(
/\+\d+\%/,
"+" +
Math.round((Game.hasBuff("Devastation").multClick - 1) * 100) +
"%"
);
}
}
Game.tooltip.oldDraw(from, text, origin);
}
function fcReset() {
Game.CollectWrinklers();
if (Game.HasUnlocked("Chocolate egg") && !Game.Has("Chocolate egg")) {
Game.ObjectsById.forEach(function (b) {
b.sell(-1);
});
Game.Upgrades["Chocolate egg"].buy();
}
Game.oldReset();
FrozenCookies.frenzyTimes = {};
FrozenCookies.last_gc_state =
(Game.hasBuff("Frenzy") ? Game.buffs["Frenzy"].multCpS : 1) *
clickBuffBonus();
FrozenCookies.last_gc_time = Date.now();
FrozenCookies.lastHCAmount = Game.HowMuchPrestige(
Game.cookiesEarned + Game.cookiesReset + wrinklerValue()
);
FrozenCookies.lastHCTime = Date.now();
FrozenCookies.maxHCPercent = 0;
FrozenCookies.prevLastHCTime = Date.now();
FrozenCookies.lastCps = 0;
FrozenCookies.lastBaseCps = 0;
FrozenCookies.trackedStats = [];
recommendationList(true);
}
function saveFCData() {
var saveString = {};
_.keys(FrozenCookies.preferenceValues).forEach(function (preference) {
saveString[preference] = FrozenCookies[preference];
});
saveString.frenzyClickSpeed = FrozenCookies.frenzyClickSpeed;
saveString.cookieClickSpeed = FrozenCookies.cookieClickSpeed;
saveString.HCAscendAmount = FrozenCookies.HCAscendAmount;
saveString.cursorMax = FrozenCookies.cursorMax;
saveString.farmMax = FrozenCookies.farmMax;
saveString.minCpSMult = FrozenCookies.minCpSMult;
saveString.frenzyTimes = JSON.stringify(FrozenCookies.frenzyTimes);
// saveString.nonFrenzyTime = FrozenCookies.non_gc_time;
// saveString.frenzyTime = FrozenCookies.gc_time;
saveString.lastHCAmount = FrozenCookies.lastHCAmount;
saveString.maxHCPercent = FrozenCookies.maxHCPercent;
saveString.lastHCTime = FrozenCookies.lastHCTime;
saveString.manaMax = FrozenCookies.manaMax;
saveString.maxSpecials = FrozenCookies.maxSpecials;
saveString.prevLastHCTime = FrozenCookies.prevLastHCTime;
saveString.saveVersion = FrozenCookies.version;
return JSON.stringify(saveString);
}
function divCps(value, cps) {
var result = 0;
if (value) {
if (cps) {
result = value / cps;
} else {
result = Number.POSITIVE_INFINITY;
}
}
return result;
}
function nextHC(tg) {
var futureHC = Math.ceil(
Game.HowMuchPrestige(Game.cookiesEarned + Game.cookiesReset)
);
var nextHC = Game.HowManyCookiesReset(futureHC);
var toGo = nextHC - (Game.cookiesEarned + Game.cookiesReset);
return tg ? toGo : timeDisplay(divCps(toGo, Game.cookiesPs));
}
function copyToClipboard(text) {
Game.promptOn = 1;
window.prompt("Copy to clipboard: Ctrl+C, Enter", text);
Game.promptOn = 0;
}
function getBuildingSpread() {
return Game.ObjectsById.map(function (a) {
return a.amount;
}).join("/");
}
// todo: add bind for autoascend
// Press 'a' to toggle autobuy.
// Press 'b' to pop up a copyable window with building spread.
// Press 'c' to toggle auto-GC
// Press 'e' to pop up a copyable window with your export string
// Press 'r' to pop up the reset window
// Press 's' to do a manual save
// Press 'w' to display a wrinkler-info window
document.addEventListener("keydown", function (event) {
if (!Game.promptOn) {
if (event.keyCode == 65) {
Game.Toggle("autoBuy", "autobuyButton", "Autobuy OFF", "Autobuy ON");
toggleFrozen("autoBuy");
}
if (event.keyCode == 66) {
copyToClipboard(getBuildingSpread());
}
if (event.keyCode == 67) {
Game.Toggle(
"autoGC",
"autogcButton",
"Autoclick GC OFF",
"Autoclick GC ON"
);
toggleFrozen("autoGC");
}
if (event.keyCode == 69) {
copyToClipboard(Game.WriteSave(true));
}
if (event.keyCode == 82) {
Game.Reset();
}
if (event.keyCode == 83) {
Game.WriteSave();
}
if (event.keyCode == 87) {
Game.Notify(
"Wrinkler Info",
"Popping all wrinklers will give you " +
Beautify(wrinklerValue()) +
' cookies. <input type="button" value="Click here to pop all wrinklers" onclick="Game.CollectWrinklers()"></input>',
[19, 8],
7
);
}
}
});
function writeFCButton(setting) {
var current = FrozenCookies[setting];
}
function userInputPrompt(title, description, existingValue, callback) {
Game.Prompt(`<h3>${title}</h3><div class="block" style="text-align:center;">${description}</div><div class="block"><input type="text" style="text-align:center;width:100%;" id="fcGenericInput" value="${existingValue}"/></div>`,
[
'Confirm',
'Cancel'
]);
$('#promptOption0').click(() => {callback(l('fcGenericInput').value)});
l('fcGenericInput').focus();
l('fcGenericInput').select();
}
function validateNumber(value, minValue = null, maxValue = null) {
if (typeof value == "undefined" ||
value == null) {
return false;
}
const numericValue = Number(value);
return !isNaN(numericValue) &&
(minValue == null || numericValue >= minValue) &&
(maxValue == null || numericValue <= maxValue);
}
function storeNumberCallback(base, min, max) {
return (result) => {
if (!validateNumber(result, min, max)) {
result = FrozenCookies[base];
}
FrozenCookies[base] = Number(result);
FCStart();
}
}
function updateSpeed(base) {
userInputPrompt(
'Autoclicking!',
"How many times per second do you want to click? (Current maximum is 250 clicks per second)",
FrozenCookies[base],
storeNumberCallback(base, 0, 250)
);
}
function updateCpSMultMin(base) {
userInputPrompt(
'Autocasting!',
'What CpS multiplier should trigger Auto Casting (e.g. "7" will trigger when you have full mana and a Frenzy, "1" prevents triggering during a clot, etc.)?',
FrozenCookies[base],
storeNumberCallback(base, 0)
);
}
function updateAscendAmount(base) {
userInputPrompt(
'Autoascending!',
'How many heavenly chips do you want to auto-ascend at?',
FrozenCookies[base],
storeNumberCallback(base, 1)
);
}
function updateManaMax(base) {
userInputPrompt(
'Mana Cap!',
'Choose a maximum mana amount',
FrozenCookies[base],
storeNumberCallback(base, 0)
);
}
function updateMaxSpecials(base) {
userInputPrompt(
'Harvest Bank!',
'Set amount of stacked Building specials for Harvest Bank',
FrozenCookies[base],
storeNumberCallback(base, 0)
);
}
function updateCursorMax(base) {
userInputPrompt(
'Cursor Cap!',
'How many Cursors should Autobuy stop at?',
FrozenCookies[base],
storeNumberCallback(base, 0)
);
}
function updateFarmMax(base) {
userInputPrompt(
'Farm Cap!',
'How many Farms should Autobuy stop at?',
FrozenCookies[base],
storeNumberCallback(base, 0)
);
}
function updateTimeTravelAmount() {
userInputPrompt(
'Time Travel!',
"Warning: Time travel is highly unstable, and large values are highly likely to either cause long delays or crash the game. Be careful!\nHow much do you want to time travel by? This will happen instantly.",
FrozenCookies.timeTravelAmount,
storeNumberCallback('timeTravelAmount', 0)
);
}
function cyclePreference(preferenceName) {
var preference = FrozenCookies.preferenceValues[preferenceName];
if (preference) {
var display = preference.display;
var current = FrozenCookies[preferenceName];
var preferenceButton = $("#" + preferenceName + "Button");
if (
display &&
display.length > 0 &&
preferenceButton &&
preferenceButton.length > 0
) {
var newValue = (current + 1) % display.length;
preferenceButton[0].innerText = display[newValue];
FrozenCookies[preferenceName] = newValue;
FrozenCookies.recalculateCaches = true;
Game.RefreshStore();
Game.RebuildUpgrades();
FCStart();
}
}
}
function toggleFrozen(setting) {
if (!FrozenCookies[setting]) {
FrozenCookies[setting] = 1;
} else {
FrozenCookies[setting] = 0;
}
FCStart();
}
var T = Game.Objects["Temple"].minigame;
var M = Game.Objects["Wizard tower"].minigame;
function rigiSell() {
//Sell enough cursors to enable Rigidels effect
if (Game.BuildingsOwned % 10)
Game.Objects["Cursor"].sell(Game.BuildingsOwned % 10);
return;
}
function lumpIn(mins) {
//For debugging, set minutes until next lump is *ripe*
Game.lumpT = Date.now() - Game.lumpRipeAge + 60000 * mins;
}
function swapIn(godId, targetSlot) {
//mostly code copied from minigamePantheon.js, tweaked to avoid references to "dragging"
if (T.swaps == 0) return;
T.useSwap(1);
T.lastSwapT = 0;
var div = l("templeGod" + godId);
var prev = T.slot[targetSlot]; //id of God currently in slot
if (prev != -1) {
//when something's in there already
prev = T.godsById[prev]; //prev becomes god object
var prevDiv = l("templeGod" + prev.id);
if (T.godsById[godId].slot != -1)
l("templeSlot" + T.godsById[godId].slot).appendChild(prevDiv);
else {
var other = l("templeGodPlaceholder" + prev.id);
other.parentNode.insertBefore(prevDiv, other);
}
}
l("templeSlot" + targetSlot).appendChild(l("templeGod" + godId));
T.slotGod(T.godsById[godId], targetSlot);
PlaySound("snd/tick.mp3");
PlaySound("snd/spirit.mp3");
var rect = l("templeGod" + godId).getBoundingClientRect();
Game.SparkleAt(
(rect.left + rect.right) / 2,
(rect.top + rect.bottom) / 2 - 24
);
}
function autoRigidel() {
if (!T) return; //Exit if pantheon doesnt even exist
var timeToRipe =
(Math.ceil(Game.lumpRipeAge) - (Date.now() - Game.lumpT)) / 60000; //Minutes until sugar lump ripens
var orderLvl = Game.hasGod("order") ? Game.hasGod("order") : 0;
switch (orderLvl) {
case 0: //Rigidel isn't in a slot
if (T.swaps < 2 || (T.swaps == 1 && T.slot[0] == -1)) return; //Don't do anything if we can't swap Rigidel in
if (timeToRipe < 60) {
var prev = T.slot[0]; //cache whatever god you have equipped
swapIn(10, 0); //swap in rigidel
Game.computeLumpTimes();
rigiSell(); //Meet the %10 condition
Game.clickLump(); //harvest the ripe lump, AutoSL probably covers this but this should avoid issues with autoBuy going first and disrupting Rigidel
if (prev != -1) swapIn(prev, 0); //put the old one back
}
case 1: //Rigidel is already in diamond slot
if (timeToRipe < 60 && Game.BuildingsOwned % 10) {
rigiSell();
Game.computeLumpTimes();
Game.clickLump();
}
case 2: //Rigidel in Ruby slot,
if (timeToRipe < 40 && Game.BuildingsOwned % 10) {
rigiSell();
Game.computeLumpTimes();
Game.clickLump();
}
case 3: //Rigidel in Jade slot
if (timeToRipe < 20 && Game.BuildingsOwned % 10) {
rigiSell();
Game.computeLumpTimes();
Game.clickLump();
}
}
}
function autoTicker() {
if (Game.TickerEffect && Game.TickerEffect.type == "fortune") {
Game.tickerL.click();
}
}
function autoCast() {
if (!M) return; // Just leave if you don't have grimoire
if (M.magic == M.magicM) {
if (
cpsBonus() >= FrozenCookies.minCpSMult ||
Game.hasBuff("Dragonflight") ||
Game.hasBuff("Click frenzy")
) {
switch (FrozenCookies.autoSpell) {
case 0:
return;
case 1:
var CBG = M.spellsById[0];
if (M.magicM < Math.floor(CBG.costMin + CBG.costPercent * M.magicM))
return;
M.castSpell(CBG);
logEvent("AutoSpell", "Cast Conjure Baked Goods");
return;
case 2:
var FTHOF = M.spellsById[1];
if (
M.magicM < Math.floor(FTHOF.costMin + FTHOF.costPercent * M.magicM)
)
return;
M.castSpell(FTHOF);
logEvent("AutoSpell", "Cast Force the Hand of Fate");
return;
case 3:
var SE = M.spellsById[3];
// This code apparently works under the following assumptions:
// - you want to spend your mana to get the highest value building (currently Idleverse)
// - therefore you'll manually keep your number of Idleverses < 400, or don't mind selling the excess for the chance to win a free one
// If you don't have any Idleverse yet, or can't cast SE, just give up.
if (
Game.Objects["Idleverse"].amount == 0 ||
M.magicM < Math.floor(SE.costMin + SE.costPercent * M.magicM)
)
return;
// If we have over 400 Idleverses, always going to sell down to 399.
// If you don't have half a Idleverse's worth of cookies in bank, sell one or more until you do
while (
Game.Objects["Idleverse"].amount >= 400 ||
Game.cookies < Game.Objects["Idleverse"].price / 2
) {
Game.Objects["Idleverse"].sell(1);
logEvent(
"Store",
"Sold 1 Idleverse for " +
(Beautify(
Game.Objects["Idleverse"].price *
Game.Objects["Idleverse"].getSellMultiplier()
) +
" cookies")
);
}
M.castSpell(SE);
logEvent("AutoSpell", "Cast Spontaneous Edifice");
return;
case 4:
var hagC = M.spellsById[4];
if (M.magicM < Math.floor(hagC.costMin + hagC.costPercent * M.magicM))
return;
M.castSpell(hagC);
logEvent("AutoSpell", "Cast Haggler's Charm");
return;
}
}
}
}
function autoBlacklistOff() {
switch (FrozenCookies.blacklist) {
case 1:
FrozenCookies.blacklist = Game.cookiesEarned >= 1000000 ? 0 : 1;
break;
case 2:
FrozenCookies.blacklist = Game.cookiesEarned >= 1000000000 ? 0 : 2;
break;
case 3:
FrozenCookies.blacklist =
haveAll("halloween") && haveAll("easter") ? 0 : 3;
break;
}
}
function generateProbabilities(upgradeMult, minBase, maxMult) {
var cumProb = [];
var remainingProbability = 1;
var minTime = minBase * upgradeMult;
var maxTime = maxMult * minTime;
var spanTime = maxTime - minTime;
for (var i = 0; i < maxTime; i++) {
var thisFrame =
remainingProbability * Math.pow(Math.max(0, (i - minTime) / spanTime), 5);
remainingProbability -= thisFrame;
cumProb.push(1 - remainingProbability);
}
return cumProb;
}
var cumulativeProbabilityList = {
golden: [1, 0.95, 0.5, 0.475, 0.25, 0.2375].reduce(function (r, x) {
r[x] = generateProbabilities(x, 5 * 60 * Game.fps, 3);
return r;
}, {}),
reindeer: [1, 0.5].reduce(function (r, x) {
r[x] = generateProbabilities(x, 3 * 60 * Game.fps, 2);
return r;
}, {}),
};
function getProbabilityList(listType) {
return cumulativeProbabilityList[listType][getProbabilityModifiers(listType)];
}
function getProbabilityModifiers(listType) {
var result;
switch (listType) {
case "golden":
result =
(Game.Has("Lucky day") ? 0.5 : 1) *
(Game.Has("Serendipity") ? 0.5 : 1) *
(Game.Has("Golden goose egg") ? 0.95 : 1);
break;
case "reindeer":
result = Game.Has("Reindeer baking grounds") ? 0.5 : 1;
break;
}
return result;
}
function cumulativeProbability(listType, start, stop) {
return (
1 -
(1 - getProbabilityList(listType)[stop]) /
(1 - getProbabilityList(listType)[start])
);
}
function probabilitySpan(listType, start, endProbability) {
var startProbability = getProbabilityList(listType)[start];
return _.sortedIndex(
getProbabilityList(listType),
startProbability + endProbability - startProbability * endProbability
);
}
function clickBuffBonus() {
var ret = 1;
for (var i in Game.buffs) {
// Devastation, Godzamok's buff, is too variable
if (
typeof Game.buffs[i].multClick != "undefined" &&
Game.buffs[i].name != "Devastation"
) {
ret *= Game.buffs[i].multClick;
}
}
return ret;
}
function cpsBonus() {
var ret = 1;
for (var i in Game.buffs) {
if (typeof Game.buffs[i].multCpS != "undefined") {
ret *= Game.buffs[i].multCpS;
}
}
return ret;
}
function hasClickBuff() {
return Game.hasBuff("Cursed finger") || clickBuffBonus() > 1;
}
function baseCps() {
var buffMod = 1;
for (var i in Game.buffs) {
if (typeof Game.buffs[i].multCpS != "undefined")
buffMod *= Game.buffs[i].multCpS;
}
if (buffMod === 0) {
return FrozenCookies.lastBaseCPS;
}
var baseCPS = Game.cookiesPs / buffMod;
FrozenCookies.lastBaseCPS = baseCPS;
return baseCPS;
}
function baseClickingCps(clickSpeed) {
var clickFrenzyMod = clickBuffBonus();
var frenzyMod = Game.hasBuff("Frenzy") ? Game.buffs["Frenzy"].multCpS : 1;
var cpc = Game.mouseCps() / (clickFrenzyMod * frenzyMod);
return clickSpeed * cpc;
}
function effectiveCps(delay, wrathValue, wrinklerCount) {
wrathValue = wrathValue != null ? wrathValue : Game.elderWrath;
wrinklerCount = wrinklerCount != null ? wrinklerCount : wrathValue ? 10 : 0;
var wrinkler = wrinklerMod(wrinklerCount);
if (delay == null) {
delay = delayAmount();
}
return (
baseCps() * wrinkler +