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