graou13

Pure Cookie B_1.0

Oct 10th, 2013
449
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. /* Cheat Interface Beta 1.0 by Graou13 */
  2.  
  3. //draw buttons
  4.  
  5. var CheatButton = document.createElement("div");
  6. var hidden = true;
  7. var oldNode = l("links").firstChild;
  8. var newNode = document.createElement("span");
  9. var t = document.createTextNode("Cheat");
  10. CheatButton.setAttribute("id", "cheatButton");
  11. CheatButton.setAttribute("class", "button");
  12. CheatButton.setAttribute("onMouseOver", "this.style.right=\"-8px\"");
  13. CheatButton.setAttribute("onMouseOut", "this.style.right=\"-16px\"");
  14. CheatButton.style.padding = "14px 16px 10px 0px";
  15. CheatButton.style.top = "0px";
  16. CheatButton.style.right = "-16px";
  17. CheatButton.appendChild(t);
  18. l("comments").insertBefore(CheatButton, l("logButton"));
  19. l('cheatButton').onclick = function () {
  20.     Game.ShowMenu('cheat');
  21. };
  22. newNode.setAttribute("id", "newNode");
  23. newNode.innerHTML = '<a class="option" style="height:16px" id="autoupdate" onclick="Game.Toggle(\'autoupdate\',\'autoupdate\',\'autoupdate:on\',\'autoupdate:off\')">' + (Game.prefs.autoupdate ? 'autoupdate:on' : 'autoupdate:off') + '</a> | <a class="option" style="height:16px" id="antilag" onclick="Game.Toggle(\'antilag\',\'antilag\',\'antilag:on\',\'antilag:off\')">' + (Game.prefs.antilag ? 'antilag:on' : 'antilag:off') + '</a> | <a class="option" style="height:16px" id="autosave" onclick="Game.Toggle(\'autosave\',\'autosave\',\'autosave:on\',\'autosave:off\')">' + (Game.prefs.autosave ? 'autosave:on' : 'autosave:off') + '</a> | ';
  24. l("links").insertBefore(newNode, oldNode);
  25. document.addEventListener('keydown', function (event) {
  26.     if (event.keyCode == 80) {
  27.         if (hidden) {
  28.             l("cheatButton").setAttribute("hidden", "true");
  29.             Game.ShowMenu(Game.onMenu);
  30.             Game.prefs.buybot = 0;
  31.             clearInterval(buyBot);
  32.             BuyBot = 0;
  33.             Game.prefs.autoclick = 0;
  34.             clearInterval(clickerBotC);
  35.             clickerBotC = 0;
  36.             Game.prefs.autogolden = 0;
  37.             clearInterval(clickerBotG);
  38.             clickerBotG = 0;
  39.         } else {
  40.             l("cheatButton").removeAttribute("hidden");
  41.         }
  42.         hidden = !hidden;
  43.     }
  44. });
  45.  
  46. //variables
  47.  
  48. var clickerBotC = 0;
  49. var clickerBotG = 0;
  50. var buyBot = 0;
  51. var pledgeBot = 0;
  52. var CAmount = 0;
  53. var HAmount = 0;
  54. var BAmount = 0;
  55. var CClickSpeed = 5;
  56. var GClickSpeed = 5;
  57. var MFix = false;
  58. var HFix = false;
  59. var BFree = false;
  60. var bypass = false;
  61. var goldenChoice = 'any';
  62. var buildingChoice = 'all';
  63. var Flast = 1;
  64. var Fpow = 1;
  65. var SHours = 0;
  66. var MilkLvl = 0;
  67. var displayUpgradeHack = '';
  68. var displayAchievementHack = '';
  69. var ABCps;
  70. var ABName;
  71. var ABPrice;
  72. var ABText = '';
  73. var ABInterval = 250;
  74. var ABCurrentCps;
  75. var ABSelected = 0;
  76. var ABOptimal;
  77. var PTime = 0;
  78. var focused = false;
  79. Game.prefs.antilag = 1;
  80. Game.prefs.autoupdate = 1;
  81. var intRegex = /^\d+$/;
  82.  
  83. //cheat menu
  84.  
  85. Game.oldUpdateMenu = Game.UpdateMenu;
  86. Game.UpdateMenu = function () {
  87.     var str = '';
  88.     if (Game.onMenu != 'cheat') {
  89.         return Game.oldUpdateMenu();
  90.     }
  91.     if (Game.onMenu !== '') {
  92.         str += '<div style="position:absolute;top:8px;right:8px;cursor:pointer;font-size:16px;" onclick="Game.ShowMenu(Game.onMenu);">X</div>';
  93.     }
  94.     if (Game.onMenu == 'cheat') {
  95.         str += '<div class="section">Cheat</div>' +
  96.             '<div class="subsection">' +
  97.             '<div class="title">Give cookies</div>' +
  98.             '<form>' +
  99.             '<div class="listing"><b>how many:</b> <input id="CAmount" type="number" name="CAmount" value="' + CAmount + '" step="1" min="0" onfocus="focused = true;" onblur="focused = false;"><input id="MFix" type="checkbox" name="MFix" value="MFix" onfocus="focused = true;" onblur="focused = false;"><b>fixed </b><a class="option" onclick="GetCookies();">Get cookies</a><br></div>' +
  100.             '</form></div>' +
  101.             '<div class="subsection">' +
  102.             '<div class="title">Auto-click big cookie</div>' +
  103.             '<form>' +
  104.             '<div class="listing"><b>interval:</b> <input id="CClickSpeed" type="range" value="' + CClickSpeed + '" min="5" max="1000" name="CClickSpeed" onchange=l("displayCClickSpeed").innerHTML=l("CClickSpeed").value step="5" style="width:250px" onfocus="focused = true;" onblur="focused = false;"> <b><span id="displayCClickSpeed">' + CClickSpeed + '</span>ms</b> ' + Game.WriteButton('autoclick', 'autoClick', 'AutoClick ON', 'AutoClick OFF', 'ClickCookie();') + '<br></div>' +
  105.             '</form></div>' +
  106.             '<div class="subsection">' +
  107.             '<div class="title">Auto-click golden cookies</div>' +
  108.             '<form>' +
  109.             '<div class="listing"><input id="bypass" type="checkbox" name="bypass" value="bypass" onfocus="focused = true;" onblur="focused = false;"><b>bypass time; interval:</b> <input id="GClickSpeed" type="range" value="' + GClickSpeed + '" min="5" max="1000" name="GClickSpeed" onchange=l("displayGClickSpeed").innerHTML=l("GClickSpeed").value step="5" style="width:250px" onfocus="focused = true;" onblur="focused = false;"> <b><span id="displayGClickSpeed">' + GClickSpeed + '</span>ms</b>' + Game.WriteButton('autogolden', 'autoGolden', 'AutoGolden: ON', 'AutoGolden: OFF', 'ClickGolden();') + '<br></div>' +
  110.             '</form></div>' +
  111.             '<div class="subsection">' +
  112.             '<div class="title">Spawn a golden cookie</div>' +
  113.             '<form>' +
  114.             '<div class="listing"><select name="goldenChoice" id="goldenChoice" value="' + goldenChoice + '" onfocus="focused = true;" onblur="focused = false;"><option value="any" id="SelectedChoice_any">Any</option><option value="clot" id="SelectedChoice_clot">Clot</option><option value="multiply cookies" id="SelectedChoice_multiply cookies">Lucky</option><option value="ruin cookies" id="SelectedChoice_ruin cookies">Ruin</option><option value="frenzy" id="SelectedChoice_frenzy">Frenzy</option><option value="blood frenzy" id="SelectedChoice_blood frenzy">Elder Frenzy</option><option value="chain cookie" id="SelectedChoice_chain cookie">Chain Cookie</option><option value="click frenzy" id="SelectedChoice_click frenzy">Click Frenzy</option></select><a class="option" onclick="SpawnGolden();">Spawn a golden cookie</a><br></div>' +
  115.             '</form></div>' +
  116.             '<div class="subsection">' +
  117.             '<div class="title">Create a frenzy</div>' +
  118.             '<form>' +
  119.             '<div class="listing"><b>Last </b><input id="Flast" type="number" name="Flast" value="' + Flast + '" step="1" Style="width:50px" min="1" onfocus="focused = true;" onblur="focused = false;"><b> seconds; multiply by </b><input id="Fpow" type="number" name="Fpow" value="' + Fpow + '" step="1" Style="width:100px" min="1" onfocus="focused = true;" onblur="focused = false;"><a class="option" onclick="SpawnFrenzy();">Spawn the custom frenzy</a><br></div>' +
  120.             '</form></div>' +
  121.             '<div class="subsection">' +
  122.             '<div class="title">Change the game started value</div>' +
  123.             '<form>' +
  124.             '<div class="listing"><b>Game started </b><input id="SHours" type="number" name="SHours" value="' + SHours + '" step="1" min="0" onfocus="focused = true;" onblur="focused = false;"><b> hours ago </b><a class="option" onclick="SetStartDate();">Set the time</a><br></div>' +
  125.             '</form></div>' +
  126.             '<div class="subsection">' +
  127.             '<div class="title">Get Heavenly Chips</div>' +
  128.             '<form>' +
  129.             '<div class="listing"><b>Amount of H.C: </b><input id="HAmount" type="number" name="HAmount" value="' + HAmount + '" step="1" min="0" onfocus="focused = true;" onblur="focused = false;"><input id="HFix" type="checkbox" name="HFix" value="HFix" onfocus="focused = true;" onblur="focused = false;"><b>fixed </b><a class="option" onclick="GetHeavenly();">Get Heavenly Chips</a></div>' +
  130.             '</form><br></div>' +
  131.             '<div class="subsection">' +
  132.             '<div class="title">Set Milk level</div>' +
  133.             '<form>' +
  134.             '<div class="listing"><b>set Milk level: </b><input id="MilkLvl" type="number" name="MilkLvl" value="' + MilkLvl + '" step="1" Style="width:100px" min="0" onfocus="focused = true;" onblur="focused = false;"><b> % </b><a class="option" onclick="SetMilk();">Set Milk</a><br></div>' +
  135.             '</form></div>' +
  136.             '<div class="subsection">' +
  137.             '<div class="title">Hack upgrades</div>' +
  138.             '<form>' +
  139.             '<div class="listing">' + Game.WriteButton('upgradehack', 'upgradeHack', 'Hack upgrades: ON', 'Hack upgrades: OFF', 'UpgradeHack();') + '<a class="option" onclick="AllUpgrades();">Toggle all upgrades</a>' +
  140.             '<br><div id="displayUpgradeHack" style="overflow-y:hidden;">' + displayUpgradeHack + '</div><br></div>' +
  141.             '</form></div>' +
  142.             '<div class="subsection">' +
  143.             '<div class="title">Hack achievements</div>' +
  144.             '<form>' +
  145.             '<div class="listing">' + Game.WriteButton('achievementhack', 'achievementHack', 'Hack achievements: ON', 'Hack achievements: OFF', 'AchievementHack();') + '<a class="option" onclick="AllAchievements();">Toggle all achievements</a>' +
  146.             '<br><div id="displayAchievementHack" style="overflow-y:hidden;">' + displayAchievementHack + '</div><br></div>' +
  147.             '</form></div>' +
  148.             '<div class="subsection">' +
  149.             '<div class="title">Autobuy</div>' +
  150.             '<form>' +
  151.             '<div class="listing">' + Game.WriteButton('autobuy', 'autoBuy', 'Autobuy: ON', 'Autobuy: OFF', 'AutoBuy();') +
  152.             '<br><div id="displayAutoBuyText">' + ABText + '</div><br></div>' +
  153.             '</form></div>' +
  154.             '<div class="subsection">' +
  155.             '<div class="title">Hack buildings</div>' +
  156.             '<form>' +
  157.             '<div class="listing"><select name="buildingChoice" id="buildingChoice" value="' + buildingChoice + '" onfocus="focused = true;" onblur="focused = false;">' + SelectBuilding() + '</select><b>Amount of building: </b><input id="BAmount" type="number" name="BAmount" value="' + BAmount + '" step="1" min="0" onfocus="focused = true;" onblur="focused = false;"><input id="BFree" type="checkbox" name="BFree" value="BFree" onfocus="focused = true;" onblur="focused = false;"><b>set price to 0 </b><a class="option" onclick="GetBuilding();">Hack buildings</a><br></div>' +
  158.             '</form></div>' +
  159.             '<div class="subsection">' +
  160.             '<div class="title">Instant research</div>' +
  161.             '<form>' +
  162.             '<div class="listing">' + Game.WriteButton('instantsearch', 'instantSearch', 'Instant search: ON', 'Instant search: OFF', 'InstantSearch();') +
  163.             '</form></div>' +
  164.             '<div class="subsection">' +
  165.             '<div class="title">Custom pledges</div>' +
  166.             '<form>' +
  167.             '<div class="listing"><b>how many minutes:</b> <input id="PTime" type="number" name="PTime" value="' + PTime + '" step="1" min="0" onfocus="focused = true;" onblur="focused = false;">' + Game.WriteButton('autobuypledge', 'autoBuyPledge', 'Autobuy Pledge: ON', 'Autobuy Pledge: OFF', 'ABPledge();') + '<a class="option" onclick="CustomPledge();">Custom Pledge</a><br></div>' +
  168.             '</form></div>';
  169.     }
  170.     l("menu").innerHTML = str;
  171.     l("MFix").checked = MFix;
  172.     l("HFix").checked = HFix;
  173.     l("BFree").checked = BFree;
  174.     l("bypass").checked = bypass;
  175.     l("SelectedChoice_" + goldenChoice).setAttribute("selected", "true");
  176.     l("SelectedChoice_" + buildingChoice).setAttribute("selected", "true");
  177. };
  178.  
  179. //modified original code
  180.  
  181. Game.Draw = function () {
  182.     Game.DrawBackground();
  183.     if (Game.prefs.particles) {
  184.         var r = ((-Game.T * 0.05) % 360);
  185.         var me = l('cookieCursors');
  186.         me.style.transform = 'rotate(' + r + 'deg)';
  187.         me.style.mozTransform = 'rotate(' + r + 'deg)';
  188.         me.style.webkitTransform = 'rotate(' + r + 'deg)';
  189.         me.style.msTransform = 'rotate(' + r + 'deg)';
  190.         me.style.oTransform = 'rotate(' + r + 'deg)';
  191.     }
  192.     var unit = (Math.round(Game.cookiesd) == 1 ? ' cookie' : ' cookies');
  193.     if (Math.round(Game.cookiesd).toString().length > 11) unit = '<br>cookies';
  194.     l('cookies').innerHTML = Beautify(Math.round(Game.cookiesd)) + unit + '<div style="font-size:50%;">per second : ' + Beautify(Game.cookiesPs, 1) + '</div>';
  195.     Game.TickerDraw();
  196.     for (var i in Game.Objects) {
  197.         var me = Game.Objects[i];
  198.         if (Game.cookies >= me.price) l('product' + me.id).className = 'product enabled';
  199.         else l('product' + me.id).className = 'product disabled';
  200.         if (l('rowInfo' + me.id) && Game.T % 5 === 0) l('rowInfoContent' + me.id).innerHTML = '&bull; ' + me.amount + ' ' + (me.amount == 1 ? me.single : me.plural) + '<br>&bull; producing ' + Beautify(me.storedTotalCps, 1) + ' ' + (me.storedTotalCps == 1 ? 'cookie' : 'cookies') + ' per second<br>&bull; total : ' + Beautify(me.totalCookies) + ' ' + (Math.floor(me.totalCookies) == 1 ? 'cookie' : 'cookies') + ' ' + me.actionName;
  201.     }
  202.     for (var i in Game.UpgradesInStore) {
  203.         var me = Game.UpgradesInStore[i];
  204.         if (Game.cookies >= me.basePrice) l('upgrade' + i).className = 'crate upgrade enabled';
  205.         else l('upgrade' + i).className = 'crate upgrade disabled';
  206.     }
  207.     if (Math.floor(Game.T % Game.fps / 2) === 0 && Game.onMenu != 'cheat' && Game.prefs.autoupdate) Game.UpdateMenu();
  208.     else if (Math.floor(Game.T % Game.fps / 2) === 0 && Game.onMenu == 'cheat' && !focused && Game.prefs.autoupdate) SmartUpdateMenu();
  209.     Game.cookieNumbersUpdate();
  210.     Game.particlesUpdate();
  211.     Game.drawT++;
  212. };
  213.  
  214. Game.goldenCookie.choose = function () {
  215.     if (goldenChoice == 'any') {
  216.         var list = [];
  217.         if (Game.goldenCookie.wrath > 0) list.push('clot', 'multiply cookies', 'ruin cookies');
  218.         else list.push('frenzy', 'multiply cookies');
  219.         if (Game.goldenCookie.wrath > 0 && Math.random() < 0.3) list.push('blood frenzy', 'chain cookie');
  220.         else if (Math.random() < 0.01 && Game.cookiesEarned >= 100000) list.push('chain cookie');
  221.         if (Math.random() < 0.05) list.push('click frenzy');
  222.         if (Game.goldenCookie.last !== '' && Math.random() < 0.8 && list.indexOf(Game.goldenCookie.last) != -1) list.splice(list.indexOf(Game.goldenCookie.last), 1);
  223.         var choice = choose(list);
  224.         return choice;
  225.     } else if (goldenChoice != 'any') {
  226.         return goldenChoice;
  227.     }
  228. };
  229.  
  230. Game.Loop = function () {
  231.     Game.catchupLogic = 0;
  232.     Game.Logic();
  233.     Game.catchupLogic = 1;
  234.     Game.accumulatedDelay += ((new Date().getTime() - Game.time) - 1000 / Game.fps);
  235.     Game.accumulatedDelay = Math.min(Game.accumulatedDelay, 1000 * 5);
  236.     Game.time = new Date().getTime();
  237.     while (Game.accumulatedDelay > 0) {
  238.         if (clickerBotG !== 0 && Game.prefs.antilag && Game.accumulatedDelay > 500) {
  239.             Game.Toggle('autoclick', 'autoClick', 'AutoClick ON', 'AutoClick OFF');
  240.         }
  241.         if (clickerBotC !== 0 && Game.prefs.antilag && Game.accumulatedDelay > 500) {
  242.             Game.Toggle('autogolden', 'autoGolden', 'AutoGolden: ON', 'AutoGolden: OFF');
  243.         }
  244.         if (buyBot !== 0 && Game.prefs.antilag && Game.accumulatedDelay > 500) {
  245.             Game.Toggle('autobuy', 'autoBuy', 'Autobuy: ON', 'Autobuy: OFF');
  246.         }
  247.         Game.Logic();
  248.         Game.accumulatedDelay -= 1000 / Game.fps;
  249.     }
  250.     Game.catchupLogic = 0;
  251.     Game.Draw();
  252.     setTimeout(Game.Loop, 1000 / Game.fps);
  253. };
  254.  
  255. Game.Win = function (what) {
  256.     if (typeof what === 'string') {
  257.         if (Game.Achievements[what]) {
  258.             if (Game.Achievements[what].won === 0) {
  259.                 Game.Achievements[what].won = 1;
  260.                 Game.Popup('Achievement unlocked :<br>' + Game.Achievements[what].name + '<br> ');
  261.                 if (Game.Achievements[what].hide != 3) {
  262.                     Game.AchievementsOwned++;
  263.                 }
  264.                 Game.recalculateGains = 1;
  265.                 if (displayAchievementHack !== '') {
  266.                     AchievementHack();
  267.                 }
  268.             }
  269.         }
  270.     } else {
  271.         for (var i in what) {
  272.             Game.Win(what[i]);
  273.         }
  274.     }
  275. };
  276.  
  277. //functions
  278.  
  279. function SmartUpdateMenu() {
  280.     if (intRegex.test(parseInt(l("CAmount").value, 10))) {
  281.         CAmount = parseInt(l("CAmount").value, 10);
  282.     }
  283.     if (intRegex.test(parseInt(l("HAmount").value, 10))) {
  284.         HAmount = parseInt(l("HAmount").value, 10);
  285.     }
  286.     if (intRegex.test(parseInt(l("BAmount").value, 10))) {
  287.         BAmount = parseInt(l("BAmount").value, 10);
  288.     }
  289.     if (intRegex.test(parseInt(l("PTime").value, 10))) {
  290.         PTime = parseInt(l("PTime").value, 10);
  291.     }
  292.     if (intRegex.test(parseInt(l("Fpow").value, 10))) {
  293.         Fpow = parseInt(l("Fpow").value, 10);
  294.     }
  295.     if (intRegex.test(parseInt(l("Flast").value, 10))) {
  296.         Flast = parseInt(l("Flast").value, 10);
  297.     }
  298.     if (intRegex.test(parseInt(l("SHours").value, 10))) {
  299.         SHours = parseInt(l("SHours").value, 10);
  300.     }
  301.     if (intRegex.test(parseInt(l("CClickSpeed").value, 10))) {
  302.         CClickSpeed = parseInt(l("CClickSpeed").value, 10);
  303.     }
  304.     if (intRegex.test(parseInt(l("GClickSpeed").value, 10))) {
  305.         GClickSpeed = parseInt(l("GClickSpeed").value, 10);
  306.     }
  307.     if (intRegex.test(parseInt(l("MilkLvl").value, 10))) {
  308.         MilkLvl = parseInt(l("MilkLvl").value, 10);
  309.     }
  310.     MFix = l("MFix").checked;
  311.     HFix = l("HFix").checked;
  312.     BFree = l("BFree").checked;
  313.     bypass = l("bypass").checked;
  314.     goldenChoice = l("goldenChoice").value;
  315.     buildingChoice = l("buildingChoice").value;
  316.     Game.UpdateMenu();
  317. }
  318.  
  319. function GetCookies() {
  320.     SmartUpdateMenu();
  321.     var toMoney = Math.abs(CAmount - Game.cookies);
  322.     if (CAmount < Game.cookies && MFix) {
  323.         Game.Spend(toMoney);
  324.     } else if (CAmount > Game.cookies && MFix) {
  325.         Game.Earn(toMoney);
  326.     } else if (!MFix) {
  327.         Game.Earn(CAmount);
  328.     }
  329. }
  330.  
  331. function ClickCookie() {
  332.     SmartUpdateMenu();
  333.     var choice = Game.prefs.autoclick;
  334.     if (choice && clickerBotC === 0) {
  335.         clickerBotC = setInterval(function () {
  336.             Game.ClickCookie();
  337.         }, CClickSpeed);
  338.     } else if (!choice) {
  339.         clearInterval(clickerBotC);
  340.         clickerBotC = 0;
  341.     }
  342. }
  343.  
  344. function ClickGolden() {
  345.     SmartUpdateMenu();
  346.     var choice = Game.prefs.autogolden;
  347.     if (choice) {
  348.         if (bypass && clickerBotG === 0) {
  349.             clickerBotG = setInterval(function () {
  350.                 Game.goldenCookie.life = 1;
  351.                 Game.goldenCookie.click();
  352.             }, GClickSpeed);
  353.         } else if (!bypass) {
  354.             clickerBotG = setInterval(function () {
  355.                 if (Game.goldenCookie.life > 0) {
  356.                     Game.goldenCookie.click();
  357.                 }
  358.             }, 500);
  359.         }
  360.     } else if (!choice) {
  361.         clearInterval(clickerBotG);
  362.         clickerBotG = 0;
  363.     }
  364. }
  365.  
  366. function SpawnGolden() {
  367.     SmartUpdateMenu();
  368.     Game.goldenCookie.delay = Game.goldenCookie.life = 0;
  369. }
  370.  
  371. function SpawnFrenzy() {
  372.     SmartUpdateMenu();
  373.     Game.frenzy = Game.fps * Flast;
  374.     Game.frenzyPower = Fpow;
  375.     Game.CalculateGains();
  376.     Game.Popup("Custom Frenzy! Cookie production x" + Fpow + " for " + Flast + " second!");
  377. }
  378.  
  379. function SetStartDate() {
  380.     SmartUpdateMenu();
  381.     date = new Date().getTime();
  382.     date -= SHours * 3600 * 1000;
  383.     Game.startDate = date;
  384. }
  385.  
  386. function GetHeavenly() {
  387.     SmartUpdateMenu();
  388.     var toGive = 0;
  389.     if (!HFix) {
  390.         toGive = HAmount + Game.prestige['Heavenly chips'];
  391.     } else if (HFix) {
  392.         toGive = HAmount;
  393.     }
  394.     Game.cookiesReset = (Math.pow(2 * toGive + 1, 2) - 1) * Math.pow(10, 12) / 8;
  395.     Game.CalculatePrestige();
  396. }
  397.  
  398. function SetMilk() {
  399.     SmartUpdateMenu();
  400.     toGive = MilkLvl * 0.01;
  401.     Game.AchievementsOwned = toGive * 25;
  402.     Game.CalculateGains();
  403. }
  404.  
  405. function UpgradeHack() {
  406.     var list = [];
  407.     var choice = Game.prefs.upgradehack;
  408.     displayUpgradeHack = '';
  409.     for (var i in Game.Upgrades) {
  410.         list.push(Game.Upgrades[i]);
  411.     }
  412.     for (var i in list) {
  413.         var me = list[i];
  414.         displayUpgradeHack += '<div onclick="Game.UpgradesById[' + me.id + '].toggle();UpgradeHack();" class="crate upgrade' + (me.bought > 0 ? ' enabled' : '') + '" ' + Game.getTooltip(
  415.             '<div style="min-width:200px;"><div style="float:right;"><span class="price">' + Beautify(Math.round(me.basePrice)) + '</span></div><small>[Upgrade]' + (me.bought > 0 ? ' [Purchased]' : '') + '</small><div class="name">' + me.name + '</div><div class="description">' + me.desc + '</div></div>', 0, 0, 'bottom-right') + ' style="background-position:' + (-me.icon[0] * 48 + 6) + 'px ' + (-me.icon[1] * 48 + 6) + 'px;"></div>';
  416.     }
  417.     focused = true;
  418.     if (!choice) {
  419.         focused = false;
  420.         displayUpgradeHack = '';
  421.     }
  422.     SmartUpdateMenu();
  423. }
  424.  
  425. function AchievementHack() {
  426.     var list = [];
  427.     var choice = Game.prefs.achievementhack;
  428.     displayAchievementHack = '';
  429.     for (var i in Game.Achievements) {
  430.         list.push(Game.Achievements[i]);
  431.     }
  432.     for (var i in list) {
  433.         var me = list[i];
  434.         displayAchievementHack += '<div onclick="ToggleAchievement(' + me.id + ');AchievementHack();" class="crate achievement' + (me.won > 0 ? ' enabled' : '') + '" ' + Game.getTooltip(
  435.             '<div style="min-width:200px;"><small>[Achievement]' + (me.won == 1 ? ' [Unlocked]' : '') + (me.hide == 3 ? ' [Shadow]' : '') + '</small><div class="name">' + me.name + '</div><div class="description">' + me.desc + '</div></div>', 0, 0, 'bottom-right') + ' style="background-position:' + (-me.icon[0] * 48 + 6) + 'px ' + (-me.icon[1] * 48 + 6) + 'px;"></div>';
  436.     }
  437.     focused = true;
  438.     if (!choice) {
  439.         focused = false;
  440.         displayAchievementHack = '';
  441.     }
  442.     SmartUpdateMenu();
  443. }
  444.  
  445. Game.Lose = function (what) {
  446.     if (typeof what === 'string') {
  447.         if (Game.Achievements[what]) {
  448.             if (Game.Achievements[what].won == 1) {
  449.                 Game.Achievements[what].won = 0;
  450.                 Game.Popup('Achievement locked :<br>' + Game.Achievements[what].name + '<br> ');
  451.                 Game.AchievementsOwned--;
  452.                 Game.recalculateGains = 1;
  453.             }
  454.         }
  455.     } else {
  456.         for (var i in what) {
  457.             Game.Lose(what[i]);
  458.         }
  459.     }
  460. };
  461.  
  462. function ToggleAchievement(what) {
  463.     if (typeof what === 'number') {
  464.         var that = Game.AchievementsById[what].name;
  465.         if (Game.Achievements[that]) {
  466.             if (Game.Achievements[that].won === 0) {
  467.                 Game.Win(that);
  468.             } else {
  469.                 Game.Lose(that);
  470.             }
  471.         }
  472.     }
  473. }
  474.  
  475. function DisplayAutobuy() {
  476.     var time = (ABPrice - Game.cookies) / Game.cookiesPs;
  477.     time = time < 0 ? 0 : Beautify(time);
  478.     ABText = "Buying " + ABName + " for " + Beautify(ABPrice) + " at " + Beautify(Math.round(ABPrice / (ABCps * Game.globalCpsMult))) + " cookies per CPS!" + "<br>This will take " + time + " seconds.";
  479.     if (Game.onMenu == 'cheat') {
  480.         l("displayAutoBuyText").innerHTML = ABText;
  481.     }
  482. }
  483.  
  484. function OptimalItem() {
  485.     var cpc = Number.MAX_VALUE;
  486.     var sel;
  487.     for (i = Game.UpgradesInStore.length - 1; i >= 0; i--) {
  488.         var cps1 = 0;
  489.         var me = Game.UpgradesInStore[i];
  490.         var x = Game.UpgradesInStore[i].id;
  491.         if (x != 64 && x != 74 && x != 84 && x != 85) {
  492.             Game.UpgradesById[x].bought = 1;
  493.             Game.CalculateGains();
  494.             for (j = Game.ObjectsById.length - 1; j >= 0; j--) {
  495.                 cps1 += Game.ObjectsById[j].cps() * Game.ObjectsById[j].amount;
  496.             }
  497.             var cps2 = cps1 * Game.globalCpsMult;
  498.             Game.UpgradesById[x].bought = 0;
  499.             Game.CalculateGains();
  500.             var myCps = cps2 - ABCurrentCps;
  501.             var cpsUpgrade = me.basePrice * (Game.cookiesPs + myCps) / myCps;
  502.             if (cpsUpgrade < cpc && myCps >= 0.1) {
  503.                 cpc = cpsUpgrade;
  504.                 sel = me;
  505.                 ABCps = myCps;
  506.                 ABName = me.name;
  507.                 ABPrice = Math.round(me.basePrice);
  508.             }
  509.         }
  510.     }
  511.     for (i = Game.ObjectsById.length - 1; i >= 0; i--) {
  512.         var cps1 = 0;
  513.         var me = Game.ObjectsById[i];
  514.         me.amount++;
  515.         Game.CalculateGains();
  516.         for (j = Game.ObjectsById.length - 1; j >= 0; j--) {
  517.             cps1 += Game.ObjectsById[j].cps() * Game.ObjectsById[j].amount;
  518.         }
  519.         var cps2 = cps1 * Game.globalCpsMult;
  520.         me.amount--;
  521.         Game.CalculateGains();
  522.         var myCps = cps2 - ABCurrentCps;
  523.         var cpsBuilding = me.price * (Game.cookiesPs + myCps) / myCps;
  524.         if (cpsBuilding < cpc && myCps >= 0.1) {
  525.             cpc = cpsBuilding;
  526.             sel = me;
  527.             ABCps = myCps;
  528.             ABName = me.name;
  529.             ABPrice = Math.round(me.price);
  530.         }
  531.     }
  532.     ABCurrentCps = Game.cookiesPs;
  533.     ABSelected = 1;
  534.     ABOptimal = sel;
  535. }
  536.  
  537. function AutoBuy() {
  538.     SmartUpdateMenu();
  539.     var choice = Game.prefs.autobuy;
  540.     ABInterval = 250;
  541.     ABCurrentCps = Game.cookiesPs;
  542.     if (choice && buyBot === 0) {
  543.         AutoBuyFunction();
  544.     } else if (!choice) {
  545.         clearTimeout(buyBot);
  546.         BuyBot = 0;
  547.         ABText = '';
  548.         SmartUpdateMenu();
  549.     }
  550. }
  551.  
  552. function AutoBuyFunction() {
  553.     buyBot = setTimeout(function () {
  554.         if (Game.cookies >= ABPrice && ABSelected == 1) {
  555.             ABOptimal.buy();
  556.             DisplayAutobuy();
  557.             ABSelected = 0;
  558.             AutoBuyFunction();
  559.         } else if (ABSelected === 0 || ABCurrentCps != Game.cookiesPs) {
  560.             OptimalItem();
  561.             DisplayAutobuy();
  562.             AutoBuyFunction();
  563.         } else if (ABSelected == 1) {
  564.             DisplayAutobuy();
  565.             AutoBuyFunction();
  566.         }
  567.     }, ABInterval);
  568. }
  569.  
  570. function GetBuilding() {
  571.     SmartUpdateMenu();
  572.     if (buildingChoice != 'all') {
  573.         var me = Game.ObjectsById[buildingChoice];
  574.         me.amount = me.bought = BAmount;
  575.         if (BFree) {
  576.             me.basePrice = 0;
  577.             me.refresh();
  578.         }
  579.     } else if (buildingChoice == 'all') {
  580.         for (i = 0; i < Game.Object.length; i++) {
  581.             var me = Game.ObjectsById[i];
  582.             me.amount = me.bought = BAmount;
  583.             if (BFree) {
  584.                 me.basePrice = 0;
  585.                 me.refresh();
  586.             }
  587.         }
  588.     }
  589.     BOUpdate();
  590.     Game.CalculateGains();
  591.     Game.RebuildStore();
  592. }
  593.  
  594. function SelectBuilding() {
  595.     var text;
  596.     for (i = 0; i < Game.Object.length; i++) {
  597.         me = Game.ObjectsById[i];
  598.         text += '<option value="' + i + '" id="SelectedChoice_' + i + '">' + me.name + '</option>';
  599.     }
  600.     return '<option value="all" id="SelectedChoice_all">All</option>' + text;
  601. }
  602.  
  603. function InstantSearch() {
  604.     SmartUpdateMenu();
  605.     var choice = Game.prefs.instantsearch;
  606.     if (choice) {
  607.         Game.researchT = 0;
  608.         Game.baseResearchTime = 0;
  609.     } else if (!choice) {
  610.         Game.baseResearchTime = Game.fps * 60 * 30;
  611.     }
  612. }
  613.  
  614. function CustomPledge() {
  615.     SmartUpdateMenu();
  616.     Game.pledgeT = Game.fps * 60 * PTime;
  617.     Game.Lock('Elder Pledge');
  618.     Game.elderWrath = 0;
  619.     Game.pledges++;
  620. }
  621.  
  622. function ABPledge() {
  623.     SmartUpdateMenu();
  624.     var choice = Game.prefs.autobuypledge;
  625.     var toWait = (Game.pledgeT / Game.fps) * 1000;
  626.     if (choice) {
  627.         pledgeBot = setTimeout(function () {
  628.             Game.UpgradesById[74].buy();
  629.             ABPledge();
  630.         }, toWait);
  631.     }
  632.     if (!choice) {
  633.         clearTimeout(pledgeBot);
  634.         pledgeBot = 0;
  635.     }
  636. }
  637.  
  638. function AllUpgrades() {
  639.     SmartUpdateMenu();
  640.     for (var i in Game.Upgrades) {
  641.         Game.Upgrades[i].toggle();
  642.     }
  643.     Game.CalculateGains();
  644.     Game.RebuildUpgrades();
  645.     UpgradeHack();
  646. }
  647.  
  648. function AllAchievements() {
  649.     SmartUpdateMenu();
  650.     for (var i in Game.Achievements) {
  651.         ToggleAchievement(Game.Achievements[i].id);
  652.     }
  653.     Game.CalculateGains();
  654.     AchievementHack();
  655. }
  656.  
  657. function BOUpdate() {
  658.     Game.BuildingsOwned = 0;
  659.     for (i = 0; i < Game.Object.length; i++) {
  660.         me = Game.ObjectsById[i];
  661.         Game.BuildingsOwned += me.amount;
  662.         if (me.buyFunction) {
  663.             me.buyFunction();
  664.         }
  665.         if (me.drawFunction) {
  666.             me.drawFunction();
  667.         }
  668.         if (me.amount >= 1 && me.id !== 0) {
  669.             l('row' + me.id).className = 'row enabled';
  670.         }
  671.     }
  672. }
Advertisement
Add Comment
Please, Sign In to add comment