-
Notifications
You must be signed in to change notification settings - Fork 11
/
data.js
10902 lines (9206 loc) · 534 KB
/
data.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
/*
Ethereal Farm
Copyright (C) 2020-2025 Lode Vandevenne
This program is free software: you can redistribute it and/or modify
it under the terms of the GNU General Public License as published by
the Free Software Foundation, either version 3 of the License, or
(at your option) any later version.
This program is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU General Public License for more details.
You should have received a copy of the GNU General Public License
along with this program. If not, see <https://www.gnu.org/licenses/>.
*/
// The game data: definition of upgrades, crops, ...
var seasonNames = ['spring', 'summer', 'autumn', 'winter',
'ethereal', 'infernal', 'infinity'];
var croptype_index = 0;
var CROPTYPE_BERRY = croptype_index++;
var CROPTYPE_MUSH = croptype_index++;
var CROPTYPE_FLOWER = croptype_index++;
var CROPTYPE_STINGING = croptype_index++; // stinging plants such as nettle and thistle
var CROPTYPE_BRASSICA = croptype_index++; // watercress, wasabi, etc...
var CROPTYPE_AUTOMATON = croptype_index++;
var CROPTYPE_LOTUS = croptype_index++; // ethereal field only, this is an ethereal crop that boost their ethereal neighbors, so a flower type, but regular flowers in ethereal field boost the basic field flowers instead
var CROPTYPE_MISTLETOE = croptype_index++;
var CROPTYPE_BEE = croptype_index++; // boosts flowers
var CROPTYPE_CHALLENGE = croptype_index++; // only exists for challenges
var CROPTYPE_FERN = croptype_index++; // ethereal fern, giving starter money. in infinity field, copies everything
var CROPTYPE_SQUIRREL = croptype_index++;
var CROPTYPE_NUT = croptype_index++;
var CROPTYPE_PUMPKIN = croptype_index++; // halloween pumpkin
var CROPTYPE_RUNESTONE = croptype_index++;
var NUM_CROPTYPES = croptype_index;
// for prestige
var num_tiers_per_crop_type = [];
num_tiers_per_crop_type[CROPTYPE_BERRY] = 16;
num_tiers_per_crop_type[CROPTYPE_MUSH] = 8;
num_tiers_per_crop_type[CROPTYPE_FLOWER] = 8;
num_tiers_per_crop_type[CROPTYPE_NUT] = 16;
//var etherealDeleteSessionTime = 60; // how long time to delete/replace more ethereal crops after deleting one for this session
//var etherealDeleteStartTime = 1800; // how long it's free to delete/replant without being considered a "session" at the start of a run
//var etherealDeleteWaitTime = 7200; // how long to wait til next ethereal deletion session once this one is over
function getCropTypeName(type) {
if(type == CROPTYPE_BERRY) return 'berry';
if(type == CROPTYPE_MUSH) return 'mushroom';
if(type == CROPTYPE_FLOWER) return 'flower';
if(type == CROPTYPE_STINGING) return 'stinging';
if(type == CROPTYPE_BRASSICA) return 'brassica';
if(type == CROPTYPE_AUTOMATON) return 'automaton';
if(type == CROPTYPE_LOTUS) return 'lotus';
if(type == CROPTYPE_MISTLETOE) return 'mistletoe';
if(type == CROPTYPE_BEE) return 'bee';
if(type == CROPTYPE_CHALLENGE) return 'challenge';
if(type == CROPTYPE_FERN) return 'fern';
if(type == CROPTYPE_SQUIRREL) return 'squirrel';
if(type == CROPTYPE_NUT) return 'nuts';
if(type == CROPTYPE_PUMPKIN) return 'pumpkin';
if(type == CROPTYPE_RUNESTONE) return 'runestone';
return 'unknown';
}
// opt_crop is cropid for specific crop in case it has a slightly different description
function getCropTypeHelp(type, opt_state) {
var no_nettles = !!opt_state && (opt_state.challenge == challenge_bees);
var diagonal_mistletoe = !!opt_state && !!opt_state.upgrades2[upgrade2_diagonal_mistletoes].count;
switch(type) {
case CROPTYPE_BERRY: return 'Produces seeds. Boosted by flowers. ' + (no_nettles ? '' : 'Negatively affected by nettles. ') + 'Neighboring mushrooms can consume its seeds to produce spores. Neighboring watercress can copy its production.';
case CROPTYPE_MUSH: return 'Requires berries as neighbors to consume seeds to produce spores. Boosted by flowers' + (no_nettles ? '' : ' and nettles') + '. Neighboring watercress can copy its production (but also consumption).';
case CROPTYPE_FLOWER: return 'Boosts neighboring berries and mushrooms, their production but also their consumption.' + (no_nettles ? '' : ' Negatively affected by neighboring nettles.');
case CROPTYPE_STINGING: return 'Boosts neighboring mushrooms spores production (without increasing seeds consumption), but negatively affects orthogonally neighboring berries and flowers, so avoid touching those with this plant';
case CROPTYPE_BRASSICA: return 'Produces a small amount of seeds on its own, but can produce much more resources by copying from berry and mushroom neighbors once you have those. Unlike other crops, has limited lifetime.';
case CROPTYPE_MISTLETOE: return 'Produces twigs (which you receive on transcend) when tree levels up, ' + (diagonal_mistletoe ? 'when orthogonally or diagonally next to the tree' : 'when orthogonally next to the tree only') + '. Having more than one increases level up spores requirement and slightly decreases resin gain.';
case CROPTYPE_BEE: return 'Boosts orthogonally neighboring flowers (in spring also diagonally). Since this is a boost of a boost, indirectly boosts berries and mushrooms by an entirely new factor.';
case CROPTYPE_CHALLENGE: return 'A type of crop specific to a challenge, not available in regular runs.';
case CROPTYPE_FERN: return 'Ethereal fern, giving starter resources';
case CROPTYPE_NUT: return 'Produces nuts. Can have only max 1 nut plant in the field. Neighboring watercress can copy its production, but less effectively than it copies berries. Receives a limited fixed boost from flowers of high enough tier. Not boosted by other standard berry and mushroom production boosts.';
case CROPTYPE_PUMPKIN: return 'A crop for the halloween holiday event. It will be no longer available when the event is over.';
case CROPTYPE_RUNESTONE: return '';
}
return undefined;
}
// similar to getCropTypeHelp, but for field3 (infinity field)
function getCropTypeHelp3(type, opt_state) {
var have_fishes = !!opt_state && haveFishes(opt_state);
switch(type) {
case CROPTYPE_BERRY: return 'Produces infinity seeds. Boosted by flowers.';
case CROPTYPE_MUSH: return 'Produces infinity spores. Unlocks the pond. Does not require berry neighbors. Boosted by flower tiers, but not as much as berries are and depends on relative tier difference.';
case CROPTYPE_FLOWER: return have_fishes ? 'Boosts neighboring berries. Also boosts mushrooms but with a smaller boost depending on relative tier.' : 'Boosts neighboring berries.';
case CROPTYPE_STINGING: return 'Boosts neighboring mushrooms. The boost depends on the tier of the stinging crop relative to the mushroom, and too low tier gives no boost.';
case CROPTYPE_BRASSICA: return 'Produces seeds, but has a limited lifespan. Produces more seeds than its initial cost over its lifespan.';
case CROPTYPE_MISTLETOE: return '';
case CROPTYPE_BEE: return have_fishes ? 'Boosts neighboring flowers. For the flower boost to mushrooms, also has a small effect based on tier.' : 'Boosts neighboring flowers.';
case CROPTYPE_CHALLENGE: return '';
case CROPTYPE_FERN: return 'Copies all infinity seed and spores resources of the entire field, for crops of the same tier';
case CROPTYPE_NUT: return 'Produces infinity seeds. Works exactly the same as berries and is boosted by the same flowers and fishes.';
case CROPTYPE_PUMPKIN: return '';
case CROPTYPE_RUNESTONE: return 'Boosts the basic field production boost of any neighboring crops in the infinity field.';
case CROPTYPE_LOTUS: return 'Boosts berries and mushrooms, similar to flower but this is a separate boost multiplicative with the flower boost, and only works within the same crop tier. Not affected by bees.';
}
return undefined;
}
var fern_wait_minutes = 2; // default fern wait minutes (in very early game they go faster)
// apply bonuses that apply to all weather ability durations
function adjustWeatherDuration(result) {
if(state.upgrades[active_choice0].count == 1) result *= 2;
if(!basicChallenge() && state.squirrel_upgrades[upgradesq_weather_duration].count) result *= (1 + upgradesq_weather_duration_bonus);
return result;
}
// apply bonuses that apply to all weather ability waits
function adjustWeatherWait(result) {
if(state.upgrades[active_choice0].count == 1) result *= 2;
return result;
}
function getWeatherBoost() {
var result = Num(1);
var level = getFruitAbility(FRUIT_WEATHER, true);
if(level > 0) {
var mul = Num(1).add(getFruitBoost(FRUIT_WEATHER, level, getFruitTier(true)));
result.mulInPlace(mul);
}
return result;
}
////////////////////////////////////////////////////////////////////////////////
var sun_duration = 2 * 60;
var sun_wait = 10 * 60 + sun_duration;
// how long the sun effect is active
function getSunDuration() {
var result = sun_duration;
result = adjustWeatherDuration(result);
return result;
}
// how long the entire sun cycle (including the time when it is active) is
function getSunWait() {
var result = sun_wait;
result = adjustWeatherWait(result);
return result;
}
function sunActive() {
if(state.lastWeather != 0) return false;
return state.upgrades[upgrade_sununlock].count && (state.time - state.suntime) < getSunDuration();
}
////////////////////////////////////////////////////////////////////////////////
var mist_duration = 3 * 60;
var mist_wait = 15 * 60 + mist_duration;
// how long the mist effect is active
function getMistDuration() {
var result = mist_duration;
result = adjustWeatherDuration(result);
return result;
}
// how long the entire mist cycle (including the time when it is active) is
function getMistWait() {
var result = mist_wait;
result = adjustWeatherWait(result);
return result;
}
function mistActive() {
if(state.lastWeather != 1) return false;
return state.upgrades[upgrade_mistunlock].count && (state.time - state.misttime) < getMistDuration();
}
////////////////////////////////////////////////////////////////////////////////
var rainbow_duration = 4 * 60;
var rainbow_wait = 20 * 60 + rainbow_duration;
// how long the rainbow effect is active
function getRainbowDuration() {
var result = rainbow_duration;
result = adjustWeatherDuration(result);
return result;
}
// how long the entire rainbow cycle (including the time when it is active) is
function getRainbowWait() {
var result = rainbow_wait;
result = adjustWeatherWait(result);
return result;
}
function rainbowActive() {
if(state.lastWeather != 2) return false;
return state.upgrades[upgrade_rainbowunlock].count && (state.time - state.rainbowtime) < getRainbowDuration();
}
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
////////////////////////////////////////////////////////////////////////////////
// @constructor
function Crop() {
this.name = 'a';
this.cost = Res(); // one-time cost (do not use directly, use .getCost() to get all multipliers taken into account) and .getBaseCost() to get prestige taken into account
this.prod = Res(); // production per second (do not use directly, use getProd() to get all multipliers taken into account)
this.prod0 = Res(); // production if not prestiged
this.leech = undefined; // e.g. set to Num(1) for 100% base copying for watercress
this.index = 0; // index in the crops array
this.planttime = 0; // in seconds
this.planttime0 = 0; // planttime if not prestiged
// how much this boosts neighboring crops, 0 means no boost, 1 means +100%, etc... (do not use directly, use getBoost() to get all multipliers taken into account)
// meaning depends on crop type, e.g. for bees this is boostboost instead, challenge specific crops may use this value, ...
this.boost = Num(0);
this.tagline = '';
this.basic_upgrade = null; // id of registered upgrade that does basic upgrades of this plant
this.image = undefined;
this.image_remainder = undefined; // used for brassica
this.image_post = undefined; // used for brassica
this.type = undefined;
this.tier = 0;
this.tier_non_prestiged = 0;
this.istemplate = false; // if true, is a placeholder template
this.isghost = false; // if true, is a ghost. This is a remainder of a plant, currently only used for the undeletable challenge when a crop is prestiged: the ghost of the unprestiged versions remains, to ensure it still cannot be deleted
this.cached_prestige_ = 0; // for recomputing crop stats data if prestige changed: the cost, prod, ... fields of this crop are overwritten for prestige
this.quad = false; // if true, takes up 2x2 field spaces
this.images_quad = undefined; // if quad is true, must be array of 4 images
};
var sameTypeCostMultiplier = 1.5;
var sameTypeCostMultiplier_Flower = 2;
var sameTypeCostMultiplier_Short = 1;
// returns recoup for deleting a plant. It is only partial, the goal of the game is not to replace plants often
function getCropRecoup() {
if(state.challenges[challenge_nodelete].completed) return 0.66;
return 0.33;
}
var squirrel_respec_initial = 2; // how many squirrel upgrade respecs received at game start
Crop.prototype.isReal = function() {
return !this.istemplate && !this.isghost;
};
// Returns a value based on x but smoothly capped to be no lower than lowest. The input x is also assumed to never be higher than highest, and no value higher than highest will be returned.
// The softness determines how strongly the value gets capped: at 0, x goes down linearly, until reaching lowest, then stays at lowest.
// For higher values of softness, the cap is softer, such that when x = lowest, the output will be lowest + softness,
// for lower and higher x the deviation from the sharply capped curve gets less and less.
// highest should be larger than lowest + softness (else the direction inverts)
// To summarize:
// For x == lowest, the output is lowest + softness = x + softness
// For x == highest, the output is highest
// For x < lowest, the output goes towards lowest (reaching it at -infinity)
// For x between lowest and highest, x smoothly curves from lowest + softness towards highest
// For x above highest, the result still gets larger, but normally it's assumed that input x < highest
function towardsFloorValue(x, lowest, highest, softness) {
var s = 4 * softness * softness;
x -= lowest;
// scale x such that x=highest results in output highest
var h = 4 * (highest - lowest) * (highest - lowest);
x *= (h - s) / (h);
var v = 0.5 * (x + Math.sqrt(x * x + s));
return lowest + v;
}
// aka getgrowspeed, getgrowtime, getlifetime
Crop.prototype.getPlantTime = function() {
if(state.challenge == challenge_towerdefense) {
var td = state.towerdef;
if(this.type == CROPTYPE_BRASSICA || !td.started || !tdWaveActive()) {
return 0.01;
} else {
return 5;
}
}
var result = this.planttime;
if(result == 0) return result;
var basic = basicChallenge();
// NOTE: challenge_towerdefense's sped up grow time is not handled here but in game.js
// This is the opposite for CROPTYPE_BRASSICA, it's not planttime but live time. TODO: make two separate functions for this
if(this.type == CROPTYPE_BRASSICA) {
if(this.basic_upgrade != null) {
var u = state.upgrades[this.basic_upgrade];
var u2 = upgrades[this.basic_upgrade];
if(u.count > 0) {
result += (this.planttime * u2.bonus) * u.count;
}
}
if(!basic) {
if(state.squirrel_upgrades[upgradesq_watercresstime].count || state.squirrel_upgrades[upgradesq_watercresstime2].count) {
result *= 1.5;
}
}
if(state.upgrades[watercress_choice0].count == 1) {
result *= (1 + watercress_choice_lifetime_increase);
}
return result;
}
var planttime = this.planttime;
var min = 60 + Math.log(planttime) + 10 * this.tier;
if(min > planttime * 0.5) min = planttime * 0.5;
var level = getFruitAbility(FRUIT_GROWSPEED, true);
if(level > 0) {
var mul = Num(1).sub(getFruitBoost(FRUIT_GROWSPEED, level, getFruitTier(true))).valueOf();
result *= mul;
}
if(!basic) {
var count = state.upgrades2[upgrade2_time_reduce_0].count;
if(count) {
result -= upgrade2_time_reduce_0_amount * count;
}
}
var softness = planttime * 0.33;
var highest = planttime;
if(min + softness > highest) highest = min + softness;
result = towardsFloorValue(result, min, highest, softness);
// for prestiged crops, which has its own different softness curve
var planttime2 = result;
if(!basic) {
var c2 = state.crops[this.index];
if(c2.prestige) {
var count = state.upgrades2[upgrade2_prestiged_growspeed].count;
if(count) {
result -= upgrade2_prestiged_growspeed_amount * count;
}
}
}
var min2 = 60 + Math.log(planttime2) + 10 * this.tier;
if(min2 > planttime2 * 0.5) min2 = planttime2 * 0.5;
var softness2 = planttime2 * 0.33;
var highest2 = planttime2;
if(min2 + softness2 > highest2) highest2 = min2 + softness2;
result = towardsFloorValue(result, min2, highest2, softness2);
if(result > planttime) result = planttime;
if(!basic) {
if(state.squirrel_upgrades[upgradesq_growspeed].count) {
result *= (1 - upgradesq_growspeed_bonus);
}
if(state.upgrades2[upgrade2_season2[0]].count && getSeason() == 0) {
result *= (1 - upgrade2_spring_growspeed_bonus);
}
}
if(presentGrowSpeedActive()) {
result *= 0.5;
}
return result;
};
Crop.prototype.getCost = function(opt_adjust_count) {
var mul = sameTypeCostMultiplier;
if(this.type == CROPTYPE_FLOWER) mul = sameTypeCostMultiplier_Flower;
if(this.type == CROPTYPE_BRASSICA) mul = sameTypeCostMultiplier_Short;
if(this.type == CROPTYPE_CHALLENGE) {
if(this.challengecroppricemul) mul = this.challengecroppricemul;
}
if(state.challenge == challenge_towerdefense && this.type != CROPTYPE_BRASSICA && this.type != CROPTYPE_CHALLENGE) {
mul = Math.max(4, mul);
}
var countfactor = Math.pow(mul, state.cropcount[this.index] + (opt_adjust_count || 0));
return this.cost.mulr(countfactor);
};
Crop.prototype.getRecoup = function(f, opt_adjust_count) {
var adjust = opt_adjust_count || 0;
var result = this.getCost(adjust - 1);
// no recoup reduction but full refund during the TD challenge
if(state.challenge == challenge_towerdefense) return result;
if(f && this.type == CROPTYPE_BRASSICA) {
// brassica give amount scaled by their lifetime, and full rather than multiplied with getCropRecoup() percentage
// this used to be different (before jan 2024 brassica gave 0 recoup) but is now made to be more like infinity field brassica, and also to make the watercress refresh button more useful and reliable for the first few minutes of the game and prevent having too few resources for first watercress by planting one and immediately deleting it again
return result.mulr(Math.min(Math.max(0, f.growth), 1));
}
// the withering crops during the wither challenge give no recoup
if(state.challenge == challenge_wither) return new Res();
if(f && f.growth < 1 && this.type != CROPTYPE_BRASSICA && state.challenge != challenge_wither) {
// growing crops give a full refund
return result;
}
return result.mulr(getCropRecoup());
};
var infernal_tier_base = 0.5;
var infernal_berry_tier_mul = 700; // same as getBerryProd(n + 1).spores.div(getBerryProd(n).spores) for any high enough n
var infernal_berry_upgrade_count = 29; // matches value in setCropMultiplierCosts. TODO: make single variable
var infernal_mush_tier_mul = 612500; // same as getMushroomProd(n + 1).spores.div(getMushroomProd(n).spores) for any high enough n
var infernal_mush_upgrade_count = 52; // matches value in setCropMultiplierCosts. TODO: make single variable
var infernal_berry_upgrade_base = Num.pow(Num(infernal_berry_tier_mul), Num(1.0 / infernal_berry_upgrade_count)).div(Num.pow(Num(infernal_berry_tier_mul * infernal_tier_base), Num(1.0 / infernal_berry_upgrade_count)));
var infernal_mush_upgrade_base = Num.pow(Num(infernal_mush_tier_mul), Num(1.0 / infernal_mush_upgrade_count)).div(Num.pow(Num(infernal_mush_tier_mul * infernal_tier_base), Num(1.0 / infernal_mush_upgrade_count)));
// used for multiple possible aspects, such as production, boost if this is a flower, etc...
// f is field, similar to in Crop.prototype.getProd
// result is changed in-place and may be either Num or Res. Nothing is returned.
Crop.prototype.addSeasonBonus_ = function(result, season, f, breakdown) {
// posmul is used:
// Unlike other multipliers, this one does not affect negative production. This is a good thing in the crop's good season, but extra harsh in a bad season (e.g. winter)
var basic = basicChallenge();
if(season == 0 && this.type == CROPTYPE_FLOWER) {
var bonus = getSpringFlowerBonus();
result.mulInPlace(bonus);
if(breakdown) breakdown.push([seasonNames[season], true, bonus, result.clone()]);
}
if(season == 1 && (this.type == CROPTYPE_BERRY || this.type == CROPTYPE_PUMPKIN)) {
var bonus = getSummerBerryBonus();
result.mulInPlace(bonus);
if(breakdown) breakdown.push([seasonNames[season], true, bonus, result.clone()]);
}
// with ethereal upgrades, spring also benefits mushrooms a bit, to catch up with other seasons ethereal upgrades
if(season == 1 && this.type == CROPTYPE_MUSH) {
var bonus = getSummerMushroomBonus();
result.mulInPlace(bonus);
if(breakdown && bonus.neqr(1)) breakdown.push([seasonNames[season], true, bonus, result.clone()]);
}
if(season == 2 && this.type == CROPTYPE_MUSH) {
var bonus = getAutumnMushroomBonus();
result.posmulInPlace(bonus);
var reduction = Num(1).sub(getAutumnMushroomConsumptionReduction());
result.negmulInPlace(reduction);
if(breakdown) breakdown.push([seasonNames[season], true, bonus, result.clone()]);
}
// with ethereal upgrades, autumn also benefits berries a bit, to catch up with other seasons ethereal upgrades
if(season == 2 && (this.type == CROPTYPE_BERRY || this.type == CROPTYPE_PUMPKIN)) {
var bonus = getAutumnBerryBonus();
result.posmulInPlace(bonus);
if(breakdown && bonus.neqr(1)) breakdown.push([seasonNames[season], true, bonus, result.clone()]);
}
if(season == 3 && (this.type == CROPTYPE_BERRY || this.type == CROPTYPE_PUMPKIN || this.type == CROPTYPE_MUSH || this.type == CROPTYPE_FLOWER || this.type == CROPTYPE_BEE || this.type == CROPTYPE_NUT) && f) {
var weather_ignore = false;
if((this.type == CROPTYPE_BERRY || this.type == CROPTYPE_PUMPKIN) && sunActive()) weather_ignore = true;
if(this.type == CROPTYPE_MUSH && mistActive()) weather_ignore = true;
if(this.type == CROPTYPE_FLOWER && rainbowActive()) weather_ignore = true;
var p = prefield[f.y][f.x];
if(!p.treeneighbor && !weather_ignore) {
var malus = getWinterMalus();
if(malus.neqr(1)) {
result.posmulInPlace(malus);
if(breakdown) breakdown.push([seasonNames[season], true, malus, result.clone()]);
}
}
// winter tree warmth
if(p.treeneighbor && (this.type == CROPTYPE_BERRY || this.type == CROPTYPE_PUMPKIN || this.type == CROPTYPE_MUSH)) {
var bonus = getWinterTreeWarmth();
if(this.quad) {
// quad crop is overpowered in winter if it gets the full winter warmth, instead take into account it only partially touches the tree since it's so big
// NOTE: even better would be to do it percentage wise for amount of pieces touching the tree. However, that will always either be 25% or 50%, and 50% if well placed, so simplifying it to always 50% is ok
bonus = bonus.subr(1).mulr(0.5).addr(1);
}
result.mulInPlace(bonus);
if(breakdown) breakdown.push(['winter tree warmth', true, bonus, result.clone()]);
}
if(!basic) {
if(p.treeneighbor && state.upgrades2[upgrade2_season2[3]].count && this.type == CROPTYPE_FLOWER) {
var bonus = upgrade2_winter_flower_bonus;
result.mulInPlace(bonus);
if(breakdown) breakdown.push(['winter tree warmth (flowers)', true, bonus, result.clone()]);
}
}
}
if(state.challenge == challenge_infernal && season == 5 && this.tier >= 0) {
var tier_effective = -1;
var upgrade_base = undefined;
if(this.type == CROPTYPE_BERRY || this.type == CROPTYPE_PUMPKIN) {
tier_effective = this.tier;
upgrade_base = infernal_berry_upgrade_base;
}
if(this.type == CROPTYPE_MUSH) {
tier_effective = this.tier * 2 + 2;
upgrade_base = infernal_mush_upgrade_base;
}
var malus = Num(1e-9); // this applies to berries, flowers, mushrooms, bees, nettles, watercress production (but not copying)
if(tier_effective >= 0) {
malus.mulInPlace(Num.powr(Num(infernal_tier_base), tier_effective + 1));
var u = state.upgrades[this.basic_upgrade];
malus.mulInPlace(Num.powr(Num(upgrade_base), -u.count));
}
if(this.type == CROPTYPE_BRASSICA && result.seeds) {
// for brassica, keep the production at least as much as initial game brassica: so that it's possible to play infermal without having fern in ethereal field in theory
var minseeds = Num.min(this.prod.seeds, result.seeds);
if(result.seeds.mul(malus).lt(minseeds) && result.seeds.neqr(0)) {
// the result.seeds.neqr(0) check above is to avoid NaN, production can be 0 if the watercress is end of life (it still copies then, but doesn't produce)
malus = minseeds.div(result.seeds);
}
}
result.mulInPlace(malus);
if(breakdown) breakdown.push(['infernal', true, malus, result.clone()]);
}
}
// derive the nettle malus from its boost to mushrooms
function deriveNettleMalus(boost) {
if(state.challenge == challenge_poisonivy) {
// this challenge is REALLY hard if this less extreme malus is not there
return boost.powr(0.25).addr(2).inv();
}
return boost.powr(0.5).addr(2).inv();
}
Crop.prototype.computeNettleMalusReceived_ = function(f, pretend) {
// this computation must match what precomputeField does for nettlemalus_received
var malus = new Num(1);
if(!f) return malus;
for(var dir = 0; dir < 4; dir++) { // get the neighbors N,E,S,W
var x2 = f.x + (dir == 1 ? 1 : (dir == 3 ? -1 : 0));
var y2 = f.y + (dir == 2 ? 1 : (dir == 0 ? -1 : 0));
if(x2 < 0 || x2 >= state.numw || y2 < 0 || y2 >= state.numh) continue;
var n = state.field[y2][x2];
if(n.hasRealCrop() && n.getCrop().type == CROPTYPE_STINGING) {
var boost = n.getCrop().getBoost(n, pretend);
malus.mulInPlace(deriveNettleMalus(boost));
}
}
return malus;
};
// in spring, bees can work diagonally too. Except during the rockier challenge
function haveDiagonalBees() {
if(state.challenge == challenge_rockier) return false;
return getSeason() == 0;
}
Crop.prototype.computeBeehiveBoostReceived_ = function(f, pretend) {
var numbeedirs = haveDiagonalBees() ? 8 : 4;
// this computation must match what precomputeField does for beeboostboost_received
var bonus = new Num(0);
if(!f) return bonus;
for(var dir = 0; dir < numbeedirs; dir++) { // get the neighbors N,E,S,W,NE,SE,SW,NW
var x2 = f.x + ((dir == 1 || dir == 4 || dir == 5) ? 1 : ((dir == 3 || dir == 6 || dir == 7) ? -1 : 0));
var y2 = f.y + ((dir == 0 || dir == 4 || dir == 7) ? -1 : ((dir == 2 || dir == 5 || dir == 6) ? 1 : 0));
if(x2 < 0 || x2 >= state.numw || y2 < 0 || y2 >= state.numh) continue;
if(dir >= 4 && !diagConnected(f.x, f.y, x2, y2, state.field)) continue;
var n = state.field[y2][x2];
if(n.hasRealCrop() && n.getCrop().type == CROPTYPE_BEE) {
var boostboost = n.getCrop().getBoostBoost(n, pretend);
bonus.addInPlace(boostboost);
}
}
return bonus;
};
var flower_nut_boost = Num(0.25);
var spores_overload_penalty = Num(4);
//var seed_consumption_mul = 1.0; // for testing only
// f = Cell from field, or undefined to not take location-based production bonuses into account
// prefield must already have been computed for flowers, bees and nettles (but not yet for berries/mushrooms, which is what is being computed now) before this may get called, unless pretent is non-0
// pretend: if anything else than 0, pretents crops are fullgrown, and cannot use the prefield computations so is slower to compute
// 0: normal
// 1: compute income if this plant would be planted here, while it doesn't exist here in reality. For the planting dialog UI, ...
// 2: same as 1, but for tooltips/dialogs/expected hypothetical gain display/..., so will also include brassica copying, but normally precomputefield handles this instead
// 3: compute the value for best berry for the pumpkin income. Must include all berry specific bonuses and its growth, but not the pumpkin bonuses. The max of all berries from this must be stored in state.bestberryforpumpkin, and then if the crop type is CROPTYPE_PUMPKIN it uses this value as base
// 4: same as 3, but assuming the crop is fullgrown
// 5: compute for fern. This assumes everything is fullgrown, like 1, and in addition uses modified weighted time at level
Crop.prototype.getProd = function(f, pretend, breakdown) {
var basic = basicChallenge();
var baseprod = this.prod;
var baseprod0 = this.prod0; // production without prestige, only used for display purposes
if(state.challenge == challenge_towerdefense) {
if(this.type == CROPTYPE_BRASSICA) {
baseprod = getTDBerryBaseDamage(0).divr(16);
baseprod0 = baseprod;
}
}
var result = new Res(baseprod);
if(this.type == CROPTYPE_PUMPKIN) {
var best = state.bestberryforpumpkin;
if(pretend == 1 || pretend == 2 || pretend == 4 || pretend == 5) best = state.bestberryforpumpkin_expected;
result = new Res(best);
}
if(breakdown) {
if(state.crops[this.index].prestige > 0) {
breakdown.push(['base', true, Num(0), baseprod0.clone()]);
var div = Res.findDiv(baseprod, baseprod0);
breakdown.push(['prestige', true, div, result.clone()]);
} else {
breakdown.push(['base', true, Num(0), result.clone()]);
}
}
if(this.type == CROPTYPE_PUMPKIN) {
result.mulInPlace(pumpkin_multiplier);
if(breakdown) breakdown.push(['pumpkin', true, pumpkin_multiplier, result.clone()]);
}
if(state.challenge == challenge_towerdefense && f && f.growth < 1 && this.type == CROPTYPE_MUSH) {
result.mulrInPlace(0);
if(breakdown) breakdown.push(['tower growing', true, Num(0), result.clone()]);
return result;
}
if(this.type == CROPTYPE_NUT && state.just_evolution) {
result.mulrInPlace(0);
if(breakdown) breakdown.push(['squirrel evolution in progress', true, Num(0), result.clone()]);
return result;
}
if(this.quad && f && getQuadPos(f.x, f.y) != 0) {
result.mulrInPlace(0);
if(breakdown) breakdown.push(['not the main 2x2 crop piece', true, Num(0), result.clone()]);
return result;
}
// The f.isFullGrown check considers all brassica fullgrown (so brassica aren't affected by this), except those that are end of life from infinite lifetime (so those get 0 production, but still copy). This behavior is not by design (EOL brassica was only implemented later) but is ok and sensible.
if((!pretend || pretend == 3) && f && (!f.isFullGrown() || state.challenge == challenge_wither)) {
if(state.challenge == challenge_wither) {
// wither challenge
var t = Num(witherCurve(f.growth) * f.growth);
result.mulInPlace(t);
if(breakdown) breakdown.push(['withering', true, t, result.clone()]);
} else {
// still growing
var t = f.growth * f.growth; // unlike flowers etc..., the actual producers ramp up quadratically (= a slower start, but not applied to flowers/bees/... to count this effect in only once)
if(this.type == CROPTYPE_MUSH) {
// mushrooms spores ramp up much later: when progressing through low tier mushrooms, grow speed should be a limiting factor, to avoid the game having the highest resin/hr after too short time (should be at 1-2 hours, not at 20 minutes), to avoid the game being too active
result.seeds.mulrInPlace(t);
t = Math.pow(t, 4);
result.spores.mulrInPlace(t);
} else {
result.mulrInPlace(t);
}
if(breakdown) breakdown.push(['growing', true, Num(t), result.clone()]);
}
}
// upgrades
if(this.basic_upgrade != null) {
var u = state.upgrades[this.basic_upgrade];
var u2 = upgrades[this.basic_upgrade];
if(u.count > 0) {
var mul_upgrade;
if(this.type == CROPTYPE_BRASSICA) {
mul_upgrade = Num(brassica_prod_upgrade_boost * u.count + 1); // brassica upgrade is additive instead of multiplicative
} else {
mul_upgrade = u2.bonus.powr(u.count);
}
result.mulInPlace(mul_upgrade);
if(breakdown) breakdown.push(['upgrades (' + u.count + ')', true, mul_upgrade, result.clone()]);
}
}
if(pretend == 3 || pretend == 4) {
// don't apply any other mode for this bonus: this is highest base berry production for pumpkin, from itself and its upgrades, all other effects apply to the pumpkin itself
return result;
}
if(!basic) {
// squirrel evolution
if(this.type == CROPTYPE_BERRY || this.type == CROPTYPE_MUSH || this.type == CROPTYPE_PUMPKIN) {
if(state.squirrel_evolution > 0) {
var mul = squirrel_epoch_prod_bonus.addr(1);
result.mulInPlace(mul);
if(breakdown) breakdown.push(['squirrel evolution', true, mul, result.clone()]);
}
}
}
if(this.type == CROPTYPE_BERRY || this.type == CROPTYPE_MUSH || this.type == CROPTYPE_PUMPKIN) {
if(state.upgrades[resin_choice0].count == 2) {
var mul = Num(resin_choice0_production_bonus + 1);
result.mulInPlace(mul);
if(breakdown) breakdown.push(['resin choice: production', true, mul, result.clone()]);
}
}
if(!basic) {
// medal
if(this.type != CROPTYPE_NUT) {
result.mulInPlace(state.medal_prodmul);
if(breakdown) breakdown.push(['achievements', true, state.medal_prodmul, result.clone()]);
}
// amber
if((this.type == CROPTYPE_BERRY || this.type == CROPTYPE_MUSH || this.type == CROPTYPE_PUMPKIN)) {
if(state.amberprod) {
var bonus = Num(2);
result.mulInPlace(bonus);
if(breakdown) breakdown.push(['amber production bonus active', true, bonus, result.clone()]);
}
}
}
// fruit
if(basic != 2) {
if(this.type == CROPTYPE_BERRY || this.type == CROPTYPE_PUMPKIN) {
var level = getFruitAbility(FRUIT_BERRYBOOST, true);
if(level > 0) {
var mul = getFruitBoost(FRUIT_BERRYBOOST, level, getFruitTier(true)).addr(1);
result.mulInPlace(mul);
if(breakdown) breakdown.push(['fruit: ' + getFruitAbilityName(FRUIT_BERRYBOOST), true, mul, result.clone()]);
}
}
if(this.type == CROPTYPE_MUSH) {
var level = getFruitAbility(FRUIT_MUSHBOOST, true);
if(level > 0) {
var mul = getFruitBoost(FRUIT_MUSHBOOST, level, getFruitTier(true)).addr(1);
result.mulInPlace(mul);
if(breakdown) breakdown.push(['fruit: ' + getFruitAbilityName(FRUIT_MUSHBOOST), true, mul, result.clone()]);
}
var level = getFruitAbility(FRUIT_MUSHEFF, true);
if(level > 0) {
var mul = Num(1).sub(getFruitBoost(FRUIT_MUSHEFF, level, getFruitTier(true)));
result.seeds.mulInPlace(mul);
if(breakdown) breakdown.push(['fruit: ' + getFruitAbilityName(FRUIT_MUSHEFF), true, mul, result.clone()]);
}
}
if(this.type == CROPTYPE_NUT) {
var level = getFruitAbility(FRUIT_NUTBOOST, true);
if(level > 0) {
var mul = getFruitBoost(FRUIT_NUTBOOST, level, getFruitTier(true)).addr(1);
result.mulInPlace(mul);
if(breakdown) breakdown.push(['fruit: ' + getFruitAbilityName(FRUIT_NUTBOOST), true, mul, result.clone()]);
}
}
if(this.type == CROPTYPE_BERRY || this.type == CROPTYPE_MUSH || this.type == CROPTYPE_PUMPKIN) {
// also applied to mushroom because overload increases mushroom's seed consumption equally
var level = getFruitAbility(FRUIT_SEED_OVERLOAD, true);
if(level > 0) {
var mul = getFruitBoost(FRUIT_SEED_OVERLOAD, level, getFruitTier(true)).addr(1);
result.seeds.mulInPlace(mul);
if(breakdown) breakdown.push(['fruit: ' + getFruitAbilityName(FRUIT_SEED_OVERLOAD), true, mul, result.clone()]);
}
}
if(this.type == CROPTYPE_MUSH) {
var level = getFruitAbility(FRUIT_SPORES_OVERLOAD, true);
if(level > 0) {
var mul = getFruitBoost(FRUIT_SPORES_OVERLOAD, level, getFruitTier(true)).addr(1);
var seedmul = spores_overload_penalty;
if(mul.ltr(1000)) {
/*
seedmul is the seed penalty due to spores overload
without spores overload, the penalty is 1 (multiply with 1 = no penalty)
with only spores overload, the penalty is 4 (= value of spores_overload_penalty, if this value was tuned to something else, this example still uses 4)
but the original non-overloaded spores production should not be penalized, so overall the penalty will be slightly smaller
e.g. if mul is 10, then 10% (0.1) is produced with 1x penalty, 90% (0.9) is produced with 4x penalty, so overall penalty is:
1 * 0.1 + 4 * 0.9 = 3.7
This is only done for small mul, for the typical muls over 1000 normally gotten at emerald fruits this is a rounding error and not computed, but it can matter during basic challenge
*/
var a = mul.rdiv(1); // 1 / mul, e.g. the 0.1 in the example above
var b = a.rsub(1); // e.g the 0.9 in the example above
var seedmul = Num(1).mul(a).add(spores_overload_penalty.mul(b));
}
result.mulInPlace(mul);
result.seeds.mulInPlace(seedmul);
if(breakdown) breakdown.push(['fruit: ' + getFruitAbilityName(FRUIT_SPORES_OVERLOAD), true, mul, result.clone()]);
}
}
}
if(!basic) {
// ethereal crops bonus to basic crops
var ethereal_prodmul = Res.resOne();
if(this.type == CROPTYPE_BERRY || this.type == CROPTYPE_PUMPKIN) {
ethereal_prodmul.seeds = state.ethereal_berry_bonus.addr(1);
}
if(this.type == CROPTYPE_MUSH) {
// seeds commented out in v0.1.16 but enabled again in v0.1.47 because otherwise the seed prod/consumption balance will get lost with higher level etherela field.
ethereal_prodmul.seeds = state.ethereal_mush_bonus.addr(1);
ethereal_prodmul.spores = state.ethereal_mush_bonus.addr(1);
}
var e = result.elmul(ethereal_prodmul);
if(result.neq(e)) {
if(breakdown) {
var mul = Num(1);
var a0 = result.toArray();
var a1 = e.toArray();
for(var i = 0; i < a0.length; i++) {
if(a0[i].neq(a1[i])) {
mul = a1[i].div(a0[i]);
break;
}
}
breakdown.push(['ethereal crops', true, mul, e.clone()]);
}
result = e;
}
if(this.type == CROPTYPE_BERRY || this.type == CROPTYPE_MUSH || this.type == CROPTYPE_PUMPKIN) {
// tree's gesture ethereal upgrade
var gesture = treeGestureBonus();
if(gesture.neqr(1)) {
result.mulInPlace(gesture);
if(breakdown) breakdown.push(['tree\'s gesture', true, gesture, result.clone()]);
}
// ethereal tree level above 25 ethereal upgrade
var num = state.upgrades2[upgrade2_ethereal_tree_level].count;
if(num) {
var mul = upgrade2_ethereal_tree_level_bonus.mulr(num).mulr(state.treelevel2 - 25).addr(1);
result.mulInPlace(mul);
if(breakdown) breakdown.push(['ethereal tree level > 25', true, mul, result.clone()]);
}
}
if(haveSquirrel()) {
if(this.type == CROPTYPE_BERRY || this.type == CROPTYPE_PUMPKIN) {
if(state.squirrel_upgrades[upgradesq_berry].count) {
var bonus = upgradesq_berry_bonus.mulr(state.squirrel_upgrades[upgradesq_berry].count).addr(1);
result.mulInPlace(bonus);
if(breakdown) breakdown.push(['squirrel upgrades', true, bonus, result.clone()]);
}
var this_prestige = state.crops[this.index].prestige;
if(this.type == CROPTYPE_PUMPKIN) {
this_prestige = state.bestberryforpumpkin_prestige;
}
if(this_prestige && state.squirrel_upgrades[upgradesq_prestiged_berry].count) {
var bonus = upgradesq_prestiged_berry_bonus.mulr(state.squirrel_upgrades[upgradesq_prestiged_berry].count).addr(1);
bonus = bonus.powr(this_prestige); // applies multiple times for multiple prestiges
result.mulInPlace(bonus);
if(breakdown) breakdown.push(['squirrel prestiged', true, bonus, result.clone()]);
}
}
if(this.type == CROPTYPE_MUSH) {
if(state.squirrel_upgrades[upgradesq_mushroom].count) {
var bonus = upgradesq_mushroom_bonus.mulr(state.squirrel_upgrades[upgradesq_mushroom].count).addr(1);
result.mulInPlace(bonus);
if(breakdown) breakdown.push(['squirrel upgrades', true, bonus, result.clone()]);
}
if(state.crops[this.index].prestige && state.squirrel_upgrades[upgradesq_prestiged_mushroom].count) {
var bonus = upgradesq_prestiged_mushroom_bonus.mulr(state.squirrel_upgrades[upgradesq_prestiged_mushroom].count).addr(1);
bonus = bonus.powr(state.crops[this.index].prestige); // applies multiple times for multiple prestiges
result.mulInPlace(bonus);
if(breakdown) breakdown.push(['squirrel prestiged', true, bonus, result.clone()]);
}
}
}
if(haveUnusedNutsBonus() && state.res.nuts.gter(1) && this.type != CROPTYPE_NUT) {
var nuts_bonus = getUnusedNutsBonus();
result.mulInPlace(nuts_bonus);
if(breakdown) breakdown.push(['unused nuts', true, nuts_bonus, result.clone()]);
}
if(state.res.resin.gter(1) && this.type != CROPTYPE_NUT) {
var resin_bonus = getUnusedResinBonus();
result.mulInPlace(resin_bonus);
if(breakdown) breakdown.push(['unused resin', true, resin_bonus, result.clone()]);
}
if(this.type != CROPTYPE_NUT) {
var twigs_bonus = getUnusedTwigsBonus();
if(twigs_bonus.neqr(1)) {
result.mulInPlace(twigs_bonus);
if(breakdown) breakdown.push(['unused twigs', true, twigs_bonus, result.clone()]);
}
}
if(this.type == CROPTYPE_BERRY || this.type == CROPTYPE_MUSH || this.type == CROPTYPE_PUMPKIN) {
if(haveEtherealMistletoeUpgrade(mistle_upgrade_prod)) {
var mul = getEtherealMistletoeBonus(mistle_upgrade_prod).addr(1);
result.mulInPlace(mul);
if(breakdown) breakdown.push(['ethereal mistletoe leafiness', true, mul, result.clone()]);
}
}
if(this.type == CROPTYPE_BERRY || this.type == CROPTYPE_PUMPKIN) {
if(haveEtherealMistletoeUpgrade(mistle_upgrade_berry)) {
var mul = getEtherealMistletoeBonus(mistle_upgrade_berry).addr(1);
result.mulInPlace(mul);
if(breakdown) breakdown.push(['ethereal mistletoe berry-ness', true, mul, result.clone()]);
}
}
if(this.type == CROPTYPE_NUT) {
if(haveEtherealMistletoeUpgrade(mistle_upgrade_nuts)) {
var mul = getEtherealMistletoeBonus(mistle_upgrade_nuts).addr(1);
result.mulInPlace(mul);
if(breakdown) breakdown.push(['ethereal mistletoe nuttiness', true, mul, result.clone()]);
}
}
if(this.type == CROPTYPE_MUSH) {
if(haveEtherealMistletoeUpgrade(mistle_upgrade_mush)) {
var mul = getEtherealMistletoeBonus(mistle_upgrade_mush).addr(1);
result.mulInPlace(mul);
if(breakdown) breakdown.push(['ethereal mistletoe funginess', true, mul, result.clone()]);
}
}
}
var season = getSeason();
// flower boost
if(f && (this.type == CROPTYPE_BERRY || this.type == CROPTYPE_MUSH || this.type == CROPTYPE_PUMPKIN)) {
var mul_boost = Num(1);
var num = 0;
var x = f.x, y = f.y, w = state.numw, h = state.numh;
var dirs = f.getNeighborDirsFrom(false);
for(var dir = 0; dir < dirs.length; dir++) {
var x2 = x + dirs[dir][0];
var y2 = y + dirs[dir][1];
if(x2 < 0 || x2 >= w || y2 < 0 || y2 >= h) continue;
var n = state.field[y2][x2];
if(n.hasRealCrop() && n.getCrop().type == CROPTYPE_FLOWER) {
var boost;
if(pretend) boost = n.getCrop().getBoost(n, pretend);
else boost = prefield[n.y][n.x].boost;
if(boost.neqr(0)) {
mul_boost.addInPlace(boost);
num++;
}
}
}
result.mulInPlace(mul_boost);
if(breakdown && num > 0) breakdown.push(['flowers (' + num + ')', true, mul_boost, result.clone()]);
}
// flower boost for nuts
if(f && (this.type == CROPTYPE_NUT)) {
var mul_boost = Num(1);
var num = 0;
var x = f.x, y = f.y, w = state.numw, h = state.numh;
// require good tier flowers for the nut, don't benefit from low unupgraded flowers next to nuts
var min_tier = state.highestoftypeplanted[CROPTYPE_FLOWER] - 1;
for(var dir = 0; dir < 4; dir++) { // get the neighbors N,E,S,W
var x2 = x + (dir == 1 ? 1 : (dir == 3 ? -1 : 0));
var y2 = y + (dir == 2 ? 1 : (dir == 0 ? -1 : 0));
if(x2 < 0 || x2 >= w || y2 < 0 || y2 >= h) continue;
var n = state.field[y2][x2];
if(n.hasRealCrop() && n.getCrop().type == CROPTYPE_FLOWER && n.getCrop().tier >= min_tier) {
mul_boost.addInPlace(flower_nut_boost.mulr(n.growth));
num++;
}
}
result.mulInPlace(mul_boost);
if(breakdown && num > 0) breakdown.push(['flowers (' + num + ', ' + flower_nut_boost.toPercentString() + ' each)', true, mul_boost, result.clone()]);
}
// nettle malus
if(f && (this.type == CROPTYPE_BERRY || this.type == CROPTYPE_NUT || this.type == CROPTYPE_PUMPKIN)) {
var p = prefield[f.y][f.x];