Merge pull request #604 from DanielNoord/feature/changelog

Final update for 2.031.4
This commit is contained in:
Daniël van Noord
2021-02-24 00:22:28 +01:00
committed by GitHub
13 changed files with 3321 additions and 1839 deletions

View File

@@ -1,26 +1,50 @@
module.exports = { module.exports = {
"env": { env: {
"browser": true, browser: true,
"es2021": true es2021: true,
}, },
"globals": { globals: {
"module": "readonly", module: 'readonly',
"Game": "writable", Game: 'writable',
"l": "readonly", l: 'readonly',
"b64_to_utf8": "readonly", b64_to_utf8: 'readonly',
"utf8_to_b64": "readonly", utf8_to_b64: 'readonly',
"Beautify": "writable", Beautify: 'writable',
"realAudio": "readonly", realAudio: 'readonly',
"JSColor": "readonly", JSColor: 'readonly',
"jscolor": "readonly", jscolor: 'readonly',
"BeautifyAll": "readonly", BeautifyAll: 'readonly',
"CM": "writable", CM: 'writable',
"unsafeWindow": "readonly", unsafeWindow: 'readonly',
}, },
"extends": "eslint:recommended", extends: 'airbnb-base',
"parserOptions": { parserOptions: {
"ecmaVersion": 12 ecmaVersion: 12,
}, },
"rules": { rules: {
} indent: ['error', 'tab'],
'no-tabs': 'off',
'max-len': 'off',
'no-param-reassign': 'off',
'no-plusplus': 'off',
'no-new-func': 'off',
'no-eval': 'off',
'no-restricted-properties': 'off',
'no-restricted-syntax': 'off',
'no-mixed-operators': 'off',
'prefer-destructuring': 'off',
'func-names': 'off',
'no-use-before-define': 'off',
'no-console': 'off',
'no-nested-ternary': 'off',
'object-shorthand': 'off',
'no-else-return': 'off',
'prefer-arrow-callback': 'off',
'no-new': 'off',
'no-alert': 'off',
'new-cap': 'off',
'no-restricted-globals': 'off',
'no-template-curly-in-string': 'off',
radix: 'off',
},
}; };

View File

@@ -6,7 +6,9 @@ jobs:
steps: steps:
- uses: actions/checkout@v2 - uses: actions/checkout@v2
- name: Run ESLint - name: Run ESLint
run: npx eslint src run: |
npm install
npx eslint src
Check_main_file: Check_main_file:
runs-on: ubuntu-latest runs-on: ubuntu-latest
steps: steps:

File diff suppressed because one or more lines are too long

1415
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -39,13 +39,15 @@
"homepage": "https://github.com/Aktanusa/CookieMonster#readme", "homepage": "https://github.com/Aktanusa/CookieMonster#readme",
"devDependencies": { "devDependencies": {
"eslint": "^7.19.0", "eslint": "^7.19.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.22.1",
"terser": "^5.6.0-beta" "terser": "^5.6.0-beta"
}, },
"ccrepo": { "ccrepo": {
"icon": [ "icon": [
10, 10,
0 0
], ],
"name": "Cookie Monster" "name": "Cookie Monster"
} }
} }

View File

@@ -1,8 +1,8 @@
/********* /**
* Cache * * Cache *
*********/ */
/******** /**
* Section: General Cache related functions */ * Section: General Cache related functions */
/** /**
@@ -10,7 +10,7 @@
* The declaration follows the structure of the CM.Cache.js file * The declaration follows the structure of the CM.Cache.js file
* It is called by CM.Main.DelayInit * It is called by CM.Main.DelayInit
*/ */
CM.Cache.InitCache = function() { CM.Cache.InitCache = function () {
CM.Cache.CacheDragonAuras(); CM.Cache.CacheDragonAuras();
CM.Cache.CacheWrinklers(); CM.Cache.CacheWrinklers();
CM.Cache.CacheStats(); CM.Cache.CacheStats();
@@ -20,11 +20,11 @@ CM.Cache.InitCache = function() {
CM.Cache.CacheSeaSpec(); CM.Cache.CacheSeaSpec();
CM.Cache.InitCookiesDiff(); CM.Cache.InitCookiesDiff();
CM.Cache.HeavenlyChipsDiff = new CMAvgQueue(5); // Used by CM.Cache.CacheHeavenlyChipsPS() CM.Cache.HeavenlyChipsDiff = new CMAvgQueue(5); // Used by CM.Cache.CacheHeavenlyChipsPS()
CM.Cache.CacheHeavenlyChipsPS CM.Cache.CacheHeavenlyChipsPS();
CM.Cache.CacheAvgCPS(); CM.Cache.CacheAvgCPS();
CM.Cache.CacheIncome(); CM.Cache.CacheIncome();
CM.Cache.CacheBuildingsPrices(); CM.Cache.CacheBuildingsPrices();
CM.Cache.CachePP(); CM.Cache.CachePP();
}; };
/** /**
@@ -32,7 +32,7 @@ CM.Cache.InitCache = function() {
* It is called by CM.Main.Loop() * It is called by CM.Main.Loop()
* @global {string} CM.Cache.TimeTillNextPrestige Time requried till next prestige level * @global {string} CM.Cache.TimeTillNextPrestige Time requried till next prestige level
*/ */
CM.Cache.LoopCache = function() { CM.Cache.LoopCache = function () {
// Update Wrinkler Bank // Update Wrinkler Bank
CM.Cache.CacheWrinklers(); CM.Cache.CacheWrinklers();
@@ -41,12 +41,11 @@ CM.Cache.LoopCache = function() {
CM.Cache.CacheAvgCPS(); CM.Cache.CacheAvgCPS();
CM.Cache.CacheHeavenlyChipsPS(); CM.Cache.CacheHeavenlyChipsPS();
let cookiesToNext = Game.HowManyCookiesReset(Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)) + 1) - (Game.cookiesEarned + Game.cookiesReset); const cookiesToNext = Game.HowManyCookiesReset(Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)) + 1) - (Game.cookiesEarned + Game.cookiesReset);
CM.Cache.TimeTillNextPrestige = CM.Disp.FormatTime(cookiesToNext / CM.Disp.GetCPS()); CM.Cache.TimeTillNextPrestige = CM.Disp.FormatTime(cookiesToNext / CM.Disp.GetCPS());
}; };
/**
/********
* Section: Helper functions */ * Section: Helper functions */
/** /**
@@ -63,7 +62,7 @@ class CMAvgQueue {
this.queue = []; this.queue = [];
} }
addLatest (newValue) { addLatest(newValue) {
if (this.queue.push(newValue) > this.maxLength) { if (this.queue.push(newValue) > this.maxLength) {
this.queue.shift(); this.queue.shift();
} }
@@ -74,7 +73,7 @@ class CMAvgQueue {
* @param {number} timePeriod The period in seconds to computer average over * @param {number} timePeriod The period in seconds to computer average over
* @returns {number} ret The average * @returns {number} ret The average
*/ */
calcAverage (timePeriod) { calcAverage(timePeriod) {
if (timePeriod > this.maxLength) timePeriod = this.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;
let ret = 0; let ret = 0;
@@ -85,7 +84,7 @@ class CMAvgQueue {
} }
} }
/******** /**
* Section: Functions related to Dragon Auras */ * Section: Functions related to Dragon Auras */
/** /**
@@ -95,12 +94,12 @@ class CMAvgQueue {
* @global {number} CM.Cache.dragonAura The number of the first (right) Aura * @global {number} CM.Cache.dragonAura The number of the first (right) Aura
* @global {number} CM.Cache.dragonAura2 The number of the second (left) Aura * @global {number} CM.Cache.dragonAura2 The number of the second (left) Aura
*/ */
CM.Cache.CacheDragonAuras = function() { CM.Cache.CacheDragonAuras = function () {
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 */
/** /**
@@ -110,7 +109,7 @@ CM.Cache.CacheDragonAuras = function() {
* @global {number} CM.Cache.WrinklersNormal The cookies of all normal wrinklers * @global {number} CM.Cache.WrinklersNormal The cookies of all normal wrinklers
* @global {[{number}, {number}]} CM.Cache.WrinklersFattest A list containing the cookies and the id of the fattest non-shiny wrinkler * @global {[{number}, {number}]} CM.Cache.WrinklersFattest A list containing the cookies and the id of the fattest non-shiny wrinkler
*/ */
CM.Cache.CacheWrinklers = function() { 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];
@@ -118,11 +117,11 @@ CM.Cache.CacheWrinklers = function() {
let sucked = Game.wrinklers[i].sucked; let sucked = Game.wrinklers[i].sucked;
let toSuck = 1.1; let toSuck = 1.1;
if (Game.Has('Sacrilegious corruption')) toSuck *= 1.05; if (Game.Has('Sacrilegious corruption')) toSuck *= 1.05;
if (Game.wrinklers[i].type==1) toSuck *= 3; // Shiny wrinklers if (Game.wrinklers[i].type === 1) toSuck *= 3; // Shiny wrinklers
sucked *= toSuck; sucked *= toSuck;
if (Game.Has('Wrinklerspawn')) sucked *= 1.05; if (Game.Has('Wrinklerspawn')) sucked *= 1.05;
if (CM.Sim.Objects.Temple.minigameLoaded) { if (CM.Sim.Objects.Temple.minigameLoaded) {
let godLvl = Game.hasGod('scorn'); const godLvl = Game.hasGod('scorn');
if (godLvl === 1) sucked *= 1.15; if (godLvl === 1) sucked *= 1.15;
else if (godLvl === 2) sucked *= 1.1; else if (godLvl === 2) sucked *= 1.1;
else if (godLvl === 3) sucked *= 1.05; else if (godLvl === 3) sucked *= 1.05;
@@ -135,7 +134,7 @@ CM.Cache.CacheWrinklers = function() {
} }
}; };
/******** /**
* Section: Functions related to Caching stats */ * Section: Functions related to Caching stats */
/** /**
@@ -152,10 +151,10 @@ CM.Cache.CacheWrinklers = function() {
* @global {number} CM.Cache.Edifice Cookies required for most expensive building through Spontaneous Edifice * @global {number} CM.Cache.Edifice Cookies required for most expensive building through Spontaneous Edifice
* @global {string} CM.Cache.EdificeBuilding Name of most expensive building possible with Spontaneous Edifice * @global {string} CM.Cache.EdificeBuilding Name of most expensive building possible with Spontaneous Edifice
*/ */
CM.Cache.CacheStats = function() { CM.Cache.CacheStats = function () {
CM.Cache.Lucky = (CM.Cache.NoGoldSwitchCookiesPS * 900) / 0.15; CM.Cache.Lucky = (CM.Cache.NoGoldSwitchCookiesPS * 900) / 0.15;
CM.Cache.Lucky *= CM.Cache.DragonsFortuneMultAdjustment; CM.Cache.Lucky *= CM.Cache.DragonsFortuneMultAdjustment;
let cpsBuffMult = CM.Cache.getCPSBuffMult(); const cpsBuffMult = CM.Cache.getCPSBuffMult();
if (cpsBuffMult > 0) CM.Cache.Lucky /= cpsBuffMult; if (cpsBuffMult > 0) CM.Cache.Lucky /= cpsBuffMult;
else CM.Cache.Lucky = 0; else CM.Cache.Lucky = 0;
CM.Cache.LuckyReward = CM.Cache.GoldenCookiesMult * (CM.Cache.Lucky * 0.15) + 13; CM.Cache.LuckyReward = CM.Cache.GoldenCookiesMult * (CM.Cache.Lucky * 0.15) + 13;
@@ -169,14 +168,14 @@ CM.Cache.CacheStats = function() {
CM.Cache.Edifice = 0; CM.Cache.Edifice = 0;
let max = 0; let max = 0;
let n = 0; let n = 0;
for (let i of Object.keys(Game.Objects)) { for (const 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 (let i of Object.keys(Game.Objects)) { for (const 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) {
CM.Cache.Edifice = Game.Objects[i].price * 2; CM.Cache.Edifice = Game.Objects[i].price * 2;
CM.Cache.EdificeBuilding = i; CM.Cache.EdificeBuilding = i;
} }
@@ -191,7 +190,7 @@ CM.Cache.CacheStats = function() {
* @param {number} CM.Cache.WrathCookiesMult Multiplier for wrath cookies * @param {number} CM.Cache.WrathCookiesMult Multiplier for wrath cookies
* @param {number} CM.Cache.DragonsFortuneMultAdjustment Multiplier for dragon fortune + active golden cookie * @param {number} CM.Cache.DragonsFortuneMultAdjustment Multiplier for dragon fortune + active golden cookie
*/ */
CM.Cache.CacheGoldenAndWrathCookiesMults = function() { CM.Cache.CacheGoldenAndWrathCookiesMults = function () {
if (CM.Footer.isInitzializing) { if (CM.Footer.isInitzializing) {
CM.Cache.GoldenCookiesMult = 1; CM.Cache.GoldenCookiesMult = 1;
CM.Cache.WrathCookiesMult = 1; CM.Cache.WrathCookiesMult = 1;
@@ -233,17 +232,16 @@ CM.Cache.CacheGoldenAndWrathCookiesMults = function() {
* @param {number} mult Multiplier * @param {number} mult Multiplier
* @returns [{number, number, number}] Total cookies earned, cookie needed for this and next level * @returns [{number, number, number}] Total cookies earned, cookie needed for this and next level
*/ */
CM.Cache.MaxChainCookieReward = function(digit, maxPayout, mult) { CM.Cache.MaxChainCookieReward = function (digit, maxPayout, mult) {
let totalFromChain = 0; let totalFromChain = 0;
let moni = 0; let moni = 0;
let nextMoni = 0; let nextMoni = 0;
let nextRequired = 0; let nextRequired = 0;
let chain = 1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10); let chain = 1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10);
while (nextMoni < maxPayout) { while (nextMoni < maxPayout) {
moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit * mult), maxPayout * mult)); moni = Math.max(digit, Math.min(Math.floor(1 / 9 * 10 ** chain * digit * mult), maxPayout * mult));
// TODO: Calculate Cookies or cps needed for next level of chain. See issue #29 nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * 10 ** (chain + 1) * digit * mult), maxPayout * mult));
nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * mult), maxPayout * mult)); nextRequired = Math.floor(1 / 9 * 10 ** (chain + 1) * digit * mult);
nextRequired = Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * mult);
totalFromChain += moni; totalFromChain += moni;
chain++; chain++;
} }
@@ -266,12 +264,12 @@ CM.Cache.MaxChainCookieReward = function(digit, maxPayout, mult) {
* @global {number} CM.Cache.ChainFrenzyWrathRequired Cookies needed for maximum reward for wrath frenzy chain * @global {number} CM.Cache.ChainFrenzyWrathRequired Cookies needed for maximum reward for wrath frenzy chain
* @global {number} CM.Cache.ChainFrenzyWrathRequiredNext Total cookies needed for next level for wrath frenzy chain * @global {number} CM.Cache.ChainFrenzyWrathRequiredNext Total cookies needed for next level for wrath frenzy chain
*/ */
CM.Cache.CacheChain = function() { CM.Cache.CacheChain = function () {
let maxPayout = CM.Cache.NoGoldSwitchCookiesPS * 60 * 60 * 6 * CM.Cache.DragonsFortuneMultAdjustment; let maxPayout = CM.Cache.NoGoldSwitchCookiesPS * 60 * 60 * 6 * CM.Cache.DragonsFortuneMultAdjustment;
// Removes effect of Frenzy etc. // Removes effect of Frenzy etc.
let cpsBuffMult = CM.Cache.getCPSBuffMult(); const cpsBuffMult = CM.Cache.getCPSBuffMult();
if (cpsBuffMult > 0) maxPayout /= cpsBuffMult; if (cpsBuffMult > 0) maxPayout /= cpsBuffMult;
else maxPayout = 0; else maxPayout = 0;
CM.Cache.ChainMaxReward = CM.Cache.MaxChainCookieReward(7, maxPayout, CM.Cache.GoldenCookiesMult); CM.Cache.ChainMaxReward = CM.Cache.MaxChainCookieReward(7, maxPayout, CM.Cache.GoldenCookiesMult);
CM.Cache.ChainRequired = CM.Cache.ChainMaxReward[1] * 2 / CM.Cache.GoldenCookiesMult; CM.Cache.ChainRequired = CM.Cache.ChainMaxReward[1] * 2 / CM.Cache.GoldenCookiesMult;
@@ -297,32 +295,32 @@ CM.Cache.CacheChain = function() {
* @global {string} CM.Cache.MissingUpgradesCookies String containig the HTML to create the "crates" for missing cookie upgrades * @global {string} CM.Cache.MissingUpgradesCookies String containig the HTML to create the "crates" for missing cookie upgrades
* @global {string} CM.Cache.MissingUpgradesPrestige String containig the HTML to create the "crates" for missing prestige upgrades * @global {string} CM.Cache.MissingUpgradesPrestige String containig the HTML to create the "crates" for missing prestige upgrades
*/ */
CM.Cache.CacheMissingUpgrades = function() { CM.Cache.CacheMissingUpgrades = function () {
CM.Cache.MissingUpgrades = ""; CM.Cache.MissingUpgrades = '';
CM.Cache.MissingUpgradesCookies = ""; CM.Cache.MissingUpgradesCookies = '';
CM.Cache.MissingUpgradesPrestige = ""; CM.Cache.MissingUpgradesPrestige = '';
let list = []; const list = [];
//sort the upgrades // sort the upgrades
for (let i of Object.keys(Game.Upgrades)) { for (const i of Object.keys(Game.Upgrades)) {
list.push(Game.Upgrades[i]); list.push(Game.Upgrades[i]);
} }
let sortMap = function(a, b) { const 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; return 0;
}; };
list.sort(sortMap); list.sort(sortMap);
for (let i of Object.keys(list)) { for (const i of Object.keys(list)) {
let me = list[i]; const me = list[i];
if (me.bought === 0) { if (me.bought === 0) {
let str = ''; let str = '';
str += CM.Disp.crateMissing(me); str += CM.Disp.crateMissing(me);
if (me.pool === 'prestige') CM.Cache.MissingUpgradesPrestige += str; if (me.pool === 'prestige') CM.Cache.MissingUpgradesPrestige += str;
else if (me.pool === 'cookie') CM.Cache.MissingUpgradesCookies += str; else if (me.pool === 'cookie') CM.Cache.MissingUpgradesCookies += str;
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;
} }
} }
}; };
@@ -332,7 +330,7 @@ CM.Cache.CacheMissingUpgrades = function() {
* It is called by CM.Main.Loop() and CM.Cache.InitCache() * It is called by CM.Main.Loop() and CM.Cache.InitCache()
* @global {number} CM.Cache.SeaSpec The reward for popping a reindeer * @global {number} CM.Cache.SeaSpec The reward for popping a reindeer
*/ */
CM.Cache.CacheSeaSpec = function() { CM.Cache.CacheSeaSpec = function () {
if (Game.season === 'christmas') { if (Game.season === 'christmas') {
let val = Game.cookiesPs * 60; let val = Game.cookiesPs * 60;
if (Game.hasBuff('Elder frenzy')) val *= 0.5; if (Game.hasBuff('Elder frenzy')) val *= 0.5;
@@ -347,39 +345,39 @@ CM.Cache.CacheSeaSpec = function() {
* It is called by CM.Cache.LoopCache() * It is called by CM.Cache.LoopCache()
* @global {number} CM.Cache.HCPerSecond The Heavenly Chips per second in the last five seconds * @global {number} CM.Cache.HCPerSecond The Heavenly Chips per second in the last five seconds
*/ */
CM.Cache.CacheHeavenlyChipsPS = function() { CM.Cache.CacheHeavenlyChipsPS = function () {
CM.Cache.HCPerSecond = 0; // Mainly there to not throw errors during initialization CM.Cache.HCPerSecond = 0; // Mainly there to not throw errors during initialization
let currDate = Math.floor(Date.now() / 1000); const currDate = Math.floor(Date.now() / 1000);
// Only calculate every new second // Only calculate every new second
if ((Game.T / Game.fps) % 1 === 0) { if ((Game.T / Game.fps) % 1 === 0) {
let chipsOwned = Game.HowMuchPrestige(Game.cookiesReset); const chipsOwned = Game.HowMuchPrestige(Game.cookiesReset);
let ascendNowToOwn = Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)); const ascendNowToOwn = Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned));
let ascendNowToGet = ascendNowToOwn - Math.floor(chipsOwned); const ascendNowToGet = ascendNowToOwn - Math.floor(chipsOwned);
// Add recent gains to AvgQueue's // Add recent gains to AvgQueue's
let timeDiff = currDate - CM.Cache.lastHeavenlyCheck; const timeDiff = currDate - CM.Cache.lastHeavenlyCheck;
let heavenlyChipsDiffAvg = Math.max(0, (ascendNowToGet - CM.Cache.lastHeavenlyChips)) / timeDiff; const heavenlyChipsDiffAvg = Math.max(0, (ascendNowToGet - CM.Cache.lastHeavenlyChips)) / timeDiff;
for (let i = 0; i < timeDiff; i++) { for (let i = 0; i < timeDiff; i++) {
CM.Cache.HeavenlyChipsDiff.addLatest(heavenlyChipsDiffAvg); CM.Cache.HeavenlyChipsDiff.addLatest(heavenlyChipsDiffAvg);
} }
// Store current data for next loop // Store current data for next loop
CM.Cache.lastHeavenlyCheck = currDate; CM.Cache.lastHeavenlyCheck = currDate;
CM.Cache.lastHeavenlyChips = ascendNowToGet; CM.Cache.lastHeavenlyChips = ascendNowToGet;
// Get average gain over period of 5 seconds // Get average gain over period of 5 seconds
CM.Cache.HCPerSecond = CM.Cache.HeavenlyChipsDiff.calcAverage(5); CM.Cache.HCPerSecond = CM.Cache.HeavenlyChipsDiff.calcAverage(5);
} }
} };
/******** /**
* Section: Functions related to caching CPS */ * Section: Functions related to caching CPS */
/** /**
* This functions caches creates the CMAvgQueue used by CM.Cache.CacheAvgCPS() to calculate CPS * This functions caches creates the CMAvgQueue used by CM.Cache.CacheAvgCPS() to calculate CPS
* Called by CM.Cache.InitCache() * Called by CM.Cache.InitCache()
*/ */
CM.Cache.InitCookiesDiff = function() { CM.Cache.InitCookiesDiff = function () {
CM.Cache.CookiesDiff = new CMAvgQueue(CM.Disp.cookieTimes[CM.Disp.cookieTimes.length - 1]); CM.Cache.CookiesDiff = new CMAvgQueue(CM.Disp.cookieTimes[CM.Disp.cookieTimes.length - 1]);
CM.Cache.WrinkDiff = new CMAvgQueue(CM.Disp.cookieTimes[CM.Disp.cookieTimes.length - 1]); CM.Cache.WrinkDiff = 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.WrinkFattestDiff = new CMAvgQueue(CM.Disp.cookieTimes[CM.Disp.cookieTimes.length - 1]);
@@ -395,8 +393,8 @@ CM.Cache.InitCookiesDiff = function() {
* @global {number} CM.Cache.AverageClicks Average cookies from clicking over time-period as defined by AvgClicksHist * @global {number} CM.Cache.AverageClicks Average cookies from clicking over time-period as defined by AvgClicksHist
* @global {number} CM.Cache.AvgCPSChoEgg Average cookies from combination of normal CPS and average Chocolate Cookie CPS * @global {number} CM.Cache.AvgCPSChoEgg Average cookies from combination of normal CPS and average Chocolate Cookie CPS
*/ */
CM.Cache.CacheAvgCPS = function() { CM.Cache.CacheAvgCPS = function () {
let currDate = Math.floor(Date.now() / 1000); const currDate = Math.floor(Date.now() / 1000);
// Only calculate every new second // Only calculate every new second
if ((Game.T / Game.fps) % 1 === 0) { if ((Game.T / Game.fps) % 1 === 0) {
let choEggTotal = Game.cookies + CM.Cache.SellForChoEgg; let choEggTotal = Game.cookies + CM.Cache.SellForChoEgg;
@@ -405,12 +403,12 @@ CM.Cache.CacheAvgCPS = function() {
choEggTotal *= 0.05; choEggTotal *= 0.05;
// Add recent gains to AvgQueue's // Add recent gains to AvgQueue's
let timeDiff = currDate - CM.Cache.lastCPSCheck; const timeDiff = currDate - CM.Cache.lastCPSCheck;
let bankDiffAvg = Math.max(0, (Game.cookies - CM.Cache.lastCookies)) / timeDiff; const bankDiffAvg = Math.max(0, (Game.cookies - CM.Cache.lastCookies)) / timeDiff;
let wrinkDiffAvg = Math.max(0, (CM.Cache.WrinklersTotal - CM.Cache.lastWrinkCookies)) / timeDiff; const wrinkDiffAvg = Math.max(0, (CM.Cache.WrinklersTotal - CM.Cache.lastWrinkCookies)) / timeDiff;
let wrinkFattestDiffAvg = Math.max(0, (CM.Cache.WrinklersFattest[0] - CM.Cache.lastWrinkFattestCookies)) / timeDiff; const wrinkFattestDiffAvg = Math.max(0, (CM.Cache.WrinklersFattest[0] - CM.Cache.lastWrinkFattestCookies)) / timeDiff;
let choEggDiffAvg = Math.max(0,(choEggTotal - CM.Cache.lastChoEgg)) / timeDiff; const choEggDiffAvg = Math.max(0, (choEggTotal - CM.Cache.lastChoEgg)) / timeDiff;
let clicksDiffAvg = (Game.cookieClicks - CM.Cache.lastClicks) / timeDiff; const clicksDiffAvg = (Game.cookieClicks - CM.Cache.lastClicks) / timeDiff;
for (let 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);
@@ -419,7 +417,7 @@ CM.Cache.CacheAvgCPS = function() {
CM.Cache.ClicksDiff.addLatest(clicksDiffAvg); CM.Cache.ClicksDiff.addLatest(clicksDiffAvg);
} }
// Store current data for next loop // Store current data for next loop
CM.Cache.lastCPSCheck = currDate; CM.Cache.lastCPSCheck = currDate;
CM.Cache.lastCookies = Game.cookies; CM.Cache.lastCookies = Game.cookies;
CM.Cache.lastWrinkCookies = CM.Cache.WrinklersTotal; CM.Cache.lastWrinkCookies = CM.Cache.WrinklersTotal;
@@ -428,7 +426,7 @@ CM.Cache.CacheAvgCPS = function() {
CM.Cache.lastClicks = Game.cookieClicks; CM.Cache.lastClicks = Game.cookieClicks;
// Get average gain over period of cpsLength seconds // Get average gain over period of cpsLength seconds
let cpsLength = CM.Disp.cookieTimes[CM.Options.AvgCPSHist]; const cpsLength = CM.Disp.cookieTimes[CM.Options.AvgCPSHist];
CM.Cache.AverageGainBank = CM.Cache.CookiesDiff.calcAverage(cpsLength); CM.Cache.AverageGainBank = CM.Cache.CookiesDiff.calcAverage(cpsLength);
CM.Cache.AverageGainWrink = CM.Cache.WrinkDiff.calcAverage(cpsLength); CM.Cache.AverageGainWrink = CM.Cache.WrinkDiff.calcAverage(cpsLength);
CM.Cache.AverageGainWrinkFattest = CM.Cache.WrinkFattestDiff.calcAverage(cpsLength); CM.Cache.AverageGainWrinkFattest = CM.Cache.WrinkFattestDiff.calcAverage(cpsLength);
@@ -437,14 +435,13 @@ CM.Cache.CacheAvgCPS = function() {
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;
let choEgg = (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg')); const choEgg = (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg'));
if (choEgg || CM.Options.CalcWrink === 0) { if (choEgg || CM.Options.CalcWrink === 0) {
CM.Cache.AvgCPSWithChoEgg = CM.Cache.AverageGainBank + CM.Cache.AverageGainWrink + (choEgg ? CM.Cache.AverageGainChoEgg : 0); CM.Cache.AvgCPSWithChoEgg = CM.Cache.AverageGainBank + CM.Cache.AverageGainWrink + (choEgg ? CM.Cache.AverageGainChoEgg : 0);
} } else CM.Cache.AvgCPSWithChoEgg = CM.Cache.AvgCPS;
else CM.Cache.AvgCPSWithChoEgg = CM.Cache.AvgCPS;
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]);
} }
}; };
@@ -453,14 +450,14 @@ CM.Cache.CacheAvgCPS = function() {
* It is called by CM.Main.Loop() * It is called by CM.Main.Loop()
* @global {number} CM.Cache.SellForChoEgg Total cookies to be gained from selling Chocolate egg * @global {number} CM.Cache.SellForChoEgg Total cookies to be gained from selling Chocolate egg
*/ */
CM.Cache.CacheSellForChoEgg = function() { CM.Cache.CacheSellForChoEgg = function () {
let sellTotal = 0; let sellTotal = 0;
// Compute cookies earned by selling stock market goods // Compute cookies earned by selling stock market goods
if (Game.Objects.Bank.minigameLoaded) { if (Game.Objects.Bank.minigameLoaded) {
let marketGoods = Game.Objects.Bank.minigame.goods; const marketGoods = Game.Objects.Bank.minigame.goods;
let goodsVal = 0; let goodsVal = 0;
for (let i of Object.keys(marketGoods)) { for (const i of Object.keys(marketGoods)) {
let marketGood = marketGoods[i]; const marketGood = marketGoods[i];
goodsVal += marketGood.stock * marketGood.val; goodsVal += marketGood.stock * marketGood.val;
} }
sellTotal += goodsVal * Game.cookiesPsRawHighest; sellTotal += goodsVal * Game.cookiesPsRawHighest;
@@ -476,15 +473,15 @@ CM.Cache.CacheSellForChoEgg = function() {
* @global {number} CM.Cache.CurrWrinklerCount Current number of wrinklers * @global {number} CM.Cache.CurrWrinklerCount Current number of wrinklers
* @global {number} CM.Cache.CurrWrinklerCPSMult Current multiplier of CPS because of wrinklers (excluding their negative sucking effect) * @global {number} CM.Cache.CurrWrinklerCPSMult Current multiplier of CPS because of wrinklers (excluding their negative sucking effect)
*/ */
CM.Cache.CacheCurrWrinklerCPS = function() { CM.Cache.CacheCurrWrinklerCPS = function () {
CM.Cache.CurrWrinklerCPSMult = 0; CM.Cache.CurrWrinklerCPSMult = 0;
let count = 0; let count = 0;
for (let i in Game.wrinklers) { for (const 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) {
let godLvl = Game.hasGod('scorn'); const godLvl = Game.hasGod('scorn');
if (godLvl === 1) godMult *= 1.15; if (godLvl === 1) godMult *= 1.15;
else if (godLvl === 2) godMult *= 1.1; else if (godLvl === 2) godMult *= 1.1;
else if (godLvl === 3) godMult *= 1.05; else if (godLvl === 3) godMult *= 1.05;
@@ -498,10 +495,10 @@ CM.Cache.CacheCurrWrinklerCPS = function() {
* It is called by CM.Sim.CalculateGains(), CM.Disp.UpdateTooltipWarnings(), CM.Cache.CacheStats() and CM.Cache.CacheChain() * It is called by CM.Sim.CalculateGains(), CM.Disp.UpdateTooltipWarnings(), CM.Cache.CacheStats() and CM.Cache.CacheChain()
* @returns {number} mult The multiplier * @returns {number} mult The multiplier
*/ */
CM.Cache.getCPSBuffMult = function() { CM.Cache.getCPSBuffMult = function () {
let mult = 1; let mult = 1;
for (let i of Object.keys(Game.buffs)) { for (const 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;
}; };
@@ -511,14 +508,13 @@ CM.Cache.getCPSBuffMult = function() {
* If so it CM.Sim.Win()'s them and the caller function will know to recall CM.Sim.CalculateGains() * If so it CM.Sim.Win()'s them and the caller function will know to recall CM.Sim.CalculateGains()
* It is called at the end of any functions that simulates certain behaviour * It is called at the end of any functions that simulates certain behaviour
*/ */
CM.Cache.NoGoldSwitchCPS = function() { CM.Cache.NoGoldSwitchCPS = function () {
if (Game.Has('Golden switch [off]')) { if (Game.Has('Golden switch [off]')) {
CM.Cache.NoGoldSwitchCookiesPS = CM.Sim.NoGoldSwitchCPS(); CM.Cache.NoGoldSwitchCookiesPS = CM.Sim.NoGoldSwitchCPS();
} } else CM.Cache.NoGoldSwitchCookiesPS = Game.cookiesPs;
else CM.Cache.NoGoldSwitchCookiesPS = Game.cookiesPs;
}; };
/******** /**
* Section: Functions related to "Specials" (Dragon and Santa) */ * Section: Functions related to "Specials" (Dragon and Santa) */
/** /**
@@ -527,48 +523,45 @@ CM.Cache.NoGoldSwitchCPS = function() {
* @global {number} CM.Cache.lastDragonLevel The last cached dragon level * @global {number} CM.Cache.lastDragonLevel The last cached dragon level
* @global {string} CM.Cache.CostDragonUpgrade The Beautified cost of the next upgrade * @global {string} CM.Cache.CostDragonUpgrade The Beautified cost of the next upgrade
*/ */
CM.Cache.CacheDragonCost = function() { CM.Cache.CacheDragonCost = function () {
if (CM.Cache.lastDragonLevel != Game.dragonLevel || CM.Sim.DoSims) { if (CM.Cache.lastDragonLevel !== Game.dragonLevel || CM.Sim.DoSims) {
if (Game.dragonLevel < 25 && Game.dragonLevels[Game.dragonLevel].buy.toString().includes("sacrifice")) { if (Game.dragonLevel < 25 && Game.dragonLevels[Game.dragonLevel].buy.toString().includes('sacrifice')) {
let target = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/Objects\[(.*)\]/)[1]; let target = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/Objects\[(.*)\]/)[1];
let amount = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/sacrifice\((.*?)\)/)[1]; const 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 {
let cost = 0; let cost = 0;
CM.Sim.CopyData(); CM.Sim.CopyData();
for (let i = 0; i < amount; i++) { for (let i = 0; i < amount; i++) {
let price = CM.Sim.Objects[target].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free)); let price = CM.Sim.Objects[target].basePrice * 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;
CM.Sim.Objects[target].amount--; CM.Sim.Objects[target].amount--;
} }
CM.Cache.CostDragonUpgrade = "Cost to rebuy: " + CM.Disp.Beautify(cost); CM.Cache.CostDragonUpgrade = `Cost to rebuy: ${CM.Disp.Beautify(cost)}`;
} }
} } else {
else {
let cost = 0; let cost = 0;
CM.Sim.CopyData(); CM.Sim.CopyData();
for (let j of Object.keys(Game.Objects)) { for (const 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 (let i = 0; i < amount; i++) { for (let i = 0; i < amount; i++) {
let price = CM.Sim.Objects[target].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free)); let price = CM.Sim.Objects[target].basePrice * 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;
CM.Sim.Objects[target].amount--; CM.Sim.Objects[target].amount--;
} }
} }
CM.Cache.CostDragonUpgrade = "Cost to rebuy: " + CM.Disp.Beautify(cost); CM.Cache.CostDragonUpgrade = `Cost to rebuy: ${CM.Disp.Beautify(cost)}`;
} }
} }
} }
@@ -576,14 +569,14 @@ CM.Cache.CacheDragonCost = function() {
} }
}; };
/******** /**
* Section: Functions related to caching income */ * Section: Functions related to caching income */
/** /**
* This functions caches the income gain of each building and upgrade and stores it in the cache * This functions caches the income gain of each building and upgrade and stores it in the cache
* It is called by CM.Main.Loop() and CM.Cache.InitCache() * It is called by CM.Main.Loop() and CM.Cache.InitCache()
*/ */
CM.Cache.CacheIncome = function() { CM.Cache.CacheIncome = function () {
// Simulate Building Buys for 1, 10 and 100 amount // Simulate Building Buys for 1, 10 and 100 amount
CM.Cache.CacheBuildingIncome(1, 'Objects1'); CM.Cache.CacheBuildingIncome(1, 'Objects1');
CM.Cache.CacheBuildingIncome(10, 'Objects10'); CM.Cache.CacheBuildingIncome(10, 'Objects10');
@@ -599,54 +592,54 @@ CM.Cache.CacheIncome = function() {
* @param {amount} amount Amount to be bought * @param {amount} amount Amount to be bought
* @parem {string} target The target Cache object ("Objects1", "Objects10" or "Objects100") * @parem {string} target The target Cache object ("Objects1", "Objects10" or "Objects100")
*/ */
CM.Cache.CacheBuildingIncome = function(amount, target) { CM.Cache.CacheBuildingIncome = function (amount, target) {
CM.Cache[target] = []; CM.Cache[target] = [];
for (let i of Object.keys(Game.Objects)) { for (const i of Object.keys(Game.Objects)) {
CM.Cache[target][i] = {}; CM.Cache[target][i] = {};
CM.Cache[target][i].bonus = CM.Sim.BuyBuildingsBonusIncome(i, amount); CM.Cache[target][i].bonus = CM.Sim.BuyBuildingsBonusIncome(i, amount);
if (amount != 1) { if (amount !== 1) {
CM.Cache.DoRemakeBuildPrices = 1; CM.Cache.DoRemakeBuildPrices = 1;
} }
} }
} };
/** /**
* This functions starts the calculation/simulation of the bonus income of upgrades * This functions starts the calculation/simulation of the bonus income of upgrades
* It is called by CM.Cache.CacheIncome() * It is called by CM.Cache.CacheIncome()
*/ */
CM.Cache.CacheUpgradeIncome = function() { CM.Cache.CacheUpgradeIncome = function () {
CM.Cache.Upgrades = []; CM.Cache.Upgrades = [];
for (let i of Object.keys(Game.Upgrades)) { for (const i of Object.keys(Game.Upgrades)) {
let bonusIncome = CM.Sim.BuyUpgradesBonusIncome(i); const bonusIncome = CM.Sim.BuyUpgradesBonusIncome(i);
CM.Cache.Upgrades[i] = {}; CM.Cache.Upgrades[i] = {};
if (bonusIncome[0]) CM.Cache.Upgrades[i].bonus = bonusIncome[0]; if (bonusIncome[0]) CM.Cache.Upgrades[i].bonus = bonusIncome[0];
if (bonusIncome[1]) CM.Cache.Upgrades[i].bonusMouse = bonusIncome[1]; if (bonusIncome[1]) CM.Cache.Upgrades[i].bonusMouse = bonusIncome[1];
} }
} };
/******** /**
* Section: Functions related to caching prices */ * Section: Functions related to caching prices */
/** /**
* This functions caches the price of each building and stores it in the cache * This functions caches the price of each building and stores it in the cache
* It is called by CM.Main.Loop() and CM.Cache.InitCache() * It is called by CM.Main.Loop() and CM.Cache.InitCache()
*/ */
CM.Cache.CacheBuildingsPrices = function() { CM.Cache.CacheBuildingsPrices = function () {
for (let i of Object.keys(Game.Objects)) { for (const i of Object.keys(Game.Objects)) {
CM.Cache.Objects1[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 1); CM.Cache.Objects1[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);
} }
}; };
/******** /**
* Section: Functions related to caching PP */ * Section: Functions related to caching PP */
/** /**
* This functions caches the PP of each building and upgrade and stores it in the cache * This functions caches the PP of each building and upgrade and stores it in the cache
* It is called by CM.Cache.LoopCache() and CM.Cache.InitCache() * It is called by CM.Cache.LoopCache() and CM.Cache.InitCache()
*/ */
CM.Cache.CachePP = function() { CM.Cache.CachePP = function () {
CM.Cache.CacheBuildingsPP(); CM.Cache.CacheBuildingsPP();
CM.Cache.CacheUpgradePP(); CM.Cache.CacheUpgradePP();
}; };
@@ -658,7 +651,7 @@ CM.Cache.CachePP = function() {
* @params {number} price The price of the object * @params {number} price The price of the object
* @returns {string} color The colour assosciated with the pp value * @returns {string} color The colour assosciated with the pp value
*/ */
CM.Cache.ColourOfPP = function(me, price) { CM.Cache.ColourOfPP = function (me, price) {
let color = ''; let color = '';
// Colour based on PP // Colour based on PP
if (me.pp <= 0 || me.pp === Infinity) color = CM.Disp.colorGray; if (me.pp <= 0 || me.pp === Infinity) color = CM.Disp.colorGray;
@@ -671,28 +664,28 @@ CM.Cache.ColourOfPP = function(me, price) {
// Colour based on price in terms of CPS // Colour based on price in terms of CPS
if (Number(CM.Options.PPSecondsLowerLimit) !== 0) { if (Number(CM.Options.PPSecondsLowerLimit) !== 0) {
if (price / CM.Disp.GetCPS() < Number(CM.Options.PPSecondsLowerLimit)) color = CM.Disp.colorBlue if (price / CM.Disp.GetCPS() < Number(CM.Options.PPSecondsLowerLimit)) color = CM.Disp.colorBlue;
} }
// Colour based on being able to purchase // Colour based on being able to purchase
if (CM.Options.PPOnlyConsiderBuyable) { if (CM.Options.PPOnlyConsiderBuyable) {
if (price - Game.cookies > 0) color = CM.Disp.colorRed; if (price - Game.cookies > 0) color = CM.Disp.colorRed;
} }
return color return color;
}; };
/** /**
* This functions caches the PP of each building it saves all date in CM.Cache.Objects... * This functions caches the PP of each building it saves all date in CM.Cache.Objects...
* It is called by CM.Cache.CachePP() * It is called by CM.Cache.CachePP()
*/ */
CM.Cache.CacheBuildingsPP = function() { CM.Cache.CacheBuildingsPP = function () {
CM.Cache.min = Infinity; CM.Cache.min = Infinity;
CM.Cache.max = 1; CM.Cache.max = 1;
CM.Cache.ArrayOfPPs = []; CM.Cache.ArrayOfPPs = [];
if (typeof CM.Options.PPExcludeTop === "undefined") CM.Options.PPExcludeTop = 0; // Otherwise breaks during initialization if (typeof CM.Options.PPExcludeTop === 'undefined') CM.Options.PPExcludeTop = 0; // Otherwise breaks during initialization
// Calculate PP and colors when compared to purchase of optimal building in single-purchase mode // Calculate PP and colors when compared to purchase of optimal building in single-purchase mode
if (CM.Options.ColorPPBulkMode === 0) { if (CM.Options.ColorPPBulkMode === 0) {
for (let i of Object.keys(CM.Cache.Objects1)) { for (const i of Object.keys(CM.Cache.Objects1)) {
if (Game.cookiesPs) { if (Game.cookiesPs) {
CM.Cache.Objects1[i].pp = (Math.max(Game.Objects[i].getPrice() - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].getPrice() / CM.Cache.Objects1[i].bonus); CM.Cache.Objects1[i].pp = (Math.max(Game.Objects[i].getPrice() - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].getPrice() / CM.Cache.Objects1[i].bonus);
} else CM.Cache.Objects1[i].pp = (Game.Objects[i].getPrice() / CM.Cache.Objects1[i].bonus); } else CM.Cache.Objects1[i].pp = (Game.Objects[i].getPrice() / CM.Cache.Objects1[i].bonus);
@@ -705,13 +698,13 @@ CM.Cache.CacheBuildingsPP = function() {
if (CM.Cache.ArrayOfPPs.length === 1) { if (CM.Cache.ArrayOfPPs.length === 1) {
break; break;
} }
CM.Cache.ArrayOfPPs.shift() CM.Cache.ArrayOfPPs.shift();
} }
} }
CM.Cache.min = CM.Cache.ArrayOfPPs[CM.Options.PPExcludeTop][0]; CM.Cache.min = CM.Cache.ArrayOfPPs[CM.Options.PPExcludeTop][0];
CM.Cache.max = CM.Cache.ArrayOfPPs[CM.Cache.ArrayOfPPs.length - 1][0]; CM.Cache.max = CM.Cache.ArrayOfPPs[CM.Cache.ArrayOfPPs.length - 1][0];
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 (let i of Object.keys(CM.Cache.Objects1)) { for (const i of Object.keys(CM.Cache.Objects1)) {
CM.Cache.Objects1[i].color = CM.Cache.ColourOfPP(CM.Cache.Objects1[i], Game.Objects[i].getPrice()); CM.Cache.Objects1[i].color = CM.Cache.ColourOfPP(CM.Cache.Objects1[i], Game.Objects[i].getPrice());
// Colour based on excluding certain top-buildings // Colour based on excluding certain top-buildings
for (let j = 0; j < CM.Options.PPExcludeTop; j++) { for (let j = 0; j < CM.Options.PPExcludeTop; j++) {
@@ -721,15 +714,14 @@ CM.Cache.CacheBuildingsPP = function() {
// Calculate PP of bulk-buy modes // Calculate PP of bulk-buy modes
CM.Cache.CacheBuildingsBulkPP('Objects10'); CM.Cache.CacheBuildingsBulkPP('Objects10');
CM.Cache.CacheBuildingsBulkPP('Objects100'); CM.Cache.CacheBuildingsBulkPP('Objects100');
} } else {
// 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 { const target = `Objects${Game.buyBulk}`;
let target = `Objects${Game.buyBulk}` for (const i of Object.keys(CM.Cache[target])) {
for (let i of Object.keys(CM.Cache[target])) {
if (Game.cookiesPs) { if (Game.cookiesPs) {
CM.Cache[target][i].pp = (Math.max(Game.Objects[i].bulkPrice - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].bulkPrice / CM.Cache[target][i].bonus); CM.Cache[target][i].pp = (Math.max(Game.Objects[i].bulkPrice - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].bulkPrice / CM.Cache[target][i].bonus);
} else CM.Cache[target][i].pp = (Game.Objects[i].bulkPrice / CM.Cache[target][i].bonus); } else CM.Cache[target][i].pp = (Game.Objects[i].bulkPrice / CM.Cache[target][i].bonus);
CM.Cache.ArrayOfPPs.push([CM.Cache[target][i].pp, Game.Objects[i].bulkPrice]) CM.Cache.ArrayOfPPs.push([CM.Cache[target][i].pp, Game.Objects[i].bulkPrice]);
} }
// Set CM.Cache.min to best non-excluded buidliung // Set CM.Cache.min to best non-excluded buidliung
CM.Cache.ArrayOfPPs.sort((a, b) => a[0] - b[0]); CM.Cache.ArrayOfPPs.sort((a, b) => a[0] - b[0]);
@@ -738,14 +730,14 @@ CM.Cache.CacheBuildingsPP = function() {
if (CM.Cache.ArrayOfPPs.length === 1) { if (CM.Cache.ArrayOfPPs.length === 1) {
break; break;
} }
CM.Cache.ArrayOfPPs.shift() CM.Cache.ArrayOfPPs.shift();
} }
} }
CM.Cache.min = CM.Cache.ArrayOfPPs[CM.Options.PPExcludeTop][0]; CM.Cache.min = CM.Cache.ArrayOfPPs[CM.Options.PPExcludeTop][0];
CM.Cache.max = CM.Cache.ArrayOfPPs[CM.Cache.ArrayOfPPs.length - 1][0]; CM.Cache.max = CM.Cache.ArrayOfPPs[CM.Cache.ArrayOfPPs.length - 1][0];
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 (let i of Object.keys(CM.Cache.Objects1)) { for (const i of Object.keys(CM.Cache.Objects1)) {
CM.Cache[target][i].color = CM.Cache.ColourOfPP(CM.Cache[target][i], Game.Objects[i].bulkPrice); CM.Cache[target][i].color = CM.Cache.ColourOfPP(CM.Cache[target][i], Game.Objects[i].bulkPrice);
// Colour based on excluding certain top-buildings // Colour based on excluding certain top-buildings
for (let j = 0; j < CM.Options.PPExcludeTop; j++) { for (let j = 0; j < CM.Options.PPExcludeTop; j++) {
@@ -760,8 +752,8 @@ CM.Cache.CacheBuildingsPP = function() {
* It saves all date in CM.Cache.Objects... * It saves all date in CM.Cache.Objects...
* It is called by CM.Cache.CacheBuildingsPP() * It is called by CM.Cache.CacheBuildingsPP()
*/ */
CM.Cache.CacheBuildingsBulkPP = function(target) { CM.Cache.CacheBuildingsBulkPP = function (target) {
for (let i of Object.keys(CM.Cache[target])) { for (const i of Object.keys(CM.Cache[target])) {
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 CM.Cache[target][i].pp = (CM.Cache[target][i].price / CM.Cache[target][i].bonus); } else CM.Cache[target][i].pp = (CM.Cache[target][i].price / CM.Cache[target][i].bonus);
@@ -774,18 +766,18 @@ CM.Cache.CacheBuildingsBulkPP = function(target) {
* This functions caches the PP of each building it saves all date in CM.Cache.Upgrades * This functions caches the PP of each building it saves all date in CM.Cache.Upgrades
* It is called by CM.Cache.CachePP() * It is called by CM.Cache.CachePP()
*/ */
CM.Cache.CacheUpgradePP = function() { CM.Cache.CacheUpgradePP = function () {
for (let i of Object.keys(CM.Cache.Upgrades)) { for (const i of Object.keys(CM.Cache.Upgrades)) {
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);
} else CM.Cache.Upgrades[i].pp = (Game.Upgrades[i].getPrice() / CM.Cache.Upgrades[i].bonus); } else 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 (Number.isNaN(CM.Cache.Upgrades[i].pp)) CM.Cache.Upgrades[i].pp = Infinity;
CM.Cache.Upgrades[i].color = CM.Cache.ColourOfPP(CM.Cache.Upgrades[i], Game.Upgrades[i].getPrice()); CM.Cache.Upgrades[i].color = CM.Cache.ColourOfPP(CM.Cache.Upgrades[i], Game.Upgrades[i].getPrice());
} }
}; };
/******** /**
* Section: Cached variables */ * Section: Cached variables */
/** /**

View File

@@ -1,22 +1,22 @@
/********** /**
* Config * * Config *
**********/ */
/******** /**
* Section: Functions related to saving, loading and restoring configs */ * Section: Functions related to saving, loading and restoring configs */
/** /**
* This function saves the config of CookieMonster without saving any of the other save-data * This function saves the config of CookieMonster without saving any of the other save-data
* This allows saving in between the autosave intervals * This allows saving in between the autosave intervals
* It is called by CM.Config.LoadConfig(), CM.Config.RestoreDefault(), CM.Config.ToggleConfig(), * It is called by CM.Config.LoadConfig(), CM.Config.RestoreDefault(), CM.Config.ToggleConfig(),
* CM.ToggleConfigVolume() and changes in options with type "url", "color" or "numscale" * CM.ToggleConfigVolume() and changes in options with type "url", "color" or "numscale"
*/ */
CM.Config.SaveConfig = function() { CM.Config.SaveConfig = function () {
let saveString = b64_to_utf8(unescape(localStorage.getItem('CookieClickerGame')).split('!END!')[0]); const saveString = b64_to_utf8(unescape(localStorage.getItem('CookieClickerGame')).split('!END!')[0]);
let CookieMonsterSave = saveString.match(/CookieMonster.*(;|$)/); const CookieMonsterSave = saveString.match(/CookieMonster.*(;|$)/);
if (CookieMonsterSave != null) { if (CookieMonsterSave !== null) {
let newSaveString = saveString.replace(CookieMonsterSave[0], "CookieMonster:" + CM.save()); const 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!`));
} }
}; };
@@ -24,46 +24,40 @@ CM.Config.SaveConfig = function() {
* 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
* It is called by CM.Main.DelayInit() and CM.Config.RestoreDefault() * It is called by CM.Main.DelayInit() and CM.Config.RestoreDefault()
*/ */
CM.Config.LoadConfig = function(settings) { CM.Config.LoadConfig = function (settings) {
// This removes cookies left from earlier versions of CookieMonster // This removes cookies left from earlier versions of CookieMonster
if (typeof localStorage.CMConfig != "undefined") { if (typeof localStorage.CMConfig !== 'undefined') {
delete localStorage.CMConfig; delete localStorage.CMConfig;
} }
if (settings != null) { if (settings !== undefined) {
CM.Options = settings; CM.Options = settings;
// Check values // Check values
let mod = false; let mod = false;
for (let i in CM.Data.ConfigDefault) { for (const 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];
} } else if (i !== 'Header' && i !== 'Colors') {
else if (i != 'Header' && i != 'Colors') {
if (i.indexOf('SoundURL') === -1) { if (i.indexOf('SoundURL') === -1) {
if (!(CM.Options[i] > -1 && CM.Options[i] < CM.Data.Config[i].label.length)) { if (!(CM.Options[i] > -1 && CM.Options[i] < CM.Data.Config[i].label.length)) {
mod = true; mod = true;
CM.Options[i] = CM.Data.ConfigDefault[i]; CM.Options[i] = CM.Data.ConfigDefault[i];
} }
} else if (typeof CM.Options[i] !== 'string') { // Sound URLs
mod = true;
CM.Options[i] = CM.Data.ConfigDefault[i];
} }
else { // Sound URLs } else if (i === 'Header') {
if (typeof CM.Options[i] != 'string') { for (const j in CM.Data.ConfigDefault.Header) {
mod = true;
CM.Options[i] = CM.Data.ConfigDefault[i];
}
}
}
else if (i === '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];
} }
} }
} } else { // Colors
else { // Colors for (const 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,13 +66,12 @@ CM.Config.LoadConfig = function(settings) {
} }
if (mod) CM.Config.SaveConfig(); if (mod) CM.Config.SaveConfig();
CM.Main.Loop(); // Do loop once CM.Main.Loop(); // Do loop once
for (let i in CM.Data.ConfigDefault) { for (const i in CM.Data.ConfigDefault) {
if (i != 'Header' && typeof CM.Data.Config[i].func !== 'undefined') { if (i !== 'Header' && typeof CM.Data.Config[i].func !== 'undefined') {
CM.Data.Config[i].func(); CM.Data.Config[i].func();
} }
} }
} } else { // Default values
else { // Default values
CM.Config.RestoreDefault(); CM.Config.RestoreDefault();
} }
}; };
@@ -87,13 +80,13 @@ CM.Config.LoadConfig = function(settings) {
* 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
* It is called by resDefBut.onclick loaded in the options page or by CM.Config.LoadConfig if no localStorage is found * It is called by resDefBut.onclick loaded in the options page or by CM.Config.LoadConfig if no localStorage is found
*/ */
CM.Config.RestoreDefault = function() { 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 */
/** /**
@@ -101,14 +94,13 @@ CM.Config.RestoreDefault = function() {
* It is called by the onclick event of options of the "bool" type * It is called by the onclick event of options of the "bool" type
* @param {string} config The name of the option * @param {string} config The name of the option
*/ */
CM.Config.ToggleConfig = function(config) { CM.Config.ToggleConfig = function (config) {
CM.Options[config]++; CM.Options[config]++;
if (CM.Options[config] === CM.Data.Config[config].label.length) { if (CM.Options[config] === CM.Data.Config[config].label.length) {
CM.Options[config] = 0; CM.Options[config] = 0;
if (CM.Data.Config[config].toggle) l(CM.Config.ConfigPrefix + config).className = 'option off'; if (CM.Data.Config[config].toggle) l(CM.Config.ConfigPrefix + config).className = 'option off';
} } else l(CM.Config.ConfigPrefix + config).className = 'option';
else l(CM.Config.ConfigPrefix + config).className = 'option';
if (typeof CM.Data.Config[config].func !== 'undefined') { if (typeof CM.Data.Config[config].func !== 'undefined') {
CM.Data.Config[config].func(); CM.Data.Config[config].func();
@@ -123,11 +115,11 @@ CM.Config.ToggleConfig = function(config) {
* It is called by the oninput and onchange event of "vol" type options * It is called by the oninput and onchange event of "vol" type options
* @param {string} config The name of the option * @param {string} config The name of the option
*/ */
CM.Config.ToggleConfigVolume = function(config) { CM.Config.ToggleConfigVolume = function (config) {
if (l("slider" + config) != null) { if (l(`slider${config}`) !== null) {
l("slider" + config + "right").innerHTML = l("slider" + config).value + "%"; l(`slider${config}right`).innerHTML = `${l(`slider${config}`).value}%`;
CM.Options[config] = Math.round(l("slider" + config).value); CM.Options[config] = Math.round(l(`slider${config}`).value);
} }
CM.Config.SaveConfig(); CM.Config.SaveConfig();
}; };
@@ -136,13 +128,13 @@ CM.Config.ToggleConfigVolume = function(config) {
* It is called by the onclick event of the +/- next to headers * It is called by the onclick event of the +/- next to headers
* @param {string} config The name of the header * @param {string} config The name of the header
*/ */
CM.Config.ToggleHeader = function(config) { 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 */
/** /**
@@ -151,13 +143,13 @@ CM.Config.ToggleHeader = function(config) {
* Note that most browsers will stop asking if the user has ignored the prompt around 6 times * Note that most browsers will stop asking if the user has ignored the prompt around 6 times
* @param {number} ToggleOnOff A number indicating whether the option has been turned off (0) or on (1) * @param {number} ToggleOnOff A number indicating whether the option has been turned off (0) or on (1)
*/ */
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
let checkNotificationPromise = function () { const checkNotificationPromise = function () {
try { try {
Notification.requestPermission().then(); Notification.requestPermission().then();
} catch(e) { } catch (e) {
return false; return false;
} }
return true; return true;
@@ -165,20 +157,16 @@ CM.Config.CheckNotificationPermissions = function(ToggleOnOff) {
// 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)) {
console.log("This browser does not support notifications."); console.log('This browser does not support notifications.');
} } else if (checkNotificationPromise()) {
else { Notification.requestPermission().then();
if(checkNotificationPromise()) { } else {
Notification.requestPermission().then(); Notification.requestPermission();
}
else {
Notification.requestPermission();
}
} }
} }
}; };
/******** /**
* Section: Variables used in Config functions */ * Section: Variables used in Config functions */
/** /**

View File

@@ -1,109 +1,109 @@
/******** /**
* Data * * Data *
********/ */
/******** /**
* Section: Data used in the stats page to show not yet purchased updates. See CM.Disp.CreateStatsMissDisp() */ * Section: Data used in the stats page to show not yet purchased updates. See CM.Disp.CreateStatsMissDisp() */
CM.Data.Fortunes = [ CM.Data.Fortunes = [
'Fortune #001', 'Fortune #001',
'Fortune #002', 'Fortune #002',
'Fortune #003', 'Fortune #003',
'Fortune #004', 'Fortune #004',
'Fortune #005', 'Fortune #005',
'Fortune #006', 'Fortune #006',
'Fortune #007', 'Fortune #007',
'Fortune #008', 'Fortune #008',
'Fortune #009', 'Fortune #009',
'Fortune #010', 'Fortune #010',
'Fortune #011', 'Fortune #011',
'Fortune #012', 'Fortune #012',
'Fortune #013', 'Fortune #013',
'Fortune #014', 'Fortune #014',
'Fortune #015', 'Fortune #015',
'Fortune #016', 'Fortune #016',
'Fortune #017', 'Fortune #017',
'Fortune #018', 'Fortune #018',
'Fortune #100', 'Fortune #100',
'Fortune #101', 'Fortune #101',
'Fortune #102', 'Fortune #102',
'Fortune #103', 'Fortune #103',
'Fortune #104' 'Fortune #104',
]; ];
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 */
CM.Data.Effects = { CM.Data.Effects = {
buildingCost: "Building prices", buildingCost: 'Building prices',
click: "Cookies per click", click: 'Cookies per click',
cps: "Total CPS", cps: 'Total CPS',
cursorCps: "Cursor CPS", cursorCps: 'Cursor CPS',
goldenCookieDur: "Golden cookie duration", goldenCookieDur: 'Golden cookie duration',
goldenCookieEffDur: "Golden cookie effect duration", goldenCookieEffDur: 'Golden cookie effect duration',
goldenCookieFreq: "Golden cookie frequency", goldenCookieFreq: 'Golden cookie frequency',
goldenCookieGain: "Golden cookie gains", goldenCookieGain: 'Golden cookie gains',
grandmaCps: "Grandma CPS", grandmaCps: 'Grandma CPS',
itemDrops: "Random item drop chance", itemDrops: 'Random item drop chance',
milk: "Effect from milk", milk: 'Effect from milk',
reindeerDur: "Reindeer duration", reindeerDur: 'Reindeer duration',
reindeerFreq: "Reindeer frequency", reindeerFreq: 'Reindeer frequency',
reindeerGain: "Reindeer gains", reindeerGain: 'Reindeer gains',
upgradeCost: "Upgrade prices", upgradeCost: 'Upgrade prices',
wrathCookieDur: "Wrath cookie duration", wrathCookieDur: 'Wrath cookie duration',
wrathCookieEffDur: "Wrath cookie effect duration", wrathCookieEffDur: 'Wrath cookie effect duration',
wrathCookieFreq: "Wrath cookie frequency", wrathCookieFreq: 'Wrath cookie frequency',
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 */
CM.Data.metric = ['', '', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y']; CM.Data.metric = ['', '', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
CM.Data.shortScale = ['', '', 'M', 'B', 'Tr', 'Quadr', 'Quint', 'Sext', 'Sept', 'Oct', 'Non', 'Dec', 'Undec', 'Duodec', 'Tredec', 'Quattuordec', 'Quindec', 'Sexdec', 'Septendec', 'Octodec', 'Novemdec', 'Vigint', 'Unvigint', 'Duovigint', 'Trevigint', 'Quattuorvigint']; CM.Data.shortScale = ['', '', 'M', 'B', 'Tr', 'Quadr', 'Quint', 'Sext', 'Sept', 'Oct', 'Non', 'Dec', 'Undec', 'Duodec', 'Tredec', 'Quattuordec', 'Quindec', 'Sexdec', 'Septendec', 'Octodec', 'Novemdec', 'Vigint', 'Unvigint', 'Duovigint', 'Trevigint', 'Quattuorvigint'];
CM.Data.shortScaleAbbreviated = ['', 'K', 'M', 'B', 'T', 'Qa', 'Qi', 'Sx', 'Sp', 'Oc', 'No', 'De', CM.Data.shortScaleAbbreviated = ['', 'K', 'M', 'B', 'T', 'Qa', 'Qi', 'Sx', 'Sp', 'Oc', 'No', 'De',
'UDe', 'DDe', 'TDe', 'QaDe', 'QiDe', 'SxDe', 'SpDe', 'ODe', 'NDe', 'Vi', 'UDe', 'DDe', 'TDe', 'QaDe', 'QiDe', 'SxDe', 'SpDe', 'ODe', 'NDe', 'Vi',
'UVi', 'DVi', 'TVi', 'QaVi', 'QiVi', 'SxVi', 'SpVi', 'OVi', 'NVi', 'Tr', 'UVi', 'DVi', 'TVi', 'QaVi', 'QiVi', 'SxVi', 'SpVi', 'OVi', 'NVi', 'Tr',
'UTr', 'DTr', 'TTr', 'QaTr', 'QiTr', 'SxTr', 'SpTr', 'OTr', 'NTr', 'Qaa', 'UTr', 'DTr', 'TTr', 'QaTr', 'QiTr', 'SxTr', 'SpTr', 'OTr', 'NTr', 'Qaa',
'UQa', 'DQa', 'TQa', 'QaQa', 'QiQa', 'SxQa', 'SpQa', 'OQa', 'NQa', 'Qia', 'UQa', 'DQa', 'TQa', 'QaQa', 'QiQa', 'SxQa', 'SpQa', 'OQa', 'NQa', 'Qia',
'UQi', 'DQi', 'TQi', 'QaQi', 'QiQi', 'SxQi', 'SpQi', 'OQi', 'NQi', 'Sxa', 'UQi', 'DQi', 'TQi', 'QaQi', 'QiQi', 'SxQi', 'SpQi', 'OQi', 'NQi', 'Sxa',
'USx', 'DSx', 'TSx', 'QaSx', 'QiSx', 'SxSx', 'SpSx', 'OSx', 'NSx', 'Spa', 'USx', 'DSx', 'TSx', 'QaSx', 'QiSx', 'SxSx', 'SpSx', 'OSx', 'NSx', 'Spa',
'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 */
CM.Data.ConfigGroups = { CM.Data.ConfigGroups = {
BarsColors: "Bars/Colors", BarsColors: 'Bars/Colors',
Calculation: "Calculation", Calculation: 'Calculation',
Notification: "Notification", Notification: 'Notification',
Tooltip: "Tooltips and additional insights", Tooltip: 'Tooltips and additional insights',
Statistics: "Statistics", Statistics: 'Statistics',
Notation: "Notation", Notation: 'Notation',
Miscellaneous: "Miscellaneous" Miscellaneous: 'Miscellaneous',
}; };
CM.Data.ConfigGroupsNotification = { CM.Data.ConfigGroupsNotification = {
NotificationGeneral: "General Notifications", NotificationGeneral: 'General Notifications',
NotificationGC: "Golden Cookie", NotificationGC: 'Golden Cookie',
NotificationFC: "Fortune Cookie", NotificationFC: 'Fortune Cookie',
NotificationSea: "Season Special", NotificationSea: 'Season Special',
NotificationGard: "Garden Tick", NotificationGard: 'Garden Tick',
NotificationMagi: "Full Magic Bar", NotificationMagi: 'Full Magic Bar',
NotificationWrink: "Wrinkler", NotificationWrink: 'Wrinkler',
NotificationWrinkMax: "Maximum Wrinklers", NotificationWrinkMax: 'Maximum Wrinklers',
}; };
/******** /**
* Section: An array (CM.Data.Config) containing all Config options and an array of default settings */ * Section: An array (CM.Data.Config) containing all Config options and an array of default settings */
/** /**
@@ -117,140 +117,313 @@ CM.Data.ConfigGroupsNotification = {
* @item {function} func A function to be called when the option is toggled * @item {function} func A function to be called when the option is toggled
*/ */
// Barscolors // Barscolors
CM.Data.Config.BotBar = {type: 'bool', group: 'BarsColors', label: ['Bottom Bar OFF', 'Bottom Bar ON'], desc: 'Building Information', toggle: true, func: function() {CM.Disp.ToggleBotBar();}}; CM.Data.Config.BotBar = {
CM.Data.Config.TimerBar = {type: 'bool', group: 'BarsColors', label: ['Timer Bar OFF', 'Timer Bar ON'], desc: 'Timers of Golden Cookie, Season Popup, Frenzy (Normal, Clot, Elder), Click Frenzy', toggle: true, func: function() {CM.Disp.ToggleTimerBar();}}; type: 'bool', group: 'BarsColors', label: ['Bottom Bar OFF', 'Bottom Bar ON'], desc: 'Building Information', toggle: true, func: function () { CM.Disp.ToggleBotBar(); },
CM.Data.Config.TimerBarPos = {type: 'bool', group: 'BarsColors', label: ['Timer Bar Position (Top Left)', 'Timer Bar Position (Bottom)'], desc: 'Placement of the Timer Bar', toggle: false, func: function() {CM.Disp.ToggleTimerBarPos();}}; };
CM.Data.Config.TimerBarOverlay = {type: 'bool', group: 'BarsColors', label: ['Timer Bar Overlay OFF', 'Timer Bar Overlay Only Seconds', 'Timer Bar Overlay Full'], desc: 'Overlay on timers displaying seconds and/or percentage left', toggle: true}; CM.Data.Config.TimerBar = {
CM.Data.Config.SortBuildings = {type: 'bool', group: 'BarsColors', label: ['Sort Buildings: Default', 'Sort Buildings: PP'], desc: 'Sort the display of buildings in either default order or by PP', toggle: false, func: function () { CM.Disp.UpdateBuildings();}}; type: 'bool', group: 'BarsColors', label: ['Timer Bar OFF', 'Timer Bar ON'], desc: 'Timers of Golden Cookie, Season Popup, Frenzy (Normal, Clot, Elder), Click Frenzy', toggle: true, func: function () { CM.Disp.ToggleTimerBar(); },
CM.Data.Config.SortUpgrades = {type: 'bool', group: 'BarsColors', label: ['Sort Upgrades: Default', 'Sort Upgrades: PP'], desc: 'Sort the display of upgrades in either default order or by PP', toggle: false, func: function () { CM.Disp.UpdateUpgrades();}}; };
CM.Data.Config.BuildColor = {type: 'bool', group: 'BarsColors', label: ['Building Colors OFF', 'Building Colors ON'], desc: 'Color code buildings', toggle: true, func: function() {CM.Disp.UpdateBuildings();}}; CM.Data.Config.TimerBarPos = {
CM.Data.Config.BulkBuildColor = {type: 'bool', group: 'BarsColors', label: ['Bulk Building Colors (Single Building Color)', 'Bulk Building Colors (Calculated Bulk Color)'], desc: 'Color code bulk buildings based on single buildings color or calculated bulk value color', toggle: false, func: function() {CM.Disp.UpdateBuildings();}}; type: 'bool', group: 'BarsColors', label: ['Timer Bar Position (Top Left)', 'Timer Bar Position (Bottom)'], desc: 'Placement of the Timer Bar', toggle: false, func: function () { CM.Disp.ToggleTimerBarPos(); },
CM.Data.Config.UpBarColor = {type: 'bool', group: 'BarsColors', label: ['Upgrade Colors/Bar OFF', 'Upgrade Colors with Bar ON', 'Upgrade Colors without Bar ON'], desc: 'Color code upgrades and optionally add a counter bar', toggle: false, func: function() {CM.Disp.ToggleUpgradeBarAndColor();}}; };
CM.Data.Config.Colors = { type: 'color', group: 'BarsColors', CM.Data.Config.TimerBarOverlay = {
desc: { type: 'bool', group: 'BarsColors', label: ['Timer Bar Overlay OFF', 'Timer Bar Overlay Only Seconds', 'Timer Bar Overlay Full'], desc: 'Overlay on timers displaying seconds and/or percentage left', toggle: true,
Blue: 'Color Blue. Used to show better than best PP building, for Click Frenzy bar, and for various labels', };
Green: 'Color Green. Used to show best PP building, for Blood Frenzy bar, and for various labels', CM.Data.Config.SortBuildings = {
Yellow: 'Color Yellow. Used to show between best and worst PP buildings closer to best, for Frenzy bar, and for various labels', type: 'bool', group: 'BarsColors', label: ['Sort Buildings: Default', 'Sort Buildings: PP'], desc: 'Sort the display of buildings in either default order or by PP', toggle: false, func: function () { CM.Disp.UpdateBuildings(); },
Orange: 'Color Orange. Used to show between best and worst PP buildings closer to worst, for Next Reindeer bar, and for various labels', };
Red: 'Color Red. Used to show worst PP building, for Clot bar, and for various labels', CM.Data.Config.SortUpgrades = {
Purple: 'Color Purple. Used to show worse than worst PP building, for Next Cookie bar, and for various labels', type: 'bool', group: 'BarsColors', label: ['Sort Upgrades: Default', 'Sort Upgrades: PP'], desc: 'Sort the display of upgrades in either default order or by PP', toggle: false, func: function () { CM.Disp.UpdateUpgrades(); },
Gray: 'Color Gray. Used to show negative or infinity PP, and for Next Cookie/Next Reindeer bar', };
Pink: 'Color Pink. Used for Dragonflight bar', CM.Data.Config.BuildColor = {
Brown: 'Color Brown. Used for Dragon Harvest bar' type: 'bool', group: 'BarsColors', label: ['Building Colors OFF', 'Building Colors ON'], desc: 'Color code buildings', toggle: true, func: function () { CM.Disp.UpdateBuildings(); },
}, };
func: function() {CM.Disp.UpdateColors();} CM.Data.Config.BulkBuildColor = {
type: 'bool', group: 'BarsColors', label: ['Bulk Building Colors (Single Building Color)', 'Bulk Building Colors (Calculated Bulk Color)'], desc: 'Color code bulk buildings based on single buildings color or calculated bulk value color', toggle: false, func: function () { CM.Disp.UpdateBuildings(); },
};
CM.Data.Config.UpBarColor = {
type: 'bool', group: 'BarsColors', label: ['Upgrade Colors/Bar OFF', 'Upgrade Colors with Bar ON', 'Upgrade Colors without Bar ON'], desc: 'Color code upgrades and optionally add a counter bar', toggle: false, func: function () { CM.Disp.ToggleUpgradeBarAndColor(); },
};
CM.Data.Config.Colors = {
type: 'color',
group: 'BarsColors',
desc: {
Blue: 'Color Blue. Used to show better than best PP building, for Click Frenzy bar, and for various labels',
Green: 'Color Green. Used to show best PP building, for Blood Frenzy bar, and for various labels',
Yellow: 'Color Yellow. Used to show between best and worst PP buildings closer to best, for Frenzy bar, and for various labels',
Orange: 'Color Orange. Used to show between best and worst PP buildings closer to worst, for Next Reindeer bar, and for various labels',
Red: 'Color Red. Used to show worst PP building, for Clot bar, and for various labels',
Purple: 'Color Purple. Used to show worse than worst PP building, for Next Cookie bar, and for various labels',
Gray: 'Color Gray. Used to show negative or infinity PP, and for Next Cookie/Next Reindeer bar',
Pink: 'Color Pink. Used for Dragonflight bar',
Brown: 'Color Brown. Used for Dragon Harvest bar',
},
func: function () { CM.Disp.UpdateColors(); },
};
CM.Data.Config.UpgradeBarFixedPos = {
type: 'bool', group: 'BarsColors', label: ['Upgrade Bar Fixed Position OFF', 'Upgrade Bar Fixed Position ON'], desc: 'Lock the upgrade bar at top of the screen to prevent it from moving ofscreen when scrolling', toggle: true, func: function () { CM.Disp.ToggleUpgradeBarFixedPos(); },
}; };
CM.Data.Config.UpgradeBarFixedPos = {type: 'bool', group: 'BarsColors', label: ['Upgrade Bar Fixed Position OFF', 'Upgrade Bar Fixed Position ON'], desc: 'Lock the upgrade bar at top of the screen to prevent it from moving ofscreen when scrolling', toggle: true, func: function() {CM.Disp.ToggleUpgradeBarFixedPos();}};
// Calculation // Calculation
CM.Data.Config.CalcWrink = {type: 'bool', group: 'Calculation', label: ['Calculate with Wrinklers OFF', 'Calculate with Wrinklers ON', 'Calculate with Single Fattest Wrinkler ON'], desc: 'Calculate times and average Cookies Per Second with (only the single non-shiny fattest) Wrinklers', toggle: true}; CM.Data.Config.CalcWrink = {
CM.Data.Config.CPSMode = {type: 'bool', group: 'Calculation', label: ['Current Cookies Per Second', 'Average Cookies Per Second'], desc: 'Calculate times using current Cookies Per Second or average Cookies Per Second', toggle: false}; type: 'bool', group: 'Calculation', label: ['Calculate with Wrinklers OFF', 'Calculate with Wrinklers ON', 'Calculate with Single Fattest Wrinkler ON'], desc: 'Calculate times and average Cookies Per Second with (only the single non-shiny fattest) Wrinklers', toggle: true,
CM.Data.Config.AvgCPSHist = {type: 'bool', group: 'Calculation', label: ['Average CPS for past 10s', 'Average CPS for past 15s', 'Average CPS for past 30s', 'Average CPS for past 1m', 'Average CPS for past 5m', 'Average CPS for past 10m', 'Average CPS for past 15m', 'Average CPS for past 30m'], desc: 'How much time average Cookies Per Second should consider', toggle: false}; };
CM.Data.Config.AvgClicksHist = {type: 'bool', group: 'Calculation', label: ['Average Cookie Clicks for past 1s', 'Average Cookie Clicks for past 5s', 'Average Cookie Clicks for past 10s', 'Average Cookie Clicks for past 15s', 'Average Cookie Clicks for past 30s'], desc: 'How much time average Cookie Clicks should consider', toggle: false}; CM.Data.Config.CPSMode = {
CM.Data.Config.ColorPPBulkMode = {type: 'bool', group: 'Calculation', label: ['Color of PP (Compared to Single)', 'Color of PP (Compared to Bulk)'], desc: 'Color PP-values based on comparison with single purchase or with selected bulk-buy mode', toggle: false, func: function () {CM.Cache.CachePP();}}; type: 'bool', group: 'Calculation', label: ['Current Cookies Per Second', 'Average Cookies Per Second'], desc: 'Calculate times using current Cookies Per Second or average Cookies Per Second', toggle: false,
CM.Data.Config.PPExcludeTop = {type: 'bool', group: 'Calculation', label: ["Don't Ignore Any", 'Ignore 1st Best', 'Ignore 1st and 2nd Best', 'Ignore 1st, 2nd and 3rd Best'], desc: 'Makes CookieMonster ignore the 1st, 2nd or 3rd best buildings in labeling and colouring PP values', toggle: true}; };
CM.Data.Config.PPSecondsLowerLimit = {type: 'numscale', group: 'Calculation', label: 'Lower limit for PP (in seconds): ', desc: 'If a building or upgrade costs less than the specified seconds of CPS it will also be considered optimal and label it as such ("PP is less than xx seconds of CPS"); setting to 0 ignores this option', min: 0, max: Infinity}; CM.Data.Config.AvgCPSHist = {
CM.Data.Config.PPOnlyConsiderBuyable = {type: 'bool', group: 'Calculation', label: ["Don't Ignore Non-Buyable", 'Ignore Non-Buyable'], desc: "Makes CookieMonster label buildings and upgrades you can't buy right now red, useful in those situations where you just want to spend your full bank 'most optimally'", toggle: true}; type: 'bool', group: 'Calculation', label: ['Average CPS for past 10s', 'Average CPS for past 15s', 'Average CPS for past 30s', 'Average CPS for past 1m', 'Average CPS for past 5m', 'Average CPS for past 10m', 'Average CPS for past 15m', 'Average CPS for past 30m'], desc: 'How much time average Cookies Per Second should consider', toggle: false,
CM.Data.Config.ToolWarnBon = {type: 'bool', group: 'Calculation', label: ['Calculate Tooltip Warning With Bonus CPS OFF', 'Calculate Tooltip Warning With Bonus CPS ON'], desc: 'Calculate the warning with or without the bonus CPS you get from buying', toggle: true}; };
CM.Data.Config.AvgClicksHist = {
type: 'bool', group: 'Calculation', label: ['Average Cookie Clicks for past 1s', 'Average Cookie Clicks for past 5s', 'Average Cookie Clicks for past 10s', 'Average Cookie Clicks for past 15s', 'Average Cookie Clicks for past 30s'], desc: 'How much time average Cookie Clicks should consider', toggle: false,
};
CM.Data.Config.ColorPPBulkMode = {
type: 'bool', group: 'Calculation', label: ['Color of PP (Compared to Single)', 'Color of PP (Compared to Bulk)'], desc: 'Color PP-values based on comparison with single purchase or with selected bulk-buy mode', toggle: false, func: function () { CM.Cache.CachePP(); },
};
CM.Data.Config.PPExcludeTop = {
type: 'bool', group: 'Calculation', label: ["Don't Ignore Any", 'Ignore 1st Best', 'Ignore 1st and 2nd Best', 'Ignore 1st, 2nd and 3rd Best'], desc: 'Makes CookieMonster ignore the 1st, 2nd or 3rd best buildings in labeling and colouring PP values', toggle: true,
};
CM.Data.Config.PPSecondsLowerLimit = {
type: 'numscale', group: 'Calculation', label: 'Lower limit for PP (in seconds): ', desc: 'If a building or upgrade costs less than the specified seconds of CPS it will also be considered optimal and label it as such ("PP is less than xx seconds of CPS"); setting to 0 ignores this option', min: 0, max: Infinity,
};
CM.Data.Config.PPOnlyConsiderBuyable = {
type: 'bool', group: 'Calculation', label: ["Don't Ignore Non-Buyable", 'Ignore Non-Buyable'], desc: "Makes CookieMonster label buildings and upgrades you can't buy right now red, useful in those situations where you just want to spend your full bank 'most optimally'", toggle: true,
};
CM.Data.Config.ToolWarnBon = {
type: 'bool', group: 'Calculation', label: ['Calculate Tooltip Warning With Bonus CPS OFF', 'Calculate Tooltip Warning With Bonus CPS ON'], desc: 'Calculate the warning with or without the bonus CPS you get from buying', toggle: true,
};
// Notification // Notification
CM.Data.Config.Title = {type: 'bool', group: 'NotificationGeneral', label: ['Title OFF', 'Title ON', 'Title Pinned Tab Highlight'], desc: 'Update title with Golden Cookie/Season Popup timers; pinned tab highlight only changes the title when a Golden Cookie/Season Popup spawns; "!" means that Golden Cookie/Reindeer can spawn', toggle: true}; CM.Data.Config.Title = {
CM.Data.Config.GeneralSound = {type: 'bool', group: 'NotificationGeneral', label: ['Consider Game Volume Setting OFF', 'Consider Game Volume Setting ON'], desc: 'Turning this toggle to "off" makes Cookie Monster no longer consider the volume setting of the base game, allowing mod notifications to play with base game volume turned down', toggle: true}; type: 'bool', group: 'NotificationGeneral', label: ['Title OFF', 'Title ON', 'Title Pinned Tab Highlight'], desc: 'Update title with Golden Cookie/Season Popup timers; pinned tab highlight only changes the title when a Golden Cookie/Season Popup spawns; "!" means that Golden Cookie/Reindeer can spawn', toggle: true,
CM.Data.Config.GCNotification = {type: 'bool', group: 'NotificationGC', label: ['Notification OFF', 'Notification ON'], desc: 'Create a notification when Golden Cookie spawns', toggle: true, func: function () {CM.Config.CheckNotificationPermissions(CM.Options.GCNotification);}}; };
CM.Data.Config.GCFlash = {type: 'bool', group: 'NotificationGC', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen on Golden Cookie', toggle: true}; CM.Data.Config.GeneralSound = {
CM.Data.Config.GCSound = {type: 'bool', group: 'NotificationGC', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound on Golden Cookie', toggle: true}; type: 'bool', group: 'NotificationGeneral', label: ['Consider Game Volume Setting OFF', 'Consider Game Volume Setting ON'], desc: 'Turning this toggle to "off" makes Cookie Monster no longer consider the volume setting of the base game, allowing mod notifications to play with base game volume turned down', toggle: true,
CM.Data.Config.GCVolume = {type: 'vol', group: 'NotificationGC', label: [], desc: 'Volume'}; };
CM.Data.Config.GCNotification = {
type: 'bool', group: 'NotificationGC', label: ['Notification OFF', 'Notification ON'], desc: 'Create a notification when Golden Cookie spawns', toggle: true, func: function () { CM.Config.CheckNotificationPermissions(CM.Options.GCNotification); },
};
CM.Data.Config.GCFlash = {
type: 'bool', group: 'NotificationGC', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen on Golden Cookie', toggle: true,
};
CM.Data.Config.GCSound = {
type: 'bool', group: 'NotificationGC', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound on Golden Cookie', toggle: true,
};
CM.Data.Config.GCVolume = {
type: 'vol', group: 'NotificationGC', label: [], desc: 'Volume',
};
for (let i = 0; i < 101; i++) { for (let i = 0; i < 101; i++) {
CM.Data.Config.GCVolume.label[i] = i + '%'; CM.Data.Config.GCVolume.label[i] = `${i}%`;
} }
CM.Data.Config.GCSoundURL = {type: 'url', group: 'NotificationGC', label: 'Sound URL:', desc: 'URL of the sound to be played when a Golden Cookie spawns'}; CM.Data.Config.GCSoundURL = {
CM.Data.Config.FortuneNotification = {type: 'bool', group: 'NotificationFC', label: ['Notification OFF', 'Notification ON'], desc: 'Create a notification when Fortune Cookie is on the Ticker', toggle: true, func: function () {CM.Config.CheckNotificationPermissions(CM.Options.FortuneNotification);}}; type: 'url', group: 'NotificationGC', label: 'Sound URL:', desc: 'URL of the sound to be played when a Golden Cookie spawns',
CM.Data.Config.FortuneFlash = {type: 'bool', group: 'NotificationFC', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen on Fortune Cookie', toggle: true}; };
CM.Data.Config.FortuneSound = {type: 'bool', group: 'NotificationFC', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound on Fortune Cookie', toggle: true}; CM.Data.Config.FortuneNotification = {
CM.Data.Config.FortuneVolume = {type: 'vol', group: 'NotificationFC', label: [], desc: 'Volume'}; type: 'bool', group: 'NotificationFC', label: ['Notification OFF', 'Notification ON'], desc: 'Create a notification when Fortune Cookie is on the Ticker', toggle: true, func: function () { CM.Config.CheckNotificationPermissions(CM.Options.FortuneNotification); },
};
CM.Data.Config.FortuneFlash = {
type: 'bool', group: 'NotificationFC', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen on Fortune Cookie', toggle: true,
};
CM.Data.Config.FortuneSound = {
type: 'bool', group: 'NotificationFC', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound on Fortune Cookie', toggle: true,
};
CM.Data.Config.FortuneVolume = {
type: 'vol', group: 'NotificationFC', label: [], desc: 'Volume',
};
for (let i = 0; i < 101; i++) { for (let i = 0; i < 101; i++) {
CM.Data.Config.FortuneVolume.label[i] = i + '%'; CM.Data.Config.FortuneVolume.label[i] = `${i}%`;
} }
CM.Data.Config.FortuneSoundURL = {type: 'url', group: 'NotificationFC', label: 'Sound URL:', desc: 'URL of the sound to be played when the Ticker has a Fortune Cookie'}; CM.Data.Config.FortuneSoundURL = {
CM.Data.Config.SeaNotification = {type: 'bool', group: 'NotificationSea', label: ['Notification OFF', 'Notification ON'], desc: 'Create a notification on Season Popup', toggle: true, func: function () {CM.Config.CheckNotificationPermissions(CM.Options.SeaNotification);}}; type: 'url', group: 'NotificationFC', label: 'Sound URL:', desc: 'URL of the sound to be played when the Ticker has a Fortune Cookie',
CM.Data.Config.SeaFlash = {type: 'bool', group: 'NotificationSea', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen on Season Popup', toggle: true}; };
CM.Data.Config.SeaSound = {type: 'bool', group: 'NotificationSea', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound on Season Popup', toggle: true}; CM.Data.Config.SeaNotification = {
CM.Data.Config.SeaVolume = {type: 'vol', group: 'NotificationSea', label: [], desc: 'Volume'}; type: 'bool', group: 'NotificationSea', label: ['Notification OFF', 'Notification ON'], desc: 'Create a notification on Season Popup', toggle: true, func: function () { CM.Config.CheckNotificationPermissions(CM.Options.SeaNotification); },
};
CM.Data.Config.SeaFlash = {
type: 'bool', group: 'NotificationSea', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen on Season Popup', toggle: true,
};
CM.Data.Config.SeaSound = {
type: 'bool', group: 'NotificationSea', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound on Season Popup', toggle: true,
};
CM.Data.Config.SeaVolume = {
type: 'vol', group: 'NotificationSea', label: [], desc: 'Volume',
};
for (let i = 0; i < 101; i++) { for (let i = 0; i < 101; i++) {
CM.Data.Config.SeaVolume.label[i] = i + '%'; CM.Data.Config.SeaVolume.label[i] = `${i}%`;
} }
CM.Data.Config.SeaSoundURL = {type: 'url', group: 'NotificationSea', label: 'Sound URL:', desc: 'URL of the sound to be played when a Season Special spawns'}; CM.Data.Config.SeaSoundURL = {
CM.Data.Config.GardFlash = {type: 'bool', group: 'NotificationGard', label: ['Garden Tick Flash OFF', 'Flash ON'], desc: 'Flash screen on Garden Tick', toggle: true}; type: 'url', group: 'NotificationSea', label: 'Sound URL:', desc: 'URL of the sound to be played when a Season Special spawns',
CM.Data.Config.GardSound = {type: 'bool', group: 'NotificationGard', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound on Garden Tick', toggle: true}; };
CM.Data.Config.GardVolume = {type: 'vol', group: 'NotificationGard', label: [], desc: 'Volume'}; CM.Data.Config.GardFlash = {
type: 'bool', group: 'NotificationGard', label: ['Garden Tick Flash OFF', 'Flash ON'], desc: 'Flash screen on Garden Tick', toggle: true,
};
CM.Data.Config.GardSound = {
type: 'bool', group: 'NotificationGard', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound on Garden Tick', toggle: true,
};
CM.Data.Config.GardVolume = {
type: 'vol', group: 'NotificationGard', label: [], desc: 'Volume',
};
for (let i = 0; i < 101; i++) { for (let i = 0; i < 101; i++) {
CM.Data.Config.GardVolume.label[i] = i + '%'; CM.Data.Config.GardVolume.label[i] = `${i}%`;
} }
CM.Data.Config.GardSoundURL = {type: 'url', group: 'NotificationGard', label: 'Garden Tick Sound URL:', desc: 'URL of the sound to be played when the garden ticks'}; CM.Data.Config.GardSoundURL = {
CM.Data.Config.MagicNotification = {type: 'bool', group: 'NotificationMagi', label: ['Notification OFF', 'Notification ON'], desc: 'Create a notification when magic reaches maximum', toggle: true, func: function () {CM.Config.CheckNotificationPermissions(CM.Options.MagicNotification);}}; type: 'url', group: 'NotificationGard', label: 'Garden Tick Sound URL:', desc: 'URL of the sound to be played when the garden ticks',
CM.Data.Config.MagicFlash = {type: 'bool', group: 'NotificationMagi', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen when magic reaches maximum', toggle: true}; };
CM.Data.Config.MagicSound = {type: 'bool', group: 'NotificationMagi', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound when magic reaches maximum', toggle: true}; CM.Data.Config.MagicNotification = {
CM.Data.Config.MagicVolume = {type: 'vol', group: 'NotificationMagi', label: [], desc: 'Volume'}; type: 'bool', group: 'NotificationMagi', label: ['Notification OFF', 'Notification ON'], desc: 'Create a notification when magic reaches maximum', toggle: true, func: function () { CM.Config.CheckNotificationPermissions(CM.Options.MagicNotification); },
};
CM.Data.Config.MagicFlash = {
type: 'bool', group: 'NotificationMagi', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen when magic reaches maximum', toggle: true,
};
CM.Data.Config.MagicSound = {
type: 'bool', group: 'NotificationMagi', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound when magic reaches maximum', toggle: true,
};
CM.Data.Config.MagicVolume = {
type: 'vol', group: 'NotificationMagi', label: [], desc: 'Volume',
};
for (let i = 0; i < 101; i++) { for (let i = 0; i < 101; i++) {
CM.Data.Config.MagicVolume.label[i] = i + '%'; CM.Data.Config.MagicVolume.label[i] = `${i}%`;
} }
CM.Data.Config.MagicSoundURL = {type: 'url', group: 'NotificationMagi', label: 'Sound URL:', desc: 'URL of the sound to be played when magic reaches maxium'}; CM.Data.Config.MagicSoundURL = {
CM.Data.Config.WrinklerNotification = {type: 'bool', group: 'NotificationWrink', label: ['Notification OFF', 'Notification ON'], desc: 'Create a notification when a Wrinkler appears', toggle: true, func: function () {CM.Config.CheckNotificationPermissions(CM.Options.WrinklerNotification);}}; type: 'url', group: 'NotificationMagi', label: 'Sound URL:', desc: 'URL of the sound to be played when magic reaches maxium',
CM.Data.Config.WrinklerFlash = {type: 'bool', group: 'NotificationWrink', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen when a Wrinkler appears', toggle: true}; };
CM.Data.Config.WrinklerSound = {type: 'bool', group: 'NotificationWrink', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound when a Wrinkler appears', toggle: true}; CM.Data.Config.WrinklerNotification = {
CM.Data.Config.WrinklerVolume = {type: 'vol', group: 'NotificationWrink', label: [], desc: 'Volume'}; type: 'bool', group: 'NotificationWrink', label: ['Notification OFF', 'Notification ON'], desc: 'Create a notification when a Wrinkler appears', toggle: true, func: function () { CM.Config.CheckNotificationPermissions(CM.Options.WrinklerNotification); },
};
CM.Data.Config.WrinklerFlash = {
type: 'bool', group: 'NotificationWrink', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen when a Wrinkler appears', toggle: true,
};
CM.Data.Config.WrinklerSound = {
type: 'bool', group: 'NotificationWrink', label: ['Sound OFF', 'Sound ON'], desc: 'Play a sound when a Wrinkler appears', toggle: true,
};
CM.Data.Config.WrinklerVolume = {
type: 'vol', group: 'NotificationWrink', label: [], desc: 'Volume',
};
for (let i = 0; i < 101; i++) { for (let i = 0; i < 101; i++) {
CM.Data.Config.WrinklerVolume.label[i] = i + '%'; CM.Data.Config.WrinklerVolume.label[i] = `${i}%`;
} }
CM.Data.Config.WrinklerSoundURL = {type: 'url', group: 'NotificationWrink', label: 'Sound URL:', desc: 'URL of the sound to be played when a Wrinkler appears'}; CM.Data.Config.WrinklerSoundURL = {
CM.Data.Config.WrinklerMaxNotification = {type: 'bool', group: 'NotificationWrinkMax', label: ['Notification OFF', 'Notification ON'], desc: 'Create a notification when the maximum amount of Wrinklers has appeared', toggle: true, func: function () {CM.Config.CheckNotificationPermissions(CM.Options.WrinklerMaxNotification);}}; type: 'url', group: 'NotificationWrink', label: 'Sound URL:', desc: 'URL of the sound to be played when a Wrinkler appears',
CM.Data.Config.WrinklerMaxFlash = {type: 'bool', group: 'NotificationWrinkMax', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen when the maximum amount of Wrinklers has appeared', toggle: true}; };
CM.Data.Config.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.Data.Config.WrinklerMaxNotification = {
CM.Data.Config.WrinklerMaxVolume = {type: 'vol', group: 'NotificationWrinkMax', label: [], desc: 'Volume'}; type: 'bool', group: 'NotificationWrinkMax', label: ['Notification OFF', 'Notification ON'], desc: 'Create a notification when the maximum amount of Wrinklers has appeared', toggle: true, func: function () { CM.Config.CheckNotificationPermissions(CM.Options.WrinklerMaxNotification); },
};
CM.Data.Config.WrinklerMaxFlash = {
type: 'bool', group: 'NotificationWrinkMax', label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen when the maximum amount of Wrinklers has appeared', toggle: true,
};
CM.Data.Config.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.Data.Config.WrinklerMaxVolume = {
type: 'vol', group: 'NotificationWrinkMax', label: [], desc: 'Volume',
};
for (let i = 0; i < 101; i++) { for (let i = 0; i < 101; i++) {
CM.Data.Config.WrinklerMaxVolume.label[i] = i + '%'; CM.Data.Config.WrinklerMaxVolume.label[i] = `${i}%`;
} }
CM.Data.Config.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.Data.Config.WrinklerMaxSoundURL = {
type: 'url', group: 'NotificationWrinkMax', label: 'Sound URL:', desc: 'URL of the sound to be played when the maximum amount of Wrinklers has appeared',
};
// Tooltip // Tooltip
CM.Data.Config.TooltipBuildUpgrade = {type: 'bool', group: 'Tooltip', label: ['Building/Upgrade Tooltip Information OFF', 'Building/Upgrade Tooltip Information ON'], desc: 'Extra information in Building/Upgrade tooltips', toggle: true}; CM.Data.Config.TooltipBuildUpgrade = {
CM.Data.Config.TooltipAmor = {type: 'bool', group: 'Tooltip', label: ['Buildings Tooltip Amortization Information OFF', 'Buildings Tooltip Amortization Information ON'], desc: 'Add amortization information to buildings tooltip', toggle: true}; type: 'bool', group: 'Tooltip', label: ['Building/Upgrade Tooltip Information OFF', 'Building/Upgrade Tooltip Information ON'], desc: 'Extra information in Building/Upgrade tooltips', toggle: true,
CM.Data.Config.ToolWarnLucky = {type: 'bool', group: 'Tooltip', label: ['Tooltip Lucky Warning OFF', 'Tooltip Lucky Warning ON'], desc: 'A warning when buying if it will put the bank under the amount needed for max "Lucky!" rewards', toggle: true}; };
CM.Data.Config.ToolWarnLuckyFrenzy = {type: 'bool', group: 'Tooltip', label: ['Tooltip Lucky Frenzy Warning OFF', 'Tooltip Lucky Frenzy Warning ON'], desc: 'A warning when buying if it will put the bank under the amount needed for max "Lucky!" (Frenzy) rewards', toggle: true}; CM.Data.Config.TooltipAmor = {
CM.Data.Config.ToolWarnConjure = {type: 'bool', group: 'Tooltip', label: ['Tooltip Conjure Warning OFF', 'Tooltip Conjure Warning ON'], desc: 'A warning when buying if it will put the bank under the amount needed for max "Conjure Baked Goods" rewards', toggle: true}; type: 'bool', group: 'Tooltip', label: ['Buildings Tooltip Amortization Information OFF', 'Buildings Tooltip Amortization Information ON'], desc: 'Add amortization information to buildings tooltip', toggle: true,
CM.Data.Config.ToolWarnConjureFrenzy = {type: 'bool', group: 'Tooltip', label: ['Tooltip Conjure Frenzy Warning OFF', 'Tooltip Conjure Frenzy Warning ON'], desc: 'A warning when buying if it will put the bank under the amount needed for max "Conjure Baked Goods" rewards with Frenzy active', toggle: true}; };
CM.Data.Config.ToolWarnEdifice = {type: 'bool', group: 'Tooltip', label: ['Tooltip Edifice Warning OFF', 'Tooltip Edifice Warning ON'], desc: 'A warning when buying if it will put the bank under the amount needed for "Spontaneous Edifice" to possibly give you your most expensive building', toggle: true}; CM.Data.Config.ToolWarnLucky = {
CM.Data.Config.ToolWarnUser = {type: 'numscale', group: 'Tooltip', label: 'Tooltip Warning At x times CPS: ', desc: 'Use this to show a customized warning if buying it will put the bank under the amount equal to value times cps; setting to 0 disables the function altogether', min: 0, max: Infinity}; type: 'bool', group: 'Tooltip', label: ['Tooltip Lucky Warning OFF', 'Tooltip Lucky Warning ON'], desc: 'A warning when buying if it will put the bank under the amount needed for max "Lucky!" rewards', toggle: true,
CM.Data.Config.ToolWarnPos = {type: 'bool', group: 'Tooltip', label: ['Tooltip Warning Position (Left)', 'Tooltip Warning Position (Bottom)'], desc: 'Placement of the warning boxes', toggle: false, func: function() {CM.Disp.ToggleToolWarnPos();}}; };
CM.Data.Config.TooltipGrim = {type: 'bool', group: 'Tooltip', label: ['Grimoire Tooltip Information OFF', 'Grimoire Tooltip Information ON'], desc: 'Extra information in tooltip for grimoire', toggle: true}; CM.Data.Config.ToolWarnLuckyFrenzy = {
CM.Data.Config.TooltipWrink = {type: 'bool', group: 'Tooltip', label: ['Wrinkler Tooltip OFF', 'Wrinkler Tooltip ON'], desc: 'Shows the amount of cookies a wrinkler will give when popping it', toggle: true}; type: 'bool', group: 'Tooltip', label: ['Tooltip Lucky Frenzy Warning OFF', 'Tooltip Lucky Frenzy Warning ON'], desc: 'A warning when buying if it will put the bank under the amount needed for max "Lucky!" (Frenzy) rewards', toggle: true,
CM.Data.Config.TooltipLump = {type: 'bool', group: 'Tooltip', label: ['Sugar Lump Tooltip OFF', 'Sugar Lump Tooltip ON'], desc: 'Shows the current Sugar Lump type in Sugar lump tooltip.', toggle: true}; };
CM.Data.Config.TooltipPlots = {type: 'bool', group: 'Tooltip', label: ['Garden Plots Tooltip OFF', 'Garden Plots Tooltip ON'], desc: 'Shows a tooltip for plants that have a cookie reward.', toggle: true}; CM.Data.Config.ToolWarnConjure = {
CM.Data.Config.DragonAuraInfo = {type: 'bool', group: 'Tooltip', label: ['Extra Dragon Aura Info OFF', 'Extra Dragon Aura Info ON'], desc: 'Shows information about changes in CPS and costs in the dragon aura interface.', toggle: true}; type: 'bool', group: 'Tooltip', label: ['Tooltip Conjure Warning OFF', 'Tooltip Conjure Warning ON'], desc: 'A warning when buying if it will put the bank under the amount needed for max "Conjure Baked Goods" rewards', toggle: true,
CM.Data.Config.TooltipAscendButton = {type: 'bool', group: 'Tooltip', label: ['Show Extra Info Ascend Tooltip OFF', 'Show Extra Info Ascend Tooltip ON'], desc: 'Shows additional info in the ascend tooltip', toggle: true}; };
CM.Data.Config.ToolWarnConjureFrenzy = {
type: 'bool', group: 'Tooltip', label: ['Tooltip Conjure Frenzy Warning OFF', 'Tooltip Conjure Frenzy Warning ON'], desc: 'A warning when buying if it will put the bank under the amount needed for max "Conjure Baked Goods" rewards with Frenzy active', toggle: true,
};
CM.Data.Config.ToolWarnEdifice = {
type: 'bool', group: 'Tooltip', label: ['Tooltip Edifice Warning OFF', 'Tooltip Edifice Warning ON'], desc: 'A warning when buying if it will put the bank under the amount needed for "Spontaneous Edifice" to possibly give you your most expensive building', toggle: true,
};
CM.Data.Config.ToolWarnUser = {
type: 'numscale', group: 'Tooltip', label: 'Tooltip Warning At x times CPS: ', desc: 'Use this to show a customized warning if buying it will put the bank under the amount equal to value times cps; setting to 0 disables the function altogether', min: 0, max: Infinity,
};
CM.Data.Config.ToolWarnPos = {
type: 'bool', group: 'Tooltip', label: ['Tooltip Warning Position (Left)', 'Tooltip Warning Position (Bottom)'], desc: 'Placement of the warning boxes', toggle: false, func: function () { CM.Disp.ToggleToolWarnPos(); },
};
CM.Data.Config.TooltipGrim = {
type: 'bool', group: 'Tooltip', label: ['Grimoire Tooltip Information OFF', 'Grimoire Tooltip Information ON'], desc: 'Extra information in tooltip for grimoire', toggle: true,
};
CM.Data.Config.TooltipWrink = {
type: 'bool', group: 'Tooltip', label: ['Wrinkler Tooltip OFF', 'Wrinkler Tooltip ON'], desc: 'Shows the amount of cookies a wrinkler will give when popping it', toggle: true,
};
CM.Data.Config.TooltipLump = {
type: 'bool', group: 'Tooltip', label: ['Sugar Lump Tooltip OFF', 'Sugar Lump Tooltip ON'], desc: 'Shows the current Sugar Lump type in Sugar lump tooltip.', toggle: true,
};
CM.Data.Config.TooltipPlots = {
type: 'bool', group: 'Tooltip', label: ['Garden Plots Tooltip OFF', 'Garden Plots Tooltip ON'], desc: 'Shows a tooltip for plants that have a cookie reward.', toggle: true,
};
CM.Data.Config.DragonAuraInfo = {
type: 'bool', group: 'Tooltip', label: ['Extra Dragon Aura Info OFF', 'Extra Dragon Aura Info ON'], desc: 'Shows information about changes in CPS and costs in the dragon aura interface.', toggle: true,
};
CM.Data.Config.TooltipAscendButton = {
type: 'bool', group: 'Tooltip', label: ['Show Extra Info Ascend Tooltip OFF', 'Show Extra Info Ascend Tooltip ON'], desc: 'Shows additional info in the ascend tooltip', toggle: true,
};
// Statistics // Statistics
CM.Data.Config.Stats = {type: 'bool', group: 'Statistics', label: ['Statistics OFF', 'Statistics ON'], desc: 'Extra Cookie Monster statistics!', toggle: true}; CM.Data.Config.Stats = {
CM.Data.Config.MissingUpgrades = {type: 'bool', group: 'Statistics', label: ['Missing Upgrades OFF', 'Missing Upgrades ON'], desc: 'Shows Missing upgrades in Stats Menu. This feature can be laggy for users with a low amount of unlocked achievements.', toggle: true}; type: 'bool', group: 'Statistics', label: ['Statistics OFF', 'Statistics ON'], desc: 'Extra Cookie Monster statistics!', toggle: true,
CM.Data.Config.UpStats = {type: 'bool', group: 'Statistics', label: ['Statistics Update Rate (Default)', 'Statistics Update Rate (1s)'], desc: 'Default Game rate is once every 5 seconds', toggle: false}; };
CM.Data.Config.TimeFormat = {type: 'bool', group: 'Statistics', label: ['Time XXd, XXh, XXm, XXs', 'Time XX:XX:XX:XX:XX'], desc: 'Change the time format', toggle: false}; CM.Data.Config.MissingUpgrades = {
CM.Data.Config.DetailedTime = {type: 'bool', group: 'Statistics', label: ['Detailed Time OFF', 'Detailed Time ON'], desc: 'Change how time is displayed in certain statistics and tooltips', toggle: true, func: function() {CM.Disp.ToggleDetailedTime();}}; type: 'bool', group: 'Statistics', label: ['Missing Upgrades OFF', 'Missing Upgrades ON'], desc: 'Shows Missing upgrades in Stats Menu. This feature can be laggy for users with a low amount of unlocked achievements.', toggle: true,
CM.Data.Config.GrimoireBar = {type: 'bool', group: 'Statistics', label: ['Grimoire Magic Meter Timer OFF', 'Grimoire Magic Meter Timer ON'], desc: 'A timer on how long before the Grimoire magic meter is full', toggle: true}; };
CM.Data.Config.HeavenlyChipsTarget = {type: 'numscale', group: 'Statistics', label: 'Heavenly Chips Target: ', desc: 'Use this to set a Heavenly Chips target that will be counted towards in the "prestige" statsistics sections', min: 1, max: Infinity}; CM.Data.Config.UpStats = {
CM.Data.Config.ShowMissedGC = {type: 'bool', group: 'Statistics', label: ['Missed GC OFF', 'Missed GC ON'], desc: 'Show a stat in the statistics screen that counts how many Golden Cookies you have missed', toggle: true}; type: 'bool', group: 'Statistics', label: ['Statistics Update Rate (Default)', 'Statistics Update Rate (1s)'], desc: 'Default Game rate is once every 5 seconds', toggle: false,
};
CM.Data.Config.TimeFormat = {
type: 'bool', group: 'Statistics', label: ['Time XXd, XXh, XXm, XXs', 'Time XX:XX:XX:XX:XX'], desc: 'Change the time format', toggle: false,
};
CM.Data.Config.DetailedTime = {
type: 'bool', group: 'Statistics', label: ['Detailed Time OFF', 'Detailed Time ON'], desc: 'Change how time is displayed in certain statistics and tooltips', toggle: true, func: function () { CM.Disp.ToggleDetailedTime(); },
};
CM.Data.Config.GrimoireBar = {
type: 'bool', group: 'Statistics', label: ['Grimoire Magic Meter Timer OFF', 'Grimoire Magic Meter Timer ON'], desc: 'A timer on how long before the Grimoire magic meter is full', toggle: true,
};
CM.Data.Config.HeavenlyChipsTarget = {
type: 'numscale', group: 'Statistics', label: 'Heavenly Chips Target: ', desc: 'Use this to set a Heavenly Chips target that will be counted towards in the "prestige" statsistics sections', min: 1, max: Infinity,
};
CM.Data.Config.ShowMissedGC = {
type: 'bool', group: 'Statistics', label: ['Missed GC OFF', 'Missed GC ON'], desc: 'Show a stat in the statistics screen that counts how many Golden Cookies you have missed', toggle: true,
};
// Notation // Notation
CM.Data.Config.Scale = {type: 'bool', group: 'Notation', label: ['Game\'s Setting Scale', 'Metric', 'Short Scale', 'Short Scale (Abbreviated)', 'Scientific Notation', 'Engineering Notation'], desc: 'Change how long numbers are handled', toggle: false, func: function() {CM.Disp.RefreshScale();}}; CM.Data.Config.Scale = {
CM.Data.Config.ScaleDecimals = {type: 'bool', group: 'Notation', label: ['1 decimals', '2 decimals', '3 decimals'], desc: 'Set the number of decimals used when applicable', toggle: false, func: function() {CM.Disp.RefreshScale();}}; type: 'bool', group: 'Notation', label: ['Game\'s Setting Scale', 'Metric', 'Short Scale', 'Short Scale (Abbreviated)', 'Scientific Notation', 'Engineering Notation'], desc: 'Change how long numbers are handled', toggle: false, func: function () { CM.Disp.RefreshScale(); },
CM.Data.Config.ScaleSeparator = {type: 'bool', group: 'Notation', label: ['. for decimals (Standard)', '. for thousands'], desc: 'Set the separator used for decimals and thousands', toggle: false, func: function() {CM.Disp.RefreshScale();}}; };
CM.Data.Config.ScaleCutoff = {type: 'numscale', group: 'Notation', label: 'Notation Cut-off Point: ', desc: 'The number from which CookieMonster will start formatting numbers based on chosen scale. Standard is 999,999. Setting this above 999,999,999 might break certain notations', min: 1, max: 999999999}; CM.Data.Config.ScaleDecimals = {
type: 'bool', group: 'Notation', label: ['1 decimals', '2 decimals', '3 decimals'], desc: 'Set the number of decimals used when applicable', toggle: false, func: function () { CM.Disp.RefreshScale(); },
};
CM.Data.Config.ScaleSeparator = {
type: 'bool', group: 'Notation', label: ['. for decimals (Standard)', '. for thousands'], desc: 'Set the separator used for decimals and thousands', toggle: false, func: function () { CM.Disp.RefreshScale(); },
};
CM.Data.Config.ScaleCutoff = {
type: 'numscale', group: 'Notation', label: 'Notation Cut-off Point: ', desc: 'The number from which CookieMonster will start formatting numbers based on chosen scale. Standard is 999,999. Setting this above 999,999,999 might break certain notations', min: 1, max: 999999999,
};
// Miscellaneous // Miscellaneous
CM.Data.Config.GCTimer = {type: 'bool', group: 'Miscellaneous', label: ['Golden Cookie Timer OFF', 'Golden Cookie Timer ON'], desc: 'A timer on the Golden Cookie when it has been spawned', toggle: true, func: function() {CM.Disp.ToggleGCTimer();}}; CM.Data.Config.GCTimer = {
CM.Data.Config.Favicon = {type: 'bool', group: 'Miscellaneous', label: ['Favicon OFF', 'Favicon ON'], desc: 'Update favicon with Golden/Wrath Cookie', toggle: true, func: function() {CM.Disp.UpdateFavicon();}}; type: 'bool', group: 'Miscellaneous', label: ['Golden Cookie Timer OFF', 'Golden Cookie Timer ON'], desc: 'A timer on the Golden Cookie when it has been spawned', toggle: true, func: function () { CM.Disp.ToggleGCTimer(); },
CM.Data.Config.WrinklerButtons = {type: 'bool', group: 'Miscellaneous', label: ['Extra Buttons OFF', 'Extra Buttons ON'], desc: 'Show buttons for popping wrinklers at bottom of cookie section', toggle: true, func: function() {CM.Disp.UpdateWrinklerButtons();}}; };
CM.Data.Config.BulkBuyBlock = {type: 'bool', group: 'Miscellaneous', label: ['Block Bulk Buying OFF', 'Block Bulk Buying ON'], desc: "Block clicking bulk buying when you can't buy all. This prevents buying 7 of a building when you are in buy-10 or buy-100 mode.", toggle: true}; CM.Data.Config.Favicon = {
type: 'bool', group: 'Miscellaneous', label: ['Favicon OFF', 'Favicon ON'], desc: 'Update favicon with Golden/Wrath Cookie', toggle: true, func: function () { CM.Disp.UpdateFavicon(); },
};
CM.Data.Config.WrinklerButtons = {
type: 'bool', group: 'Miscellaneous', label: ['Extra Buttons OFF', 'Extra Buttons ON'], desc: 'Show buttons for popping wrinklers at bottom of cookie section', toggle: true, func: function () { CM.Disp.UpdateWrinklerButtons(); },
};
CM.Data.Config.BulkBuyBlock = {
type: 'bool', group: 'Miscellaneous', label: ['Block Bulk Buying OFF', 'Block Bulk Buying ON'], desc: "Block clicking bulk buying when you can't buy all. This prevents buying 7 of a building when you are in buy-10 or buy-100 mode.", toggle: true,
};
/** /**
* This array describes all default settings * This array describes all default settings
@@ -319,7 +492,7 @@ CM.Data.ConfigDefault = {
ToolWarnEdifice: 1, ToolWarnEdifice: 1,
ToolWarnUser: 0, ToolWarnUser: 0,
ToolWarnPos: 1, ToolWarnPos: 1,
TooltipGrim:1, TooltipGrim: 1,
TooltipWrink: 1, TooltipWrink: 1,
TooltipLump: 1, TooltipLump: 1,
TooltipPlots: 1, TooltipPlots: 1,
@@ -337,14 +510,18 @@ CM.Data.ConfigDefault = {
ScaleDecimals: 2, ScaleDecimals: 2,
ScaleSeparator: 0, ScaleSeparator: 0,
ScaleCutoff: 999999, ScaleCutoff: 999999,
Colors: {Blue: '#4bb8f0', Green: '#00ff00', Yellow: '#ffff00', Orange: '#ff7f00', Red: '#ff0000', Purple: '#ff00ff', Gray: '#b3b3b3', Pink: '#ff1493', Brown: '#8b4513'}, Colors: {
Blue: '#4bb8f0', Green: '#00ff00', Yellow: '#ffff00', Orange: '#ff7f00', Red: '#ff0000', Purple: '#ff00ff', Gray: '#b3b3b3', Pink: '#ff1493', Brown: '#8b4513',
},
SortBuildings: 0, SortBuildings: 0,
SortUpgrades: 0, SortUpgrades: 0,
GCTimer: 1, GCTimer: 1,
Favicon: 1, Favicon: 1,
WrinklerButtons: 1, WrinklerButtons: 1,
BulkBuyBlock: 0, BulkBuyBlock: 0,
Header: {BarsColors: 1, Calculation: 1, Notification: 1, NotificationGeneral: 1, NotificationGC: 1, NotificationFC: 1, NotificationSea: 1, NotificationGard: 1, NotificationMagi: 1, NotificationWrink: 1, NotificationWrinkMax: 1, Tooltip: 1, Statistics: 1, Notation: 1, Miscellaneous: 1, Lucky: 1, Chain: 1, Spells: 1, Garden: 1, Prestige: 1, Wrink: 1, Sea: 1, Misc: 1, InfoTab: 1}, Header: {
BarsColors: 1, Calculation: 1, Notification: 1, NotificationGeneral: 1, NotificationGC: 1, NotificationFC: 1, NotificationSea: 1, NotificationGard: 1, NotificationMagi: 1, NotificationWrink: 1, NotificationWrinkMax: 1, Tooltip: 1, Statistics: 1, Notation: 1, Miscellaneous: 1, Lucky: 1, Chain: 1, Spells: 1, Garden: 1, Prestige: 1, Wrink: 1, Sea: 1, Misc: 1, InfoTab: 1,
},
}; };
/** /**
@@ -355,19 +532,22 @@ CM.Data.ModDescription = `<div class="listing">
<a href="https://github.com/Aktanusa/CookieMonster" target="blank">Cookie Monster</a> <a href="https://github.com/Aktanusa/CookieMonster" target="blank">Cookie Monster</a>
offers a wide range of tools and statistics to enhance your game experience. offers a wide range of tools and statistics to enhance your game experience.
It is not a cheat interface although it does offer helpers for golden cookies and such, everything can be toggled off at will to only leave how much information you want.</br> It is not a cheat interface although it does offer helpers for golden cookies and such, everything can be toggled off at will to only leave how much information you want.</br>
Progess on new updates and all previous release notes can be found on the GitHub page linked above! Progess on new updates and all previous release notes can be found on the GitHub page linked above!</br>
Please also report any bugs you may find over there!</br>
</div> </div>
` `;
CM.Data.LatestReleaseNotes = `<div class="listing"> CM.Data.LatestReleaseNotes = `<div class="listing">
<b>The latest update (v 2.031.4) has introduced the following features:</b></br <b>The latest update (v 2.031.4) has introduced the following features:</b></br>
- Added a changelog to the info tab and notification indicating a new version</br>
- Warnings in tooltips are now based on the income after buying the upgrade</br> - Warnings in tooltips are now based on the income after buying the upgrade</br>
- A new warning and stat for Conjure Baked Goods in combination with Frenzy has been added</br> - A new warning and stat for Conjure Baked Goods in combination with Frenzy has been added</br>
- User can now set a custom tooltip warning ("x times cps") in the settings</br> - User can now set a custom tooltip warning ("x times cps") in the settings</br>
- Garden plots with plants that give cookies on harvest now display a tooltip with current and maximum reward</br> - Garden plots with plants that give cookies on harvest now display a tooltip with current and maximum reward</br>
- The Harvest All button in the Garden now has a tooltip displaying the current reward</br> - The Harvest All button in the Garden now has a tooltip displaying the current reward </br>
- The Ascend button can now display additional info (this can be turned off in the settings)</br> - The Ascend button can now display additional info (this can be turned off in the settings) </br>
- The statistics page now displays the Heavenly Chips per second</br> - The statistics page now displays the Heavenly Chips per second</br>
- The statistics page now displays the CPS needed for the next level in Chain Cookies</br> - The statistics page now displays the CPS needed for the next level in Chain Cookies</br>
- The statistics page now displays the cookies needed for optimal rewards for garden plants</br>
- You can now set a Heavenly Chips target in the settings which will be counted down to in the statistics page</br> - You can now set a Heavenly Chips target in the settings which will be counted down to in the statistics page</br>
- The color picker in the settings has been updated to its latest version</br> - The color picker in the settings has been updated to its latest version</br>
- The overlay of seconds/percentage of timers is now toggle able and more readable</br> - The overlay of seconds/percentage of timers is now toggle able and more readable</br>
@@ -387,5 +567,6 @@ CM.Data.LatestReleaseNotes = `<div class="listing">
- Fixed the integration with mods that provide additional content, they should now no longer break CookieMonster</br> - Fixed the integration with mods that provide additional content, they should now no longer break CookieMonster</br>
- The Timer bar will now disappear correctly when the Golden Switch has been activated</br> - The Timer bar will now disappear correctly when the Golden Switch has been activated</br>
- Fixed errors in the calculation of the Chain Cookies and Wrinkler stats</br> - Fixed errors in the calculation of the Chain Cookies and Wrinkler stats</br>
- Fixed buy warnings showing incorrectly</br>
</div> </div>
` `;

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,8 @@
/********** /**
* Footer * * Footer *
**********/ */
/******** /**
* Section: Functions related to base game modding API */ * Section: Functions related to base game modding API */
/** /**
@@ -11,18 +11,18 @@
* declare hooks here" * declare hooks here"
* It starts the further initialization of CookieMonster and registers hooks * It starts the further initialization of CookieMonster and registers hooks
*/ */
CM.init = function() { CM.init = function () {
CM.Footer.isInitzializing = true CM.Footer.isInitzializing = true;
let proceed = true; let proceed = true;
if (Game.version != CM.VersionMajor) { if (Game.version !== Number(CM.VersionMajor)) {
proceed = confirm('Cookie Monster version ' + CM.VersionMajor + '.' + CM.VersionMinor + ' is meant for Game version ' + CM.VersionMajor + '. Loading a different version may cause errors. Do you still want to load Cookie Monster?'); proceed = confirm(`Cookie Monster version ${CM.VersionMajor}.${CM.VersionMinor} is meant for Game version ${CM.VersionMajor}. Loading a different version may cause errors. Do you still want to load Cookie Monster?`);
} }
if (proceed) { if (proceed) {
CM.Main.DelayInit(); CM.Main.DelayInit();
Game.registerHook('draw', CM.Disp.Draw); Game.registerHook('draw', CM.Disp.Draw);
Game.registerHook('logic', CM.Main.Loop); Game.registerHook('logic', CM.Main.Loop);
CM.Footer.isInitzializing = false CM.Footer.isInitzializing = false;
} }
}; };
/** /**
@@ -30,39 +30,39 @@ CM.init = function() {
* "use this to store persistent data associated with your mod * "use this to store persistent data associated with your mod
* return 'a string to be saved';" * return 'a string to be saved';"
*/ */
CM.save = function() { CM.save = function () {
return JSON.stringify({ return JSON.stringify({
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:
* "do stuff with the string data you saved previously" * "do stuff with the string data you saved previously"
*/ */
CM.load = function(str) { CM.load = function (str) {
let save = JSON.parse(str); const save = JSON.parse(str);
CM.Config.LoadConfig(save.settings); CM.Config.LoadConfig(save.settings);
if (save.version !== CM.VersionMajor + '.' + CM.VersionMinor) { if (save.version !== `${CM.VersionMajor}.${CM.VersionMinor}`) {
if (Game.prefs.popups) Game.Popup('A new version of Cookie Monster has been loaded, check out the release notes in the info tab!'); if (Game.prefs.popups) Game.Popup('A new version of Cookie Monster has been loaded, check out the release notes in the info tab!');
else Game.Notify('A new version of Cookie Monster has been loaded, check out the release notes in the info tab!', '', '', 0, 1); else Game.Notify('A new version of Cookie Monster has been loaded, check out the release notes in the info tab!', '', '', 0, 1);
} }
}; };
/******** /**
* Section: Functions related to the initialization of CookieMonster */ * Section: Functions related to the initialization of CookieMonster */
/** /**
* This functions loads an external script (on the same repository) that creates the * This functions loads an external script (on the same repository) that creates the
* functionality needed to dynamiccaly change colours * functionality needed to dynamiccaly change colours
* It is called by the last function in the footer * It is called by the last function in the footer
*/ */
CM.Footer.AddJscolor = function() { CM.Footer.AddJscolor = function () {
CM.Footer.Jscolor = document.createElement('script'); CM.Footer.Jscolor = document.createElement('script');
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);
}; };
/** /**
@@ -70,12 +70,12 @@ CM.Footer.AddJscolor = function() {
* It is called as the last function in this script's execution * It is called as the last function in this script's execution
*/ */
if (typeof CM.Footer.isInitzializing === 'undefined') { if (typeof CM.Footer.isInitzializing === 'undefined') {
CM.Footer.AddJscolor(); CM.Footer.AddJscolor();
let delay = setInterval(function() { const delay = setInterval(function () {
if (typeof jscolor !== 'undefined') { if (typeof jscolor !== 'undefined') {
jscolor.init(); jscolor.init();
Game.registerMod('CookieMonster', CM); Game.registerMod('CookieMonster', CM);
clearInterval(delay); clearInterval(delay);
} }
}, 500); }, 500);
} }

View File

@@ -1,19 +1,18 @@
/* eslint-disable no-redeclare */
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
/********** /**
* Header * * Header *
**********/ */
const CM = { const CM = {
Backup: {}, Backup: {},
Cache: {}, Cache: {},
Config: {}, Config: {},
Data: {Config: {}}, Data: { Config: {} },
Disp: {}, Disp: {},
Footer: {}, Footer: {},
Main: {}, Main: {},
Options: {}, Options: {},
Sim: {}, Sim: {},
VersionMajor: '2.031', VersionMajor: '2.031',
VersionMinor: '4', VersionMinor: '4',
}; };

View File

@@ -1,28 +1,28 @@
/******** /**
* Main * * Main *
********/ */
/******** /**
* Section: Functions related to the main and initialization loop */ * Section: Functions related to the main and initialization loop */
/** /**
* Main loop of Cookie Monster * Main loop of Cookie Monster
* CM.init registers it to the "logic" hook provided by the modding api * CM.init registers it to the "logic" hook provided by the modding api
*/ */
CM.Main.Loop = function() { CM.Main.Loop = function () {
if (CM.Disp.lastAscendState != Game.OnAscend) { if (CM.Disp.lastAscendState !== Game.OnAscend) {
CM.Disp.lastAscendState = Game.OnAscend; CM.Disp.lastAscendState = Game.OnAscend;
CM.Disp.UpdateAscendState(); CM.Disp.UpdateAscendState();
} }
if (!Game.OnAscend && Game.AscendTimer === 0) { if (!Game.OnAscend && Game.AscendTimer === 0) {
// Check if any other mods have been loaded // Check if any other mods have been loaded
if (CM.Main.LastModCount != Object.keys(Game.mods).length) { if (CM.Main.LastModCount !== Object.keys(Game.mods).length) {
CM.Sim.CreateSimFunctions(); CM.Sim.CreateSimFunctions();
CM.Sim.InitData(); CM.Sim.InitData();
CM.Cache.InitCache(); CM.Cache.InitCache();
CM.Main.LastModCount = Object.keys(Game.mods).length; CM.Main.LastModCount = Object.keys(Game.mods).length;
} }
// CM.Sim.DoSims is set whenever CPS has changed // CM.Sim.DoSims is set whenever CPS has changed
if (CM.Sim.DoSims) { if (CM.Sim.DoSims) {
CM.Cache.CacheIncome(); CM.Cache.CacheIncome();
@@ -41,12 +41,11 @@ CM.Main.Loop = function() {
} }
// Check for aura change to recalculate buildings prices // Check for aura change to recalculate buildings prices
let hasBuildAura = Game.auraMult('Fierce Hoarder') > 0; const hasBuildAura = Game.auraMult('Fierce Hoarder') > 0;
if (!CM.Cache.HadBuildAura && hasBuildAura) { if (!CM.Cache.HadBuildAura && hasBuildAura) {
CM.Cache.HadBuildAura = true; CM.Cache.HadBuildAura = true;
CM.Cache.DoRemakeBuildPrices = 1; CM.Cache.DoRemakeBuildPrices = 1;
} } else if (CM.Cache.HadBuildAura && !hasBuildAura) {
else if (CM.Cache.HadBuildAura && !hasBuildAura) {
CM.Cache.HadBuildAura = false; CM.Cache.HadBuildAura = false;
CM.Cache.DoRemakeBuildPrices = 1; CM.Cache.DoRemakeBuildPrices = 1;
} }
@@ -72,7 +71,7 @@ CM.Main.Loop = function() {
* Initialization loop of Cookie Monster * Initialization loop of Cookie Monster
* Called by CM.init() * Called by CM.init()
*/ */
CM.Main.DelayInit = function() { CM.Main.DelayInit = function () {
// Create CM.Sim functions // Create CM.Sim functions
CM.Sim.CreateSimFunctions(); CM.Sim.CreateSimFunctions();
@@ -80,7 +79,7 @@ CM.Main.DelayInit = function() {
CM.Cache.InitCache(); CM.Cache.InitCache();
// Stored to check if we need to re-initiliaze data // Stored to check if we need to re-initiliaze data
CM.Main.LastModCount = Object.keys(Game.mods).length CM.Main.LastModCount = Object.keys(Game.mods).length;
// Creating visual elements // Creating visual elements
CM.Disp.CreateCssArea(); CM.Disp.CreateCssArea();
@@ -89,7 +88,7 @@ CM.Main.DelayInit = function() {
CM.Disp.CreateUpgradeBar(); CM.Disp.CreateUpgradeBar();
CM.Disp.CreateWhiteScreen(); CM.Disp.CreateWhiteScreen();
CM.Disp.CreateFavicon(); CM.Disp.CreateFavicon();
for (let i of Object.keys(CM.Disp.TooltipText)) { for (const 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();
@@ -105,61 +104,61 @@ CM.Main.DelayInit = function() {
CM.Config.LoadConfig(); // Must be after all things are created! CM.Config.LoadConfig(); // Must be after all things are created!
CM.Disp.lastAscendState = Game.OnAscend; CM.Disp.lastAscendState = Game.OnAscend;
if (Game.prefs.popups) Game.Popup('Cookie Monster version ' + CM.VersionMajor + '.' + CM.VersionMinor + ' loaded!'); if (Game.prefs.popups) Game.Popup(`Cookie Monster version ${CM.VersionMajor}.${CM.VersionMinor} loaded!`);
else Game.Notify('Cookie Monster version ' + CM.VersionMajor + '.' + CM.VersionMinor + ' loaded!', '', '', 1, 1); else Game.Notify(`Cookie Monster version ${CM.VersionMajor}.${CM.VersionMinor} loaded!`, '', '', 1, 1);
Game.Win('Third-party'); Game.Win('Third-party');
}; };
/******** /**
* Section: Functions related to replacing stuff */ * Section: Functions related to replacing stuff */
/** /**
* This function replaces certain native (from the base-game) functions * This function replaces certain native (from the base-game) functions
* It is called by CM.Main.DelayInit() * It is called by CM.Main.DelayInit()
*/ */
CM.Main.ReplaceNative = function() { CM.Main.ReplaceNative = function () {
CM.Backup.Beautify = Beautify; CM.Backup.Beautify = Beautify;
Beautify = CM.Disp.Beautify; Beautify = CM.Disp.Beautify;
CM.Backup.CalculateGains = Game.CalculateGains; CM.Backup.CalculateGains = Game.CalculateGains;
eval('CM.Backup.CalculateGainsMod = ' + Game.CalculateGains.toString().split('ages\');').join('ages\');CM.Sim.DateAges = Date.now();').split('if (Game.Has(\'Century').join('CM.Sim.DateCentury = Date.now();if (Game.Has(\'Century')); eval(`CM.Backup.CalculateGainsMod = ${Game.CalculateGains.toString().split('ages\');').join('ages\');CM.Sim.DateAges = Date.now();').split('if (Game.Has(\'Century')
Game.CalculateGains = function() { .join('CM.Sim.DateCentury = Date.now();if (Game.Has(\'Century')}`);
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);
l('bigCookie').addEventListener('click', function() { CM.Main.FixMouseY(Game.ClickCookie); }, false); l('bigCookie').addEventListener('click', function () { CM.Main.FixMouseY(Game.ClickCookie); }, false);
CM.Backup.RebuildUpgrades = Game.RebuildUpgrades; CM.Backup.RebuildUpgrades = Game.RebuildUpgrades;
Game.RebuildUpgrades = function() { Game.RebuildUpgrades = function () {
CM.Backup.RebuildUpgrades(); CM.Backup.RebuildUpgrades();
CM.Disp.ReplaceTooltipUpgrade(); CM.Disp.ReplaceTooltipUpgrade();
Game.CalculateGains(); Game.CalculateGains();
@@ -168,9 +167,9 @@ CM.Main.ReplaceNative = function() {
CM.Backup.ClickProduct = Game.ClickProduct; CM.Backup.ClickProduct = Game.ClickProduct;
/** /**
* This function adds a check to the purchase of a building to allow BulkBuyBlock to work. * This function adds a check to the purchase of a building to allow BulkBuyBlock to work.
* If the options is 1 (on) bulkPrice is under cookies you can't buy the building. * If the options is 1 (on) bulkPrice is under cookies you can't buy the building.
*/ */
Game.ClickProduct = function(what) { Game.ClickProduct = function (what) {
if (!CM.Options.BulkBuyBlock || Game.ObjectsById[what].bulkPrice < Game.cookies) { if (!CM.Options.BulkBuyBlock || Game.ObjectsById[what].bulkPrice < Game.cookies) {
CM.Backup.ClickProduct(what); CM.Backup.ClickProduct(what);
} }
@@ -182,7 +181,7 @@ CM.Main.ReplaceNative = function() {
* This adds information about CPS differences and costs to the aura choosing interface * This adds information about CPS differences and costs to the aura choosing interface
* @param {number} aura The number of the aura currently selected by the mouse/user * @param {number} aura The number of the aura currently selected by the mouse/user
*/ */
Game.DescribeDragonAura = function(aura) { Game.DescribeDragonAura = function (aura) {
CM.Backup.DescribeDragonAura(aura); CM.Backup.DescribeDragonAura(aura);
CM.Disp.AddAuraInfo(aura); CM.Disp.AddAuraInfo(aura);
}; };
@@ -191,13 +190,13 @@ CM.Main.ReplaceNative = function() {
/** /**
* This function adds the code to display the tooltips for the levelUp button of the dragon * This function adds the code to display the tooltips for the levelUp button of the dragon
*/ */
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 () {
if (typeof jscolor.picker === 'undefined' || typeof jscolor.picker.owner === 'undefined') { if (typeof jscolor.picker === 'undefined' || typeof jscolor.picker.owner === 'undefined') {
CM.Backup.UpdateMenu(); CM.Backup.UpdateMenu();
CM.Disp.AddMenu(); CM.Disp.AddMenu();
@@ -205,21 +204,21 @@ CM.Main.ReplaceNative = function() {
}; };
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 (Number.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);
}; };
// Since the Ascend Tooltip is not actually a tooltip we need to add our additional info here... // Since the Ascend Tooltip is not actually a tooltip we need to add our additional info here...
CM.Backup.Logic = Game.Logic; CM.Backup.Logic = Game.Logic;
CM.Backup.LogicMod = new Function( CM.Backup.LogicMod = new Function(
`return ${Game.Logic.toString() `return ${Game.Logic.toString()
.split('document.title') .split('document.title')
.join('CM.Disp.Title') .join('CM.Disp.Title')
.split("' more cookies</b> for the next level.<br>';") .split("' more cookies</b> for the next level.<br>';")
.join("` more cookies</b> for the next level.<br>${CM.Options.TooltipAscendButton ? `<div class='line'></div>It takes ${CM.Cache.TimeTillNextPrestige} to reach the next level and you are making ${Beautify(CM.Cache.HCPerSecond, 2)} chips on average in the last 5 seconds.<br>` : ``}`;")}`, .join("` more cookies</b> for the next level.<br>${CM.Options.TooltipAscendButton ? `<div class='line'></div>It takes ${CM.Cache.TimeTillNextPrestige} to reach the next level and you are making ${Beautify(CM.Cache.HCPerSecond, 2)} chips on average in the last 5 seconds.<br>` : ``}`;")}`,
)(); )();
Game.Logic = function() { Game.Logic = function () {
CM.Backup.LogicMod(); CM.Backup.LogicMod();
// Update Title // Update Title
CM.Disp.UpdateTitle(); CM.Disp.UpdateTitle();
@@ -230,7 +229,7 @@ CM.Main.ReplaceNative = function() {
* This function fixes replaces the Launch and Draw functions of the Grimoire * This function fixes replaces the Launch and Draw functions of the Grimoire
* It is called by CM.Main.DelayInit() and Game.LoadMinigames() * It is called by CM.Main.DelayInit() and Game.LoadMinigames()
*/ */
CM.Main.ReplaceNativeGrimoire = function() { CM.Main.ReplaceNativeGrimoire = function () {
CM.Main.ReplaceNativeGrimoireLaunch(); CM.Main.ReplaceNativeGrimoireLaunch();
CM.Main.ReplaceNativeGrimoireDraw(); CM.Main.ReplaceNativeGrimoireDraw();
}; };
@@ -239,12 +238,12 @@ CM.Main.ReplaceNativeGrimoire = function() {
* This function fixes replaces the .launch function of the Grimoire * This function fixes replaces the .launch function of the Grimoire
* It is called by CM.Main.ReplaceNativeGrimoire() * It is called by CM.Main.ReplaceNativeGrimoire()
*/ */
CM.Main.ReplaceNativeGrimoireLaunch = function() { CM.Main.ReplaceNativeGrimoireLaunch = function () {
if (!CM.Main.HasReplaceNativeGrimoireLaunch && Game.Objects['Wizard tower'].minigameLoaded) { if (!CM.Main.HasReplaceNativeGrimoireLaunch && Game.Objects['Wizard tower'].minigameLoaded) {
let minigame = Game.Objects['Wizard tower'].minigame; const minigame = Game.Objects['Wizard tower'].minigame;
CM.Backup.GrimoireLaunch = minigame.launch; CM.Backup.GrimoireLaunch = minigame.launch;
eval('CM.Backup.GrimoireLaunchMod = ' + minigame.launch.toString().split('=this').join('= Game.Objects[\'Wizard tower\'].minigame')); eval(`CM.Backup.GrimoireLaunchMod = ${minigame.launch.toString().split('=this').join('= Game.Objects[\'Wizard tower\'].minigame')}`);
Game.Objects['Wizard tower'].minigame.launch = function() { Game.Objects['Wizard tower'].minigame.launch = function () {
CM.Backup.GrimoireLaunchMod(); CM.Backup.GrimoireLaunchMod();
CM.Main.ReplaceTooltipGrimoire(); CM.Main.ReplaceTooltipGrimoire();
CM.HasReplaceNativeGrimoireDraw = false; CM.HasReplaceNativeGrimoireDraw = false;
@@ -258,35 +257,35 @@ CM.Main.ReplaceNativeGrimoireLaunch = function() {
* This function fixes replaces the .draw function of the Grimoire * This function fixes replaces the .draw function of the Grimoire
* It is called by CM.Main.ReplaceNativeGrimoire() * It is called by CM.Main.ReplaceNativeGrimoire()
*/ */
CM.Main.ReplaceNativeGrimoireDraw = function() { CM.Main.ReplaceNativeGrimoireDraw = function () {
if (!CM.Main.HasReplaceNativeGrimoireDraw && Game.Objects['Wizard tower'].minigameLoaded) { if (!CM.Main.HasReplaceNativeGrimoireDraw && Game.Objects['Wizard tower'].minigameLoaded) {
let minigame = Game.Objects['Wizard tower'].minigame; const minigame = Game.Objects['Wizard tower'].minigame;
CM.Backup.GrimoireDraw = minigame.draw; CM.Backup.GrimoireDraw = minigame.draw;
Game.Objects['Wizard tower'].minigame.draw = function() { Game.Objects['Wizard tower'].minigame.draw = function () {
CM.Backup.GrimoireDraw(); CM.Backup.GrimoireDraw();
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.Main.HasReplaceNativeGrimoireDraw = true; CM.Main.HasReplaceNativeGrimoireDraw = true;
} }
}; };
/******** /**
* Section: Functions related to first initizalition of CM */ * Section: Functions related to first initizalition of CM */
/** /**
* This function call all functions that replace Game-tooltips with CM-enhanced tooltips * This function call all functions that replace Game-tooltips with CM-enhanced tooltips
* It is called by CM.Main.DelayInit() * It is called by CM.Main.DelayInit()
*/ */
CM.Main.ReplaceTooltips = function() { CM.Main.ReplaceTooltips = function () {
CM.Main.ReplaceTooltipBuild(); CM.Main.ReplaceTooltipBuild();
CM.Main.ReplaceTooltipLump(); CM.Main.ReplaceTooltipLump();
// Replace Tooltips of Minigames. Nesting it in LoadMinigames makes sure to replace them even if // Replace Tooltips of Minigames. Nesting it in LoadMinigames makes sure to replace them even if
// they were not loaded initially // they were not loaded initially
CM.Backup.LoadMinigames = Game.LoadMinigames; CM.Backup.LoadMinigames = Game.LoadMinigames;
Game.LoadMinigames = function() { Game.LoadMinigames = function () {
CM.Backup.LoadMinigames(); CM.Backup.LoadMinigames();
CM.Main.ReplaceTooltipGarden(); CM.Main.ReplaceTooltipGarden();
CM.Main.ReplaceTooltipGrimoire(); CM.Main.ReplaceTooltipGrimoire();
@@ -295,7 +294,7 @@ CM.Main.ReplaceTooltips = function() {
Game.LoadMinigames(); Game.LoadMinigames();
}; };
/******** /**
* Section: Functions related to replacing tooltips */ * Section: Functions related to replacing tooltips */
/** /**
@@ -303,13 +302,13 @@ CM.Main.ReplaceTooltips = function() {
* CM.Disp.Tooltip() sets the tooltip type to 'b' * CM.Disp.Tooltip() sets the tooltip type to 'b'
* It is called by CM.Main.ReplaceTooltips() * It is called by CM.Main.ReplaceTooltips()
*/ */
CM.Main.ReplaceTooltipBuild = function() { CM.Main.ReplaceTooltipBuild = function () {
CM.Main.TooltipBuildBackup = []; CM.Main.TooltipBuildBackup = [];
for (let i of Object.keys(Game.Objects)) { for (const i of Object.keys(Game.Objects)) {
let me = Game.Objects[i]; const 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();}`);
} }
} }
}; };
@@ -319,10 +318,10 @@ CM.Main.ReplaceTooltipBuild = function() {
* CM.Disp.Tooltip() sets the tooltip type to 's' * CM.Disp.Tooltip() sets the tooltip type to 's'
* It is called by CM.Main.ReplaceTooltips() * It is called by CM.Main.ReplaceTooltips()
*/ */
CM.Main.ReplaceTooltipLump = function() { CM.Main.ReplaceTooltipLump = function () {
if (Game.canLumps()) { if (Game.canLumps()) {
CM.Main.TooltipLumpBackup = l('lumps').onmouseover; CM.Main.TooltipLumpBackup = l('lumps').onmouseover;
eval('l(\'lumps\').onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'s\', \'Lump\');}, \'this\'); Game.tooltip.wobble();}'); eval('l(\'lumps\').onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'s\', \'Lump\');}, \'this\'); Game.tooltip.wobble();}');
} }
}; };
@@ -331,13 +330,13 @@ CM.Main.ReplaceTooltipLump = function() {
* CM.Disp.Tooltip() sets the tooltip type to 'g' * CM.Disp.Tooltip() sets the tooltip type to 'g'
* It is called by CM.Main.ReplaceTooltips() * It is called by CM.Main.ReplaceTooltips()
*/ */
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 (let i in Game.Objects['Wizard tower'].minigame.spellsById) { for (const 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();}`);
} }
} }
} }
@@ -348,28 +347,28 @@ CM.Main.ReplaceTooltipGrimoire = function() {
* CM.Disp.Tooltip() sets the tooltip type to 'p' * CM.Disp.Tooltip() sets the tooltip type to 'p'
* 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) => { Array.from(l('gardenPlot').children).forEach((child) => {
let coords = child.id.slice(-3,); const 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(); };
}); });
} }
}; };
/******** /**
* Section: Functions related to checking for changes in Minigames/GC's/Ticker */ * Section: Functions related to checking for changes in Minigames/GC's/Ticker */
/** /**
* Auxilirary function that finds all currently spawned shimmers. * Auxilirary function that finds all currently spawned shimmers.
* CM.Cache.spawnedGoldenShimmer stores the non-user spawned cookie to later determine data for the favicon and tab-title * CM.Cache.spawnedGoldenShimmer stores the non-user spawned cookie to later determine data for the favicon and tab-title
* It is called by CM.CM.Main.CheckGoldenCookie * It is called by CM.CM.Main.CheckGoldenCookie
*/ */
CM.Main.FindShimmer = function() { CM.Main.FindShimmer = function () {
CM.Main.currSpawnedGoldenCookieState = 0; CM.Main.currSpawnedGoldenCookieState = 0;
CM.Cache.goldenShimmersByID = {}; CM.Cache.goldenShimmersByID = {};
for (let i of Object.keys(Game.shimmers)) { for (const 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];
@@ -382,25 +381,25 @@ CM.Main.FindShimmer = function() {
* This function checks for changes in the amount of Golden Cookies * This function checks for changes in the amount of Golden Cookies
* It is called by CM.Main.Loop * It is called by CM.Main.Loop
*/ */
CM.Main.CheckGoldenCookie = function() { CM.Main.CheckGoldenCookie = function () {
CM.Main.FindShimmer(); CM.Main.FindShimmer();
for (let i of Object.keys(CM.Disp.GCTimers)) { for (const 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]);
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 (let i of Object.keys(Game.shimmers)) { for (const 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]);
} }
} }
@@ -408,9 +407,8 @@ CM.Main.CheckGoldenCookie = function() {
CM.Disp.UpdateFavicon(); CM.Disp.UpdateFavicon();
CM.Main.lastSpawnedGoldenCookieState = CM.Main.currSpawnedGoldenCookieState; CM.Main.lastSpawnedGoldenCookieState = CM.Main.currSpawnedGoldenCookieState;
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 (const i of Object.keys(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);
@@ -422,10 +420,10 @@ CM.Main.CheckGoldenCookie = function() {
* 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.Main.Loop * It is called by CM.Main.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 (let i of Object.keys(Game.shimmers)) { for (const 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;
@@ -433,7 +431,7 @@ 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!');
} }
}; };
@@ -441,13 +439,13 @@ CM.Main.CheckSeasonPopup = function() {
* This function checks if there is a fortune cookie on the ticker * This function checks if there is a fortune cookie on the ticker
* It is called by CM.Main.Loop * It is called by CM.Main.Loop
*/ */
CM.Main.CheckTickerFortune = function() { CM.Main.CheckTickerFortune = function () {
if (CM.Main.lastTickerFortuneState != (Game.TickerEffect && Game.TickerEffect.type === 'fortune')) { if (CM.Main.lastTickerFortuneState !== (Game.TickerEffect && Game.TickerEffect.type === 'fortune')) {
CM.Main.lastTickerFortuneState = (Game.TickerEffect && Game.TickerEffect.type === 'fortune'); CM.Main.lastTickerFortuneState = (Game.TickerEffect && Game.TickerEffect.type === 'fortune');
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.');
} }
} }
}; };
@@ -456,9 +454,9 @@ CM.Main.CheckTickerFortune = function() {
* This function checks if a garden tick has happened * This function checks if a garden tick has happened
* It is called by CM.Main.Loop * It is called by CM.Main.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');
} }
@@ -470,15 +468,15 @@ CM.Main.CheckGardenTick = function() {
* This function checks if the magic meter is full * This function checks if the magic meter is full
* It is called by CM.Main.Loop * It is called by CM.Main.Loop
*/ */
CM.Main.CheckMagicMeter = function() { CM.Main.CheckMagicMeter = function () {
if (Game.Objects['Wizard tower'].minigameLoaded && CM.Options.GrimoireBar === 1) { if (Game.Objects['Wizard tower'].minigameLoaded && CM.Options.GrimoireBar === 1) {
let minigame = Game.Objects['Wizard tower'].minigame; const minigame = Game.Objects['Wizard tower'].minigame;
if (minigame.magic < minigame.magicM) CM.Main.lastMagicBarFull = false; if (minigame.magic < minigame.magicM) CM.Main.lastMagicBarFull = false;
else if (!CM.Main.lastMagicBarFull) { else if (!CM.Main.lastMagicBarFull) {
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!');
} }
} }
}; };
@@ -487,10 +485,10 @@ CM.Main.CheckMagicMeter = function() {
* This function checks if any new Wrinklers have popped up * This function checks if any new Wrinklers have popped up
* It is called by CM.Main.Loop * It is called by CM.Main.Loop
*/ */
CM.Main.CheckWrinklerCount = function() { CM.Main.CheckWrinklerCount = function () {
if (Game.elderWrath > 0) { if (Game.elderWrath > 0) {
let CurrentWrinklers = 0; let CurrentWrinklers = 0;
for (let i in Game.wrinklers) { for (const 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) {
@@ -505,10 +503,10 @@ CM.Main.CheckWrinklerCount = function() {
} else { } else {
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;
@@ -521,18 +519,18 @@ CM.Main.CheckWrinklerCount = function() {
* It is called by CM.Main.DelayInit * It is called by CM.Main.DelayInit
* As wrinklers are not appended to the DOM we us a different system than for other tooltips * As wrinklers are not appended to the DOM we us a different system than for other tooltips
*/ */
CM.Main.AddWrinklerAreaDetect = function() { CM.Main.AddWrinklerAreaDetect = function () {
l('backgroundLeftCanvas').onmouseover = function() {CM.Disp.TooltipWrinklerArea = 1;}; l('backgroundLeftCanvas').onmouseover = function () { CM.Disp.TooltipWrinklerArea = 1; };
l('backgroundLeftCanvas').onmouseout = function() { l('backgroundLeftCanvas').onmouseout = function () {
CM.Disp.TooltipWrinklerArea = 0; CM.Disp.TooltipWrinklerArea = 0;
Game.tooltip.hide(); Game.tooltip.hide();
for (let i of Object.keys(Game.wrinklers)) { for (const 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 */
/** /**
@@ -540,14 +538,13 @@ CM.Main.AddWrinklerAreaDetect = function() {
* It is called by Game.UpdateWrinklers(), Game.UpdateSpecial() and the .onmousover of the BigCookie * It is called by Game.UpdateWrinklers(), Game.UpdateSpecial() and the .onmousover of the BigCookie
* before execution of their actual function * before execution of their actual function
*/ */
CM.Main.FixMouseY = function(target) { CM.Main.FixMouseY = function (target) {
if (CM.Options.TimerBar === 1 && CM.Options.TimerBarPos === 0) { if (CM.Options.TimerBar === 1 && CM.Options.TimerBarPos === 0) {
let timerBarHeight = parseInt(CM.Disp.TimerBar.style.height); const timerBarHeight = parseInt(CM.Disp.TimerBar.style.height);
Game.mouseY -= timerBarHeight; Game.mouseY -= timerBarHeight;
target(); target();
Game.mouseY += timerBarHeight; Game.mouseY += timerBarHeight;
} } else {
else {
target(); target();
} }
}; };

View File

@@ -1,8 +1,8 @@
/******* /**
* Sim * * Sim *
*******/ */
/******** /**
* Section: Functions to calculate building buy and sell prices */ * Section: Functions to calculate building buy and sell prices */
/** /**
@@ -16,10 +16,10 @@
* @param {number} increase Increase of building * @param {number} increase Increase of building
* @returns {number} moni Total price * @returns {number} moni Total price
*/ */
CM.Sim.BuildingGetPrice = function(build, basePrice, start, free, increase) { CM.Sim.BuildingGetPrice = function (build, basePrice, start, free, increase) {
let moni = 0; let moni = 0;
for (let i = 0; i < increase; i++) { for (let i = 0; i < increase; i++) {
let price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free)); let price = basePrice * 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;
@@ -35,13 +35,13 @@ CM.Sim.BuildingGetPrice = function(build, basePrice, start, free, increase) {
* @param {number} price Current price of building * @param {number} price Current price of building
* @returns {number} price The modified building price * @returns {number} price The modified building price
*/ */
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;
if (CM.Sim.Has('Santa\'s dominion')) price *= 0.99; if (CM.Sim.Has('Santa\'s dominion')) price *= 0.99;
if (CM.Sim.Has('Faberge egg')) price *= 0.99; if (CM.Sim.Has('Faberge egg')) price *= 0.99;
if (CM.Sim.Has('Divine discount')) price *= 0.99; if (CM.Sim.Has('Divine discount')) price *= 0.99;
if (CM.Sim.Has('Fortune #100')) price *= 0.99; if (CM.Sim.Has('Fortune #100')) price *= 0.99;
//if (CM.Sim.hasAura('Fierce Hoarder')) price *= 0.98; // if (CM.Sim.hasAura('Fierce Hoarder')) price *= 0.98;
price *= 1 - CM.Sim.auraMult('Fierce Hoarder') * 0.02; price *= 1 - CM.Sim.auraMult('Fierce Hoarder') * 0.02;
if (Game.hasBuff('Everything must go')) price *= 0.95; if (Game.hasBuff('Everything must go')) price *= 0.95;
if (Game.hasBuff('Crafty pixies')) price *= 0.98; if (Game.hasBuff('Crafty pixies')) price *= 0.98;
@@ -49,7 +49,7 @@ 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) {
let godLvl = CM.Sim.hasGod('creation'); const 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;
@@ -62,7 +62,7 @@ CM.Sim.modifyBuildingPrice = function(building, price) {
* It is called by CM.Sim.BuildingSell() * It is called by CM.Sim.BuildingSell()
* @returns {number} giveBack The multiplier * @returns {number} giveBack The multiplier
*/ */
CM.Sim.getSellMultiplier = function() { CM.Sim.getSellMultiplier = function () {
let giveBack = 0.25; let giveBack = 0.25;
giveBack *= 1 + CM.Sim.auraMult('Earth Shatterer'); giveBack *= 1 + CM.Sim.auraMult('Earth Shatterer');
return giveBack; return giveBack;
@@ -80,18 +80,18 @@ CM.Sim.getSellMultiplier = function() {
* @param {number} noSim 1 of 0 depending on if function is called from CM.Sim * @param {number} noSim 1 of 0 depending on if function is called from CM.Sim
* @returns {number} moni Total price gained * @returns {number} moni Total price gained
*/ */
CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, noSim) { CM.Sim.BuildingSell = function (build, basePrice, start, free, amount, noSim) {
// Calculate money gains from selling buildings // Calculate money gains from selling buildings
// If noSim is set, use Game methods to compute price instead of Sim ones. // If noSim is set, use Game methods to compute price instead of Sim ones.
noSim = typeof noSim === "undefined" ? 0 : noSim; noSim = typeof noSim === 'undefined' ? 0 : noSim;
let moni = 0; let moni = 0;
if (amount === -1) amount = start; if (amount === -1) amount = start;
if (!amount) amount = Game.buyBulk; if (!amount) amount = Game.buyBulk;
for (let i = 0; i < amount; i++) { for (let i = 0; i < amount; i++) {
let price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free)); let price = basePrice * 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);
let giveBack = noSim ? build.getSellMultiplier() : CM.Sim.getSellMultiplier(); const giveBack = noSim ? build.getSellMultiplier() : CM.Sim.getSellMultiplier();
price = Math.floor(price * giveBack); price = Math.floor(price * giveBack);
if (start > 0) { if (start > 0) {
moni += price; moni += price;
@@ -101,60 +101,60 @@ CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, noSim) {
return moni; return moni;
}; };
/******** /**
* Section: Functions related to making functions that check against sim data rather than game data */ * Section: Functions related to making functions that check against sim data rather than game data */
/** /**
* This functions helps create functions that check sim data * This functions helps create functions that check sim data
* For example, instead of Game.Has, a function that has gone through CM.Sim.ReplaceFunction will use CM.Sim.Has() * For example, instead of Game.Has, a function that has gone through CM.Sim.ReplaceFunction will use CM.Sim.Has()
* Subsequently the function rather than checking Game.Upgrades, will check CM.Sim.Upgrades * Subsequently the function rather than checking Game.Upgrades, will check CM.Sim.Upgrades
* *
* It is called by CM.Sim.ReplaceRelevantFunctions() * It is called by CM.Sim.ReplaceRelevantFunctions()
* @param {function} funcToBeReplaced Function to be replaced * @param {function} funcToBeReplaced Function to be replaced
* @returns {string} The function in string form with only calls to CM.Sim * @returns {string} The function in string form with only calls to CM.Sim
*/ */
CM.Sim.ReplaceFunction = function(funcToBeReplaced) { CM.Sim.ReplaceFunction = function (funcToBeReplaced) {
return funcToBeReplaced.toString() return funcToBeReplaced.toString()
.split("Game.Upgrades[") // Include '[' to not replace Game.UpgradesByPool .split('Game.Upgrades[') // Include '[' to not replace Game.UpgradesByPool
.join("CM.Sim.Upgrades[") .join('CM.Sim.Upgrades[')
.split("Game.Achievements") .split('Game.Achievements')
.join("CM.Sim.Achievements") .join('CM.Sim.Achievements')
.split("Game.Has") .split('Game.Has')
.join("CM.Sim.Has") .join('CM.Sim.Has')
.split("Game.dragonAura]") .split('Game.dragonAura]')
.join("CM.Sim.dragonAura]") .join('CM.Sim.dragonAura]')
.split("Game.dragonAura2]") .split('Game.dragonAura2]')
.join("CM.Sim.dragonAura2]") .join('CM.Sim.dragonAura2]')
.split("Game.auraMult") .split('Game.auraMult')
.join("CM.Sim.auraMult") .join('CM.Sim.auraMult')
.split("Game.hasGod") .split('Game.hasGod')
.join("CM.Sim.hasGod") .join('CM.Sim.hasGod')
.split("M.gods[what]") // Replaces code in the Pantheon minigame .split('M.gods[what]') // Replaces code in the Pantheon minigame
.join("CM.Sim.Objects.Temple.minigame.gods[what]") .join('CM.Sim.Objects.Temple.minigame.gods[what]')
.split("M.slot[i]") // Replaces code in the Pantheon minigame .split('M.slot[i]') // Replaces code in the Pantheon minigame
.join("CM.Sim.Objects.Temple.minigame.slot[i]") .join('CM.Sim.Objects.Temple.minigame.slot[i]')
.split("Game.effs") // Replaces code in the Pantheon minigame .split('Game.effs') // Replaces code in the Pantheon minigame
.join("CM.Sim.effs") .join('CM.Sim.effs')
.split("Game.Objects") .split('Game.Objects')
.join("CM.Sim.Objects") .join('CM.Sim.Objects')
.split("Game.GetTieredCpsMult") // Replace in .cps of building objects .split('Game.GetTieredCpsMult') // Replace in .cps of building objects
.join("CM.Sim.GetTieredCpsMult") .join('CM.Sim.GetTieredCpsMult')
.split('Game.eff') // Replace in .cps of building objects .split('Game.eff') // Replace in .cps of building objects
.join('CM.Sim.eff'); .join('CM.Sim.eff');
//.split('syn.buildingTie1.amount') // .split('syn.buildingTie1.amount')
//.join('CM.Sim.Objects[syn.buildingTie1.name].amount') // .join('CM.Sim.Objects[syn.buildingTie1.name].amount')
//.split('syn.buildingTie2.amount') // .split('syn.buildingTie2.amount')
//.join('CM.Sim.Objects[syn.buildingTie2.name].amount') // .join('CM.Sim.Objects[syn.buildingTie2.name].amount')
} };
/** /**
* This functions creates all functions by CM.Sim to check CM.Sim. data instead of Game. data * This functions creates all functions by CM.Sim to check CM.Sim. data instead of Game. data
* It does this by calling CM.Sim.ReplaceFunction() * It does this by calling CM.Sim.ReplaceFunction()
* It follows naming of the vanilla functions * It follows naming of the vanilla functions
* *
* It is called by CM.Main.DelayInit() * It is called by CM.Main.DelayInit()
*/ */
CM.Sim.CreateSimFunctions = function() { CM.Sim.CreateSimFunctions = function () {
CM.Sim.Has = new Function(`return ${CM.Sim.ReplaceFunction(Game.Has)}`)(); CM.Sim.Has = new Function(`return ${CM.Sim.ReplaceFunction(Game.Has)}`)();
CM.Sim.HasAchiev = new Function(`return ${CM.Sim.ReplaceFunction(Game.HasAchiev)}`)(); CM.Sim.HasAchiev = new Function(`return ${CM.Sim.ReplaceFunction(Game.HasAchiev)}`)();
CM.Sim.hasAura = new Function(`return ${CM.Sim.ReplaceFunction(Game.hasAura)}`)(); CM.Sim.hasAura = new Function(`return ${CM.Sim.ReplaceFunction(Game.hasAura)}`)();
@@ -163,7 +163,7 @@ CM.Sim.CreateSimFunctions = function() {
CM.Sim.auraMult = new Function(`return ${CM.Sim.ReplaceFunction(Game.auraMult)}`)(); CM.Sim.auraMult = new Function(`return ${CM.Sim.ReplaceFunction(Game.auraMult)}`)();
CM.Sim.eff = new Function(`return ${CM.Sim.ReplaceFunction(Game.eff)}`)(); CM.Sim.eff = new Function(`return ${CM.Sim.ReplaceFunction(Game.eff)}`)();
CM.Sim.GetTieredCpsMult = new Function(`return ${CM.Sim.ReplaceFunction(Game.GetTieredCpsMult)}`)(); CM.Sim.GetTieredCpsMult = new Function(`return ${CM.Sim.ReplaceFunction(Game.GetTieredCpsMult)}`)();
} };
/** /**
* This function "wins" an achievement in the current sim data * This function "wins" an achievement in the current sim data
@@ -171,16 +171,16 @@ CM.Sim.CreateSimFunctions = function() {
* It is not created by CM.Sim.CreateSimFunctions() in order to avoid spamming pop-ups upon winning * It is not created by CM.Sim.CreateSimFunctions() in order to avoid spamming pop-ups upon winning
* @param {string} what Name of the achievement * @param {string} what Name of the achievement
*/ */
CM.Sim.Win = function(what) { CM.Sim.Win = function (what) {
if (CM.Sim.Achievements[what]) { if (CM.Sim.Achievements[what]) {
if (CM.Sim.Achievements[what].won === 0) { if (CM.Sim.Achievements[what].won === 0) {
CM.Sim.Achievements[what].won = 1; CM.Sim.Achievements[what].won = 1;
if (Game.Achievements[what].pool != 'shadow') CM.Sim.AchievementsOwned++; if (Game.Achievements[what].pool !== 'shadow') CM.Sim.AchievementsOwned++;
} }
} }
}; };
/******** /**
* Section: Functions used to create static objects of Buildings, Upgrades and Achievements */ * Section: Functions used to create static objects of Buildings, Upgrades and Achievements */
/** /**
@@ -193,9 +193,9 @@ CM.Sim.Win = function(what) {
* @param {string} buildingName Name of the building * @param {string} buildingName Name of the building
* @returns {Object} you The static object * @returns {Object} you The static object
*/ */
CM.Sim.InitialBuildingData = function(buildingName) { CM.Sim.InitialBuildingData = function (buildingName) {
let me = Game.Objects[buildingName]; const me = Game.Objects[buildingName];
let you = {}; const you = {};
you.cps = new Function(`return ${CM.Sim.ReplaceFunction(me.cps)}`)(); you.cps = new Function(`return ${CM.Sim.ReplaceFunction(me.cps)}`)();
// Below is needed for above eval, specifically for the GetTieredCpsMult function // Below is needed for above eval, specifically for the GetTieredCpsMult function
you.baseCps = me.baseCps; you.baseCps = me.baseCps;
@@ -204,9 +204,9 @@ CM.Sim.InitialBuildingData = function(buildingName) {
you.synergies = me.synergies; you.synergies = me.synergies;
you.fortune = me.fortune; you.fortune = me.fortune;
you.grandma = me.grandma; you.grandma = me.grandma;
you.baseCPS = me.baseCps you.baseCPS = me.baseCps;
you.id = me.id you.id = me.id;
you.vanilla = me.vanilla you.vanilla = me.vanilla;
return you; return you;
}; };
@@ -216,12 +216,12 @@ CM.Sim.InitialBuildingData = function(buildingName) {
* @param {string} upgradeName Name of the Upgrade * @param {string} upgradeName Name of the Upgrade
* @returns {Object} you The static object * @returns {Object} you The static object
*/ */
CM.Sim.InitUpgrade = function(upgradeName) { CM.Sim.InitUpgrade = function (upgradeName) {
let me = Game.Upgrades[upgradeName]; const me = Game.Upgrades[upgradeName];
let you = {}; const you = {};
// Some upgrades have a function for .power (notably the valentine cookies) // Some upgrades have a function for .power (notably the valentine cookies)
you.power = me.power; you.power = me.power;
if (typeof(me.power) === 'function') { if (typeof (me.power) === 'function') {
me.power = new Function(`return ${CM.Sim.ReplaceFunction(me.power)}`)(); me.power = new Function(`return ${CM.Sim.ReplaceFunction(me.power)}`)();
} }
you.pool = me.pool; you.pool = me.pool;
@@ -235,47 +235,46 @@ CM.Sim.InitUpgrade = function(upgradeName) {
* @param {string} achievementName Name of the Achievement * @param {string} achievementName Name of the Achievement
* @returns {Object} you The static object * @returns {Object} you The static object
*/ */
CM.Sim.InitAchievement = function(achievementName) { CM.Sim.InitAchievement = function (achievementName) {
let me = Game.Achievements[achievementName]; const me = Game.Achievements[achievementName];
let you = {}; const you = {};
you.name = me.name; you.name = me.name;
return you; return you;
}; };
/** /**
* This function creates static objects for Buildings, Upgrades and Achievements * This function creates static objects for Buildings, Upgrades and Achievements
* It is called by CM.Main.DelayInit() * It is called by CM.Main.DelayInit()
*/ */
CM.Sim.InitData = function() { CM.Sim.InitData = function () {
// Buildings // Buildings
CM.Sim.Objects = []; CM.Sim.Objects = [];
for (let i of Object.keys(Game.Objects)) { for (const 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 (let i of Object.keys(Game.Upgrades)) { for (const 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 (let i of Object.keys(Game.Achievements)) { for (const 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();
}; };
/******** /**
* Section: Functions related to creating a new iteration of "sim data" */ * Section: Functions related to creating a new iteration of "sim data" */
/** /**
* This function copies all relevant data and therefore sets a new iteration of the "sim data" * This function copies all relevant data and therefore sets a new iteration of the "sim data"
* It is called at the start of any function that simulates certain behaviour or actions * It is called at the start of any function that simulates certain behaviour or actions
*/ */
CM.Sim.CopyData = function() { CM.Sim.CopyData = function () {
// Other variables // Other variables
CM.Sim.UpgradesOwned = Game.UpgradesOwned; CM.Sim.UpgradesOwned = Game.UpgradesOwned;
CM.Sim.pledges = Game.pledges; CM.Sim.pledges = Game.pledges;
@@ -284,11 +283,12 @@ CM.Sim.CopyData = function() {
CM.Sim.prestige = Game.prestige; CM.Sim.prestige = Game.prestige;
// Buildings // Buildings
for (let i of Object.keys(Game.Objects)) { for (const i of Object.keys(Game.Objects)) {
let me = Game.Objects[i]; const me = Game.Objects[i];
let 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); CM.Sim.Objects[i] = CM.Sim.InitialBuildingData(i);
you = CM.Sim.Objects[i];
CM.Disp.CreateBotBarBuildingColumn(i); // Add new building to the bottom bar CM.Disp.CreateBotBarBuildingColumn(i); // Add new building to the bottom bar
} }
you.amount = me.amount; you.amount = me.amount;
@@ -300,21 +300,23 @@ CM.Sim.CopyData = function() {
} }
// Upgrades // Upgrades
for (let i of Object.keys(Game.Upgrades)) { for (const i of Object.keys(Game.Upgrades)) {
let me = Game.Upgrades[i]; const me = Game.Upgrades[i];
let 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); CM.Sim.Upgrades[i] = CM.Sim.InitUpgrade(i);
you = CM.Sim.Upgrades[i];
} }
you.bought = me.bought; you.bought = me.bought;
} }
// Achievements // Achievements
for (let i of Object.keys(Game.Achievements)) { for (const i of Object.keys(Game.Achievements)) {
let me = Game.Achievements[i]; const me = Game.Achievements[i];
let 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); CM.Sim.Achievements[i] = CM.Sim.InitAchievement(i);
you = CM.Sim.Achievements[i];
} }
you.won = me.won; you.won = me.won;
} }
@@ -325,7 +327,7 @@ CM.Sim.CopyData = function() {
CM.Sim.dragonAura2 = CM.Cache.dragonAura2; CM.Sim.dragonAura2 = CM.Cache.dragonAura2;
}; };
/******** /**
* Section: Functions related to checking the CPS of the current sim data */ * Section: Functions related to checking the CPS of the current sim data */
/** /**
@@ -334,35 +336,35 @@ CM.Sim.CopyData = function() {
* It is called at the start of any function that simulates certain behaviour or actions * It is called at the start of any function that simulates certain behaviour or actions
* @global {number} CM.Sim.cookiesPs The CPS of the current sim data * @global {number} CM.Sim.cookiesPs The CPS of the current sim data
*/ */
CM.Sim.CalculateGains = function() { CM.Sim.CalculateGains = function () {
CM.Sim.cookiesPs = 0; CM.Sim.cookiesPs = 0;
let mult = 1; let mult = 1;
// Include minigame effects // Include minigame effects
let effs = {}; const effs = {};
for (let i of Object.keys(Game.Objects)) { for (const i of Object.keys(Game.Objects)) {
if (Game.Objects[i].minigameLoaded && Game.Objects[i].minigame.effs) { if (Game.Objects[i].minigameLoaded && Game.Objects[i].minigame.effs) {
let myEffs = Game.Objects[i].minigame.effs; const myEffs = Game.Objects[i].minigame.effs;
for (let ii in myEffs) { for (const 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];
} }
} }
} }
CM.Sim.effs = effs; CM.Sim.effs = effs;
if (Game.ascensionMode != 1) mult += parseFloat(CM.Sim.prestige) * 0.01 * CM.Sim.heavenlyPower * CM.Sim.GetHeavenlyMultiplier(); if (Game.ascensionMode !== 1) mult += parseFloat(CM.Sim.prestige) * 0.01 * CM.Sim.heavenlyPower * CM.Sim.GetHeavenlyMultiplier();
mult *= CM.Sim.eff('cps'); mult *= CM.Sim.eff('cps');
if (CM.Sim.Has('Heralds') && Game.ascensionMode != 1) mult *= 1 + 0.01 * Game.heralds; if (CM.Sim.Has('Heralds') && Game.ascensionMode !== 1) mult *= 1 + 0.01 * Game.heralds;
for (let i of Object.keys(Game.cookieUpgrades)) { for (const i of Object.keys(Game.cookieUpgrades)) {
let me = Game.cookieUpgrades[i]; const me = Game.cookieUpgrades[i];
if (CM.Sim.Has(me.name)) { if (CM.Sim.Has(me.name)) {
// Some upgrades have a functio as .power (notably the valentine cookies) // Some upgrades have a functio as .power (notably the valentine cookies)
// CM.Sim.InitialBuildingData has changed to use CM.Sim.Has instead of Game.Has etc. // CM.Sim.InitialBuildingData has changed to use CM.Sim.Has instead of Game.Has etc.
// Therefore this call is to the .power of the Sim.Object // Therefore this call is to the .power of the Sim.Object
if (typeof(me.power) === 'function') { if (typeof (me.power) === 'function') {
mult *= 1 + (CM.Sim.Upgrades[me.name].power(CM.Sim.Upgrades[me.name]) * 0.01); mult *= 1 + (CM.Sim.Upgrades[me.name].power(CM.Sim.Upgrades[me.name]) * 0.01);
} else mult *= 1 + (me.power * 0.01); } else mult *= 1 + (me.power * 0.01);
} }
@@ -395,8 +397,8 @@ CM.Sim.CalculateGains = function() {
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);
godLvl = CM.Sim.hasGod('decadence'); godLvl = CM.Sim.hasGod('decadence');
if (godLvl === 1) buildMult *= 0.93; if (godLvl === 1) buildMult *= 0.93;
@@ -416,13 +418,13 @@ CM.Sim.CalculateGains = function() {
if (CM.Sim.Has('Santa\'s legacy')) mult *= 1 + (Game.santaLevel + 1) * 0.03; if (CM.Sim.Has('Santa\'s legacy')) mult *= 1 + (Game.santaLevel + 1) * 0.03;
let milkProgress = CM.Sim.AchievementsOwned / 25; const milkProgress = CM.Sim.AchievementsOwned / 25;
let milkMult = 1; let milkMult = 1;
if (CM.Sim.Has('Santa\'s milk and cookies')) milkMult *= 1.05; if (CM.Sim.Has('Santa\'s milk and cookies')) milkMult *= 1.05;
//if (CM.Sim.hasAura('Breath of Milk')) milkMult *= 1.05; // if (CM.Sim.hasAura('Breath of Milk')) milkMult *= 1.05;
milkMult *= 1 + CM.Sim.auraMult('Breath of Milk') * 0.05; milkMult *= 1 + CM.Sim.auraMult('Breath of Milk') * 0.05;
if (CM.Sim.hasGod) { if (CM.Sim.hasGod) {
let godLvl = CM.Sim.hasGod('mother'); const 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;
@@ -447,15 +449,15 @@ 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 (let i of Object.keys(CM.Sim.Objects)) { for (const i of Object.keys(CM.Sim.Objects)) {
let me = CM.Sim.Objects[i]; const me = CM.Sim.Objects[i];
let storedCps = me.cps(me); let storedCps = me.cps(me);
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;
CM.Sim.cookiesPs += me.amount * storedCps; CM.Sim.cookiesPs += me.amount * storedCps;
} }
if (CM.Sim.Has('"egg"')) CM.Sim.cookiesPs += 9;//"egg" if (CM.Sim.Has('"egg"')) CM.Sim.cookiesPs += 9;// "egg"
mult *= catMult; mult *= catMult;
@@ -477,30 +479,30 @@ CM.Sim.CalculateGains = function() {
let day = Math.floor((CM.Sim.DateCentury - Game.startDate) / 1000 / 10) * 10 / 60 / 60 / 24; let day = Math.floor((CM.Sim.DateCentury - Game.startDate) / 1000 / 10) * 10 / 60 / 60 / 24;
day = Math.min(day, 100); day = Math.min(day, 100);
// Sets a Cache value to be displayed in the Stats page, could be moved... // Sets a Cache value to be displayed in the Stats page, could be moved...
CM.Cache.CentEgg = 1 + (1 - Math.pow(1 - day / 100, 3)) * 0.1; CM.Cache.CentEgg = 1 + (1 - (1 - day / 100) ** 3) * 0.1;
eggMult *= CM.Cache.CentEgg; eggMult *= CM.Cache.CentEgg;
} }
mult *= eggMult; mult *= eggMult;
if (CM.Sim.Has('Sugar baking')) mult *= (1 + Math.min(100, Game.lumps) * 0.01); if (CM.Sim.Has('Sugar baking')) mult *= (1 + Math.min(100, Game.lumps) * 0.01);
//if (CM.Sim.hasAura('Radiant Appetite')) mult *= 2; // if (CM.Sim.hasAura('Radiant Appetite')) mult *= 2;
mult *= 1 + CM.Sim.auraMult('Radiant Appetite'); mult *= 1 + CM.Sim.auraMult('Radiant Appetite');
let rawCookiesPs = CM.Sim.cookiesPs * mult; const rawCookiesPs = CM.Sim.cookiesPs * mult;
for (let i of Object.keys(Game.CpsAchievements)) { for (const 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;
let n = Game.shimmerTypes.golden.n; const n = Game.shimmerTypes.golden.n;
let auraMult = CM.Sim.auraMult('Dragon\'s Fortune'); const auraMult = CM.Sim.auraMult('Dragon\'s Fortune');
for (let i = 0; i < n; i++){ for (let i = 0; i < n; i++) {
mult *= 1 + auraMult * 1.23; mult *= 1 + auraMult * 1.23;
} }
let name = Game.bakeryName.toLowerCase(); const name = Game.bakeryName.toLowerCase();
if (name === 'orteil') mult *= 0.99; if (name === 'orteil') mult *= 0.99;
else if (name === 'ortiel') mult *= 0.98; else if (name === 'ortiel') mult *= 0.98;
@@ -509,8 +511,8 @@ CM.Sim.CalculateGains = function() {
if (CM.Sim.Has('Golden switch [off]')) { if (CM.Sim.Has('Golden switch [off]')) {
let goldenSwitchMult = 1.5; let goldenSwitchMult = 1.5;
if (CM.Sim.Has('Residual luck')) { if (CM.Sim.Has('Residual luck')) {
let upgrades = Game.goldenCookieUpgrades; const upgrades = Game.goldenCookieUpgrades;
for (let i of Object.keys(upgrades)) { for (const i of Object.keys(upgrades)) {
if (CM.Sim.Has(upgrades[i])) goldenSwitchMult += 0.1; if (CM.Sim.Has(upgrades[i])) goldenSwitchMult += 0.1;
} }
} }
@@ -522,11 +524,11 @@ CM.Sim.CalculateGains = function() {
mult *= 1 + veilMult; mult *= 1 + veilMult;
} }
if (CM.Sim.Has('Magic shenanigans')) mult*=1000; if (CM.Sim.Has('Magic shenanigans')) mult *= 1000;
if (CM.Sim.Has('Occult obstruction')) mult*=0; if (CM.Sim.Has('Occult obstruction')) mult *= 0;
CM.Sim.cookiesPs = Game.runModHookOnValue('cps', CM.Sim.cookiesPs); CM.Sim.cookiesPs = Game.runModHookOnValue('cps', CM.Sim.cookiesPs);
mult *= CM.Cache.getCPSBuffMult(); mult *= CM.Cache.getCPSBuffMult();
CM.Sim.cookiesPs *= mult; CM.Sim.cookiesPs *= mult;
@@ -539,9 +541,9 @@ CM.Sim.CalculateGains = function() {
* If so it CM.Sim.Win()'s them and the caller function will know to recall CM.Sim.CalculateGains() * If so it CM.Sim.Win()'s them and the caller function will know to recall CM.Sim.CalculateGains()
* It is called at the end of any functions that simulates certain behaviour * It is called at the end of any functions that simulates certain behaviour
*/ */
CM.Sim.CheckOtherAchiev = function() { CM.Sim.CheckOtherAchiev = function () {
let grandmas = 0; let grandmas = 0;
for (let i of Object.keys(Game.GrandmaSynergies)) { for (const 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');
@@ -551,11 +553,11 @@ CM.Sim.CheckOtherAchiev = function() {
let mathematician = 1; let mathematician = 1;
let base10 = 1; let base10 = 1;
let minAmount = 100000; let minAmount = 100000;
for (let i of Object.keys(CM.Sim.Objects)) { for (const 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')) {
if (CM.Sim.Objects[i].amount < Math.min(128, Math.pow(2, (Game.ObjectsById.length - Game.Objects[i].id) - 1))) mathematician = 0; if (CM.Sim.Objects[i].amount < Math.min(128, 2 ** ((Game.ObjectsById.length - Game.Objects[i].id) - 1))) mathematician = 0;
} }
if (!CM.Sim.HasAchiev('Base 10')) { if (!CM.Sim.HasAchiev('Base 10')) {
if (CM.Sim.Objects[i].amount < (Game.ObjectsById.length - Game.Objects[i].id) * 10) base10 = 0; if (CM.Sim.Objects[i].amount < (Game.ObjectsById.length - Game.Objects[i].id) * 10) base10 = 0;
@@ -596,21 +598,21 @@ CM.Sim.CheckOtherAchiev = function() {
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');
let hasAllHalloCook = true; let hasAllHalloCook = true;
for (let i of Object.keys(CM.Data.HalloCookies)) { for (const 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');
let hasAllChristCook = true; let hasAllChristCook = true;
for (let i of Object.keys(CM.Data.ChristCookies)) { for (const 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')) {
let list = Game.Tiers.fortune.upgrades; const list = Game.Tiers.fortune.upgrades;
let fortunes = 0; let fortunes = 0;
for (let i of Object.keys(list)) { for (const 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');
@@ -621,14 +623,14 @@ CM.Sim.CheckOtherAchiev = function() {
* This function calculates CPS without the Golden Switch * This function calculates CPS without the Golden Switch
* It is called by CM.Cache.NoGoldSwitchCPS() * It is called by CM.Cache.NoGoldSwitchCPS()
*/ */
CM.Sim.NoGoldSwitchCPS = function() { CM.Sim.NoGoldSwitchCPS = function () {
CM.Sim.CopyData(); CM.Sim.CopyData();
CM.Sim.Upgrades['Golden switch [off]'].bought = 0; CM.Sim.Upgrades['Golden switch [off]'].bought = 0;
CM.Sim.CalculateGains(); CM.Sim.CalculateGains();
return CM.Sim.cookiesPs; return CM.Sim.cookiesPs;
}; };
/******** /**
* Section: Functions related to calculating Bonus Income */ * Section: Functions related to calculating Bonus Income */
/** /**
@@ -638,9 +640,9 @@ CM.Sim.NoGoldSwitchCPS = function() {
* @param {number} amount The amount to be bought * @param {number} amount The amount to be bought
* @returns {number} The bonus income of the building * @returns {number} The bonus income of the building
*/ */
CM.Sim.BuyBuildingsBonusIncome = function(building, amount) { CM.Sim.BuyBuildingsBonusIncome = function (building, amount) {
CM.Sim.CopyData(); CM.Sim.CopyData();
let me = CM.Sim.Objects[building]; const me = CM.Sim.Objects[building];
me.amount += amount; me.amount += amount;
if (building === 'Cursor') { if (building === 'Cursor') {
@@ -655,21 +657,21 @@ CM.Sim.BuyBuildingsBonusIncome = function(building, amount) {
if (me.amount >= 600) CM.Sim.Win('With her finger and her thumb'); if (me.amount >= 600) CM.Sim.Win('With her finger and her thumb');
if (me.amount >= 700) CM.Sim.Win('Gotta hand it to you'); if (me.amount >= 700) CM.Sim.Win('Gotta hand it to you');
if (me.amount >= 800) CM.Sim.Win('The devil\'s workshop'); if (me.amount >= 800) CM.Sim.Win('The devil\'s workshop');
} } else {
else { for (const j in Game.Objects[me.name].tieredAchievs) {
for (let j in Game.Objects[me.name].tieredAchievs) { if (me.amount >= Game.Tiers[Game.Objects[me.name].tieredAchievs[j].tier].achievUnlock) {
if (me.amount >= Game.Tiers[Game.Objects[me.name].tieredAchievs[j].tier].achievUnlock)
CM.Sim.Win(Game.Objects[me.name].tieredAchievs[j].name); CM.Sim.Win(Game.Objects[me.name].tieredAchievs[j].name);
}
} }
} }
let lastAchievementsOwned = CM.Sim.AchievementsOwned; const lastAchievementsOwned = CM.Sim.AchievementsOwned;
CM.Sim.CalculateGains(); CM.Sim.CalculateGains();
CM.Sim.CheckOtherAchiev(); CM.Sim.CheckOtherAchiev();
if (lastAchievementsOwned != CM.Sim.AchievementsOwned) { if (lastAchievementsOwned !== CM.Sim.AchievementsOwned) {
CM.Sim.CalculateGains(); CM.Sim.CalculateGains();
} }
@@ -682,10 +684,10 @@ CM.Sim.BuyBuildingsBonusIncome = function(building, amount) {
* @param {string} building The name of the upgrade to be bought * @param {string} building The name of the upgrade to be bought
* @returns {[{number, number}]} The bonus income of the upgrade and the difference in MouseCPS * @returns {[{number, number}]} The bonus income of the upgrade and the difference in MouseCPS
*/ */
CM.Sim.BuyUpgradesBonusIncome = function(upgrade) { CM.Sim.BuyUpgradesBonusIncome = function (upgrade) {
if (Game.Upgrades[upgrade].pool === 'toggle' || (Game.Upgrades[upgrade].bought === 0 && Game.Upgrades[upgrade].unlocked && Game.Upgrades[upgrade].pool != 'prestige')) { if (Game.Upgrades[upgrade].pool === 'toggle' || (Game.Upgrades[upgrade].bought === 0 && Game.Upgrades[upgrade].unlocked && Game.Upgrades[upgrade].pool !== 'prestige')) {
CM.Sim.CopyData(); CM.Sim.CopyData();
let me = CM.Sim.Upgrades[upgrade]; const me = CM.Sim.Upgrades[upgrade];
me.bought = 1; me.bought = 1;
if (Game.CountsAsUpgradeOwned(Game.Upgrades[upgrade].pool)) CM.Sim.UpgradesOwned++; if (Game.CountsAsUpgradeOwned(Game.Upgrades[upgrade].pool)) CM.Sim.UpgradesOwned++;
@@ -693,44 +695,40 @@ CM.Sim.BuyUpgradesBonusIncome = function(upgrade) {
CM.Sim.pledges++; CM.Sim.pledges++;
if (CM.Sim.pledges > 0) CM.Sim.Win('Elder nap'); if (CM.Sim.pledges > 0) CM.Sim.Win('Elder nap');
if (CM.Sim.pledges >= 5) CM.Sim.Win('Elder slumber'); if (CM.Sim.pledges >= 5) CM.Sim.Win('Elder slumber');
} } else if (upgrade === 'Elder Covenant') {
else if (upgrade === 'Elder Covenant') {
CM.Sim.Win('Elder calm'); CM.Sim.Win('Elder calm');
} } else if (upgrade === 'Prism heart biscuits') {
else if (upgrade === 'Prism heart biscuits') {
CM.Sim.Win('Lovely cookies'); CM.Sim.Win('Lovely cookies');
} } else if (upgrade === 'Heavenly key') {
else if (upgrade === 'Heavenly key') {
CM.Sim.Win('Wholesome'); CM.Sim.Win('Wholesome');
} }
let lastAchievementsOwned = CM.Sim.AchievementsOwned; const lastAchievementsOwned = CM.Sim.AchievementsOwned;
CM.Sim.CalculateGains(); CM.Sim.CalculateGains();
CM.Sim.CheckOtherAchiev(); CM.Sim.CheckOtherAchiev();
if (lastAchievementsOwned != CM.Sim.AchievementsOwned) { if (lastAchievementsOwned !== CM.Sim.AchievementsOwned) {
CM.Sim.CalculateGains(); CM.Sim.CalculateGains();
} }
let diffMouseCPS = CM.Sim.mouseCps() - Game.computedMouseCps; const diffMouseCPS = CM.Sim.mouseCps() - Game.computedMouseCps;
if (diffMouseCPS) { if (diffMouseCPS) {
return [CM.Sim.cookiesPs - Game.cookiesPs, diffMouseCPS]; return [CM.Sim.cookiesPs - Game.cookiesPs, diffMouseCPS];
} }
return [CM.Sim.cookiesPs - Game.cookiesPs]; return [CM.Sim.cookiesPs - Game.cookiesPs];
} else { } else {
return []; return [];
} }
}; };
/** /**
* This function calculates the cookies per click * This function calculates the cookies per click
* It is called by CM.Sim.BuyUpgradesBonusIncome() when an upgrades has no bonus-income (and is thus a clicking-upgrade) * It is called by CM.Sim.BuyUpgradesBonusIncome() when an upgrades has no bonus-income (and is thus a clicking-upgrade)
* @returns {number} out The clicking power * @returns {number} out The clicking power
*/ */
CM.Sim.mouseCps = function() { CM.Sim.mouseCps = function () {
let add = 0; let add = 0;
if (CM.Sim.Has('Thousand fingers')) add += 0.1; if (CM.Sim.Has('Thousand fingers')) add += 0.1;
if (CM.Sim.Has('Million fingers')) add *= 5; if (CM.Sim.Has('Million fingers')) add *= 5;
@@ -742,10 +740,10 @@ CM.Sim.mouseCps = function() {
if (CM.Sim.Has('Septillion fingers')) add *= 20; if (CM.Sim.Has('Septillion fingers')) add *= 20;
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;
let num=0; let num = 0;
for (let i of Object.keys(CM.Sim.Objects)) {num += CM.Sim.Objects[i].amount;} for (const 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 *= num;
// Can use CM.Sim.cookiesPs as function is always called after CM.Sim.CalculateGains() // Can use CM.Sim.cookiesPs as function is always called after CM.Sim.CalculateGains()
if (CM.Sim.Has('Plastic mouse')) add += CM.Sim.cookiesPs * 0.01; if (CM.Sim.Has('Plastic mouse')) add += CM.Sim.cookiesPs * 0.01;
@@ -763,46 +761,45 @@ CM.Sim.mouseCps = function() {
if (CM.Sim.Has('Miraculite mouse')) add += CM.Sim.cookiesPs * 0.01; if (CM.Sim.Has('Miraculite mouse')) add += CM.Sim.cookiesPs * 0.01;
if (CM.Sim.Has('Fortune #104')) add += CM.Sim.cookiesPs * 0.01; if (CM.Sim.Has('Fortune #104')) add += CM.Sim.cookiesPs * 0.01;
let mult=1; let mult = 1;
if (CM.Sim.Has('Santa\'s helpers')) mult *= 1.1; if (CM.Sim.Has('Santa\'s helpers')) mult *= 1.1;
if (CM.Sim.Has('Cookie egg')) mult *= 1.1; if (CM.Sim.Has('Cookie egg')) mult *= 1.1;
if (CM.Sim.Has('Halo gloves')) mult *= 1.1; if (CM.Sim.Has('Halo gloves')) mult *= 1.1;
if (CM.Sim.Has('Dragon claw')) mult *= 1.03; if (CM.Sim.Has('Dragon claw')) mult *= 1.03;
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');
if (CM.Sim.Objects.Temple.minigameLoaded) { if (CM.Sim.Objects.Temple.minigameLoaded) {
if (CM.Sim.hasGod) { if (CM.Sim.hasGod) {
let godLvl = CM.Sim.hasGod('labor'); const godLvl = CM.Sim.hasGod('labor');
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;
} }
} }
for (let i of Object.keys(Game.buffs)) { for (const 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;
} }
//if (CM.Sim.auraMult('Dragon Cursor')) mult*=1.05; // if (CM.Sim.auraMult('Dragon Cursor')) mult*=1.05;
mult *= 1 + CM.Sim.auraMult('Dragon Cursor') * 0.05; mult *= 1 + CM.Sim.auraMult('Dragon Cursor') * 0.05;
// No need to make this function a CM function // No need to make this function a CM function
let out = mult * Game.ComputeCps(1, CM.Sim.Has('Reinforced index finger') + CM.Sim.Has('Carpal tunnel prevention cream') + CM.Sim.Has('Ambidextrous'), add); let out = mult * Game.ComputeCps(1, CM.Sim.Has('Reinforced index finger') + CM.Sim.Has('Carpal tunnel prevention cream') + CM.Sim.Has('Ambidextrous'), add);
out = Game.runModHookOnValue('cookiesPerClick', out); out = Game.runModHookOnValue('cookiesPerClick', out);
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;
}; };
/**
/********
* Section: Functions related to calculating the effect of changing Dragon Aura */ * Section: Functions related to calculating the effect of changing Dragon Aura */
/** /**
@@ -811,23 +808,23 @@ CM.Sim.mouseCps = function() {
* @param {number} aura The number of the aura currently selected by the mouse/user * @param {number} aura The number of the aura currently selected by the mouse/user
* @returns {[number, number]} [CM.Sim.cookiesPs - Game.cookiesPs, price] The bonus cps and the price of the change * @returns {[number, number]} [CM.Sim.cookiesPs - Game.cookiesPs, price] The bonus cps and the price of the change
*/ */
CM.Sim.CalculateChangeAura = function(aura) { 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
let auraToBeChanged = l('promptContent').children[0].innerHTML.includes("secondary"); const 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; 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 (let 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) {
let highestBuilding = CM.Sim.Objects[Game.ObjectsById[i].name].name; const 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;
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 = CM.Sim.Objects[highestBuilding].basePrice * 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 = Game.modifyBuildingPrice(CM.Sim.Objects[highestBuilding], price);
price = Math.ceil(price); price = Math.ceil(price);
break; break;
@@ -835,17 +832,17 @@ CM.Sim.CalculateChangeAura = function(aura) {
} }
} }
let lastAchievementsOwned = CM.Sim.AchievementsOwned; const lastAchievementsOwned = CM.Sim.AchievementsOwned;
CM.Sim.CalculateGains(); CM.Sim.CalculateGains();
CM.Sim.CheckOtherAchiev(); CM.Sim.CheckOtherAchiev();
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];
}; };
/******** /**
* Section: Functions related to calculating the reset bonus */ * Section: Functions related to calculating the reset bonus */
/** /**
@@ -854,7 +851,7 @@ CM.Sim.CalculateChangeAura = function(aura) {
* @param {number} newHeavenlyChips The total heavenly chips after ascension * @param {number} newHeavenlyChips The total heavenly chips after ascension
* @returns {number} ResetCPS The CPS difference after reset * @returns {number} ResetCPS The CPS difference after reset
*/ */
CM.Sim.ResetBonus = function(newHeavenlyChips) { CM.Sim.ResetBonus = function (newHeavenlyChips) {
// Calculate CPS with all Heavenly upgrades // Calculate CPS with all Heavenly upgrades
let curCPS = Game.cookiesPs; let curCPS = Game.cookiesPs;
@@ -900,17 +897,17 @@ CM.Sim.ResetBonus = function(newHeavenlyChips) {
CM.Sim.prestige = newHeavenlyChips; CM.Sim.prestige = newHeavenlyChips;
let lastAchievementsOwned = CM.Sim.AchievementsOwned; const lastAchievementsOwned = CM.Sim.AchievementsOwned;
CM.Sim.CalculateGains(); CM.Sim.CalculateGains();
CM.Sim.CheckOtherAchiev(); CM.Sim.CheckOtherAchiev();
if (lastAchievementsOwned != CM.Sim.AchievementsOwned) { if (lastAchievementsOwned !== CM.Sim.AchievementsOwned) {
CM.Sim.CalculateGains(); CM.Sim.CalculateGains();
} }
let ResetCPS = CM.Sim.cookiesPs - curCPS; const ResetCPS = CM.Sim.cookiesPs - curCPS;
// Reset Pretige level after calculation as it is used in CM.Sim.CalculateGains() so can't be local // Reset Pretige level after calculation as it is used in CM.Sim.CalculateGains() so can't be local
CM.Sim.prestige = Game.prestige; CM.Sim.prestige = Game.prestige;
@@ -918,7 +915,7 @@ CM.Sim.ResetBonus = function(newHeavenlyChips) {
return ResetCPS; return ResetCPS;
}; };
/******** /**
* Section: Functions related to selling builings before buying the chocolate egg */ * Section: Functions related to selling builings before buying the chocolate egg */
/** /**
@@ -926,11 +923,11 @@ CM.Sim.ResetBonus = function(newHeavenlyChips) {
* It is called by CM.Cache.CacheSellForChoEgg() * It is called by CM.Cache.CacheSellForChoEgg()
* @returns {number} sellTotal The maximum cookies to be earned * @returns {number} sellTotal The maximum cookies to be earned
*/ */
CM.Sim.SellBuildingsForChoEgg = function() { CM.Sim.SellBuildingsForChoEgg = function () {
let sellTotal = 0; let sellTotal = 0;
CM.Sim.CopyData(); CM.Sim.CopyData();
// Change auras to Earth Shatterer + Reality bending to optimize money made by selling // Change auras to Earth Shatterer + Reality bending to optimize money made by selling
let buildingsToSacrifice = 2; let buildingsToSacrifice = 2;
if (CM.Sim.dragonAura === 5 || CM.Sim.dragonAura === 18) { if (CM.Sim.dragonAura === 5 || CM.Sim.dragonAura === 18) {
@@ -945,8 +942,8 @@ CM.Sim.SellBuildingsForChoEgg = function() {
// Sacrifice highest buildings for the aura switch // Sacrifice highest buildings for the aura switch
for (let i = 0; i < buildingsToSacrifice; ++i) { for (let i = 0; i < buildingsToSacrifice; ++i) {
let highestBuilding = 0; let highestBuilding = 0;
for (let j in CM.Sim.Objects) { for (const j in CM.Sim.Objects) {
if (CM.Sim.Objects[j].amount > 0) { if (CM.Sim.Objects[j].amount > 0) {
highestBuilding = CM.Sim.Objects[j]; highestBuilding = CM.Sim.Objects[j];
} }
} }
@@ -955,8 +952,8 @@ CM.Sim.SellBuildingsForChoEgg = function() {
} }
// Get money made by selling all remaining buildings // Get money made by selling all remaining buildings
for (let i of Object.keys(CM.Sim.Objects)) { for (const i of Object.keys(CM.Sim.Objects)) {
let me = CM.Sim.Objects[i]; const 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);
} }