Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
mamayaya1
GitHub Repository: mamayaya1/game
Path: blob/main/projects/cookie-clicker/minigameGarden.js
4626 views
1
var M={};
2
M.parent=Game.Objects['Farm'];
3
M.parent.minigame=M;
4
M.launch=function()
5
{
6
var M=this;
7
M.name=M.parent.minigameName;
8
M.init=function(div)
9
{
10
//populate div with html and initialize values
11
12
/*
13
plants age from 0 to 100
14
at one point in its lifespan, the plant becomes mature
15
plants have 4 life stages once planted : bud, sprout, bloom, mature
16
a plant may age faster by having a higher .ageTick
17
if a plant has .ageTickR, a random number between 0 and that amount is added to .ageTick
18
a plant may mature faster by having a lower .mature
19
a plant's effects depend on how mature it is
20
a plant can only reproduce when mature
21
*/
22
M.plants={
23
'bakerWheat':{
24
name:'Baker\'s wheat',
25
icon:0,
26
cost:1,
27
costM:30,
28
ageTick:7,
29
ageTickR:2,
30
mature:35,
31
children:['bakerWheat','thumbcorn','cronerice','bakeberry','clover','goldenClover','chocoroot','tidygrass'],
32
effsStr:'<div class="green">&bull; +1% CpS</div>',
33
q:'A plentiful crop whose hardy grain is used to make flour for pastries.',
34
onHarvest:function(x,y,age)
35
{
36
if (age>=this.mature) M.dropUpgrade('Wheat slims',0.001);
37
},
38
},
39
'thumbcorn':{
40
name:'Thumbcorn',
41
icon:1,
42
cost:5,
43
costM:100,
44
ageTick:6,
45
ageTickR:2,
46
mature:20,
47
children:['bakerWheat','thumbcorn','cronerice','gildmillet','glovemorel'],
48
effsStr:'<div class="green">&bull; +2% cookies per click</div>',
49
q:'A strangely-shaped variant of corn. The amount of strands that can sprout from one seed is usually in the single digits.',
50
},
51
'cronerice':{
52
name:'Cronerice',
53
icon:2,
54
cost:15,
55
costM:250,
56
ageTick:0.4,
57
ageTickR:0.7,
58
mature:55,
59
children:['thumbcorn','gildmillet','elderwort','wardlichen'],
60
effsStr:'<div class="green">&bull; +3% grandma CpS</div>',
61
q:'Not only does this wrinkly bulb look nothing like rice, it\'s not even related to it either; its closest extant relative is the weeping willow.',
62
},
63
'gildmillet':{
64
name:'Gildmillet',
65
icon:3,
66
cost:15,
67
costM:1500,
68
ageTick:2,
69
ageTickR:1.5,
70
mature:40,
71
children:['clover','goldenClover','shimmerlily'],
72
effsStr:'<div class="green">&bull; +1% golden cookie gains</div><div class="green">&bull; +0.1% golden cookie effect duration</div>',
73
q:'An ancient staple crop, famed for its golden sheen. Was once used to bake birthday cakes for kings and queens of old.',
74
},
75
'clover':{
76
name:'Ordinary clover',
77
icon:4,
78
cost:25,
79
costM:77777,
80
ageTick:1,
81
ageTickR:1.5,
82
mature:35,
83
children:['goldenClover','greenRot','shimmerlily'],
84
effsStr:'<div class="green">&bull; +1% golden cookie frequency</div>',
85
q:'<i>Trifolium repens</i>, a fairly mundane variety of clover with a tendency to produce four leaves. Such instances are considered lucky by some.',
86
},
87
'goldenClover':{
88
name:'Golden clover',
89
icon:5,
90
cost:125,
91
costM:777777777777,
92
ageTick:4,
93
ageTickR:12,
94
mature:50,
95
children:[],
96
effsStr:'<div class="green">&bull; +3% golden cookie frequency</div>',
97
q:'A variant of the ordinary clover that traded its chlorophyll for pure organic gold. Tragically short-lived, this herb is an evolutionary dead-end - but at least it looks pretty.',
98
},
99
'shimmerlily':{
100
name:'Shimmerlily',
101
icon:6,
102
cost:60,
103
costM:777777,
104
ageTick:5,
105
ageTickR:6,
106
mature:70,
107
children:['elderwort','whiskerbloom','chimerose','cheapcap'],
108
effsStr:'<div class="green">&bull; +1% golden cookie gains</div><div class="green">&bull; +1% golden cookie frequency</div><div class="green">&bull; +1% random drops</div>',
109
q:'These little flowers are easiest to find at dawn, as the sunlight refracting in dew drops draws attention to their pure-white petals.',
110
},
111
'elderwort':{
112
name:'Elderwort',
113
icon:7,
114
cost:60*3,
115
costM:100000000,
116
ageTick:0.3,
117
ageTickR:0.5,
118
mature:90,
119
immortal:1,
120
noContam:true,
121
detailsStr:'Immortal',
122
children:['everdaisy','ichorpuff','shriekbulb'],
123
effsStr:'<div class="green">&bull; +1% wrath cookie gains</div><div class="green">&bull; +1% wrath cookie frequency</div><div class="green">&bull; +1% grandma CpS</div><div class="green">&bull; immortal</div><div class="gray">&bull; surrounding plants (3x3) age 3% faster</div>',
124
q:'A very old, long-forgotten subspecies of edelweiss that emits a strange, heady scent. There is some anecdotal evidence that these do not undergo molecular aging.',
125
onHarvest:function(x,y,age)
126
{
127
if (age>=this.mature) M.dropUpgrade('Elderwort biscuits',0.01);
128
},
129
},
130
'bakeberry':{
131
name:'Bakeberry',
132
icon:8,
133
cost:45,
134
costM:100000000,
135
ageTick:1,
136
ageTickR:1,
137
mature:50,
138
children:['queenbeet'],
139
effsStr:'<div class="green">&bull; +1% CpS</div><div class="green">&bull; harvest when mature for +30 minutes of CpS (max. 3% of bank)</div>',
140
q:'A favorite among cooks, this large berry has a crunchy brown exterior and a creamy red center. Excellent in pies or chicken stews.',
141
onHarvest:function(x,y,age)
142
{
143
if (age>=this.mature)
144
{
145
var moni=Math.min(Game.cookies*0.03,Game.cookiesPs*60*30);
146
if (moni!=0)
147
{
148
Game.Earn(moni);
149
Game.Popup('(Bakeberry)<br>+'+Beautify(moni)+' cookies!',Game.mouseX,Game.mouseY);
150
}
151
M.dropUpgrade('Bakeberry cookies',0.015);
152
}
153
},
154
},
155
'chocoroot':{
156
name:'Chocoroot',
157
icon:9,
158
cost:15,
159
costM:100000,
160
ageTick:4,
161
ageTickR:0,
162
mature:25,
163
detailsStr:'Predictable growth',
164
children:['whiteChocoroot','drowsyfern','queenbeet'],
165
effsStr:'<div class="green">&bull; +1% CpS</div><div class="green">&bull; harvest when mature for +3 minutes of CpS (max. 3% of bank)</div><div class="green">&bull; predictable growth</div>',
166
q:'A tangly bramble coated in a sticky, sweet substance. Unknown genetic ancestry. Children often pick these from fields as-is as a snack.',
167
onHarvest:function(x,y,age)
168
{
169
if (age>=this.mature)
170
{
171
var moni=Math.min(Game.cookies*0.03,Game.cookiesPs*60*3);
172
if (moni!=0)
173
{
174
Game.Earn(moni);
175
Game.Popup('(Chocoroot)<br>+'+Beautify(moni)+' cookies!',Game.mouseX,Game.mouseY);
176
}
177
}
178
},
179
},
180
'whiteChocoroot':{
181
name:'White chocoroot',
182
icon:10,
183
cost:15,
184
costM:100000,
185
ageTick:4,
186
ageTickR:0,
187
mature:25,
188
detailsStr:'Predictable growth',
189
children:['whiskerbloom','tidygrass'],
190
effsStr:'<div class="green">&bull; +1% golden cookie gains</div><div class="green">&bull; harvest when mature for +3 minutes of CpS (max. 3% of bank)</div><div class="green">&bull; predictable growth</div>',
191
q:'A pale, even sweeter variant of the chocoroot. Often impedes travelers with its twisty branches.',
192
onHarvest:function(x,y,age)
193
{
194
if (age>=this.mature)
195
{
196
var moni=Math.min(Game.cookies*0.03,Game.cookiesPs*60*3);
197
if (moni!=0)
198
{
199
Game.Earn(moni);
200
Game.Popup('(White chocoroot)<br>+'+Beautify(moni)+' cookies!',Game.mouseX,Game.mouseY);
201
}
202
}
203
},
204
},
205
206
'whiteMildew':{
207
name:'White mildew',
208
fungus:true,
209
icon:26,
210
cost:20,
211
costM:9999,
212
ageTick:8,
213
ageTickR:12,
214
mature:70,
215
detailsStr:'Spreads easily',
216
children:['brownMold','whiteChocoroot','wardlichen','greenRot'],
217
effsStr:'<div class="green">&bull; +1% CpS</div><div class="gray">&bull; may spread as brown mold</div>',
218
q:'A common rot that infests shady plots of earth. Grows in little creamy capsules. Smells sweet, but sadly wilts quickly.',
219
},
220
'brownMold':{
221
name:'Brown mold',
222
fungus:true,
223
icon:27,
224
cost:20,
225
costM:9999,
226
ageTick:8,
227
ageTickR:12,
228
mature:70,
229
detailsStr:'Spreads easily',
230
children:['whiteMildew','chocoroot','keenmoss','wrinklegill'],
231
effsStr:'<div class="red">&bull; -1% CpS</div><div class="gray">&bull; may spread as white mildew</div>',
232
q:'A common rot that infests shady plots of earth. Grows in odd reddish clumps. Smells bitter, but thankfully wilts quickly.',
233
},
234
235
'meddleweed':{
236
name:'Meddleweed',
237
weed:true,
238
icon:29,
239
cost:1,
240
costM:10,
241
ageTick:10,
242
ageTickR:6,
243
mature:50,
244
contam:0.05,
245
detailsStr:'Grows in empty tiles, spreads easily',
246
children:['meddleweed','brownMold','crumbspore'],
247
effsStr:'<div class="red">&bull; useless</div><div class="red">&bull; may overtake nearby plants</div><div class="gray">&bull; may sometimes drop spores when uprooted</div>',
248
q:'The sign of a neglected farmland, this annoying weed spawns from unused dirt and may sometimes spread to other plants, killing them in the process.',
249
onKill:function(x,y,age)
250
{
251
if (Math.random()<0.2*(age/100)) M.plot[y][x]=[M.plants[choose(['brownMold','crumbspore'])].id+1,0];
252
},
253
},
254
255
'whiskerbloom':{
256
name:'Whiskerbloom',
257
icon:11,
258
cost:20,
259
costM:1000000,
260
ageTick:2,
261
ageTickR:2,
262
mature:60,
263
children:['chimerose','nursetulip'],
264
effsStr:'<div class="green">&bull; +0.2% effects from milk</div>',
265
q:'Squeezing the translucent pods makes them excrete a milky liquid, while producing a faint squeak akin to a cat\'s meow.',
266
},
267
'chimerose':{
268
name:'Chimerose',
269
icon:12,
270
cost:15,
271
costM:242424,
272
ageTick:1,
273
ageTickR:1.5,
274
mature:30,
275
children:['chimerose'],
276
effsStr:'<div class="green">&bull; +1% reindeer gains</div><div class="green">&bull; +1% reindeer frequency</div>',
277
q:'Originating in the greener flanks of polar mountains, this beautiful flower with golden accents is fragrant enough to make any room feel a little bit more festive.',
278
},
279
'nursetulip':{
280
name:'Nursetulip',
281
icon:13,
282
cost:40,
283
costM:1000000000,
284
ageTick:0.5,
285
ageTickR:2,
286
mature:60,
287
children:[],
288
effsStr:'<div class="green">&bull; surrounding plants (3x3) are 20% more efficient</div><div class="red">&bull; -2% CpS</div>',
289
q:'This flower grows an intricate root network that distributes nutrients throughout the surrounding soil. The reason for this seemingly altruistic behavior is still unknown.',
290
},
291
'drowsyfern':{
292
name:'Drowsyfern',
293
icon:14,
294
cost:90,
295
costM:100000,
296
ageTick:0.05,
297
ageTickR:0.1,
298
mature:30,
299
children:[],
300
effsStr:'<div class="green">&bull; +3% CpS</div><div class="red">&bull; -5% cookies per click</div><div class="red">&bull; -10% golden cookie frequency</div>',
301
q:'Traditionally used to brew a tea that guarantees a good night of sleep.',
302
onHarvest:function(x,y,age)
303
{
304
if (age>=this.mature) M.dropUpgrade('Fern tea',0.01);
305
},
306
},
307
'wardlichen':{
308
name:'Wardlichen',
309
icon:15,
310
cost:10,
311
costM:10000,
312
ageTick:5,
313
ageTickR:4,
314
mature:65,
315
children:['wardlichen'],
316
effsStr:'<div class="gray">&bull; 2% less wrath cookies</div><div class="gray">&bull; wrinklers spawn 15% slower</div>',
317
q:'The metallic stench that emanates from this organism has been known to keep insects and slugs away.',
318
},
319
'keenmoss':{
320
name:'Keenmoss',
321
icon:16,
322
cost:50,
323
costM:1000000,
324
ageTick:4,
325
ageTickR:5,
326
mature:65,
327
children:['drowsyfern','wardlichen','keenmoss'],
328
effsStr:'<div class="green">&bull; +3% random drops</div>',
329
q:'Fuzzy to the touch and of a vibrant green. In plant symbolism, keenmoss is associated with good luck for finding lost objects.',
330
},
331
'queenbeet':{
332
name:'Queenbeet',
333
icon:17,
334
cost:60*1.5,
335
costM:1000000000,
336
ageTick:1,
337
ageTickR:0.4,
338
mature:80,
339
noContam:true,
340
children:['duketater','queenbeetLump','shriekbulb'],
341
effsStr:'<div class="green">&bull; +0.3% golden cookie effect duration</div><div class="red">&bull; -2% CpS</div><div class="green">&bull; harvest when mature for +1 hour of CpS (max. 4% of bank)</div>',
342
q:'A delicious taproot used to prepare high-grade white sugar. Entire countries once went to war over these.',
343
onHarvest:function(x,y,age)
344
{
345
if (age>=this.mature)
346
{
347
var moni=Math.min(Game.cookies*0.04,Game.cookiesPs*60*60);
348
if (moni!=0)
349
{
350
Game.Earn(moni);
351
Game.Popup('(Queenbeet)<br>+'+Beautify(moni)+' cookies!',Game.mouseX,Game.mouseY);
352
}
353
}
354
},
355
},
356
'queenbeetLump':{
357
name:'Juicy queenbeet',
358
icon:18,
359
plantable:false,
360
cost:60*2,
361
costM:1000000000000,
362
ageTick:0.04,
363
ageTickR:0.08,
364
mature:85,
365
noContam:true,
366
children:[],
367
effsStr:'<div class="red">&bull; -10% CpS</div><div class="red">&bull; surrounding plants (3x3) are 20% less efficient</div><div class="green">&bull; harvest when mature for a sugar lump</div>',
368
q:'A delicious taproot used to prepare high-grade white sugar. Entire countries once went to war over these.<br>It looks like this one has grown especially sweeter and juicier from growing in close proximity to other queenbeets.',
369
onHarvest:function(x,y,age)
370
{
371
if (age>=this.mature)
372
{
373
Game.gainLumps(1);
374
popup='(Juicy queenbeet)<br>Sweet!<div style="font-size:65%;">Found 1 sugar lump!</div>';
375
}
376
},
377
},
378
'duketater':{
379
name:'Duketater',
380
icon:19,
381
cost:60*8,
382
costM:1000000000000,
383
ageTick:0.4,
384
ageTickR:0.1,
385
mature:95,
386
noContam:true,
387
children:['shriekbulb'],
388
effsStr:'<div class="green">&bull; harvest when mature for +2 hours of CpS (max. 8% of bank)</div>',
389
q:'A rare, rich-tasting tuber fit for a whole meal, as long as its strict harvesting schedule is respected. Its starch has fascinating baking properties.',
390
onHarvest:function(x,y,age)
391
{
392
if (age>=this.mature)
393
{
394
var moni=Math.min(Game.cookies*0.08,Game.cookiesPs*60*60*2);
395
if (moni!=0)
396
{
397
Game.Earn(moni);
398
Game.Popup('(Duketater)<br>+'+Beautify(moni)+' cookies!',Game.mouseX,Game.mouseY);
399
}
400
M.dropUpgrade('Duketater cookies',0.005);
401
}
402
},
403
},
404
'crumbspore':{
405
name:'Crumbspore',
406
fungus:true,
407
icon:20,
408
cost:10,
409
costM:999,
410
ageTick:3,
411
ageTickR:3,
412
mature:65,
413
contam:0.03,
414
noContam:true,
415
detailsStr:'Spreads easily',
416
children:['crumbspore','glovemorel','cheapcap','doughshroom','wrinklegill','ichorpuff'],
417
effsStr:'<div class="green">&bull; explodes into up to 1 minute of CpS at the end of its lifecycle (max. 1% of bank)</div><div class="red">&bull; may overtake nearby plants</div>',
418
q:'An archaic mold that spreads its spores to the surrounding dirt through simple pod explosion.',
419
onDie:function(x,y)
420
{
421
var moni=Math.min(Game.cookies*0.01,Game.cookiesPs*60)*Math.random();
422
if (moni!=0)
423
{
424
Game.Earn(moni);
425
Game.Popup('(Crumbspore)<br>+'+Beautify(moni)+' cookies!',Game.mouseX,Game.mouseY);
426
}
427
},
428
},
429
'doughshroom':{
430
name:'Doughshroom',
431
fungus:true,
432
icon:24,
433
cost:100,
434
costM:100000000,
435
ageTick:1,
436
ageTickR:2,
437
mature:85,
438
contam:0.03,
439
noContam:true,
440
detailsStr:'Spreads easily',
441
children:['crumbspore','doughshroom','foolBolete','shriekbulb'],
442
effsStr:'<div class="green">&bull; explodes into up to 5 minutes of CpS at the end of its lifecycle (max. 3% of bank)</div><div class="red">&bull; may overtake nearby plants</div>',
443
q:'Jammed full of warm spores; some forest walkers often describe the smell as similar to passing by a bakery.',
444
onDie:function(x,y)
445
{
446
var moni=Math.min(Game.cookies*0.03,Game.cookiesPs*60*5)*Math.random();
447
if (moni!=0)
448
{
449
Game.Earn(moni);
450
Game.Popup('(Doughshroom)<br>+'+Beautify(moni)+' cookies!',Game.mouseX,Game.mouseY);
451
}
452
},
453
},
454
'glovemorel':{
455
name:'Glovemorel',
456
fungus:true,
457
icon:21,
458
cost:30,
459
costM:10000,
460
ageTick:3,
461
ageTickR:18,
462
mature:80,
463
children:[],
464
effsStr:'<div class="green">&bull; +4% cookies per click</div><div class="green">&bull; +1% cursor CpS</div><div class="red">&bull; -1% CpS</div>',
465
q:'Touching its waxy skin reveals that the interior is hollow and uncomfortably squishy.',
466
},
467
'cheapcap':{
468
name:'Cheapcap',
469
fungus:true,
470
icon:22,
471
cost:40,
472
costM:100000,
473
ageTick:6,
474
ageTickR:16,
475
mature:40,
476
children:[],
477
effsStr:'<div class="green">&bull; buildings and upgrades are 0.2% cheaper</div><div class="red">&bull; cannot handle cold climates; 15% chance to die when frozen</div>',
478
q:'Small, tough, and good in omelettes. Some historians propose that the heads of dried cheapcaps were once used as currency in some bronze age societies.',
479
},
480
'foolBolete':{
481
name:'Fool\'s bolete',
482
fungus:true,
483
icon:23,
484
cost:15,
485
costM:10000,
486
ageTick:5,
487
ageTickR:25,
488
mature:50,
489
children:[],
490
effsStr:'<div class="green">&bull; +2% golden cookie frequency</div><div class="red">&bull; -5% golden cookie gains</div><div class="red">&bull; -2% golden cookie duration</div><div class="red">&bull; -2% golden cookie effect duration</div>',
491
q:'Named for its ability to fool mushroom pickers. The fool\'s bolete is not actually poisonous, it\'s just extremely bland.',
492
},
493
'wrinklegill':{
494
name:'Wrinklegill',
495
fungus:true,
496
icon:25,
497
cost:20,
498
costM:1000000,
499
ageTick:1,
500
ageTickR:3,
501
mature:65,
502
children:['elderwort','shriekbulb'],
503
effsStr:'<div class="gray">&bull; wrinklers spawn 2% faster</div><div class="gray">&bull; wrinklers eat 1% more</div>',
504
q:'This mushroom\'s odor resembles that of a well-done steak, and is said to whet the appetite - making one\'s stomach start gurgling within seconds.',
505
},
506
'greenRot':{
507
name:'Green rot',
508
fungus:true,
509
icon:28,
510
cost:60,
511
costM:1000000,
512
ageTick:12,
513
ageTickR:13,
514
mature:65,
515
children:['keenmoss','foolBolete'],
516
effsStr:'<div class="green">&bull; +0.5% golden cookie duration</div><div class="green">&bull; +1% golden cookie frequency</div><div class="green">&bull; +1% random drops</div>',
517
q:'This short-lived mold is also known as "emerald pebbles", and is considered by some as a pseudo-gem that symbolizes good fortune.',
518
onHarvest:function(x,y,age)
519
{
520
if (age>=this.mature) M.dropUpgrade('Green yeast digestives',0.005);
521
},
522
},
523
'shriekbulb':{
524
name:'Shriekbulb',
525
icon:30,
526
cost:60,
527
costM:4444444444444,
528
ageTick:3,
529
ageTickR:1,
530
mature:60,
531
noContam:true,
532
detailsStr:'The unfortunate result of some plant combinations',
533
children:['shriekbulb'],
534
effsStr:'<div class="red">&bull; -2% CpS</div><div class="red">&bull; surrounding plants (3x3) are 5% less efficient</div>',
535
q:'A nasty vegetable with a dreadful quirk : its flesh resonates with a high-pitched howl whenever it is hit at the right angle by sunlight, moonlight, or even a slight breeze.',
536
},
537
'tidygrass':{
538
name:'Tidygrass',
539
icon:31,
540
cost:90,
541
costM:100000000000000,
542
ageTick:0.5,
543
ageTickR:0,
544
mature:40,
545
children:['everdaisy'],
546
effsStr:'<div class="green">&bull; surrounding tiles (5x5) develop no weeds or fungus</div>',
547
q:'The molecules this grass emits are a natural weedkiller. Its stems grow following a predictable pattern, making it an interesting -if expensive- choice for a lawn grass.',
548
},
549
'everdaisy':{
550
name:'Everdaisy',
551
icon:32,
552
cost:180,
553
costM:100000000000000000000,
554
ageTick:0.3,
555
ageTickR:0,
556
mature:75,
557
noContam:true,
558
immortal:1,
559
detailsStr:'Immortal',
560
children:[],
561
effsStr:'<div class="green">&bull; surrounding tiles (3x3) develop no weeds or fungus</div><div class="green">&bull; immortal</div>',
562
q:'While promoted by some as a superfood owing to its association with longevity and intriguing geometry, this elusive flower is actually mildly toxic.',
563
},
564
'ichorpuff':{
565
name:'Ichorpuff',
566
fungus:true,
567
icon:33,
568
cost:120,
569
costM:987654321,
570
ageTick:1,
571
ageTickR:1.5,
572
mature:35,
573
children:[],
574
effsStr:'<div class="green">&bull; surrounding plants (3x3) age half as fast</div><div class="red">&bull; surrounding plants (3x3) are half as efficient</div>',
575
q:'This puffball mushroom contains sugary spores, but it never seems to mature to bursting on its own. Surrounding plants under its influence have a very slow metabolism, reducing their effects but lengthening their lifespan.',
576
onHarvest:function(x,y,age)
577
{
578
if (age>=this.mature) M.dropUpgrade('Ichor syrup',0.005);
579
},
580
},
581
};
582
M.plantsById=[];var n=0;
583
for (var i in M.plants)
584
{
585
M.plants[i].unlocked=0;
586
M.plants[i].id=n;
587
M.plants[i].key=i;
588
M.plants[i].matureBase=M.plants[i].mature;
589
M.plantsById[n]=M.plants[i];
590
if (typeof M.plants[i].plantable==='undefined') {M.plants[i].plantable=true;}
591
n++;
592
}
593
M.plantsN=M.plantsById.length;
594
M.plantsUnlockedN=0;
595
M.getUnlockedN=function()
596
{
597
M.plantsUnlockedN=0;
598
for (var i in M.plants){if (M.plants[i].unlocked) M.plantsUnlockedN++;}
599
if (M.plantsUnlockedN>=M.plantsN)
600
{
601
Game.Win('Keeper of the conservatory');
602
l('gardenTool-3').classList.remove('locked');
603
}
604
else l('gardenTool-3').classList.add('locked');
605
606
return M.plantsUnlockedN;
607
}
608
609
M.dropUpgrade=function(upgrade,rate)
610
{
611
if (!Game.Has(upgrade) && Math.random()<=rate*Game.dropRateMult()*(Game.HasAchiev('Seedless to nay')?1.05:1))
612
{
613
Game.Unlock(upgrade);
614
}
615
}
616
617
M.computeMatures=function()
618
{
619
var mult=1;
620
if (Game.HasAchiev('Seedless to nay')) mult=0.95;
621
for (var i in M.plants)
622
{
623
M.plants[i].mature=M.plants[i].matureBase*mult;
624
}
625
}
626
627
M.plantContam={};
628
for (var i in M.plants)
629
{
630
if (M.plants[i].contam) M.plantContam[M.plants[i].key]=M.plants[i].contam;
631
}
632
633
M.getMuts=function(neighs,neighsM)
634
{
635
//get possible mutations given a list of neighbors
636
//note : neighs stands for neighbors, not horsey noises
637
var muts=[];
638
639
if (neighsM['bakerWheat']>=2) muts.push(['bakerWheat',0.2],['thumbcorn',0.05],['bakeberry',0.001]);
640
if (neighsM['bakerWheat']>=1 && neighsM['thumbcorn']>=1) muts.push(['cronerice',0.01]);
641
if (neighsM['thumbcorn']>=2) muts.push(['thumbcorn',0.1],['bakerWheat',0.05]);
642
if (neighsM['cronerice']>=1 && neighsM['thumbcorn']>=1) muts.push(['gildmillet',0.03]);
643
if (neighsM['cronerice']>=2) muts.push(['thumbcorn',0.02]);
644
if (neighsM['bakerWheat']>=1 && neighsM['gildmillet']>=1) muts.push(['clover',0.03],['goldenClover',0.0007]);
645
if (neighsM['clover']>=1 && neighsM['gildmillet']>=1) muts.push(['shimmerlily',0.02]);
646
if (neighsM['clover']>=2 && neighs['clover']<5) muts.push(['clover',0.007],['goldenClover',0.0001]);
647
if (neighsM['clover']>=4) muts.push(['goldenClover',0.0007]);
648
if (neighsM['shimmerlily']>=1 && neighsM['cronerice']>=1) muts.push(['elderwort',0.01]);
649
if (neighsM['wrinklegill']>=1 && neighsM['cronerice']>=1) muts.push(['elderwort',0.002]);
650
if (neighsM['bakerWheat']>=1 && neighs['brownMold']>=1) muts.push(['chocoroot',0.1]);
651
if (neighsM['chocoroot']>=1 && neighs['whiteMildew']>=1) muts.push(['whiteChocoroot',0.1]);
652
if (neighsM['whiteMildew']>=1 && neighs['brownMold']<=1) muts.push(['brownMold',0.5]);
653
if (neighsM['brownMold']>=1 && neighs['whiteMildew']<=1) muts.push(['whiteMildew',0.5]);
654
if (neighsM['meddleweed']>=1 && neighs['meddleweed']<=3) muts.push(['meddleweed',0.15]);
655
656
if (neighsM['shimmerlily']>=1 && neighsM['whiteChocoroot']>=1) muts.push(['whiskerbloom',0.01]);
657
if (neighsM['shimmerlily']>=1 && neighsM['whiskerbloom']>=1) muts.push(['chimerose',0.05]);
658
if (neighsM['chimerose']>=2) muts.push(['chimerose',0.005]);
659
if (neighsM['whiskerbloom']>=2) muts.push(['nursetulip',0.05]);
660
if (neighsM['chocoroot']>=1 && neighsM['keenmoss']>=1) muts.push(['drowsyfern',0.005]);
661
if ((neighsM['cronerice']>=1 && neighsM['keenmoss']>=1) || (neighsM['cronerice']>=1 && neighsM['whiteMildew']>=1)) muts.push(['wardlichen',0.005]);
662
if (neighsM['wardlichen']>=1 && neighs['wardlichen']<2) muts.push(['wardlichen',0.05]);
663
if (neighsM['greenRot']>=1 && neighsM['brownMold']>=1) muts.push(['keenmoss',0.1]);
664
if (neighsM['keenmoss']>=1 && neighs['keenmoss']<2) muts.push(['keenmoss',0.05]);
665
if (neighsM['chocoroot']>=1 && neighsM['bakeberry']>=1) muts.push(['queenbeet',0.01]);
666
if (neighsM['queenbeet']>=8) muts.push(['queenbeetLump',0.001]);
667
if (neighsM['queenbeet']>=2) muts.push(['duketater',0.001]);
668
669
if (neighsM['crumbspore']>=1 && neighs['crumbspore']<=1) muts.push(['crumbspore',0.07]);
670
if (neighsM['crumbspore']>=1 && neighsM['thumbcorn']>=1) muts.push(['glovemorel',0.02]);
671
if (neighsM['crumbspore']>=1 && neighsM['shimmerlily']>=1) muts.push(['cheapcap',0.04]);
672
if (neighsM['doughshroom']>=1 && neighsM['greenRot']>=1) muts.push(['foolBolete',0.04]);
673
if (neighsM['crumbspore']>=2) muts.push(['doughshroom',0.005]);
674
if (neighsM['doughshroom']>=1 && neighs['doughshroom']<=1) muts.push(['doughshroom',0.07]);
675
if (neighsM['doughshroom']>=2) muts.push(['crumbspore',0.005]);
676
if (neighsM['crumbspore']>=1 && neighsM['brownMold']>=1) muts.push(['wrinklegill',0.06]);
677
if (neighsM['whiteMildew']>=1 && neighsM['clover']>=1) muts.push(['greenRot',0.05]);
678
679
if (neighsM['wrinklegill']>=1 && neighsM['elderwort']>=1) muts.push(['shriekbulb',0.001]);
680
if (neighsM['elderwort']>=5) muts.push(['shriekbulb',0.001]);
681
if (neighs['duketater']>=3) muts.push(['shriekbulb',0.005]);
682
if (neighs['doughshroom']>=4) muts.push(['shriekbulb',0.002]);
683
if (neighsM['queenbeet']>=5) muts.push(['shriekbulb',0.001]);
684
if (neighs['shriekbulb']>=1 && neighs['shriekbulb']<2) muts.push(['shriekbulb',0.005]);
685
686
if (neighsM['bakerWheat']>=1 && neighsM['whiteChocoroot']>=1) muts.push(['tidygrass',0.002]);
687
if (neighsM['tidygrass']>=3 && neighsM['elderwort']>=3) muts.push(['everdaisy',0.002]);
688
if (neighsM['elderwort']>=1 && neighsM['crumbspore']>=1) muts.push(['ichorpuff',0.002]);
689
690
return muts;
691
}
692
693
M.computeBoostPlot=function()
694
{
695
//some plants apply effects to surrounding tiles
696
//this function computes those effects by creating a grid in which those effects stack
697
for (var y=0;y<6;y++)
698
{
699
for (var x=0;x<6;x++)
700
{
701
//age mult, power mult, weed mult
702
M.plotBoost[y][x]=[1,1,1];
703
}
704
}
705
706
var effectOn=function(X,Y,s,mult)
707
{
708
for (var y=Math.max(0,Y-s);y<Math.min(6,Y+s+1);y++)
709
{
710
for (var x=Math.max(0,X-s);x<Math.min(6,X+s+1);x++)
711
{
712
if (X==x && Y==y) {}
713
else
714
{
715
for (var i=0;i<mult.length;i++)
716
{
717
M.plotBoost[y][x][i]*=mult[i];
718
}
719
}
720
}
721
}
722
}
723
for (var y=0;y<6;y++)
724
{
725
for (var x=0;x<6;x++)
726
{
727
var tile=M.plot[y][x];
728
if (tile[0]>0)
729
{
730
var me=M.plantsById[tile[0]-1];
731
var name=me.key;
732
var stage=0;
733
if (tile[1]>=me.mature) stage=4;
734
else if (tile[1]>=me.mature*0.666) stage=3;
735
else if (tile[1]>=me.mature*0.333) stage=2;
736
else stage=1;
737
738
var soilMult=M.soilsById[M.soil].effMult;
739
var mult=soilMult;
740
741
if (stage==1) mult*=0.1;
742
else if (stage==2) mult*=0.25;
743
else if (stage==3) mult*=0.5;
744
else mult*=1;
745
746
//age mult, power mult, weed mult
747
/*if (name=='elderwort') effectOn(x,y,1,[1+0.03*mult,1,1]);
748
else if (name=='queenbeetLump') effectOn(x,y,1,[1,1-0.2*mult,1]);
749
else if (name=='nursetulip') effectOn(x,y,1,[1,1+0.2*mult,1]);
750
else if (name=='shriekbulb') effectOn(x,y,1,[1,1-0.05*mult,1]);
751
else if (name=='tidygrass') effectOn(x,y,2,[1,1,0]);
752
else if (name=='everdaisy') effectOn(x,y,1,[1,1,0]);
753
else if (name=='ichorpuff') effectOn(x,y,1,[1-0.5*mult,1-0.5*mult,1]);*/
754
755
var ageMult=1;
756
var powerMult=1;
757
var weedMult=1;
758
var range=0;
759
760
if (name=='elderwort') {ageMult=1.03;range=1;}
761
else if (name=='queenbeetLump') {powerMult=0.8;range=1;}
762
else if (name=='nursetulip') {powerMult=1.2;range=1;}
763
else if (name=='shriekbulb') {powerMult=0.95;range=1;}
764
else if (name=='tidygrass') {weedMult=0;range=2;}
765
else if (name=='everdaisy') {weedMult=0;range=1;}
766
else if (name=='ichorpuff') {ageMult=0.5;powerMult=0.5;range=1;}
767
768
//by god i hope these are right
769
if (ageMult>=1) ageMult=(ageMult-1)*mult+1; else if (mult>=1) ageMult=1/((1/ageMult)*mult); else ageMult=1-(1-ageMult)*mult;
770
if (powerMult>=1) powerMult=(powerMult-1)*mult+1; else if (mult>=1) powerMult=1/((1/powerMult)*mult); else powerMult=1-(1-powerMult)*mult;
771
772
if (range>0) effectOn(x,y,range,[ageMult,powerMult,weedMult]);
773
}
774
}
775
}
776
}
777
778
M.computeEffs=function()
779
{
780
M.toCompute=false;
781
var effs={
782
cps:1,
783
click:1,
784
cursorCps:1,
785
grandmaCps:1,
786
goldenCookieGain:1,
787
goldenCookieFreq:1,
788
goldenCookieDur:1,
789
goldenCookieEffDur:1,
790
wrathCookieGain:1,
791
wrathCookieFreq:1,
792
wrathCookieDur:1,
793
wrathCookieEffDur:1,
794
reindeerGain:1,
795
reindeerFreq:1,
796
reindeerDur:1,
797
itemDrops:1,
798
milk:1,
799
wrinklerSpawn:1,
800
wrinklerEat:1,
801
upgradeCost:1,
802
buildingCost:1,
803
};
804
805
if (!M.freeze)
806
{
807
var soilMult=M.soilsById[M.soil].effMult;
808
809
for (var y=0;y<6;y++)
810
{
811
for (var x=0;x<6;x++)
812
{
813
var tile=M.plot[y][x];
814
if (tile[0]>0)
815
{
816
var me=M.plantsById[tile[0]-1];
817
var name=me.key;
818
var stage=0;
819
if (tile[1]>=me.mature) stage=4;
820
else if (tile[1]>=me.mature*0.666) stage=3;
821
else if (tile[1]>=me.mature*0.333) stage=2;
822
else stage=1;
823
824
var mult=soilMult;
825
826
if (stage==1) mult*=0.1;
827
else if (stage==2) mult*=0.25;
828
else if (stage==3) mult*=0.5;
829
else mult*=1;
830
831
mult*=M.plotBoost[y][x][1];
832
833
if (name=='bakerWheat') effs.cps+=0.01*mult;
834
else if (name=='thumbcorn') effs.click+=0.02*mult;
835
else if (name=='cronerice') effs.grandmaCps+=0.03*mult;
836
else if (name=='gildmillet') {effs.goldenCookieGain+=0.01*mult;effs.goldenCookieEffDur+=0.001*mult;}
837
else if (name=='clover') effs.goldenCookieFreq+=0.01*mult;
838
else if (name=='goldenClover') effs.goldenCookieFreq+=0.03*mult;
839
else if (name=='shimmerlily') {effs.goldenCookieGain+=0.01*mult;effs.goldenCookieFreq+=0.01*mult;effs.itemDrops+=0.01*mult;}
840
else if (name=='elderwort') {effs.wrathCookieGain+=0.01*mult;effs.wrathCookieFreq+=0.01*mult;effs.grandmaCps+=0.01*mult;}
841
else if (name=='bakeberry') effs.cps+=0.01*mult;
842
else if (name=='chocoroot') effs.cps+=0.01*mult;
843
else if (name=='whiteChocoroot') effs.goldenCookieGain+=0.01*mult;
844
845
else if (name=='whiteMildew') effs.cps+=0.01*mult;
846
else if (name=='brownMold') effs.cps*=1-0.01*mult;
847
848
else if (name=='meddleweed') {}
849
850
else if (name=='whiskerbloom') effs.milk+=0.002*mult;
851
else if (name=='chimerose') {effs.reindeerGain+=0.01*mult;effs.reindeerFreq+=0.01*mult;}
852
853
else if (name=='nursetulip') {effs.cps*=1-0.02*mult;}
854
else if (name=='drowsyfern') {effs.cps+=0.03*mult;effs.click*=1-0.05*mult;effs.goldenCookieFreq*=1-0.1*mult;}
855
else if (name=='wardlichen') {effs.wrinklerSpawn*=1-0.15*mult;effs.wrathCookieFreq*=1-0.02*mult;}
856
else if (name=='keenmoss') {effs.itemDrops+=0.03*mult;}
857
else if (name=='queenbeet') {effs.goldenCookieEffDur+=0.003*mult;effs.cps*=1-0.02*mult;}
858
else if (name=='queenbeetLump') {effs.cps*=1-0.1*mult;}
859
else if (name=='glovemorel') {effs.click+=0.04*mult;effs.cursorCps+=0.01*mult;effs.cps*=1-0.01*mult;}
860
else if (name=='cheapcap') {effs.upgradeCost*=1-0.002*mult;effs.buildingCost*=1-0.002*mult;}
861
else if (name=='foolBolete') {effs.goldenCookieFreq+=0.02*mult;effs.goldenCookieGain*=1-0.05*mult;effs.goldenCookieDur*=1-0.02*mult;effs.goldenCookieEffDur*=1-0.02*mult;}
862
else if (name=='wrinklegill') {effs.wrinklerSpawn+=0.02*mult;effs.wrinklerEat+=0.01*mult;}
863
else if (name=='greenRot') {effs.goldenCookieDur+=0.005*mult;effs.goldenCookieFreq+=0.01*mult;effs.itemDrops+=0.01*mult;}
864
else if (name=='shriekbulb') {effs.cps*=1-0.02*mult;}
865
}
866
}
867
}
868
}
869
M.effs=effs;
870
Game.recalculateGains=1;
871
}
872
873
874
M.soils={
875
'dirt':{
876
name:'Dirt',
877
icon:0,
878
tick:5,
879
effMult:1,
880
weedMult:1,
881
req:0,
882
effsStr:'<div class="gray">&bull; tick every <b>5 minutes</b></div>',
883
q:'Simple, regular old dirt that you\'d find in nature.',
884
},
885
'fertilizer':{
886
name:'Fertilizer',
887
icon:1,
888
tick:3,
889
effMult:0.75,
890
weedMult:1.2,
891
req:50,
892
effsStr:'<div class="gray">&bull; tick every <b>3 minutes</b></div><div class="red">&bull; passive plant effects <b>-25%</b></div><div class="red">&bull; weeds appear <b>20%</b> more</div>',
893
q:'Soil with a healthy helping of fresh manure. Plants grow faster but are less efficient.',
894
},
895
'clay':{
896
name:'Clay',
897
icon:2,
898
tick:15,
899
effMult:1.25,
900
weedMult:1,
901
req:100,
902
effsStr:'<div class="gray">&bull; tick every <b>15 minutes</b></div><div class="green">&bull; passive plant effects <b>+25%</b></div>',
903
q:'Rich soil with very good water retention. Plants grow slower but are more efficient.',
904
},
905
'pebbles':{
906
name:'Pebbles',
907
icon:3,
908
tick:5,
909
effMult:0.25,
910
weedMult:0.1,
911
req:200,
912
effsStr:'<div class="gray">&bull; tick every <b>5 minutes</b></div><div class="red">&bull; passive plant effects <b>-75%</b></div><div class="green">&bull; <b>35% chance</b> of collecting seeds automatically when plants expire</div><div class="green">&bull; weeds appear <b>10 times</b> less</div>',
913
q:'Dry soil made of small rocks tightly packed together. Not very conducive to plant health, but whatever falls off your crops will be easy to retrieve.<br>Useful if you\'re one of those farmers who just want to find new seeds without having to tend their garden too much.',
914
},
915
'woodchips':{
916
name:'Wood chips',
917
icon:4,
918
tick:5,
919
effMult:0.25,
920
weedMult:0.1,
921
req:300,
922
effsStr:'<div class="gray">&bull; tick every <b>5 minutes</b></div><div class="red">&bull; passive plant effects <b>-75%</b></div><div class="green">&bull; plants spread and mutate <b>3 times more</b></div><div class="green">&bull; weeds appear <b>10 times</b> less</div>',
923
q:'Soil made of bits and pieces of bark and sawdust. Helpful for young sprouts to develop, not so much for mature plants.',
924
},
925
};
926
M.soilsById=[];var n=0;for (var i in M.soils){M.soils[i].id=n;M.soils[i].key=i;M.soilsById[n]=M.soils[i];n++;}
927
928
929
M.tools={
930
'info':{
931
name:'Garden information',
932
icon:3,
933
desc:'-',
934
descFunc:function()
935
{
936
var str='';
937
if (M.freeze) str='Your garden is frozen, providing no effects.';
938
else
939
{
940
var effs={
941
cps:{n:'CpS'},
942
click:{n:'cookies/click'},
943
cursorCps:{n:'cursor CpS'},
944
grandmaCps:{n:'grandma CpS'},
945
goldenCookieGain:{n:'golden cookie gains'},
946
goldenCookieFreq:{n:'golden cookie frequency'},
947
goldenCookieDur:{n:'golden cookie duration'},
948
goldenCookieEffDur:{n:'golden cookie effect duration'},
949
wrathCookieGain:{n:'wrath cookie gains'},
950
wrathCookieFreq:{n:'wrath cookie frequency'},
951
wrathCookieDur:{n:'wrath cookie duration'},
952
wrathCookieEffDur:{n:'wrath cookie effect duration'},
953
reindeerGain:{n:'reindeer gains'},
954
reindeerFreq:{n:'reindeer cookie frequency'},
955
reindeerDur:{n:'reindeer cookie duration'},
956
itemDrops:{n:'random drops'},
957
milk:{n:'milk effects'},
958
wrinklerSpawn:{n:'wrinkler spawn rate'},
959
wrinklerEat:{n:'wrinkler appetite'},
960
upgradeCost:{n:'upgrade costs',rev:true},
961
buildingCost:{n:'building costs',rev:true},
962
};
963
964
var effStr='';
965
for (var i in M.effs)
966
{
967
if (M.effs[i]!=1 && effs[i])
968
{
969
var amount=(M.effs[i]-1)*100;
970
effStr+='<div style="font-size:10px;margin-left:64px;"><b>&bull; '+effs[i].n+' :</b> <span class="'+((amount*(effs[i].rev?-1:1))>0?'green':'red')+'">'+(amount>0?'+':'-')+Beautify(Math.abs(M.effs[i]-1)*100,2)+'%</span></div>';
971
}
972
}
973
if (effStr=='') effStr='<div style="font-size:10px;margin-left:64px;"><b>None.</b></div>';
974
str+='<div>Combined effects of all your plants :</div>'+effStr;
975
}
976
str+='<div class="line"></div>';
977
str+='<img src="img/gardenTip.png" style="float:right;margin:0px 0px 8px 8px;"/><small style="line-height:100%;">&bull; You can cross-breed plants by planting them close to each other; new plants will grow in the empty tiles next to them.<br>&bull; Unlock new seeds by harvesting mature plants.<br>&bull; When you ascend, your garden plants are reset, but you keep all the seeds you\'ve unlocked.<br>&bull; Your garden has no effect and does not grow while the game is closed.</small>';
978
return str;
979
},
980
func:function(){},
981
},
982
'harvestAll':{
983
name:'Harvest all',
984
icon:0,
985
descFunc:function(){return 'Instantly harvest all plants in your garden.<div class="line"></div>'+((Game.keys[16] && Game.keys[17])?'<b>You are holding shift+ctrl.</b> Only mature, mortal plants will be harvested.':'Shift+ctrl+click to harvest only mature, mortal plants.');},
986
func:function(){
987
PlaySound('snd/toneTick.mp3');
988
/*if (M.freeze){return false;}*/
989
if (Game.keys[16] && Game.keys[17]) M.harvestAll(0,1,1);//ctrl & shift, harvest only mature non-immortal plants
990
else M.harvestAll();
991
},
992
},
993
'freeze':{
994
name:'Freeze',
995
icon:1,
996
descFunc:function()
997
{
998
return 'Cryogenically preserve your garden.<br>Plants no longer grow, spread or die; they provide no benefits.<br>Soil cannot be changed.<div class="line"></div>Using this will effectively pause your garden.<div class="line"></div>';//<span class="red">'+((M.nextFreeze>Date.now())?'You will be able to freeze your garden again in '+Game.sayTime((M.nextFreeze-Date.now())/1000*30+30,-1)+'.':'After unfreezing your garden, you must wait 10 minutes to freeze it again.')+'</span>
999
},
1000
func:function(){
1001
//if (!M.freeze && M.nextFreeze>Date.now()) return false;
1002
PlaySound('snd/toneTick.mp3');
1003
M.freeze=(M.freeze?0:1);
1004
if (M.freeze)
1005
{
1006
M.computeEffs();
1007
PlaySound('snd/freezeGarden.mp3');
1008
this.classList.add('on');
1009
l('gardenContent').classList.add('gardenFrozen');
1010
1011
1012
for (var y=0;y<6;y++)
1013
{
1014
for (var x=0;x<6;x++)
1015
{
1016
var tile=M.plot[y][x];
1017
if (tile[0]>0)
1018
{
1019
var me=M.plantsById[tile[0]-1];
1020
var age=tile[1];
1021
if (me.key=='cheapcap' && Math.random()<0.15)
1022
{
1023
M.plot[y][x]=[0,0];
1024
if (me.onKill) me.onKill(x,y,age);
1025
M.toRebuild=true;
1026
}
1027
}
1028
}
1029
}
1030
}
1031
else
1032
{
1033
//M.nextFreeze=Date.now()+(Game.Has('Turbo-charged soil')?1:(1000*60*10));
1034
M.computeEffs();
1035
this.classList.remove('on');
1036
l('gardenContent').classList.remove('gardenFrozen');
1037
}
1038
},
1039
isOn:function(){if (M.freeze){l('gardenContent').classList.add('gardenFrozen');}else{l('gardenContent').classList.remove('gardenFrozen');}return M.freeze;},
1040
},
1041
'convert':{
1042
name:'Sacrifice garden',
1043
icon:2,
1044
desc:'A swarm of sugar hornets comes down on your garden, <span class="red">destroying every plant as well as every seed you\'ve unlocked</span> - leaving only a Baker\'s wheat seed.<br>In exchange, they will grant you <span class="green"><b>10</b> sugar lumps</span>.<br>This action is only available with a complete seed log.',
1045
func:function(){PlaySound('snd/toneTick.mp3');M.askConvert();},
1046
isDisplayed:function(){if (M.plantsUnlockedN>=M.plantsN) return true; else return false;},
1047
},
1048
};
1049
M.toolsById=[];var n=0;for (var i in M.tools){M.tools[i].id=n;M.tools[i].key=i;M.toolsById[n]=M.tools[i];n++;}
1050
1051
1052
M.plot=[];
1053
for (var y=0;y<6;y++)
1054
{
1055
M.plot[y]=[];
1056
for (var x=0;x<6;x++)
1057
{
1058
M.plot[y][x]=[0,0];
1059
}
1060
}
1061
M.plotBoost=[];
1062
for (var y=0;y<6;y++)
1063
{
1064
M.plotBoost[y]=[];
1065
for (var x=0;x<6;x++)
1066
{
1067
//age mult, power mult, weed mult
1068
M.plotBoost[y][x]=[1,1,1];
1069
}
1070
}
1071
1072
M.tileSize=40;
1073
1074
M.seedSelected=-1;
1075
1076
M.soil=0;
1077
M.nextSoil=0;//timestamp for when soil will be ready to change again
1078
1079
M.stepT=1;//in seconds
1080
M.nextStep=0;//timestamp for next step tick
1081
1082
M.harvests=0;
1083
M.harvestsTotal=0;
1084
1085
M.loopsMult=1;
1086
1087
M.toRebuild=false;
1088
M.toCompute=false;
1089
1090
M.freeze=0;
1091
M.nextFreeze=0;//timestamp for when we can freeze again; unused, but still stored
1092
1093
M.getCost=function(me)
1094
{
1095
if (Game.Has('Turbo-charged soil')) return 0;
1096
return Math.max(me.costM,Game.cookiesPs*me.cost*60)*(Game.HasAchiev('Seedless to nay')?0.95:1);
1097
}
1098
1099
M.getPlantDesc=function(me)
1100
{
1101
var children='';
1102
if (me.children.length>0)
1103
{
1104
children+='<div class="shadowFilter" style="display:inline-block;">';
1105
for (var i in me.children)
1106
{
1107
if (!M.plants[me.children[i]]) console.log('No plant named '+me.children[i]);
1108
else
1109
{
1110
var it=M.plants[me.children[i]];
1111
if (it.unlocked) children+='<div class="gardenSeedTiny" style="background-position:'+(-0*48)+'px '+(-it.icon*48)+'px;"></div>';
1112
else children+='<div class="gardenSeedTiny" style="background-image:url(img/icons.png?v='+Game.version+');background-position:'+(-0*48)+'px '+(-7*48)+'px;opacity:0.35;"></div>';
1113
}
1114
}
1115
children+='</div>';
1116
}
1117
1118
return '<div class="description">'+
1119
(!me.immortal?('<div style="margin:6px 0px;font-size:11px;"><b>Average lifespan :</b> '+Game.sayTime(((100/(me.ageTick+me.ageTickR/2))*M.stepT)*30,-1)+' <small>('+Beautify(Math.ceil((100/((me.ageTick+me.ageTickR/2)))*(1)))+' ticks)</small></div>'):'')+
1120
'<div style="margin:6px 0px;font-size:11px;"><b>Average maturation :</b> '+Game.sayTime(((100/((me.ageTick+me.ageTickR/2)))*(me.mature/100)*M.stepT)*30,-1)+' <small>('+Beautify(Math.ceil((100/((me.ageTick+me.ageTickR/2)))*(me.mature/100)))+' ticks)</small></div>'+
1121
(me.weed?'<div style="margin:6px 0px;font-size:11px;"><b>Is a weed</b></div>':'')+
1122
(me.fungus?'<div style="margin:6px 0px;font-size:11px;"><b>Is a fungus</b></div>':'')+
1123
(me.detailsStr?('<div style="margin:6px 0px;font-size:11px;"><b>Details :</b> '+me.detailsStr+'</div>'):'')+
1124
(children!=''?('<div style="margin:6px 0px;font-size:11px;"><b>Possible mutations :</b> '+children+'</div>'):'')+
1125
'<div class="line"></div>'+
1126
'<div style="margin:6px 0px;"><b>Effects :</b></div>'+
1127
'<div style="font-size:11px;font-weight:bold;">'+me.effsStr+'</div>'+
1128
(me.q?('<q>'+me.q+'</q>'):'')+
1129
'</div>';
1130
}
1131
M.canPlant=function(me)
1132
{
1133
if (Game.cookies>=M.getCost(me)) return true; else return false;
1134
}
1135
1136
M.cursor=1;
1137
M.hideCursor=function()
1138
{
1139
M.cursor=0;
1140
}
1141
M.showCursor=function()
1142
{
1143
M.cursor=1;
1144
}
1145
1146
M.soilTooltip=function(id)
1147
{
1148
return function(){
1149
var me=M.soilsById[id];
1150
var str='<div style="padding:8px 4px;min-width:350px;">'+
1151
(M.parent.amount<me.req?(
1152
'<div style="text-align:center;">Soil unlocked at '+me.req+' farms.</div>'
1153
):('<div class="icon" style="background:url(img/gardenPlants.png?v='+Game.version+');float:left;margin-left:-8px;margin-top:-8px;background-position:'+(-me.icon*48)+'px '+(-34*48)+'px;"></div>'+
1154
'<div><div class="name">'+me.name+'</div><div><small>'+((M.soil==me.id)?'Your field is currently using this soil.':(M.nextSoil>Date.now())?'You will be able to change your soil again in '+Game.sayTime((M.nextSoil-Date.now())/1000*30+30,-1)+'.':'Click to use this type of soil for your whole field.')+'</small></div></div>'+
1155
'<div class="line"></div>'+
1156
'<div class="description">'+
1157
'<div style="margin:6px 0px;"><b>Effects :</b></div>'+
1158
'<div style="font-size:11px;font-weight:bold;">'+me.effsStr+'</div>'+
1159
(me.q?('<q>'+me.q+'</q>'):'')+
1160
'</div>'))+
1161
'</div>';
1162
return str;
1163
};
1164
}
1165
M.seedTooltip=function(id)
1166
{
1167
return function(){
1168
var me=M.plantsById[id];
1169
var str='<div style="padding:8px 4px;min-width:400px;">'+
1170
'<div class="icon" style="background:url(img/gardenPlants.png?v='+Game.version+');float:left;margin-left:-24px;margin-top:-4px;background-position:'+(-0*48)+'px '+(-me.icon*48)+'px;"></div>'+
1171
'<div class="icon" style="background:url(img/gardenPlants.png?v='+Game.version+');float:left;margin-left:-24px;margin-top:-28px;background-position:'+(-4*48)+'px '+(-me.icon*48)+'px;"></div>'+
1172
'<div style="background:url(img/turnInto.png);width:20px;height:22px;position:absolute;left:28px;top:24px;z-index:1000;"></div>'+
1173
(me.plantable?('<div style="float:right;text-align:right;width:100px;"><small>Planting cost :</small><br><span class="price'+(M.canPlant(me)?'':' disabled')+'">'+Beautify(Math.round(shortenNumber(M.getCost(me))))+'</span><br><small>'+Game.sayTime(me.cost*60*30,-1)+' of CpS,<br>minimum '+Beautify(me.costM)+' cookies</small></div>'):'')+
1174
'<div style="width:300px;"><div class="name">'+me.name+' seed</div><div><small>'+(me.plantable?'Click to select this seed for planting.':'<span class="red">This seed cannot be planted.</span>')+'<br>Shift+ctrl+click to harvest all mature plants of this type.</small></div></div>'+
1175
'<div class="line"></div>'+
1176
M.getPlantDesc(me)+
1177
'</div>';
1178
return str;
1179
};
1180
}
1181
M.toolTooltip=function(id)
1182
{
1183
return function(){
1184
var me=M.toolsById[id];
1185
var icon=[me.icon,35];
1186
var str='<div style="padding:8px 4px;min-width:350px;">'+
1187
'<div class="icon" style="background:url(img/gardenPlants.png?v='+Game.version+');float:left;margin-left:-8px;margin-top:-8px;background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;"></div>'+
1188
'<div><div class="name">'+me.name+'</div></div>'+
1189
'<div class="line"></div>'+
1190
'<div class="description">'+
1191
(me.descFunc?me.descFunc():me.desc)+
1192
'</div>'+
1193
'</div>';
1194
return str;
1195
};
1196
}
1197
M.tileTooltip=function(x,y)
1198
{
1199
return function(){
1200
if (Game.keys[16]) return '';
1201
var tile=M.plot[y][x];
1202
if (tile[0]==0)
1203
{
1204
var me=(M.seedSelected>=0)?M.plantsById[M.seedSelected]:0;
1205
var str='<div style="padding:8px 4px;min-width:350px;text-align:center;">'+
1206
'<div class="name">Empty tile</div>'+'<div class="line"></div><div class="description">'+
1207
'This tile of soil is empty.<br>Pick a seed and plant something!'+
1208
(me?'<div class="line"></div>Click to plant <b>'+me.name+'</b> for <span class="price'+(M.canPlant(me)?'':' disabled')+'">'+Beautify(Math.round(M.getCost(me)))+'</span>.<br><small>(Shift-click to plant multiple.)</small><br><small>(Holding the shift key pressed will also hide tooltips.)</small>':'')+
1209
(M.plotBoost[y][x]!=[1,1,1]?('<small>'+
1210
(M.plotBoost[y][x][0]!=1?'<br>Aging multiplier : '+Beautify(M.plotBoost[y][x][0]*100)+'%':'')+
1211
(M.plotBoost[y][x][1]!=1?'<br>Effect multiplier : '+Beautify(M.plotBoost[y][x][1]*100)+'%':'')+
1212
(M.plotBoost[y][x][2]!=1?'<br>Weeds/fungus repellent : '+Beautify(100-M.plotBoost[y][x][2]*100)+'%':'')+
1213
'</small>'
1214
):'')+
1215
'</div>'+
1216
'</div>';
1217
return str;
1218
}
1219
else
1220
{
1221
var me=M.plantsById[tile[0]-1];
1222
var stage=0;
1223
if (tile[1]>=me.mature) stage=4;
1224
else if (tile[1]>=me.mature*0.666) stage=3;
1225
else if (tile[1]>=me.mature*0.333) stage=2;
1226
else stage=1;
1227
var icon=[stage,me.icon];
1228
var str='<div style="padding:8px 4px;min-width:350px;">'+
1229
'<div class="icon" style="background:url(img/gardenPlants.png?v='+Game.version+');float:left;margin-left:-8px;margin-top:-8px;background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;"></div>'+
1230
'<div class="name">'+me.name+'</div><div><small>This plant is growing here.</small></div>'+
1231
'<div class="line"></div>'+
1232
'<div style="text-align:center;">'+
1233
'<div style="display:inline-block;position:relative;box-shadow:0px 0px 0px 1px #000,0px 0px 0px 1px rgba(255,255,255,0.5) inset,0px -2px 2px 0px rgba(255,255,255,0.5) inset;width:256px;height:6px;background:linear-gradient(to right,#fff 0%,#0f9 '+me.mature+'%,#3c0 '+(me.mature+0.1)+'%,#960 100%)">'+
1234
'<div class="gardenGrowthIndicator" style="left:'+Math.floor((tile[1]/100)*256)+'px;"></div>'+
1235
'<div style="background:url(img/gardenPlants.png?v='+Game.version+');background-position:'+(-1*48)+'px '+(-icon[1]*48)+'px;position:absolute;left:'+(0-24)+'px;top:-32px;transform:scale(0.5,0.5);width:48px;height:48px;"></div>'+
1236
'<div style="background:url(img/gardenPlants.png?v='+Game.version+');background-position:'+(-2*48)+'px '+(-icon[1]*48)+'px;position:absolute;left:'+((((me.mature*0.333)/100)*256)-24)+'px;top:-32px;transform:scale(0.5,0.5);width:48px;height:48px;"></div>'+
1237
'<div style="background:url(img/gardenPlants.png?v='+Game.version+');background-position:'+(-3*48)+'px '+(-icon[1]*48)+'px;position:absolute;left:'+((((me.mature*0.666)/100)*256)-24)+'px;top:-32px;transform:scale(0.5,0.5);width:48px;height:48px;"></div>'+
1238
'<div style="background:url(img/gardenPlants.png?v='+Game.version+');background-position:'+(-4*48)+'px '+(-icon[1]*48)+'px;position:absolute;left:'+((((me.mature)/100)*256)-24)+'px;top:-32px;transform:scale(0.5,0.5);width:48px;height:48px;"></div>'+
1239
'</div><br>'+
1240
'<b>Stage :</b> '+['bud','sprout','bloom','mature'][stage-1]+'<br>'+
1241
'<small>'+(stage==1?'Plant effects : 10%':stage==2?'Plant effects : 25%':stage==3?'Plant effects : 50%':'Plant effects : 100%; may reproduce, will drop seed when harvested')+'</small>'+
1242
'<br><small>'+(
1243
stage<4?(
1244
'Mature in about '+Game.sayTime(((100/(M.plotBoost[y][x][0]*(me.ageTick+me.ageTickR/2)))*((me.mature-tile[1])/100)*M.stepT)*30,-1)+' ('+Beautify(Math.ceil((100/(M.plotBoost[y][x][0]*(me.ageTick+me.ageTickR/2)))*((me.mature-tile[1])/100)))+' tick'+(Math.ceil((100/(M.plotBoost[y][x][0]*(me.ageTick+me.ageTickR/2)))*((me.mature-tile[1])/100))==1?'':'s')+')'
1245
):(
1246
!me.immortal?(
1247
'Decays in about '+Game.sayTime(((100/(M.plotBoost[y][x][0]*(me.ageTick+me.ageTickR/2)))*((100-tile[1])/100)*M.stepT)*30,-1)+' ('+Beautify(Math.ceil((100/(M.plotBoost[y][x][0]*(me.ageTick+me.ageTickR/2)))*((100-tile[1])/100)))+' tick'+(Math.ceil((100/(M.plotBoost[y][x][0]*(me.ageTick+me.ageTickR/2)))*((100-tile[1])/100))==1?'':'s')+')'
1248
):
1249
'Does not decay'
1250
)
1251
)+'</small>'+
1252
//'<small><br>'+M.plotBoost[y][x]+'</small>'+
1253
(M.plotBoost[y][x]!=[1,1,1]?('<small>'+
1254
(M.plotBoost[y][x][0]!=1?'<br>Aging multiplier : '+Beautify(M.plotBoost[y][x][0]*100)+'%':'')+
1255
(M.plotBoost[y][x][1]!=1?'<br>Effect multiplier : '+Beautify(M.plotBoost[y][x][1]*100)+'%':'')+
1256
(M.plotBoost[y][x][2]!=1?'<br>Weeds/fungus repellent : '+Beautify(100-M.plotBoost[y][x][2]*100)+'%':'')+
1257
'</small>'
1258
):'')+
1259
'</div>'+
1260
'<div class="line"></div>'+
1261
//'<div style="text-align:center;">Click to harvest'+(M.seedSelected>=0?', planting <b>'+M.plantsById[M.seedSelected].name+'</b><br>for <span class="price'+(M.canPlant(me)?'':' disabled')+'">'+Beautify(Math.round(M.getCost(M.plantsById[M.seedSelected])))+'</span> in its place':'')+'.</div>'+
1262
'<div style="text-align:center;">Click to '+(stage==4?'harvest':'unearth')+'.</div>'+
1263
'<div class="line"></div>'+
1264
M.getPlantDesc(me)+
1265
'</div>';
1266
return str;
1267
}
1268
};
1269
}
1270
1271
M.refillTooltip=function(){
1272
return '<div style="padding:8px;width:300px;font-size:11px;text-align:center;">Click to refill your soil timer and trigger <b>1</b> plant growth tick with <b>x3</b> spread and mutation rate for <span class="price lump">1 sugar lump</span>.'+
1273
(Game.canRefillLump()?'<br><small>(can be done once every '+Game.sayTime(Game.getLumpRefillMax(),-1)+')</small>':('<br><small class="red">(usable again in '+Game.sayTime(Game.getLumpRefillRemaining()+Game.fps,-1)+')</small>'))+
1274
'</div>';
1275
};
1276
1277
M.buildPanel=function()
1278
{
1279
if (!l('gardenSeeds')) return false;
1280
var str='';
1281
for (var i in M.plants)
1282
{
1283
var me=M.plants[i];
1284
var icon=[0,me.icon];
1285
str+='<div id="gardenSeed-'+me.id+'" class="gardenSeed'+(M.seedSelected==me.id?' on':'')+' locked" '+Game.getDynamicTooltip('Game.ObjectsById['+M.parent.id+'].minigame.seedTooltip('+me.id+')','this')+'>';
1286
str+='<div id="gardenSeedIcon-'+me.id+'" class="gardenSeedIcon shadowFilter" style="background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;"></div>';
1287
str+='</div>';
1288
}
1289
l('gardenSeeds').innerHTML=str;
1290
1291
for (var i in M.plants)
1292
{
1293
var me=M.plants[i];
1294
me.l=l('gardenSeed-'+me.id);
1295
AddEvent(me.l,'click',function(me){return function()
1296
{
1297
if (/* !M.freeze && */Game.keys[16] && Game.keys[17])//shift & ctrl
1298
{
1299
//harvest all mature of type
1300
M.harvestAll(me,1);
1301
return false;
1302
}
1303
if (!me.plantable && !Game.sesame) return false;
1304
if (M.seedSelected==me.id){M.seedSelected=-1;}
1305
else {M.seedSelected=me.id;PlaySound('snd/toneTick.mp3');}
1306
for (var i in M.plants)
1307
{
1308
var it=M.plants[i];
1309
if (it.id==M.seedSelected){it.l.classList.add('on');}
1310
else {it.l.classList.remove('on');}
1311
}
1312
}}(me));
1313
AddEvent(me.l,'mouseover',M.hideCursor);
1314
AddEvent(me.l,'mouseout',M.showCursor);
1315
if (me.unlocked) me.l.classList.remove('locked');
1316
}
1317
1318
var str='';
1319
for (var i in M.tools)
1320
{
1321
var me=M.tools[i];
1322
var icon=[me.icon,35];
1323
str+='<div id="gardenTool-'+me.id+'" style="margin:8px;" class="gardenSeed'+((me.isOn && me.isOn())?' on':'')+''+((!me.isDisplayed || me.isDisplayed())?'':' locked')+'" '+Game.getDynamicTooltip('Game.ObjectsById['+M.parent.id+'].minigame.toolTooltip('+me.id+')','this')+'>';
1324
str+='<div id="gardenToolIcon-'+me.id+'" class="gardenSeedIcon shadowFilter" style="background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;"></div>';
1325
str+='</div>';
1326
}
1327
l('gardenTools').innerHTML=str;
1328
1329
for (var i in M.tools)
1330
{
1331
var me=M.tools[i];
1332
AddEvent(l('gardenTool-'+me.id),'click',me.func);
1333
AddEvent(l('gardenTool-'+me.id),'mouseover',M.hideCursor);
1334
AddEvent(l('gardenTool-'+me.id),'mouseout',M.showCursor);
1335
}
1336
1337
var str='';
1338
for (var i in M.soils)
1339
{
1340
var me=M.soils[i];
1341
var icon=[me.icon,34];
1342
str+='<div id="gardenSoil-'+me.id+'" class="gardenSeed gardenSoil disabled'+(M.soil==me.id?' on':'')+'" '+Game.getDynamicTooltip('Game.ObjectsById['+M.parent.id+'].minigame.soilTooltip('+me.id+')','this')+'>';
1343
str+='<div id="gardenSoilIcon-'+me.id+'" class="gardenSeedIcon shadowFilter" style="background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;"></div>';
1344
str+='</div>';
1345
}
1346
l('gardenSoils').innerHTML=str;
1347
1348
for (var i in M.soils)
1349
{
1350
var me=M.soils[i];
1351
AddEvent(l('gardenSoil-'+me.id),'click',function(me){return function(){
1352
if (M.freeze || M.soil==me.id || M.nextSoil>Date.now() || M.parent.amount<me.req){return false;}
1353
PlaySound('snd/toneTick.mp3');
1354
M.nextSoil=Date.now()+(Game.Has('Turbo-charged soil')?1:(1000*60*10));
1355
M.toCompute=true;M.soil=me.id;M.computeStepT();
1356
for (var i in M.soils){var it=M.soils[i];if (it.id==M.soil){l('gardenSoil-'+it.id).classList.add('on');}else{l('gardenSoil-'+it.id).classList.remove('on');}}
1357
}}(me));
1358
AddEvent(l('gardenSoil-'+me.id),'mouseover',M.hideCursor);
1359
AddEvent(l('gardenSoil-'+me.id),'mouseout',M.showCursor);
1360
}
1361
1362
M.cursorL=l('gardenCursor');
1363
}
1364
M.buildPlot=function()
1365
{
1366
M.toRebuild=false;
1367
if (!l('gardenPlot')) return false;
1368
if (!l('gardenTile-0-0'))
1369
{
1370
var str='';
1371
for (var y=0;y<6;y++)
1372
{
1373
for (var x=0;x<6;x++)
1374
{
1375
str+='<div id="gardenTile-'+x+'-'+y+'" class="gardenTile" style="left:'+(x*M.tileSize)+'px;top:'+(y*M.tileSize)+'px;display:none;" '+Game.getDynamicTooltip('Game.ObjectsById['+M.parent.id+'].minigame.tileTooltip('+x+','+y+')','this')+'>';
1376
str+='<div id="gardenTileIcon-'+x+'-'+y+'" class="gardenTileIcon" style="display:none;"></div>';
1377
str+='</div>';
1378
}
1379
}
1380
l('gardenPlot').innerHTML=str;
1381
1382
for (var y=0;y<6;y++)
1383
{
1384
for (var x=0;x<6;x++)
1385
{
1386
AddEvent(l('gardenTile-'+x+'-'+y),'click',function(x,y){return function()
1387
{
1388
M.clickTile(x,y);
1389
}}(x,y));
1390
}
1391
}
1392
}
1393
var plants=0;
1394
for (var y=0;y<6;y++)
1395
{
1396
for (var x=0;x<6;x++)
1397
{
1398
var tile=M.plot[y][x];
1399
var tileL=l('gardenTile-'+x+'-'+y);
1400
var iconL=l('gardenTileIcon-'+x+'-'+y);
1401
var me=0;
1402
if (tile[0]>0)
1403
{
1404
plants++;
1405
me=M.plantsById[tile[0]-1];
1406
var stage=0;
1407
if (tile[1]>=me.mature) stage=4;
1408
else if (tile[1]>=me.mature*0.666) stage=3;
1409
else if (tile[1]>=me.mature*0.333) stage=2;
1410
else stage=1;
1411
var dying=((tile[1]+Math.ceil(me.ageTick+me.ageTickR))>=100?1:0);
1412
var icon=[stage,me.icon];
1413
iconL.style.opacity=(dying?0.5:1);
1414
iconL.style.backgroundPosition=(-icon[0]*48)+'px '+(-icon[1]*48)+'px';
1415
iconL.style.display='block';
1416
//iconL.innerHTML=M.plotBoost[y][x];
1417
}
1418
else iconL.style.display='none';
1419
if (M.isTileUnlocked(x,y)) tileL.style.display='block';
1420
else tileL.style.display='none';
1421
}
1422
}
1423
if (plants>=6*6) Game.Win('In the garden of Eden (baby)');
1424
}
1425
1426
M.clickTile=function(x,y)
1427
{
1428
//if (M.freeze) return false;
1429
var outcome=M.useTool(M.seedSelected,x,y);
1430
M.toCompute=true;
1431
if (outcome && !Game.keys[16])//shift
1432
{
1433
M.seedSelected=-1;
1434
for (var i in M.plants)
1435
{
1436
var it=M.plants[i];
1437
if (it.id==M.seedSelected) {l('gardenSeed-'+it.id).classList.add('on');}
1438
else {l('gardenSeed-'+it.id).classList.remove('on');}
1439
}
1440
}
1441
//PlaySound('snd/tick.mp3');
1442
}
1443
1444
M.useTool=function(what,x,y)
1445
{
1446
var harvested=M.harvest(x,y,1);
1447
if (harvested)
1448
{
1449
Game.SparkleAt(Game.mouseX,Game.mouseY);
1450
PlaySound('snd/harvest'+choose(['1','2','3'])+'.mp3',1,0.2);
1451
}
1452
else
1453
{
1454
if (what>=0 && M.canPlant(M.plantsById[what]))
1455
{
1456
M.plot[y][x]=[what+1,0];
1457
M.toRebuild=true;
1458
Game.Spend(M.getCost(M.plantsById[what]));
1459
Game.SparkleAt(Game.mouseX,Game.mouseY);
1460
PlaySound('snd/tillb'+choose(['1','2','3'])+'.mp3',1,0.2);
1461
return true;
1462
}
1463
}
1464
return false;
1465
}
1466
1467
M.getTile=function(x,y)
1468
{
1469
if (x<0 || x>5 || y<0 || y>5 || !M.isTileUnlocked(x,y)) return [0,0];
1470
return M.plot[y][x];
1471
}
1472
1473
M.plotLimits=[
1474
[2,2,4,4],
1475
[2,2,5,4],
1476
[2,2,5,5],
1477
[1,2,5,5],
1478
[1,1,5,5],
1479
[1,1,6,5],
1480
[1,1,6,6],
1481
[0,1,6,6],
1482
[0,0,6,6],
1483
];
1484
M.isTileUnlocked=function(x,y)
1485
{
1486
var level=M.parent.level;
1487
level=Math.max(1,Math.min(M.plotLimits.length,level))-1;
1488
var limits=M.plotLimits[level];
1489
if (x>=limits[0] && x<limits[2] && y>=limits[1] && y<limits[3]) return true; else return false;
1490
}
1491
1492
M.computeStepT=function()
1493
{
1494
if (Game.Has('Turbo-charged soil')) M.stepT=1;
1495
else M.stepT=M.soilsById[M.soil].tick*60;
1496
}
1497
1498
M.convertTimes=0;
1499
M.askConvert=function()
1500
{
1501
if (M.plantsUnlockedN<M.plantsN) return false;
1502
Game.Prompt('<h3>Sacrifice garden</h3><div class="block">Do you REALLY want to sacrifice your garden to the sugar hornets?<br><small>You will be left with an empty plot and only the Baker\'s wheat seed unlocked.<br>In return, you will gain <b>10 sugar lumps</b>.</small></div>',[['Yes!','Game.ClosePrompt();Game.ObjectsById['+M.parent.id+'].minigame.convert();'],'No']);
1503
}
1504
M.convert=function()
1505
{
1506
if (M.plantsUnlockedN<M.plantsN) return false;
1507
M.harvestAll();
1508
for (var i in M.plants){M.lockSeed(M.plants[i]);}
1509
M.unlockSeed(M.plants['bakerWheat']);
1510
1511
Game.gainLumps(10);
1512
Game.Notify('Sacrifice!','You\'ve sacrificed your garden to the sugar hornets, destroying your crops and your knowledge of seeds.<br>In the remains, you find <b>10 sugar lumps</b>.',[29,14],12);
1513
1514
M.seedSelected=-1;
1515
Game.Win('Seedless to nay');
1516
M.convertTimes++;
1517
M.computeMatures();
1518
PlaySound('snd/spellFail.mp3',0.75);
1519
}
1520
1521
M.harvestAll=function(type,mature,mortal)
1522
{
1523
var harvested=0;
1524
for (var i=0;i<2;i++)//we do it twice to take care of whatever spawns on kill
1525
{
1526
for (var y=0;y<6;y++)
1527
{
1528
for (var x=0;x<6;x++)
1529
{
1530
if (M.plot[y][x][0]>=1)
1531
{
1532
var doIt=true;
1533
var tile=M.plot[y][x];
1534
var me=M.plantsById[tile[0]-1];
1535
if (type && me!=type) doIt=false;
1536
if (mortal && me.immortal) doIt=false;
1537
if (mature && tile[1]<me.mature) doIt=false;
1538
1539
if (doIt) harvested+=M.harvest(x,y)?1:0;
1540
}
1541
}
1542
}
1543
}
1544
if (harvested>0) setTimeout(function(){PlaySound('snd/harvest1.mp3',1,0.2);},50);
1545
if (harvested>2) setTimeout(function(){PlaySound('snd/harvest2.mp3',1,0.2);},150);
1546
if (harvested>6) setTimeout(function(){PlaySound('snd/harvest3.mp3',1,0.2);},250);
1547
}
1548
M.harvest=function(x,y,manual)
1549
{
1550
var tile=M.plot[y][x];
1551
if (tile[0]>=1)
1552
{
1553
M.toCompute=true;
1554
var me=M.plantsById[tile[0]-1];
1555
var age=tile[1];
1556
if (me.onHarvest) me.onHarvest(x,y,age);
1557
if (tile[1]>=me.mature)
1558
{
1559
if (M.unlockSeed(me)) Game.Popup('('+me.name+')<br>Unlocked '+me.name+' seed.',Game.mouseX,Game.mouseY);
1560
M.harvests++;
1561
M.harvestsTotal++;
1562
if (M.harvestsTotal>=100) Game.Win('Botany enthusiast');
1563
if (M.harvestsTotal>=1000) Game.Win('Green, aching thumb');
1564
}
1565
1566
M.plot[y][x]=[0,0];
1567
if (me.onKill) me.onKill(x,y,age);
1568
M.toRebuild=true;
1569
return true;
1570
}
1571
return false;
1572
}
1573
1574
M.unlockSeed=function(me)
1575
{
1576
if (me.unlocked) return false;
1577
me.unlocked=1;
1578
if (me.l) me.l.classList.remove('locked');
1579
M.getUnlockedN();
1580
return true;
1581
}
1582
M.lockSeed=function(me)
1583
{
1584
if (me.locked) return false;
1585
me.unlocked=0;
1586
if (me.l) me.l.classList.add('locked');
1587
M.getUnlockedN();
1588
return true;
1589
}
1590
1591
var str='';
1592
str+='<style>'+
1593
'#gardenBG{background:url(img/shadedBorders.png),url(img/BGgarden.jpg);background-size:100% 100%,auto;position:absolute;left:0px;right:0px;top:0px;bottom:16px;}'+
1594
'#gardenContent{position:relative;box-sizing:border-box;padding:4px 24px;height:'+(6*M.tileSize+16+48+48)+'px;}'+
1595
'.gardenFrozen{box-shadow:0px 0px 16px rgba(255,255,255,1) inset,0px 0px 48px 24px rgba(200,255,225,0.5) inset;}'+
1596
'#gardenPanel{text-align:center;margin:0px;padding:0px;position:absolute;left:4px;top:4px;bottom:4px;right:65%;overflow-y:auto;overflow-x:hidden;box-shadow:8px 0px 8px rgba(0,0,0,0.5);}'+
1597
'#gardenSeeds{}'+
1598
'#gardenField{text-align:center;position:absolute;right:0px;top:0px;bottom:0px;overflow-x:auto;overflow:hidden;}'+//width:65%;
1599
'#gardenPlot{position:relative;margin:8px auto;}'+
1600
'.gardenTile{cursor:pointer;width:'+M.tileSize+'px;height:'+M.tileSize+'px;position:absolute;}'+
1601
//'.gardenTile:before{transform:translate(0,0);pointer-events:none;content:\'\';display:block;position:absolute;left:0px;top:0px;right:0px;bottom:0px;margin:6px;border-radius:12px;background:rgba(0,0,0,0.1);box-shadow:0px 0px 4px rgba(255,255,255,0.2),-4px 4px 4px 2px rgba(0,0,0,0.2) inset;}'+
1602
//'.gardenTile:hover:before{margin:2px;animation:wobble 0.5s;}'+
1603
'.gardenTile:before{transform:translate(0,0);opacity:0.65;transition:opacity 0.2s;pointer-events:none;content:\'\';display:block;position:absolute;left:0px;top:0px;right:0px;bottom:0px;margin:0px;background:url(img/gardenPlots.png);}'+
1604
'.gardenTile:nth-child(4n+1):before{background-position:40px 0px;}'+
1605
'.gardenTile:nth-child(4n+2):before{background-position:80px 0px;}'+
1606
'.gardenTile:nth-child(4n+3):before{background-position:120px 0px;}'+
1607
'.gardenTile:hover:before{opacity:1;animation:wobble 0.5s;}'+
1608
'.noFancy .gardenTile:hover:before{opacity:1;animation:none;}'+
1609
'.gardenTileIcon{transform:translate(0,0);pointer-events:none;transform-origin:50% 40px;width:48px;height:48px;position:absolute;left:-'+((48-M.tileSize)/2)+'px;top:-'+((48-M.tileSize)/2+8)+'px;background:url(img/gardenPlants.png?v='+Game.version+');}'+
1610
'.gardenTile:hover .gardenTileIcon{animation:pucker 0.3s;}'+
1611
'.noFancy .gardenTile:hover .gardenTileIcon{animation:none;}'+
1612
'#gardenDrag{pointer-events:none;position:absolute;left:0px;top:0px;right:0px;bottom:0px;overflow:hidden;z-index:1000000001;}'+
1613
'#gardenCursor{transition:transform 0.1s;display:none;pointer-events:none;width:48px;height:48px;position:absolute;background:url(img/gardenPlants.png?v='+Game.version+');}'+
1614
'.gardenSeed{cursor:pointer;display:inline-block;width:40px;height:40px;position:relative;}'+
1615
'.gardenSeed.locked{display:none;}'+
1616
'.gardenSeedIcon{pointer-events:none;transform:translate(0,0);display:inline-block;position:absolute;left:-4px;top:-4px;width:48px;height:48px;background:url(img/gardenPlants.png?v='+Game.version+');}'+
1617
'.gardenSeed:hover .gardenSeedIcon{animation:bounce 0.8s;z-index:1000000001;}'+
1618
'.gardenSeed:active .gardenSeedIcon{animation:pucker 0.2s;}'+
1619
'.noFancy .gardenSeed:hover .gardenSeedIcon,.noFancy .gardenSeed:active .gardenSeedIcon{animation:none;}'+
1620
'.gardenPanelLabel{font-size:12px;width:100%;padding:2px;margin-top:4px;margin-bottom:-4px;}'+'.gardenSeedTiny{transform:scale(0.5,0.5);margin:-20px -16px;display:inline-block;width:48px;height:48px;background:url(img/gardenPlants.png?v='+Game.version+');}'+
1621
'.gardenSeed.on:before{pointer-events:none;content:\'\';display:block;position:absolute;left:0px;top:0px;right:0px;bottom:0px;margin:-2px;border-radius:12px;transform:rotate(45deg);background:rgba(0,0,0,0.2);box-shadow:0px 0px 8px rgba(255,255,255,0.75);}'+
1622
1623
'.gardenGrowthIndicator{background:#000;box-shadow:0px 0px 0px 1px #fff,0px 0px 0px 2px #000,2px 2px 2px 2px rgba(0,0,0,0.5);position:absolute;top:0px;width:1px;height:6px;z-index:100;}'+
1624
'.noFancy .gardenGrowthIndicator{background:#fff;border:1px solid #000;margin-top:-1px;margin-left:-1px;}'+
1625
1626
'#gardenSoils{}'+
1627
'.gardenSoil.disabled{filter:brightness(10%);}'+
1628
'.noFilters .gardenSoil.disabled{opacity:0.2;}'+
1629
1630
'#gardenInfo{position:relative;display:inline-block;margin:8px auto 0px auto;padding:8px 16px;padding-left:32px;text-align:left;font-size:11px;color:rgba(255,255,255,0.75);text-shadow:-1px 1px 0px #000;background:rgba(0,0,0,0.75);border-radius:16px;}'+
1631
1632
'</style>';
1633
str+='<div id="gardenBG"></div>';
1634
str+='<div id="gardenContent">';
1635
str+='<div id="gardenDrag"><div id="gardenCursor" class="shadowFilter"></div></div>';
1636
1637
str+='<div id="gardenPanel" class="framed">';
1638
str+='<div class="title gardenPanelLabel">Tools</div><div class="line"></div>';
1639
str+='<div id="gardenTools"></div>';
1640
str+='<div id="gardenSeedsUnlocked" class="title gardenPanelLabel">Seeds</div><div class="line"></div>';
1641
str+='<div id="gardenSeeds"></div>';
1642
str+='</div>';
1643
str+='<div id="gardenField">';
1644
str+='<div style="pointer-events:none;opacity:0.75;position:absolute;left:0px;right:0px;top:8px;" id="gardenPlotSize"></div>';
1645
str+='<div id="gardenPlot" class="shadowFilter" style="width:'+(6*M.tileSize)+'px;height:'+(6*M.tileSize)+'px;"></div>';
1646
str+='<div style="margin-top:0px;" id="gardenSoils"></div>';
1647
str+='<div id="gardenInfo">';
1648
str+='<div '+Game.getDynamicTooltip('Game.ObjectsById['+M.parent.id+'].minigame.refillTooltip','this')+' id="gardenLumpRefill" class="usesIcon shadowFilter lumpRefill" style="display:none;left:-8px;top:-6px;background-position:'+(-29*48)+'px '+(-14*48)+'px;"></div>';
1649
str+='<div id="gardenNextTick">Initializing...</div>';
1650
str+='<div id="gardenStats"></div>';
1651
str+='</div>';
1652
str+='</div>';
1653
1654
str+='</div>';
1655
div.innerHTML=str;
1656
M.buildPlot();
1657
M.buildPanel();
1658
1659
M.lumpRefill=l('gardenLumpRefill');
1660
AddEvent(M.lumpRefill,'click',function(){
1661
Game.refillLump(1,function(){
1662
M.loopsMult=3;
1663
M.nextSoil=Date.now();
1664
//M.nextFreeze=Date.now();
1665
M.nextStep=Date.now();
1666
PlaySound('snd/pop'+Math.floor(Math.random()*3+1)+'.mp3',0.75);
1667
});
1668
});
1669
AddEvent(l('gardenSeedsUnlocked'),'click',function()
1670
{
1671
if (Game.sesame)
1672
{
1673
if (Game.keys[16] && Game.keys[17])//ctrl & shift, fill garden with random plants
1674
{
1675
for (var y=0;y<6;y++)
1676
{
1677
for (var x=0;x<6;x++)
1678
{
1679
M.plot[y][x]=[choose(M.plantsById).id+1,Math.floor(Math.random()*100)];
1680
}
1681
}
1682
M.toRebuild=true;
1683
M.toCompute=true;
1684
}
1685
else//unlock/lock all seeds
1686
{
1687
var locked=0;
1688
for (var i in M.plants)
1689
{
1690
if (!M.plants[i].unlocked) locked++;
1691
}
1692
if (locked>0){for (var i in M.plants){M.unlockSeed(M.plants[i]);}}
1693
else{for (var i in M.plants){M.lockSeed(M.plants[i]);}}
1694
M.unlockSeed(M.plants['bakerWheat']);
1695
}
1696
}
1697
});
1698
1699
M.reset();
1700
1701
//M.parent.switchMinigame(1);
1702
}
1703
M.onResize=function()
1704
{
1705
var width=l('gardenContent').offsetWidth;
1706
var panelW=Math.min(Math.max(width*0.40,320),width-6*M.tileSize)-8;
1707
var fieldW=Math.max(Math.min(width*0.60,width-panelW),6*M.tileSize)-8;
1708
l('gardenField').style.width=fieldW+'px';
1709
l('gardenPanel').style.width=panelW+'px';
1710
}
1711
M.onLevel=function(level)
1712
{
1713
M.buildPlot();
1714
}
1715
M.onRuinTheFun=function()
1716
{
1717
for (var i in M.plants){M.unlockSeed(M.plants[i]);}
1718
}
1719
M.save=function()
1720
{
1721
//output cannot use ",", ";" or "|"
1722
var str=''+
1723
parseFloat(M.nextStep)+':'+
1724
parseInt(M.soil)+':'+
1725
parseFloat(M.nextSoil)+':'+
1726
parseInt(M.freeze)+':'+
1727
parseInt(M.harvests)+':'+
1728
parseInt(M.harvestsTotal)+':'+
1729
parseInt(M.parent.onMinigame?'1':'0')+':'+
1730
parseFloat(M.convertTimes)+':'+
1731
parseFloat(M.nextFreeze)+':'+
1732
' ';
1733
for (var i in M.plants)
1734
{
1735
str+=''+(M.plants[i].unlocked?'1':'0');
1736
}
1737
str+=' ';
1738
for (var y=0;y<6;y++)
1739
{
1740
for (var x=0;x<6;x++)
1741
{
1742
str+=parseInt(M.plot[y][x][0])+':'+parseInt(M.plot[y][x][1])+':';
1743
}
1744
}
1745
return str;
1746
}
1747
M.load=function(str)
1748
{
1749
//interpret str; called after .init
1750
//note : not actually called in the Game's load; see "minigameSave" in main.js
1751
if (!str) return false;
1752
var i=0;
1753
var spl=str.split(' ');
1754
var spl2=spl[i++].split(':');
1755
var i2=0;
1756
M.nextStep=parseFloat(spl2[i2++]||M.nextStep);
1757
M.soil=parseInt(spl2[i2++]||M.soil);
1758
M.nextSoil=parseFloat(spl2[i2++]||M.nextSoil);
1759
M.freeze=parseInt(spl2[i2++]||M.freeze)?1:0;
1760
M.harvests=parseInt(spl2[i2++]||0);
1761
M.harvestsTotal=parseInt(spl2[i2++]||0);
1762
var on=parseInt(spl2[i2++]||0);if (on && Game.ascensionMode!=1) M.parent.switchMinigame(1);
1763
M.convertTimes=parseFloat(spl2[i2++]||M.convertTimes);
1764
M.nextFreeze=parseFloat(spl2[i2++]||M.nextFreeze);
1765
var seeds=spl[i++]||'';
1766
if (seeds)
1767
{
1768
var n=0;
1769
for (var ii in M.plants)
1770
{
1771
if (seeds.charAt(n)=='1') M.plants[ii].unlocked=1; else M.plants[ii].unlocked=0;
1772
n++;
1773
}
1774
}
1775
M.plants['bakerWheat'].unlocked=1;
1776
1777
var plot=spl[i++]||0;
1778
if (plot)
1779
{
1780
plot=plot.split(':');
1781
var n=0;
1782
for (var y=0;y<6;y++)
1783
{
1784
for (var x=0;x<6;x++)
1785
{
1786
M.plot[y][x]=[parseInt(plot[n]),parseInt(plot[n+1])];
1787
n+=2;
1788
}
1789
}
1790
}
1791
1792
M.getUnlockedN();
1793
M.computeStepT();
1794
1795
M.buildPlot();
1796
M.buildPanel();
1797
1798
M.computeBoostPlot();
1799
M.toCompute=true;
1800
}
1801
M.reset=function(hard)
1802
{
1803
M.soil=0;
1804
if (M.seedSelected>-1) M.plantsById[M.seedSelected].l.classList.remove('on');
1805
M.seedSelected=-1;
1806
1807
M.nextStep=Date.now();
1808
M.nextSoil=Date.now();
1809
M.nextFreeze=Date.now();
1810
for (var y=0;y<6;y++)
1811
{
1812
for (var x=0;x<6;x++)
1813
{
1814
M.plot[y][x]=[0,0];
1815
}
1816
}
1817
1818
M.harvests=0;
1819
if (hard)
1820
{
1821
M.convertTimes=0;
1822
M.harvestsTotal=0;
1823
for (var i in M.plants)
1824
{
1825
M.plants[i].unlocked=0;
1826
}
1827
}
1828
1829
M.plants['bakerWheat'].unlocked=1;
1830
1831
M.loopsMult=1;
1832
1833
M.getUnlockedN();
1834
M.computeStepT();
1835
1836
M.computeMatures();
1837
1838
M.buildPlot();
1839
M.buildPanel();
1840
M.computeEffs();
1841
M.toCompute=true;
1842
1843
setTimeout(function(M){return function(){M.onResize();}}(M),10);
1844
}
1845
M.logic=function()
1846
{
1847
//run each frame
1848
var now=Date.now();
1849
1850
if (!M.freeze)
1851
{
1852
M.nextStep=Math.min(M.nextStep,now+(M.stepT)*1000);
1853
if (now>=M.nextStep)
1854
{
1855
M.computeStepT();
1856
M.nextStep=now+M.stepT*1000;
1857
1858
M.computeBoostPlot();
1859
M.computeMatures();
1860
1861
var weedMult=M.soilsById[M.soil].weedMult;
1862
1863
var loops=1;
1864
if (M.soilsById[M.soil].key=='woodchips') loops=3;
1865
loops*=M.loopsMult;
1866
M.loopsMult=1;
1867
1868
for (var y=0;y<6;y++)
1869
{
1870
for (var x=0;x<6;x++)
1871
{
1872
if (M.isTileUnlocked(x,y))
1873
{
1874
var tile=M.plot[y][x];
1875
var me=M.plantsById[tile[0]-1];
1876
if (tile[0]>0)
1877
{
1878
//age
1879
tile[1]+=randomFloor((me.ageTick+me.ageTickR*Math.random())*M.plotBoost[y][x][0]);
1880
tile[1]=Math.max(tile[1],0);
1881
if (me.immortal) tile[1]=Math.min(me.mature+1,tile[1]);
1882
else if (tile[1]>=100)
1883
{
1884
//die of old age
1885
M.plot[y][x]=[0,0];
1886
if (me.onDie) me.onDie(x,y);
1887
if (M.soilsById[M.soil].key=='pebbles' && Math.random()<0.35)
1888
{
1889
if (M.unlockSeed(me)) Game.Popup('Unlocked '+me.name+' seed.',Game.mouseX,Game.mouseY);
1890
}
1891
}
1892
else if (!me.noContam)
1893
{
1894
//other plant contamination
1895
//only occurs in cardinal directions
1896
//immortal plants and plants with noContam are immune
1897
1898
var list=[];
1899
for (var i in M.plantContam)
1900
{
1901
if (Math.random()<M.plantContam[i] && (!M.plants[i].weed || Math.random()<weedMult)) list.push(i);
1902
}
1903
var contam=choose(list);
1904
1905
if (contam && me.key!=contam)
1906
{
1907
if ((!M.plants[contam].weed && !M.plants[contam].fungus) || Math.random()<M.plotBoost[y][x][2])
1908
{
1909
var any=0;
1910
var neighs={};//all surrounding plants
1911
var neighsM={};//all surrounding mature plants
1912
for (var i in M.plants){neighs[i]=0;}
1913
for (var i in M.plants){neighsM[i]=0;}
1914
var neigh=M.getTile(x,y-1);if (neigh[0]>0){var age=neigh[1];neigh=M.plantsById[neigh[0]-1];any++;neighs[neigh.key]++;if (age>=neigh.mature){neighsM[neigh.key]++;}}
1915
var neigh=M.getTile(x,y+1);if (neigh[0]>0){var age=neigh[1];neigh=M.plantsById[neigh[0]-1];any++;neighs[neigh.key]++;if (age>=neigh.mature){neighsM[neigh.key]++;}}
1916
var neigh=M.getTile(x-1,y);if (neigh[0]>0){var age=neigh[1];neigh=M.plantsById[neigh[0]-1];any++;neighs[neigh.key]++;if (age>=neigh.mature){neighsM[neigh.key]++;}}
1917
var neigh=M.getTile(x+1,y);if (neigh[0]>0){var age=neigh[1];neigh=M.plantsById[neigh[0]-1];any++;neighs[neigh.key]++;if (age>=neigh.mature){neighsM[neigh.key]++;}}
1918
1919
if (neighsM[contam]>=1) M.plot[y][x]=[M.plants[contam].id+1,0];
1920
}
1921
}
1922
}
1923
}
1924
else
1925
{
1926
//plant spreading and mutation
1927
//happens on all 8 tiles around this one
1928
for (var loop=0;loop<loops;loop++)
1929
{
1930
var any=0;
1931
var neighs={};//all surrounding plants
1932
var neighsM={};//all surrounding mature plants
1933
for (var i in M.plants){neighs[i]=0;}
1934
for (var i in M.plants){neighsM[i]=0;}
1935
var neigh=M.getTile(x,y-1);if (neigh[0]>0){var age=neigh[1];neigh=M.plantsById[neigh[0]-1];any++;neighs[neigh.key]++;if (age>=neigh.mature){neighsM[neigh.key]++;}}
1936
var neigh=M.getTile(x,y+1);if (neigh[0]>0){var age=neigh[1];neigh=M.plantsById[neigh[0]-1];any++;neighs[neigh.key]++;if (age>=neigh.mature){neighsM[neigh.key]++;}}
1937
var neigh=M.getTile(x-1,y);if (neigh[0]>0){var age=neigh[1];neigh=M.plantsById[neigh[0]-1];any++;neighs[neigh.key]++;if (age>=neigh.mature){neighsM[neigh.key]++;}}
1938
var neigh=M.getTile(x+1,y);if (neigh[0]>0){var age=neigh[1];neigh=M.plantsById[neigh[0]-1];any++;neighs[neigh.key]++;if (age>=neigh.mature){neighsM[neigh.key]++;}}
1939
var neigh=M.getTile(x-1,y-1);if (neigh[0]>0){var age=neigh[1];neigh=M.plantsById[neigh[0]-1];any++;neighs[neigh.key]++;if (age>=neigh.mature){neighsM[neigh.key]++;}}
1940
var neigh=M.getTile(x-1,y+1);if (neigh[0]>0){var age=neigh[1];neigh=M.plantsById[neigh[0]-1];any++;neighs[neigh.key]++;if (age>=neigh.mature){neighsM[neigh.key]++;}}
1941
var neigh=M.getTile(x+1,y-1);if (neigh[0]>0){var age=neigh[1];neigh=M.plantsById[neigh[0]-1];any++;neighs[neigh.key]++;if (age>=neigh.mature){neighsM[neigh.key]++;}}
1942
var neigh=M.getTile(x+1,y+1);if (neigh[0]>0){var age=neigh[1];neigh=M.plantsById[neigh[0]-1];any++;neighs[neigh.key]++;if (age>=neigh.mature){neighsM[neigh.key]++;}}
1943
if (any>0)
1944
{
1945
var muts=M.getMuts(neighs,neighsM);
1946
1947
var list=[];
1948
for (var ii=0;ii<muts.length;ii++)
1949
{
1950
if (Math.random()<muts[ii][1] && (!M.plants[muts[ii][0]].weed || Math.random()<weedMult) && ((!M.plants[muts[ii][0]].weed && !M.plants[muts[ii][0]].fungus) || Math.random()<M.plotBoost[y][x][2])) list.push(muts[ii][0]);
1951
}
1952
if (list.length>0) M.plot[y][x]=[M.plants[choose(list)].id+1,0];
1953
}
1954
else if (loop==0)
1955
{
1956
//weeds in empty tiles (no other plants must be nearby)
1957
var chance=0.002*weedMult*M.plotBoost[y][x][2];
1958
if (Math.random()<chance) M.plot[y][x]=[M.plants['meddleweed'].id+1,0];
1959
}
1960
}
1961
}
1962
}
1963
}
1964
}
1965
M.toRebuild=true;
1966
M.toCompute=true;
1967
}
1968
}
1969
if (M.toRebuild) M.buildPlot();
1970
if (M.toCompute) M.computeEffs();
1971
1972
if (Game.keys[27])//esc
1973
{
1974
if (M.seedSelected>-1) M.plantsById[M.seedSelected].l.classList.remove('on');
1975
M.seedSelected=-1;
1976
}
1977
}
1978
M.draw=function()
1979
{
1980
//run each draw frame
1981
1982
if (M.cursorL)
1983
{
1984
if (!M.cursor || M.seedSelected<0)
1985
{
1986
M.cursorL.style.display='none';
1987
}
1988
else
1989
{
1990
var box=l('gardenDrag').getBoundingClientRect();
1991
var x=Game.mouseX-box.left-24;
1992
var y=Game.mouseY-box.top;
1993
var seed=M.plantsById[M.seedSelected];
1994
var icon=[0,seed.icon];
1995
M.cursorL.style.transform='translate('+(x)+'px,'+(y)+'px)';
1996
M.cursorL.style.backgroundPosition=(-icon[0]*48)+'px '+(-icon[1]*48)+'px';
1997
M.cursorL.style.display='block';
1998
}
1999
}
2000
if (Game.drawT%10==0)
2001
{
2002
M.lumpRefill.style.display='block';
2003
if (M.freeze) l('gardenNextTick').innerHTML='Garden is frozen. Unfreeze to resume.';
2004
else l('gardenNextTick').innerHTML='Next tick in '+Game.sayTime((M.nextStep-Date.now())/1000*30+30,-1)+'';
2005
l('gardenStats').innerHTML='Mature plants harvested : '+Beautify(M.harvests)+' (total : '+Beautify(M.harvestsTotal)+')';
2006
if (M.parent.level<M.plotLimits.length) l('gardenPlotSize').innerHTML='<small>Plot size : '+Math.max(1,Math.min(M.plotLimits.length,M.parent.level))+'/'+M.plotLimits.length+'<br>(Upgrades with farm level)</small>';
2007
else l('gardenPlotSize').innerHTML='';
2008
l('gardenSeedsUnlocked').innerHTML='Seeds<small> ('+M.plantsUnlockedN+'/'+M.plantsN+')</small>';
2009
for (var i in M.soils)
2010
{
2011
var me=M.soils[i];
2012
if (M.parent.amount<me.req) l('gardenSoil-'+me.id).classList.add('disabled');
2013
else l('gardenSoil-'+me.id).classList.remove('disabled');
2014
}
2015
}
2016
}
2017
M.init(l('rowSpecial'+M.parent.id));
2018
}
2019
var M=0;
2020