JAVASCRIPT 7
Cookiebot Beta Beta By admin on 5th October 2018 06:13:26 PM
  1. //cookie bot: auto-play-through cookie clicker
  2.  
  3. var AutoPlay;
  4.  
  5. if(!AutoPlay) AutoPlay = {};
  6. AutoPlay.version = "1.9.11"
  7. AutoPlay.gameVersion = "2.012";
  8. AutoPlay.robotName="Automated ";
  9. AutoPlay.delay=0;
  10. AutoPlay.night=false;
  11. AutoPlay.finished=false;
  12. AutoPlay.deadline=0;
  13.  
  14. AutoPlay.run = function () {
  15.   if (Game.AscendTimer>0 || Game.ReincarnateTimer>0) return;
  16.   if (AutoPlay.delay>0) { AutoPlay.delay--; return; }
  17.   if (AutoPlay.nextAchievement==397) { AutoPlay.runJustRight(); return; }
  18.   AutoPlay.now=Date.now();
  19.   // if high cps then do not wait
  20.   if (AutoPlay.now<AutoPlay.deadline) { AutoPlay.handleClicking(); AutoPlay.handleGoldenCookies(); return; }
  21.   AutoPlay.deadline=AutoPlay.now+6000; // wait 10 seconds before next step
  22.   AutoPlay.cpsMult=1;
  23.   for (var i in Game.buffs) if (typeof Game.buffs[i].multCpS != 'undefined') AutoPlay.cpsMult*=Game.buffs[i].multCpS;
  24.   if (AutoPlay.cpsMult>100) AutoPlay.setDeadline(0);
  25.   AutoPlay.activities = AutoPlay.mainActivity;
  26.   if (AutoPlay.plantPending || AutoPlay.harvestPlant) AutoPlay.addActivity("Do not ascend now, since we wait for plants to harvest!");
  27.   if (AutoPlay.nightMode()) { AutoPlay.cheatSugarLumps(AutoPlay.now-Game.lumpT); return; }
  28.   AutoPlay.handleClicking();
  29.   AutoPlay.handleGoldenCookies();
  30.   AutoPlay.handleUpgrades();
  31.   AutoPlay.handleBuildings();
  32.   AutoPlay.handleSeasons();
  33.   AutoPlay.handleDragon();
  34.   AutoPlay.handleWrinklers();
  35.   AutoPlay.handleSugarLumps();
  36.   AutoPlay.handleAscend();
  37.   AutoPlay.handleNotes();
  38. }
  39.  
  40. AutoPlay.runJustRight = function () {
  41.   AutoPlay.activities = "Running just right.";
  42.   AutoPlay.handleAscend();
  43.   if (Game.ObjectsById[Game.ObjectsById.length-1].amount) AutoPlay.doAscend("Starting runJustRight properly.",0);
  44.   const goal=1000000000000;
  45.   const notBuy=[0,1,2,3,4,5,6,129,324];
  46.   if (Game.cookies<goal/10) { // buying buildings and upgrades
  47.     for(var i = Game.ObjectsById.length-2; i >= 0; i--) {
  48.       var me = Game.ObjectsById[i];
  49.       if ((me.getPrice()<Game.cookies) && (me.amount<10+Game.ObjectsById[i+1].amount)) { me.buy(1); return; }
  50.     }
  51.     Game.UpgradesById.forEach(function(e) { if (e.unlocked && !e.bought && e.canBuy() && e.pool!="toggle" && notBuy.indexOf(e.id)<0) { e.buy(true); } });
  52.   } else {
  53.         var cookieDiff = goal-Game.cookies;
  54.         if (Game.BuildingsOwned == 0) { // almost there
  55.       if (Math.round(Game.cookiesd)==goal) AutoPlay.doAscend("Fixed run just right.",1);
  56.           else if ((cookieDiff < -goal) && (Date.now()-Game.startDate>60000)) AutoPlay.doAscend("runJustRight does not work, retry.",0);
  57.           else if (cookieDiff < -2000000000) Game.ObjectsById[0].buy(130);
  58.           else if (cookieDiff < -6000000) Game.ObjectsById[0].buy(90);
  59.           else if (cookieDiff < -30000) Game.ObjectsById[0].buy(50);
  60.           else if (cookieDiff < 0) Game.ObjectsById[0].buy(22);
  61.           else if (cookieDiff > 10000000) Game.ObjectsById[5].buy(1);
  62.           else if (cookieDiff > 500000) Game.ObjectsById[4].buy(1);
  63.           else if (cookieDiff > 5000) Game.ObjectsById[2].buy(1);
  64.           else if (cookieDiff > 50) Game.ObjectsById[0].buy(1);
  65.           else Game.ClickCookie();
  66.         } else { // now we are selling
  67.           if (cookieDiff/Game.cookiesPs > 1000) Game.ObjectsById[5].buy(1);
  68.       for(var i = Game.ObjectsById.length-2; i >= 0; i--) {
  69.         var me = Game.ObjectsById[i];
  70.         if (me.amount>10+Game.ObjectsById[i+1].amount) { me.sell(me.amount-(10+Game.ObjectsById[i+1].amount)); return; }
  71.         if (me.amount>0 && (4*me.getReverseSumPrice(me.amount)+Game.cookiesPs>cookieDiff)) { me.sell(100); }
  72.       }
  73.         }
  74.   }
  75. }
  76.  
  77. //===================== Night Mode ==========================
  78. AutoPlay.preNightMode = function() { if(AutoPlay.Config.NightMode!=1) return false; var h=(new Date).getHours(); return(h>=22); }
  79.  
  80. AutoPlay.nightMode = function() {
  81.   if(AutoPlay.Config.NightMode==0) return false;
  82.   if(AutoPlay.grinding() && !AutoPlay.endPhase()) return false; //do not sleep while grinding
  83.   var h=(new Date).getHours();
  84.   if(AutoPlay.Config.NightMode==1 && h>=7 && h<23) { // be active
  85.     if (AutoPlay.night) AutoPlay.useLump();
  86.     AutoPlay.night=false;
  87.     AutoPlay.nightAtTemple(false);
  88.     var gs=Game.Upgrades["Golden switch [on]"]; if(gs.unlocked) { gs.buy(); }
  89.         AutoPlay.nightAtGarden(false);
  90.     return false;
  91.   }
  92.   if (AutoPlay.night) { AutoPlay.activities='The bot is sleeping.'; return true; } //really sleep now
  93.   AutoPlay.addActivity('Preparing for the night.');
  94.   var gs=Game.Upgrades["Golden switch [off]"]; if(gs.unlocked) {
  95.     AutoPlay.handleGoldenCookies();
  96.     var buffCount=0;
  97.     for (var i in Game.buffs) { if(Game.buffs[i].time>=0) buffCount++; }
  98.         if((buffCount==1 && Game.hasBuff("Clot")) || h<7) gs.buy();
  99.         if(!gs.bought) return true; // do not activate spirits before golden switch
  100.   }
  101.   AutoPlay.nightAtTemple(true);
  102.   AutoPlay.nightAtGarden(true);
  103.   AutoPlay.night=true;
  104.   return true;
  105. }
  106.  
  107. //===================== Handle Cookies and Golden Cookies ==========================
  108. AutoPlay.handleGoldenCookies = function() { // pop the first golden cookie or reindeer
  109.   if(AutoPlay.Config.GoldenClickMode==0) return;
  110.   if(Game.shimmerTypes['golden'].n>=4 && !Game.Achievements['Four-leaf cookie'].won) return;
  111.   for(sx in Game.shimmers) {
  112.     var s=Game.shimmers[sx];
  113.     if((s.type!="golden") || (s.life<Game.fps) || (!Game.Achievements["Early bird"].won)) { s.pop(); AutoPlay.setDeadline(0); return; }
  114.     if((s.life/Game.fps)<(s.dur-2) && (Game.Achievements["Fading luck"].won)) {
  115.           s.pop();
  116.           AutoPlay.setDeadline(0);
  117.           if(AutoPlay.Config.GoldenClickMode==1) return;
  118.         }
  119.   }
  120.   AutoPlay.cheatGoldenCookies();
  121. }
  122.  
  123. AutoPlay.cheatGoldenCookies = function() {
  124.   if (AutoPlay.Config.CheatGolden==0) return;
  125.   var level=10+30*(AutoPlay.Config.CheatGolden-1);
  126.   if (AutoPlay.Config.CheatGolden==1) {
  127.     if(AutoPlay.wantAscend) return; // already cheated enough
  128.         if(!AutoPlay.grinding() || AutoPlay.endPhase()) return; // only cheat in grinding
  129.     var daysInRun=(Date.now()-Game.startDate)/1000/60/60/24;
  130.     if (daysInRun < 20) return; // cheat only after 20 days
  131.     level=((3*daysInRun)<<0)-20;
  132.   }
  133.   if(level>100) level=100;
  134.   AutoPlay.addActivity('Cheating golden cookies at level ' + level + '.');
  135.   var levelTime=Game.shimmerTypes.golden.maxTime*level/140;
  136.   if(Game.shimmerTypes.golden.time<levelTime) Game.shimmerTypes.golden.time=levelTime;
  137. //golden cookie with building special: var newShimmer=new Game.shimmer("golden");newShimmer.force="building special";
  138. }
  139.  
  140. AutoPlay.handleClicking = function() {
  141.   if (AutoPlay.Config.ClickMode==0) return;
  142.   //if (!Game.Achievements["Neverclick"].won && (Game.cookieClicks>=15) ) { AutoPlay.addActivity('Waiting for neverclick.'); return; }
  143.   //if (Game.ascensionMode==1 && AutoPlay.endPhase() && !Game.Achievements["True Neverclick"].won && (!Game.cookieClicks) ) { AutoPlay.addActivity('Waiting for true neverclick.'); return; }
  144.   if(!Game.Achievements["Uncanny clicker"].won) { for(i=1; i<6; i++) setTimeout(Game.ClickCookie, 150*i); }
  145.   if (Game.ascensionMode==1 && Game.Achievements["Hardcore"].won) setTimeout(Game.ClickCookie, 25); // extra clicking when born again for speed baking
  146.   if(AutoPlay.Config.ClickMode>1) { for(i=1; i<10; i++) setTimeout(AutoPlay.speedClicking, 30*i); }
  147.   Game.ClickCookie();
  148. }
  149.  
  150. AutoPlay.speedClicking = function() {
  151.   Game.ClickCookie();
  152.   var clickCount=1<<(10*(AutoPlay.Config.ClickMode-2));
  153.   Game.ClickCookie(0,clickCount*Game.computedMouseCps);
  154. }
  155.  
  156. //===================== Handle Upgrades ==========================
  157. AutoPlay.handleUpgrades = function() {
  158.   //if (!Game.Achievements["Hardcore"].won && Game.UpgradesOwned==0) return;
  159.   Game.UpgradesById.forEach(function(e) { if (e.unlocked && !e.bought && e.canBuy() && !AutoPlay.avoidbuy(e)) { e.buy(true); } });
  160.   if (Game.lumps>120 && Game.Upgrades["Sugar frenzy"].unlocked && !Game.Upgrades["Sugar frenzy"].bought && (Date.now()-Game.startDate) > 3*24*60*60*1000)
  161.     Game.Upgrades["Sugar frenzy"].buy();
  162. }
  163.  
  164. AutoPlay.avoidbuy = function(up) { //normally we do not buy 227, 71, 73, rolling pins
  165.   switch(up.id) {
  166.     case 71: return Game.Achievements["Elder nap"].won && Game.Achievements["Elder slumber"].won && Game.Achievements["Elder calm"].won &&
  167.           (!Game.Achievements["Reincarnation"].won || Game.Upgrades["Arcane sugar"].bought); // brainsweep
  168.         case 73: return Game.Achievements["Elder nap"].won && Game.Achievements["Elder slumber"].won && Game.Achievements["Elder calm"].won; // elder pact
  169.         case 74: return Game.Achievements["Elder nap"].won && Game.Achievements["Elder slumber"].won && Game.Upgrades["Elder Covenant"].unlocked; // elder pledge
  170.         case 84: return Game.Upgrades["Elder Pledge"].bought || Game.Achievements["Elder calm"].won; // elder covenant
  171. //      case 85: return Game.Upgrades["Elder Covenant"].bought; // revoke elder covenant
  172.     case 227: return true; // choco egg
  173.         default: return up.pool=="toggle";
  174. } }
  175.  
  176. //===================== Handle Buildings ==========================
  177. AutoPlay.handleBuildings = function() {
  178.   var buyAmount=100, checkAmount=1;
  179.   if (Game.buyMode==-1) Game.storeBulkButton(0);
  180.   if ((Date.now()-Game.startDate) > 10*60*1000) buyAmount=1; // buy single after 10 minutes
  181.   if (Game.resets && Game.ascensionMode!=1 && Game.isMinigameReady(Game.Objects["Temple"]) && Game.Objects["Temple"].minigame.slot[0]==10 // Rigidel is in slot 0
  182.       && Game.BuildingsOwned%10==0 && (Date.now()-Game.startDate) > 2*60*1000) // do not use factor 10 in the first 2 minutes after descend
  183.     buyAmount=checkAmount=10;
  184.   var cpc=0; // relative strength of cookie production
  185.   for(var i = Game.ObjectsById.length-1; i >= 0; i--){ var me = Game.ObjectsById[i]; var mycpc = me.storedCps / me.price; if (mycpc > cpc) { cpc = mycpc; } };
  186.   for(i = Game.ObjectsById.length-1; i >= 0; i--) {
  187.     var me = Game.ObjectsById[i];
  188.     if ((me.storedCps/me.price > cpc/2 || me.amount % 50 >= 40) && (me.getSumPrice(checkAmount)<Game.cookies)) {
  189.           me.buy(buyAmount); AutoPlay.setDeadline(0); return;
  190.         }
  191.   }
  192.   if(Game.resets && Game.ascensionMode!=1 && Game.isMinigameReady(Game.Objects["Temple"]) && Game.Objects["Temple"].minigame.slot[0]==10 && Game.BuildingsOwned%10!=0) { // Rigidel is in slot 0, buy the cheapest
  193.         var minIdx=0, minPrice=Game.ObjectsById[minIdx].price;
  194.     for(var i = Game.ObjectsById.length-1; i >= 0; i--){ if (Game.ObjectsById[i].price < minPrice) { minPrice=Game.ObjectsById[i].price; minIdx=i; } };
  195.         Game.ObjectsById[minIdx].buy();
  196. } }
  197.  
  198. //===================== Handle Seasons ==========================
  199. AutoPlay.handleSeasons = function() {
  200.   if (!Game.Upgrades["Season switcher"].bought || Game.ascensionMode==1) return;
  201.   if (AutoPlay.seasonFinished(Game.season)) {
  202.     switch (Game.season) {
  203.           case "christmas": Game.Upgrades["Bunny biscuit"].buy(); break; // go to easter
  204.           case "easter": Game.Upgrades["Lovesick biscuit"].buy(); break; // go to valentine
  205.           case "valentines": Game.Upgrades["Ghostly biscuit"].buy(); break; // go to halloween
  206.           default: Game.Upgrades["Festive biscuit"].buy(); break; // go to christmas
  207.   } } else if (!(AutoPlay.allUnlocked(AutoPlay.allSeasonUpgrades))) AutoPlay.addActivity('Waiting for all results in '+Game.season+'.');
  208.   if (Game.Upgrades["A festive hat"].bought && ! Game.Upgrades["Santa's dominion"].unlocked) { // develop santa
  209.     Game.specialTab="santa"; Game.UpgradeSanta(); Game.ToggleSpecialMenu(0);
  210. } }
  211.  
  212. AutoPlay.valentineUpgrades = range(169,174);
  213. AutoPlay.christmasUpgrades = [168].concat(range(152,166)).concat(range(143,149));
  214. AutoPlay.easterUpgrades = range(210,229);
  215. AutoPlay.halloweenUpgrades = range(134,140);
  216. AutoPlay.allSeasonUpgrades = AutoPlay.valentineUpgrades.concat(AutoPlay.christmasUpgrades).concat(AutoPlay.easterUpgrades).concat(AutoPlay.halloweenUpgrades);
  217.  
  218. AutoPlay.allUnlocked = function(l) { return l.every(function (u) { return Game.UpgradesById[u].unlocked; }); }
  219.  
  220. AutoPlay.seasonFinished = function(s) {
  221.   if (s == '') return true;
  222.   switch (s) {
  223.     case "valentines": return AutoPlay.allUnlocked(AutoPlay.valentineUpgrades);
  224.         case "christmas": if (AutoPlay.allUnlocked(AutoPlay.allSeasonUpgrades)) return false; else return AutoPlay.allUnlocked(AutoPlay.christmasUpgrades);
  225.         case "easter": return (Game.Achievements["Hide & seek champion"].won && (AutoPlay.allUnlocked(AutoPlay.easterUpgrades)));
  226.         case "halloween": return AutoPlay.allUnlocked(AutoPlay.halloweenUpgrades);
  227.         default: return true;
  228. } }
  229.  
  230. //===================== Handle Sugarlumps ==========================
  231. AutoPlay.level1Order=[2,6,7]; // unlocking in this order for the minigames
  232. AutoPlay.level10Order=[2,7]; // finishing in this order
  233. AutoPlay.minLumps=AutoPlay.level1Order.length+55*AutoPlay.level10Order.length;
  234. AutoPlay.lumpRelatedAchievements=range(307,320).concat([336,268,271]);
  235.  
  236. AutoPlay.handleSugarLumps = function() {
  237.   if (!Game.canLumps()) return; //do not work with sugar lumps before enabled
  238.   if (Game.ascensionMode==1) return; //no sugar lumps in born again
  239.   var age=AutoPlay.now-Game.lumpT;
  240.   if (age>=Game.lumpMatureAge && Game.lumpCurrentType==0 && Game.lumpsTotal>AutoPlay.minLumps && !Game.Achievements["Hand-picked"].won) AutoPlay.harvestLump();
  241. //  if(Game.lumpCurrentType==0) AutoPlay.farmGoldenSugarLumps(age); // not needed now, because we cheat sugar lumps
  242.   if (age>=Game.lumpRipeAge) AutoPlay.harvestLump(); // normal harvesting, should check !masterCopy
  243.   AutoPlay.cheatSugarLumps(age);
  244.   AutoPlay.useLump();
  245.   AutoPlay.handleMinigames();
  246. }
  247.  
  248. AutoPlay.cheatSugarLumps = function(age) {
  249.   AutoPlay.cheatLumps=false;
  250.   if(AutoPlay.Config.CheatLumps==0) return;
  251.   if(AutoPlay.Config.CheatLumps==1) {
  252.         if(AutoPlay.finished) return;
  253.     for(a in Game.AchievementsById) { var me=Game.AchievementsById[a]; if (!(me.won || me.pool=="dungeon" || AutoPlay.lumpRelatedAchievements.indexOf(me.id)>=0)) return; }
  254.   }
  255.   AutoPlay.cheatLumps=true; // after checking that only heavy lump related achievements are missing
  256.   AutoPlay.addActivity('Cheating sugar lumps.');
  257.   var cheatReduction=25*25; // divide lump ripe time, making days into hours, minutes or seconds
  258.   if (AutoPlay.Config.CheatLumps==2) cheatReduction=25;
  259.   if (AutoPlay.Config.CheatLumps==4) cheatReduction=25*cheatReduction;
  260.   var cheatDelay=Game.lumpRipeAge/cheatReduction;
  261.   if(age<Game.lumpRipeAge-cheatDelay) Game.lumpT-=cheatDelay*(cheatReduction-1);
  262. }
  263.  
  264. AutoPlay.harvestLump = function() {
  265.   Game.clickLump(); //could reload if golden lump and below 6 harvested (much work, little payback)
  266.   AutoPlay.useLump();
  267. }
  268.  
  269. AutoPlay.useLump = function() { // recursive call just needed if we have many sugar lumps
  270.   if(!Game.lumps) return;
  271.   for(i in AutoPlay.level1Order) {
  272.     var me = Game.ObjectsById[AutoPlay.level1Order[i]];
  273.         if (!me.level && Game.lumps) { me.levelUp(); AutoPlay.useLump(); return; }
  274.   }
  275.   for(i in AutoPlay.level10Order) {
  276.     var me = Game.ObjectsById[AutoPlay.level10Order[i]];
  277.         if (me.level<10) { if(me.level<Game.lumps) { me.levelUp(); AutoPlay.useLump(); } return; }
  278.   }
  279.   if(Game.lumps<95) return; //collect lumps for  better cps
  280.   for(i = Game.ObjectsById.length-1; i >= 0; i--) {
  281.     var me = Game.ObjectsById[i];
  282.         if (me.level<10 && me.level<Game.lumps) { me.levelUp(); AutoPlay.useLump(); return; }
  283.   }
  284. //  for(i = Game.ObjectsById.length-1; i >= 0; i--) Game.ObjectsById[i].levelUp(); -- do not use sugar lumps for more than level 10
  285. }
  286.  
  287.  
  288. /* farming golden sugar lumps - not needed now since we cheat sugar lumps
  289. AutoPlay.copyWindows=[]; // need to init in the code some place
  290. AutoPlay.masterSaveCopy=0;
  291. AutoPlay.masterLoadCopy=0;
  292. AutoPlay.copyCount=100;
  293.  
  294. // golden sugar lumps = 1 in 2000 (ordinary) -> about 5 years
  295. AutoPlay.farmGoldenSugarLumps = function(age) { // this is tested and it works (some kind of cheating) - do this only in endgame
  296.   if(Game.Achievements["All-natural cane sugar"].won) return;
  297.   if(AutoPlay.nextAchievement!=Game.Achievements["All-natural cane sugar"].id) return;
  298.   if (AutoPlay.masterSaveCopy) { AutoPlay.debugInfo("back to save master"); Game.LoadSave(AutoPlay.masterSaveCopy); AutoPlay.masterSaveCopy=0; return; }
  299.   if (age<Game.lumpRipeAge && age>=Game.lumpMatureAge) {
  300.     if (AutoPlay.copyWindows.length>=AutoPlay.copyCount) { AutoPlay.debugInfo("creating master load copy"); AutoPlay.masterLoadCopy=Game.WriteSave(1); } // check rather !masterCopy
  301.     if (AutoPlay.copyWindows.length) {
  302.           Game.LoadSave(AutoPlay.copyWindows.pop());
  303.           if (Game.lumpCurrentType) AutoPlay.debugInfo("found lump with type " + Game.lumpCurrentType);
  304.           if (Game.lumpCurrentType==2) {
  305.             AutoPlay.info("YESS, golden lump");
  306.                 AutoPlay.masterLoadCopy=0; AutoPlay.copyWindows=[];
  307.         } } else if (AutoPlay.masterLoadCopy) { AutoPlay.debugInfo("going back to master copy"); Game.LoadSave(AutoPlay.masterLoadCopy); AutoPlay.masterLoadCopy=0; }
  308.   }
  309.   if (age>=Game.lumpRipeAge && AutoPlay.copyWindows.length<AutoPlay.copyCount) {
  310.     if(!AutoPlay.copyWindows.length) AutoPlay.info("farming golden sugar lumps.");
  311.     AutoPlay.masterSaveCopy=Game.WriteSave(1);
  312.     Game.clickLump();
  313.     AutoPlay.copyWindows.push(Game.WriteSave(1));
  314.   }
  315. }
  316. */
  317.  
  318. AutoPlay.handleMinigames = function() {
  319.   // wizard towers: grimoires
  320.   if (Game.isMinigameReady(Game.Objects["Wizard tower"])) {
  321.     var g=Game.Objects["Wizard tower"].minigame;
  322.     var sp=g.spells["hand of fate"]; // try to get a sugar lump in backfiring
  323.         if (Game.shimmerTypes['golden'].n && g.magic>=g.getSpellCost(sp) && (g.magic/g.magicM >= 0.95)) { g.castSpell(sp); }
  324.     if (Game.shimmerTypes['golden'].n == 2 && !Game.Achievements["Four-leaf cookie"].won && Game.lumps>0 && g.magic>=g.getSpellCost(sp)) { g.castSpell(sp); }
  325.     if (Game.shimmerTypes['golden'].n == 3 && !Game.Achievements["Four-leaf cookie"].won) { g.lumpRefill.click(); g.castSpell(sp); }
  326.     sp=g.spells["conjure baked goods"];
  327.         if (AutoPlay.cpsMult>100) {
  328.           if (g.magic>=g.getSpellCost(sp)) { g.castSpell(sp); return; }
  329.           if (Game.lumps>98) { g.lumpRefill.click(); }
  330.         }
  331.   }
  332.   // temples: pantheon
  333.   if (Game.isMinigameReady(Game.Objects["Temple"])) {
  334.         var age=AutoPlay.now-Game.lumpT;
  335.     if(Game.lumpRipeAge-age < 61*60*1000 && !AutoPlay.cheatLumps /*&& Game.lumps<11*/) AutoPlay.assignSpirit(0,"order",0);
  336.         else if (AutoPlay.preNightMode() && Game.lumpOverripeAge-age < 9*60*60*1000 && (new Date).getMinutes()==59 && !AutoPlay.cheatLumps) AutoPlay.assignSpirit(0,"order",0);
  337.         else AutoPlay.assignSpirit(0,"mother",0);
  338.     AutoPlay.assignSpirit(1,"decadence",0);
  339.     AutoPlay.assignSpirit(2,"labor",0);
  340.   }
  341.   // farms: garden
  342.   if (Game.isMinigameReady(Game.Objects["Farm"])) {
  343.         // only check after each tick (wait until Date.now() > g.nextStep
  344.     var g=Game.Objects["Farm"].minigame;
  345.         AutoPlay.planting(g);
  346.         AutoPlay.harvesting(g);
  347.     if(Game.lumps<100 && AutoPlay.gardenReady(g) && !AutoPlay.finished && !AutoPlay.harvestPlant &&
  348.             !AutoPlay.lumpRelatedAchievements.every(function(a) { return Game.AchievementsById[a].won; })) {
  349.       AutoPlay.plantCookies = false;
  350.           g.harvestAll(); g.askConvert(); Game.ConfirmPrompt(); //convert garden in order to get more sugar lumps
  351.           AutoPlay.plantList=[0,0,0,0];
  352.         }
  353.   }
  354. }
  355.  
  356. AutoPlay.gardenUpgrades = range(470,476);
  357.  
  358. AutoPlay.gardenReady = function(g) { // have all plants and all cookies
  359.   return (Game.Objects["Farm"].level>8) &&
  360.     (g.plantsUnlockedN==g.plantsN) &&
  361.     AutoPlay.allUnlocked(AutoPlay.gardenUpgrades);
  362. }
  363.  
  364. AutoPlay.nightAtTemple = function(on) {
  365.   if(!Game.isMinigameReady(Game.Objects["Temple"])) return;
  366.   if(on) {
  367.     AutoPlay.removeSpirit(1,"decadence");
  368.     AutoPlay.removeSpirit(2,"labor");
  369.     AutoPlay.assignSpirit(1,"asceticism",1);
  370.     AutoPlay.assignSpirit(2,"industry",1);
  371.   } else {
  372.     AutoPlay.removeSpirit(1,"asceticism");
  373.   }
  374. }
  375.  
  376. AutoPlay.nightAtGarden = function(on) {
  377.   if(!Game.isMinigameReady(Game.Objects["Farm"])) return;
  378.   if(on!=Game.Objects["Farm"].minigame.freeze) FireEvent(l('gardenTool-2'),'click'); // (un)freeze garden
  379. }
  380.  
  381. AutoPlay.plantDependencies = [
  382. ['dummy','dummy','dummy'], // just to fill index 0
  383. ['queenbeetLump','queenbeet','queenbeet'], // need to know its index
  384. ['everdaisy','elderwort','tidygrass'], // need to know its index
  385. // critical path
  386. ['thumbcorn','bakerWheat','bakerWheat'], //level 1
  387. ['cronerice','bakerWheat','thumbcorn'], //level 2
  388. ['gildmillet','thumbcorn','cronerice'], //level 3
  389. ['clover','bakerWheat','gildmillet'], //level 4
  390. ['shimmerlily','gildmillet','clover'], //level 5
  391. ['elderwort','cronerice','shimmerlily'], //level 6
  392. //rest is given according to ripening times
  393. ['drowsyfern','chocoroot','keenmoss'], //level 7
  394. ['duketater','queenbeet','queenbeet'], //level 3
  395. ['tidygrass','bakerWheat','whiteChocoroot'], //level 3
  396. ['queenbeet','chocoroot','bakeberry'], //level 2
  397. ['nursetulip','whiskerbloom','whiskerbloom'], //level 7
  398. ['doughshroom','crumbspore','crumbspore'], //level 1
  399. ['bakeberry','bakerWheat','bakerWheat'], //level 1
  400. ['wrinklegill','crumbspore','brownMold'], //level 1
  401. ['shriekbulb','wrinklegill','elderwort'], //level 7
  402. ['ichorpuff','crumbspore','elderwort'], //level 7
  403. ['whiskerbloom','whiteChocoroot','shimmerlily'], //level 6
  404. ['chimerose','whiskerbloom','shimmerlily'], //level 7
  405. ['keenmoss','brownMold','greenRot'], //level 6
  406. ['wardlichen','cronerice','whiteMildew'], //level 3
  407. ['glovemorel','thumbcorn','crumbspore'], //level 2
  408. ['chocoroot','bakerWheat','brownMold'], //level 1
  409. ['whiteChocoroot','chocoroot','whiteMildew'], //level 2
  410. ['whiteMildew','brownMold','brownMold'], //level 1
  411. ['goldenClover','bakerWheat','gildmillet'], //level 4
  412. ['greenRot','clover','whiteMildew'], //level 5
  413. ['cheapcap','crumbspore','shimmerlily'], //level 6
  414. ['foolBolete','greenRot','doughshroom'] //level 6
  415. ];
  416.  
  417. if(!AutoPlay.plantList) AutoPlay.plantList=[0,0,0,0];
  418. AutoPlay.plantPending=false; // Is there a plant we want and that is not mature yet?
  419. AutoPlay.harvestPlant=false; // Is there a plant that gives things when harvesting?
  420. AutoPlay.plantsMissing=true; // Are there still unlocked plants?
  421.  
  422. AutoPlay.sectorText = function(sector) {
  423.   if(Game.Objects["Farm"].level>4) return (sector<2?'bottom':'top')+(sector%2?' left':' right');
  424.   else if (Game.Objects["Farm"].level==4) return (sector%2?'left':'right');
  425.   else return 'middle';
  426. }
  427.  
  428. AutoPlay.havePlant = function(game,plant) {
  429.   if(game.plants[plant].unlocked) return true;
  430.   var plantID=game.plants[plant].id+1;
  431.   for(var x=0;x<6;x++) for(var y=0;y<6;y++) {
  432.     if((game.getTile(x,y))[0]==plantID) return true;
  433.   }
  434.   return false;
  435. }
  436.  
  437. AutoPlay.findPlants = function(game,idx) {
  438.   if(AutoPlay.wantAscend) return false; // do not plant before ascend
  439.   var couldPlant=0;
  440.   if(AutoPlay.plantList[idx]!=0) {// already used
  441.     var oldPlant=AutoPlay.plantDependencies[AutoPlay.plantList[idx]][0];
  442.     AutoPlay.addActivity("Trying to get plant " + game.plants[oldPlant].name + " on sector " + AutoPlay.sectorText(idx) + '.');
  443.     AutoPlay.plantCookies = false;
  444. //      AutoPlay.info("currently we have " + oldPlant + " and it is unlocked " + game.plants[oldPlant].unlocked);
  445.     if(AutoPlay.havePlant(game,oldPlant)) AutoPlay.plantList[idx]=0; else return true;
  446.   }
  447.   var chkx=(idx%2)?0:5; var chky=(idx>1)?0:5; // try to plant expensive plants first (if possible) as they take longest time.
  448.   if(game.isTileUnlocked(chkx,chky)) { // only plant if the spot is big enough
  449.     if(!AutoPlay.havePlant(game,'everdaisy') && game.plants['elderwort'].unlocked && game.plants['tidygrass'].unlocked) {
  450.           if(AutoPlay.plantList.includes(2)) couldPlant=2;
  451.           else { AutoPlay.plantList[idx]=2; AutoPlay.info("expensive planting everdaisy onto " + idx); return true; }
  452.         }
  453.     if(!AutoPlay.havePlant(game,'queenbeetLump') && game.plants['queenbeet'].unlocked) {
  454.           if(AutoPlay.plantList.includes(1)) couldPlant=1;
  455.           else { AutoPlay.plantList[idx]=1; AutoPlay.info("expensive planting queenbeetLump onto " + idx); return true; }
  456.         }
  457.   }
  458.   for(i = 3; i < AutoPlay.plantDependencies.length; i++) { // try to plant normals plants now
  459.         var plant=AutoPlay.plantDependencies[i][0];
  460.         if(!AutoPlay.havePlant(game,plant) && game.plants[AutoPlay.plantDependencies[i][1]].unlocked && game.plants[AutoPlay.plantDependencies[i][2]].unlocked) { // want to get the plant
  461.           if(AutoPlay.plantList.includes(i)) { if(!couldPlant) couldPlant=i; } // it is already in another slot - remember it
  462.           else { AutoPlay.plantList[idx]=i; AutoPlay.info("planting " + plant + " onto " + idx); return true; }
  463.     }
  464.   }
  465.   if(!couldPlant) return false;
  466.   // did not find anything else to do, join one of the others
  467.   //AutoPlay.plantList[idx]=(idx==0)?couldPlant:AutoPlay.plantList[idx>2?1:0];
  468.   AutoPlay.plantList[idx]=couldPlant;
  469.   AutoPlay.info("(re)planting " + AutoPlay.plantDependencies[AutoPlay.plantList[idx]][0] + " onto " + idx);
  470.   return true;
  471. }
  472.  
  473. AutoPlay.planting = function(game) {
  474.   if(!game.plants["meddleweed"].unlocked) { AutoPlay.plantList=[0,0,0,0]; AutoPlay.addActivity("Waiting for meddleweed."); AutoPlay.switchSoil(0,'fertilizer'); return; } // wait for meddleweed to appear
  475.   if(!game.plants["crumbspore"].unlocked || !game.plants["brownMold"].unlocked) { // use meddleweed to get them
  476.     AutoPlay.addActivity("Trying to get crumbspore and brown mold.");
  477.     for(var x=0;x<6;x++) for(var y=0;y<6;y++) if(game.isTileUnlocked(x,y)) AutoPlay.plantSeed("meddleweed",x,y);
  478.         return;
  479.   }
  480.   AutoPlay.plantsMissing=true;
  481.   if(!AutoPlay.findPlants(game,0)) { AutoPlay.plantList=[0,0,0,0]; for(var i=0; i<4; i++) AutoPlay.plantSector(i,'','','dummy'); return; }
  482.   AutoPlay.switchSoil(0,AutoPlay.plantPending?'fertilizer':'woodchips'); // want many mutations
  483.   if(Game.Objects["Farm"].level<4) {
  484.     AutoPlay.plantSeed(AutoPlay.plantDependencies[AutoPlay.plantList[0]][1],3,2); AutoPlay.plantSeed(AutoPlay.plantDependencies[AutoPlay.plantList[0]][2],3,3);
  485.         if(game.isTileUnlocked(3,4)) AutoPlay.plantSeed(AutoPlay.plantDependencies[AutoPlay.plantList[0]][1],3,4);
  486.         return;
  487.   }
  488.   AutoPlay.findPlants(game,1);
  489.   if(Game.Objects["Farm"].level==4) { // now we are at level 4
  490.     if(AutoPlay.plantList[1]==0) { AutoPlay.info("Warning: Do not know what to plant in sector 2."); return; } // should never happen
  491.     AutoPlay.plantSeed(AutoPlay.plantDependencies[AutoPlay.plantList[0]][1],4,2);
  492.         AutoPlay.plantSeed(AutoPlay.plantDependencies[AutoPlay.plantList[0]][2],4,3);
  493.         AutoPlay.plantSeed(AutoPlay.plantDependencies[AutoPlay.plantList[0]][1],4,4);
  494.     AutoPlay.plantSeed(AutoPlay.plantDependencies[AutoPlay.plantList[1]][1],1,2);
  495.         AutoPlay.plantSeed(AutoPlay.plantDependencies[AutoPlay.plantList[1]][2],1,3);
  496.         AutoPlay.plantSeed(AutoPlay.plantDependencies[AutoPlay.plantList[1]][1],1,4);
  497.         return;
  498.   }
  499.   AutoPlay.findPlants(game,2); AutoPlay.findPlants(game,3); // now we have four areas to build
  500.   for(var sector=0; sector<4; sector++) {
  501.         var dep=AutoPlay.plantDependencies[AutoPlay.plantList[sector]];
  502.         AutoPlay.plantSector(sector, dep[1], dep[2], dep[0]);
  503.   }
  504. }
  505.  
  506. AutoPlay.plantSector = function(sector,plant1,plant2,plant0) {
  507.   var X=(sector%2)?0:3;
  508.   var Y=(sector>1)?0:3;
  509.   if(plant0=="dummy") {
  510.         var thePlant=AutoPlay.seedCalendar(sector);
  511.     //AutoPlay.info("plantSector " + sector + " with " + thePlant);
  512.         for(var x = X; x < X+3; x++) for(var y = Y; y < Y+3; y++) { AutoPlay.plantSeed(thePlant,x,y); }
  513.     return;    
  514.   }
  515.   if(plant0=="queenbeetLump") {
  516.         for (var y = Y; y < Y+3; y++) { AutoPlay.plantSeed(plant1,X,y); AutoPlay.plantSeed(plant2,X+2,y); }
  517.         AutoPlay.plantSeed(plant1,X+1,Y); AutoPlay.plantSeed(plant2,X+1,Y+2);
  518.         return;
  519.   }
  520.   if(plant0=="everdaisy") {
  521.         for (var y = Y; y < Y+3; y++) { AutoPlay.plantSeed(plant1,X,y); AutoPlay.plantSeed(plant2,X+2,y); }
  522.         return;
  523.   }
  524.   AutoPlay.plantSeed(plant1,X+1,Y); AutoPlay.plantSeed(plant2,X+1,Y+1); AutoPlay.plantSeed(plant1,X+1,Y+2);
  525. }
  526.  
  527. AutoPlay.plantCookies = false;
  528.  
  529. AutoPlay.plantSeed = function(seed,whereX,whereY) {
  530.   if (AutoPlay.cpsMult>10) return; // do not plant when it is expensive
  531.   var g=Game.Objects["Farm"].minigame;
  532.   if(!g.isTileUnlocked(whereX,whereY)) return; // do not plant onto locked tiles
  533.   var oldPlant=(g.getTile(whereX,whereY))[0];
  534.   if (oldPlant!=0) { // slot is already planted, try to get rid of it
  535.     if(g.plantsById[oldPlant-1].key!=seed) AutoPlay.cleanSeed(g,whereX,whereY);
  536.         return;
  537.   }
  538.   if(!g.canPlant(g.plants[seed])) return;
  539.   g.useTool(g.plants[seed].id,whereX,whereY)
  540. }
  541.  
  542. AutoPlay.seedCalendar = function(sector) {
  543.   if(AutoPlay.wantAscend) return 'bakerWheat'; // plant cheap before ascend
  544.   AutoPlay.plantsMissing=false;
  545.   var g=Game.Objects["Farm"].minigame;
  546.   if(sector==0) AutoPlay.plantCookies = true;
  547.   var doPrint = (sector==0) || (sector!=3 && Game.Objects["Farm"].level==sector+6);
  548.   if(!Game.Upgrades["Wheat slims"].bought && g.plants["bakerWheat"].unlocked) { AutoPlay.switchSoil(sector,'fertilizer'); if(doPrint) AutoPlay.addActivity("Trying to get Wheat slims."); return "bakerWheat"; }
  549.   if(!Game.Upgrades["Elderwort biscuits"].bought && g.plants["elderwort"].unlocked) { AutoPlay.switchSoil(sector,'fertilizer'); if(doPrint) AutoPlay.addActivity("Trying to get Elderwort cookies."); return "elderwort"; }
  550.   if(!Game.Upgrades["Bakeberry cookies"].bought && g.plants["bakeberry"].unlocked) { AutoPlay.switchSoil(sector,'fertilizer'); if(doPrint) AutoPlay.addActivity("Trying to get Bakeberry cookies."); return "bakeberry"; }
  551.   if(!Game.Upgrades["Fern tea"].bought && g.plants["drowsyfern"].unlocked) { AutoPlay.switchSoil(sector,'fertilizer'); if(doPrint) AutoPlay.addActivity("Trying to get Fern tea."); return "drowsyfern"; }
  552.   if(!Game.Upgrades["Duketater cookies"].bought && g.plants["duketater"].unlocked) { AutoPlay.switchSoil(sector,'fertilizer'); if(doPrint) AutoPlay.addActivity("Trying to get Duketater cookies."); return "duketater"; }
  553.   if(!Game.Upgrades["Green yeast digestives"].bought && g.plants["greenRot"].unlocked) { AutoPlay.switchSoil(sector,'fertilizer'); if(doPrint) AutoPlay.addActivity("Trying to get Green yeast digestives."); return "greenRot"; }
  554.   if(!Game.Upgrades["Ichor syrup"].bought && g.plants["ichorpuff"].unlocked) { AutoPlay.switchSoil(sector,'fertilizer'); if(doPrint) AutoPlay.addActivity("Trying to get Ichor syrup."); return "ichorpuff"; }
  555.   AutoPlay.plantCookies = false;
  556.   AutoPlay.switchSoil(sector,(AutoPlay.plantPending)?'fertilizer':'clay'); //only when mature, otherwise it should be fertilizer
  557.   //use garden to get cps and sugarlumps
  558.   if(g.plants['bakeberry'].unlocked && AutoPlay.lumpRelatedAchievements.every(function(a) { return Game.AchievementsById[a].won; })) return 'bakeberry'; // 1% cps add. + harvest 30 mins with high ratio - use only in endgame
  559.   if(g.plants['whiskerbloom'].unlocked) return 'whiskerbloom'; // approx. 1.5% cps add. - should use with nursetulip in the middle
  560.   return 'bakerWheat'; // nothing else works
  561. /* alternative: chocoroot gives 1% cps, but also gets 3 mins of cps - harvest on high cps - predictable growth */
  562. }
  563.  
  564. AutoPlay.cleaningGarden = function(game) {
  565.   if(Game.Objects["Farm"].level<4) {
  566.         if(AutoPlay.plantList[0]==0) return;
  567.     for(var y=2;y<5;y++) { AutoPlay.cleanSeed(game,2,y); AutoPlay.cleanSeed(game,4,y); }
  568.   } else if(Game.Objects["Farm"].level==4) {
  569.     for(var y=2;y<5;y++) { AutoPlay.cleanSeed(game,2,y); AutoPlay.cleanSeed(game,3,y); }
  570.   } else {
  571.     for(var sector=0; sector<4; sector++) AutoPlay.cleanSector(game,sector,AutoPlay.plantDependencies[AutoPlay.plantList[sector]][0]);
  572.   }
  573. }
  574.  
  575. AutoPlay.cleanSector = function(game,sector,plant0) {
  576.   if(plant0=="dummy") return; // do not clean when we are at work
  577.   var X=(sector%2)?0:3;
  578.   var Y=(sector>1)?0:3;
  579.   if(plant0=="queenbeetLump") { AutoPlay.cleanSeed(game,X+1,Y+1); return; }
  580.   if(plant0=="everdaisy") {
  581.     for (var y = Y; y < Y+3; y++) AutoPlay.cleanSeed(game,X+1,y);
  582.         return;
  583.   }
  584.   if(plant0=="all") {
  585.     for(var x=X;x<X+3;x++) for(var y=Y;y<Y+3;y++) if((x!=X+1)||(y!=Y+1)) { // we do not really need that if, do we?
  586.       var tile=game.getTile(x,y);
  587.           if ((tile[0]>=1) && game.plantsById[tile[0]-1].unlocked) game.harvest(x,y);
  588.         }
  589.         return;
  590.   }
  591.   for(var y=Y;y<Y+3;y++) { AutoPlay.cleanSeed(game,X,y); AutoPlay.cleanSeed(game,X+2,y); }
  592. }
  593.  
  594. AutoPlay.harvestable=['bakeberry','chocoroot','whiteChocoroot','queenbeet','queenbeetLump','duketater'];
  595.  
  596. AutoPlay.cleanSeed = function(g,x,y) {
  597.   if(!g.isTileUnlocked(x,y)) return;
  598.   var tile=g.getTile(x,y);
  599.   if (tile[0] == 0) return;
  600.   var plant=g.plantsById[tile[0]-1];
  601.   if ((!plant.unlocked) && (tile[1]<=plant.mature)) return;
  602.   if ((AutoPlay.harvestable.indexOf(plant.key)>=0) && tile[1] && (tile[1]<=plant.mature)) return; // do not clean harvestable plants
  603.   g.harvest(x,y);
  604. }
  605.  
  606. AutoPlay.harvesting = function(game) {
  607.   AutoPlay.cleaningGarden(game);
  608.   AutoPlay.plantPending=false;
  609.   AutoPlay.harvestPlant=false;
  610.   for(var x=0;x<6;x++) for(var y=0;y<6;y++) if(game.isTileUnlocked(x,y)) {
  611.     var tile=game.getTile(x,y);
  612.         if(tile[0]) {
  613.       var plant=game.plantsById[tile[0]-1];
  614.           if(!plant.unlocked) {
  615.             AutoPlay.plantPending=true;
  616.                 AutoPlay.addActivity(plant.name + " is still growing, do not disturb!");
  617.         if (tile[1]>=game.plantsById[tile[0]-1].mature) game.harvest(x,y); // is mature
  618.           } else if(!AutoPlay.plantsMissing && AutoPlay.harvestable.indexOf(plant.key)>=0) {
  619.             AutoPlay.harvestPlant=true;
  620.             AutoPlay.addActivity("Waiting to harvest " + plant.name + ".");
  621.         if (tile[1]>=game.plantsById[tile[0]-1].mature) { // is mature and can give cookies
  622.                   if (AutoPlay.cpsMult>300) game.harvest(x,y); // harvest when it pays a lot
  623.                 }
  624.           }
  625.       if (AutoPlay.plantCookies && tile[1]>=game.plantsById[tile[0]-1].mature) game.harvest(x,y); // is mature and can give cookies
  626.       if (plant.ageTick+plant.ageTickR+tile[1] >= 100) AutoPlay.harvest(game,x,y); // would die in next round
  627.   } }
  628. }
  629.  
  630. AutoPlay.harvest = function(game,x,y) {
  631.   game.harvest(x,y);
  632.   var sector = ((x<3)?1:0)+((y<3)?2:0);
  633.   if(AutoPlay.plantList[sector] == 1) AutoPlay.cleanSector(game,sector,"all");
  634. }
  635.  
  636. AutoPlay.switchSoil = function(sector,which) { // 'dirt','fertilizer','clay','pebbles','woodchips'
  637.   if(sector) return;
  638.   var g=Game.Objects["Farm"].minigame;
  639.   if(g.nextSoil>Date.now()) return;
  640.   var me=g.soils[which];
  641.   if(g.soil==me.id || g.parent.bought<me.req) return;
  642.   FireEvent(l('gardenSoil-'+Game.Objects["Farm"].minigame.soils[which].id),'click');
  643. }
  644.  
  645. AutoPlay.assignSpirit = function(slot, god, force) {
  646.   var g=Game.Objects["Temple"].minigame;
  647.   if(g.swaps+force<3) return;
  648.   if(g.slot[slot]==g.gods[god].id) return;
  649.   g.slotHovered=slot; g.dragging=g.gods[god]; g.dropGod();
  650. }  
  651.  
  652. AutoPlay.removeSpirit = function(slot, god) {
  653.   var g=Game.Objects["Temple"].minigame;
  654.   if(g.slot[slot]!=g.gods[god].id) return;
  655.   g.slotHovered=-1; g.dragging=g.gods[god]; g.dropGod();
  656. }  
  657.  
  658. //===================== Handle Wrinklers ==========================
  659. AutoPlay.nextWrinkler=0;
  660. AutoPlay.wrinklerTime=0;
  661.  
  662. AutoPlay.handleWrinklers = function() {
  663.   if(!Game.Upgrades["One mind"].bought) return;
  664.   var doPop = (((Game.season == "easter") || (Game.season == "halloween")) && !AutoPlay.seasonFinished(Game.season));
  665.   doPop = doPop || (Game.Upgrades["Unholy bait"].bought && !Game.Achievements["Moistburster"].won);
  666.   doPop = doPop || (AutoPlay.endPhase() && !Game.Achievements["Last Chance to See"].won);
  667.   if (doPop) {
  668.         AutoPlay.setDeadline(AutoPlay.now+20000);
  669.     AutoPlay.addActivity("Popping wrinklers for droppings and/or achievements.");
  670.     Game.wrinklers.forEach(function(w) { if (w.close==1) w.hp = 0; } );
  671.   } else if((((AutoPlay.now-Game.startDate) > 10*24*60*60*1000) || AutoPlay.grinding()) && !AutoPlay.endPhase() && !AutoPlay.wantAscend) {
  672.     AutoPlay.addActivity("Popping one wrinkler per 2 hours, last " + (((Date.now()-AutoPlay.wrinklerTime)/1000/60)>>0) + " minutes ago.");
  673.         if(AutoPlay.now-AutoPlay.wrinklerTime >= 2*60*60*1000) {
  674.       var w=Game.wrinklers[AutoPlay.nextWrinkler];
  675.           if (w.close==1) w.hp = 0;
  676.           AutoPlay.wrinklerTime=AutoPlay.now;
  677.           AutoPlay.nextWrinkler=(AutoPlay.nextWrinkler+1)%Game.getWrinklersMax();
  678.         }
  679.   }
  680. }
  681.  
  682. //===================== Handle Small Achievements ==========================
  683. AutoPlay.backupHeight=0;
  684. AutoPlay.handleSmallAchievements = function() {
  685.   if(!Game.Achievements["Tabloid addiction"].won) { for (i = 0; i < 50; i++) { Game.tickerL.click(); } }
  686.   if(!Game.Achievements["Here you go"].won) Game.Achievements["Here you go"].click();
  687.   if(!Game.Achievements["Tiny cookie"].won) Game.ClickTinyCookie();
  688.   var bakeryName = Game.bakeryName;
  689.   if(!Game.Achievements["God complex"].won) { Game.bakeryName = "Orteil"; Game.bakeryNamePrompt(); Game.ConfirmPrompt(); }
  690.   if(!Game.Achievements["What's in a name"].won || Game.bakeryName.slice(0,AutoPlay.robotName.length)!=AutoPlay.robotName) {
  691.     Game.bakeryName = AutoPlay.robotName+bakeryName; Game.bakeryNamePrompt(); Game.ConfirmPrompt();
  692.   }
  693.   if(AutoPlay.endPhase() && !Game.Achievements["Cheated cookies taste awful"].won) Game.Win("Cheated cookies taste awful"); // only take this at the end, after all is done
  694.   if(!Game.Achievements["Third-party"].won) Game.Win("Third-party"); // cookie bot is a third party itself
  695.   if(!Game.Achievements["Cookie-dunker"].won && Game.milkProgress > 1 && Game.milkHd>0.34) {
  696.         if(AutoPlay.backupHeight) { Game.LeftBackground.canvas.height=AutoPlay.backupHeight; AutoPlay.backupHeight=0; }
  697.     else { AutoPlay.backupHeight=Game.LeftBackground.canvas.height; Game.LeftBackground.canvas.height=400; setTimeout(AutoPlay.unDunk, 20*1000); }
  698.   }
  699. }
  700.  
  701. AutoPlay.unDunk = function() {
  702.   if(!Game.Achievements["Cookie-dunker"].won) { setTimeout(AutoPlay.unDunk, 20*1000); return; }
  703.   Game.LeftBackground.canvas.height=AutoPlay.backupHeight; AutoPlay.backupHeight=0;
  704. }
  705.  
  706. //===================== Handle Ascend ==========================
  707. AutoPlay.ascendLimit = 0.9*Math.floor(2*(1-Game.ascendMeterPercent));
  708. AutoPlay.wantAscend=false;
  709.  
  710. AutoPlay.handleAscend = function() {
  711.   if (Game.OnAscend) { AutoPlay.doReincarnate(); AutoPlay.findNextAchievement(); return; }
  712.   if (Game.ascensionMode==1 && !AutoPlay.canContinue()) AutoPlay.doAscend("reborn mode did not work, retry.",0);
  713.   if (AutoPlay.preNightMode() && AutoPlay.Config.NightMode==5) return; //do not ascend right before the night
  714.   // critical, does not work together with nightmode config and switching off nightmode at grinding
  715.   var daysInRun=(Date.now()-Game.startDate)/1000/60/60/24;
  716.   if (AutoPlay.endPhase() && !Game.Achievements["Endless cycle"].won && !Game.ascensionMode && Game.Upgrades["Sucralosia Inutilis"].bought) { // this costs 2 minutes per 2 ascend
  717.     AutoPlay.activities="Going for 1000 ascends.";
  718.         AutoPlay.setDeadline(0);
  719.         AutoPlay.wantAscend=true; //avoid byuing plants
  720.     if ((Game.ascendMeterLevel > 0) && ((AutoPlay.ascendLimit < Game.ascendMeterLevel*Game.ascendMeterPercent) || ((Game.prestige+Game.ascendMeterLevel)%1000==777)))
  721.         { AutoPlay.doAscend("go for 1000 ascends",0); }
  722.   }
  723.   if (Game.Upgrades["Permanent upgrade slot V"].bought && !Game.Achievements["Reincarnation"].won && !Game.ascensionMode) { // this costs 3+2 minute per 2 ascend
  724.     AutoPlay.activities="Going for 100 ascends.";
  725.         AutoPlay.setDeadline(0);
  726.         AutoPlay.wantAscend=true; //avoid byuing plants
  727.     if ((Game.ascendMeterLevel > 0) && ((AutoPlay.ascendLimit < Game.ascendMeterLevel*Game.ascendMeterPercent) ))
  728.         { AutoPlay.doAscend("go for 100 ascends",0); }
  729.   }
  730.   var extraDaysInRun = daysInRun + daysInRun*Game.ascendMeterLevel/(Game.prestige+1000000000);
  731.   if (AutoPlay.grinding() && !AutoPlay.wantAscend) AutoPlay.addActivity("Still " + (40-(extraDaysInRun<<0)) + " days until next hard ascend.");
  732.   if (extraDaysInRun > 40) AutoPlay.doAscend("ascend after " + daysInRun + " days just while waiting for next achievement.",1);
  733.   var newPrestige=(Game.prestige+Game.ascendMeterLevel)%1000000;
  734.   if (AutoPlay.grinding() && !Game.Upgrades["Lucky digit"].bought && Game.ascendMeterLevel>0 && ((Game.prestige+Game.ascendMeterLevel)%10 == 7)) { AutoPlay.doAscend("ascend for lucky digit.",0); }
  735.   if (AutoPlay.grinding() && !Game.Upgrades["Lucky number"].bought && Game.ascendMeterLevel>0 && ((Game.prestige+Game.ascendMeterLevel)%1000 == 777)) { AutoPlay.doAscend("ascend for lucky number.",0); }
  736.   if (AutoPlay.grinding() && !Game.Upgrades["Lucky payout"].bought && (Game.heavenlyChips > 77777777)) {
  737.         AutoPlay.wantAscend=true; //avoid byuing plants
  738.         AutoPlay.setDeadline(0);
  739.     AutoPlay.addActivity("Trying to get Lucky Payout.");
  740.     if (Game.ascendMeterLevel>0 && (newPrestige <= 777777) && (newPrestige+Game.ascendMeterLevel >= 777777))
  741.       AutoPlay.doAscend("ascend for lucky payout.",0);
  742.   }
  743.   if (Game.AchievementsById[AutoPlay.nextAchievement].won) {
  744.         var date=new Date();
  745.         date.setTime(Date.now()-Game.startDate);
  746.         var legacyTime=Game.sayTime(date.getTime()/1000*Game.fps,-1);
  747.         date.setTime(Date.now()-Game.fullDate);
  748.         var fullTime=Game.sayTime(date.getTime()/1000*Game.fps,-1);
  749.     AutoPlay.doAscend("have achievement: " + Game.AchievementsById[AutoPlay.nextAchievement].desc + " after " + legacyTime + "(total: " + fullTime + ")",1);
  750. } }
  751.  
  752. AutoPlay.canContinue = function() {
  753.   if (!Game.Achievements["Neverclick"].won && Game.cookieClicks<=15) { AutoPlay.activities="Trying to get achievement: Neverclick."; return true; }
  754.   if (!Game.Achievements["True Neverclick"].won && Game.cookieClicks==0) { AutoPlay.activities="Trying to get achievement: True Neverclick."; return true; }
  755.   if (!Game.Achievements["Hardcore"].won && Game.UpgradesOwned==0) { AutoPlay.activities="Trying to get achievement: Hardcore."; return true; }
  756.   if (!Game.Achievements["Speed baking I"].won && (Date.now()-Game.startDate <= 1000*60*35)) { AutoPlay.activities="Trying to get achievement: Speed baking I."; return true; }
  757.   if (!Game.Achievements["Speed baking II"].won && (Date.now()-Game.startDate <= 1000*60*25)) { AutoPlay.activities="Trying to get achievement: Speed baking II."; return true; }
  758.   if (!Game.Achievements["Speed baking III"].won && (Date.now()-Game.startDate <= 1000*60*15)) { AutoPlay.activities="Trying to get achievement: Speed baking III."; return true; }
  759.   return false;
  760. }
  761.  
  762. AutoPlay.doReincarnate = function() {
  763.   AutoPlay.delay=10; AutoPlay.buyHeavenlyUpgrades();
  764.   AutoPlay.setDeadline(0);
  765.   if(!Game.Achievements["Neverclick"].won || !Game.Achievements["Hardcore"].won) { Game.PickAscensionMode(); Game.nextAscensionMode=1; Game.ConfirmPrompt(); }
  766.   if(AutoPlay.endPhase() && AutoPlay.mustRebornAscend()) { Game.PickAscensionMode(); Game.nextAscensionMode=1; Game.ConfirmPrompt(); }
  767.   Game.Reincarnate(true);
  768. //  if (AutoPlay.loggingInfo) setTimeout(AutoPlay.logging, 20*1000); - this is for logging after ascend, not before
  769.   AutoPlay.ascendLimit = 0.9*Math.floor(2*(1-Game.ascendMeterPercent));
  770. }
  771.  
  772. AutoPlay.mustRebornAscend = function() { return !([78,93,94,95].every(function(a) { return Game.AchievementsById[a].won; })); }
  773.  
  774. AutoPlay.doAscend = function(str,log) {
  775.   AutoPlay.wantAscend=AutoPlay.plantPending || AutoPlay.harvestPlant;
  776.   AutoPlay.addActivity("Preparing to ascend.");
  777.   if (AutoPlay.wantAscend) return; // do not ascend when we wait for a plant to mature
  778.   if (Game.hasBuff("Sugar frenzy")) return; // do not ascend when sugar frenzy is active
  779. //  for (var i in Game.buffs) { if(Game.buffs[i].time>=0) return; } // do not ascend while we have buffs - does not work well with cheating golden
  780. //  if(AutoPlay.checkAllAchievementsOK(false)) { AutoPlay.logging(); return; } // do not ascend when we are finished
  781.   if(Game.wrinklers.some(function(w) { return w.close; } )) AutoPlay.assignSpirit(0,"scorn",1);
  782.   Game.wrinklers.forEach(function(w) { if (w.close==1) w.hp=0; } ); // pop all wrinklers
  783.   if (Game.isMinigameReady(Game.Objects["Farm"])) Game.Objects["Farm"].minigame.harvestAll(); // harvest garden
  784.   if (Game.Upgrades["Chocolate egg"].unlocked && !Game.Upgrades["Chocolate egg"].bought) {
  785.     if (Game.dragonLevel>=9) { // setting first aura to earth shatterer
  786.       Game.specialTab="dragon"; Game.SetDragonAura(5,0);
  787.       Game.ConfirmPrompt(); Game.ToggleSpecialMenu(0);
  788.         }
  789.         Game.ObjectsById.forEach(function(e) { e.sell(e.amount); } );
  790.     Game.Upgrades["Chocolate egg"].buy();
  791.   } else { AutoPlay.debugInfo(str); AutoPlay.loggingInfo=log?str:0; AutoPlay.logging(); AutoPlay.delay=10; Game.Ascend(true); }
  792. }
  793.  
  794. //===================== Handle Achievements ==========================
  795. AutoPlay.wantedAchievements = [82, 89, 108, 225, 227, 229, 279, 280, 372, 373, 374, 375, 390, 391, 389, 395, 397];
  796. AutoPlay.nextAchievement=AutoPlay.wantedAchievements[0];
  797.  
  798. AutoPlay.endPhase = function() { return AutoPlay.wantedAchievements.indexOf(AutoPlay.nextAchievement)<0; }
  799.  
  800. AutoPlay.grinding = function() { return Game.AchievementsById[373].won /*&& !Game.AchievementsById[391].won*/; }
  801.  
  802. AutoPlay.mainActivity="Doing nothing in particular.";
  803.  
  804. AutoPlay.setMainActivity = function(str) {
  805.   AutoPlay.mainActivity=str;
  806.   AutoPlay.debugInfo(str);
  807. }
  808.  
  809. AutoPlay.findNextAchievement = function() {
  810.   AutoPlay.wantAscend=false;
  811.   AutoPlay.handleSmallAchievements();
  812.   for(i = 0; i < AutoPlay.wantedAchievements.length; i++) {
  813.     if (!(Game.AchievementsById[AutoPlay.wantedAchievements[i]].won)) {
  814.           AutoPlay.nextAchievement = AutoPlay.wantedAchievements[i];
  815.           AutoPlay.setMainActivity("Trying to get achievement: " + Game.AchievementsById[AutoPlay.nextAchievement].desc);
  816.           return;
  817.         }
  818.   }
  819.   AutoPlay.checkAllAchievementsOK(true);
  820. }
  821.  
  822. AutoPlay.checkAllAchievementsOK = function(log) { // could remove the parameter ...
  823.   for (var i in Game.Achievements) {
  824.     var me=Game.Achievements[i];
  825.     if (!me.won && me.pool!="dungeon" && me.id!=367) { // missing achievement, but do not stop for legacy of one year
  826.       if(log) AutoPlay.setMainActivity("Missing achievement #" + me.id + ": " + me.desc + ", try to get it now.");
  827.           if(log) AutoPlay.nextAchievement=me.id;
  828.           return false;
  829.   } }
  830.   for (var i in Game.Upgrades) {
  831.     var me=Game.Upgrades[i];
  832.     if (me.pool=='prestige' && !me.bought) { // we have not all prestige upgrades yet
  833.       if(log) AutoPlay.nextAchievement=AutoPlay.wantedAchievements[AutoPlay.wantedAchievements.length-1];
  834.       if(log) AutoPlay.setMainActivity("Prestige upgrade " + me.name + " is missing, waiting to buy it.");
  835.           if(log) Game.RemoveAchiev(Game.AchievementsById[AutoPlay.nextAchievement].name);
  836.           return false;
  837.   } }
  838.   if(!Game.Achievements["So much to do so much to see"].won) { //wait until the end of the year - achievement 367
  839.     var me=Game.Achievements["So much to do so much to see"];
  840.     if(log) AutoPlay.setMainActivity("Missing achievement #" + me.id + ": " + me.desc + ", try to get it now.");
  841.         if(log) AutoPlay.nextAchievement=me.id;
  842.         return false;
  843.   }
  844.   // finished with playing: idle further
  845.   AutoPlay.finished=true;
  846.   if(log) AutoPlay.setMainActivity("My job is done here, have a nice day. I am still idling along.");
  847.   if(log) AutoPlay.nextAchievement=99; // follow the white rabbit (from dungeons)
  848.   return false;
  849. }
  850.  
  851. AutoPlay.leaveGame = function() {
  852.   clearInterval(AutoPlay.autoPlayer); //stop autoplay:
  853.   AutoPlay.info("My job is done here, have a nice day.");
  854.   if(Game.bakeryName.slice(0,AutoPlay.robotName.length)==AutoPlay.robotName) {
  855.     Game.bakeryName = Game.bakeryName.slice(AutoPlay.robotName.length); Game.bakeryNamePrompt(); Game.ConfirmPrompt();
  856.   }
  857.   return true;
  858. }
  859.  
  860. AutoPlay.findMissingAchievements = function() { // just for testing purposes
  861.   for (var i in Game.Achievements) {
  862.     var me=Game.Achievements[i];
  863.     if (!me.won && me.pool!="dungeon") { // missing achievement
  864.       AutoPlay.debugInfo("missing achievement #" + me.id + ": " + me.desc);
  865.   } }
  866.   for (var i in Game.Upgrades) {
  867.     var me=Game.Upgrades[i];
  868.     if (me.pool=='prestige' && !me.bought) { // we have not all prestige upgrades yet
  869.       AutoPlay.debugInfo("prestige upgrade " + me.name + " is missing.");
  870. } } }
  871.  
  872. //===================== Handle Heavenly Upgrades ==========================
  873. AutoPlay.prioUpgrades = [363,323,411,412,413,264,265,266,267,268,181,282,283,284,291,393,394]; // legacy, dragon, lucky upgrades, permanent slots, season switcher, better golden cookies, kittens, synergies
  874. AutoPlay.kittens = [31,32,54,108,187,320,321,322,425,442,462,494];
  875. AutoPlay.cursors = [0,1,2,3,4,5,6,43,82,109,188,189];
  876. AutoPlay.chancemakers = [416,417,418,419,420,421,422,423,441,493];
  877. AutoPlay.butterBiscuits = [334,335,336,337,400,477,478,479,497];
  878.  
  879. AutoPlay.buyHeavenlyUpgrades = function() {
  880.   AutoPlay.prioUpgrades.forEach(function(id) { var e=Game.UpgradesById[id]; if (e.canBePurchased && !e.bought && e.buy(true)) { AutoPlay.info("buying "+e.name); } });
  881.   Game.UpgradesById.forEach(function(e) { if (e.canBePurchased && !e.bought && e.buy(true)) { AutoPlay.info("buying "+e.name); } });
  882.   AutoPlay.assignPermanentSlot(1,AutoPlay.kittens);
  883.   AutoPlay.assignPermanentSlot(2,AutoPlay.chancemakers);
  884.   if(!Game.Achievements["Reincarnation"].won) { // for many ascends
  885.     AutoPlay.assignPermanentSlot(0,AutoPlay.cursors);
  886.     AutoPlay.assignPermanentSlot(3,[52]); // lucky day
  887.     AutoPlay.assignPermanentSlot(4,[53]); // serendipity
  888.   } else { //collect rare things
  889.     AutoPlay.assignPermanentSlot(0,AutoPlay.butterBiscuits);
  890.     AutoPlay.assignPermanentSlot(3,[226]); // omelette
  891.         if(Game.Achievements["Elder nap"].won && Game.Achievements["Elder slumber"].won && Game.Achievements["Elder calm"].won)
  892.       AutoPlay.assignPermanentSlot(4,[72]); // arcane sugar
  893.         else AutoPlay.assignPermanentSlot(4,[53]); // serendipity
  894.   }
  895. }
  896.  
  897. AutoPlay.assignPermanentSlot = function(slot,options) {
  898.   if (!Game.UpgradesById[264+slot].bought) return;
  899.   Game.AssignPermanentSlot(slot);
  900.   for (var i=options.length-1; i>=0; i--) { if(Game.UpgradesById[options[i]].bought) { Game.PutUpgradeInPermanentSlot(options[i],slot); break; } }
  901.   Game.ConfirmPrompt();
  902. }
  903.  
  904. //===================== Handle Dragon ==========================
  905. AutoPlay.handleDragon = function() {
  906.   if (Game.Upgrades["A crumbly egg"].unlocked) {
  907.     if (Game.dragonLevel<Game.dragonLevels.length-1 && Game.dragonLevels[Game.dragonLevel].cost()) {
  908.       Game.specialTab="dragon"; Game.UpgradeDragon(); Game.ToggleSpecialMenu(0);
  909.   } }
  910.   if ((Game.dragonAura==0) && (Game.dragonLevel>=5)) { // set first aura to kitten (breath of milk)
  911.     Game.specialTab="dragon"; Game.SetDragonAura(1,0);
  912.     Game.ConfirmPrompt(); Game.ToggleSpecialMenu(0);
  913.   }
  914.   if ((Game.dragonAura==1) && (Game.dragonLevel>=19)) { // set first aura to prism (radiant appetite)
  915.     Game.specialTab="dragon"; Game.SetDragonAura(15,0);
  916.     Game.ConfirmPrompt(); Game.ToggleSpecialMenu(0);
  917.   }
  918.   if ((Game.dragonAura2==0) && (Game.dragonLevel>=Game.dragonLevels.length-1)) { // set second aura to kitten (breath of milk)
  919.     Game.specialTab="dragon"; Game.SetDragonAura(1,1);
  920.     Game.ConfirmPrompt(); Game.ToggleSpecialMenu(0);
  921. } }
  922.  
  923. //===================== Menu ==========================
  924. //somehow the toggle off goes away after some short period.
  925.  
  926. if(!AutoPlay.Backup) AutoPlay.Backup = {};
  927. AutoPlay.Config = {};
  928. AutoPlay.ConfigData = {};
  929. AutoPlay.Disp = {};
  930.  
  931. AutoPlay.ConfigPrefix = 'autoplayConfig';
  932.  
  933. AutoPlay.SaveConfig = function(config) {
  934.         localStorage.setItem(AutoPlay.ConfigPrefix, JSON.stringify(config));
  935. }
  936.  
  937. AutoPlay.LoadConfig = function() {
  938.         if (localStorage.getItem(AutoPlay.ConfigPrefix) != null) {
  939.                 AutoPlay.Config = JSON.parse(localStorage.getItem(AutoPlay.ConfigPrefix));
  940.  
  941.                 // Check values
  942.                 var mod = false;
  943.                 for (var i in AutoPlay.ConfigDefault) {
  944.                         if (typeof AutoPlay.Config[i] === 'undefined' || AutoPlay.Config[i] < 0 || AutoPlay.Config[i] >= AutoPlay.ConfigData[i].label.length) {
  945.                                 mod = true;
  946.                                 AutoPlay.Config[i] = AutoPlay.ConfigDefault[i];
  947.                         }
  948.                 }
  949.                 if (mod) AutoPlay.SaveConfig(AutoPlay.Config);
  950.         }
  951.         else { // Default values
  952.                 AutoPlay.RestoreDefault();
  953.         }
  954. }
  955.  
  956. AutoPlay.RestoreDefault = function() {
  957.         AutoPlay.Config = {};
  958.         AutoPlay.SaveConfig(AutoPlay.ConfigDefault);
  959.         AutoPlay.LoadConfig();
  960.         Game.UpdateMenu();
  961. }
  962.  
  963. AutoPlay.ToggleConfig = function(config) {
  964.         AutoPlay.ToggleConfigUp(config);
  965.         if (AutoPlay.Config[config] == 0) {
  966.                 l(AutoPlay.ConfigPrefix + config).className = 'option off';
  967.         }
  968.         else {
  969.                 l(AutoPlay.ConfigPrefix + config).className = 'option';
  970.         }
  971. }
  972.  
  973. AutoPlay.WaitConfig = function(config) {
  974. }
  975.  
  976. AutoPlay.ToggleConfigUp = function(config) {
  977.         AutoPlay.Config[config]++;
  978.         if (AutoPlay.Config[config] == AutoPlay.ConfigData[config].label.length) {
  979.                 AutoPlay.Config[config] = 0;
  980.         }
  981.         l(AutoPlay.ConfigPrefix + config).innerHTML = AutoPlay.Disp.GetConfigDisplay(config);
  982.         AutoPlay.SaveConfig(AutoPlay.Config);
  983. }
  984.  
  985. AutoPlay.ConfigData.NightMode = {label: ['OFF', 'AUTO', 'ON'], desc: 'Handling of night mode'};
  986. AutoPlay.ConfigData.ClickMode = {label: ['OFF', 'AUTO', 'LIGHT SPEED', 'RIDICULOUS SPEED', 'LUDICROUS SPEED'], desc: 'Clicking speed'};
  987. AutoPlay.ConfigData.GoldenClickMode = {label: ['OFF', 'AUTO', 'ALL'], desc: 'Golden Cookie clicking mode'};
  988. AutoPlay.ConfigData.CheatLumps = {label: ['OFF', 'AUTO', 'LITTLE', 'MEDIUM', 'MUCH'], desc: 'Cheating of sugar lumps'};
  989. AutoPlay.ConfigData.CheatGolden = {label: ['OFF', 'AUTO', 'LITTLE', 'MEDIUM', 'MUCH'], desc: 'Cheating of golden cookies'};
  990. AutoPlay.ConfigData.CleanLog = {label: ['Clean Log'], desc: 'Cleaning the log'};
  991. AutoPlay.ConfigData.ShowLog = {label: ['Show Log'], desc: 'Showing the log'};
  992.  
  993. AutoPlay.ConfigDefault = {NightMode: 1, ClickMode: 1, GoldenClickMode: 1, CheatLumps: 1, CheatGolden: 1, CleanLog: 0, ShowLog: 0}; // default
  994.  
  995. AutoPlay.LoadConfig();
  996.  
  997. AutoPlay.Disp.GetConfigDisplay = function(config) {
  998.         return AutoPlay.ConfigData[config].label[AutoPlay.Config[config]];
  999. }
  1000.  
  1001. AutoPlay.Disp.AddMenuPref = function() {
  1002.         var header = function(text) {
  1003.                 var div = document.createElement('div');
  1004.                 div.className = 'listing';
  1005.                 div.style.padding = '5px 16px';
  1006.                 div.style.opacity = '0.7';
  1007.                 div.style.fontSize = '17px';
  1008.                 div.style.fontFamily = '\"Kavoon\", Georgia, serif';
  1009.                 div.textContent = text;
  1010.                 return div;
  1011.         }
  1012.  
  1013.         var frag = document.createDocumentFragment();
  1014.  
  1015.         var div = document.createElement('div');
  1016.         div.className = 'title ' + AutoPlay.Disp.colorTextPre + AutoPlay.Disp.colorBlue;
  1017.         div.textContent = 'Cookiebot Options';
  1018.        
  1019.         frag.appendChild(div);
  1020.  
  1021.         var listing = function(config,clickFunc) {
  1022.                 var div = document.createElement('div');
  1023.                 div.className = 'listing';
  1024.                 var a = document.createElement('a');
  1025.                 a.className = 'option';
  1026.                 if (AutoPlay.ConfigData[config].toggle && AutoPlay.Config[config] == 0) a.className = 'option off';
  1027.                 a.id = AutoPlay.ConfigPrefix + config;
  1028.                 a.onclick = function() { AutoPlay.ToggleConfig(config); };
  1029.                 if(clickFunc) a.onclick = clickFunc;
  1030.                 a.textContent = AutoPlay.Disp.GetConfigDisplay(config);
  1031.                 div.appendChild(a);
  1032.                 var label = document.createElement('label');
  1033.                 label.textContent = AutoPlay.ConfigData[config].desc;
  1034.                 div.appendChild(label);
  1035.                 return div;
  1036.         }
  1037.  
  1038.         frag.appendChild(listing('NightMode',null));
  1039.         frag.appendChild(listing('ClickMode',null));
  1040.         frag.appendChild(listing('GoldenClickMode',null));
  1041.         frag.appendChild(header('Cheating'));
  1042.         frag.appendChild(listing('CheatLumps',null));
  1043.         frag.appendChild(listing('CheatGolden',null));
  1044.         frag.appendChild(header('Logging'));
  1045.         frag.appendChild(listing('CleanLog',AutoPlay.cleanLog));
  1046.         frag.appendChild(listing('ShowLog',AutoPlay.showLog));
  1047.  
  1048.         l('menu').childNodes[2].insertBefore(frag, l('menu').childNodes[2].childNodes[l('menu').childNodes[2].childNodes.length - 1]);
  1049. }
  1050.  
  1051. if(!AutoPlay.Backup.UpdateMenu) { console.log("new update menu"); AutoPlay.Backup.UpdateMenu = Game.UpdateMenu; }
  1052.  
  1053. Game.UpdateMenu = function() {
  1054.         AutoPlay.Backup.UpdateMenu();
  1055.         if (Game.onMenu == 'prefs') {
  1056.                 AutoPlay.Disp.AddMenuPref();
  1057.         }
  1058. }
  1059.  
  1060. //===================== Auxiliary ==========================
  1061.  
  1062. AutoPlay.info = function(s) { console.log("### "+s); Game.Notify("Automatic Playthrough",s,1,100); }
  1063. AutoPlay.debugInfo = function(s) { console.log("======> "+s); Game.Notify("Debugging CookieBot",s,1,20); }
  1064.  
  1065. AutoPlay.setDeadline = function(d) { if (AutoPlay.deadline>d) AutoPlay.deadline=d; }
  1066.  
  1067. AutoPlay.logging = function() {
  1068.   var before=window.localStorage.getItem("autoplayLog");
  1069.   var toAdd="#logging autoplay V" + AutoPlay.version + " with " + AutoPlay.loggingInfo + "\n" + Game.WriteSave(1) + "\n";
  1070.   AutoPlay.loggingInfo=0;
  1071.   window.localStorage.setItem("autoplayLog",before+toAdd);
  1072. }
  1073.  
  1074. AutoPlay.cleanLog = function() {
  1075.   window.localStorage.setItem("autoplayLog","");
  1076. }
  1077.  
  1078. AutoPlay.showLog = function() {
  1079.   Game.Prompt('<h3>Cookie Bot Log</h3><div class="block">This is the log of the bot with saves at important stages.<br>Copy it and use it as you like.</div><div class="block"><textarea id="textareaPrompt" style="width:100%;height:128px;" readonly>'+window.localStorage.getItem("autoplayLog")+'</textarea></div>',['All done!']);
  1080. }
  1081.  
  1082. AutoPlay.handleNotes = function() {
  1083.   for (var i in Game.Notes) {
  1084.     if (Game.Notes[i].quick==0) { Game.Notes[i].life=2000*Game.fps; Game.Notes[i].quick=1; }
  1085. } }
  1086.  
  1087. function range(start, end) {
  1088.   var foo = [];
  1089.   for (var i = start; i <= end; i++) { foo.push(i); }
  1090.   return foo;
  1091. }
  1092.  
  1093. AutoPlay.whatTheBotIsDoing = function() {
  1094.   return '<div style="padding:8px;width:400px;font-size:11px;text-align:center;">'+
  1095.     '<span style="color:#6f6;font-size:18px"> What is the bot doing?</span>'+
  1096.     '<div class="line"></div>'+
  1097.     AutoPlay.activities+
  1098.         '</div>';
  1099. }
  1100.  
  1101. AutoPlay.addActivity = function(str) {
  1102.   if(!AutoPlay.activities.includes(str)) AutoPlay.activities+= '<div class="line"></div>'+str;
  1103. }
  1104.  
  1105. //===================== Init & Start ==========================
  1106.  
  1107. if (AutoPlay.autoPlayer) { AutoPlay.info("replacing old version of autoplay"); clearInterval(AutoPlay.autoPlayer); }
  1108. //AutoPlay.autoPlayer = setInterval(AutoPlay.run, 300); // was 100 before, but that is too quick
  1109. AutoPlay.autoPlayer = setInterval(AutoPlay.run, 300); // was 100 before, but that is too quick
  1110. AutoPlay.findNextAchievement();
  1111. l('versionNumber').innerHTML='v. '+Game.version+" (with Cookiebot v."+AutoPlay.version+")";
  1112. l('versionNumber').innerHTML='v. '+Game.version+' <span '+Game.getDynamicTooltip('AutoPlay.whatTheBotIsDoing','this')+">(with Cookiebot v."+AutoPlay.version+")"+'</span>';
  1113. if (Game.version != AutoPlay.gameVersion) AutoPlay.info("Warning: cookieBot is last tested with cookie clicker version " + AutoPlay.gameVersion);

OCJC Pastebin is a general-purpose paste service.

Login or Register to edit, delete and keep track of your pastes and more.

Raw Paste
',['All done!']); } AutoPlay.handleNotes = function() { for (var i in Game.Notes) { if (Game.Notes[i].quick==0) { Game.Notes[i].life=2000*Game.fps; Game.Notes[i].quick=1; } } } function range(start, end) { var foo = []; for (var i = start; i <= end; i++) { foo.push(i); } return foo; } AutoPlay.whatTheBotIsDoing = function() { return '
'+ ' What is the bot doing?'+ '
'+ AutoPlay.activities+ '
'; } AutoPlay.addActivity = function(str) { if(!AutoPlay.activities.includes(str)) AutoPlay.activities+= '
'+str; } //===================== Init & Start ========================== if (AutoPlay.autoPlayer) { AutoPlay.info("replacing old version of autoplay"); clearInterval(AutoPlay.autoPlayer); } //AutoPlay.autoPlayer = setInterval(AutoPlay.run, 300); // was 100 before, but that is too quick AutoPlay.autoPlayer = setInterval(AutoPlay.run, 300); // was 100 before, but that is too quick AutoPlay.findNextAchievement(); l('versionNumber').innerHTML='v. '+Game.version+" (with Cookiebot v."+AutoPlay.version+")"; l('versionNumber').innerHTML='v. '+Game.version+' (with Cookiebot v."+AutoPlay.version+")"+''; if (Game.version != AutoPlay.gameVersion) AutoPlay.info("Warning: cookieBot is last tested with cookie clicker version " + AutoPlay.gameVersion);

Login or Register to edit or fork this paste. It's free.