Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
titaniumnetwork-dev
GitHub Repository: titaniumnetwork-dev/Incognito-old
Path: blob/main/static/src/gs/public/cookie/minigameGarden.js
1344 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 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.',
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
var tile=M.plot[y][x];
1201
if (tile[0]==0)
1202
{
1203
var me=(M.seedSelected>=0)?M.plantsById[M.seedSelected]:0;
1204
var str='<div style="padding:8px 4px;min-width:350px;text-align:center;">'+
1205
'<div class="name">Empty tile</div>'+'<div class="line"></div><div class="description">'+
1206
'This tile of soil is empty.<br>Pick a seed and plant something!'+
1207
(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>':'')+
1208
(M.plotBoost[y][x]!=[1,1,1]?('<small>'+
1209
(M.plotBoost[y][x][0]!=1?'<br>Aging multiplier : '+Beautify(M.plotBoost[y][x][0]*100)+'%':'')+
1210
(M.plotBoost[y][x][1]!=1?'<br>Effect multiplier : '+Beautify(M.plotBoost[y][x][1]*100)+'%':'')+
1211
(M.plotBoost[y][x][2]!=1?'<br>Weeds/fungus repellent : '+Beautify(100-M.plotBoost[y][x][2]*100)+'%':'')+
1212
'</small>'
1213
):'')+
1214
'</div>'+
1215
'</div>';
1216
return str;
1217
}
1218
else
1219
{
1220
var me=M.plantsById[tile[0]-1];
1221
var stage=0;
1222
if (tile[1]>=me.mature) stage=4;
1223
else if (tile[1]>=me.mature*0.666) stage=3;
1224
else if (tile[1]>=me.mature*0.333) stage=2;
1225
else stage=1;
1226
var icon=[stage,me.icon];
1227
var str='<div style="padding:8px 4px;min-width:350px;">'+
1228
'<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>'+
1229
'<div class="name">'+me.name+'</div><div><small>This plant is growing here.</small></div>'+
1230
'<div class="line"></div>'+
1231
'<div style="text-align:center;">'+
1232
'<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%)">'+
1233
'<div class="gardenGrowthIndicator" style="left:'+Math.floor((tile[1]/100)*256)+'px;"></div>'+
1234
'<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>'+
1235
'<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>'+
1236
'<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>'+
1237
'<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>'+
1238
'</div><br>'+
1239
'<b>Stage :</b> '+['bud','sprout','bloom','mature'][stage-1]+'<br>'+
1240
'<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>'+
1241
'<br><small>'+(
1242
stage<4?(
1243
'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')+')'
1244
):(
1245
!me.immortal?(
1246
'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')+')'
1247
):
1248
'Does not decay'
1249
)
1250
)+'</small>'+
1251
//'<small><br>'+M.plotBoost[y][x]+'</small>'+
1252
(M.plotBoost[y][x]!=[1,1,1]?('<small>'+
1253
(M.plotBoost[y][x][0]!=1?'<br>Aging multiplier : '+Beautify(M.plotBoost[y][x][0]*100)+'%':'')+
1254
(M.plotBoost[y][x][1]!=1?'<br>Effect multiplier : '+Beautify(M.plotBoost[y][x][1]*100)+'%':'')+
1255
(M.plotBoost[y][x][2]!=1?'<br>Weeds/fungus repellent : '+Beautify(100-M.plotBoost[y][x][2]*100)+'%':'')+
1256
'</small>'
1257
):'')+
1258
'</div>'+
1259
'<div class="line"></div>'+
1260
//'<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>'+
1261
'<div style="text-align:center;">Click to '+(stage==4?'harvest':'unearth')+'.</div>'+
1262
'<div class="line"></div>'+
1263
M.getPlantDesc(me)+
1264
'</div>';
1265
return str;
1266
}
1267
};
1268
}
1269
1270
M.refillTooltip=function(){
1271
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>.'+
1272
(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>'))+
1273
'</div>';
1274
};
1275
1276
M.buildPanel=function()
1277
{
1278
if (!l('gardenSeeds')) return false;
1279
var str='';
1280
for (var i in M.plants)
1281
{
1282
var me=M.plants[i];
1283
var icon=[0,me.icon];
1284
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')+'>';
1285
str+='<div id="gardenSeedIcon-'+me.id+'" class="gardenSeedIcon shadowFilter" style="background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;"></div>';
1286
str+='</div>';
1287
}
1288
l('gardenSeeds').innerHTML=str;
1289
1290
for (var i in M.plants)
1291
{
1292
var me=M.plants[i];
1293
me.l=l('gardenSeed-'+me.id);
1294
AddEvent(me.l,'click',function(me){return function()
1295
{
1296
if (/* !M.freeze && */Game.keys[16] && Game.keys[17])//shift & ctrl
1297
{
1298
//harvest all mature of type
1299
M.harvestAll(me,1);
1300
return false;
1301
}
1302
if (!me.plantable && !Game.sesame) return false;
1303
if (M.seedSelected==me.id){M.seedSelected=-1;}
1304
else {M.seedSelected=me.id;PlaySound('snd/toneTick.mp3');}
1305
for (var i in M.plants)
1306
{
1307
var it=M.plants[i];
1308
if (it.id==M.seedSelected){it.l.classList.add('on');}
1309
else {it.l.classList.remove('on');}
1310
}
1311
}}(me));
1312
AddEvent(me.l,'mouseover',M.hideCursor);
1313
AddEvent(me.l,'mouseout',M.showCursor);
1314
if (me.unlocked) me.l.classList.remove('locked');
1315
}
1316
1317
var str='';
1318
for (var i in M.tools)
1319
{
1320
var me=M.tools[i];
1321
var icon=[me.icon,35];
1322
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')+'>';
1323
str+='<div id="gardenToolIcon-'+me.id+'" class="gardenSeedIcon shadowFilter" style="background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;"></div>';
1324
str+='</div>';
1325
}
1326
l('gardenTools').innerHTML=str;
1327
1328
for (var i in M.tools)
1329
{
1330
var me=M.tools[i];
1331
AddEvent(l('gardenTool-'+me.id),'click',me.func);
1332
AddEvent(l('gardenTool-'+me.id),'mouseover',M.hideCursor);
1333
AddEvent(l('gardenTool-'+me.id),'mouseout',M.showCursor);
1334
}
1335
1336
var str='';
1337
for (var i in M.soils)
1338
{
1339
var me=M.soils[i];
1340
var icon=[me.icon,34];
1341
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')+'>';
1342
str+='<div id="gardenSoilIcon-'+me.id+'" class="gardenSeedIcon shadowFilter" style="background-position:'+(-icon[0]*48)+'px '+(-icon[1]*48)+'px;"></div>';
1343
str+='</div>';
1344
}
1345
l('gardenSoils').innerHTML=str;
1346
1347
for (var i in M.soils)
1348
{
1349
var me=M.soils[i];
1350
AddEvent(l('gardenSoil-'+me.id),'click',function(me){return function(){
1351
if (M.freeze || M.soil==me.id || M.nextSoil>Date.now() || M.parent.amount<me.req){return false;}
1352
PlaySound('snd/toneTick.mp3');
1353
M.nextSoil=Date.now()+(Game.Has('Turbo-charged soil')?1:(1000*60*10));
1354
M.toCompute=true;M.soil=me.id;M.computeStepT();
1355
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');}}
1356
}}(me));
1357
AddEvent(l('gardenSoil-'+me.id),'mouseover',M.hideCursor);
1358
AddEvent(l('gardenSoil-'+me.id),'mouseout',M.showCursor);
1359
}
1360
1361
M.cursorL=l('gardenCursor');
1362
}
1363
M.buildPlot=function()
1364
{
1365
M.toRebuild=false;
1366
if (!l('gardenPlot')) return false;
1367
if (!l('gardenTile-0-0'))
1368
{
1369
var str='';
1370
for (var y=0;y<6;y++)
1371
{
1372
for (var x=0;x<6;x++)
1373
{
1374
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')+'>';
1375
str+='<div id="gardenTileIcon-'+x+'-'+y+'" class="gardenTileIcon" style="display:none;"></div>';
1376
str+='</div>';
1377
}
1378
}
1379
l('gardenPlot').innerHTML=str;
1380
1381
for (var y=0;y<6;y++)
1382
{
1383
for (var x=0;x<6;x++)
1384
{
1385
AddEvent(l('gardenTile-'+x+'-'+y),'click',function(x,y){return function()
1386
{
1387
M.clickTile(x,y);
1388
}}(x,y));
1389
}
1390
}
1391
}
1392
var plants=0;
1393
for (var y=0;y<6;y++)
1394
{
1395
for (var x=0;x<6;x++)
1396
{
1397
var tile=M.plot[y][x];
1398
var tileL=l('gardenTile-'+x+'-'+y);
1399
var iconL=l('gardenTileIcon-'+x+'-'+y);
1400
var me=0;
1401
if (tile[0]>0)
1402
{
1403
plants++;
1404
me=M.plantsById[tile[0]-1];
1405
var stage=0;
1406
if (tile[1]>=me.mature) stage=4;
1407
else if (tile[1]>=me.mature*0.666) stage=3;
1408
else if (tile[1]>=me.mature*0.333) stage=2;
1409
else stage=1;
1410
var dying=((tile[1]+Math.ceil(me.ageTick+me.ageTickR))>=100?1:0);
1411
var icon=[stage,me.icon];
1412
iconL.style.opacity=(dying?0.5:1);
1413
iconL.style.backgroundPosition=(-icon[0]*48)+'px '+(-icon[1]*48)+'px';
1414
iconL.style.display='block';
1415
//iconL.innerHTML=M.plotBoost[y][x];
1416
}
1417
else iconL.style.display='none';
1418
if (M.isTileUnlocked(x,y)) tileL.style.display='block';
1419
else tileL.style.display='none';
1420
}
1421
}
1422
if (plants>=6*6) Game.Win('In the garden of Eden (baby)');
1423
}
1424
1425
M.clickTile=function(x,y)
1426
{
1427
//if (M.freeze) return false;
1428
var outcome=M.useTool(M.seedSelected,x,y);
1429
M.toCompute=true;
1430
if (outcome && !Game.keys[16])//shift
1431
{
1432
M.seedSelected=-1;
1433
for (var i in M.plants)
1434
{
1435
var it=M.plants[i];
1436
if (it.id==M.seedSelected) {l('gardenSeed-'+it.id).classList.add('on');}
1437
else {l('gardenSeed-'+it.id).classList.remove('on');}
1438
}
1439
}
1440
//PlaySound('snd/tick.mp3');
1441
}
1442
1443
M.useTool=function(what,x,y)
1444
{
1445
var harvested=M.harvest(x,y,1);
1446
if (harvested)
1447
{
1448
Game.SparkleAt(Game.mouseX,Game.mouseY);
1449
PlaySound('snd/harvest'+choose(['1','2','3'])+'.mp3',1,0.2);
1450
}
1451
else
1452
{
1453
if (what>=0 && M.canPlant(M.plantsById[what]))
1454
{
1455
M.plot[y][x]=[what+1,0];
1456
M.toRebuild=true;
1457
Game.Spend(M.getCost(M.plantsById[what]));
1458
Game.SparkleAt(Game.mouseX,Game.mouseY);
1459
PlaySound('snd/tillb'+choose(['1','2','3'])+'.mp3',1,0.2);
1460
return true;
1461
}
1462
}
1463
return false;
1464
}
1465
1466
M.getTile=function(x,y)
1467
{
1468
if (x<0 || x>5 || y<0 || y>5 || !M.isTileUnlocked(x,y)) return [0,0];
1469
return M.plot[y][x];
1470
}
1471
1472
M.plotLimits=[
1473
[2,2,4,4],
1474
[2,2,5,4],
1475
[2,2,5,5],
1476
[1,2,5,5],
1477
[1,1,5,5],
1478
[1,1,6,5],
1479
[1,1,6,6],
1480
[0,1,6,6],
1481
[0,0,6,6],
1482
];
1483
M.isTileUnlocked=function(x,y)
1484
{
1485
var level=M.parent.level;
1486
level=Math.max(1,Math.min(M.plotLimits.length,level))-1;
1487
var limits=M.plotLimits[level];
1488
if (x>=limits[0] && x<limits[2] && y>=limits[1] && y<limits[3]) return true; else return false;
1489
}
1490
1491
M.computeStepT=function()
1492
{
1493
if (Game.Has('Turbo-charged soil')) M.stepT=1;
1494
else M.stepT=M.soilsById[M.soil].tick*60;
1495
}
1496
1497
M.convertTimes=0;
1498
M.askConvert=function()
1499
{
1500
if (M.plantsUnlockedN<M.plantsN) return false;
1501
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']);
1502
}
1503
M.convert=function()
1504
{
1505
if (M.plantsUnlockedN<M.plantsN) return false;
1506
M.harvestAll();
1507
for (var i in M.plants){M.lockSeed(M.plants[i]);}
1508
M.unlockSeed(M.plants['bakerWheat']);
1509
1510
Game.gainLumps(10);
1511
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);
1512
1513
Game.Win('Seedless to nay');
1514
M.convertTimes++;
1515
M.computeMatures();
1516
PlaySound('snd/spellFail.mp3',0.75);
1517
}
1518
1519
M.harvestAll=function(type,mature,mortal)
1520
{
1521
var harvested=0;
1522
for (var i=0;i<2;i++)//we do it twice to take care of whatever spawns on kill
1523
{
1524
for (var y=0;y<6;y++)
1525
{
1526
for (var x=0;x<6;x++)
1527
{
1528
if (M.plot[y][x][0]>=1)
1529
{
1530
var doIt=true;
1531
var tile=M.plot[y][x];
1532
var me=M.plantsById[tile[0]-1];
1533
if (type && me!=type) doIt=false;
1534
if (mortal && me.immortal) doIt=false;
1535
if (mature && tile[1]<me.mature) doIt=false;
1536
1537
if (doIt) harvested+=M.harvest(x,y)?1:0;
1538
}
1539
}
1540
}
1541
}
1542
if (harvested>0) setTimeout(function(){PlaySound('snd/harvest1.mp3',1,0.2);},50);
1543
if (harvested>2) setTimeout(function(){PlaySound('snd/harvest2.mp3',1,0.2);},150);
1544
if (harvested>6) setTimeout(function(){PlaySound('snd/harvest3.mp3',1,0.2);},250);
1545
}
1546
M.harvest=function(x,y,manual)
1547
{
1548
var tile=M.plot[y][x];
1549
if (tile[0]>=1)
1550
{
1551
M.toCompute=true;
1552
var me=M.plantsById[tile[0]-1];
1553
var age=tile[1];
1554
if (me.onHarvest) me.onHarvest(x,y,age);
1555
if (tile[1]>=me.mature)
1556
{
1557
if (M.unlockSeed(me)) Game.Popup('('+me.name+')<br>Unlocked '+me.name+' seed.',Game.mouseX,Game.mouseY);
1558
M.harvests++;
1559
M.harvestsTotal++;
1560
if (M.harvestsTotal>=100) Game.Win('Botany enthusiast');
1561
if (M.harvestsTotal>=1000) Game.Win('Green, aching thumb');
1562
}
1563
1564
M.plot[y][x]=[0,0];
1565
if (me.onKill) me.onKill(x,y,age);
1566
M.toRebuild=true;
1567
return true;
1568
}
1569
return false;
1570
}
1571
1572
M.unlockSeed=function(me)
1573
{
1574
if (me.unlocked) return false;
1575
me.unlocked=1;
1576
if (me.l) me.l.classList.remove('locked');
1577
M.getUnlockedN();
1578
return true;
1579
}
1580
M.lockSeed=function(me)
1581
{
1582
if (me.locked) return false;
1583
me.unlocked=0;
1584
if (me.l) me.l.classList.add('locked');
1585
M.getUnlockedN();
1586
return true;
1587
}
1588
1589
var str='';
1590
str+='<style>'+
1591
'#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;}'+
1592
'#gardenContent{position:relative;box-sizing:border-box;padding:4px 24px;height:'+(6*M.tileSize+16+48+48)+'px;}'+
1593
'.gardenFrozen{box-shadow:0px 0px 16px rgba(255,255,255,1) inset,0px 0px 48px 24px rgba(200,255,225,0.5) inset;}'+
1594
'#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);}'+
1595
'#gardenSeeds{}'+
1596
'#gardenField{text-align:center;position:absolute;right:0px;top:0px;bottom:0px;overflow-x:auto;overflow:hidden;}'+//width:65%;
1597
'#gardenPlot{position:relative;margin:8px auto;}'+
1598
'.gardenTile{cursor:pointer;width:'+M.tileSize+'px;height:'+M.tileSize+'px;position:absolute;}'+
1599
//'.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;}'+
1600
//'.gardenTile:hover:before{margin:2px;animation:wobble 0.5s;}'+
1601
'.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);}'+
1602
'.gardenTile:nth-child(4n+1):before{background-position:40px 0px;}'+
1603
'.gardenTile:nth-child(4n+2):before{background-position:80px 0px;}'+
1604
'.gardenTile:nth-child(4n+3):before{background-position:120px 0px;}'+
1605
'.gardenTile:hover:before{opacity:1;animation:wobble 0.5s;}'+
1606
'.noFancy .gardenTile:hover:before{opacity:1;animation:none;}'+
1607
'.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+');}'+
1608
'.gardenTile:hover .gardenTileIcon{animation:pucker 0.3s;}'+
1609
'.noFancy .gardenTile:hover .gardenTileIcon{animation:none;}'+
1610
'#gardenDrag{pointer-events:none;position:absolute;left:0px;top:0px;right:0px;bottom:0px;overflow:hidden;z-index:1000000001;}'+
1611
'#gardenCursor{transition:transform 0.1s;display:none;pointer-events:none;width:48px;height:48px;position:absolute;background:url(img/gardenPlants.png?v='+Game.version+');}'+
1612
'.gardenSeed{cursor:pointer;display:inline-block;width:40px;height:40px;position:relative;}'+
1613
'.gardenSeed.locked{display:none;}'+
1614
'.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+');}'+
1615
'.gardenSeed:hover .gardenSeedIcon{animation:bounce 0.8s;z-index:1000000001;}'+
1616
'.gardenSeed:active .gardenSeedIcon{animation:pucker 0.2s;}'+
1617
'.noFancy .gardenSeed:hover .gardenSeedIcon,.noFancy .gardenSeed:active .gardenSeedIcon{animation:none;}'+
1618
'.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+');}'+
1619
'.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);}'+
1620
1621
'.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;}'+
1622
'.noFancy .gardenGrowthIndicator{background:#fff;border:1px solid #000;margin-top:-1px;margin-left:-1px;}'+
1623
1624
'#gardenSoils{}'+
1625
'.gardenSoil.disabled{filter:brightness(10%);}'+
1626
'.noFilters .gardenSoil.disabled{opacity:0.2;}'+
1627
1628
'#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;}'+
1629
1630
'</style>';
1631
str+='<div id="gardenBG"></div>';
1632
str+='<div id="gardenContent">';
1633
str+='<div id="gardenDrag"><div id="gardenCursor" class="shadowFilter"></div></div>';
1634
1635
str+='<div id="gardenPanel" class="framed">';
1636
str+='<div class="title gardenPanelLabel">Tools</div><div class="line"></div>';
1637
str+='<div id="gardenTools"></div>';
1638
str+='<div id="gardenSeedsUnlocked" class="title gardenPanelLabel">Seeds</div><div class="line"></div>';
1639
str+='<div id="gardenSeeds"></div>';
1640
str+='</div>';
1641
str+='<div id="gardenField">';
1642
str+='<div style="pointer-events:none;opacity:0.75;position:absolute;left:0px;right:0px;top:8px;" id="gardenPlotSize"></div>';
1643
str+='<div id="gardenPlot" class="shadowFilter" style="width:'+(6*M.tileSize)+'px;height:'+(6*M.tileSize)+'px;"></div>';
1644
str+='<div style="margin-top:0px;" id="gardenSoils"></div>';
1645
str+='<div id="gardenInfo">';
1646
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>';
1647
str+='<div id="gardenNextTick">Initializing...</div>';
1648
str+='<div id="gardenStats"></div>';
1649
str+='</div>';
1650
str+='</div>';
1651
1652
str+='</div>';
1653
div.innerHTML=str;
1654
M.buildPlot();
1655
M.buildPanel();
1656
1657
M.lumpRefill=l('gardenLumpRefill');
1658
AddEvent(M.lumpRefill,'click',function(){
1659
Game.refillLump(1,function(){
1660
M.loopsMult=3;
1661
M.nextSoil=Date.now();
1662
//M.nextFreeze=Date.now();
1663
M.nextStep=Date.now();
1664
PlaySound('snd/pop'+Math.floor(Math.random()*3+1)+'.mp3',0.75);
1665
});
1666
});
1667
AddEvent(l('gardenSeedsUnlocked'),'click',function()
1668
{
1669
if (Game.sesame)
1670
{
1671
if (Game.keys[16] && Game.keys[17])//ctrl & shift, fill garden with random plants
1672
{
1673
for (var y=0;y<6;y++)
1674
{
1675
for (var x=0;x<6;x++)
1676
{
1677
M.plot[y][x]=[choose(M.plantsById).id+1,Math.floor(Math.random()*100)];
1678
}
1679
}
1680
M.toRebuild=true;
1681
M.toCompute=true;
1682
}
1683
else//unlock/lock all seeds
1684
{
1685
var locked=0;
1686
for (var i in M.plants)
1687
{
1688
if (!M.plants[i].unlocked) locked++;
1689
}
1690
if (locked>0){for (var i in M.plants){M.unlockSeed(M.plants[i]);}}
1691
else{for (var i in M.plants){M.lockSeed(M.plants[i]);}}
1692
M.unlockSeed(M.plants['bakerWheat']);
1693
}
1694
}
1695
});
1696
1697
M.reset();
1698
1699
//M.parent.switchMinigame(1);
1700
}
1701
M.onResize=function()
1702
{
1703
var width=l('gardenContent').offsetWidth;
1704
var panelW=Math.min(Math.max(width*0.40,320),width-6*M.tileSize)-8;
1705
var fieldW=Math.max(Math.min(width*0.60,width-panelW),6*M.tileSize)-8;
1706
l('gardenField').style.width=fieldW+'px';
1707
l('gardenPanel').style.width=panelW+'px';
1708
}
1709
M.onLevel=function(level)
1710
{
1711
M.buildPlot();
1712
}
1713
M.onRuinTheFun=function()
1714
{
1715
for (var i in M.plants){M.unlockSeed(M.plants[i]);}
1716
}
1717
M.save=function()
1718
{
1719
//output cannot use ",", ";" or "|"
1720
var str=''+
1721
parseFloat(M.nextStep)+':'+
1722
parseInt(M.soil)+':'+
1723
parseFloat(M.nextSoil)+':'+
1724
parseInt(M.freeze)+':'+
1725
parseInt(M.harvests)+':'+
1726
parseInt(M.harvestsTotal)+':'+
1727
parseInt(M.parent.onMinigame?'1':'0')+':'+
1728
parseFloat(M.convertTimes)+':'+
1729
parseFloat(M.nextFreeze)+':'+
1730
' ';
1731
for (var i in M.plants)
1732
{
1733
str+=''+(M.plants[i].unlocked?'1':'0');
1734
}
1735
str+=' ';
1736
for (var y=0;y<6;y++)
1737
{
1738
for (var x=0;x<6;x++)
1739
{
1740
str+=parseInt(M.plot[y][x][0])+':'+parseInt(M.plot[y][x][1])+':';
1741
}
1742
}
1743
return str;
1744
}
1745
M.load=function(str)
1746
{
1747
//interpret str; called after .init
1748
//note : not actually called in the Game's load; see "minigameSave" in main.js
1749
if (!str) return false;
1750
var i=0;
1751
var spl=str.split(' ');
1752
var spl2=spl[i++].split(':');
1753
var i2=0;
1754
M.nextStep=parseFloat(spl2[i2++]||M.nextStep);
1755
M.soil=parseInt(spl2[i2++]||M.soil);
1756
M.nextSoil=parseFloat(spl2[i2++]||M.nextSoil);
1757
M.freeze=parseInt(spl2[i2++]||M.freeze)?1:0;
1758
M.harvests=parseInt(spl2[i2++]||0);
1759
M.harvestsTotal=parseInt(spl2[i2++]||0);
1760
var on=parseInt(spl2[i2++]||0);if (on && Game.ascensionMode!=1) M.parent.switchMinigame(1);
1761
M.convertTimes=parseFloat(spl2[i2++]||M.convertTimes);
1762
M.nextFreeze=parseFloat(spl2[i2++]||M.nextFreeze);
1763
var seeds=spl[i++]||'';
1764
if (seeds)
1765
{
1766
var n=0;
1767
for (var ii in M.plants)
1768
{
1769
if (seeds.charAt(n)=='1') M.plants[ii].unlocked=1; else M.plants[ii].unlocked=0;
1770
n++;
1771
}
1772
}
1773
M.plants['bakerWheat'].unlocked=1;
1774
1775
var plot=spl[i++]||0;
1776
if (plot)
1777
{
1778
plot=plot.split(':');
1779
var n=0;
1780
for (var y=0;y<6;y++)
1781
{
1782
for (var x=0;x<6;x++)
1783
{
1784
M.plot[y][x]=[parseInt(plot[n]),parseInt(plot[n+1])];
1785
n+=2;
1786
}
1787
}
1788
}
1789
1790
M.getUnlockedN();
1791
M.computeStepT();
1792
1793
M.buildPlot();
1794
M.buildPanel();
1795
1796
M.computeBoostPlot();
1797
M.toCompute=true;
1798
}
1799
M.reset=function(hard)
1800
{
1801
M.soil=0;
1802
if (M.seedSelected>-1) M.plantsById[M.seedSelected].l.classList.remove('on');
1803
M.seedSelected=-1;
1804
1805
M.nextStep=Date.now();
1806
M.nextSoil=Date.now();
1807
M.nextFreeze=Date.now();
1808
for (var y=0;y<6;y++)
1809
{
1810
for (var x=0;x<6;x++)
1811
{
1812
M.plot[y][x]=[0,0];
1813
}
1814
}
1815
1816
M.harvests=0;
1817
if (hard)
1818
{
1819
M.convertTimes=0;
1820
M.harvestsTotal=0;
1821
for (var i in M.plants)
1822
{
1823
M.plants[i].unlocked=0;
1824
}
1825
}
1826
1827
M.plants['bakerWheat'].unlocked=1;
1828
1829
M.loopsMult=1;
1830
1831
M.getUnlockedN();
1832
M.computeStepT();
1833
1834
M.computeMatures();
1835
1836
M.buildPlot();
1837
M.buildPanel();
1838
M.toCompute=true;
1839
1840
setTimeout(function(M){return function(){M.onResize();}}(M),10);
1841
}
1842
M.logic=function()
1843
{
1844
//run each frame
1845
var now=Date.now();
1846
1847
if (!M.freeze)
1848
{
1849
M.nextStep=Math.min(M.nextStep,now+(M.stepT)*1000);
1850
if (now>=M.nextStep)
1851
{
1852
M.computeStepT();
1853
M.nextStep=now+M.stepT*1000;
1854
1855
M.computeBoostPlot();
1856
M.computeMatures();
1857
1858
var weedMult=M.soilsById[M.soil].weedMult;
1859
1860
var loops=1;
1861
if (M.soilsById[M.soil].key=='woodchips') loops=3;
1862
loops*=M.loopsMult;
1863
M.loopsMult=1;
1864
1865
for (var y=0;y<6;y++)
1866
{
1867
for (var x=0;x<6;x++)
1868
{
1869
if (M.isTileUnlocked(x,y))
1870
{
1871
var tile=M.plot[y][x];
1872
var me=M.plantsById[tile[0]-1];
1873
if (tile[0]>0)
1874
{
1875
//age
1876
tile[1]+=randomFloor((me.ageTick+me.ageTickR*Math.random())*M.plotBoost[y][x][0]);
1877
tile[1]=Math.max(tile[1],0);
1878
if (me.immortal) tile[1]=Math.min(me.mature+1,tile[1]);
1879
else if (tile[1]>=100)
1880
{
1881
//die of old age
1882
M.plot[y][x]=[0,0];
1883
if (me.onDie) me.onDie(x,y);
1884
if (M.soilsById[M.soil].key=='pebbles' && Math.random()<0.35)
1885
{
1886
if (M.unlockSeed(me)) Game.Popup('Unlocked '+me.name+' seed.',Game.mouseX,Game.mouseY);
1887
}
1888
}
1889
else if (!me.noContam)
1890
{
1891
//other plant contamination
1892
//only occurs in cardinal directions
1893
//immortal plants and plants with noContam are immune
1894
1895
var list=[];
1896
for (var i in M.plantContam)
1897
{
1898
if (Math.random()<M.plantContam[i] && (!M.plants[i].weed || Math.random()<weedMult)) list.push(i);
1899
}
1900
var contam=choose(list);
1901
1902
if (contam && me.key!=contam)
1903
{
1904
if ((!M.plants[contam].weed && !M.plants[contam].fungus) || Math.random()<M.plotBoost[y][x][2])
1905
{
1906
var any=0;
1907
var neighs={};//all surrounding plants
1908
var neighsM={};//all surrounding mature plants
1909
for (var i in M.plants){neighs[i]=0;}
1910
for (var i in M.plants){neighsM[i]=0;}
1911
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]++;}}
1912
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]++;}}
1913
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]++;}}
1914
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]++;}}
1915
1916
if (neighsM[contam]>=1) M.plot[y][x]=[M.plants[contam].id+1,0];
1917
}
1918
}
1919
}
1920
}
1921
else
1922
{
1923
//plant spreading and mutation
1924
//happens on all 8 tiles around this one
1925
for (var loop=0;loop<loops;loop++)
1926
{
1927
var any=0;
1928
var neighs={};//all surrounding plants
1929
var neighsM={};//all surrounding mature plants
1930
for (var i in M.plants){neighs[i]=0;}
1931
for (var i in M.plants){neighsM[i]=0;}
1932
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]++;}}
1933
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]++;}}
1934
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]++;}}
1935
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]++;}}
1936
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]++;}}
1937
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]++;}}
1938
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]++;}}
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
if (any>0)
1941
{
1942
var muts=M.getMuts(neighs,neighsM);
1943
1944
var list=[];
1945
for (var ii=0;ii<muts.length;ii++)
1946
{
1947
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]);
1948
}
1949
if (list.length>0) M.plot[y][x]=[M.plants[choose(list)].id+1,0];
1950
}
1951
else if (loop==0)
1952
{
1953
//weeds in empty tiles (no other plants must be nearby)
1954
var chance=0.002*weedMult*M.plotBoost[y][x][2];
1955
if (Math.random()<chance) M.plot[y][x]=[M.plants['meddleweed'].id+1,0];
1956
}
1957
}
1958
}
1959
}
1960
}
1961
}
1962
M.toRebuild=true;
1963
M.toCompute=true;
1964
}
1965
}
1966
if (M.toRebuild) M.buildPlot();
1967
if (M.toCompute) M.computeEffs();
1968
1969
if (Game.keys[27])//esc
1970
{
1971
if (M.seedSelected>-1) M.plantsById[M.seedSelected].l.classList.remove('on');
1972
M.seedSelected=-1;
1973
}
1974
}
1975
M.draw=function()
1976
{
1977
//run each draw frame
1978
1979
if (M.cursorL)
1980
{
1981
if (!M.cursor || M.seedSelected<0)
1982
{
1983
M.cursorL.style.display='none';
1984
}
1985
else
1986
{
1987
var box=l('gardenDrag').getBoundingClientRect();
1988
var x=Game.mouseX-box.left-24;
1989
var y=Game.mouseY-box.top;
1990
var seed=M.plantsById[M.seedSelected];
1991
var icon=[0,seed.icon];
1992
M.cursorL.style.transform='translate('+(x)+'px,'+(y)+'px)';
1993
M.cursorL.style.backgroundPosition=(-icon[0]*48)+'px '+(-icon[1]*48)+'px';
1994
M.cursorL.style.display='block';
1995
}
1996
}
1997
if (Game.drawT%10==0)
1998
{
1999
M.lumpRefill.style.display='block';
2000
if (M.freeze) l('gardenNextTick').innerHTML='Garden is frozen. Unfreeze to resume.';
2001
else l('gardenNextTick').innerHTML='Next tick in '+Game.sayTime((M.nextStep-Date.now())/1000*30+30,-1)+'';
2002
l('gardenStats').innerHTML='Mature plants harvested : '+Beautify(M.harvests)+' (total : '+Beautify(M.harvestsTotal)+')';
2003
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>';
2004
else l('gardenPlotSize').innerHTML='';
2005
l('gardenSeedsUnlocked').innerHTML='Seeds<small> ('+M.plantsUnlockedN+'/'+M.plantsN+')</small>';
2006
for (var i in M.soils)
2007
{
2008
var me=M.soils[i];
2009
if (M.parent.amount<me.req) l('gardenSoil-'+me.id).classList.add('disabled');
2010
else l('gardenSoil-'+me.id).classList.remove('disabled');
2011
}
2012
}
2013
}
2014
M.init(l('rowSpecial'+M.parent.id));
2015
}
2016
var M=0;
2017
2018