Skip to content

Commit

Permalink
Fixed for Version 2.021 of Cookie Clicker (Issues #257, #259, and #265)
Browse files Browse the repository at this point in the history
  • Loading branch information
Aktanusa committed Oct 7, 2019
1 parent 108a0d8 commit cb4b85a
Show file tree
Hide file tree
Showing 5 changed files with 178 additions and 64 deletions.
121 changes: 89 additions & 32 deletions CookieMonster.js
Original file line number Diff line number Diff line change
Expand Up @@ -39,8 +39,8 @@ CM.Cache.NextNumber = function(base) {

CM.Cache.RemakeBuildingsPrices = function() {
for (var i in Game.Objects) {
CM.Cache.Objects10[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 10);
CM.Cache.Objects100[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 100);
CM.Cache.Objects10[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 10);
CM.Cache.Objects100[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 100);
}
}

Expand Down Expand Up @@ -223,29 +223,41 @@ CM.Cache.RemakeSeaSpec = function() {
}

CM.Cache.RemakeSellForChoEgg = function() {
if (Game.hasAura('Earth Shatterer') || Game.dragonLevel < 9) {
if (Game.auraMult('Earth Shatterer') == 1.1) {
var sellTotal = 0;
for (var i in Game.Objects) {
var me = Game.Objects[i];
sellTotal += CM.Sim.BuildingSell(me.basePrice, me.amount, me.free, me.amount, 0);
sellTotal += CM.Sim.BuildingSell(me, me.basePrice, me.amount, me.free, me.amount, 0);
}
}
else {
var highestBuilding = '';
for (var i in Game.Objects) {
if (Game.Objects[i].amount > 0) highestBuilding = i;
}
var secondHighBuild = '';
if (Game.auraMult('Earth Shatterer') == 0 && highestBuilding != '') {
if (Game.Objects[highestBuilding].amount > 1) {
secondHighBuild = highestBuilding;
}
else {
for (var i in Game.Objects) {
if (i != highestBuilding && Game.Objects[i].amount > 0) secondHighBuild = i;
}
}
}

var sellTotal = 0;
for (var i in Game.Objects) {
var me = Game.Objects[i];
var amount = 0;
var amount = me.amount;
if (i == highestBuilding) {
amount = me.amount - 1;
amount -= 1;
}
else {
amount = me.amount;
if (i == secondHighBuild) {
amount -= 1;
}
sellTotal += CM.Sim.BuildingSell(me.basePrice, amount, me.free, amount, 1);
sellTotal += CM.Sim.BuildingSell(me, me.basePrice, amount, me.free, amount, 1);
}
}
CM.Cache.SellForChoEgg = sellTotal;
Expand Down Expand Up @@ -377,7 +389,7 @@ CM.Cache.ChainFrenzyWrathReward = 0;
CM.Cache.CentEgg = 0;
CM.Cache.SellForChoEgg = 0;
CM.Cache.Title = '';
CM.Cache.HadFierHoard = false;
CM.Cache.HadBuildAura = false;
CM.Cache.RealCookiesEarned = -1;
CM.Cache.lastDate = -1;
CM.Cache.lastCookies = -1;
Expand Down Expand Up @@ -1812,11 +1824,16 @@ CM.Disp.AddMenuStats = function(title) {
var luckyRewardFrenzyMaxWrath = CM.Cache.LuckyRewardFrenzy;
var luckyCur = luckyCurBase;
var luckyCurWrath = luckyCurBase;
// Old way
if (Game.hasAura('Ancestral Metamorphosis')) {
luckyRewardMax *= 1.1;
luckyRewardFrenzyMax *= 1.1;
luckyCur *= 1.1;
}
/*luckyRewardMax *= 1 + Game.auraMult('Ancestral Metamorphosis') * 0.1;
luckyRewardFrenzyMax *= 1 + Game.auraMult('Ancestral Metamorphosis') * 0.1;
luckyCur *= 1 + Game.auraMult('Ancestral Metamorphosis') * 0.1;*/
// Old way
if (Game.hasAura('Unholy Dominion')) {
luckyRewardMaxWrath *= 1.1;
luckyRewardFrenzyMaxWrath *= 1.1;
Expand Down Expand Up @@ -2242,7 +2259,7 @@ CM.Disp.Tooltip = function(type, name) {
if (type == 'b') {
l('tooltip').innerHTML = Game.Objects[name].tooltip();
if (CM.Config.TooltipAmor == 1) {
var buildPrice = CM.Sim.BuildingGetPrice(Game.Objects[name].basePrice, 0, Game.Objects[name].free, Game.Objects[name].amount);
var buildPrice = CM.Sim.BuildingGetPrice(Game.Objects[name], Game.Objects[name].basePrice, 0, Game.Objects[name].free, Game.Objects[name].amount);
var amortizeAmount = buildPrice - Game.Objects[name].totalCookies;
if (amortizeAmount > 0) {
l('tooltip').innerHTML = l('tooltip').innerHTML
Expand All @@ -2267,10 +2284,10 @@ CM.Disp.Tooltip = function(type, name) {
}
else if (Game.buyMode == -1) {
if (Game.buyBulk == -1) {
l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join('-' + Beautify(CM.Sim.BuildingSell(Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].free, Game.Objects[name].amount, 0)));
l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join('-' + Beautify(CM.Sim.BuildingSell(Game.Objects[name], Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].free, Game.Objects[name].amount, 0)));
}
else {
l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join('-' + Beautify(CM.Sim.BuildingSell(Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].free, Game.buyBulk, 0)));
l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].getPrice())).join('-' + Beautify(CM.Sim.BuildingSell(Game.Objects[name], Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].free, Game.buyBulk, 0)));
}
}
}
Expand Down Expand Up @@ -2627,11 +2644,11 @@ for (var i in Game.wrinklers) {

CM.Disp.TooltipText = [
['GoldCookTooltipPlaceholder', 'Calculated with Golden Switch off', '200px'],
['PrestMaxTooltipPlaceholder', 'The MAX prestige is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all buildings with Earth Shatterer aura, and buying Chocolate egg', '380px'],
['PrestMaxTooltipPlaceholder', 'The MAX prestige is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all buildings with Earth Shatterer and Reality Bending auras, and buying Chocolate egg', '320px'],
['NextPrestTooltipPlaceholder', 'Calculated with cookies gained from wrinklers and Chocolate egg', '200px'],
['HeavenChipMaxTooltipPlaceholder', 'The MAX heavenly chips is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all buildings with Earth Shatterer aura, and buying Chocolate egg', '390px'],
['HeavenChipMaxTooltipPlaceholder', 'The MAX heavenly chips is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all buildings with Earth Shatterer and Reality Bending auras, and buying Chocolate egg', '330px'],
['ResetTooltipPlaceholder', 'The bonus income you would get from new prestige levels unlocked at 100% of its potential and from reset achievements if you have the same buildings/upgrades after reset', '370px'],
['ChoEggTooltipPlaceholder', 'The amount of cookies you would get from popping all wrinklers with Skruuia god in Diamond slot, selling all buildings with Earth Shatterer aura, and then buying Chocolate egg', '280px']
['ChoEggTooltipPlaceholder', 'The amount of cookies you would get from popping all wrinklers with Skruuia god in Diamond slot, selling all buildings with Earth Shatterer and Reality Bending auras, and then buying Chocolate egg', '300px']
];

/********
Expand Down Expand Up @@ -2778,13 +2795,13 @@ CM.Loop = function() {
}

// Check for aura change to recalculate buildings prices
var hasFierHoard = Game.hasAura('Fierce Hoarder');
if (!CM.Cache.HadFierHoard && hasFierHoard) {
CM.Cache.HadFierHoard = true;
var hasBuildAura = Game.auraMult('Fierce Hoarder') > 0;
if (!CM.Cache.HadBuildAura && hasBuildAura) {
CM.Cache.HadBuildAura = true;
CM.Cache.DoRemakeBuildPrices = 1;
}
else if (CM.Cache.HadFierHoard && !hasFierHoard) {
CM.Cache.HadFierHoard = false;
else if (CM.Cache.HadBuildAura && !hasBuildAura) {
CM.Cache.HadBuildAura = false;
CM.Cache.DoRemakeBuildPrices = 1;
}

Expand Down Expand Up @@ -2935,7 +2952,7 @@ CM.VersionMinor = '1';
* Sim *
*******/

CM.Sim.BuildingGetPrice = function(basePrice, start, free, increase) {
CM.Sim.BuildingGetPrice = function(build, basePrice, start, free, increase) {
/*var price=0;
for (var i = Math.max(0 , start); i < Math.max(0, start + increase); i++) {
price += basePrice * Math.pow(Game.priceIncrease, Math.max(0, i - free));
Expand All @@ -2950,15 +2967,15 @@ CM.Sim.BuildingGetPrice = function(basePrice, start, free, increase) {
var moni = 0;
for (var i = 0; i < increase; i++) {
var price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free));
price = Game.modifyBuildingPrice(null, price);
price = Game.modifyBuildingPrice(build, price);
price = Math.ceil(price);
moni += price;
start++;
}
return moni;
}

CM.Sim.BuildingSell = function(basePrice, start, free, amount, emuAura) {
CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, emuAura) {
/*var price=0;
for (var i = Math.max(0, start - amount); i < Math.max(0, start); i++) {
price += basePrice * Math.pow(Game.priceIncrease, Math.max(0, i - free));
Expand All @@ -2979,10 +2996,15 @@ CM.Sim.BuildingSell = function(basePrice, start, free, amount, emuAura) {
var moni=0;
for (var i = 0; i < amount; i++) {
var price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free));
price = Game.modifyBuildingPrice(null, price);
price = Game.modifyBuildingPrice(build, price);
price = Math.ceil(price);
var giveBack = 0.25;
if (Game.hasAura('Earth Shatterer') || emuAura) giveBack = 0.5;
if (emuAura) {
giveBack = 0.5;
}
else {
giveBack *= 1 + Game.auraMult('Earth Shatterer');
}
price = Math.floor(price * giveBack);
if (start > 0) {
moni += price;
Expand All @@ -3009,7 +3031,7 @@ CM.Sim.Win = function(what) {

eval('CM.Sim.HasAchiev = ' + Game.HasAchiev.toString().split('Game').join('CM.Sim'));

eval('CM.Sim.GetHeavenlyMultiplier = ' + Game.GetHeavenlyMultiplier.toString().split('Game.Has').join('CM.Sim.Has').split('Game.hasAura').join('CM.Sim.hasAura'));
eval('CM.Sim.GetHeavenlyMultiplier = ' + Game.GetHeavenlyMultiplier.toString().split('Game.Has').join('CM.Sim.Has').split('Game.hasAura').join('CM.Sim.hasAura').split('Game.auraMult').join('CM.Sim.auraMult'));

CM.Sim.hasAura = function(what) {
if (Game.dragonAuras[CM.Sim.dragonAura].name == what || Game.dragonAuras[CM.Sim.dragonAura2].name == what)
Expand All @@ -3018,6 +3040,15 @@ CM.Sim.hasAura = function(what) {
return false;
}

CM.Sim.auraMult = function(what) {
var n = 0;
if (Game.dragonAuras[CM.Sim.dragonAura].name == what || Game.dragonAuras[CM.Sim.dragonAura2].name == what)
n = 1;
if (Game.dragonAuras[CM.Sim.dragonAura].name == 'Reality Bending' || Game.dragonAuras[CM.Sim.dragonAura2].name == 'Reality Bending')
n += 0.1;
return n;
}

eval('CM.Sim.GetTieredCpsMult = ' + Game.GetTieredCpsMult.toString()
.split('Game.Has').join('CM.Sim.Has')
.split('me.tieredUpgrades').join('Game.Objects[me.name].tieredUpgrades')
Expand All @@ -3027,6 +3058,7 @@ eval('CM.Sim.GetTieredCpsMult = ' + Game.GetTieredCpsMult.toString()
.split('me.grandma').join('Game.Objects[me.name].grandma')
.split('me.id').join('Game.Objects[me.name].id')
.split('Game.Objects[\'Grandma\']').join('CM.Sim.Objects[\'Grandma\']')
.split('me.fortune').join('Game.Objects[me.name].fortune')
);

CM.Sim.getCPSBuffMult = function() {
Expand All @@ -3044,7 +3076,13 @@ CM.Sim.InitData = function() {
CM.Sim.Objects[i] = {};
var me = Game.Objects[i];
var you = CM.Sim.Objects[i];
eval('you.cps = ' + me.cps.toString().split('Game.Has').join('CM.Sim.Has').split('Game.hasAura').join('CM.Sim.hasAura').split('Game.Objects').join('CM.Sim.Objects').split('Game.GetTieredCpsMult').join('CM.Sim.GetTieredCpsMult'));
eval('you.cps = ' + me.cps.toString()
.split('Game.Has').join('CM.Sim.Has')
.split('Game.hasAura').join('CM.Sim.hasAura')
.split('Game.Objects').join('CM.Sim.Objects')
.split('Game.GetTieredCpsMult').join('CM.Sim.GetTieredCpsMult')
.split('Game.auraMult').join('CM.Sim.auraMult')
);
// Below is needed for above eval!
you.baseCps = me.baseCps;
you.name = me.name;
Expand Down Expand Up @@ -3129,6 +3167,9 @@ CM.Sim.CalculateGains = function() {
if (CM.Sim.Has('An itchy sweater')) mult *= 1.01;
if (CM.Sim.Has('Santa\'s dominion')) mult *= 1.2;

if (CM.Sim.Has('Fortune #100')) mult *= 1.01;
if (CM.Sim.Has('Fortune #101')) mult *= 1.07;

var buildMult = 1;
if (Game.hasGod) {
var godLvl = Game.hasGod('asceticism');
Expand Down Expand Up @@ -3170,7 +3211,8 @@ CM.Sim.CalculateGains = function() {

var milkMult=1;
if (CM.Sim.Has('Santa\'s milk and cookies')) milkMult *= 1.05;
if (CM.Sim.hasAura('Breath of Milk')) milkMult *= 1.05;
//if (CM.Sim.hasAura('Breath of Milk')) milkMult *= 1.05;
milkMult *= 1 + CM.Sim.auraMult('Breath of Milk') * 0.05;
if (Game.hasGod) {
var godLvl = Game.hasGod('mother');
if (godLvl == 1) milkMult *= 1.1;
Expand All @@ -3194,7 +3236,9 @@ CM.Sim.CalculateGains = function() {
if (CM.Sim.Has('Kitten assistants to the regional manager')) catMult *= (1 + (CM.Sim.AchievementsOwned / 25) * 0.175 * milkMult);
if (CM.Sim.Has('Kitten marketeers')) catMult *= (1 + (CM.Sim.AchievementsOwned / 25) * 0.15 * milkMult);
if (CM.Sim.Has('Kitten analysts')) catMult *= (1 + (CM.Sim.AchievementsOwned / 25) * 0.125 * milkMult);
if (CM.Sim.Has('Kitten executives')) catMult *= (1 + (CM.Sim.AchievementsOwned / 25) * 0.115 * milkMult);
if (CM.Sim.Has('Kitten angels')) catMult *= (1 + (CM.Sim.AchievementsOwned / 25) * 0.1 * milkMult);
if (CM.Sim.Has('Fortune #103')) catMult *= (1 + (CM.Sim.AchievementsOwned / 25) * 0.05 * milkMult);

mult *= catMult;

Expand Down Expand Up @@ -3223,12 +3267,14 @@ CM.Sim.CalculateGains = function() {
// TODO Store lumps?
if (CM.Sim.Has('Sugar baking')) mult *= (1 + Math.min(100, Game.lumps) * 0.01);

if (CM.Sim.hasAura('Radiant Appetite')) mult *= 2;
//if (CM.Sim.hasAura('Radiant Appetite')) mult *= 2;
mult *= 1 + CM.Sim.auraMult('Radiant Appetite');

if (Game.hasAura('Dragon\'s Fortune')) {
if (true) { // || CM.Sim.hasAura('Dragon\'s Fortune')) {
var n = Game.shimmerTypes['golden'].n;
var auraMult = CM.Sim.auraMult('Dragon\'s Fortune');
for (var i = 0; i < n; i++) {
mult *= 2.23;
mult *= 1 + auraMult * 1.23;
}
}

Expand Down Expand Up @@ -3333,6 +3379,15 @@ CM.Sim.CheckOtherAchiev = function() {
if (!CM.Sim.Has(CM.Data.ChristCookies[i])) hasAllChristCook = false;
}
if (hasAllChristCook) CM.Sim.Win('Let it snow');

if (CM.Sim.Has('Fortune cookies')) {
var list = Game.Tiers['fortune'].upgrades;
var fortunes = 0;
for (var i in list) {
if (CM.Sim.Has(list[i].name)) fortunes++;
}
if (fortunes >= list.length) CM.Sim.Win('O Fortuna');
}
}

CM.Sim.BuyBuildings = function(amount, target) {
Expand Down Expand Up @@ -3465,6 +3520,8 @@ CM.Sim.ResetBonus = function(possiblePresMax) {
if (CM.Cache.RealCookiesEarned >= 1000000000000000000000000000000000000000000) CM.Sim.Win('The end of the world');
if (CM.Cache.RealCookiesEarned >= 1000000000000000000000000000000000000000000000) CM.Sim.Win('Oh, you\'re back');
if (CM.Cache.RealCookiesEarned >= 1000000000000000000000000000000000000000000000000) CM.Sim.Win('Lazarus');
if (CM.Cache.RealCookiesEarned >= 1000000000000000000000000000000000000000000000000000) CM.Sim.Win('Smurf account');
if (CM.Cache.RealCookiesEarned >= 1000000000000000000000000000000000000000000000000000000) CM.Sim.Win('If at first you don\'t succeed');

CM.Sim.Upgrades['Heavenly chip secret'].bought = 1;
CM.Sim.Upgrades['Heavenly cookie stand'].bought = 1;
Expand Down
32 changes: 22 additions & 10 deletions src/Cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,8 +19,8 @@ CM.Cache.NextNumber = function(base) {

CM.Cache.RemakeBuildingsPrices = function() {
for (var i in Game.Objects) {
CM.Cache.Objects10[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 10);
CM.Cache.Objects100[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 100);
CM.Cache.Objects10[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 10);
CM.Cache.Objects100[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 100);
}
}

Expand Down Expand Up @@ -203,29 +203,41 @@ CM.Cache.RemakeSeaSpec = function() {
}

CM.Cache.RemakeSellForChoEgg = function() {
if (Game.hasAura('Earth Shatterer') || Game.dragonLevel < 9) {
if (Game.auraMult('Earth Shatterer') == 1.1) {
var sellTotal = 0;
for (var i in Game.Objects) {
var me = Game.Objects[i];
sellTotal += CM.Sim.BuildingSell(me.basePrice, me.amount, me.free, me.amount, 0);
sellTotal += CM.Sim.BuildingSell(me, me.basePrice, me.amount, me.free, me.amount, 0);
}
}
else {
var highestBuilding = '';
for (var i in Game.Objects) {
if (Game.Objects[i].amount > 0) highestBuilding = i;
}
var secondHighBuild = '';
if (Game.auraMult('Earth Shatterer') == 0 && highestBuilding != '') {
if (Game.Objects[highestBuilding].amount > 1) {
secondHighBuild = highestBuilding;
}
else {
for (var i in Game.Objects) {
if (i != highestBuilding && Game.Objects[i].amount > 0) secondHighBuild = i;
}
}
}

var sellTotal = 0;
for (var i in Game.Objects) {
var me = Game.Objects[i];
var amount = 0;
var amount = me.amount;
if (i == highestBuilding) {
amount = me.amount - 1;
amount -= 1;
}
else {
amount = me.amount;
if (i == secondHighBuild) {
amount -= 1;
}
sellTotal += CM.Sim.BuildingSell(me.basePrice, amount, me.free, amount, 1);
sellTotal += CM.Sim.BuildingSell(me, me.basePrice, amount, me.free, amount, 1);
}
}
CM.Cache.SellForChoEgg = sellTotal;
Expand Down Expand Up @@ -357,7 +369,7 @@ CM.Cache.ChainFrenzyWrathReward = 0;
CM.Cache.CentEgg = 0;
CM.Cache.SellForChoEgg = 0;
CM.Cache.Title = '';
CM.Cache.HadFierHoard = false;
CM.Cache.HadBuildAura = false;
CM.Cache.RealCookiesEarned = -1;
CM.Cache.lastDate = -1;
CM.Cache.lastCookies = -1;
Expand Down
Loading

0 comments on commit cb4b85a

Please sign in to comment.