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

View File

@@ -13,12 +13,12 @@
*/ */
CM.Config.SaveConfig = function() { CM.Config.SaveConfig = function() {
let saveString = b64_to_utf8(unescape(localStorage.getItem('CookieClickerGame')).split('!END!')[0]); let saveString = b64_to_utf8(unescape(localStorage.getItem('CookieClickerGame')).split('!END!')[0]);
CookieMonsterSave = saveString.match(/CookieMonster.*(;|$)/); let CookieMonsterSave = saveString.match(/CookieMonster.*(;|$)/);
if (CookieMonsterSave != null) { if (CookieMonsterSave != null) {
newSaveString = saveString.replace(CookieMonsterSave[0], "CookieMonster:" + CM.save()); let newSaveString = saveString.replace(CookieMonsterSave[0], "CookieMonster:" + CM.save());
localStorage.setItem('CookieClickerGame', escape(utf8_to_b64(newSaveString)+'!END!')) 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 * 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 // Check values
var mod = false; var mod = false;
for (var i in CM.Data.ConfigDefault) { for (let i in CM.Data.ConfigDefault) {
if (typeof CM.Options[i] === 'undefined') { if (typeof CM.Options[i] === 'undefined') {
mod = true; mod = true;
CM.Options[i] = CM.Data.ConfigDefault[i]; CM.Options[i] = CM.Data.ConfigDefault[i];
@@ -54,7 +54,7 @@ CM.Config.LoadConfig = function(settings) {
} }
} }
else if (i == 'Header') { 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)) { if (typeof CM.Options[i][j] === 'undefined' || !(CM.Options[i][j] > -1 && CM.Options[i][j] < 2)) {
mod = true; mod = true;
CM.Options[i][j] = CM.Data.ConfigDefault[i][j]; CM.Options[i][j] = CM.Data.ConfigDefault[i][j];
@@ -62,7 +62,7 @@ CM.Config.LoadConfig = function(settings) {
} }
} }
else { // Colors 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') { if (typeof CM.Options[i][j] === 'undefined' || typeof CM.Options[i][j] != 'string') {
mod = true; mod = true;
CM.Options[i][j] = CM.Data.ConfigDefault[i][j]; CM.Options[i][j] = CM.Data.ConfigDefault[i][j];
@@ -72,7 +72,7 @@ CM.Config.LoadConfig = function(settings) {
} }
if (mod) CM.Config.SaveConfig(); if (mod) CM.Config.SaveConfig();
CM.Loop(); // Do loop once 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') { if (i != 'Header' && typeof CM.ConfigData[i].func !== 'undefined') {
CM.ConfigData[i].func(); CM.ConfigData[i].func();
} }
@@ -81,7 +81,7 @@ CM.Config.LoadConfig = function(settings) {
else { // Default values else { // Default values
CM.Config.RestoreDefault(); CM.Config.RestoreDefault();
} }
} };
/** /**
* This function reloads and resaves the default config as stored in CM.Data.ConfigDefault * 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.LoadConfig(CM.Data.ConfigDefault);
CM.Config.SaveConfig(); CM.Config.SaveConfig();
Game.UpdateMenu(); Game.UpdateMenu();
} };
/******** /********
* Section: Functions related to toggling or changing configs */ * 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]]; l(CM.ConfigPrefix + config).innerHTML = CM.ConfigData[config].label[CM.Options[config]];
CM.Config.SaveConfig(); CM.Config.SaveConfig();
} };
/** /**
* This function sets the value of the specified volume-option and updates the display in the options menu * 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.Options[config] = Math.round(l("slider" + config).value);
} }
CM.Config.SaveConfig(); CM.Config.SaveConfig();
} };
/** /**
* This function toggles header options by incrementing them with 1 and handling changes * 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]++; CM.Options.Header[config]++;
if (CM.Options.Header[config] > 1) CM.Options.Header[config] = 0; if (CM.Options.Header[config] > 1) CM.Options.Header[config] = 0;
CM.Config.SaveConfig(); CM.Config.SaveConfig();
} };
/******** /********
* Section: Functions related to notifications */ * Section: Functions related to notifications */
@@ -154,14 +154,14 @@ CM.Config.ToggleHeader = function(config) {
CM.Config.CheckNotificationPermissions = function(ToggleOnOff) { CM.Config.CheckNotificationPermissions = function(ToggleOnOff) {
if (ToggleOnOff == 1) { if (ToggleOnOff == 1) {
// Check if browser support Promise version of Notification Permissions // Check if browser support Promise version of Notification Permissions
function checkNotificationPromise() { let checkNotificationPromise = function () {
try { try {
Notification.requestPermission().then(); Notification.requestPermission().then();
} catch(e) { } catch(e) {
return false; return false;
} }
return true; return true;
} };
// Check if the browser supports notifications and which type // Check if the browser supports notifications and which type
if (!('Notification' in window)) { 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.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.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.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 */ * Section: All possible effects plants and other items can have with an explanation */
@@ -60,7 +60,7 @@ CM.Data.Effects = {
wrathCookieGain: "Wrath cookie gains", wrathCookieGain: "Wrath cookie gains",
wrinklerEat: "Wrinkler ", wrinklerEat: "Wrinkler ",
wrinklerSpawn: "Wrinkler spawn frequency" wrinklerSpawn: "Wrinkler spawn frequency"
} };
/******** /********
* Section: Data for the various scales used by CookieMonster */ * 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', 'USp', 'DSp', 'TSp', 'QaSp', 'QiSp', 'SxSp', 'SpSp', 'OSp', 'NSp', 'Oco',
'UOc', 'DOc', 'TOc', 'QaOc', 'QiOc', 'SxOc', 'SpOc', 'OOc', 'NOc', 'Noa', 'UOc', 'DOc', 'TOc', 'QaOc', 'QiOc', 'SxOc', 'SpOc', 'OOc', 'NOc', 'Noa',
'UNo', 'DNo', 'TNo', 'QaNo', 'QiNo', 'SxNo', 'SpNo', 'ONo', 'NNo', 'Ct', '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 */ * Section: Two array's containing all Config groups and their to-be displayed title */
@@ -90,7 +90,7 @@ CM.ConfigGroups = {
Statistics: "Statistics", Statistics: "Statistics",
Notation: "Notation", Notation: "Notation",
Miscellaneous: "Miscellaneous" Miscellaneous: "Miscellaneous"
} };
CM.ConfigGroupsNotification = { CM.ConfigGroupsNotification = {
NotificationGC: "Golden Cookie", NotificationGC: "Golden Cookie",
@@ -100,7 +100,7 @@ CM.ConfigGroupsNotification = {
NotificationMagi: "Full Magic Bar", NotificationMagi: "Full Magic Bar",
NotificationWrink: "Wrinkler", NotificationWrink: "Wrinkler",
NotificationWrinkMax: "Maximum Wrinklers", NotificationWrinkMax: "Maximum Wrinklers",
} };
/******** /********
* Section: An array (CM.ConfigData) containing all Config options and an array of default settings */ * 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.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.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'}; 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.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'}; 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.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.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'}; 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.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'}; 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.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.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'}; 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.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.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.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.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'}; 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.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'}; 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.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.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'}; 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.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'}; 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.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.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'}; 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.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'}; 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.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.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'}; 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.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'}; 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(); CM.DelayInit();
Game.registerHook('draw', CM.Disp.Draw); Game.registerHook('draw', CM.Disp.Draw);
} }
} };
/** /**
* This registers a save function to the CM object. Per Game code/comments: * This registers a save function to the CM object. Per Game code/comments:
@@ -32,7 +32,7 @@ CM.save = function() {
settings: CM.Options, settings: CM.Options,
version: CM.VersionMajor + '.' + CM.VersionMinor, version: CM.VersionMajor + '.' + CM.VersionMinor,
}); });
} };
/** /**
* This registers a load function to the CM object. Per Game code/comments: * This registers a load function to the CM object. Per Game code/comments:
@@ -41,7 +41,7 @@ CM.save = function() {
CM.load = function(str) { CM.load = function(str) {
let save = JSON.parse(str); let save = JSON.parse(str);
CM.Config.LoadConfig(save.settings); CM.Config.LoadConfig(save.settings);
} };
/******** /********
* Section: Functions related to the initialization of CookieMonster */ * 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.type = 'text/javascript';
CM.Footer.Jscolor.setAttribute('src', 'https://aktanusa.github.io/CookieMonster/jscolor/jscolor.js'); CM.Footer.Jscolor.setAttribute('src', 'https://aktanusa.github.io/CookieMonster/jscolor/jscolor.js');
document.head.appendChild(CM.Footer.Jscolor); document.head.appendChild(CM.Footer.Jscolor);
} };
/** /**
* This functions starts the initizialization and register CookieMonster * This functions starts the initizialization and register CookieMonster
@@ -72,6 +72,6 @@ if (!CM.isRunning) {
clearInterval(delay); clearInterval(delay);
} }
}, 500); }, 500);
CM.isRunning = 1 CM.isRunning = 1;
} }

View File

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

View File

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

View File

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