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