Merge pull request #542 from DanielNoord/jshint

Jshint
This commit is contained in:
DanielNoord
2021-01-31 14:07:35 +01:00
committed by GitHub
10 changed files with 1258 additions and 1228 deletions

26
.eslintrc.js Normal file
View File

@@ -0,0 +1,26 @@
module.exports = {
"env": {
"browser": true,
"es2021": true
},
"globals": {
"module": "readonly",
"CM": "writable",
"Game": "writable",
"l": "readonly",
"b64_to_utf8": "readonly",
"utf8_to_b64": "readonly",
"Beautify": "writable",
"realAudio": "readonly",
"JSColor": "readonly",
"jscolor": "readonly",
"BeautifyAll": "readonly",
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 12
},
"rules": {
}
};

File diff suppressed because it is too large Load Diff

View File

@@ -16,7 +16,7 @@ CM.Cache.InitCache = function() {
CM.Cache.CacheWrinklers();
CM.Cache.CacheStats();
CM.Cache.CacheMissingUpgrades();
}
};
/********
* Section: Functions related to Dragon Auras */
@@ -32,7 +32,7 @@ CM.Cache.CacheDragonAuras = function() {
/** @global */
CM.Cache.dragonAura = Game.dragonAura;
CM.Cache.dragonAura2 = Game.dragonAura2;
}
};
/********
* Section: Functions related to Wrinklers */
@@ -48,7 +48,7 @@ CM.Cache.CacheWrinklers = function() {
CM.Cache.WrinklersTotal = 0;
CM.Cache.WrinklersNormal = 0;
CM.Cache.WrinklersFattest = [0, null];
for (var i in Game.wrinklers) {
for (let i; i < Game.wrinklers.length; i++) {
var sucked = Game.wrinklers[i].sucked;
var toSuck = 1.1;
if (Game.Has('Sacrilegious corruption')) toSuck *= 1.05;
@@ -67,7 +67,7 @@ CM.Cache.CacheWrinklers = function() {
if (sucked > CM.Cache.WrinklersFattest[0]) CM.Cache.WrinklersFattest = [sucked, i];
}
}
}
};
/********
* Section: Functions related to Caching stats */
@@ -102,15 +102,15 @@ CM.Cache.CacheStats = function() {
CM.Cache.LuckyWrathRewardFrenzy = wrathMult * (CM.Cache.LuckyFrenzy * 0.15) + 13;
CM.Cache.Conjure = CM.Cache.Lucky * 2;
CM.Cache.ConjureReward = CM.Cache.Conjure * 0.15;
CM.Cache.Edifice = 0;
var max = 0;
var n = 0;
for (var i in Game.Objects) {
for (let i of Object.keys(Game.Objects)) {
if (Game.Objects[i].amount > max) max = Game.Objects[i].amount;
if (Game.Objects[i].amount > 0) n++;
}
for (var i in Game.Objects) {
for (let i of Object.keys(Game.Objects)) {
if ((Game.Objects[i].amount < max || n == 1) &&
Game.Objects[i].amount < 400 &&
Game.Objects[i].price * 2 > CM.Cache.Edifice) {
@@ -118,7 +118,7 @@ CM.Cache.CacheStats = function() {
CM.Cache.EdificeBuilding = i;
}
}
}
};
/**
* This functions caches variables related to missing upgrades
@@ -133,17 +133,17 @@ CM.Cache.CacheMissingUpgrades = function() {
CM.Cache.MissingUpgradesPrestige = "";
var list = [];
//sort the upgrades
for (var i in Game.Upgrades) {
for (let i of Object.keys(Game.Upgrades)) {
list.push(Game.Upgrades[i]);
}
var sortMap = function(a, b) {
if (a.order>b.order) return 1;
else if (a.order<b.order) return -1;
else return 0;
}
};
list.sort(sortMap);
for (var i in list) {
for (let i of Object.keys(list)) {
var me = list[i];
if (me.bought == 0) {
@@ -155,7 +155,7 @@ CM.Cache.CacheMissingUpgrades = function() {
else if (me.pool != 'toggle' && me.pool != 'unused' && me.pool != 'debug') CM.Cache.MissingUpgrades += str;
}
}
}
};
/********
* Section: Functions related to Caching CPS */
@@ -171,7 +171,7 @@ CM.Cache.CacheMissingUpgrades = function() {
class CMAvgQueue {
constructor(maxLength) {
this.maxLength = maxLength;
this.queue = []
this.queue = [];
}
addLatest (newValue) {
@@ -182,10 +182,10 @@ class CMAvgQueue {
// TODO: Might want to do this according to "https://stackoverflow.com/questions/10359907/how-to-compute-the-sum-and-average-of-elements-in-an-array"
calcAverage (timePeriod) {
if (timePeriod > this.maxLength) timePeriod = this.maxLength, console.log("Called for average of Queue for time-period longer than MaxLength");
if (timePeriod > this.maxLength) timePeriod = this.maxLength;
if (timePeriod > this.queue.length) timePeriod = this.queue.length;
var ret = 0
for (var i = this.queue.length - 1; i >= 0 && i > this.queue.length - 1 - timePeriod; i--) {
var ret = 0;
for (let i = this.queue.length - 1; i >= 0 && i > this.queue.length - 1 - timePeriod; i--) {
ret += this.queue[i];
}
return ret / timePeriod;
@@ -202,7 +202,7 @@ CM.Cache.InitCookiesDiff = function() {
CM.Cache.WrinkFattestDiff = new CMAvgQueue(CM.Disp.cookieTimes[CM.Disp.cookieTimes.length - 1]);
CM.Cache.ChoEggDiff = new CMAvgQueue(CM.Disp.cookieTimes[CM.Disp.cookieTimes.length - 1]);
CM.Cache.ClicksDiff = new CMAvgQueue(CM.Disp.clickTimes[CM.Disp.clickTimes.length - 1]);
}
};
/**
* This functions caches two variables related average CPS and Clicks
@@ -223,13 +223,13 @@ CM.Cache.UpdateAvgCPS = function() {
choEggTotal *= 0.05;
if (CM.Cache.lastDate != -1) {
var timeDiff = currDate - CM.Cache.lastDate
var timeDiff = currDate - CM.Cache.lastDate;
var bankDiffAvg = Math.max(0, (Game.cookies - CM.Cache.lastCookies)) / timeDiff;
var wrinkDiffAvg = Math.max(0, (CM.Cache.WrinklersTotal - CM.Cache.lastWrinkCookies)) / timeDiff;
var wrinkFattestDiffAvg = Math.max(0, (CM.Cache.WrinklersFattest[0] - CM.Cache.lastWrinkFattestCookies)) / timeDiff;
var choEggDiffAvg = Math.max(0,(choEggTotal - CM.Cache.lastChoEgg)) / timeDiff;
var clicksDiffAvg = (Game.cookieClicks - CM.Cache.lastClicks) / timeDiff;
for (var i = 0; i < timeDiff; i++) {
for (let i = 0; i < timeDiff; i++) {
CM.Cache.CookiesDiff.addLatest(bankDiffAvg);
CM.Cache.WrinkDiff.addLatest(wrinkDiffAvg);
CM.Cache.WrinkFattestDiff.addLatest(wrinkFattestDiffAvg);
@@ -251,7 +251,7 @@ CM.Cache.UpdateAvgCPS = function() {
CM.Cache.AverageGainWrinkFattest = CM.Cache.WrinkFattestDiff.calcAverage(cpsLength);
CM.Cache.AverageGainChoEgg = CM.Cache.ChoEggDiff.calcAverage(cpsLength);
CM.Cache.AvgCPS = CM.Cache.AverageGainBank
CM.Cache.AvgCPS = CM.Cache.AverageGainBank;
if (CM.Options.CalcWrink == 1) CM.Cache.AvgCPS += CM.Cache.AverageGainWrink;
if (CM.Options.CalcWrink == 2) CM.Cache.AvgCPS += CM.Cache.AverageGainWrinkFattest;
@@ -265,7 +265,7 @@ CM.Cache.UpdateAvgCPS = function() {
CM.Cache.AverageClicks = CM.Cache.ClicksDiff.calcAverage(CM.Disp.clickTimes[CM.Options.AvgClicksHist]);
}
}
};
/**
* This functions caches the current Wrinkler CPS multiplier
@@ -277,7 +277,7 @@ CM.Cache.UpdateCurrWrinklerCPS = function() {
CM.Cache.CurrWrinklerCPSMult = 0;
let count = 0;
for (let i in Game.wrinklers) {
if (Game.wrinklers[i].phase == 2) count++
if (Game.wrinklers[i].phase == 2) count++;
}
let godMult = 1;
if (CM.Sim.Objects.Temple.minigameLoaded) {
@@ -288,7 +288,7 @@ CM.Cache.UpdateCurrWrinklerCPS = function() {
}
CM.Cache.CurrWrinklerCount = count;
CM.Cache.CurrWrinklerCPSMult = count * (count * 0.05 * 1.1) * (Game.Has('Sacrilegious corruption') * 0.05 + 1) * (Game.Has('Wrinklerspawn') * 0.05 + 1) * godMult;
}
};
/********
* Section: Functions related to "Specials" (Dragon and Santa) */
@@ -305,15 +305,15 @@ CM.Cache.CacheDragonCost = function() {
var target = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/Objects\[(.*)\]/)[1];
var amount = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/sacrifice\((.*?)\)/)[1];
if (target != "i") {
target = target.replaceAll("\'", "");
target = target.replaceAll("'", "");
if (Game.Objects[target].amount < amount) {
CM.Cache.CostDragonUpgrade = "Not enough buildings to sell";
}
else {
var cost = 0;
let cost = 0;
CM.Sim.CopyData();
for (var i = 0; i < amount; i++) {
var price = CM.Sim.Objects[target].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free));
for (let i = 0; i < amount; i++) {
let price = CM.Sim.Objects[target].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free));
price = Game.modifyBuildingPrice(CM.Sim.Objects[target], price);
price = Math.ceil(price);
cost += price;
@@ -323,17 +323,17 @@ CM.Cache.CacheDragonCost = function() {
}
}
else {
var cost = 0;
let cost = 0;
CM.Sim.CopyData();
for (var j in Game.Objects) {
for (let j of Object.keys(Game.Objects)) {
target = j;
if (Game.Objects[target].amount < amount) {
CM.Cache.CostDragonUpgrade = "Not enough buildings to sell";
break
break;
}
else {
for (var i = 0; i < amount; i++) {
var price = CM.Sim.Objects[target].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free));
for (let i = 0; i < amount; i++) {
let price = CM.Sim.Objects[target].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free));
price = Game.modifyBuildingPrice(CM.Sim.Objects[target], price);
price = Math.ceil(price);
cost += price;
@@ -346,8 +346,8 @@ CM.Cache.CacheDragonCost = function() {
}
CM.Cache.lastDragonLevel = Game.dragonLevel;
}
}
};
/********
* Section: UNSORTED */
@@ -357,15 +357,15 @@ CM.Cache.NextNumber = function(base) {
count = CM.Cache.NextNumber(count);
}
return (base + count);
}
};
CM.Cache.RemakeBuildingsPrices = function() {
for (var i in Game.Objects) {
for (let i of Object.keys(Game.Objects)) {
CM.Cache.Objects[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 1);
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);
}
}
};
CM.Cache.RemakeIncome = function() {
// Simulate Building Buys for 1 amount
@@ -379,7 +379,7 @@ CM.Cache.RemakeIncome = function() {
// Simulate Building Buys for 100 amount
CM.Sim.BuyBuildings(100, 'Objects100');
}
};
CM.Cache.RemakeBuildingsPP = function() {
CM.Cache.min = -1;
@@ -387,7 +387,7 @@ CM.Cache.RemakeBuildingsPP = function() {
CM.Cache.mid = -1;
// Calculate PP and colors when compared to purchase of single optimal building
if (CM.Options.ColorPPBulkMode == 0) {
for (var i in CM.Cache.Objects) {
for (let i of Object.keys(CM.Cache.Objects)) {
//CM.Cache.Objects[i].pp = Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus;
if (Game.cookiesPs) {
CM.Cache.Objects[i].pp = (Math.max(Game.Objects[i].getPrice() - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus);
@@ -398,8 +398,8 @@ CM.Cache.RemakeBuildingsPP = function() {
if (CM.Cache.max == -1 || CM.Cache.Objects[i].pp > CM.Cache.max) CM.Cache.max = CM.Cache.Objects[i].pp;
}
CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min;
for (var i in CM.Cache.Objects) {
var color = '';
for (let i of Object.keys(CM.Cache.Objects)) {
let color = '';
if (CM.Cache.Objects[i].pp == CM.Cache.min) color = CM.Disp.colorGreen;
else if (CM.Cache.Objects[i].pp == CM.Cache.max) color = CM.Disp.colorRed;
else if (CM.Cache.Objects[i].pp > CM.Cache.mid) color = CM.Disp.colorOrange;
@@ -415,7 +415,7 @@ CM.Cache.RemakeBuildingsPP = function() {
// Calculate PP and colors when compared to purchase of selected bulk mode
else {
if (Game.buyBulk == 1) {
for (var i in CM.Cache.Objects) {
for (let i of Object.keys(CM.Cache.Objects)) {
//CM.Cache.Objects[i].pp = Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus;
if (Game.cookiesPs) {
CM.Cache.Objects[i].pp = (Math.max(Game.Objects[i].getPrice() - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].getPrice() / CM.Cache.Objects[i].bonus);
@@ -426,8 +426,8 @@ CM.Cache.RemakeBuildingsPP = function() {
if (CM.Cache.max == -1 || CM.Cache.Objects[i].pp > CM.Cache.max) CM.Cache.max = CM.Cache.Objects[i].pp;
}
CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min;
for (var i in CM.Cache.Objects) {
var color = '';
for (let i of Object.keys(CM.Cache.Objects)) {
let color = '';
if (CM.Cache.Objects[i].pp == CM.Cache.min) color = CM.Disp.colorGreen;
else if (CM.Cache.Objects[i].pp == CM.Cache.max) color = CM.Disp.colorRed;
else if (CM.Cache.Objects[i].pp > CM.Cache.mid) color = CM.Disp.colorOrange;
@@ -438,7 +438,7 @@ CM.Cache.RemakeBuildingsPP = function() {
CM.Cache.RemakeBuildingsOtherPP(100, 'Objects100');
}
else if (Game.buyBulk == 10) {
for (var i in CM.Cache.Objects) {
for (let i of Object.keys(CM.Cache.Objects)) {
if (Game.cookiesPs) {
CM.Cache.Objects10[i].pp = (Math.max(Game.Objects[i].bulkPrice - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].bulkPrice / CM.Cache.Objects10[i].bonus);
} else {
@@ -448,8 +448,8 @@ CM.Cache.RemakeBuildingsPP = function() {
if (CM.Cache.max == -1 || CM.Cache.Objects10[i].pp > CM.Cache.max) CM.Cache.max = CM.Cache.Objects10[i].pp;
}
CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min;
for (var i in CM.Cache.Objects) {
var color = '';
for (let i of Object.keys(CM.Cache.Objects)) {
let color = '';
if (CM.Cache.Objects10[i].pp == CM.Cache.min) color = CM.Disp.colorGreen;
else if (CM.Cache.Objects10[i].pp == CM.Cache.max) color = CM.Disp.colorRed;
else if (CM.Cache.Objects10[i].pp > CM.Cache.mid) color = CM.Disp.colorOrange;
@@ -460,7 +460,7 @@ CM.Cache.RemakeBuildingsPP = function() {
CM.Cache.RemakeBuildingsOtherPP(100, 'Objects100');
}
else if (Game.buyBulk == 100) {
for (var i in CM.Cache.Objects) {
for (let i of Object.keys(CM.Cache.Objects)) {
if (Game.cookiesPs) {
CM.Cache.Objects100[i].pp = (Math.max(Game.Objects[i].bulkPrice - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].bulkPrice / CM.Cache.Objects100[i].bonus);
} else {
@@ -470,8 +470,8 @@ CM.Cache.RemakeBuildingsPP = function() {
if (CM.Cache.max == -1 || CM.Cache.Objects100[i].pp > CM.Cache.max) CM.Cache.max = CM.Cache.Objects100[i].pp;
}
CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min;
for (var i in CM.Cache.Objects) {
var color = '';
for (let i of Object.keys(CM.Cache.Objects)) {
let color = '';
if (CM.Cache.Objects100[i].pp == CM.Cache.min) color = CM.Disp.colorGreen;
else if (CM.Cache.Objects100[i].pp == CM.Cache.max) color = CM.Disp.colorRed;
else if (CM.Cache.Objects100[i].pp > CM.Cache.mid) color = CM.Disp.colorOrange;
@@ -482,10 +482,10 @@ CM.Cache.RemakeBuildingsPP = function() {
CM.Cache.RemakeBuildingsOtherPP(10, 'Objects10');
}
}
}
};
CM.Cache.RemakeUpgradePP = function() {
for (var i in CM.Cache.Upgrades) {
for (let i of Object.keys(CM.Cache.Upgrades)) {
//CM.Cache.Upgrades[i].pp = Game.Upgrades[i].getPrice() / CM.Cache.Upgrades[i].bonus;
if (Game.cookiesPs) {
CM.Cache.Upgrades[i].pp = (Math.max(Game.Upgrades[i].getPrice() - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Upgrades[i].getPrice() / CM.Cache.Upgrades[i].bonus);
@@ -493,7 +493,7 @@ CM.Cache.RemakeUpgradePP = function() {
CM.Cache.Upgrades[i].pp = (Game.Upgrades[i].getPrice() / CM.Cache.Upgrades[i].bonus);
}
if (isNaN(CM.Cache.Upgrades[i].pp)) CM.Cache.Upgrades[i].pp = Infinity;
var color = '';
let color = '';
if (CM.Cache.Upgrades[i].pp <= 0 || CM.Cache.Upgrades[i].pp == Infinity) color = CM.Disp.colorGray;
else if (CM.Cache.Upgrades[i].pp < CM.Cache.min) color = CM.Disp.colorBlue;
else if (CM.Cache.Upgrades[i].pp == CM.Cache.min) color = CM.Disp.colorGreen;
@@ -503,17 +503,17 @@ CM.Cache.RemakeUpgradePP = function() {
else color = CM.Disp.colorYellow;
CM.Cache.Upgrades[i].color = color;
}
}
};
CM.Cache.RemakeBuildingsOtherPP = function(amount, target) {
for (var i in CM.Cache[target]) {
for (let i of Object.keys(CM.Cache[target])) {
//CM.Cache[target][i].pp = CM.Cache[target][i].price / CM.Cache[target][i].bonus;
if (Game.cookiesPs) {
CM.Cache[target][i].pp = (Math.max(CM.Cache[target][i].price - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (CM.Cache[target][i].price / CM.Cache[target][i].bonus);
} else {
CM.Cache[target][i].pp = (CM.Cache[target][i].price / CM.Cache[target][i].bonus);
}
var color = '';
let color = '';
if (CM.Cache[target][i].pp <= 0 || CM.Cache[target][i].pp == Infinity) color = CM.Disp.colorGray;
else if (CM.Cache[target][i].pp < CM.Cache.min) color = CM.Disp.colorBlue;
else if (CM.Cache[target][i].pp == CM.Cache.min) color = CM.Disp.colorGreen;
@@ -523,7 +523,7 @@ CM.Cache.RemakeBuildingsOtherPP = function(amount, target) {
else color = CM.Disp.colorYellow;
CM.Cache[target][i].color = color;
}
}
};
CM.Cache.RemakePP = function() {
// Buildings
@@ -531,7 +531,7 @@ CM.Cache.RemakePP = function() {
// Upgrades
CM.Cache.RemakeUpgradePP();
}
};
CM.Cache.RemakeGoldenAndWrathCookiesMults = function() {
var goldenMult = 1;
@@ -559,7 +559,7 @@ CM.Cache.RemakeGoldenAndWrathCookiesMults = function() {
if (Game.shimmerTypes.golden.n === 0) {
CM.Cache.DragonsFortuneMultAdjustment *= 1 + CM.Sim.auraMult('Dragon\'s Fortune') * 1.23;
}
}
};
CM.Cache.MaxChainMoni = function(digit, maxPayout, mult) {
var chain = 1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10);
@@ -571,7 +571,7 @@ CM.Cache.MaxChainMoni = function(digit, maxPayout, mult) {
nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * mult), maxPayout));
}
return moni;
}
};
CM.Cache.RemakeChain = function() {
var maxPayout = CM.Cache.NoGoldSwitchCookiesPS * 60 * 60 * 6;
@@ -619,7 +619,7 @@ CM.Cache.RemakeChain = function() {
else {
CM.Cache.ChainFrenzyWrath = CM.Cache.NextNumber(CM.Cache.ChainFrenzyWrathReward) / 0.5;
}
}
};
CM.Cache.RemakeSeaSpec = function() {
if (Game.season == 'christmas') {
@@ -629,7 +629,7 @@ CM.Cache.RemakeSeaSpec = function() {
CM.Cache.SeaSpec = Math.max(25, val);
if (Game.Has('Ho ho ho-flavored frosting')) CM.Cache.SeaSpec *= 2;
}
}
};
CM.Cache.RemakeSellForChoEgg = function() {
var sellTotal = 0;
@@ -637,7 +637,7 @@ CM.Cache.RemakeSellForChoEgg = function() {
if (Game.Objects.Bank.minigameLoaded) {
var marketGoods = Game.Objects.Bank.minigame.goods;
var goodsVal = 0;
for (var i in marketGoods) {
for (let i of Object.keys(marketGoods)) {
var marketGood = marketGoods[i];
goodsVal += marketGood.stock * marketGood.val;
}
@@ -646,7 +646,7 @@ CM.Cache.RemakeSellForChoEgg = function() {
// Compute cookies earned by selling all buildings with optimal auras (ES + RB)
sellTotal += CM.Sim.SellBuildingsForChoEgg();
CM.Cache.SellForChoEgg = sellTotal;
}
};
CM.Cache.min = -1;
CM.Cache.max = -1;
@@ -669,7 +669,5 @@ CM.Cache.SellForChoEgg = 0;
CM.Cache.Title = '';
CM.Cache.HadBuildAura = false;
CM.Cache.RealCookiesEarned = -1;
CM.Cache.seasonPopShimmer;
CM.Cache.goldenShimmersByID = {};
CM.Cache.spawnedGoldenShimmer = 0;

View File

@@ -13,12 +13,12 @@
*/
CM.Config.SaveConfig = function() {
let saveString = b64_to_utf8(unescape(localStorage.getItem('CookieClickerGame')).split('!END!')[0]);
CookieMonsterSave = saveString.match(/CookieMonster.*(;|$)/);
let CookieMonsterSave = saveString.match(/CookieMonster.*(;|$)/);
if (CookieMonsterSave != null) {
newSaveString = saveString.replace(CookieMonsterSave[0], "CookieMonster:" + CM.save());
localStorage.setItem('CookieClickerGame', escape(utf8_to_b64(newSaveString)+'!END!'))
let newSaveString = saveString.replace(CookieMonsterSave[0], "CookieMonster:" + CM.save());
localStorage.setItem('CookieClickerGame', escape(utf8_to_b64(newSaveString)+'!END!'));
}
}
};
/**
* This function loads the config of CookieMonster saved in localStorage and loads it into CM.Options
@@ -34,7 +34,7 @@ CM.Config.LoadConfig = function(settings) {
// Check values
var mod = false;
for (var i in CM.Data.ConfigDefault) {
for (let i in CM.Data.ConfigDefault) {
if (typeof CM.Options[i] === 'undefined') {
mod = true;
CM.Options[i] = CM.Data.ConfigDefault[i];
@@ -54,7 +54,7 @@ CM.Config.LoadConfig = function(settings) {
}
}
else if (i == 'Header') {
for (var j in CM.Data.ConfigDefault.Header) {
for (let j in CM.Data.ConfigDefault.Header) {
if (typeof CM.Options[i][j] === 'undefined' || !(CM.Options[i][j] > -1 && CM.Options[i][j] < 2)) {
mod = true;
CM.Options[i][j] = CM.Data.ConfigDefault[i][j];
@@ -62,7 +62,7 @@ CM.Config.LoadConfig = function(settings) {
}
}
else { // Colors
for (var j in CM.Data.ConfigDefault.Colors) {
for (let j in CM.Data.ConfigDefault.Colors) {
if (typeof CM.Options[i][j] === 'undefined' || typeof CM.Options[i][j] != 'string') {
mod = true;
CM.Options[i][j] = CM.Data.ConfigDefault[i][j];
@@ -72,7 +72,7 @@ CM.Config.LoadConfig = function(settings) {
}
if (mod) CM.Config.SaveConfig();
CM.Loop(); // Do loop once
for (var i in CM.Data.ConfigDefault) {
for (let i in CM.Data.ConfigDefault) {
if (i != 'Header' && typeof CM.ConfigData[i].func !== 'undefined') {
CM.ConfigData[i].func();
}
@@ -81,7 +81,7 @@ CM.Config.LoadConfig = function(settings) {
else { // Default values
CM.Config.RestoreDefault();
}
}
};
/**
* This function reloads and resaves the default config as stored in CM.Data.ConfigDefault
@@ -91,7 +91,7 @@ CM.Config.RestoreDefault = function() {
CM.Config.LoadConfig(CM.Data.ConfigDefault);
CM.Config.SaveConfig();
Game.UpdateMenu();
}
};
/********
* Section: Functions related to toggling or changing configs */
@@ -116,7 +116,7 @@ CM.Config.ToggleConfig = function(config) {
l(CM.ConfigPrefix + config).innerHTML = CM.ConfigData[config].label[CM.Options[config]];
CM.Config.SaveConfig();
}
};
/**
* This function sets the value of the specified volume-option and updates the display in the options menu
@@ -129,7 +129,7 @@ CM.Config.ToggleConfigVolume = function(config) {
CM.Options[config] = Math.round(l("slider" + config).value);
}
CM.Config.SaveConfig();
}
};
/**
* This function toggles header options by incrementing them with 1 and handling changes
@@ -140,7 +140,7 @@ CM.Config.ToggleHeader = function(config) {
CM.Options.Header[config]++;
if (CM.Options.Header[config] > 1) CM.Options.Header[config] = 0;
CM.Config.SaveConfig();
}
};
/********
* Section: Functions related to notifications */
@@ -154,14 +154,14 @@ CM.Config.ToggleHeader = function(config) {
CM.Config.CheckNotificationPermissions = function(ToggleOnOff) {
if (ToggleOnOff == 1) {
// Check if browser support Promise version of Notification Permissions
function checkNotificationPromise() {
let checkNotificationPromise = function () {
try {
Notification.requestPermission().then();
} catch(e) {
return false;
}
return true;
}
};
// Check if the browser supports notifications and which type
if (!('Notification' in window)) {
@@ -176,4 +176,4 @@ CM.Config.CheckNotificationPermissions = function(ToggleOnOff) {
}
}
}
}
};

View File

@@ -33,7 +33,7 @@ CM.Data.Fortunes = [
CM.Data.HalloCookies = ['Skull cookies', 'Ghost cookies', 'Bat cookies', 'Slime cookies', 'Pumpkin cookies', 'Eyeball cookies', 'Spider cookies'];
CM.Data.ChristCookies = ['Christmas tree biscuits', 'Snowflake biscuits', 'Snowman biscuits', 'Holly biscuits', 'Candy cane biscuits', 'Bell biscuits', 'Present biscuits'];
CM.Data.ValCookies = ['Pure heart biscuits', 'Ardent heart biscuits', 'Sour heart biscuits', 'Weeping heart biscuits', 'Golden heart biscuits', 'Eternal heart biscuits', 'Prism heart biscuits'];
CM.Data.PlantDrops = ['Elderwort biscuits', 'Bakeberry cookies', 'Duketater cookies', 'Green yeast digestives', 'Wheat slims', 'Fern tea', 'Ichor syrup']
CM.Data.PlantDrops = ['Elderwort biscuits', 'Bakeberry cookies', 'Duketater cookies', 'Green yeast digestives', 'Wheat slims', 'Fern tea', 'Ichor syrup'];
/********
* Section: All possible effects plants and other items can have with an explanation */
@@ -60,7 +60,7 @@ CM.Data.Effects = {
wrathCookieGain: "Wrath cookie gains",
wrinklerEat: "Wrinkler ",
wrinklerSpawn: "Wrinkler spawn frequency"
}
};
/********
* Section: Data for the various scales used by CookieMonster */
@@ -77,7 +77,7 @@ CM.Data.shortScaleAbbreviated = ['', 'K', 'M', 'B', 'T', 'Qa', 'Qi', 'Sx', 'Sp',
'USp', 'DSp', 'TSp', 'QaSp', 'QiSp', 'SxSp', 'SpSp', 'OSp', 'NSp', 'Oco',
'UOc', 'DOc', 'TOc', 'QaOc', 'QiOc', 'SxOc', 'SpOc', 'OOc', 'NOc', 'Noa',
'UNo', 'DNo', 'TNo', 'QaNo', 'QiNo', 'SxNo', 'SpNo', 'ONo', 'NNo', 'Ct',
'UCt']
'UCt'];
/********
* Section: Two array's containing all Config groups and their to-be displayed title */
@@ -90,7 +90,7 @@ CM.ConfigGroups = {
Statistics: "Statistics",
Notation: "Notation",
Miscellaneous: "Miscellaneous"
}
};
CM.ConfigGroupsNotification = {
NotificationGC: "Golden Cookie",
@@ -100,7 +100,7 @@ CM.ConfigGroupsNotification = {
NotificationMagi: "Full Magic Bar",
NotificationWrink: "Wrinkler",
NotificationWrinkMax: "Maximum Wrinklers",
}
};
/********
* Section: An array (CM.ConfigData) containing all Config options and an array of default settings */
@@ -154,7 +154,7 @@ CM.ConfigData.GCNotification = {type: 'bool', group: 'NotificationGC', label: ['
CM.ConfigData.GCFlash = {type: 'bool', group: 'NotificationGC', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen on Golden Cookie', toggle: true};
CM.ConfigData.GCSound = {type: 'bool', group: 'NotificationGC', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound on Golden Cookie', toggle: true};
CM.ConfigData.GCVolume = {type: 'vol', group: 'NotificationGC', label: [], desc: 'Volume'};
for (var i = 0; i < 101; i++) {
for (let i = 0; i < 101; i++) {
CM.ConfigData.GCVolume.label[i] = i + '%';
}
CM.ConfigData.GCSoundURL = {type: 'url', group: 'NotificationGC', label: 'Sound URL:', desc: 'URL of the sound to be played when a Golden Cookie spawns'};
@@ -162,7 +162,7 @@ CM.ConfigData.FortuneNotification = {type: 'bool', group: 'NotificationFC', labe
CM.ConfigData.FortuneFlash = {type: 'bool', group: 'NotificationFC', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen on Fortune Cookie', toggle: true};
CM.ConfigData.FortuneSound = {type: 'bool', group: 'NotificationFC', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound on Fortune Cookie', toggle: true};
CM.ConfigData.FortuneVolume = {type: 'vol', group: 'NotificationFC', label: [], desc: 'Volume'};
for (var i = 0; i < 101; i++) {
for (let i = 0; i < 101; i++) {
CM.ConfigData.FortuneVolume.label[i] = i + '%';
}
CM.ConfigData.FortuneSoundURL = {type: 'url', group: 'NotificationFC', label: 'Sound URL:', desc: 'URL of the sound to be played when the Ticker has a Fortune Cookie'};
@@ -170,14 +170,14 @@ CM.ConfigData.SeaNotification = {type: 'bool', group: 'NotificationSea', label:
CM.ConfigData.SeaFlash = {type: 'bool', group: 'NotificationSea', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen on Season Popup', toggle: true};
CM.ConfigData.SeaSound = {type: 'bool', group: 'NotificationSea', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound on Season Popup', toggle: true};
CM.ConfigData.SeaVolume = {type: 'vol', group: 'NotificationSea', label: [], desc: 'Volume'};
for (var i = 0; i < 101; i++) {
for (let i = 0; i < 101; i++) {
CM.ConfigData.SeaVolume.label[i] = i + '%';
}
CM.ConfigData.SeaSoundURL = {type: 'url', group: 'NotificationSea', label: 'Sound URL:', desc: 'URL of the sound to be played when a Season Special spawns'};
CM.ConfigData.GardFlash = {type: 'bool', group: 'NotificationGard', label: ['Garden Tick Flash OFF', 'Flash ON'], desc: 'Flash screen on Garden Tick', toggle: true};
CM.ConfigData.GardSound = {type: 'bool', group: 'NotificationGard', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound on Garden Tick', toggle: true};
CM.ConfigData.GardVolume = {type: 'vol', group: 'NotificationGard', label: [], desc: 'Volume'};
for (var i = 0; i < 101; i++) {
for (let i = 0; i < 101; i++) {
CM.ConfigData.GardVolume.label[i] = i + '%';
}
CM.ConfigData.GardSoundURL = {type: 'url', group: 'NotificationGard', label: 'Garden Tick Sound URL:', desc: 'URL of the sound to be played when the garden ticks'};
@@ -185,7 +185,7 @@ CM.ConfigData.MagicNotification = {type: 'bool', group: 'NotificationMagi', labe
CM.ConfigData.MagicFlash = {type: 'bool', group: 'NotificationMagi', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen when magic reaches maximum', toggle: true};
CM.ConfigData.MagicSound = {type: 'bool', group: 'NotificationMagi', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound when magic reaches maximum', toggle: true};
CM.ConfigData.MagicVolume = {type: 'vol', group: 'NotificationMagi', label: [], desc: 'Volume'};
for (var i = 0; i < 101; i++) {
for (let i = 0; i < 101; i++) {
CM.ConfigData.MagicVolume.label[i] = i + '%';
}
CM.ConfigData.MagicSoundURL = {type: 'url', group: 'NotificationMagi', label: 'Sound URL:', desc: 'URL of the sound to be played when magic reaches maxium'};
@@ -193,7 +193,7 @@ CM.ConfigData.WrinklerNotification = {type: 'bool', group: 'NotificationWrink',
CM.ConfigData.WrinklerFlash = {type: 'bool', group: 'NotificationWrink', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen when a Wrinkler appears', toggle: true};
CM.ConfigData.WrinklerSound = {type: 'bool', group: 'NotificationWrink', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound when a Wrinkler appears', toggle: true};
CM.ConfigData.WrinklerVolume = {type: 'vol', group: 'NotificationWrink', label: [], desc: 'Volume'};
for (var i = 0; i < 101; i++) {
for (let i = 0; i < 101; i++) {
CM.ConfigData.WrinklerVolume.label[i] = i + '%';
}
CM.ConfigData.WrinklerSoundURL = {type: 'url', group: 'NotificationWrink', label: 'Sound URL:', desc: 'URL of the sound to be played when a Wrinkler appears'};
@@ -201,7 +201,7 @@ CM.ConfigData.WrinklerMaxNotification = {type: 'bool', group: 'NotificationWrink
CM.ConfigData.WrinklerMaxFlash = {type: 'bool', group: 'NotificationWrinkMax', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen when the maximum amount of Wrinklers has appeared', toggle: true};
CM.ConfigData.WrinklerMaxSound = {type: 'bool', group: 'NotificationWrinkMax', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound when the maximum amount of Wrinklers has appeared', toggle: true};
CM.ConfigData.WrinklerMaxVolume = {type: 'vol', group: 'NotificationWrinkMax', label: [], desc: 'Volume'};
for (var i = 0; i < 101; i++) {
for (let i = 0; i < 101; i++) {
CM.ConfigData.WrinklerMaxVolume.label[i] = i + '%';
}
CM.ConfigData.WrinklerMaxSoundURL = {type: 'url', group: 'NotificationWrinkMax', label: 'Sound URL:', desc: 'URL of the sound to be played when the maximum amount of Wrinklers has appeared'};

File diff suppressed because it is too large Load Diff

View File

@@ -20,7 +20,7 @@ CM.init = function() {
CM.DelayInit();
Game.registerHook('draw', CM.Disp.Draw);
}
}
};
/**
* This registers a save function to the CM object. Per Game code/comments:
@@ -32,7 +32,7 @@ CM.save = function() {
settings: CM.Options,
version: CM.VersionMajor + '.' + CM.VersionMinor,
});
}
};
/**
* This registers a load function to the CM object. Per Game code/comments:
@@ -41,7 +41,7 @@ CM.save = function() {
CM.load = function(str) {
let save = JSON.parse(str);
CM.Config.LoadConfig(save.settings);
}
};
/********
* Section: Functions related to the initialization of CookieMonster */
@@ -56,7 +56,7 @@ CM.Footer.AddJscolor = function() {
CM.Footer.Jscolor.type = 'text/javascript';
CM.Footer.Jscolor.setAttribute('src', 'https://aktanusa.github.io/CookieMonster/jscolor/jscolor.js');
document.head.appendChild(CM.Footer.Jscolor);
}
};
/**
* This functions starts the initizialization and register CookieMonster
@@ -72,6 +72,6 @@ if (!CM.isRunning) {
clearInterval(delay);
}
}, 500);
CM.isRunning = 1
CM.isRunning = 1;
}

View File

@@ -1,7 +1,8 @@
/**********
* Header *
**********/
RunCookieMonsterHeader = function() {
var RunCookieMonsterHeader = function() {
CM = {};
CM.Backup = {};
@@ -23,7 +24,7 @@ RunCookieMonsterHeader = function() {
CM.Options = {};
CM.Sim = {};
}
};
if (typeof CM == "undefined") {
RunCookieMonsterHeader();

View File

@@ -11,31 +11,31 @@ CM.ReplaceNative = function() {
Game.CalculateGains = function() {
CM.Backup.CalculateGainsMod();
CM.Sim.DoSims = 1;
}
};
CM.Backup.tooltip = {};
CM.Backup.tooltip.draw = Game.tooltip.draw;
eval('CM.Backup.tooltip.drawMod = ' + Game.tooltip.draw.toString().split('this').join('Game.tooltip'));
Game.tooltip.draw = function(from, text, origin) {
CM.Backup.tooltip.drawMod(from, text, origin);
}
};
CM.Backup.tooltip.update = Game.tooltip.update;
eval('CM.Backup.tooltip.updateMod = ' + Game.tooltip.update.toString().split('this.').join('Game.tooltip.'));
Game.tooltip.update = function() {
CM.Backup.tooltip.updateMod();
CM.Disp.UpdateTooltipLocation();
}
};
CM.Backup.UpdateWrinklers = Game.UpdateWrinklers;
Game.UpdateWrinklers = function() {
CM.Main.FixMouseY(CM.Backup.UpdateWrinklers);
}
};
CM.Backup.UpdateSpecial = Game.UpdateSpecial;
Game.UpdateSpecial = function() {
CM.Main.FixMouseY(CM.Backup.UpdateSpecial);
}
};
// Assumes newer browsers
l('bigCookie').removeEventListener('click', Game.ClickCookie, false);
@@ -46,7 +46,7 @@ CM.ReplaceNative = function() {
CM.Backup.RebuildUpgrades();
CM.Disp.ReplaceTooltipUpgrade();
Game.CalculateGains();
}
};
CM.Backup.DescribeDragonAura = Game.DescribeDragonAura;
/**
@@ -57,7 +57,7 @@ CM.ReplaceNative = function() {
Game.DescribeDragonAura = function(aura) {
CM.Backup.DescribeDragonAura(aura);
CM.Disp.AddAuraInfo(aura);
}
};
CM.Backup.ToggleSpecialMenu = Game.ToggleSpecialMenu;
/**
@@ -66,8 +66,7 @@ CM.ReplaceNative = function() {
Game.ToggleSpecialMenu = function(on) {
CM.Backup.ToggleSpecialMenu(on);
CM.Disp.AddDragonLevelUpTooltip();
}
};
CM.Backup.UpdateMenu = Game.UpdateMenu;
Game.UpdateMenu = function() {
@@ -75,19 +74,19 @@ CM.ReplaceNative = function() {
CM.Backup.UpdateMenu();
CM.Disp.AddMenu();
}
}
};
CM.Backup.sayTime = Game.sayTime;
CM.Disp.sayTime = function(time, detail) {
if (isNaN(time) || time <= 0) return CM.Backup.sayTime(time, detail);
else return CM.Disp.FormatTime(time / Game.fps, 1);
}
};
CM.Backup.Loop = Game.Loop;
Game.Loop = function() {
CM.Backup.Loop();
CM.Loop();
}
};
CM.Backup.Logic = Game.Logic;
eval('CM.Backup.LogicMod = ' + Game.Logic.toString().split('document.title').join('CM.Cache.Title'));
@@ -96,13 +95,13 @@ CM.ReplaceNative = function() {
// Update Title
CM.Disp.UpdateTitle();
}
}
};
};
CM.ReplaceNativeGrimoire = function() {
CM.ReplaceNativeGrimoireLaunch();
CM.ReplaceNativeGrimoireDraw();
}
};
CM.ReplaceNativeGrimoireLaunch = function() {
if (!CM.HasReplaceNativeGrimoireLaunch && Game.Objects['Wizard tower'].minigameLoaded) {
@@ -114,10 +113,10 @@ CM.ReplaceNativeGrimoireLaunch = function() {
CM.Main.ReplaceTooltipGrimoire();
CM.HasReplaceNativeGrimoireDraw = false;
CM.ReplaceNativeGrimoireDraw();
}
};
CM.HasReplaceNativeGrimoireLaunch = true;
}
}
};
CM.ReplaceNativeGrimoireDraw = function() {
if (!CM.HasReplaceNativeGrimoireDraw && Game.Objects['Wizard tower'].minigameLoaded) {
@@ -128,10 +127,10 @@ CM.ReplaceNativeGrimoireDraw = function() {
if (CM.Options.GrimoireBar == 1 && minigame.magic < minigame.magicM) {
minigame.magicBarTextL.innerHTML += ' (' + CM.Disp.FormatTime(CM.Disp.CalculateGrimoireRefillTime(minigame.magic, minigame.magicM, minigame.magicM)) + ')';
}
}
};
CM.HasReplaceNativeGrimoireDraw = true;
}
}
};
CM.Loop = function() {
if (CM.Disp.lastAscendState != Game.OnAscend) {
@@ -211,7 +210,7 @@ CM.Loop = function() {
// Update Average CPS (might need to move)
CM.Cache.UpdateCurrWrinklerCPS();
CM.Cache.UpdateAvgCPS();
}
};
CM.DelayInit = function() {
CM.Sim.InitData();
@@ -222,7 +221,7 @@ CM.DelayInit = function() {
CM.Disp.CreateUpgradeBar();
CM.Disp.CreateWhiteScreen();
CM.Disp.CreateFavicon();
for (var i in CM.Disp.TooltipText) {
for (let i of Object.keys(CM.Disp.TooltipText)) {
CM.Disp.CreateSimpleTooltip(CM.Disp.TooltipText[i][0], CM.Disp.TooltipText[i][1], CM.Disp.TooltipText[i][2]);
}
CM.Disp.CreateWrinklerButtons();
@@ -249,7 +248,7 @@ CM.DelayInit = function() {
l("upgrades").style["flex-wrap"] = "wrap";
Game.Win('Third-party');
}
};
/********
* Section: Functions related to first initizalition of CM */
@@ -268,16 +267,15 @@ CM.Main.ReplaceTooltips = function() {
Game.LoadMinigames = function() {
CM.Backup.LoadMinigames();
CM.Main.ReplaceTooltipGarden();
CM.Main.ReplaceTooltipGrimoire()
CM.Main.ReplaceTooltipGrimoire();
CM.ReplaceNativeGrimoire();
}
};
Game.LoadMinigames();
}
};
/********
* Section: Functions related to replacing tooltips */
/**
* This function replaces the original .onmouseover functions of buildings so that it calls CM.Disp.Tooltip()
* CM.Disp.Tooltip() sets the tooltip type to 'b'
@@ -285,14 +283,14 @@ CM.Main.ReplaceTooltips = function() {
*/
CM.Main.ReplaceTooltipBuild = function() {
CM.Main.TooltipBuildBackup = [];
for (var i in Game.Objects) {
for (let i of Object.keys(Game.Objects)) {
var me = Game.Objects[i];
if (l('product' + me.id).onmouseover != null) {
CM.Main.TooltipBuildBackup[i] = l('product' + me.id).onmouseover;
eval('l(\'product\' + me.id).onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'b\', \'' + i + '\');}, \'store\'); Game.tooltip.wobble();}');
}
}
}
};
/**
* This function replaces the original .onmouseover functions of the Grimoire minigame so that it calls CM.Disp.Tooltip()
@@ -302,14 +300,14 @@ CM.Main.ReplaceTooltipBuild = function() {
CM.Main.ReplaceTooltipGrimoire = function() {
if (Game.Objects['Wizard tower'].minigameLoaded) {
CM.Main.TooltipGrimoireBackup = [];
for (var i in Game.Objects['Wizard tower'].minigame.spellsById) {
for (let i in Game.Objects['Wizard tower'].minigame.spellsById) {
if (l('grimoireSpell' + i).onmouseover != null) {
CM.Main.TooltipGrimoireBackup[i] = l('grimoireSpell' + i).onmouseover;
eval('l(\'grimoireSpell\' + i).onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'g\', \'' + i + '\');}, \'this\'); Game.tooltip.wobble();}');
}
}
}
}
};
/**
* This function replaces the original .onmouseover functions of sugar lumps so that it calls CM.Disp.Tooltip()
@@ -329,9 +327,9 @@ CM.Main.ReplaceTooltipLump = function() {
* It is called by CM.Main.ReplaceTooltips()
*/
CM.Main.ReplaceTooltipGarden = function() {
if (Game.Objects['Farm'].minigameLoaded) {
l('gardenTool-1').onmouseover = function() {Game.tooltip.dynamic=1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip('ha', 'HarvestAllButton');}, 'this'); Game.tooltip.wobble();}
Array.from(l('gardenPlot').children).forEach((child, index) => {
if (Game.Objects.Farm.minigameLoaded) {
l('gardenTool-1').onmouseover = function() {Game.tooltip.dynamic=1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip('ha', 'HarvestAllButton');}, 'this'); Game.tooltip.wobble();};
Array.from(l('gardenPlot').children).forEach((child) => {
var coords = child.id.slice(-3,);
child.onmouseover = function() {Game.tooltip.dynamic=1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip('p', [`${coords[0]}`,`${coords[2]}`]);}, 'this'); Game.tooltip.wobble();};
});
@@ -349,15 +347,15 @@ CM.Main.ReplaceTooltipGarden = function() {
*/
CM.Main.FindShimmer = function() {
CM.Main.currSpawnedGoldenCookieState = 0;
CM.Cache.goldenShimmersByID = {}
for (var i in Game.shimmers) {
CM.Cache.goldenShimmersByID[Game.shimmers[i].id] = Game.shimmers[i]
CM.Cache.goldenShimmersByID = {};
for (let i of Object.keys(Game.shimmers)) {
CM.Cache.goldenShimmersByID[Game.shimmers[i].id] = Game.shimmers[i];
if (Game.shimmers[i].spawnLead && Game.shimmers[i].type == 'golden') {
CM.Cache.spawnedGoldenShimmer = Game.shimmers[i];
CM.Main.currSpawnedGoldenCookieState += 1;
}
}
}
};
/**
* This function checks for changes in the amount of Golden Cookies
@@ -366,23 +364,23 @@ CM.Main.FindShimmer = function() {
*/
CM.Main.CheckGoldenCookie = function() {
CM.Main.FindShimmer();
for (var i in CM.Disp.GCTimers) {
for (let i of Object.keys(CM.Disp.GCTimers)) {
if (typeof CM.Cache.goldenShimmersByID[i] == "undefined") {
CM.Disp.GCTimers[i].parentNode.removeChild(CM.Disp.GCTimers[i]);
// TODO remove delete here
delete CM.Disp.GCTimers[i];
}
}
if (CM.Main.lastGoldenCookieState != Game.shimmerTypes['golden'].n) {
CM.Main.lastGoldenCookieState = Game.shimmerTypes['golden'].n;
if (CM.Main.lastGoldenCookieState != Game.shimmerTypes.golden.n) {
CM.Main.lastGoldenCookieState = Game.shimmerTypes.golden.n;
if (CM.Main.lastGoldenCookieState) {
if (CM.Main.lastSpawnedGoldenCookieState < CM.Main.currSpawnedGoldenCookieState) {
CM.Disp.Flash(3, 'GCFlash');
CM.Disp.PlaySound(CM.Options.GCSoundURL, 'GCSound', 'GCVolume');
CM.Disp.Notification('GCNotification', "Golden Cookie Spawned", "A Golden Cookie has spawned. Click it now!")
CM.Disp.Notification('GCNotification', "Golden Cookie Spawned", "A Golden Cookie has spawned. Click it now!");
}
for (var i in Game.shimmers) {
for (let i of Object.keys(Game.shimmers)) {
if (typeof CM.Disp.GCTimers[Game.shimmers[i].id] == "undefined") {
CM.Disp.CreateGCTimer(Game.shimmers[i]);
}
@@ -393,22 +391,22 @@ CM.Main.CheckGoldenCookie = function() {
if (CM.Main.currSpawnedGoldenCookieState == 0) CM.Cache.spawnedGoldenShimmer = 0;
}
else if (CM.Options.GCTimer == 1 && CM.Main.lastGoldenCookieState) {
for (var i in CM.Disp.GCTimers) {
for (let i of Object.keys(CM.Disp.GCTimers)) {
CM.Disp.GCTimers[i].style.opacity = CM.Cache.goldenShimmersByID[i].l.style.opacity;
CM.Disp.GCTimers[i].style.transform = CM.Cache.goldenShimmersByID[i].l.style.transform;
CM.Disp.GCTimers[i].textContent = Math.ceil(CM.Cache.goldenShimmersByID[i].life / Game.fps);
}
}
}
};
/**
* This function checks if there is reindeer that has spawned
* It is called by CM.Loop
*/
CM.Main.CheckSeasonPopup = function() {
if (CM.Main.lastSeasonPopupState != Game.shimmerTypes['reindeer'].spawned) {
CM.Main.lastSeasonPopupState = Game.shimmerTypes['reindeer'].spawned;
for (var i in Game.shimmers) {
if (CM.Main.lastSeasonPopupState != Game.shimmerTypes.reindeer.spawned) {
CM.Main.lastSeasonPopupState = Game.shimmerTypes.reindeer.spawned;
for (let i of Object.keys(Game.shimmers)) {
if (Game.shimmers[i].spawnLead && Game.shimmers[i].type == 'reindeer') {
CM.Cache.seasonPopShimmer = Game.shimmers[i];
break;
@@ -416,9 +414,9 @@ CM.Main.CheckSeasonPopup = function() {
}
CM.Disp.Flash(3, 'SeaFlash');
CM.Disp.PlaySound(CM.Options.SeaSoundURL, 'SeaSound', 'SeaVolume');
CM.Disp.Notification('SeaNotification',"Reindeer sighted!", "A Reindeer has spawned. Click it now!")
CM.Disp.Notification('SeaNotification',"Reindeer sighted!", "A Reindeer has spawned. Click it now!");
}
}
};
/**
* This function checks if there is a fortune cookie on the ticker
@@ -430,24 +428,24 @@ CM.Main.CheckTickerFortune = function() {
if (CM.Main.lastTickerFortuneState) {
CM.Disp.Flash(3, 'FortuneFlash');
CM.Disp.PlaySound(CM.Options.FortuneSoundURL, 'FortuneSound', 'FortuneVolume');
CM.Disp.Notification('FortuneNotification', "Fortune Cookie found", "A Fortune Cookie has appeared on the Ticker.")
CM.Disp.Notification('FortuneNotification', "Fortune Cookie found", "A Fortune Cookie has appeared on the Ticker.");
}
}
}
};
/**
* This function checks if a garden tick has happened
* It is called by CM.Loop
*/
CM.Main.CheckGardenTick = function() {
if (Game.Objects['Farm'].minigameLoaded && CM.Main.lastGardenNextStep != Game.Objects['Farm'].minigame.nextStep) {
if (Game.Objects.Farm.minigameLoaded && CM.Main.lastGardenNextStep != Game.Objects.Farm.minigame.nextStep) {
if (CM.Main.lastGardenNextStep != 0 && CM.Main.lastGardenNextStep < Date.now()) {
CM.Disp.Flash(3, 'GardFlash');
CM.Disp.PlaySound(CM.Options.GardSoundURL, 'GardSound', 'GardVolume');
}
CM.Main.lastGardenNextStep = Game.Objects['Farm'].minigame.nextStep;
CM.Main.lastGardenNextStep = Game.Objects.Farm.minigame.nextStep;
}
}
};
/**
* This function checks if the magic meter is full
@@ -461,10 +459,10 @@ CM.Main.CheckMagicMeter = function() {
CM.Main.lastMagicBarFull = true;
CM.Disp.Flash(3, 'MagicFlash');
CM.Disp.PlaySound(CM.Options.MagicSoundURL, 'MagicSound', 'MagicVolume');
CM.Disp.Notification('MagicNotification', "Magic Meter full", "Your Magic Meter is full. Cast a spell!")
CM.Disp.Notification('MagicNotification', "Magic Meter full", "Your Magic Meter is full. Cast a spell!");
}
}
}
};
/**
* This function checks if any new Wrinklers have popped up
@@ -473,11 +471,11 @@ CM.Main.CheckMagicMeter = function() {
CM.Main.CheckWrinklerCount = function() {
if (Game.elderWrath > 0) {
var CurrentWrinklers = 0;
for (var i in Game.wrinklers) {
for (let i in Game.wrinklers) {
if (Game.wrinklers[i].phase == 2) CurrentWrinklers++;
}
if (CurrentWrinklers > CM.Main.lastWrinklerCount) {
CM.Main.lastWrinklerCount = CurrentWrinklers
CM.Main.lastWrinklerCount = CurrentWrinklers;
if (CurrentWrinklers == Game.getWrinklersMax() && CM.Options.WrinklerMaxFlash) {
CM.Disp.Flash(3, 'WrinklerMaxFlash');
} else {
@@ -489,15 +487,15 @@ CM.Main.CheckWrinklerCount = function() {
CM.Disp.PlaySound(CM.Options.WrinklerSoundURL, 'WrinklerSound', 'WrinklerVolume');
}
if (CurrentWrinklers == Game.getWrinklersMax() && CM.Options.WrinklerMaxNotification) {
CM.Disp.Notification('WrinklerMaxNotification', "Maximum Wrinklers Reached", "You have reached your maximum ammount of wrinklers")
CM.Disp.Notification('WrinklerMaxNotification', "Maximum Wrinklers Reached", "You have reached your maximum ammount of wrinklers");
} else {
CM.Disp.Notification('WrinklerNotification', "A Wrinkler appeared", "A new wrinkler has appeared")
CM.Disp.Notification('WrinklerNotification', "A Wrinkler appeared", "A new wrinkler has appeared");
}
} else {
CM.Main.lastWrinklerCount = CurrentWrinklers
CM.Main.lastWrinklerCount = CurrentWrinklers;
}
}
}
};
/**
* This function creates .onmouseover/out events that determine if the mouse is hovering-over a Wrinkler
@@ -510,11 +508,11 @@ CM.Main.AddWrinklerAreaDetect = function() {
l('backgroundLeftCanvas').onmouseout = function() {
CM.Disp.TooltipWrinklerArea = 0;
Game.tooltip.hide();
for (var i in Game.wrinklers) {
for (let i of Object.keys(Game.wrinklers)) {
CM.Disp.TooltipWrinklerBeingShown[i] = 0;
}
};
}
};
/********
* Section: Functions related to the mouse */
@@ -534,14 +532,13 @@ CM.Main.FixMouseY = function(target) {
else {
target();
}
}
};
CM.HasReplaceNativeGrimoireLaunch = false;
CM.HasReplaceNativeGrimoireDraw = false;
CM.Main.lastGoldenCookieState = 0;
CM.Main.lastSpawnedGoldenCookieState = 0;
CM.Main.currSpawnedGoldenCookieState
CM.Main.lastTickerFortuneState = 0;
CM.Main.lastSeasonPopupState = 0;
CM.Main.lastGardenNextStep = 0;

View File

@@ -3,8 +3,8 @@
*******/
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++) {
/*let price=0;
for (let i = Math.max(0 , start); i < Math.max(0, start + increase); i++) {
price += basePrice * Math.pow(Game.priceIncrease, Math.max(0, i - free));
}
if (Game.Has('Season savings')) price *= 0.99;
@@ -15,19 +15,19 @@ CM.Sim.BuildingGetPrice = function(build, basePrice, start, free, increase) {
return Math.ceil(price);*/
var moni = 0;
for (var i = 0; i < increase; i++) {
var price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free));
for (let i = 0; i < increase; i++) {
let price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free));
price = Game.modifyBuildingPrice(build, price);
price = Math.ceil(price);
moni += price;
start++;
}
return moni;
}
};
CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, noSim) {
/*var price=0;
for (var i = Math.max(0, start - amount); i < Math.max(0, start); i++) {
/*let price=0;
for (let i = Math.max(0, start - amount); i < Math.max(0, start); i++) {
price += basePrice * Math.pow(Game.priceIncrease, Math.max(0, i - free));
}
if (Game.Has('Season savings')) price*=0.99;
@@ -49,8 +49,8 @@ CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, noSim) {
var moni = 0;
if (amount == -1) amount = start;
if (!amount) amount = Game.buyBulk;
for (var i = 0; i < amount; i++) {
var price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free));
for (let i = 0; i < amount; i++) {
let price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free));
price = noSim ? Game.modifyBuildingPrice(build, price) : CM.Sim.modifyBuildingPrice(build, price);
price = Math.ceil(price);
var giveBack = noSim ? build.getSellMultiplier() : CM.Sim.getSellMultiplier();
@@ -61,13 +61,13 @@ CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, noSim) {
}
}
return moni;
}
};
CM.Sim.Has = function(what) {
var it = CM.Sim.Upgrades[what];
let it = CM.Sim.Upgrades[what];
if (Game.ascensionMode == 1 && (it.pool == 'prestige' || it.tier == 'fortune')) return 0;
return (it ? it.bought : 0);
}
};
CM.Sim.Win = function(what) {
@@ -77,7 +77,7 @@ CM.Sim.Win = function(what) {
if (Game.Achievements[what].pool != 'shadow') CM.Sim.AchievementsOwned++;
}
}
}
};
eval('CM.Sim.HasAchiev = ' + Game.HasAchiev.toString().split('Game').join('CM.Sim'));
@@ -89,7 +89,7 @@ CM.Sim.hasAura = function(what) {
return true;
else
return false;
}
};
// Check if multiplier auras are present
// Used as CM.Sim.auraMult('Aura') * mult, i.e. CM.Sim.auraMult('Dragon God) * 0.05
@@ -100,20 +100,20 @@ CM.Sim.auraMult = function(what) {
if (Game.dragonAuras[CM.Sim.dragonAura].name == 'Reality Bending' || Game.dragonAuras[CM.Sim.dragonAura2].name == 'Reality Bending')
n += 0.1;
return n;
}
};
CM.Sim.hasGod=function(what) {
if (!CM.Sim.Objects.Temple.minigameLoaded) {
return false
return false;
}
var possibleGods = CM.Sim.Objects.Temple.minigame.gods
var possibleGods = CM.Sim.Objects.Temple.minigame.gods;
var god=possibleGods[what];
for (var i=0;i<3;i++)
for (let i=0;i<3;i++)
{
if (CM.Sim.Objects.Temple.minigame.slot[i]==god.id) return (i+1);
}
return false;
}
};
CM.Sim.eff = function(name) {
if (typeof CM.Sim.effs[name]==='undefined') {
@@ -123,7 +123,7 @@ CM.Sim.eff = function(name) {
else {
return CM.Sim.effs[name];
}
}
};
eval('CM.Sim.GetTieredCpsMult = ' + Game.GetTieredCpsMult.toString()
.split('Game.Has').join('CM.Sim.Has')
@@ -139,11 +139,11 @@ eval('CM.Sim.GetTieredCpsMult = ' + Game.GetTieredCpsMult.toString()
CM.Sim.getCPSBuffMult = function() {
var mult = 1;
for (var i in Game.buffs) {
for (let i of Object.keys(Game.buffs)) {
if (typeof Game.buffs[i].multCpS != 'undefined') mult *= Game.buffs[i].multCpS;
}
return mult;
}
};
/**
* Constructs an object with the static properties of a building,
@@ -155,8 +155,8 @@ CM.Sim.getCPSBuffMult = function() {
* are set by CM.Sim.CopyData.
*/
CM.Sim.InitialBuildingData = function(buildingName) {
var me = Game.Objects[buildingName];
var you = {};
let me = Game.Objects[buildingName];
let you = {};
eval('you.cps = ' + me.cps.toString()
.split('Game.Has').join('CM.Sim.Has')
.split('Game.hasAura').join('CM.Sim.hasAura')
@@ -168,7 +168,7 @@ CM.Sim.InitialBuildingData = function(buildingName) {
you.baseCps = me.baseCps;
you.name = me.name;
return you;
}
};
/**
* Similar to the previous function, but for upgrades.
@@ -176,12 +176,12 @@ CM.Sim.InitialBuildingData = function(buildingName) {
* so this function just returns an empty object.
*/
CM.Sim.InitUpgrade = function(upgradeName) {
var me = Game.Upgrades[upgradeName];
var you = {};
let me = Game.Upgrades[upgradeName];
let you = {};
you.pool = me.pool;
you.name = me.name;
return you;
}
};
/**
* Similar to the previous function, but for achievements.
@@ -189,29 +189,32 @@ CM.Sim.InitUpgrade = function(upgradeName) {
* so this function just returns an empty object.
*/
CM.Sim.InitAchievement = function(achievementName) {
let me = Game.Achievements[achievementName];
let you = {};
you.name = me.name;
return {};
}
};
CM.Sim.InitData = function() {
// Buildings
CM.Sim.Objects = [];
for (var i in Game.Objects) {
for (let i of Object.keys(Game.Objects)) {
CM.Sim.Objects[i] = CM.Sim.InitialBuildingData(i);
}
// Upgrades
CM.Sim.Upgrades = [];
for (var i in Game.Upgrades) {
for (let i of Object.keys(Game.Upgrades)) {
CM.Sim.Upgrades[i] = CM.Sim.InitUpgrade(i);
}
// Achievements
CM.Sim.Achievements = [];
for (var i in Game.Achievements) {
for (let i of Object.keys(Game.Achievements)) {
CM.Sim.Achievements[i] = CM.Sim.InitAchievement(i);
}
CM.Sim.CopyData
}
CM.Sim.CopyData();
};
CM.Sim.CopyData = function() {
// Other variables
@@ -222,9 +225,9 @@ CM.Sim.CopyData = function() {
CM.Sim.prestige = Game.prestige;
// Buildings
for (var i in Game.Objects) {
var me = Game.Objects[i];
var you = CM.Sim.Objects[i];
for (let i of Object.keys(Game.Objects)) {
let me = Game.Objects[i];
let you = CM.Sim.Objects[i];
if (you == undefined) { // New building!
you = CM.Sim.Objects[i] = CM.Sim.InitialBuildingData(i);
CM.Disp.CreateBotBarBuildingColumn(i); // Add new building to the bottom bar
@@ -238,9 +241,9 @@ CM.Sim.CopyData = function() {
}
// Upgrades
for (var i in Game.Upgrades) {
var me = Game.Upgrades[i];
var you = CM.Sim.Upgrades[i];
for (let i of Object.keys(Game.Upgrades)) {
let me = Game.Upgrades[i];
let you = CM.Sim.Upgrades[i];
if (you == undefined) {
you = CM.Sim.Upgrades[i] = CM.Sim.InitUpgrade(i);
}
@@ -248,9 +251,9 @@ CM.Sim.CopyData = function() {
}
// Achievements
for (var i in Game.Achievements) {
var me = Game.Achievements[i];
var you = CM.Sim.Achievements[i];
for (let i of Object.keys(Game.Achievements)) {
let me = Game.Achievements[i];
let you = CM.Sim.Achievements[i];
if (you == undefined) {
you = CM.Sim.Achievements[i] = CM.Sim.InitAchievement(i);
}
@@ -268,12 +271,12 @@ CM.Sim.CalculateGains = function() {
var mult = 1;
// Include minigame effects
var effs={};
for (var i in Game.Objects) {
for (let i of Object.keys(Game.Objects)) {
// TODO Store minigames and effects in Cache
// Include possibility of new/modded building and new/modded minigames
if (CM.Sim.Objects[i].minigameLoaded && CM.Sim.Objects[i].minigame.effs) {
var myEffs = CM.Sim.Objects[i].minigame.effs;
for (var ii in myEffs) {
for (let ii in myEffs) {
if (effs[ii]) effs[ii]*=myEffs[ii];
else effs[ii]=myEffs[ii];
}
@@ -289,8 +292,8 @@ CM.Sim.CalculateGains = function() {
// TODO: Make function call cached function where Game.Has is replaced with CM.Has
// Related to valentine cookies
for (var i in Game.cookieUpgrades) {
var me = Game.cookieUpgrades[i];
for (let i of Object.keys(Game.cookieUpgrades)) {
let me = Game.cookieUpgrades[i];
if (CM.Sim.Has(me.name)) {
mult *= (1 + (typeof(me.power) == 'function' ? me.power(me) : me.power) * 0.01);
}
@@ -316,28 +319,28 @@ CM.Sim.CalculateGains = function() {
// Check effect of chosen Gods
var buildMult = 1;
if (CM.Sim.Objects.Temple.minigameLoaded) {
var godLvl = CM.Sim.hasGod('asceticism');
let godLvl = CM.Sim.hasGod('asceticism');
if (godLvl == 1) mult *= 1.15;
else if (godLvl == 2) mult *= 1.1;
else if (godLvl == 3) mult *= 1.05;
// TODO: What does DateAges do?
var godLvl = CM.Sim.hasGod('ages');
godLvl = CM.Sim.hasGod('ages');
if (godLvl == 1) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 3)) * Math.PI * 2);
else if (godLvl == 2) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 12)) * Math.PI*2);
else if (godLvl == 3) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 24)) * Math.PI*2);
var godLvl = CM.Sim.hasGod('decadence');
godLvl = CM.Sim.hasGod('decadence');
if (godLvl == 1) buildMult *= 0.93;
else if (godLvl == 2) buildMult *= 0.95;
else if (godLvl == 3) buildMult *= 0.98;
var godLvl = CM.Sim.hasGod('industry');
godLvl = CM.Sim.hasGod('industry');
if (godLvl == 1) buildMult *= 1.1;
else if (godLvl == 2) buildMult *= 1.06;
else if (godLvl == 3) buildMult *= 1.03;
var godLvl = CM.Sim.hasGod('labor');
godLvl = CM.Sim.hasGod('labor');
if (godLvl == 1) buildMult *= 0.97;
else if (godLvl == 2) buildMult *= 0.98;
else if (godLvl == 3) buildMult *= 0.99;
@@ -351,7 +354,7 @@ CM.Sim.CalculateGains = function() {
//if (CM.Sim.hasAura('Breath of Milk')) milkMult *= 1.05;
milkMult *= 1 + CM.Sim.auraMult('Breath of Milk') * 0.05;
if (CM.Sim.Objects.Temple.minigameLoaded) {
var godLvl = CM.Sim.hasGod('mother');
let godLvl = CM.Sim.hasGod('mother');
if (godLvl == 1) milkMult *= 1.1;
else if (godLvl == 2) milkMult *= 1.05;
else if (godLvl == 3) milkMult *= 1.03;
@@ -377,8 +380,8 @@ CM.Sim.CalculateGains = function() {
if (CM.Sim.Has('Kitten angels')) catMult *= (1 + milkProgress * 0.1 * milkMult);
if (CM.Sim.Has('Fortune #103')) catMult *= (1 + milkProgress * 0.05 * milkMult);
for (var i in CM.Sim.Objects) {
var me = CM.Sim.Objects[i];
for (let i of Object.keys(CM.Sim.Objects)) {
let me = CM.Sim.Objects[i];
var storedCps = (typeof(me.cps) == 'function' ? me.cps(me) : me.cps);
if (Game.ascensionMode != 1) storedCps *= (1 + me.level * 0.01) * buildMult;
if (me.name == "Grandma" && CM.Sim.Has('Milkhelp&reg; lactose intolerance relief tablets')) storedCps *= 1 + 0.05 * milkProgress * milkMult;
@@ -418,15 +421,15 @@ CM.Sim.CalculateGains = function() {
mult *= 1 + CM.Sim.auraMult('Radiant Appetite');
var rawCookiesPs = CM.Sim.cookiesPs * mult;
for (var i in Game.CpsAchievements) {
for (let i of Object.keys(Game.CpsAchievements)) {
if (rawCookiesPs >= Game.CpsAchievements[i].threshold) CM.Sim.Win(Game.CpsAchievements[i].name);
}
CM.Sim.cookiesPsRaw = rawCookiesPs;
var n = Game.shimmerTypes['golden'].n;
var n = Game.shimmerTypes.golden.n;
var auraMult = CM.Sim.auraMult('Dragon\'s Fortune');
for (var i = 0; i < n; i++){
for (let i = 0; i < n; i++){
mult *= 1 + auraMult * 1.23;
}
@@ -442,7 +445,7 @@ CM.Sim.CalculateGains = function() {
var goldenSwitchMult = 1.5;
if (CM.Sim.Has('Residual luck')) {
var upgrades = Game.goldenCookieUpgrades;
for (var i in upgrades) {
for (let i of Object.keys(upgrades)) {
if (CM.Sim.Has(upgrades[i])) goldenSwitchMult += 0.1;
}
}
@@ -468,7 +471,7 @@ CM.Sim.CalculateGains = function() {
CM.Sim.CheckOtherAchiev = function() {
var grandmas = 0;
for (var i in Game.GrandmaSynergies) {
for (let i of Object.keys(Game.GrandmaSynergies)) {
if (CM.Sim.Has(Game.GrandmaSynergies[i])) grandmas++;
}
if (!CM.Sim.HasAchiev('Elder') && grandmas >= 7) CM.Sim.Win('Elder');
@@ -478,7 +481,7 @@ CM.Sim.CheckOtherAchiev = function() {
var mathematician = 1;
var base10 = 1;
var minAmount = 100000;
for (var i in CM.Sim.Objects) {
for (let i of Object.keys(CM.Sim.Objects)) {
buildingsOwned += CM.Sim.Objects[i].amount;
minAmount = Math.min(CM.Sim.Objects[i].amount, minAmount);
if (!CM.Sim.HasAchiev('Mathematician')) {
@@ -520,35 +523,35 @@ CM.Sim.CheckOtherAchiev = function() {
if (buildingsOwned >= 4000 && CM.Sim.UpgradesOwned >= 300) CM.Sim.Win('Polymath');
if (buildingsOwned >= 8000 && CM.Sim.UpgradesOwned >= 400) CM.Sim.Win('Renaissance baker');
if (CM.Sim.Objects['Cursor'].amount + CM.Sim.Objects['Grandma'].amount >= 777) CM.Sim.Win('The elder scrolls');
if (CM.Sim.Objects.Cursor.amount + CM.Sim.Objects.Grandma.amount >= 777) CM.Sim.Win('The elder scrolls');
var hasAllHalloCook = true;
for (var i in CM.Data.HalloCookies) {
for (let i of Object.keys(CM.Data.HalloCookies)) {
if (!CM.Sim.Has(CM.Data.HalloCookies[i])) hasAllHalloCook = false;
}
if (hasAllHalloCook) CM.Sim.Win('Spooky cookies');
var hasAllChristCook = true;
for (var i in CM.Data.ChristCookies) {
for (let i of Object.keys(CM.Data.ChristCookies)) {
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 list = Game.Tiers.fortune.upgrades;
var fortunes = 0;
for (var i in list) {
for (let i of Object.keys(list)) {
if (CM.Sim.Has(list[i].name)) fortunes++;
}
if (fortunes >= list.length) CM.Sim.Win('O Fortuna');
}
}
};
CM.Sim.BuyBuildings = function(amount, target) {
CM.Cache[target] = [];
for (var i in Game.Objects) {
for (let i of Object.keys(Game.Objects)) {
CM.Sim.CopyData();
var me = CM.Sim.Objects[i];
let me = CM.Sim.Objects[i];
me.amount += amount;
if (i == 'Cursor') {
@@ -587,14 +590,14 @@ CM.Sim.BuyBuildings = function(amount, target) {
CM.Cache.DoRemakeBuildPrices = 1;
}
}
}
};
CM.Sim.BuyUpgrades = function() {
CM.Cache.Upgrades = [];
for (var i in Game.Upgrades) {
for (let i of Object.keys(Game.Upgrades)) {
if (Game.Upgrades[i].pool == 'toggle' || (Game.Upgrades[i].bought == 0 && Game.Upgrades[i].unlocked && Game.Upgrades[i].pool != 'prestige')) {
CM.Sim.CopyData();
var me = CM.Sim.Upgrades[i];
let me = CM.Sim.Upgrades[i];
me.bought = 1;
if (Game.CountsAsUpgradeOwned(Game.Upgrades[i].pool)) CM.Sim.UpgradesOwned++;
@@ -604,7 +607,7 @@ CM.Sim.BuyUpgrades = function() {
if (CM.Sim.pledges >= 5) CM.Sim.Win('Elder slumber');
}
else if (i == 'Elder Covenant') {
CM.Sim.Win('Elder calm')
CM.Sim.Win('Elder calm');
}
else if (i == 'Prism heart biscuits') {
CM.Sim.Win('Lovely cookies');
@@ -630,7 +633,7 @@ CM.Sim.BuyUpgrades = function() {
if (diffMouseCPS) CM.Cache.Upgrades[i].bonusMouse = diffMouseCPS;
}
}
}
};
/**
* This functions calculates the cps and cost of changing a Dragon Aura
@@ -642,25 +645,27 @@ CM.Sim.CalculateChangeAura = function(aura) {
CM.Sim.CopyData();
// Check if aura being changed is first or second aura
var auraToBeChanged = l('promptContent').children[0].innerHTML.includes("secondary")
var auraToBeChanged = l('promptContent').children[0].innerHTML.includes("secondary");
if (auraToBeChanged) CM.Sim.dragonAura2 = aura;
else CM.Sim.dragonAura = aura;
// Sell highest building but only if aura is different
let price = 0;
if (CM.Sim.dragonAura != CM.Cache.dragonAura || CM.Sim.dragonAura2 != CM.Cache.dragonAura2) {
for (var i = Game.ObjectsById.length; i > -1, --i;) {
for (let i = Game.ObjectsById.length; i > -1, --i;) {
if (Game.ObjectsById[i].amount > 0) {
var highestBuilding = CM.Sim.Objects[Game.ObjectsById[i].name].name;
CM.Sim.Objects[highestBuilding].amount -=1;
CM.Sim.buildingsOwned -= 1;
break
price = CM.Sim.Objects[highestBuilding].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[highestBuilding].amount - 1 -CM.Sim.Objects[highestBuilding].free));
price = Game.modifyBuildingPrice(CM.Sim.Objects[highestBuilding], price);
price = Math.ceil(price);
break;
}
}
// This calculates price of highest building
var price = CM.Sim.Objects[highestBuilding].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[highestBuilding].amount - 1 -CM.Sim.Objects[highestBuilding].free));
price = Game.modifyBuildingPrice(CM.Sim.Objects[highestBuilding], price);
price = Math.ceil(price);
} else var price = 0;
}
var lastAchievementsOwned = CM.Sim.AchievementsOwned;
CM.Sim.CalculateGains();
@@ -669,8 +674,8 @@ CM.Sim.CalculateChangeAura = function(aura) {
if (lastAchievementsOwned != CM.Sim.AchievementsOwned) {
CM.Sim.CalculateGains();
}
return [CM.Sim.cookiesPs - Game.cookiesPs, price]
}
return [CM.Sim.cookiesPs - Game.cookiesPs, price];
};
CM.Sim.NoGoldSwitchCookiesPS = function() {
if (Game.Has('Golden switch [off]')) {
@@ -680,7 +685,7 @@ CM.Sim.NoGoldSwitchCookiesPS = function() {
CM.Cache.NoGoldSwitchCookiesPS = CM.Sim.cookiesPs;
}
else CM.Cache.NoGoldSwitchCookiesPS = Game.cookiesPs;
}
};
CM.Sim.ResetBonus = function(possiblePresMax) {
var lastAchievementsOwned = -1;
@@ -740,19 +745,19 @@ CM.Sim.ResetBonus = function(possiblePresMax) {
CM.Sim.CalculateGains();
}
var ResetCPS = CM.Sim.cookiesPs - curCPS
var ResetCPS = CM.Sim.cookiesPs - curCPS;
// Reset Pretige level after calculation
CM.Sim.prestige = Game.prestige;
return (ResetCPS);
}
};
CM.Sim.getSellMultiplier = function() {
var giveBack = 0.25;
giveBack *= 1 + CM.Sim.auraMult('Earth Shatterer');
return giveBack;
}
};
CM.Sim.modifyBuildingPrice = function(building,price) {
if (CM.Sim.Has('Season savings')) price *= 0.99;
@@ -768,13 +773,13 @@ CM.Sim.modifyBuildingPrice = function(building,price) {
if (building.fortune && CM.Sim.Has(building.fortune.name)) price *= 0.93;
price *= CM.Sim.eff('buildingCost');
if (CM.Sim.Objects.Temple.minigameLoaded) {
var godLvl = CM.Sim.hasGod('creation');
let godLvl = CM.Sim.hasGod('creation');
if (godLvl == 1) price *= 0.93;
else if (godLvl == 2) price *= 0.95;
else if (godLvl == 3) price *= 0.98;
}
return price;
}
};
CM.Sim.SellBuildingsForChoEgg = function() {
var sellTotal = 0;
@@ -792,7 +797,7 @@ CM.Sim.SellBuildingsForChoEgg = function() {
CM.Sim.dragonAura = 5;
CM.Sim.dragonAura2 = 18;
// Sacrifice highest buildings for the aura switch
for (var i = 0; i < buildingsToSacrifice; ++i) {
for (let i = 0; i < buildingsToSacrifice; ++i) {
var highestBuilding = 0;
for (var j in CM.Sim.Objects) {
if (CM.Sim.Objects[j].amount > 0) {
@@ -804,8 +809,8 @@ CM.Sim.SellBuildingsForChoEgg = function() {
}
// Get money made by selling all remaining buildings
for (var i in CM.Sim.Objects) {
var me = CM.Sim.Objects[i];
for (let i of Object.keys(CM.Sim.Objects)) {
let me = CM.Sim.Objects[i];
sellTotal += CM.Sim.BuildingSell(Game.Objects[me.name], Game.Objects[i].basePrice, me.amount, Game.Objects[i].free, me.amount);
}
@@ -820,7 +825,7 @@ CM.Sim.SellBuildingsForChoEgg = function() {
// CM.Cache.DoRemakeBuildPrices = 1;
return sellTotal;
}
};
/********
* Section: Functions used to calculate clicking power */
@@ -842,8 +847,8 @@ CM.Sim.mouseCps = function() {
if (CM.Sim.Has('Octillion fingers')) add *= 20;
if (CM.Sim.Has('Nonillion fingers')) add *= 20;
var num=0;
for (var i in CM.Sim.Objects) {num+=CM.Sim.Objects[i].amount;}
num -= CM.Sim.Objects['Cursor'].amount;
for (let i of Object.keys(CM.Sim.Objects)) {num+=CM.Sim.Objects[i].amount;}
num -= CM.Sim.Objects.Cursor.amount;
add = add * num;
// Use CM.Sim.cookiesPs as function is always called after CM.Sim.CalculateGains()
@@ -872,7 +877,7 @@ CM.Sim.mouseCps = function() {
if (CM.Sim.Has('Aura gloves'))
{
mult *= 1 + 0.05 * Math.min(Game.Objects['Cursor'].level, CM.Sim.Has('Luminous gloves') ? 20 : 10);
mult *= 1 + 0.05 * Math.min(Game.Objects.Cursor.level, CM.Sim.Has('Luminous gloves') ? 20 : 10);
}
mult *= CM.Sim.eff('click');
@@ -886,7 +891,7 @@ CM.Sim.mouseCps = function() {
}
}
for (var i in Game.buffs)
for (let i of Object.keys(Game.buffs))
{
if (typeof Game.buffs[i].multClick != 'undefined') mult*=Game.buffs[i].multClick;
}
@@ -902,4 +907,5 @@ CM.Sim.mouseCps = function() {
if (Game.hasBuff('Cursed finger')) out = Game.buffs['Cursed finger'].power;
return out;
}
};