', newLogs = 0;
var started = false, t2, t3, tClick, tClickFrenzy, oldTitle = '', tLog,
tPriority, tBankAuto, tAscendDetector, isClickingNow = false, tReloadPageOnWrongBuff;
var _history = function() {
var hist = [];
hist.push('2.111 - option to buy infernal upgrades');
hist.push('2.109 - kill all wrinklers button');
hist.push('2.107 - click first 10 minutes after ascend');
hist.push('2.101 - remove all bufs on negative multiplier (same as reload page)');
hist.push('2.100 - Info section + ascend detector');
hist.push('2.099 - mouse click upgrades');
hist.push('2.097 - auto bank storage');
hist.push('2.096 - buy objects more than 1');
hist.push('2.091 - priority table refactor');
hist.push('2.090 - buy very cheap items first');
hist.push('2.086 - clear log button');
hist.push('2.084 - buy unknown upgrades if their price is 0.1% of cookie storage');
hist.push('2.083 - mouse upgrades is processed as Upgrades');
hist.push('2.082 - start from scratch');
hist.push('2.080 - add history, add option "showTimeCompensate"');
hist.push('2.079 - hide donate box');
hist.push('2.078 - Kittens now is processed as Upgrades');
return hist;
}
var _getKittenPercentByUpgradeName = function(kName) {
if (kName == 'Kitten helpers') return Game.milkProgress*0.1;
if (kName == 'Kitten workers') return Game.milkProgress*0.125;
if (kName == 'Kitten engineers') return Game.milkProgress*0.15;
if (kName == 'Kitten overseers') return Game.milkProgress*0.175;
if (kName == 'Kitten managers') return Game.milkProgress*0.2;
if (kName == 'Kitten accountants') return Game.milkProgress*0.2;
if (kName == 'Kitten specialists') return Game.milkProgress*0.2;
if (kName == 'Kitten experts') return Game.milkProgress*0.2;
if (kName == 'Kitten angels') return Game.milkProgress*0.1;
return 0;
}
var options = {
bankStoragePercent: 100,
showTimeCompensate: false,
bankStorageAuto: false,
buyInfernalUpgrades: false
};
var _store = function(name, value) {
if (typeof(Storage) !== "undefined") localStorage.setItem(name, value);
};
var _restore = function(name) {
if (typeof(Storage) !== "undefined") return localStorage.getItem(name);
else return undefined;
};
var _getBuffMult = function () {
var buffMult = 1;
for (var buff in Game.buffs) {
if (Game.buffs[buff] !== 0 && typeof Game.buffs[buff].multCpS !== 'undefined') {
buffMult = buffMult * Game.buffs[buff].multCpS;
}
}
return buffMult === 0 ? 1 : buffMult;
};
var _getNormalCookiesPs = function () {
return Game.cookiesPs > 0 ? Game.cookiesPs / _getBuffMult() : 1;
};
var _getMinimalMoney = function () {
return Math.floor(_getNormalCookiesPs() * 42100 * options.bankStoragePercent / 100);
};
var _getMoneyCanSpend = function () {
var moneyCanSpend = Game.cookies - _getMinimalMoney();
return moneyCanSpend;
};
var _getWrinklerCount = function () {
var wrinklersCount = 0;
for (var i in Game.wrinklers) {
if (Game.wrinklers[i].sucked > 0) {
wrinklersCount++;
}
}
return wrinklersCount;
};
var priorityListObj = {}, priorityList = [], timeCompensateObj = {}, timeCompensateList = [];
var _createPriorityList = function() {
var moneyCanSpend = _getMoneyCanSpend();
var money = Game.cookies;
var buffMult = _getBuffMult();
priorityList = [];
priorityListObj = {};
for (var g in Game.UpgradesById) {
if (Game.UpgradesById[g].bought === 0 && Game.UpgradesById[g].unlocked == 1) {
var isMultiplier = Game.UpgradesById[g].desc.indexOf('production multiplier') >= 0;
var isDouble = Game.UpgradesById[g].desc.indexOf('twice') >= 0;
var isDoubleGrandma = Game.UpgradesById[g].desc.indexOf('Grandmas are twice') >= 0;
var isKitten = Game.UpgradesById[g].name.indexOf('Kitten ') >= 0;
var isDoubleCursor = Game.UpgradesById[g].desc.indexOf('The mouse and cursors are twice') >= 0;
var isClickIncrease = Game.UpgradesById[g].desc.indexOf('Clicking gains +1%') >= 0;
var isSpecialTech = Game.UpgradesById[g].pool == 'tech' && typeof Game.UpgradesById[g].clickFunction !== 'undefined';
if (isSpecialTech && Game.UpgradesById[g].clickFunction !== 'undefined') {
delete(Game.UpgradesById[g].clickFunction);
}
var increasedMoney = 0;
if (isClickIncrease) {
increasedMoney = Game.cookiesPs * 0.01;
} else if (isDoubleCursor) {
increasedMoney = Game.Objects['Cursor'].storedTotalCps * Game.globalCpsMult / buffMult;
} else if (isKitten) {
var kittenPercent = _getKittenPercentByUpgradeName(Game.UpgradesById[g].name);
increasedMoney = _getNormalCookiesPs() * kittenPercent;
} else if (isDoubleGrandma) {
increasedMoney = Game.Objects['Grandma'].storedTotalCps * Game.globalCpsMult / buffMult;
} else if (isMultiplier) {
increasedMoney = _getNormalCookiesPs() * Game.UpgradesById[g].power / 100;
} else if (isDouble) {
increasedMoney = Game.UpgradesById[g].buildingTie.storedTotalCps * Game.globalCpsMult / buffMult;
}
var interest = increasedMoney > 0 ? Game.UpgradesById[g].getPrice() / increasedMoney : '-';
if (interest != '-') {
if (typeof priorityListObj[Math.floor(interest)] === 'undefined') {
var pp = moneyCanSpend / Game.UpgradesById[g].getPrice(); // percent of cheapness
if (pp > 50) interest /= pp * 50;
priorityListObj[Math.floor(interest)] = {
name: Game.UpgradesById[g].name,
title: Game.UpgradesById[g].name + ' - ' + Beautify(Game.UpgradesById[g].getPrice()),
price: Game.UpgradesById[g].getPrice(),
cps: 1,
type: 'upgrade',
id: g,
income: increasedMoney
};
}
} else if (Game.UpgradesById[g].type == 'upgrade' &&
Game.UpgradesById[g].getPrice() < moneyCanSpend &&
Game.UpgradesById[g].pool != 'toggle' && (!isSpecialTech || options.options.buyInfernalUpgrades))
{
interest = Game.UpgradesById[g].getPrice() / moneyCanSpend * 1000;
if (typeof priorityListObj[Math.floor(interest)] === 'undefined') {
pp = moneyCanSpend / Game.UpgradesById[g].getPrice(); // percent of cheapness
if (pp > 50) interest /= pp * 50;
priorityListObj[Math.floor(interest)] = {
name: Game.UpgradesById[g].name,
title: Game.UpgradesById[g].name + ' - ' + Beautify(Game.UpgradesById[g].getPrice()),
price: Game.UpgradesById[g].getPrice(),
cps: 1,
type: 'upgrade',
id: g,
income: 0
};
}
}
//priorityList.push(Game.UpgradesById[g].name + ' - ' + Beautify(Game.UpgradesById[g].basePrice) + ' (INTEREST: ' + Beautify(interest) + ')');
}
}
for (var i in Game.ObjectsById) {
if (typeof i !== 'undefined' && i != 'undefined' && Game.ObjectsById.hasOwnProperty(i)) {
if (Game.ObjectsById[i].locked === 0) {
var cps = (Game.ObjectsById[i].storedTotalCps / Game.ObjectsById[i].amount) * Game.globalCpsMult / buffMult;
interest = Game.ObjectsById[i].price / cps;
var pp = moneyCanSpend / Game.ObjectsById[i].price; // percent of cheapness
if (pp > 50) interest /= pp * 50;
if (isNaN(Math.floor(interest)) && Game.ObjectsById[i].price < moneyCanSpend) interest = 0;
priorityListObj[Math.floor(interest)] = {
name: Game.ObjectsById[i].name,
title: Game.ObjectsById[i].name + ' - ' + Beautify(Game.ObjectsById[i].price),
price: Game.ObjectsById[i].price,
cps: cps,
type: 'buy',
id: i,
income: cps
};
//priorityList.push(Game.ObjectsById[i].name + ' - ' + Beautify(Game.ObjectsById[i].price) + ' (INTEREST: ' + Beautify(interest) + ')');
}
}
}
for (i in priorityListObj) {
var prefix = priorityListObj[i].price < moneyCanSpend ? '!!! ' : (priorityListObj[i].price < money ? '! ' : '');
var pp = Math.floor(moneyCanSpend / priorityListObj[i].price * 100);
priorityList.push(prefix + priorityListObj[i].title + ' : ' + i + ' (' + pp + '%)');
}
timeCompensateObj = {};
timeCompensateList = [];
for (i in priorityListObj) {
var o = priorityListObj[i];
if (o.type == 'buy') {
var cpsWithPercent = (o.cps / _getNormalCookiesPs() + 1) * o.cps;
var interestNew = o.price / cpsWithPercent;
timeCompensateObj[Math.floor(interestNew)] = {
name: o.name,
title: o.title,
price: o.price,
cps: cpsWithPercent,
type: 'buy',
id: o.id,
income: o.income
};
} else {
timeCompensateObj[i] = o;
}
}
for (i in timeCompensateObj) {
prefix = timeCompensateObj[i].price < moneyCanSpend ? '!!! ' : (timeCompensateObj[i].price < money ? '! ' : '');
timeCompensateList.push(prefix + timeCompensateObj[i].title + ' : ' + i);
}
};
var _caption = function(txt) {
var $v = jQuery('#versionNumber');
if ($v.text() != txt) $v.text(txt);
};
var _title = function(txt) {
var newTitle = (newLogs > 0 ? '(' + newLogs + ') ' : '') + txt;
if (document.title != newTitle) {
oldTitle = txt;
document.title = newTitle;
}
};
var _titlePercent = function(have, need, txt) {
var percent = Math.ceil(have / (need !== 0 ? need : 1) * 100);
_title(String(percent) + "% - " + txt);
};
var _logSectionTitle = function (text) {
return '
' + text + '
';
};
var _logSection = function (title, items) {
return '
' + _logSectionTitle(title) +
'
' + items.join('
') + '
' +
'
';
};
var clearLogButton = '';
var killWrinklersButton = '';
var _logPriorityTable = function() {
var moneyCanSpend = _getMoneyCanSpend();
var styles = '';
var t = '
Type
Name
Price
Interest
Income
% bank
';
for (i in priorityListObj) {
var o = priorityListObj[i];
var pp = Math.floor(moneyCanSpend / o.price * 100);
t += '