forked from zhaolinxu/cat-zh
-
Notifications
You must be signed in to change notification settings - Fork 0
/
NummonCalc.js
894 lines (835 loc) · 41.9 KB
/
NummonCalc.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
dojo.declare("classes.managers.NummonStatsManager", com.nuclearunicorn.core.TabManager, {
game: null,
roundThisNumber: function(num){
num*=1000;
num+=.5;
num=Math.floor(num);
num/=1000;
return num;
},
getButton: function(tab, buttonName){
for(var i in this.game.tabs[tab].buttons){
if(this.game.tabs[tab].buttons[i].opts.building == buttonName)
return parseInt(i);
}
},
makeNiceString: function(num, numDigits = 3){
if(typeof(num) == "number" && num != Infinity){
num = num.toFixed(numDigits);
num = num.toString();
var decimal = num.substr(num.indexOf("."));
if(decimal == "." + Array(numDigits + 1).join("0"))
num = num.substr(0,num.indexOf("."));
for(var i = (num.indexOf(".") != -1 ? num.indexOf(".") - 3 : num.length - 3); i > 0; i -= 3)
num = num.substr(0,i) + "," + num.substr(i);
}
else
num = num.toString();
return num;
},
getBestUniBuilding: function(log=false){
var validBuildings = ["unicornTomb","ivoryTower","ivoryCitadel","skyPalace","unicornUtopia","sunspire"];
var pastureButton = this.getButton(0, "unicornPasture");
var unicornsPerSecond = this.game.getEffect("unicornsPerTickBase") * this.game.getRateUI();
var globalRatio = this.game.getEffect("unicornsGlobalRatio")+1;
var religionRatio = this.game.getEffect("unicornsRatioReligion")+1;
var paragonRatio = this.game.prestige.getParagonProductionRatio()+1;
var faithBonus = this.game.religion.getProductionBonus()/100+1;
var cycle = 1;
if(this.game.calendar.cycles[this.game.calendar.cycle].festivalEffects["unicorns"]!=undefined)
if(this.game.prestige.getPerk("numeromancy").researched && this.game.calendar.festivalDays)
cycle=this.game.calendar.cycles[this.game.calendar.cycle].festivalEffects["unicorns"];
var onZig = Math.max(this.game.bld.getBuildingExt("ziggurat").meta.on,1);
var total = unicornsPerSecond * globalRatio * religionRatio * paragonRatio * faithBonus * cycle;
var baseUnicornsPerRift = 500 * (1 + this.game.getEffect("unicornsRatioReligion") * 0.1);
var riftChanceRatio = 1;
if(this.game.prestige.getPerk("unicornmancy").researched)
riftChanceRatio *= 1.1;
var baseRift = this.game.getEffect("riftChance") * riftChanceRatio / (10000 * 2) * baseUnicornsPerRift;
if(log){
console.log("Unicorns per second: "+total);
console.log("Base rift per second average: "+baseRift);
}
var bestAmoritization = Infinity;
var bestBuilding = "";
var pastureAmor = this.game.bld.getBuildingExt("unicornPasture").meta.effects["unicornsPerTickBase"] * this.game.getRateUI();
pastureAmor = pastureAmor * globalRatio * religionRatio * paragonRatio * faithBonus * cycle;
if(log){
console.log("unicornPasture");
console.log("\tBonus unicorns per second: "+pastureAmor);
}
pastureAmor = this.game.tabs[0].buttons[pastureButton].model.prices[0].val / pastureAmor;
if(log){
var baseWait = gamePage.tabs[0].buttons[pastureButton].model.prices[0].val / total;
var avgWait = gamePage.tabs[0].buttons[pastureButton].model.prices[0].val / (total + baseRift);
console.log("\tMaximum time to build: " + gamePage.toDisplaySeconds(baseWait) + " | Average time to build: " + gamePage.toDisplaySeconds(avgWait));
console.log("\tPrice: "+gamePage.tabs[0].buttons[pastureButton].model.prices[0].val+" | Amortization: "+gamePage.toDisplaySeconds(pastureAmor));
}
if(pastureAmor < bestAmoritization){
bestAmoritization = pastureAmor;
bestBuilding = "独角兽牧场";
}
for(var i in this.game.tabs[5].zgUpgradeButtons){
var btn = this.game.tabs[5].zgUpgradeButtons[i];
if(validBuildings.indexOf(btn.id)!=-1){
if(btn.model.visible){
unicornPrice = 0;
for(var j in btn.model.prices){
if(btn.model.prices[j].name=="unicorns")
unicornPrice += btn.model.prices[j].val;
if(btn.model.prices[j].name=="tears")
unicornPrice += btn.model.prices[j].val * 2500 / onZig;
}
var bld=this.game.religion.getZU(btn.id);
var relBonus = religionRatio;
var riftChance = this.game.getEffect("riftChance");
for(var j in bld.effects){
if(j=="unicornsRatioReligion")
relBonus += bld.effects[j]
if(j=="riftChance")
riftChance += bld.effects[j];
}
var unicornsPerRift = 500 * ((relBonus -1) * 0.1 +1);
var riftBonus = riftChance * riftChanceRatio / (10000 * 2) * unicornsPerRift;
riftBonus -= baseRift;
var amor = unicornsPerSecond * globalRatio * relBonus * paragonRatio * faithBonus * cycle;
amor -= total;
amor = amor + riftBonus;
if(log){
console.log(btn.id);
console.log("\tBonus unicorns per second: "+amor);
}
amor = unicornPrice / amor;
if(log){
var baseWait = unicornPrice / total;
var avgWait = unicornPrice / (total + baseRift);
var amorSeconds = gamePage.toDisplaySeconds(amor);
if(amorSeconds == "")
amorSeconds = "NA";
console.log("\tMaximum time to build: " + gamePage.toDisplaySeconds(baseWait) + " | Average time to build: " + gamePage.toDisplaySeconds(avgWait));
console.log("\tPrice: "+unicornPrice + " | Amortization: "+amorSeconds);
}
if(amor < bestAmoritization)
if(riftBonus > 0 || relBonus > religionRatio && unicornPrice > 0){
bestAmoritization = amor;
var cnid = "";
if(btn.id == "unicornTomb")
{cnid='独角兽坟墓';}
if(btn.id == "ivoryTower")
{cnid='象牙塔';}
if(btn.id == "ivoryCitadel")
{cnid='象牙城堡';}
if(btn.id == "skyPalace")
{cnid='天空宫殿';}
if(btn.id == "unicornUtopia")
{cnid='独角兽理想国';}
if(btn.id == "sunspire")
{cnid='青睐之光';}
bestBuilding = cnid;
}
}
}
}
return bestBuilding;
},
getUraniumForThoriumReactors: function(){
var needed = 250 * .1875 * this.game.bld.getBuildingExt("reactor").meta.val;
needed /= 1 + this.game.getResCraftRatio({name:"thorium"});
needed = Math.round(needed * 1000) / 1000;
return needed;
},
getBlueprintCraft: function(){
return 1 + this.game.getResCraftRatio({ name: "blueprint" });
},
getPraiseLoss: function(){
var tier = this.game.religion.getTranscendenceLevel() + 1;
var tt=game.religion.getTranscendenceRatio(tier)-game.religion.getTranscendenceRatio(tier-1);
var perc = this.game.religion.faithRatio / tt * 100;
var before = Math.round(this.game.religion.getTriValueReligion(tt * perc / 100) * 100);
var after = Math.round(game.religion.getTriValueReligion(tt * (perc - 100) / 100) * 100);
var loss = Math.round(before - after);
var lossRatio = 100 * loss / before;
perc = Math.round(perc * 1000) / 1000;
return perc + "%";
/*var str = "To tier: ";
str += tier;
str += "\n Progress: ";
str += this.makeNiceString(perc);
str += "%\n Before: ";
str += this.makeNiceString(before);
str += "%\n After: ";
str += this.makeNiceString(after);
str += "%\n Loss: ";
str += this.makeNiceString(loss);
str += "%\n Loss ratio: ";
str += this.makeNiceString(lossRatio);
str += "%";
return str;*/
},
getNecrocornsPerSecond: function(){
var numAlicorns = this.game.resPool.get("alicorn").value;
var curCorruption = this.game.religion.corruption;
var blsBoost = 1 + Math.sqrt(this.game.resPool.get("sorrow").value * this.game.getEffect("blsCorruptionRatio"));
var corruptionRate = 1;
if(this.game.resPool.get("necrocorn").value > 0)
corruptionRate = 0.25 * (1+ this.game.getEffect("corruptionBoostRatio"));
corruptionRate *= this.game.getEffect("corruptionRatio") * blsBoost;
if(numAlicorns <= 0){
curCorruption = 0;
corruptionRate = 0;
}
corruptionRate *= this.game.getRateUI();
corruptionRate = Math.floor(corruptionRate * 100000) / 100000;
if(corruptionRate == Infinity)
return "Infinity";
return corruptionRate + "/秒";
},
getNecrocornTime: function(){
var numAlicorns = this.game.resPool.get("alicorn").value;
var curCorruption = this.game.religion.corruption;
var blsBoost = 1 + Math.sqrt(this.game.resPool.get("sorrow").value * this.game.getEffect("blsCorruptionRatio"));
var corruptionRate = 1;
if(this.game.resPool.get("necrocorn").value > 0)
corruptionRate = 0.25 * (1 + this.game.getEffect("corruptionBoostRatio"));
corruptionRate *= this.game.getEffect("corruptionRatio") * blsBoost;
if(numAlicorns <= 0){
curCorruption = 0;
corruptionRate = 0;
}
if(corruptionRate == 0)
return "Infinity";
return this.game.toDisplaySeconds( (1 - curCorruption) / (corruptionRate * this.game.getRateUI()) );
},
getLeviChance: function(){
var numPyramids = this.game.religion.getZU("blackPyramid").val;
var numMarkers = this.game.religion.getZU("marker").val;
var chance = this.roundThisNumber(35 * numPyramids * (1 + 0.1 * numMarkers) / 10);
return chance + "%";
},
getReligionProductionBonusCap: function(){
var transcendTier = this.game.religion.getTranscendenceLevel();
var numObelisks = this.game.religion.getTU("blackObelisk").val;
var atheismBonus = 0;
if((this.game.challenges.getChallenge("atheism").researched))
atheismBonus = this.game.religion.getTranscendenceLevel() * 0.1;
var result = 1000 * (transcendTier * numObelisks * .005 + atheismBonus + 1);
return result + "%";
},
getCelestialPerDay: function(){
var chanceRatio = 1;
if(this.game.prestige.getPerk("chronomancy").researched)
chanceRatio *= 1.1;
chanceRatio *= 1 + this.game.getEffect("timeRatio") * 0.25;
var chance = 25;
chance += this.game.getEffect("starEventChance") * 10000;
chance *= chanceRatio;
if(this.game.prestige.getPerk("astromancy").researched)
chance *= 2;
chance = Math.round(chance);
chance /= 100;//It's out of 10,000 originally
return chance + "%";
},
getCelestialAutoSuccess: function(){
var autoChance = this.game.getEffect("starAutoSuccessChance") * 100;
if(this.game.prestige.getPerk("astromancy").researched)
autoChance *= 2;
if(autoChance > 100)
autoChance = 100;
return autoChance + "%";
},
getTitPerZebraTrade: function(){
var titaniumPerTrade = this.game.resPool.get("ship").value / 100 * 1.5 * 2 + 1.5;
return titaniumPerTrade;
},
getZebraTradesToMaxTit: function(){
var titaniumPerTrade = this.getTitPerZebraTrade();
var maxTitanium = this.game.resPool.get("titanium").maxValue;
return Math.ceil(maxTitanium / titaniumPerTrade);
},
getZebraTradesLeftToMaxTit: function(){
var titaniumPerTrade = this.getTitPerZebraTrade();
var titToFill = this.game.resPool.get("titanium").maxValue;
titToFill -= this.game.resPool.get("titanium").value;
titToFill = Math.ceil(titToFill / titaniumPerTrade);
if(titToFill < 0)
titToFill = 0;
return titToFill;
},
getTCPerSacrifice: function(){
var numTCPerSacrifice = 1;
numTCPerSacrifice += this.game.getEffect("tcRefineRatio");
return numTCPerSacrifice;
},
getRelicPerTCRefine: function(){
return 1 + game.getEffect("relicRefineRatio") * game.religion.getZU("blackPyramid").val;
},
setCatnipArray: function(finalResult, theoreticalQuantity, actualQuantity, operation = "*"){
actualQuantity = actualQuantity || theoreticalQuantity;
for(var season in finalResult["theoretical"])
for(var weather in finalResult["theoretical"][season]){
switch(operation){
case "+":
finalResult["theoretical"][season][weather] += theoreticalQuantity;
break;
case "-":
finalResult["theoretical"][season][weather] -= theoreticalQuantity;
break;
case "/":
finalResult["theoretical"][season][weather] /= theoreticalQuantity;
break;
default:
finalResult["theoretical"][season][weather] *= theoreticalQuantity;
}
}
for(var season in finalResult["actual"])
for(var weather in finalResult["actual"][season]){
switch(operation){
case "+":
finalResult["actual"][season][weather] += actualQuantity;
break;
case "-":
finalResult["actual"][season][weather] -= actualQuantity;
break;
case "/":
finalResult["actual"][season][weather] /= actualQuantity;
break;
default:
finalResult["actual"][season][weather] *= actualQuantity;
}
}
},
getCatnipInSeasons: function(log = false){
var finalResult = {theoretical: {},
actual: {}};
var catnip = this.game.resPool.get("catnip");
//Buildings
var theoreticalCatnipPerTickBase = this.game.bld.get("field").effects["catnipPerTickBase"];
var numFields = this.game.bld.get("field").on;
var theoreticalCatnipPerTickTotal = theoreticalCatnipPerTickBase * numFields;
var actualCatnipPerTickTotal = this.game.getEffect("catnipPerTickBase");
if(log)
console.log("---INITIAL CATH BUILDING PRODUCTION---" +
"\nCatnip per field per tick: " + theoreticalCatnipPerTickBase +
"\nNumber of fields: " + numFields +
"\nTotal theoretical catnip from fields per tick: " + theoreticalCatnipPerTickTotal +
"\nActual catnip from fields per tick: " + actualCatnipPerTickTotal);
//Space ratio - does nothing. Skipping.
//=========================================================================================
//Add space catnip to normal - does nothing. Skipping.
//=========================================================================================
//Weather effects
if(log)
console.log("---SETTING UP SEASONS AND WEATHER---");
var weather = {normal: 0,
warm: 0.15,
cold: -0.15};
var seasons = this.game.calendar.seasons;
for(var i in seasons){
finalResult["theoretical"][seasons[i].name] = {};
finalResult["actual"][seasons[i].name] = {};
for(var j in weather){
finalResult["theoretical"][seasons[i].name][j] = (seasons[i].modifiers["catnip"] || 1) + weather[j];
if(finalResult["theoretical"][seasons[i].name][j] < -0.95)
finalResult["theoretical"][seasons[i].name][j] = -0.95;
finalResult["theoretical"][seasons[i].name][j] *= theoreticalCatnipPerTickTotal;
finalResult["actual"][seasons[i].name][j] = (seasons[i].modifiers["catnip"] || 1) + weather[j];
if(finalResult["actual"][seasons[i].name][j] < -0.95)
finalResult["actual"][seasons[i].name][j] = -0.95;
finalResult["actual"][seasons[i].name][j] *= actualCatnipPerTickTotal;
}
}
//Village job production
var numFarmers = this.game.village.getJob("farmer").value;
var theoreticalVillageProduction = 1 * numFarmers;//1 catnip per tick per farmer
var actualVillageProduction = this.game.village.getResProduction()["catnip"] || 0;
this.setCatnipArray(finalResult, theoreticalVillageProduction, actualVillageProduction, "+");
if(log)
console.log("---VILLAGE PRODUCTION (Adds to previous totals)---" +
"\nNumber of farmers in village: " + numFarmers +
"\nCatnip produced by farmers in theory (1 per tick per farmer): " + theoreticalVillageProduction +
"\nActual catnip produced by farmers: " + actualVillageProduction);
//Village job production workshop modifiers
var workshopJobModifier = this.game.getEffect("catnipJobRatio");
this.setCatnipArray(finalResult, theoreticalVillageProduction * workshopJobModifier,
actualVillageProduction * workshopJobModifier, "+");
if(log)
console.log("---VILLAGE PRODUCTION BONUS (Adds to previous totals)---" +
"\nModifier from workshop: " + workshopJobModifier +
"\nTheoretical bonus: " + (theoreticalVillageProduction * workshopJobModifier) +
"\nActual bonus: " + (actualVillageProduction * workshopJobModifier));
//Production boost - doesn't do anything right now. Skipping.
//=========================================================================================
//Building and space production
var aqueduct = this.game.bld.get("aqueduct");
var numAqueduct = aqueduct.on;
var aqueductRatio = aqueduct.stages[aqueduct.stage].effects["catnipRatio"] || 0;
var hydroponics = this.game.space.getBuilding("hydroponics");
var numHydroponics = hydroponics.on;
var theoreticalBuildingRatio = aqueductRatio * numAqueduct;
theoreticalBuildingRatio += hydroponics.effects["catnipRatio"] * numHydroponics;
theoreticalBuildingRatio += 1;
var actualBuildingRatio = 1 + this.game.getEffect("catnipRatio");
this.setCatnipArray(finalResult, theoreticalBuildingRatio, actualBuildingRatio);
if(log)
console.log("---CATH AND SPACE PRODUCTION MULTIPLIERS---" +
"\nNumber of Aqueducts: " + numAqueduct +
"\n-The following Aqueduct ratio will be zero if you've upgraded to Hydro Farms-" +
"\nMulitipler per Aqueduct: " + aqueductRatio +
"\nTotal multiplier from Aqueducts: " + (aqueductRatio * numAqueduct) +
"\nNumber of Hydroponics (space): " + numHydroponics +
"\nMultiplier per Hydroponics: " + hydroponics.effects["catnipRatio"] +
"\nTotal multiplier from Hydroponics: " + (hydroponics.effects["catnipRatio"] * numHydroponics) +
"\nFinal theoretical building ratio: x" + theoreticalBuildingRatio +
"\nActual building ratio: x" + actualBuildingRatio);
//Religion modifiers - doesn't do anything right now. Skipping.
//=========================================================================================
//...Super Ratio? Doesn't seem to have anything for it. Skipping.
//=========================================================================================
//This would be steamworks here, but in the base it's a hack to only affect coal - skipping
//=========================================================================================
//Paragon bonus
var paragonProd = 1 + this.game.prestige.getParagonProductionRatio();
if(this.game.challenges.currentChallenge == "winterIsComing")//If we're in this challenge - after challenge rework,
paragonProd = 0; //it will need to be reworked
this.setCatnipArray(finalResult, paragonProd);
if(log)
console.log("---PARAGON MULTIPLIER---" +
"\nParagon production ratio: " + (100 + 100 * paragonProd) + "%");
//Paragon... Space production? Does nothing for catnip. Skipping.
//=========================================================================================
//Magnetos Boost - specifically does not affect catnip. Skipping.
//=========================================================================================
//Reactor production bonus - specifically does not affect catnip. Skipping.
//=========================================================================================
//SR Faith bonus
var srBonus = 1 + this.game.religion.getProductionBonus() / 100;
this.setCatnipArray(finalResult, srBonus);
if(log)
console.log("---SOLAR REVOLUTION MULTIPLIER---" +
"\nSolar Revolution bonus: " + (100 * srBonus) + "%");
//Cosmic radiation, most people will probably have this disabled
if(!this.game.opts.disableCMBR){
this.setCatnipArray(finalResult,1 + this.game.getCMBRBonus());
if(log)
console.log("---COSMIC RADIATION BONUS (offline progression)---" +
"\nCosmic Radiation Bonus Ratio: " + (100 + 100 * this.game.getCMBRBonus()) + "%");
}
//Last section of paragon space production - does nothing. Skipping.
//=========================================================================================
//Automated production building (catnipPerTickProd) - does nothing. Skipping.
//=========================================================================================
//Automated space production, full bonus - does nothing. Skipping.
//=========================================================================================
//Cycle effects - set in space buildings, none of which produce catnip themselves
//=========================================================================================
//Cycle festival effects
for(var season in finalResult["theoretical"])
for(var weather in finalResult["theoretical"][season]){
var tempEffect = {catnip: finalResult["theoretical"][season][weather]};
this.game.calendar.cycleEffectsFestival(tempEffect);
finalResult["theoretical"][season][weather] = tempEffect["catnip"];
}
for(var season in finalResult["actual"])
for(var weather in finalResult["actual"][season]){
var tempEffect = {catnip: finalResult["actual"][season][weather]};
this.game.calendar.cycleEffectsFestival(tempEffect);
finalResult["actual"][season][weather] = tempEffect["catnip"];
}
if(log)
console.log("---CYCLE FESTIVAL EFFECTS---" +
"\nCharon is x1.5 to catnip. All others do nothing." +
"\nAre we in Charon right now? " + (this.game.calendar.cycle == 0 ? "Yes" : "No"));
//Building and space pertick - does nothing. Skipping.
//=========================================================================================
//Consumption
//Theoretical
var numKittens = this.game.village.sim.kittens.length;
var theoreticalCatnipConsumption = -0.85 * numKittens;
var pastures = this.game.bld.get("pasture");
var numPastures = pastures.on;
var unicPastures = this.game.bld.get("unicornPasture");
var numUnicPastures = unicPastures.on;
var theoreticalCatnipConsReduction = pastures.effects["catnipDemandRatio"] * numPastures;
theoreticalCatnipConsReduction += unicPastures.effects["catnipDemandRatio"] * numUnicPastures;
theoreticalCatnipConsReduction = this.game.getHyperbolicEffect(theoreticalCatnipConsReduction, 1);
var theoreticalReducedCatnipConsReduction = theoreticalCatnipConsReduction;
theoreticalCatnipConsumption *= 1 + theoreticalCatnipConsReduction
var theoreticalHappinessModifier = 0;
if(numKittens > 0 && this.game.village.happiness > 1){
var theoreticalHappinessConsumption = Math.max(this.game.village.happiness - 1, 0);
var theoreticalWorkerRatio = 1 + (this.game.workshop.get("assistance").researched ? -0.25 : 0);
if(this.game.challenges.currentChallenge == "anarchy")
theoreticalHappinessModifier = theoreticalCatnipConsumption * theoreticalHappinessConsumption *
theoreticalWorkerRatio;
else
theoreticalHappinessModifier = theoreticalCatnipConsumption * theoreticalHappinessConsumption *
theoreticalWorkerRatio *
(1 - this.game.village.getFreeKittens() / numKittens);
}
theoreticalCatnipConsumption += theoreticalHappinessModifier;
//Actual
var actualCatnipConsumption = this.game.village.getResConsumption()["catnip"] || 0;
actualCatnipConsumption *= 1 + this.game.getEffect("catnipDemandRatio");
var actualHappinessModifier = 0;
if(numKittens > 0 && this.game.village.happiness > 1){
var actualHappinessConsumption = Math.max(this.game.village.happiness - 1, 0);
if(this.game.challenges.currentChallenge == "anarchy")
actualHappinessModifier = actualCatnipConsumption * actualHappinessConsumption *
(1 + this.game.getEffect("catnipDemandWorkerRatioGlobal"));
else
actualHappinessModifier = actualCatnipConsumption * actualHappinessConsumption *
(1 + this.game.getEffect("catnipDemandWorkerRatioGlobal")) *
(1 - this.game.village.getFreeKittens() / numKittens);
}
actualCatnipConsumption += actualHappinessModifier;
this.setCatnipArray(finalResult, theoreticalCatnipConsumption, actualCatnipConsumption, "+");
if(log)
console.log("---VILLAGE KITTEN CONSUMPTION (Adds to previous total)---" +
"\nNumber of kittens: " + numKittens +
"\nTheoretical demand per kitten per tick: " + (-0.85) +
"\nTotal initial theoretical demand: " + (-0.85 * numKittens) +
"\nTotal initial actual demand: " + (this.game.village.getResConsumption()["catnip"] || 0) +
"\nNumber of Pastures: " + numPastures +
"\n-The following Pasture ratio will be zero if you've upgraded to Solar Farms-" +
"\nReduction ratio per Pasture: " + pastures.effects["catnipDemandRatio"] +
"\nTotal preliminary reduction ratio for Pastures: " + (pastures.effects["catnipDemandRatio"] * numPastures) +
"\nNumber of Unicorn Pastures: " + numUnicPastures +
"\nReduction ratio per Unicorn Pasture: " + unicPastures.effects["catnipDemandRatio"] +
"\nTotal preliminary reduction ratio for Unicorn Pastures: " + (unicPastures.effects["catnipDemandRatio"] * numUnicPastures) +
"\nTotal preliminary reduction ratio: " + (pastures.effects["catnipDemandRatio"] * numPastures + unicPastures.effects["catnipDemandRatio"] * numUnicPastures) +
"\nFinal reduction ratio, after diminishing returns: " + theoreticalReducedCatnipConsReduction +
"\nActual reduction ratio after diminishing returns: " + this.game.getEffect("catnipDemandRatio") +
"\nTheoretical catnip consumption after reduction ratio: " + ((1 + theoreticalReducedCatnipConsReduction) * (-0.85 * numKittens)) +
"\nActual catnip consumption after reduction ratio: " + ((this.game.village.getResConsumption()["catnip"] || 0) * (1 + this.game.getEffect("catnipDemandRatio"))) +
"\n===HAPPINESS IMPACT===" +
"\n Happiness level: " + (100 * this.game.village.happiness) + "%" +
"\n Are we in the Anarchy challenge? " + (this.game.challenges.currentChallenge == "anarchy" ? "Yes" : "No") +
"\n Have we researched Robotic Assistance (-25% to happiness demand if so)? " + (this.game.workshop.get("assistance").researched ? "Yes" : "No") +
"\n Final theoretical happiness extra consumption: " + theoreticalHappinessModifier +
"\n Final actual happiness consumption: " + actualHappinessModifier +
"\nFinal theoretical catnip consumption: " + theoreticalCatnipConsumption +
"\nFinal actual catnip consumption: " + actualCatnipConsumption);
//Adjust from Per Tick to Per Second
this.setCatnipArray(finalResult, this.game.getRateUI());
var currentWeather = this.game.calendar.weather;
if(currentWeather == null)
currentWeather = "normal";
var currentActual = finalResult["actual"][this.game.calendar.seasons[this.game.calendar.season].name][currentWeather];
if(log)
console.log("---CONVERSION FROM TICKS TO SECONDS---" +
"\nNumber of ticks per second: " + this.game.getRateUI() +
"\nCurrent predicted actual catnip per second: " + currentActual +
"\nCurrent actual catnip per second: " + (catnip.perTickCached * this.game.getRateUI()) +
"\nCatnip per second at cold winter: " + finalResult["actual"]["winter"]["cold"]);
var theoreticalMatches = true;
for(var season in finalResult["actual"])
for(var weather in finalResult["actual"][season])
if(finalResult["theoretical"][season][weather] != finalResult["actual"][season][weather])
theoreticalMatches = false;
if(log)
console.log("---FINAL SANITY CHECKS---" +
"\nDoes the theoretical result match the actual predicted result? " + (theoreticalMatches ? "Yes" : "No") +
"\nDoes the actual predicted result match reality? " + (currentActual == (catnip.perTickCached * this.game.getRateUI()) ? "Yes" : "No") +
"\nDoes the actual predicted result closely match reality? " + ((Math.floor(currentActual * 10 + .5) == Math.floor(catnip.perTickCached * this.game.getRateUI() * 10 + .5)) ? "Yes" : "No"));
return finalResult;
},
getCatnipColdWinter: function(){
var catnip = this.getCatnipInSeasons()["actual"]["winter"]["cold"];
return catnip;
},
getCatnipInWarmSpring: function(){
var catnip = this.getCatnipInSeasons()["actual"]["spring"]["warm"];
return catnip;
},
getParagonProductionBonus: function(){
var prodRatio = this.game.prestige.getParagonProductionRatio() * 100;
prodRatio = Math.round(prodRatio * 1000) / 1000;
return prodRatio + "%";
},
getParagonStorageBonus: function(){
var storeRatio = this.game.prestige.getParagonStorageRatio();
storeRatio = Math.round(storeRatio * 1000) / 1000;
return storeRatio + "x";
},
getTradeAmountAvg: function(race){
var r = null;
try{
r = this.game.diplomacy.get(race);
}
catch(e){
}
if(r){
var ratio = this.game.diplomacy.getTradeRatio()+ 1;
var curSeason = this.game.calendar.getCurSeason().name;
var sells = [];
for(var j in r.sells){
var s = r.sells[j];
var min = 0;
var max = 0;
if(r.name == "zebras" && s.name == "titanium"){
var ships = this.game.resPool.get("ship").value;
var odds = Math.min(15 + ships * 0.35 , 100);
var amt = 1.5 * ((ships / 100) * 2 + 1);
min = amt;
max = amt;
sells[s.name] = amt;
}
else{
var sratio = s.seasons[curSeason];
var tratio = ratio;
if(r.name == "leviathans")
tratio *= (1 + 0.02 * r.energy);
var val = sratio * s.value * (1 - s.delta / 2);
max = val;
max += Math.floor(s.value * sratio * s.delta);
val *= tratio;
min = val;
max *= tratio;
var amt = (min + max) / 2;
amt *= s.chance / 100;
sells[s.name] = amt;
}
}
return sells;
}
return []
},
getBlazarsForShatterEngine: function(){
var numRR = this.game.time.getCFU("ressourceRetrieval").val;
var uoPerYear = game.getResourcePerTick("unobtainium", true) * ( 1 / game.calendar.dayPerTick * game.calendar.daysPerSeason * 4);
var tcPerTrade = this.getTradeAmountAvg("leviathans")["timeCrystal"];
var neededUO = 5000 / tcPerTrade;
var neededPerc = neededUO / uoPerYear;
var basePerc = numRR * .01;
var neededBlazars = Math.max(Math.ceil((neededPerc / basePerc - 1) / .02) , 0);
return neededBlazars;
},
getMaxComped: function(){
var scienceBldMax = this.game.bld.getEffect("scienceMax");
var compCap = this.game.bld.getEffect("scienceMaxCompendia");
var IWRatio = this.game.ironWill ? 10 : 1;
var blackLibrary = this.game.religion.getTU("blackLibrary");
if(this.game.prestige.getPerk("codexLeviathanianus").researched){
var ttBoostRatio = (0.05 * (1 + blackLibrary.val * (blackLibrary.effects["compendiaTTBoostRatio"] + this.game.getEffect("blackLibraryBonus"))));
IWRatio *= (1 + ttBoostRatio * this.game.religion.getTranscendenceLevel());
}
var compCapFinal = scienceBldMax * IWRatio + compCap;
compCapFinal /= 10;
return compCapFinal;
},
//==============================================================================================================================================
//Finally done with calculation functions, now to get down to adding it to the stats tab
//==============================================================================================================================================
stats: [
{
name: "getBestUniBuilding",
title: "最佳独角兽建筑",
val: 0,
},
{
name: "getUraniumForThoriumReactors",
title: "钍反应堆的铀/秒",
val: 0,
},
{
name: "getBlueprintCraft",
title: "每次工艺制作的蓝图",
val: 0,
},
{
name: "getNecrocornsPerSecond",
title: "每秒得到的死灵兽",
val: 0,
},
{
name: "getNecrocornTime",
title: "距离得到下一个死灵兽的时间",
val: 0,
},
{
name: "getLeviChance",
title: "利维坦每年到来的机会",
val: 0,
},
{
name: "getReligionProductionBonusCap",
title: "太阳革命极限加成",
val: 0,
},
{
name: "getPraiseLoss",
title: "到达下一超越等级的进度",
val: 0,
},
{
name: "getCelestialPerDay",
title: "天文事件的几率",
val: 0,
},
{
name: "getCelestialAutoSuccess",
title: "天文事件自动成功率",
val: 0,
},
{
name: "getTitPerZebraTrade",
title: "每次和斑马贸易得到的钛",
val: 0,
},
{
name: "getZebraTradesToMaxTit",
title: "最大斑马交易上限钛",
val: 0,
},
{
name: "getZebraTradesLeftToMaxTit",
title: "达到钛上限时与斑马交易剩余次数",
val: 0,
},
{
name: "getTCPerSacrifice",
title: "每次牺牲得到的时间水晶",
val: 0,
},
{
name: "getRelicPerTCRefine",
title: "每次遗物水晶精炼",
val: 0,
},
{
name: "getCatnipInWarmSpring",
title: "暖春中的猫薄荷/秒",
val: 0,
},
{
name: "getCatnipColdWinter",
title: "冬天的猫薄荷/秒",
val: 0,
},
{
name: "getParagonProductionBonus",
title: "领导力生产加成",
val: 0,
},
{
name: "getParagonStorageBonus",
title: "领导力库存加成",
val: 0,
},
{
name: "getBlazarsForShatterEngine",
title: "耀变体的加成",
val: 0,
},
{
name: "getMaxComped",
title: "最大加成的概要数量",
val: 0,
}],
statTitle: "附加统计(不保证准确性)",
statGroups: null,
constructor: function(game){
this.game = game;
this.statGroups = [
{
group: this.stats,
title: this.statTitle
}
];
for(var i in this.statGroups){
for(var j in this.statGroups[i].group){
this.statGroups[i].group[j].calculate = this[this.statGroups[i].group[j].name];
}
}
},
getStat: function(name){
return this[name]();
},
save: function(saveData){
},
load: function(saveData){
},
resetState: function(){
}
});
dojo.declare("classes.tab.NummonTab", com.nuclearunicorn.game.ui.tab, {
container: null,
constructor: function(tabName){
},
render: function(content){
this.container = content;
this.update();
},
update: function(){
dojo.empty(this.container);
for(var idx in this.game.nummon.statGroups){
var statGroup = this.game.nummon.statGroups[idx];
dojo.create("h1", {
innerHTML: statGroup.title
}, this.container);
var stats = statGroup.group;
var table = dojo.create("table", {class: 'statTable'}, this.container);
for(var i in stats){
var stat = stats[i];
var val = stat.val;
if(val == Infinity)
val = "无限";
stat.val = this.game.nummon[stat.name]();
var tr = dojo.create("tr", null, table);
dojo.create("td", {
innerHTML: stat.title
}, tr);
dojo.create("td", {
innerHTML: typeof val == "number" ? this.game.getDisplayValueExt(val) : val
}, tr);
}
}
}
});
NummonInit = function(){
var managers = [
{
id: "nummon", class: "NummonStatsManager"
}
];
for(var i in managers){
var manager = managers[i];
if(gamePage[manager.id] == undefined){
gamePage[manager.id] = new window["classes"]["managers"][manager.class](gamePage);
gamePage.managers.push(gamePage[manager.id]);
}
else{
gamePage[manager.id] = new window["classes"]["managers"][manager.class](gamePage);
}
}
gamePage.nummonTab = new classes.tab.NummonTab({name: "附加统计", id: "Nummon"}, gamePage);
gamePage.nummonTab.visible = true;
var tabExists = false;
for(var i in gamePage.tabs)
if(gamePage.tabs[i].tabName == "Nummon"){
gamePage.tabs[i] == gamePage.nummonTab;
tabExists = true;
}
if(!tabExists)
gamePage.addTab(gamePage.nummonTab);
gamePage.getTab = function(name){
switch(name) {
case "science":
return this.libraryTab;
case "village":
return this.villageTab;
case "workshop":
return this.workshopTab;
case "space":
return this.spaceTab;
case "stats":
return this.statsTab;
case "nummon":
return this.nummonTab;
case "time":
return this.timeTab;
}
};
gamePage.ui.render();
}
NummonInit();