-
Notifications
You must be signed in to change notification settings - Fork 1
/
Copy pathnig_sim.js
2229 lines (2105 loc) · 101 KB
/
nig_sim.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
const D = (value) => new Decimal(value);
const numarr2boolarr = (numarr, length) => {
let boolarr = new Array(length).fill(false);
numarr.forEach((n, i) => {
if (typeof n == 'boolean') {
boolarr[i] = n;
} else {
boolarr[n] = true;
}
});
return boolarr;
};
class ItemData {
constructor() {
this.challengetext = [
'昇段リセットは1e24ポイントから可能になります',
'発生器は高速に値上がりします',
'発生器購入数による強化は無効になります',
'発生器のモードは0に固定されます',
'段位によらない基礎的な下位モード強化は無効となります',
'時間加速器は購入できません',
'発生器4と8は購入できません',
'段位リセット回数による強化は無効になります',
];
this.rewardtext = [
'昇段リセット後1e4ポイント獲得',
'昇段リセット後10個の時間加速器1獲得',
'番号が最高の発生器にも購入数ボーナスが働く',
'全発生器の生産力が2倍に',
'挑戦中でも効力を有効に',
'発生器自動購入器を入手',
'時間加速器1に購入数ボーナスが働く',
'発生器1の生産力が一度に取得した最大段位数倍に(上限:100000)',
'段位リセット回数の増加分が2倍に',
'時間加速器自動購入器を入手',
'時間加速器2に購入数ボーナスが働く',
'発生器の購入数ボーナスが強化',
'リセット時の段位取得数が2倍に',
'発生器は同時に全てのモードとなる',
'自動昇段リセット器を入手',
];
this.rankrewardtext = [
'昇段リセット後1e9ポイント獲得',
'昇段リセット後256個の時間加速器1獲得',
'輝きの一度の入手数が2つに',
'全発生器の生産力が3倍に',
'受けている挑戦の数に応じて発生器が少し強化',
'段位効力自動購入器を入手',
'時間加速器3以降に購入数ボーナスが働く',
'効力8が上限以降も少しだけ強化',
'階位リセット回数の増加分が3倍に',
'間隙が50毛秒に固定(発生器の生産力変化)',
'時間加速器の購入数ボーナスが強化',
'記憶が入手数に応じてさらに強化',
'リセット時の階位取得数が3倍に',
'全時間加速器が間隙に影響',
'自動昇階リセット器を入手',
];
this.rewardcost = [1, 2, 4, 8, 8, 8, 16, 16, 16, 16, 32, 32, 32, 32, 32];
this.levelitemtext = [
'段位取得量が最大取得段位以下の範囲で増加します',
'取得している効力数によって、間隙が少しだけ短くなります',
'段位リセット1回あたりの効果が弱くなるのが遅くなります',
'新しい時間加速器を購入可能になります',
'階位の入手量が少しだけ増加します',
];
this.levelitemcost = [D('1e1'), D('1e2'), D('1e3'), D('1e4'), D('1e5')];
this.trophytext = [
'有段者',
'有階者',
'輝く者',
'世界移動者',
'裏の者',
'煌く者',
'想い出す者',
'有冠者',
'天上の者'
];
this.smalltrophytext = [
'ポイントを0より大きくする',
'ポイントを777より大きくする',
'ポイントを7777777より大きくする',
'ポイントを1e19より大きくする',
'ポイントを1e36より大きくする',
'ポイントを1e77より大きくする',
'ポイントを1e81より大きくする',
'ポイントを1e303より大きくする',
'発生器1を1つ以上購入する',
'発生器2を1つ以上購入する',
'発生器3を1つ以上購入する',
'発生器4を1つ以上購入する',
'発生器5を1つ以上購入する',
'発生器6を1つ以上購入する',
'発生器7を1つ以上購入する',
'発生器8を1つ以上購入する',
'時間加速器1を1つ以上購入する',
'時間加速器2を1つ以上購入する',
'時間加速器3を1つ以上購入する',
'時間加速器4を1つ以上購入する',
'時間加速器5を1つ以上購入する',
'時間加速器6を1つ以上購入する',
'時間加速器7を1つ以上購入する',
'時間加速器8を1つ以上購入する',
'段位リセットを200より大きくする',
'段位リセットを999より大きくする',
'挑戦1を達成する',
'挑戦2を達成する',
'挑戦3を達成する',
'挑戦4を達成する',
'挑戦5を達成する',
'挑戦6を達成する',
'挑戦7を達成する',
'挑戦8を達成する',
'挑戦を32種類以上達成する',
'挑戦を64種類以上達成する',
'挑戦を96種類以上達成する',
'挑戦を128種類以上達成する',
'挑戦を160種類以上達成する',
'挑戦を192種類以上達成する',
'挑戦を224種類以上達成する',
'挑戦を255種類以上達成する',
'階位リセットを1より大きくする',
'階位リセットを4より大きくする',
'階位リセットを9より大きくする',
'階位リセットを99より大きくする',
'階位リセットを999より大きくする',
'段位効力の累計購入回数を4以上にする',
'段位効力の累計購入回数を108以上にする',
'段位効力の累計購入回数を256以上にする',
'段位効力の累計購入回数を1728以上にする',
'段位効力の累計購入回数を12500以上にする',
'100以上の輝きを所持する',
'1000以上の輝きを所持する',
'10000以上の輝きを所持する',
'100000以上の輝きを所持する',
'1000000以上の輝きを所持する',
'10000000以上の輝きを所持する',
'設定タブ内で、データ吐き出しを行う',
'設定タブ内で、ツイート設定機能を2つ以上設定する',
'裏発生器1を1つ以上購入する',
'裏発生器2を1つ以上購入する',
'裏発生器3を1つ以上購入する',
'裏発生器4を1つ以上購入する',
'裏発生器5を1つ以上購入する',
'裏発生器6を1つ以上購入する',
'裏発生器7を1つ以上購入する',
'裏発生器8を1つ以上購入する',
'階位挑戦を32種類以上達成する',
'階位挑戦を64種類以上達成する',
'階位挑戦を96種類以上達成する',
'階位挑戦を128種類以上達成する',
'階位挑戦を160種類以上達成する',
'階位挑戦を192種類以上達成する',
'階位挑戦を224種類以上達成する',
'階位挑戦を255種類以上達成する',
'10以上の煌きを所有する',
'100以上の煌きを所有する',
'1000以上の煌きを所有する',
'10000以上の煌きを所有する',
'裏ポイントを1以上にする',
'裏ポイントを777以上にする',
'裏ポイントを7777777以上にする',
'裏ポイントを1e18以上にする',
'裏ポイントを1e72以上にする',
'銅片を1個以上にする',
'銅片を210個以上にする',
'銅片を1275個以上にする',
'銀片を1個以上にする',
'銀片を210個以上にする',
'銀片を1275個以上にする',
'金片を1個以上にする',
'金片を210個以上にする',
'金片を1275個以上にする',
'白金片を1個以上にする',
'白金片を210個以上にする',
'白金片を1275個以上にする',
'裏段位を1以上にする',
'裏段位を1e3より大きくする',
'裏段位を1e10より大きくする',
'冠位リセットを1以上にする',
'冠位リセットを5以上にする',
'冠位リセットを20以上にする',
'冠位リセットを100以上にする',
'時間回帰力を1以上にする',
'時間回帰力を3以上にする',
'時間回帰力を6以上にする',
'時間回帰力を10以上にする',
'階位を1e8より大きくする',
'階位を1e10より大きくする',
'階位を1e12より大きくする',
'天上発生器1を1つ以上購入する',
'天上発生器2を1つ以上購入する',
'天上発生器3を1つ以上購入する',
'天上発生器4を1つ以上購入する',
'天上発生器5を1つ以上購入する',
'天上発生器6を1つ以上購入する',
'天上発生器7を1つ以上購入する',
'天上発生器8を1つ以上購入する',
'紫鋼片を1個以上にする',
'紫鋼片を210個以上にする',
'紫鋼片を1275個以上にする',
'銅像を10個以上にする',
'銀像を10個以上にする',
'金像を10個以上にする',
'白金像を10個以上にする'
]
this.chipname = ['銅', '銀', '金', '白金', '紫鋼', '朱鋼', '蒼鋼', '翠鋼', '聖銀', '覇金'];
this.chipbonusname = [
'発生器効率',
'発生器1効率',
'発生器2効率',
'発生器3効率',
'発生器4効率',
'発生器5効率',
'発生器6効率',
'発生器7効率',
'発生器8効率',
'間隙',
'時間加速器1効率',
'時間加速器2効率',
'時間加速器3効率',
'時間加速器4効率',
'時間加速器5効率',
'時間加速器6効率',
'時間加速器7効率',
'時間加速器8効率',
'段位入手量',
'段位効率',
'段位リセット入手量',
'段位リセット効率(工事中)',
'階位入手量',
'階位効率',
'階位リセット入手量',
'階位リセット効率(工事中)',
'段位効力1効率',
'段位効力2効率',
'段位効力3効率',
'段位効力5効率',
'輝き入手割合',
'輝き使用効率',
'裏発生器1強化',
'裏発生器2強化',
'裏発生器3強化',
'裏発生器4強化',
'裏発生器5強化',
'裏発生器6強化',
'裏発生器7強化',
'裏発生器8強化',
'裏ポイント強化',
'裏発生器1生産強化',
'裏発生器2生産強化',
'裏発生器3生産強化',
'裏発生器4生産強化',
'裏発生器5生産強化',
'裏発生器6生産強化',
'裏発生器7生産強化',
'裏発生器8生産強化',
'煌き入手割合',
'煌き使用効率',
'煌き使用効率裏',
];
this.perfect_challengetext = [
'発生器の倍率が1/100になります。',
'間隙のベースは10000毛秒になります。',
'発生器3と6は生産をしません。',
'倍率は6桁毎に切り捨てられます。',
'段位と段位リセットの入手量は大幅に減少します。',
'階位の入手量は大幅に減少します。',
'輝きと煌きは使用できません。',
'記憶と思い出は大幅に弱体化されます。',
'裏発生器と裏ポイントは発生器を強化しません。',
'鋳片効力は、新規挑戦達成でない段位リセットを行うごとにランダムで1つが無効になります。',
];
}
};
const itemdata = new ItemData();
class MaximumBonuses {
constructor() {
this.cache = new Map();
};
get(mxtoken, rank, onchallenge) {
const key = { mxtoken: mxtoken, rank: rank, onchallenge: onchallenge };
let res = this.cache.get(key);
if (res === undefined) {
res = MaximumBonuses.maximumbonuses(mxtoken, rank, onchallenge);
this.cache.set(key, res);
}
return res;
};
static maximumbonuses(mxtoken, rank, onchallenge) {
const effectivechallengebonuses = rank ? [3, 4, 6, 7, 9, 10, 11, 13] : [2, 3, 6, 7, 10, 11, 13];
const m = 1 << effectivechallengebonuses.length;
if (!rank && onchallenge) mxtoken = Math.max(mxtoken - 8, 0);
let costs = new Array(m).fill(0);
let challengebonusescandidates = [];
for (let i = 0; i < m; i++) {
let ok = true;
for (let j = 0; j < effectivechallengebonuses.length; j++) {
if (!(i & 1 << j)) {
costs[i ^ 1 << j] = costs[i] + itemdata.rewardcost[effectivechallengebonuses[j]];
ok &= costs[i ^ 1 << j] > mxtoken || (rank && effectivechallengebonuses[j] === 9);
}
}
if (ok && costs[i] <= mxtoken) {
let cs = [];
for (let j = 0; j < effectivechallengebonuses.length; j++) {
if (i & 1 << j) {
cs.push(effectivechallengebonuses[j]);
}
}
/* 上位効力4は上位効力5の上位互換 */
if (rank && !cs.includes(3) && cs.includes(4)) { } else {
challengebonusescandidates.push(cs);
}
}
}
return challengebonusescandidates;
}
};
const mbcache = new MaximumBonuses();
const trophynum = 9;
const setchipkind = 10;
const setchipnum = 100;
class Nig {
constructor() {
const initialData = () => {
return {
money: D(1),
level: D(0),
levelresettime: D(0),
maxlevelgained: D(1),
token: 0,
shine: 0,
brightness: 0,
rank: D(0),
rankresettime: D(0),
ranktoken: 0,
crown: D(0),
crownresettime: D(0),
generators: new Array(8).fill(D(0)),
generatorsBought: new Array(8).fill(D(0)),
generatorsCost: [D(1), D('1e4'), D('1e9'), D('1e16'), D('1e25'), D('1e36'), D('1e49'), D('1e64')],
generatorsMode: new Array(8).fill().map((_, i) => i),
accelerators: new Array(8).fill(D(0)),
acceleratorsBought: new Array(8).fill(D(0)),
acceleratorsCost: [D(10), D('1e10'), D('1e20'), D('1e40'), D('1e80'), D('1e160'), D('1e320'), D('1e640')],
darkmoney: D(0),
darkgenerators: new Array(8).fill(D(0)),
darkgeneratorsBought: new Array(8).fill(D(0)),
darkgeneratorsCost: [D('1e100'), D('1e108'), D('1e127'), D('1e164'), D('1e225'), D('1e316'), D('1e443'), D('1e612')],
darklevel: D(0),
lightmoney: D(0),
lightgenerators: new Array(8).fill(D(0)),
lightgeneratorsBought: new Array(8).fill(D(0)),
lightgeneratorsCost: [D('1e200'), D('1e216'), D('1e281'), D('1e456'), D('1e825'), D('1e1496'), D('1e2601'), D('1e4296')],
tickspeed: 1000,
accelevel: 0,
accelevelused: 0,
onchallenge: false,
challenges: new Array(8).fill(false),
challengecleared: [],
challengebonuses: new Array(15).fill(false),
onpchallenge: false,
pchallenges: [],
pchallengecleared: new Array(1024).fill(0),
prchallengecleared: new Array(1024).fill(0),
rankchallengecleared: [],
rankchallengebonuses: new Array(15).fill(false),
trophies: new Array(trophynum).fill(false),
smalltrophies: new Array(100).fill(false),
smalltrophies2nd: new Array(100).fill(false),
levelitems: new Array(5).fill(0),
levelitembought: 0,
remember: 0,
rememberspent: 0,
chip: new Array(setchipkind).fill(0),
setchip: new Array(setchipnum).fill(0),
disabledchip: new Array(setchipnum).fill(false),
statue: new Array(setchipkind).fill(0),
worldpipe: new Array(10).fill(null).map(() => 0),
};
};
this.player = initialData();
this.players = new Array(10).fill().map(() => initialData());
this.highest = 0;
this.commonmult = D(1);
this.incrementalmults = new Array(8).fill(D(1));
this.multbyac = D(1);
this.memory = 0;
this.smallmemory = 0;
this.smallmemories = new Array(10).fill(0);
this.eachpipedsmallmemory = new Array(10).fill(null).map(() => 0);
this.pipedsmallmemory = 0;
this.worldopened = new Array(10).fill().map(() => false);
this.chipused = new Array(setchipkind).fill(0);
this.world = 0;
};
save() {
this.players[this.world] = this.player;
};
loadb(worldDatab) {
this.players = JSON.parse(atob(worldDatab));
this.loadPlayer(this.players[this.world]);
};
loadPlayerb(playerDatab) {
const saveData = JSON.parse(atob(playerDatab));
this.loadPlayer(saveData);
};
loadPlayer(playerData) {
this.player = {
money: D(playerData.money),
level: D(playerData.level),
levelresettime: D(playerData.levelresettime),
maxlevelgained: D(playerData.maxlevelgained ?? 1),
token: playerData.token ?? 0,
shine: playerData.shine ?? 0,
brightness: playerData.brightness ?? 0,
rank: D(playerData.rank ?? 0),
rankresettime: D(playerData.rankresettime ?? 0),
ranktoken: playerData.ranktoken ?? 0,
crown: D(playerData.crown ?? 0),
crownresettime: D(playerData.crownresettime ?? 0),
generators: playerData.generators.map(D),
generatorsBought: playerData.generatorsBought.map(D),
generatorsCost: playerData.generatorsCost.map(D),
generatorsMode: playerData.generatorsMode.map(v => parseInt(v)),
accelerators: playerData.accelerators.map(D),
acceleratorsBought: playerData.acceleratorsBought.map(D),
acceleratorsCost: playerData.acceleratorsCost.map(D),
darkmoney: D(playerData.darkmoney),
darkgenerators: playerData.darkgenerators.map(D),
darkgeneratorsBought: playerData.darkgeneratorsBought.map(D),
darkgeneratorsCost: playerData.darkgeneratorsCost.map(D),
darklevel: D(playerData.darklevel),
lightmoney: D(playerData.lightmoney ?? 0),
lightgenerators: playerData.lightgenerators.map(D),
lightgeneratorsBought: playerData.lightgeneratorsBought.map(D),
lightgeneratorsCost: playerData.lightgeneratorsCost.map(D),
tickspeed: parseFloat(playerData.tickspeed),
accelevel: playerData.accelevel ?? 0,
accelevelused: playerData.accelevelused ?? 0,
onchallenge: playerData.onchallenge ?? false,
challenges: numarr2boolarr(playerData.challenges, 8) ?? new Array(8).fill(false),
challengecleared: playerData.challengecleared ?? [],
challengebonuses: numarr2boolarr(playerData.challengebonuses, 15) ?? new Array(15).fill(false),
onpchallenge: playerData.onpchallenge ?? false,
pchallenges: numarr2boolarr(playerData.pchallenges, 8) ?? new Array(8).fill(false),
pchallengecleared: playerData.pchallengecleared ?? new Array(1024).fill(0),
prchallengecleared: playerData.prchallengecleared ?? new Array(1024).fill(0),
rankchallengecleared: playerData.rankchallengecleared ?? [],
rankchallengebonuses: numarr2boolarr(playerData.rankchallengebonuses, 15) ?? new Array(15).fill(false),
trophies: playerData.trophies ?? new Array(trophynum).fill(false),
smalltrophies: playerData.smalltrophies ?? new Array(100).fill(false),
smalltrophies2nd: playerData.smalltrophies2nd ?? new Array(100).fill(false),
levelitems: playerData.levelitems ?? new Array(5).fill(0),
levelitembought: playerData.levelitembought ?? 0,
remember: playerData.remember ?? 0,
rememberspent: playerData.rememberspent ?? 0,
chip: playerData.chip ?? new Array(setchipkind).fill(0),
setchip: playerData.setchip ?? new Array(setchipnum).fill(0),
disabledchip: playerData.disabledchip ?? new Array(setchipnum).fill(false),
statue: playerData.statue ?? new Array(setchipkind).fill(0),
worldpipe: playerData.worldpipe ?? new Array(10).fill(null).map(() => 0),
};
this.checkTrophies();
this.checkMemories();
this.checkSmallMemories();
this.checkUsedChips();
this.checkWorlds();
this.updateTickspeed();
this.checkPipedSmallMemories();
for (let i = 0; i < 8; i++) this.calcGeneratorCost(i, this.player.generatorsBought[i], true);
for (let i = 0; i < 8; i++) this.calcAcceleratorCost(i, this.player.acceleratorsBought[i], true);
for (let i = 0; i < 8; i++) this.calcDarkGeneratorCost(i, this.player.darkgeneratorsBought[i], true);
for (let i = 0; i < 8; i++) this.calcLightGeneratorCost(i, this.player.lightgeneratorsBought[i], true);
};
clone() {
let nig = new Nig();
nig.players = JSON.parse(JSON.stringify(this.players));
nig.world = this.world;
nig.loadPlayer(JSON.parse(JSON.stringify(this.player)));
return nig;
};
softCap(num, cap) {
if (num.lte(cap)) return num;
return cap.mul(D(num.div(cap).log2()).add(1)).min(num);
};
strongSoftcap(num, cap) {
if (num.lte(cap)) return num;
return cap.mul(D(D(num.div(cap).log2()).add(1).log2()).add(1)).min(num);
};
calcCommonMult() {
let mult = D(1);
if (!this.isChallengeActive(7)) {
const cap = D(100).mul(this.player.levelitems[2] * (1 + this.player.setchip[28] * 0.3) + 1);
mult = mult.mul(this.softCap(this.player.levelresettime.add(1), cap));
}
if (this.isChallengeBonusActive(3)) mult = mult.mul(D(2));
if (this.isRankChallengeBonusActive(3)) mult = mult.mul(D(3));
if (this.isPerfectChallengeActive(0)) mult = mult.div(100);
let x1 = 0.25;
let x2 = 12;
if (this.isPerfectChallengeActive(7)) {
x1 = 1.0 / 81;
x2 = 27;
}
mult = mult.mul(1 + this.smallmemory * 0.01 + this.memory * x1);
if (this.isRankChallengeBonusActive(11))
mult = mult.mul(D(2).pow(D(this.memory).div(x2)));
mult = mult.mul(1 + Math.sqrt(this.pipedsmallmemory));
if (this.player.onchallenge && this.isRankChallengeBonusActive(4)) {
let cnt = 0;
this.player.challenges.forEach(b => cnt += b ? 1 : 0);
mult = mult.mul(1 + cnt * 0.25);
}
if (!this.isPerfectChallengeActive(8) && this.player.darkmoney.gte(1))
mult = mult.mul(D(this.player.darkmoney.add(10).log10()).pow(1 + this.player.setchip[40] * 0.1));
if (this.isRankChallengeBonusActive(9)) {
mult = mult.mul(this.multbyac);
if (this.multbyac.gt(1)) mult = mult.mul(this.multbyac);
}
mult = mult.mul(1 + this.player.setchip[0] * 0.1);
let camp = this.player.accelevelused;
let d = new Date();
// if (d.getMonth() == 0 && d.getDate() <= 7) camp = camp + 1;
// if (d.getMonth() == 1 && 8 <= d.getDate() && d.getDate() <= 14) camp = camp + 1;
// if ((d.getMonth() == 1 && 25 <= d.getDate()) || ((d.getMonth() == 2 && d.getDate() <= 3))) camp = camp + 1;
if ((d.getMonth() == 6 && 27 <= d.getDate()) || ((d.getMonth() == 7 && d.getDate() < 27))) camp = camp + 2;
if (camp > 6) camp = 6;
mult = mult.mul(1 + 4 * camp);
this.commonmult = mult;
};
calcBasicIncrementMult(i, highest) {
let mult = this.commonmult;
if (!this.isChallengeActive(2)) {
if ((i < highest || this.isChallengeBonusActive(2)) && this.player.generatorsBought[i].gt(0)) {
let mm = this.player.generatorsBought[i];
if (this.isChallengeBonusActive(11)) mm = mm.mul(mm.add(2).log2());
mult = mult.mul(mm);
}
}
if (i == 0 && this.isChallengeBonusActive(7)) {
if (this.isRankChallengeBonusActive(7))
mult = mult.mul(this.strongSoftcap(this.player.maxlevelgained, D(100000)));
else
mult = mult.mul(this.player.maxlevelgained.min(100000));
}
if (!this.isPerfectChallengeActive(8) && this.player.darkgenerators[i].gte(1))
mult = mult.mul(D(i + 2 + this.player.darkgenerators[i].log10()).pow(1 + this.player.setchip[i + 32] * 0.25));
mult = mult.mul(1 + this.player.setchip[i + 1] * 0.5);
if (this.isPerfectChallengeActive(2)) {
this.incrementalmults[2] = D(0);
this.incrementalmults[5] = D(0);
}
this.incrementalmults[i] = mult;
};
calcIncrementMult(mu, i, to) {
let mult = mu.mul(this.incrementalmults[i]);
if (!this.isChallengeActive(4))
mult = mult.mul(D(10).pow((i + 1) * (i - to)));
let lv = D(this.player.level.pow(1 + 0.5 * this.player.setchip[19]).add(2).log2());
let rk = this.player.rank.add(2).div(262142).log2();
rk += D(this.player.rank.add(2).log2()).log2() * this.player.setchip[23];
mult = mult.mul(D(lv.pow((i - to) * (1 + Math.max(rk, 0) * 0.05))));
if (this.isPerfectChallengeActive(3) && mult.gt('1e-100')) {
let b = Math.floor(mult.log10() / 6);
mult = D(10).pow(b * 6);
}
return mult;
};
calcGeneratorExpr(mu = D(1)) {
this.calcCommonMult();
let highest = 0;
for (let i = 0; i < 8; i++) if (this.player.generators[i].gt(0)) highest = i;
for (let i = 0; i < 8; i++) this.calcBasicIncrementMult(i, highest);
let g = Array.from(new Array(9), (_, i) => new Array(Math.max(0, highest + 2 - i)).fill(D(0)));
g[0][0] = this.player.money;
for (let i = 0; i <= highest; i++) g[i + 1][0] = this.player.generators[i];
for (let i = highest + 1; i-- > 0;) {
if (!this.isChallengeBonusActive(13)) {
const to = this.player.generatorsMode[i];
const mult = this.calcIncrementMult(mu, i, to);
g[i + 1].forEach((gg, j) => g[to][j + 1] = g[to][j + 1].add(gg.mul(mult)));
} else if (this.isChallengeActive(3)) {
const to = 0;
const mult = this.calcIncrementMult(mu, i, to).mul(i + 1);
g[i + 1].forEach((gg, j) => g[to][j + 1] = g[to][j + 1].add(gg.mul(mult)));
} else {
for (let to = 0; to <= i; to++) {
const mult = this.calcIncrementMult(mu, i, to);
g[i + 1].forEach((gg, j) => g[to][j + 1] = g[to][j + 1].add(gg.mul(mult)));
}
}
while (g[i].length > 0 && g[i][g[i].length - 1].eq(0)) g[i].pop();
}
return g;
};
calcAcceleratorExpr(mu = D(1)) {
let highest = 0;
for (let i = 1; i < 8; i++) if (this.player.accelerators[i].gt(0)) highest = i;
let a = Array.from(new Array(8), (_, i) => new Array(Math.max(0, highest + 1 - i)).fill(D(0)));
for (let i = 0; i <= highest; i++) a[i][0] = this.player.accelerators[i];
for (let i = highest + 1; i-- > 1;) {
let mult = mu;
if (i == 1 ? this.isChallengeBonusActive(10) : this.isRankChallengeBonusActive(6))
if (this.isRankChallengeBonusActive(10))
mult = mult.add(this.player.acceleratorsBought[i].pow_base(2));
else
mult = mult.add(this.player.acceleratorsBought[i]);
mult = mult.mul(D(1.5).pow(this.player.setchip[i + 10]));
mult = mult.mul(1 + this.eachpipedsmallmemory[1] * 0.2);
a[i].forEach((aa, j) => a[i - 1][j + 1] = a[i - 1][j + 1].add(aa.mul(mult)));
while (a[i - 1].length > 0 && a[i - 1][a[i - 1].length - 1].eq(0)) a[i - 1].pop();
}
return a;
};
calcDarkGeneratorExpr(mu = D(1)) {
let highest = 0;
for (let i = 0; i < 8; i++) if (this.player.darkgenerators[i].gt(0)) highest = i;
let d = Array.from(new Array(9), (_, i) => new Array(Math.max(0, highest + 2 - i)).fill(D(0)));
d[0][0] = this.player.darkmoney;
for (let i = 0; i <= highest; i++) d[i + 1][0] = this.player.darkgenerators[i];
const darkmult = this.softCap(this.player.darklevel.add(1), D(1e3));
for (let i = highest + 1; i-- > 0;) {
let mult = mu.mul(this.player.lightgenerators[i].add(1));
mult = mult.mul(darkmult);
mult = mult.mul(1 + this.player.setchip[41 + i] * 0.25);
mult = mult.mul(1 + this.eachpipedsmallmemory[5] * 0.2);
d[i + 1].forEach((dd, j) => d[i][j + 1] = d[i][j + 1].add(dd.mul(mult)));
while (d[i].length > 0 && d[i][d[i].length - 1].eq(0)) d[i].pop();
}
return d;
};
static calcAfterNtick(expr, n) {
let p = D(1);
let res = D(0);
for (let i = 0; i < expr.length; i++) {
res = res.add(expr[i].mul(p));
p = p.mul(n.sub(i)).div(i + 1);
}
return res;
};
updateGenerators(mu = D(1), tick = D(1), gexpr = this.calcGeneratorExpr(mu)) {
this.player.money = Nig.calcAfterNtick(gexpr[0], tick);
for (let i = 0; i < 8; i++) this.player.generators[i] = Nig.calcAfterNtick(gexpr[i + 1], tick);
};
basetick() {
const challengebonusescount = this.player.challengebonuses.reduce((x, y) => x + (y ? 1 : 0), 0);
let tick_speed = 1000;
if (this.isPerfectChallengeActive(1)) tick_speed = 10000;
tick_speed += 500 * this.player.accelevelused;
return tick_speed - this.player.setchip[9] * 50 - this.player.levelitems[1] * challengebonusescount * (1 + this.player.setchip[27] * 0.5);
};
updateTickspeed() {
const amult = this.isChallengeBonusActive(6) ? (this.isRankChallengeBonusActive(10) ? this.player.acceleratorsBought[0].pow_base(2) : this.player.acceleratorsBought[0].add(1)) : D(1);
let acnum = this.player.accelerators[0].mul(D(1.5).pow(this.player.setchip[10]));
if (this.isRankChallengeBonusActive(13)) {
for (let i = 1; i < 8; i++) acnum = acnum.mul(this.player.accelerators[i].add(1));
}
this.player.tickspeed = this.basetick() / acnum.add(10).mul(amult).log10();
this.multbyac = D(50).div(this.player.tickspeed);
};
updateAccelerators(mu = D(1), tick = D(1), aexpr = this.calcAcceleratorExpr(mu)) {
for (let i = 0; i < 8; i++) this.player.accelerators[i] = Nig.calcAfterNtick(aexpr[i], tick);
this.updateTickspeed();
};
updateDarkGenerators(mu = D(1), tick = D(1), dexpr = this.calcDarkGeneratorExpr(mu)) {
this.player.darkmoney = Nig.calcAfterNtick(dexpr[0], tick);
for (let i = 0; i < 8; i++) this.player.darkgenerators[i] = Nig.calcAfterNtick(dexpr[i + 1], tick);
};
spendShine(num) {
if (this.player.shine < num) return;
if (this.isPerfectChallengeActive(6)) return;
this.player.shine -= num;
const val = D(11 + this.player.setchip[31]).pow(D(num).log10());
this.updateGenerators(val);
this.updateAccelerators(val);
};
spendBrightness(num) {
if (this.player.brightness < num) return;
if (this.isPerfectChallengeActive(6)) return;
this.player.brightness -= num;
const val = D(11 + this.player.setchip[50]).pow(D(num * 100).log10());
const vald = D(10 + this.player.setchip[51] * 0.25).pow(D(num).log10());
this.updateGenerators(val);
this.updateAccelerators(val);
this.updateDarkGenerators(vald);
};
isChallengeActive(index) {
return this.player.onchallenge && this.player.challenges[index]
};
isChallengeBonusActive(index) {
return this.player.challengebonuses[4] || !this.player.onchallenge ? this.player.challengebonuses[index] : false;
};
isRankChallengeBonusActive(index) {
return this.player.rankchallengebonuses[index];
};
isPerfectChallengeActive(index) {
return this.player.onpchallenge && this.player.pchallenges[index];
};
isGeneratorBuyable(index) {
if (this.isChallengeActive(6)) if (index == 3 || index == 7) return false;
return this.player.money.gte(this.player.generatorsCost[index]);
};
calcGeneratorCost(index, bought, update = false) {
const mult = bought.neq(0) && this.isChallengeActive(1) ? 2 : 1;
let p = (index === 0 ? bought : bought.add(index + 1).mul(index + 1)).mul(mult);
p = p.sub(this.eachpipedsmallmemory[0] * 0.2);
const cost = p.pow_base(10);
if (update) this.player.generatorsCost[index] = cost;
return cost;
};
buyGenerator(index) {
if (!this.isGeneratorBuyable(index)) return false;
this.player.money = this.player.money.sub(this.player.generatorsCost[index]);
this.player.generators[index] = this.player.generators[index].add(1);
this.player.generatorsBought[index] = this.player.generatorsBought[index].add(1);
this.calcGeneratorCost(index, this.player.generatorsBought[index], true);
return true;
};
isAcceleratorOpened(index) {
if (index >= 1 && this.player.levelresettime.lte(0)) return false;
if (index >= 2 && this.player.levelitems[3] + 1 < index) return false;
return true;
};
isAcceleratorBuyable(index) {
if (this.isChallengeActive(5)) return false;
if (!this.isAcceleratorOpened(index)) return false;
return this.player.money.gte(this.player.acceleratorsCost[index]);
};
calcAcceleratorCost(index, bought, update = false) {
let p = bought.add(1);
p = p.mul(p.add(1)).div(2);
p = p.mul(index === 0 ? 1 : D(10).mul(D(2).pow(index - 1)));
p = p.sub(this.eachpipedsmallmemory[3] * 0.2 * (index + 1));
const cost = p.pow_base(10);
if (update) this.player.acceleratorsCost[index] = cost;
return cost;
};
buyAccelerator(index) {
if (!this.isAcceleratorBuyable(index)) return false;
this.player.money = this.player.money.sub(this.player.acceleratorsCost[index]);
this.player.accelerators[index] = this.player.accelerators[index].add(1);
this.player.acceleratorsBought[index] = this.player.acceleratorsBought[index].add(1);
this.calcAcceleratorCost(index, this.player.acceleratorsBought[index], true);
return true;
};
isDarkGeneratorBuyable(index) {
return this.player.money.gte(this.player.darkgeneratorsCost[index]);
};
calcDarkGeneratorCost(index, bought, update = false) {
let p = 100 + (index == 0 ? 0 : (index + 1) * (index + 1) * (index + 1));
let q = bought.mul(index + 1).mul(index + 1);
q = q.add(p);
q = q.sub(this.eachpipedsmallmemory[8] * 0.02 * (index + 1) * (index + 1));
const cost = D(10).pow(q);
if (update) this.player.darkgeneratorsCost[index] = cost;
return cost;
};
buyDarkGenerator(index) {
if (!this.isDarkGeneratorBuyable(index)) return false;
this.player.money = this.player.money.sub(this.player.darkgeneratorsCost[index]);
this.player.darkgenerators[index] = this.player.darkgenerators[index].add(1);
this.player.darkgeneratorsBought[index] = this.player.darkgeneratorsBought[index].add(1);
this.calcDarkGeneratorCost(index, this.player.darkgeneratorsBought[index], true);
return true;
};
isLightGeneratorBuyable(index) {
return this.player.money.gte(this.player.lightgeneratorsCost[index]);
};
calcLightGeneratorCost(index, bought, update = false) {
let p = 200 + (index === 0 ? 0 : (index + 1) * (index + 1) * (index + 1) * (index + 1));
let q = bought.mul(index + 1).mul(index + 1).mul(index + 1);
q = q.add(p);
const cost = D(10).pow(q);
if (update) this.player.lightgeneratorsCost[index] = cost;
return cost;
};
buyLightGenerator(index) {
if (!this.isLightGeneratorBuyable(index)) return false;
this.player.money = this.player.money.sub(this.player.lightgeneratorsCost[index]);
this.player.lightgenerators[index] = this.player.lightgenerators[index].add(1);
this.player.lightgeneratorsBought[index] = this.player.lightgeneratorsBought[index].add(1);
this.calcLightGeneratorCost(index, this.player.lightgeneratorsBought[index], true);
return true;
};
calcToken() {
const challenge_id = this.calcPerfectChallengeId();
let spent = 0;
this.player.challengebonuses.forEach((value, index) => {
if (value) {
spent += itemdata.rewardcost[index];
}
});
let t = this.player.challengecleared.length;
if (this.player.onpchallenge) {
t = Math.max(t, this.player.pchallengecleared[challenge_id]);
}
this.player.token = t - spent;
spent = 0;
this.player.rankchallengebonuses.forEach((value, index) => {
if (value) {
spent += itemdata.rewardcost[index];
}
});
t = this.player.rankchallengecleared.length;
if (this.player.onpchallenge) {
t = Math.max(t, this.player.prchallengecleared[challenge_id]);
}
this.player.ranktoken = t - spent;
};
isRewardToggleable(index) {
return this.player.challengebonuses[index] || (this.player.token >= itemdata.rewardcost[index]);
};
toggleReward(index) {
if (this.isRewardToggleable(index)) {
if (this.player.challengebonuses[index])
this.player.token += itemdata.rewardcost[index];
else
this.player.token -= itemdata.rewardcost[index];
this.player.challengebonuses[index] = !this.player.challengebonuses[index];
this.updateTickspeed();
}
};
isRankRewardToggleable(index) {
return this.player.rankchallengebonuses[index] || (this.player.ranktoken >= itemdata.rewardcost[index]);
};
toggleRankReward(index) {
if (this.isRankRewardToggleable(index)) {
if (this.player.rankchallengebonuses[index])
this.player.ranktoken += itemdata.rewardcost[index];
else
this.player.ranktoken -= itemdata.rewardcost[index];
this.player.rankchallengebonuses[index] = !this.player.rankchallengebonuses[index];
this.updateTickspeed();
}
};
isLevelitemBuyable(index) {
if (!this.player.rankresettime.gt(0)) return false;
const cost = this.calcLevelitemCost(index);
return !(this.player.level.lt(cost) || this.player.levelitems[index] >= 5);
};
calcLevelitemCost(index) {
const d = index + 1;
const cost = itemdata.levelitemcost[index].pow(this.player.levelitems[index] + 1);
let dec = 0;
for (let i = 1; i <= 5; i++) {
if (4 * i * i * d * d * d <= this.player.levelitembought) dec = i;
}
return cost.div(D(10).pow(dec)).max(1);
};
buyLevelitems(index) {
if (!this.player.rankresettime.gt(0)) return;
const cost = this.calcLevelitemCost(index);
if (this.player.level.lt(cost) || this.player.levelitems[index] >= 5) return;
this.player.level = this.player.level.sub(cost);
this.player.levelitems[index] = this.player.levelitems[index] + 1;
if (this.player.levelitembought < 100000) this.player.levelitembought = this.player.levelitembought + 1;
};
configChallenge(index) {
if (this.player.onchallenge) return;
this.player.challenges[index] = !this.player.challenges[index];
};
configPerfectChallenge(index) {
if (this.player.onpchallenge) return;
this.player.pchallenges[index] = !this.player.pchallenges[index];
};
isGeneratorModeChangeable() {
return !this.isChallengeActive(3) && !this.isChallengeBonusActive(13);
};
resetGeneratorMode() {
if (this.isGeneratorModeChangeable()) this.player.generatorsMode = new Array(8).fill().map((_, i) => i);
};
changeMode(index) {
if (this.isChallengeActive(3)) return;
this.player.generatorsMode[index] += 1;
if (this.player.generatorsMode[index] > index) {
this.player.generatorsMode[index] = 0;
}
};
calcGainLevel(x) {
const money = x === undefined ? this.player.money : x;
const dividing = Math.max(1, 19 - this.player.rank.add(2).log2());
let mny = money.log10() - 17;
mny = D(mny).pow(this.player.setchip[18]);
let gainlevel = D(money.mul(mny).log10()).div(dividing).pow_base(2);
const glmin = D(18).div(dividing).pow_base(2);
const glmax = this.player.maxlevelgained.div(2);
if (!glmin.add(0.1).gte(glmax)) {
if (gainlevel.lt(glmax)) {
let persent = D(1).sub(gainlevel.sub(glmin).div(glmax.sub(glmin)));
persent = persent.pow(1 + this.player.levelitems[0] * (1 + this.player.setchip[26] * 2));
persent = D(1).sub(persent);
if (gainlevel.neq(glmin) && persent.lt('1e-5')) {
gainlevel = gainlevel.mul(1 + this.player.levelitems[0] * (1 + this.player.setchip[26] * 2));
} else {
gainlevel = glmax.sub(glmin).mul(persent).add(glmin);
}
}
}
if (this.isPerfectChallengeActive(4)) gainlevel = D(gainlevel.log2()).max(1);
gainlevel = gainlevel.round().max(1);
gainlevel = gainlevel.mul(1 + this.eachpipedsmallmemory[2] * 0.2);
if (this.isChallengeBonusActive(12)) gainlevel = gainlevel.mul(2);
return gainlevel;
};
calcGainRank(x) {
const money = x === undefined ? this.player.money : x;
let dv = 36 - 0.25 * this.countRemembers() - 1.2 * this.player.levelitems[4] * (1 + 0.2 * this.player.setchip[29]);
dv = Math.max(dv, 6);
dv = dv - this.player.crown.add(2).log2() * 0.1;
dv = Math.max(dv, 3);
let gainrank = D(money.log10()).div(dv).pow_base(2).round();
if (this.isPerfectChallengeActive(5)) gainrank = D(gainrank.log10()).max(1);