Cookie clicker tools

Cookie clicker tools (visual)

目前為 2018-12-02 提交的版本,檢視 最新版本

  1. // ==UserScript==
  2. // @name Cookie clicker tools
  3. // @namespace orteil.dashnet.org
  4. // @version 2.167
  5. // @description Cookie clicker tools (visual)
  6. // @author Anton
  7. // @match http://orteil.dashnet.org/cookieclicker/*
  8. // @require http://ajax.googleapis.com/ajax/libs/jquery/1.9.1/jquery.min.js
  9. // ==/UserScript==
  10.  
  11. (function() {
  12. 'use strict';
  13. var log = [], newLogs = 0;
  14.  
  15. var started = false, t2, t3, tClickFrenzy, oldTitle = '', tLog,
  16. tPriority, tBankAuto, tAscendDetector, isClickingNow = false,
  17. tSeasonSwitcher, tDragon, tReloadPageOnWrongBuff, tAutoClickInterval = 75,
  18. version = typeof GM_info == 'function' ? GM_info().script.version :
  19. (typeof GM_info == 'object' ? GM_info.script.version : '?'),
  20. logTitle = '<div class="section">Cookie clicker tools ' + version +' is here!</div>';
  21. var $logButton;
  22.  
  23. var _history = function() {
  24. var hist = [];
  25. hist.push('2.156 - lumps harvesting + achievement');
  26. hist.push('2.155 - fix some bugs with new version of the Game');
  27. hist.push('2.136 - buyAll function (it is a kind of cheat)');
  28. hist.push('2.128 - santa and dragon upgrades');
  29. hist.push('2.122 - season switcher');
  30. hist.push('2.118 - show season unlocks in "Need to unlock" table');
  31. hist.push('2.114 - option to disable auto clicking');
  32. hist.push('2.113 - info table "Achievements to unlock"');
  33. hist.push('2.112 - info table "Need to unlock"');
  34. hist.push('2.111 - option to buy infernal upgrades');
  35. hist.push('2.109 - kill all wrinklers button');
  36. hist.push('2.107 - click first 15 minutes after ascend');
  37. hist.push('2.101 - remove all bufs on negative multiplier (same as reload page)');
  38. hist.push('2.100 - Info section + ascend detector');
  39. hist.push('2.099 - mouse click upgrades');
  40. hist.push('2.097 - auto bank storage');
  41. hist.push('2.096 - buy objects more than 1');
  42. hist.push('2.091 - priority table refactor');
  43. hist.push('2.090 - buy very cheap items first');
  44. hist.push('2.086 - clear log button');
  45. hist.push('2.084 - buy unknown upgrades if their price is 0.1% of cookie storage');
  46. hist.push('2.083 - mouse upgrades is processed as Upgrades');
  47. hist.push('2.082 - start from scratch');
  48. hist.push('2.079 - hide donate box');
  49. hist.push('2.078 - Kittens now is processed as Upgrades');
  50. return hist;
  51. };
  52.  
  53. var _hasDragon = function () {
  54. return Game.Has('A crumbly egg');
  55. };
  56.  
  57. var _getDragonAuraName = function (aura) {
  58. if (typeof Game.dragonAuras[aura] !== 'undefined') {
  59. return Game.dragonAuras[aura].name + " (" + Game.dragonAuras[aura].desc + ")";
  60. }
  61. return 'Unknown (' + aura + ')';
  62. };
  63.  
  64. var _getKittenPercentByUpgradeName = function(kName) {
  65. if (kName === 'Kitten helpers') return Game.milkProgress*0.1;
  66. if (kName === 'Kitten workers') return Game.milkProgress*0.125;
  67. if (kName === 'Kitten engineers') return Game.milkProgress*0.15;
  68. if (kName === 'Kitten overseers') return Game.milkProgress*0.175;
  69. if (kName === 'Kitten managers') return Game.milkProgress*0.2;
  70. if (kName === 'Kitten accountants') return Game.milkProgress*0.2;
  71. if (kName === 'Kitten specialists') return Game.milkProgress*0.2;
  72. if (kName === 'Kitten experts') return Game.milkProgress*0.2;
  73. if (kName === 'Kitten angels') return Game.milkProgress*0.1;
  74. return 0;
  75. };
  76.  
  77. var aBeautify = function(n, floats) {
  78. return Beautify(parseInt(n), floats);
  79. };
  80.  
  81. var _getUpgradeListToUnlock = function() {
  82. var result = [];
  83. for (var x in Game.UnlockAt) {
  84. if (Game.UnlockAt.hasOwnProperty(x) &&
  85. Game.Upgrades.hasOwnProperty(Game.UnlockAt[x].name) &&
  86. Game.Upgrades[Game.UnlockAt[x].name].bought === 0)
  87. {
  88. result.push(Game.UnlockAt[x]);
  89. }
  90. }
  91. var halloweenSeason = ['Skull cookies','Ghost cookies','Bat cookies','Slime cookies','Pumpkin cookies','Eyeball cookies','Spider cookies'];
  92. for (x in halloweenSeason) {
  93. if (halloweenSeason.hasOwnProperty(x) &&
  94. Game.Upgrades[halloweenSeason[x]].bought === 0)
  95. {
  96. result.push({cookies:'',name:halloweenSeason[x],require:'Kill wrinkler',season:'halloween'});
  97. }
  98. }
  99. for (x in Game.easterEggs) {
  100. if (Game.easterEggs.hasOwnProperty(x) &&
  101. Game.Upgrades[Game.easterEggs[x]].bought === 0)
  102. {
  103. result.push({cookies:'',name:Game.easterEggs[x],require:'Find egg',season:'easter'});
  104. }
  105. }
  106. var valentines = ['Pure heart biscuits','Ardent heart biscuits','Sour heart biscuits','Weeping heart biscuits','Golden heart biscuits','Eternal heart biscuits'];
  107. var lastValentineName = '';
  108. for (x in valentines) {
  109. if (valentines.hasOwnProperty(x) &&
  110. Game.Upgrades[valentines[x]].bought === 0)
  111. {
  112. result.push({cookies:'',name:valentines[x],require:lastValentineName,season:'valentines'});
  113. lastValentineName = valentines[x];
  114. }
  115. }
  116. var christmas = ['Christmas tree biscuits','Snowflake biscuits','Snowman biscuits','Holly biscuits','Candy cane biscuits','Bell biscuits','Present biscuits'];
  117. for (x in christmas) {
  118. if (christmas.hasOwnProperty(x) &&
  119. Game.Upgrades[christmas[x]].bought === 0)
  120. {
  121. result.push({cookies:Game.Upgrades[christmas[x]].basePrice,name:christmas[x],require:'Christmas',season:'christmas'});
  122. }
  123. }
  124. return result;
  125. };
  126.  
  127. var options = {
  128. bankStoragePercent: 0,
  129. bankStorageAuto: false,
  130. buyInfernalUpgrades: false,
  131. noClicking: false,
  132. autoSeason: false
  133. };
  134.  
  135. var _store = function(name, value) {
  136. if (typeof(Storage) !== "undefined") localStorage.setItem(name, value);
  137. };
  138.  
  139. var _restore = function(name, asBool) {
  140. if (typeof asBool === 'undefined') asBool = false;
  141. if (typeof(Storage) !== "undefined") {
  142. if (asBool) {
  143. return (localStorage.getItem(name) === 'true' || localStorage.getItem(name) === true);
  144. } else {
  145. return localStorage.getItem(name);
  146. }
  147. }
  148. else return undefined;
  149. };
  150.  
  151. var _getBuffMult = function () {
  152. var buffMult = 1;
  153. for (var buff in Game.buffs) {
  154. if (Game.buffs[buff] !== 0 && typeof Game.buffs[buff].multCpS !== 'undefined') {
  155. buffMult = buffMult * Game.buffs[buff].multCpS;
  156. }
  157. }
  158. return buffMult <= 0 ? 1 : buffMult;
  159. };
  160.  
  161. var _getNormalCookiesPs = function () {
  162. return Game.cookiesPs > 0 ? Game.cookiesPs / _getBuffMult() : 1;
  163. };
  164.  
  165. var _getMinimalMoney = function () {
  166. return Math.floor(_getNormalCookiesPs() * 42100 * options.bankStoragePercent / 100);
  167. };
  168.  
  169. var _getMoneyCanSpend = function () {
  170. return Game.cookies - _getMinimalMoney();
  171. };
  172.  
  173. var _getWrinklerCount = function () {
  174. var wrinklersCount = 0;
  175. for (var i in Game.wrinklers) {
  176. if (Game.wrinklers[i].sucked > 0) {
  177. wrinklersCount++;
  178. }
  179. }
  180. return wrinklersCount;
  181. };
  182.  
  183. var priorityListObj = {}; //, priorityList = [];
  184. var _createPriorityList = function() {
  185. var moneyCanSpend = _getMoneyCanSpend();
  186. //var money = Game.cookies;
  187. var buffMult = _getBuffMult();
  188. //priorityList = [];
  189. priorityListObj = {};
  190. // top priority
  191. var topPriorityList = ['A festive hat','A crumbly egg','Heavenly chip secret','Heavenly cookie stand','Heavenly bakery','Heavenly confectionery','Heavenly key'];
  192. for (var tt in topPriorityList) {
  193. var tp = Game.Upgrades[topPriorityList[tt]];
  194. if (typeof tp !== 'undefined' && tp.bought === 0 && parseInt(tp.unlocked) === 1) {
  195. tp.buy();
  196. break;
  197. }
  198. }
  199.  
  200. for (var g in Game.UpgradesById) {
  201. if (Game.UpgradesById[g].bought === 0 && parseInt(Game.UpgradesById[g].unlocked) === 1) {
  202. var isMultiplier = Game.UpgradesById[g].desc.indexOf('production multiplier') >= 0;
  203. var isDouble = Game.UpgradesById[g].desc.indexOf('<b>twice</b>') >= 0;
  204. var isDoubleGrandma = Game.UpgradesById[g].desc.indexOf('Grandmas are <b>twice</b>') >= 0;
  205. var isKitten = Game.UpgradesById[g].name.indexOf('Kitten ') >= 0;
  206. var isDoubleCursor = Game.UpgradesById[g].desc.indexOf('The mouse and cursors are <b>twice</b>') >= 0;
  207. var isClickIncrease = Game.UpgradesById[g].desc.indexOf('Clicking gains <b>+1%') >= 0;
  208. var isSpecialTech = Game.UpgradesById[g].pool === 'tech' && typeof Game.UpgradesById[g].clickFunction !== 'undefined';
  209. if (isSpecialTech && Game.UpgradesById[g].clickFunction !== 'undefined' && options.buyInfernalUpgrades) {
  210. delete(Game.UpgradesById[g].clickFunction);
  211. }
  212. var increasedMoney = 0;
  213. if (isClickIncrease) {
  214. increasedMoney = Game.cookiesPs * 0.01;
  215. } else if (isDoubleCursor) {
  216. increasedMoney = Game.Objects['Cursor'].storedTotalCps * Game.globalCpsMult / buffMult;
  217. if (isClickingNow) increasedMoney += Game.computedMouseCps * 1000 / tAutoClickInterval;
  218. } else if (isKitten) {
  219. var kittenPercent = _getKittenPercentByUpgradeName(Game.UpgradesById[g].name);
  220. increasedMoney = _getNormalCookiesPs() * kittenPercent;
  221. } else if (isDoubleGrandma) {
  222. increasedMoney = Game.Objects['Grandma'].storedTotalCps * Game.globalCpsMult / buffMult;
  223. } else if (isMultiplier) {
  224. increasedMoney = _getNormalCookiesPs() * Game.UpgradesById[g].power / 100;
  225. } else if (isDouble) {
  226. increasedMoney = Game.UpgradesById[g].buildingTie.storedTotalCps * Game.globalCpsMult / buffMult;
  227. }
  228. var interest = increasedMoney > 0 ? Game.UpgradesById[g].getPrice() / increasedMoney : '-';
  229. if (interest !== '-') {
  230. if (typeof priorityListObj[Math.floor(interest)] === 'undefined') {
  231. var pp = moneyCanSpend / Game.UpgradesById[g].getPrice(); // percent of cheapness
  232. if (pp > 50) interest /= pp * 50;
  233. priorityListObj[Math.floor(interest)] = {
  234. name: Game.UpgradesById[g].name,
  235. title: Game.UpgradesById[g].name + ' - ' + aBeautify(Game.UpgradesById[g].getPrice()),
  236. price: Game.UpgradesById[g].getPrice(),
  237. cps: 1,
  238. type: 'upgrade',
  239. id: g,
  240. income: increasedMoney
  241. };
  242. }
  243. } else if (Game.UpgradesById[g].type === 'upgrade' &&
  244. Game.UpgradesById[g].getPrice() < moneyCanSpend &&
  245. Game.UpgradesById[g].pool !== 'toggle' && (!isSpecialTech || options.buyInfernalUpgrades))
  246. {
  247. interest = Game.UpgradesById[g].getPrice() / moneyCanSpend * 1000;
  248. if (typeof priorityListObj[Math.floor(interest)] === 'undefined') {
  249. pp = moneyCanSpend / Game.UpgradesById[g].getPrice(); // percent of cheapness
  250. if (pp > 50) interest /= pp * 50;
  251. priorityListObj[Math.floor(interest)] = {
  252. name: Game.UpgradesById[g].name,
  253. title: Game.UpgradesById[g].name + ' - ' + aBeautify(Game.UpgradesById[g].getPrice()),
  254. price: Game.UpgradesById[g].getPrice(),
  255. cps: 1,
  256. type: 'upgrade',
  257. id: g,
  258. income: 0
  259. };
  260. }
  261. }
  262. }
  263. }
  264. for (var i in Game.ObjectsById) {
  265. if (typeof i !== 'undefined' && i !== 'undefined' && Game.ObjectsById.hasOwnProperty(i)) {
  266. if (Game.ObjectsById[i].locked === 0) {
  267. var cps = (Game.ObjectsById[i].storedTotalCps / Game.ObjectsById[i].amount) * Game.globalCpsMult / buffMult;
  268. interest = Game.ObjectsById[i].price / cps;
  269. var pp2 = moneyCanSpend / Game.ObjectsById[i].price; // percent of cheapness
  270. if (pp2 > 50) interest /= pp2 * 50;
  271. if (isNaN(Math.floor(interest)) && Game.ObjectsById[i].price < moneyCanSpend) interest = 0;
  272. priorityListObj[Math.floor(interest)] = {
  273. name: Game.ObjectsById[i].name,
  274. title: Game.ObjectsById[i].name + ' - ' + aBeautify(Game.ObjectsById[i].price),
  275. price: Game.ObjectsById[i].price,
  276. cps: cps,
  277. type: 'buy',
  278. id: i,
  279. income: cps
  280. };
  281. //priorityList.push(Game.ObjectsById[i].name + ' - ' + aBeautify(Game.ObjectsById[i].price) + ' (INTEREST: ' + aBeautify(interest) + ')');
  282. }
  283. }
  284. }
  285. //for (i in priorityListObj) {
  286. //if (priorityListObj.hasOwnProperty(i)) {
  287. //var prefix = priorityListObj[i].price < moneyCanSpend ? '!!! ' : (priorityListObj[i].price < money ? '! ' : '');
  288. //var pp1 = Math.floor(moneyCanSpend / priorityListObj[i].price * 100);
  289. //priorityList.push(prefix + priorityListObj[i].title + ' : ' + i + ' (' + pp1 + '%)');
  290. //}
  291. //}
  292. };
  293.  
  294. var _caption = function(txt) {
  295. var $v = jQuery('#versionNumber');
  296. if ($v.text() !== txt) $v.text(txt);
  297. };
  298.  
  299. var _title = function(txt) {
  300. var newTitle = (newLogs > 0 ? '(' + newLogs + ') ' : '') + txt;
  301. if (document.title !== newTitle) {
  302. oldTitle = txt;
  303. document.title = newTitle;
  304. }
  305. };
  306.  
  307. var _titlePercent = function(have, need, txt) {
  308. var percent = Math.ceil(have / (need !== 0 ? need : 1) * 100);
  309. _title(String(percent) + "% - " + txt);
  310. };
  311.  
  312. var _logSectionTitle = function (text) {
  313. return '<div class="title">' + text + '</div>';
  314. };
  315.  
  316. var _logSection = function (title, items) {
  317. return '<div class="subsection">' + _logSectionTitle(title) +
  318. '<div class="listing">' + items.join('</div><div class="listing">') + '</div>' +
  319. '</div>';
  320. };
  321.  
  322. var clearLogButton = '<button data-id="clearLog" onclick="Game.CCT.onbuttonclick(this,event)">Clear Log</button>';
  323. var killWrinklersButton = '<button data-id="killWrinklers" onclick="Game.CCT.onbuttonclick(this,event)">Kill wrinklers</button>';
  324. var buyEverything = '<button data-id="buyEverything" onclick="Game.CCT.onbuttonclick(this,event)">Buy everything</button>';
  325.  
  326. var _logPriorityTable = function() {
  327. var moneyCanSpend = _getMoneyCanSpend();
  328. var styles = '<style type="text/css">.prioritytable{width:100%;}.prioritytable td,.prioritytable th{padding:3px;}</style>';
  329. var t = '<table class="prioritytable"><tr style="border-bottom:1px solid;text-align:left;font-weight:bold;"><th>Type</th><th>Name</th><th>Price</th><th>Interest</th><th>Income</th><th>% bank</th></tr>';
  330. for (var i in priorityListObj) {
  331. if (priorityListObj.hasOwnProperty(i)) {
  332. var o = priorityListObj[i];
  333. var pp = Math.floor(moneyCanSpend / o.price * 100);
  334. t += '<tr><td>' + o.type + '</td><td>' + o.name + '</td><td>' + aBeautify(o.price) + '</td><td>' + i + '</td><td>' + aBeautify(o.income) + '</td><td>' + pp + '</td></tr>';
  335. }
  336. }
  337. t += '</table>';
  338. return styles + '<div class="subsection">' + _logSectionTitle('Priority ' + clearLogButton + ' ' + killWrinklersButton + ' ' + buyEverything) + '<div class="listing">' + t + '</div></div>';
  339. };
  340.  
  341. var _logNeedBuyTable = function() {
  342. var objList = _getUpgradeListToUnlock();
  343. if (objList && objList.length > 0) {
  344. var styles = '<style type="text/css">.prioritytable{width:100%;}.prioritytable td,.prioritytable th{padding:3px;}</style>';
  345. var t = '<table class="prioritytable"><tr style="border-bottom:1px solid;text-align:left;font-weight:bold;"><th>Name</th><th>Price</th><th>Prerequisite</th><th>Season</th></tr>';
  346. for (var i in objList) {
  347. if (objList.hasOwnProperty(i)) {
  348. var o = objList[i];
  349. t += '<tr><td>' + o.name + '</td><td>' + aBeautify(o.cookies) + '</td><td>' + (typeof o.require !== 'undefined' ? o.require : '') + '</td><td>' + (typeof o.season !== 'undefined' ? o.season : '') + '</td></tr>';
  350. }
  351. }
  352. t += '</table>';
  353. return styles + '<div class="subsection">' + _logSectionTitle('Need to unlock') + '<div class="listing">' + t + '</div></div>';
  354. } else {
  355. return '';
  356. }
  357. };
  358.  
  359. var _logNeedAchieveTable = function() {
  360. var ach = [];
  361. for (var i in Game.Achievements) {
  362. if(Game.Achievements[i].won === 0 && Game.Achievements[i].pool !== 'dungeon') {
  363. ach.push(Game.Achievements[i]);
  364. }
  365. }
  366. if (ach.length > 0) {
  367. var styles = '<style type="text/css">.prioritytable{width:100%;}.prioritytable td,.prioritytable th{padding:3px;}</style>';
  368. var t = '<table class="prioritytable"><tr style="border-bottom:1px solid;text-align:left;font-weight:bold;"><th>Name</th><th>Description</th></tr>';
  369. for (i in ach) {
  370. var o = ach[i];
  371. t += '<tr><td>' + o.name + '</td><td>' + o.desc + '</td></tr>';
  372. }
  373. t += '</table>';
  374. return styles + '<div class="subsection">' + _logSectionTitle('Achievements to unlock') + '<div class="listing">' + t + '</div></div>';
  375. } else {
  376. return '';
  377. }
  378. };
  379.  
  380. var _optionsSection = function() {
  381. var content = [];
  382. content.push('<label for="bankStoragePercent" id="bankStoragePercentLabel">Storage (' + aBeautify(_getMinimalMoney()) + ') percent: ' + options.bankStoragePercent + '%</label> <input name="bankStoragePercent" id="bankStoragePercent" type="range" min="0" max="100" value="' + options.bankStoragePercent + '" onchange="Game.CCT.onsliderchange(this)" />');
  383. content.push('<button data-id="bankStorageAuto" onclick="Game.CCT.onbuttonclick(this,event)">Automatic set of bank storage percent: ' + (options.bankStorageAuto ? 'TRUE' : 'FALSE') + '</button>');
  384. content.push('<button data-id="buyInfernalUpgrades" onclick="Game.CCT.onbuttonclick(this,event)">Automatic buy infernal upgrades (makes granny evil): ' + (options.buyInfernalUpgrades ? 'TRUE' : 'FALSE') + '</button>');
  385. content.push('<button data-id="noClicking" onclick="Game.CCT.onbuttonclick(this,event)">Restrict auto clicking: ' + (options.noClicking ? 'TRUE' : 'FALSE') + '</button>');
  386. content.push('<button data-id="autoSeason" onclick="Game.CCT.onbuttonclick(this,event)">Auto season swithcer: ' + (options.autoSeason ? 'TRUE' : 'FALSE') + '</button>');
  387. content.push(clearLogButton);
  388. return content;
  389. };
  390.  
  391. var _infoSection = function() {
  392. var content = [];
  393.  
  394. var wrinklersTotal = 0;
  395. for (var i in Game.wrinklers) {
  396. wrinklersTotal += Game.wrinklers[i].sucked;
  397. }
  398.  
  399. var chipsOwned = Math.floor(Game.HowMuchPrestige(Game.cookiesReset));
  400. var ascendNowToOwn = Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned));
  401. var ascendWillGet = ascendNowToOwn - chipsOwned;
  402. var cookiesToDoubleInitial = Game.HowManyCookiesReset(chipsOwned * 2) - (Game.cookiesEarned + Game.cookiesReset);
  403. var timeToReachDouble = Math.floor(cookiesToDoubleInitial / _getNormalCookiesPs());
  404.  
  405. content.push('Now clicking: ' + (isClickingNow ? "YES" : "NO"));
  406. content.push('Per click: ' + aBeautify(Game.computedMouseCps));
  407. content.push('Cookies to double prestige: ' + (cookiesToDoubleInitial >= 0 ? aBeautify(cookiesToDoubleInitial) : 'No info'));
  408. content.push('Time to double prestige: ' + Game.sayTime(timeToReachDouble * Game.fps, 2));
  409. content.push('Heavenly chips in storage: ' + Game.heavenlyChips);
  410. content.push('You will get prestige by ascending: ' + ascendWillGet);
  411. content.push('Heavenly chips after ascend: ' + (Game.heavenlyChips + ascendWillGet));
  412. content.push('Buff mult: ' + _getBuffMult());
  413. content.push('Normal CpS: ' + aBeautify(_getNormalCookiesPs()));
  414. content.push('Money bank: ' + aBeautify(_getMinimalMoney()));
  415. content.push('Money can spend: ' + aBeautify(_getMoneyCanSpend()));
  416. content.push('Wrinklers: ' + _getWrinklerCount());
  417. content.push('Wrinklers sucked: ' + aBeautify(wrinklersTotal));
  418. if (Game.dragonLevel<Game.dragonLevels.length-1) {
  419. content.push('Next Dragon upgrade: ' + Game.dragonLevels[Game.dragonLevel].costStr());
  420. }
  421. if (_hasDragon() && Game.dragonAura >= 0 && typeof Game.dragonAuras[Game.dragonAura] !== 'undefined') {
  422. content.push("Aura: " + _getDragonAuraName(Game.dragonAura));
  423. }
  424. return content;
  425. };
  426.  
  427. var _updateLog = function () {
  428. Game.updateLog = logTitle +
  429. _logPriorityTable() +
  430. _logSection('Info', _infoSection()) +
  431. _logSection('Log', log) +
  432. _logSection('Options', _optionsSection()) +
  433. _logNeedBuyTable() +
  434. _logNeedAchieveTable() +
  435. _logSection('History', _history());
  436. var newButtonText = newLogs > 0 ? 'Log (' + newLogs + ')' : 'Log';
  437. if ($logButton.text() !== newButtonText) $logButton.text(newButtonText);
  438. _title(oldTitle);
  439. };
  440.  
  441. var _setBankStogarePercent = function(val, needUpdate) {
  442. if (options.bankStoragePercent !== val) {
  443. if (needUpdate === true) jQuery('#bankStoragePercent').val(val);
  444. if (console) console.log('bankStoragePercent =', val);
  445. _store('bankStoragePercent', val);
  446. options.bankStoragePercent = val;
  447. jQuery('#bankStoragePercentLabel').text('Storage (' + aBeautify(_getMinimalMoney()) + ') percent: ' + val + '%');
  448. _updateLog();
  449. }
  450. };
  451.  
  452. var _bankAutoFunction = function() {
  453. if (options.bankStorageAuto && Game.OnAscend === 0) {
  454. for (var idx in priorityListObj) {
  455. if (priorityListObj.hasOwnProperty(idx)) {
  456. var bankStorageNew = Math.floor(idx / 50000);
  457. if (bankStorageNew > 100) bankStorageNew = 100;
  458. if (!isNaN(bankStorageNew)) _setBankStogarePercent(bankStorageNew, true);
  459. else if (console) console.log('bankStorageNew error:', idx);
  460. break;
  461. }
  462. }
  463. }
  464. };
  465.  
  466. var _addLog = function(text, notCritical) {
  467. var t = new Date();
  468. log.push(t.toUTCString() + ': ' + text);
  469. if (notCritical !== true) newLogs++;
  470. _updateLog();
  471. };
  472.  
  473. var _killAllWrinklers = function (immediately) {
  474. if (typeof immediately === 'undefined') immediately = false;
  475. var wrinklersCount = _getWrinklerCount();
  476. if (wrinklersCount >= 10 || immediately === true) {
  477. var wrinklesIncome = 0;
  478. for (var i in Game.wrinklers) {
  479. wrinklesIncome += Game.wrinklers[i].sucked;
  480. Game.wrinklers[i].hp = 0; // kill ALL
  481. }
  482. if (wrinklesIncome > 0) {
  483. _addLog('Killed all Wrinkles for ' + aBeautify(wrinklesIncome) + ' of count ' + wrinklersCount +'.', true);
  484. }
  485. }
  486. };
  487.  
  488. var _buyEverything = function() {
  489. for (var x in Game.UpgradesById) {
  490. if (Game.UpgradesById.hasOwnProperty(x)) {
  491. if (parseInt(Game.UpgradesById[x].unlocked) === 1
  492. && Game.UpgradesById[x].bought === 0 && Game.UpgradesById[x].canBuy()) {
  493. var pool = Game.UpgradesById[x].pool;
  494. if (pool !== "prestige" &&
  495. pool !== 'debug' &&
  496. pool !== 'toggle' &&
  497. pool !== 'tech' &&
  498. pool !== 'shadow' &&
  499. pool !== 'unused' &&
  500. pool !== 'dungeon')
  501. {
  502. Game.UpgradesById[x].buy();
  503. _addLog('Buy upgrade ' + Game.UpgradesById[x].name + ' for ' + aBeautify(Game.UpgradesById[x].getPrice()));
  504. }
  505. }
  506. }
  507. }
  508. for (x in Game.ObjectsById) {
  509. if (Game.ObjectsById.hasOwnProperty(x)) {
  510. var cnt = 0, sum = 0;
  511. while (Game.cookies >= Game.ObjectsById[x].getPrice()) {
  512. sum += Game.ObjectsById[x].getPrice();
  513. Game.ObjectsById[x].buy(1);
  514. cnt++;
  515. }
  516. if (cnt > 0) _addLog('Buy ' + cnt + ' object ' + Game.ObjectsById[x].name + ' for ' + aBeautify(sum));
  517. }
  518. }
  519. };
  520.  
  521. var _buyLump = function() {
  522. if (!Game.canLumps()) return;
  523. var needAchievement = Game.Achievements['Hand-picked'] &&
  524. parseInt(Game.Achievements['Hand-picked'].won) === 0;
  525. var age = Date.now() - Game.lumpT;
  526.  
  527. if (age > Game.lumpMatureAge && needAchievement) {
  528. _addLog('Trying to get lump achievement, collecting Mature lump');
  529. if (Game.clickLump) Game.clickLump();
  530. } else if (age > Game.lumpRipeAge) {
  531. _addLog('Collecting Ripe lump');
  532. if (Game.clickLump) Game.clickLump();
  533. } else if (age > Game.lumpOverripeAge) {
  534. _addLog('Collecting Overripe lump');
  535. if (Game.clickLump) Game.clickLump();
  536. }
  537. };
  538.  
  539. var _makeABuy = function() {
  540.  
  541. _killAllWrinklers();
  542.  
  543. var moneyCanSpend = _getMoneyCanSpend();
  544.  
  545. if (moneyCanSpend < 0) {
  546. var minimalMoney = _getMinimalMoney();
  547. _caption('Collecting minimum ' + aBeautify(minimalMoney));
  548. _titlePercent(Game.cookies, minimalMoney, 'minimum');
  549. return;
  550. }
  551.  
  552. var needToBuy = undefined, needToBuyInterest;
  553.  
  554. for (var idx in priorityListObj) {
  555. if (priorityListObj.hasOwnProperty(idx)) {
  556. needToBuy = priorityListObj[idx];
  557. needToBuyInterest = idx;
  558. if (needToBuy.type === 'upgrade') {
  559. _caption('Upgrading ' + needToBuy.name + ' for ' + aBeautify(needToBuy.price));
  560. if (needToBuy.price < moneyCanSpend) {
  561. if (Game.UpgradesById[needToBuy.id].canBuy()) {
  562. Game.UpgradesById[needToBuy.id].buy();
  563. _addLog('Buy upgrade ' + Game.UpgradesById[needToBuy.id].name + ' for ' + aBeautify(needToBuy.price));
  564. _createPriorityList();
  565. }
  566. } else {
  567. _titlePercent(moneyCanSpend, needToBuy.price, Game.UpgradesById[needToBuy.id].name);
  568. }
  569. } else {
  570. // _caption('Collecting ' + aBeautify(moneyCanSpend) + ' of '
  571. // + aBeautify(needToBuy.price) + ' for ' + needToBuy.name);
  572. _caption('Collecting ' + aBeautify(needToBuy.price) + ' for ' + needToBuy.name);
  573. if (Game.ObjectsById[needToBuy.id].price < moneyCanSpend) {
  574. var amount = 1;
  575. if (Game.ObjectsById[needToBuy.id].getSumPrice(100) < moneyCanSpend) {
  576. Game.ObjectsById[needToBuy.id].buy(100);
  577. amount = 100;
  578. } else if (Game.ObjectsById[needToBuy.id].getSumPrice(10) < moneyCanSpend) {
  579. Game.ObjectsById[needToBuy.id].buy(10);
  580. amount = 10;
  581. } else {
  582. Game.ObjectsById[needToBuy.id].buy(1);
  583. }
  584. _addLog('Buy ' + amount + ' object ' + Game.ObjectsById[needToBuy.id].name + ' for ' + aBeautify(Game.ObjectsById[needToBuy.id].price));
  585. _createPriorityList();
  586. } else {
  587. _titlePercent(moneyCanSpend, needToBuy.price, Game.ObjectsById[needToBuy.id].name);
  588. }
  589. }
  590. break;
  591. }
  592. }
  593.  
  594. _buyLump();
  595. };
  596.  
  597. var startT = function() {
  598. t2 = setInterval(_makeABuy, 500);
  599. tSeasonSwitcher = setInterval(_seasonSwitcher, 3000);
  600. tDragon = setInterval(_dragonSwitcher, 10000);
  601.  
  602. started = true;
  603. _caption('Started');
  604. _addLog('Autobuy start!', true);
  605. };
  606.  
  607. var stopT = function() {
  608. clearInterval(t2);
  609. clearInterval(tSeasonSwitcher);
  610. clearInterval(tDragon);
  611.  
  612. started = false;
  613. _caption('Collecting gold...');
  614. _addLog('Autobuy stop.', true);
  615. };
  616.  
  617. jQuery('#versionNumber').on("click", function() {
  618. if (!started)
  619. startT();
  620. else
  621. stopT();
  622. });
  623.  
  624. var _restoreAll = function() {
  625. options.bankStoragePercent = parseInt(_restore('bankStoragePercent'));
  626. if (typeof options.bankStoragePercent === 'undefined' || options.bankStoragePercent === null) {
  627. options.bankStoragePercent = 0;
  628. }
  629. options.bankStorageAuto = _restore('bankStorageAuto', true);
  630. if (typeof options.bankStorageAuto === 'undefined' || options.bankStorageAuto === null) {
  631. options.bankStorageAuto = false;
  632. }
  633. options.buyInfernalUpgrades = _restore('buyInfernalUpgrades', true);
  634. if (typeof options.buyInfernalUpgrades === 'undefined' || options.buyInfernalUpgrades === null) {
  635. options.buyInfernalUpgrades = false;
  636. }
  637. options.noClicking = _restore('noClicking', true);
  638. if (typeof options.noClicking === 'undefined' || options.noClicking === null) {
  639. options.noClicking = false;
  640. }
  641. options.autoSeason = _restore('autoSeason', true);
  642. if (typeof options.autoSeason === 'undefined' || options.autoSeason === null) {
  643. options.autoSeason = false;
  644. }
  645. };
  646.  
  647. var _dragonSwitcher = function () {
  648. if (_hasDragon() && Game.dragonLevel<Game.dragonLevels.length-1 && Game.dragonLevels[Game.dragonLevel].cost()) {
  649. _addLog("Upgrading dragon Level " + (Game.dragonLevel+1) + " of " + Game.dragonLevels.length);
  650. Game.UpgradeDragon();
  651. Game.specialTab = 'Hello';
  652. Game.ToggleSpecialMenu(0);
  653. }
  654.  
  655. if (Game.dragonLevel >= 12 && parseInt(Game.dragonAura) !== 9) {
  656. Game.dragonAura = 9; //"Arcane Aura"
  657. Game.recalculateGains = 1;
  658. _addLog("Switching dragon Aura to " + _getDragonAuraName(Game.dragonAura));
  659. } else if (Game.dragonLevel >= 21 && parseInt(Game.dragonAura2) !== 15) {
  660. Game.dragonAura2 = 15; //"Radiant Appetite"
  661. Game.recalculateGains = 1;
  662. _addLog("Switching dragon Aura to " + _getDragonAuraName(Game.dragonAura));
  663. } else if (Game.dragonLevel >= 4 && Game.dragonLevel < 12 && parseInt(Game.dragonAura) !== (Game.dragonLevel - 3)) {
  664. Game.dragonAura = Game.dragonLevel - 3;
  665. Game.recalculateGains = 1;
  666. _addLog("Switching dragon Aura to " + _getDragonAuraName(Game.dragonAura));
  667. }
  668. };
  669.  
  670. var _seasonSwitcher = function() {
  671. if (!options.autoSeason) return;
  672. if (_getWrinklerCount() >= 8) {
  673. var halloweenSeason = ['Skull cookies','Ghost cookies','Bat cookies','Slime cookies','Pumpkin cookies','Eyeball cookies','Spider cookies'];
  674. for (var x in halloweenSeason) {
  675. if (halloweenSeason.hasOwnProperty(x) && Game.Upgrades[halloweenSeason[x]].bought === 0) {
  676. if (Game.season !== 'halloween') {
  677. Game.Upgrades['Ghostly biscuit'].buy();
  678. _killAllWrinklers(true);
  679. return;
  680. }
  681. }
  682. }
  683. }
  684.  
  685. if (!Game.Has('Santa\'s dominion')) {
  686. if (Game.season !== 'christmas') {
  687. Game.Upgrades['Festive biscuit'].buy();
  688. } else {
  689. if (Game.Has('A festive hat')) {
  690. for (var i = 0; i < (14 - Game.santaLevel); i++) Game.UpgradeSanta();
  691. Game.specialTab = 'Hello';
  692. Game.ToggleSpecialMenu(0);
  693. }
  694. }
  695. return;
  696. }
  697. var valentines = ['Pure heart biscuits','Ardent heart biscuits','Sour heart biscuits','Weeping heart biscuits','Golden heart biscuits','Eternal heart biscuits'];
  698. for (x in valentines) {
  699. if (valentines.hasOwnProperty(x) && Game.Upgrades[valentines[x]].bought === 0) {
  700. if (Game.season !== 'valentines') {
  701. Game.Upgrades['Lovesick biscuit'].buy();
  702. }
  703. return;
  704. }
  705. }
  706.  
  707. for (x in Game.easterEggs) {
  708. if (Game.easterEggs.hasOwnProperty(x) && Game.Upgrades[Game.easterEggs[x]].bought === 0) {
  709. if (Game.season !== 'easter') {
  710. Game.Upgrades['Bunny biscuit'].buy();
  711. }
  712. return;
  713. }
  714. }
  715.  
  716. if (Game.season !== 'christmas') {
  717. Game.Upgrades['Festive biscuit'].buy();
  718. }
  719. };
  720.  
  721. _restoreAll();
  722.  
  723. var _initLogButton = function() {
  724. $logButton = jQuery('#logButton');
  725.  
  726. $logButton.text('Log').on("click", function() {
  727. newLogs = 0;
  728. $logButton.text('Log');
  729. });
  730.  
  731. Game.CCT = {}; // Coockie clicker tools
  732. Game.CCT.onsliderchange = function(el) {
  733. var val = $(el).val();
  734. _setBankStogarePercent(val);
  735. };
  736.  
  737. Game.CCT.onbuttonclick = function(el,e) {
  738. e.preventDefault();
  739. var id = jQuery(el).attr('data-id');
  740. if (id === 'bankStorageAuto') {
  741. options.bankStorageAuto = !options.bankStorageAuto;
  742. _store('bankStorageAuto', options.bankStorageAuto);
  743. if (console) console.log('bankStorageAuto =', options.bankStorageAuto ? 'TRUE' : 'FALSE');
  744. _bankAutoFunction();
  745. } else if (id === 'killWrinklers') {
  746. _killAllWrinklers(true);
  747. } else if (id === 'buyEverything') {
  748. _buyEverything();
  749. } else if (id === 'buyInfernalUpgrades') {
  750. options.buyInfernalUpgrades = !options.buyInfernalUpgrades;
  751. _store('buyInfernalUpgrades', options.buyInfernalUpgrades);
  752. if (console) console.log('buyInfernalUpgrades =', options.buyInfernalUpgrades ? 'TRUE' : 'FALSE');
  753. } else if (id === 'noClicking') {
  754. options.noClicking = !options.noClicking;
  755. _store('noClicking', options.noClicking);
  756. if (console) console.log('noClicking =', options.noClicking ? 'TRUE' : 'FALSE');
  757. } else if (id === 'autoSeason') {
  758. options.autoSeason = !options.autoSeason;
  759. _store('autoSeason', options.autoSeason);
  760. if (console) console.log('autoSeason =', options.autoSeason ? 'TRUE' : 'FALSE');
  761. } else if (id === 'clearLog') {
  762. log = [];
  763. newLogs = 0;
  764. }
  765. //jQuery(el).attr('disabled', 'disabled');
  766. _updateLog();
  767. };
  768. };
  769.  
  770. setTimeout(function() {
  771. _initLogButton();
  772.  
  773. jQuery('#donateBox').hide();
  774.  
  775. tPriority = setInterval(function () {
  776. _createPriorityList();
  777. _updateLog();
  778. }, 1000);
  779.  
  780. tLog = setInterval(function () {
  781. _updateLog();
  782. }, 600);
  783.  
  784. tReloadPageOnWrongBuff = setInterval(function() {
  785. if (_getBuffMult() < 1) {
  786. var hasBuffsToKill = false;
  787. for (var buff in Game.buffs) {
  788. if (Game.buffs[buff] !== 0 && typeof Game.buffs[buff].multCpS !== 'undefined') {
  789. Game.buffs[buff].time = 0; // remove all buffs, not only negative (not cheating)
  790. hasBuffsToKill = true;
  791. }
  792. }
  793. if (hasBuffsToKill) _addLog('Remove all buffs because of negative multiplier', true);
  794. }
  795. }, 1000);
  796.  
  797. tAscendDetector = setInterval(function() {
  798. if (parseInt(Game.OnAscend) === 1) {
  799. _setBankStogarePercent(0, true);
  800. }
  801. }, 1000);
  802.  
  803. t3 = setInterval(function() {
  804. var golden = Game.shimmers;
  805. if (golden && golden.length > 0) {
  806. for (var i in golden) {
  807. if (golden.hasOwnProperty(i)) {
  808. golden[i].pop();
  809. }
  810. }
  811. }
  812. }, 500);
  813.  
  814. tBankAuto = setInterval(_bankAutoFunction, 600001); // 10 minutes
  815.  
  816. tClickFrenzy = setInterval(function() {
  817. if (options.noClicking) return;
  818. var date=new Date();
  819. date.setTime(Date.now()-Game.startDate);
  820. var seconds = date.getTime() / 1000;
  821. var buffMult = _getBuffMult();
  822. var buffClicker = typeof Game.hasBuff !== 'undefined' && (
  823. Game.hasBuff('Click frenzy') ||
  824. Game.hasBuff('Cursed finger') ||
  825. Game.hasBuff('Elder frenzy') ||
  826. Game.hasBuff('Dragon Harvest') ||
  827. Game.hasBuff('Dragonflight')
  828. );
  829. if (buffMult >= 15 ||
  830. Game.cookiesPs < 1000000 ||
  831. buffClicker ||
  832. seconds < 1000)
  833. {
  834. var $bigCookie = jQuery('#bigCookie');
  835. Game.mouseX = $bigCookie.width() / 2 + $bigCookie.offset().left;
  836. Game.mouseY = $bigCookie.height() / 2 + $bigCookie.offset().top;
  837. if (typeof Game.ClickCookie === 'function') Game.ClickCookie();
  838. isClickingNow = true;
  839. } else {
  840. isClickingNow = false;
  841. }
  842. }, tAutoClickInterval);
  843.  
  844. _caption('Collecting gold...');
  845. _createPriorityList();
  846. _updateLog();
  847.  
  848. _bankAutoFunction();
  849. }, 5000);
  850. })();