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 = {
"env": {
"browser": true,
"es2021": true
},
"globals": {
"module": "readonly",
"Game": "writable",
"l": "readonly",
"b64_to_utf8": "readonly",
"utf8_to_b64": "readonly",
"Beautify": "writable",
"realAudio": "readonly",
"JSColor": "readonly",
"jscolor": "readonly",
"BeautifyAll": "readonly",
"CM": "writable",
"unsafeWindow": "readonly",
},
"extends": "eslint:recommended",
"parserOptions": {
"ecmaVersion": 12
},
"rules": {
}
env: {
browser: true,
es2021: true,
},
globals: {
module: 'readonly',
Game: 'writable',
l: 'readonly',
b64_to_utf8: 'readonly',
utf8_to_b64: 'readonly',
Beautify: 'writable',
realAudio: 'readonly',
JSColor: 'readonly',
jscolor: 'readonly',
BeautifyAll: 'readonly',
CM: 'writable',
unsafeWindow: 'readonly',
},
extends: 'airbnb-base',
parserOptions: {
ecmaVersion: 12,
},
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:
- uses: actions/checkout@v2
- name: Run ESLint
run: npx eslint src
run: |
npm install
npx eslint src
Check_main_file:
runs-on: ubuntu-latest
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",
"devDependencies": {
"eslint": "^7.19.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-plugin-import": "^2.22.1",
"terser": "^5.6.0-beta"
},
"ccrepo": {
"icon": [
10,
0
10,
0
],
"name": "Cookie Monster"
}
}
}

View File

@@ -1,8 +1,8 @@
/*********
/**
* Cache *
*********/
*/
/********
/**
* Section: General Cache related functions */
/**
@@ -10,7 +10,7 @@
* The declaration follows the structure of the CM.Cache.js file
* It is called by CM.Main.DelayInit
*/
CM.Cache.InitCache = function() {
CM.Cache.InitCache = function () {
CM.Cache.CacheDragonAuras();
CM.Cache.CacheWrinklers();
CM.Cache.CacheStats();
@@ -20,7 +20,7 @@ CM.Cache.InitCache = function() {
CM.Cache.CacheSeaSpec();
CM.Cache.InitCookiesDiff();
CM.Cache.HeavenlyChipsDiff = new CMAvgQueue(5); // Used by CM.Cache.CacheHeavenlyChipsPS()
CM.Cache.CacheHeavenlyChipsPS
CM.Cache.CacheHeavenlyChipsPS();
CM.Cache.CacheAvgCPS();
CM.Cache.CacheIncome();
CM.Cache.CacheBuildingsPrices();
@@ -32,7 +32,7 @@ CM.Cache.InitCache = function() {
* It is called by CM.Main.Loop()
* @global {string} CM.Cache.TimeTillNextPrestige Time requried till next prestige level
*/
CM.Cache.LoopCache = function() {
CM.Cache.LoopCache = function () {
// Update Wrinkler Bank
CM.Cache.CacheWrinklers();
@@ -41,12 +41,11 @@ CM.Cache.LoopCache = function() {
CM.Cache.CacheAvgCPS();
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());
};
/********
/**
* Section: Helper functions */
/**
@@ -63,7 +62,7 @@ class CMAvgQueue {
this.queue = [];
}
addLatest (newValue) {
addLatest(newValue) {
if (this.queue.push(newValue) > this.maxLength) {
this.queue.shift();
}
@@ -74,7 +73,7 @@ class CMAvgQueue {
* @param {number} timePeriod The period in seconds to computer average over
* @returns {number} ret The average
*/
calcAverage (timePeriod) {
calcAverage(timePeriod) {
if (timePeriod > this.maxLength) timePeriod = this.maxLength;
if (timePeriod > this.queue.length) timePeriod = this.queue.length;
let ret = 0;
@@ -85,7 +84,7 @@ class CMAvgQueue {
}
}
/********
/**
* 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.dragonAura2 The number of the second (left) Aura
*/
CM.Cache.CacheDragonAuras = function() {
CM.Cache.CacheDragonAuras = function () {
CM.Cache.dragonAura = Game.dragonAura;
CM.Cache.dragonAura2 = Game.dragonAura2;
};
/********
/**
* 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}, {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.WrinklersNormal = 0;
CM.Cache.WrinklersFattest = [0, null];
@@ -118,11 +117,11 @@ CM.Cache.CacheWrinklers = function() {
let sucked = Game.wrinklers[i].sucked;
let toSuck = 1.1;
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;
if (Game.Has('Wrinklerspawn')) sucked *= 1.05;
if (CM.Sim.Objects.Temple.minigameLoaded) {
let godLvl = Game.hasGod('scorn');
const godLvl = Game.hasGod('scorn');
if (godLvl === 1) sucked *= 1.15;
else if (godLvl === 2) sucked *= 1.1;
else if (godLvl === 3) sucked *= 1.05;
@@ -135,7 +134,7 @@ CM.Cache.CacheWrinklers = function() {
}
};
/********
/**
* 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 {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.DragonsFortuneMultAdjustment;
let cpsBuffMult = CM.Cache.getCPSBuffMult();
const cpsBuffMult = CM.Cache.getCPSBuffMult();
if (cpsBuffMult > 0) CM.Cache.Lucky /= cpsBuffMult;
else CM.Cache.Lucky = 0;
CM.Cache.LuckyReward = CM.Cache.GoldenCookiesMult * (CM.Cache.Lucky * 0.15) + 13;
@@ -169,14 +168,14 @@ CM.Cache.CacheStats = function() {
CM.Cache.Edifice = 0;
let max = 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 > 0) n++;
}
for (let i of Object.keys(Game.Objects)) {
if ((Game.Objects[i].amount < max || n === 1) &&
Game.Objects[i].amount < 400 &&
Game.Objects[i].price * 2 > CM.Cache.Edifice) {
for (const i of Object.keys(Game.Objects)) {
if ((Game.Objects[i].amount < max || n === 1)
&& Game.Objects[i].amount < 400
&& Game.Objects[i].price * 2 > CM.Cache.Edifice) {
CM.Cache.Edifice = Game.Objects[i].price * 2;
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.DragonsFortuneMultAdjustment Multiplier for dragon fortune + active golden cookie
*/
CM.Cache.CacheGoldenAndWrathCookiesMults = function() {
CM.Cache.CacheGoldenAndWrathCookiesMults = function () {
if (CM.Footer.isInitzializing) {
CM.Cache.GoldenCookiesMult = 1;
CM.Cache.WrathCookiesMult = 1;
@@ -233,17 +232,16 @@ CM.Cache.CacheGoldenAndWrathCookiesMults = function() {
* @param {number} mult Multiplier
* @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 moni = 0;
let nextMoni = 0;
let nextRequired = 0;
let chain = 1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10);
while (nextMoni < maxPayout) {
moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(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 * Math.pow(10, chain + 1) * digit * mult), maxPayout * mult));
nextRequired = Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * mult);
moni = Math.max(digit, Math.min(Math.floor(1 / 9 * 10 ** chain * digit * mult), maxPayout * mult));
nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * 10 ** (chain + 1) * digit * mult), maxPayout * mult));
nextRequired = Math.floor(1 / 9 * 10 ** (chain + 1) * digit * mult);
totalFromChain += moni;
chain++;
}
@@ -266,10 +264,10 @@ 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.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;
// Removes effect of Frenzy etc.
let cpsBuffMult = CM.Cache.getCPSBuffMult();
const cpsBuffMult = CM.Cache.getCPSBuffMult();
if (cpsBuffMult > 0) maxPayout /= cpsBuffMult;
else maxPayout = 0;
@@ -297,24 +295,24 @@ 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.MissingUpgradesPrestige String containig the HTML to create the "crates" for missing prestige upgrades
*/
CM.Cache.CacheMissingUpgrades = function() {
CM.Cache.MissingUpgrades = "";
CM.Cache.MissingUpgradesCookies = "";
CM.Cache.MissingUpgradesPrestige = "";
let list = [];
//sort the upgrades
for (let i of Object.keys(Game.Upgrades)) {
CM.Cache.CacheMissingUpgrades = function () {
CM.Cache.MissingUpgrades = '';
CM.Cache.MissingUpgradesCookies = '';
CM.Cache.MissingUpgradesPrestige = '';
const list = [];
// sort the upgrades
for (const i of Object.keys(Game.Upgrades)) {
list.push(Game.Upgrades[i]);
}
let sortMap = function(a, b) {
if (a.order>b.order) return 1;
else if (a.order<b.order) return -1;
else return 0;
const sortMap = function (a, b) {
if (a.order > b.order) return 1;
else if (a.order < b.order) return -1;
return 0;
};
list.sort(sortMap);
for (let i of Object.keys(list)) {
let me = list[i];
for (const i of Object.keys(list)) {
const me = list[i];
if (me.bought === 0) {
let str = '';
@@ -322,7 +320,7 @@ CM.Cache.CacheMissingUpgrades = function() {
str += CM.Disp.crateMissing(me);
if (me.pool === 'prestige') CM.Cache.MissingUpgradesPrestige += 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()
* @global {number} CM.Cache.SeaSpec The reward for popping a reindeer
*/
CM.Cache.CacheSeaSpec = function() {
CM.Cache.CacheSeaSpec = function () {
if (Game.season === 'christmas') {
let val = Game.cookiesPs * 60;
if (Game.hasBuff('Elder frenzy')) val *= 0.5;
@@ -347,18 +345,18 @@ CM.Cache.CacheSeaSpec = function() {
* It is called by CM.Cache.LoopCache()
* @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
let currDate = Math.floor(Date.now() / 1000);
const currDate = Math.floor(Date.now() / 1000);
// Only calculate every new second
if ((Game.T / Game.fps) % 1 === 0) {
let chipsOwned = Game.HowMuchPrestige(Game.cookiesReset);
let ascendNowToOwn = Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned));
let ascendNowToGet = ascendNowToOwn - Math.floor(chipsOwned);
const chipsOwned = Game.HowMuchPrestige(Game.cookiesReset);
const ascendNowToOwn = Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned));
const ascendNowToGet = ascendNowToOwn - Math.floor(chipsOwned);
// Add recent gains to AvgQueue's
let timeDiff = currDate - CM.Cache.lastHeavenlyCheck;
let heavenlyChipsDiffAvg = Math.max(0, (ascendNowToGet - CM.Cache.lastHeavenlyChips)) / timeDiff;
const timeDiff = currDate - CM.Cache.lastHeavenlyCheck;
const heavenlyChipsDiffAvg = Math.max(0, (ascendNowToGet - CM.Cache.lastHeavenlyChips)) / timeDiff;
for (let i = 0; i < timeDiff; i++) {
CM.Cache.HeavenlyChipsDiff.addLatest(heavenlyChipsDiffAvg);
}
@@ -370,16 +368,16 @@ CM.Cache.CacheHeavenlyChipsPS = function() {
// Get average gain over period of 5 seconds
CM.Cache.HCPerSecond = CM.Cache.HeavenlyChipsDiff.calcAverage(5);
}
}
};
/********
/**
* Section: Functions related to caching CPS */
/**
* This functions caches creates the CMAvgQueue used by CM.Cache.CacheAvgCPS() to calculate CPS
* 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.WrinkDiff = 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.AvgCPSChoEgg Average cookies from combination of normal CPS and average Chocolate Cookie CPS
*/
CM.Cache.CacheAvgCPS = function() {
let currDate = Math.floor(Date.now() / 1000);
CM.Cache.CacheAvgCPS = function () {
const currDate = Math.floor(Date.now() / 1000);
// Only calculate every new second
if ((Game.T / Game.fps) % 1 === 0) {
let choEggTotal = Game.cookies + CM.Cache.SellForChoEgg;
@@ -405,12 +403,12 @@ CM.Cache.CacheAvgCPS = function() {
choEggTotal *= 0.05;
// Add recent gains to AvgQueue's
let timeDiff = currDate - CM.Cache.lastCPSCheck;
let bankDiffAvg = Math.max(0, (Game.cookies - CM.Cache.lastCookies)) / timeDiff;
let wrinkDiffAvg = Math.max(0, (CM.Cache.WrinklersTotal - CM.Cache.lastWrinkCookies)) / timeDiff;
let wrinkFattestDiffAvg = Math.max(0, (CM.Cache.WrinklersFattest[0] - CM.Cache.lastWrinkFattestCookies)) / timeDiff;
let choEggDiffAvg = Math.max(0,(choEggTotal - CM.Cache.lastChoEgg)) / timeDiff;
let clicksDiffAvg = (Game.cookieClicks - CM.Cache.lastClicks) / timeDiff;
const timeDiff = currDate - CM.Cache.lastCPSCheck;
const bankDiffAvg = Math.max(0, (Game.cookies - CM.Cache.lastCookies)) / timeDiff;
const wrinkDiffAvg = Math.max(0, (CM.Cache.WrinklersTotal - CM.Cache.lastWrinkCookies)) / timeDiff;
const wrinkFattestDiffAvg = Math.max(0, (CM.Cache.WrinklersFattest[0] - CM.Cache.lastWrinkFattestCookies)) / timeDiff;
const choEggDiffAvg = Math.max(0, (choEggTotal - CM.Cache.lastChoEgg)) / timeDiff;
const clicksDiffAvg = (Game.cookieClicks - CM.Cache.lastClicks) / timeDiff;
for (let i = 0; i < timeDiff; i++) {
CM.Cache.CookiesDiff.addLatest(bankDiffAvg);
CM.Cache.WrinkDiff.addLatest(wrinkDiffAvg);
@@ -428,7 +426,7 @@ CM.Cache.CacheAvgCPS = function() {
CM.Cache.lastClicks = Game.cookieClicks;
// 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.AverageGainWrink = CM.Cache.WrinkDiff.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 === 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) {
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()
* @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;
// Compute cookies earned by selling stock market goods
if (Game.Objects.Bank.minigameLoaded) {
let marketGoods = Game.Objects.Bank.minigame.goods;
const marketGoods = Game.Objects.Bank.minigame.goods;
let goodsVal = 0;
for (let i of Object.keys(marketGoods)) {
let marketGood = marketGoods[i];
for (const i of Object.keys(marketGoods)) {
const marketGood = marketGoods[i];
goodsVal += marketGood.stock * marketGood.val;
}
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.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;
let count = 0;
for (let i in Game.wrinklers) {
for (const i in Game.wrinklers) {
if (Game.wrinklers[i].phase === 2) count++;
}
let godMult = 1;
if (CM.Sim.Objects.Temple.minigameLoaded) {
let godLvl = Game.hasGod('scorn');
const godLvl = Game.hasGod('scorn');
if (godLvl === 1) godMult *= 1.15;
else if (godLvl === 2) godMult *= 1.1;
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()
* @returns {number} mult The multiplier
*/
CM.Cache.getCPSBuffMult = function() {
CM.Cache.getCPSBuffMult = function () {
let mult = 1;
for (let i of Object.keys(Game.buffs)) {
if (typeof Game.buffs[i].multCpS != 'undefined') mult *= Game.buffs[i].multCpS;
for (const i of Object.keys(Game.buffs)) {
if (typeof Game.buffs[i].multCpS !== 'undefined') mult *= Game.buffs[i].multCpS;
}
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()
* 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]')) {
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) */
/**
@@ -527,48 +523,45 @@ CM.Cache.NoGoldSwitchCPS = function() {
* @global {number} CM.Cache.lastDragonLevel The last cached dragon level
* @global {string} CM.Cache.CostDragonUpgrade The Beautified cost of the next upgrade
*/
CM.Cache.CacheDragonCost = function() {
if (CM.Cache.lastDragonLevel != Game.dragonLevel || CM.Sim.DoSims) {
if (Game.dragonLevel < 25 && Game.dragonLevels[Game.dragonLevel].buy.toString().includes("sacrifice")) {
CM.Cache.CacheDragonCost = function () {
if (CM.Cache.lastDragonLevel !== Game.dragonLevel || CM.Sim.DoSims) {
if (Game.dragonLevel < 25 && Game.dragonLevels[Game.dragonLevel].buy.toString().includes('sacrifice')) {
let target = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/Objects\[(.*)\]/)[1];
let amount = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/sacrifice\((.*?)\)/)[1];
if (target != "i") {
target = target.replaceAll("'", "");
const amount = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/sacrifice\((.*?)\)/)[1];
if (target !== 'i') {
target = target.replaceAll("'", '');
if (Game.Objects[target].amount < amount) {
CM.Cache.CostDragonUpgrade = "Not enough buildings to sell";
}
else {
CM.Cache.CostDragonUpgrade = 'Not enough buildings to sell';
} else {
let cost = 0;
CM.Sim.CopyData();
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 = Math.ceil(price);
cost += price;
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;
CM.Sim.CopyData();
for (let j of Object.keys(Game.Objects)) {
for (const j of Object.keys(Game.Objects)) {
target = j;
if (Game.Objects[target].amount < amount) {
CM.Cache.CostDragonUpgrade = "Not enough buildings to sell";
CM.Cache.CostDragonUpgrade = 'Not enough buildings to sell';
break;
}
else {
} else {
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 = Math.ceil(price);
cost += price;
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 */
/**
* 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()
*/
CM.Cache.CacheIncome = function() {
CM.Cache.CacheIncome = function () {
// Simulate Building Buys for 1, 10 and 100 amount
CM.Cache.CacheBuildingIncome(1, 'Objects1');
CM.Cache.CacheBuildingIncome(10, 'Objects10');
@@ -599,54 +592,54 @@ CM.Cache.CacheIncome = function() {
* @param {amount} amount Amount to be bought
* @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] = [];
for (let i of Object.keys(Game.Objects)) {
for (const i of Object.keys(Game.Objects)) {
CM.Cache[target][i] = {};
CM.Cache[target][i].bonus = CM.Sim.BuyBuildingsBonusIncome(i, amount);
if (amount != 1) {
if (amount !== 1) {
CM.Cache.DoRemakeBuildPrices = 1;
}
}
}
};
/**
* This functions starts the calculation/simulation of the bonus income of upgrades
* It is called by CM.Cache.CacheIncome()
*/
CM.Cache.CacheUpgradeIncome = function() {
CM.Cache.CacheUpgradeIncome = function () {
CM.Cache.Upgrades = [];
for (let i of Object.keys(Game.Upgrades)) {
let bonusIncome = CM.Sim.BuyUpgradesBonusIncome(i);
for (const i of Object.keys(Game.Upgrades)) {
const bonusIncome = CM.Sim.BuyUpgradesBonusIncome(i);
CM.Cache.Upgrades[i] = {};
if (bonusIncome[0]) CM.Cache.Upgrades[i].bonus = bonusIncome[0];
if (bonusIncome[1]) CM.Cache.Upgrades[i].bonusMouse = bonusIncome[1];
}
}
};
/********
/**
* Section: Functions related to caching prices */
/**
* 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()
*/
CM.Cache.CacheBuildingsPrices = function() {
for (let i of Object.keys(Game.Objects)) {
CM.Cache.CacheBuildingsPrices = function () {
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.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);
}
};
/********
/**
* Section: Functions related to caching PP */
/**
* 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()
*/
CM.Cache.CachePP = function() {
CM.Cache.CachePP = function () {
CM.Cache.CacheBuildingsPP();
CM.Cache.CacheUpgradePP();
};
@@ -658,7 +651,7 @@ CM.Cache.CachePP = function() {
* @params {number} price The price of the object
* @returns {string} color The colour assosciated with the pp value
*/
CM.Cache.ColourOfPP = function(me, price) {
CM.Cache.ColourOfPP = function (me, price) {
let color = '';
// Colour based on PP
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
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
if (CM.Options.PPOnlyConsiderBuyable) {
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...
* It is called by CM.Cache.CachePP()
*/
CM.Cache.CacheBuildingsPP = function() {
CM.Cache.CacheBuildingsPP = function () {
CM.Cache.min = Infinity;
CM.Cache.max = 1;
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
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) {
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);
@@ -705,13 +698,13 @@ CM.Cache.CacheBuildingsPP = function() {
if (CM.Cache.ArrayOfPPs.length === 1) {
break;
}
CM.Cache.ArrayOfPPs.shift()
CM.Cache.ArrayOfPPs.shift();
}
}
CM.Cache.min = CM.Cache.ArrayOfPPs[CM.Options.PPExcludeTop][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;
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());
// Colour based on excluding certain top-buildings
for (let j = 0; j < CM.Options.PPExcludeTop; j++) {
@@ -721,15 +714,14 @@ CM.Cache.CacheBuildingsPP = function() {
// Calculate PP of bulk-buy modes
CM.Cache.CacheBuildingsBulkPP('Objects10');
CM.Cache.CacheBuildingsBulkPP('Objects100');
}
// Calculate PP and colors when compared to purchase of selected bulk mode
else {
let target = `Objects${Game.buyBulk}`
for (let i of Object.keys(CM.Cache[target])) {
} else {
// Calculate PP and colors when compared to purchase of selected bulk mode
const target = `Objects${Game.buyBulk}`;
for (const i of Object.keys(CM.Cache[target])) {
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);
} 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
CM.Cache.ArrayOfPPs.sort((a, b) => a[0] - b[0]);
@@ -738,14 +730,14 @@ CM.Cache.CacheBuildingsPP = function() {
if (CM.Cache.ArrayOfPPs.length === 1) {
break;
}
CM.Cache.ArrayOfPPs.shift()
CM.Cache.ArrayOfPPs.shift();
}
}
CM.Cache.min = CM.Cache.ArrayOfPPs[CM.Options.PPExcludeTop][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;
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);
// Colour based on excluding certain top-buildings
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 is called by CM.Cache.CacheBuildingsPP()
*/
CM.Cache.CacheBuildingsBulkPP = function(target) {
for (let i of Object.keys(CM.Cache[target])) {
CM.Cache.CacheBuildingsBulkPP = function (target) {
for (const i of Object.keys(CM.Cache[target])) {
if (Game.cookiesPs) {
CM.Cache[target][i].pp = (Math.max(CM.Cache[target][i].price - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (CM.Cache[target][i].price / CM.Cache[target][i].bonus);
} else CM.Cache[target][i].pp = (CM.Cache[target][i].price / CM.Cache[target][i].bonus);
@@ -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
* It is called by CM.Cache.CachePP()
*/
CM.Cache.CacheUpgradePP = function() {
for (let i of Object.keys(CM.Cache.Upgrades)) {
CM.Cache.CacheUpgradePP = function () {
for (const i of Object.keys(CM.Cache.Upgrades)) {
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);
} 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());
}
};
/********
/**
* Section: Cached variables */
/**

View File

@@ -1,8 +1,8 @@
/**********
/**
* Config *
**********/
*/
/********
/**
* Section: Functions related to saving, loading and restoring configs */
/**
@@ -11,12 +11,12 @@
* 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.Config.SaveConfig = function() {
let saveString = b64_to_utf8(unescape(localStorage.getItem('CookieClickerGame')).split('!END!')[0]);
let CookieMonsterSave = saveString.match(/CookieMonster.*(;|$)/);
if (CookieMonsterSave != null) {
let newSaveString = saveString.replace(CookieMonsterSave[0], "CookieMonster:" + CM.save());
localStorage.setItem('CookieClickerGame', escape(utf8_to_b64(newSaveString)+'!END!'));
CM.Config.SaveConfig = function () {
const saveString = b64_to_utf8(unescape(localStorage.getItem('CookieClickerGame')).split('!END!')[0]);
const CookieMonsterSave = saveString.match(/CookieMonster.*(;|$)/);
if (CookieMonsterSave !== null) {
const newSaveString = saveString.replace(CookieMonsterSave[0], `CookieMonster:${CM.save()}`);
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
* 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
if (typeof localStorage.CMConfig != "undefined") {
if (typeof localStorage.CMConfig !== 'undefined') {
delete localStorage.CMConfig;
}
if (settings != null) {
if (settings !== undefined) {
CM.Options = settings;
// Check values
let mod = false;
for (let i in CM.Data.ConfigDefault) {
for (const i in CM.Data.ConfigDefault) {
if (typeof CM.Options[i] === 'undefined') {
mod = true;
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 (!(CM.Options[i] > -1 && CM.Options[i] < CM.Data.Config[i].label.length)) {
mod = true;
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
if (typeof CM.Options[i] != 'string') {
mod = true;
CM.Options[i] = CM.Data.ConfigDefault[i];
}
}
}
else if (i === 'Header') {
for (let j in CM.Data.ConfigDefault.Header) {
} else if (i === 'Header') {
for (const j in CM.Data.ConfigDefault.Header) {
if (typeof CM.Options[i][j] === 'undefined' || !(CM.Options[i][j] > -1 && CM.Options[i][j] < 2)) {
mod = true;
CM.Options[i][j] = CM.Data.ConfigDefault[i][j];
}
}
}
else { // Colors
for (let j in CM.Data.ConfigDefault.Colors) {
if (typeof CM.Options[i][j] === 'undefined' || typeof CM.Options[i][j] != 'string') {
} else { // Colors
for (const j in CM.Data.ConfigDefault.Colors) {
if (typeof CM.Options[i][j] === 'undefined' || typeof CM.Options[i][j] !== 'string') {
mod = true;
CM.Options[i][j] = CM.Data.ConfigDefault[i][j];
}
@@ -72,13 +66,12 @@ CM.Config.LoadConfig = function(settings) {
}
if (mod) CM.Config.SaveConfig();
CM.Main.Loop(); // Do loop once
for (let i in CM.Data.ConfigDefault) {
if (i != 'Header' && typeof CM.Data.Config[i].func !== 'undefined') {
for (const i in CM.Data.ConfigDefault) {
if (i !== 'Header' && typeof CM.Data.Config[i].func !== 'undefined') {
CM.Data.Config[i].func();
}
}
}
else { // Default values
} else { // Default values
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
* 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.SaveConfig();
Game.UpdateMenu();
};
/********
/**
* 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
* @param {string} config The name of the option
*/
CM.Config.ToggleConfig = function(config) {
CM.Config.ToggleConfig = function (config) {
CM.Options[config]++;
if (CM.Options[config] === CM.Data.Config[config].label.length) {
CM.Options[config] = 0;
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') {
CM.Data.Config[config].func();
@@ -123,10 +115,10 @@ CM.Config.ToggleConfig = function(config) {
* It is called by the oninput and onchange event of "vol" type options
* @param {string} config The name of the option
*/
CM.Config.ToggleConfigVolume = function(config) {
if (l("slider" + config) != null) {
l("slider" + config + "right").innerHTML = l("slider" + config).value + "%";
CM.Options[config] = Math.round(l("slider" + config).value);
CM.Config.ToggleConfigVolume = function (config) {
if (l(`slider${config}`) !== null) {
l(`slider${config}right`).innerHTML = `${l(`slider${config}`).value}%`;
CM.Options[config] = Math.round(l(`slider${config}`).value);
}
CM.Config.SaveConfig();
};
@@ -136,13 +128,13 @@ CM.Config.ToggleConfigVolume = function(config) {
* It is called by the onclick event of the +/- next to headers
* @param {string} config The name of the header
*/
CM.Config.ToggleHeader = function(config) {
CM.Config.ToggleHeader = function (config) {
CM.Options.Header[config]++;
if (CM.Options.Header[config] > 1) CM.Options.Header[config] = 0;
CM.Config.SaveConfig();
};
/********
/**
* Section: Functions related to notifications */
/**
@@ -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
* @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) {
// Check if browser support Promise version of Notification Permissions
let checkNotificationPromise = function () {
const checkNotificationPromise = function () {
try {
Notification.requestPermission().then();
} catch(e) {
} catch (e) {
return false;
}
return true;
@@ -165,20 +157,16 @@ CM.Config.CheckNotificationPermissions = function(ToggleOnOff) {
// Check if the browser supports notifications and which type
if (!('Notification' in window)) {
console.log("This browser does not support notifications.");
}
else {
if(checkNotificationPromise()) {
Notification.requestPermission().then();
}
else {
Notification.requestPermission();
}
console.log('This browser does not support notifications.');
} else if (checkNotificationPromise()) {
Notification.requestPermission().then();
} else {
Notification.requestPermission();
}
}
};
/********
/**
* Section: Variables used in Config functions */
/**

View File

@@ -1,8 +1,8 @@
/********
/**
* Data *
********/
*/
/********
/**
* Section: Data used in the stats page to show not yet purchased updates. See CM.Disp.CreateStatsMissDisp() */
CM.Data.Fortunes = [
@@ -28,82 +28,82 @@ CM.Data.Fortunes = [
'Fortune #101',
'Fortune #102',
'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.ChristCookies = ['Christmas tree biscuits', 'Snowflake biscuits', 'Snowman biscuits', 'Holly biscuits', 'Candy cane biscuits', 'Bell biscuits', 'Present biscuits'];
CM.Data.ValCookies = ['Pure heart biscuits', 'Ardent heart biscuits', 'Sour heart biscuits', 'Weeping heart biscuits', 'Golden heart biscuits', 'Eternal heart biscuits', 'Prism heart biscuits'];
CM.Data.PlantDrops = ['Elderwort biscuits', 'Bakeberry cookies', 'Duketater cookies', 'Green yeast digestives', 'Wheat slims', 'Fern tea', 'Ichor syrup'];
/********
/**
* Section: All possible effects plants and other items can have with an explanation */
CM.Data.Effects = {
buildingCost: "Building prices",
click: "Cookies per click",
cps: "Total CPS",
cursorCps: "Cursor CPS",
goldenCookieDur: "Golden cookie duration",
goldenCookieEffDur: "Golden cookie effect duration",
goldenCookieFreq: "Golden cookie frequency",
goldenCookieGain: "Golden cookie gains",
grandmaCps: "Grandma CPS",
itemDrops: "Random item drop chance",
milk: "Effect from milk",
reindeerDur: "Reindeer duration",
reindeerFreq: "Reindeer frequency",
reindeerGain: "Reindeer gains",
upgradeCost: "Upgrade prices",
wrathCookieDur: "Wrath cookie duration",
wrathCookieEffDur: "Wrath cookie effect duration",
wrathCookieFreq: "Wrath cookie frequency",
wrathCookieGain: "Wrath cookie gains",
wrinklerEat: "Wrinkler ",
wrinklerSpawn: "Wrinkler spawn frequency"
buildingCost: 'Building prices',
click: 'Cookies per click',
cps: 'Total CPS',
cursorCps: 'Cursor CPS',
goldenCookieDur: 'Golden cookie duration',
goldenCookieEffDur: 'Golden cookie effect duration',
goldenCookieFreq: 'Golden cookie frequency',
goldenCookieGain: 'Golden cookie gains',
grandmaCps: 'Grandma CPS',
itemDrops: 'Random item drop chance',
milk: 'Effect from milk',
reindeerDur: 'Reindeer duration',
reindeerFreq: 'Reindeer frequency',
reindeerGain: 'Reindeer gains',
upgradeCost: 'Upgrade prices',
wrathCookieDur: 'Wrath cookie duration',
wrathCookieEffDur: 'Wrath cookie effect duration',
wrathCookieFreq: 'Wrath cookie frequency',
wrathCookieGain: 'Wrath cookie gains',
wrinklerEat: 'Wrinkler ',
wrinklerSpawn: 'Wrinkler spawn frequency',
};
/********
/**
* Section: Data for the various scales used by CookieMonster */
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.shortScaleAbbreviated = ['', 'K', 'M', 'B', 'T', 'Qa', 'Qi', 'Sx', 'Sp', 'Oc', 'No', 'De',
'UDe', 'DDe', 'TDe', 'QaDe', 'QiDe', 'SxDe', 'SpDe', 'ODe', 'NDe', 'Vi',
'UVi', 'DVi', 'TVi', 'QaVi', 'QiVi', 'SxVi', 'SpVi', 'OVi', 'NVi', 'Tr',
'UTr', 'DTr', 'TTr', 'QaTr', 'QiTr', 'SxTr', 'SpTr', 'OTr', 'NTr', 'Qaa',
'UQa', 'DQa', 'TQa', 'QaQa', 'QiQa', 'SxQa', 'SpQa', 'OQa', 'NQa', 'Qia',
'UQi', 'DQi', 'TQi', 'QaQi', 'QiQi', 'SxQi', 'SpQi', 'OQi', 'NQi', 'Sxa',
'USx', 'DSx', 'TSx', 'QaSx', 'QiSx', 'SxSx', 'SpSx', 'OSx', 'NSx', 'Spa',
'USp', 'DSp', 'TSp', 'QaSp', 'QiSp', 'SxSp', 'SpSp', 'OSp', 'NSp', 'Oco',
'UOc', 'DOc', 'TOc', 'QaOc', 'QiOc', 'SxOc', 'SpOc', 'OOc', 'NOc', 'Noa',
'UNo', 'DNo', 'TNo', 'QaNo', 'QiNo', 'SxNo', 'SpNo', 'ONo', 'NNo', 'Ct',
'UCt'];
'UDe', 'DDe', 'TDe', 'QaDe', 'QiDe', 'SxDe', 'SpDe', 'ODe', 'NDe', 'Vi',
'UVi', 'DVi', 'TVi', 'QaVi', 'QiVi', 'SxVi', 'SpVi', 'OVi', 'NVi', 'Tr',
'UTr', 'DTr', 'TTr', 'QaTr', 'QiTr', 'SxTr', 'SpTr', 'OTr', 'NTr', 'Qaa',
'UQa', 'DQa', 'TQa', 'QaQa', 'QiQa', 'SxQa', 'SpQa', 'OQa', 'NQa', 'Qia',
'UQi', 'DQi', 'TQi', 'QaQi', 'QiQi', 'SxQi', 'SpQi', 'OQi', 'NQi', 'Sxa',
'USx', 'DSx', 'TSx', 'QaSx', 'QiSx', 'SxSx', 'SpSx', 'OSx', 'NSx', 'Spa',
'USp', 'DSp', 'TSp', 'QaSp', 'QiSp', 'SxSp', 'SpSp', 'OSp', 'NSp', 'Oco',
'UOc', 'DOc', 'TOc', 'QaOc', 'QiOc', 'SxOc', 'SpOc', 'OOc', 'NOc', 'Noa',
'UNo', 'DNo', 'TNo', 'QaNo', 'QiNo', 'SxNo', 'SpNo', 'ONo', 'NNo', 'Ct',
'UCt'];
/********
/**
* Section: Two array's containing all Config groups and their to-be displayed title */
CM.Data.ConfigGroups = {
BarsColors: "Bars/Colors",
Calculation: "Calculation",
Notification: "Notification",
Tooltip: "Tooltips and additional insights",
Statistics: "Statistics",
Notation: "Notation",
Miscellaneous: "Miscellaneous"
BarsColors: 'Bars/Colors',
Calculation: 'Calculation',
Notification: 'Notification',
Tooltip: 'Tooltips and additional insights',
Statistics: 'Statistics',
Notation: 'Notation',
Miscellaneous: 'Miscellaneous',
};
CM.Data.ConfigGroupsNotification = {
NotificationGeneral: "General Notifications",
NotificationGC: "Golden Cookie",
NotificationFC: "Fortune Cookie",
NotificationSea: "Season Special",
NotificationGard: "Garden Tick",
NotificationMagi: "Full Magic Bar",
NotificationWrink: "Wrinkler",
NotificationWrinkMax: "Maximum Wrinklers",
NotificationGeneral: 'General Notifications',
NotificationGC: 'Golden Cookie',
NotificationFC: 'Fortune Cookie',
NotificationSea: 'Season Special',
NotificationGard: 'Garden Tick',
NotificationMagi: 'Full Magic Bar',
NotificationWrink: 'Wrinkler',
NotificationWrinkMax: 'Maximum Wrinklers',
};
/********
/**
* Section: An array (CM.Data.Config) containing all Config options and an array of default settings */
/**
@@ -117,16 +117,36 @@ CM.Data.ConfigGroupsNotification = {
* @item {function} func A function to be called when the option is toggled
*/
// 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.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();}};
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.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();}};
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.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',
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.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(); },
};
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.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(); },
};
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.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',
@@ -136,121 +156,274 @@ CM.Data.Config.Colors = { type: 'color', group: 'BarsColors',
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'
Brown: 'Color Brown. Used for Dragon Harvest bar',
},
func: function() {CM.Disp.UpdateColors();}
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
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.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};
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.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};
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.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,
};
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.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
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.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};
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'};
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.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,
};
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++) {
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.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);}};
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'};
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.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); },
};
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++) {
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.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);}};
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'};
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.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); },
};
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++) {
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.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'};
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.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++) {
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.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);}};
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'};
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.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); },
};
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++) {
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.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);}};
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'};
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.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); },
};
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++) {
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.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);}};
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'};
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.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); },
};
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++) {
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
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.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};
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.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};
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};
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.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,
};
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.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,
};
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
CM.Data.Config.Stats = {type: 'bool', group: 'Statistics', label: ['Statistics OFF', 'Statistics ON'], desc: 'Extra Cookie Monster statistics!', toggle: true};
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};
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.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};
CM.Data.Config.Stats = {
type: 'bool', group: 'Statistics', label: ['Statistics OFF', 'Statistics ON'], desc: 'Extra Cookie Monster statistics!', toggle: true,
};
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,
};
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.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
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.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};
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.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
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.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};
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.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
@@ -319,7 +492,7 @@ CM.Data.ConfigDefault = {
ToolWarnEdifice: 1,
ToolWarnUser: 0,
ToolWarnPos: 1,
TooltipGrim:1,
TooltipGrim: 1,
TooltipWrink: 1,
TooltipLump: 1,
TooltipPlots: 1,
@@ -337,14 +510,18 @@ CM.Data.ConfigDefault = {
ScaleDecimals: 2,
ScaleSeparator: 0,
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,
SortUpgrades: 0,
GCTimer: 1,
Favicon: 1,
WrinklerButtons: 1,
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>
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>
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>
`
`;
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>
- 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>
- 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 Ascend button can now display additional info (this can be turned off in the settings)</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 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 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>
- 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>
@@ -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>
- 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 buy warnings showing incorrectly</br>
</div>
`
`;

File diff suppressed because it is too large Load Diff

View File

@@ -1,8 +1,8 @@
/**********
/**
* Footer *
**********/
*/
/********
/**
* Section: Functions related to base game modding API */
/**
@@ -11,18 +11,18 @@
* declare hooks here"
* It starts the further initialization of CookieMonster and registers hooks
*/
CM.init = function() {
CM.Footer.isInitzializing = true
let proceed = true;
if (Game.version != 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?');
}
if (proceed) {
CM.Main.DelayInit();
Game.registerHook('draw', CM.Disp.Draw);
Game.registerHook('logic', CM.Main.Loop);
CM.Footer.isInitzializing = false
}
CM.init = function () {
CM.Footer.isInitzializing = true;
let proceed = true;
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?`);
}
if (proceed) {
CM.Main.DelayInit();
Game.registerHook('draw', CM.Disp.Draw);
Game.registerHook('logic', CM.Main.Loop);
CM.Footer.isInitzializing = false;
}
};
/**
@@ -30,27 +30,27 @@ CM.init = function() {
* "use this to store persistent data associated with your mod
* return 'a string to be saved';"
*/
CM.save = function() {
return JSON.stringify({
settings: CM.Options,
version: CM.VersionMajor + '.' + CM.VersionMinor,
});
CM.save = function () {
return JSON.stringify({
settings: CM.Options,
version: `${CM.VersionMajor}.${CM.VersionMinor}`,
});
};
/**
* This registers a load function to the CM object. Per Game code/comments:
* "do stuff with the string data you saved previously"
*/
CM.load = function(str) {
let save = JSON.parse(str);
CM.Config.LoadConfig(save.settings);
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!');
else Game.Notify('A new version of Cookie Monster has been loaded, check out the release notes in the info tab!', '', '', 0, 1);
}
CM.load = function (str) {
const save = JSON.parse(str);
CM.Config.LoadConfig(save.settings);
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!');
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 */
/**
@@ -58,11 +58,11 @@ CM.load = function(str) {
* functionality needed to dynamiccaly change colours
* 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.type = 'text/javascript';
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
*/
if (typeof CM.Footer.isInitzializing === 'undefined') {
CM.Footer.AddJscolor();
let delay = setInterval(function() {
if (typeof jscolor !== 'undefined') {
jscolor.init();
Game.registerMod('CookieMonster', CM);
clearInterval(delay);
}
}, 500);
CM.Footer.AddJscolor();
const delay = setInterval(function () {
if (typeof jscolor !== 'undefined') {
jscolor.init();
Game.registerMod('CookieMonster', CM);
clearInterval(delay);
}
}, 500);
}

View File

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

View File

@@ -1,22 +1,22 @@
/********
/**
* Main *
********/
*/
/********
/**
* Section: Functions related to the main and initialization loop */
/**
* Main loop of Cookie Monster
* CM.init registers it to the "logic" hook provided by the modding api
*/
CM.Main.Loop = function() {
if (CM.Disp.lastAscendState != Game.OnAscend) {
CM.Main.Loop = function () {
if (CM.Disp.lastAscendState !== Game.OnAscend) {
CM.Disp.lastAscendState = Game.OnAscend;
CM.Disp.UpdateAscendState();
}
if (!Game.OnAscend && Game.AscendTimer === 0) {
// 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.InitData();
CM.Cache.InitCache();
@@ -41,12 +41,11 @@ CM.Main.Loop = function() {
}
// 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) {
CM.Cache.HadBuildAura = true;
CM.Cache.DoRemakeBuildPrices = 1;
}
else if (CM.Cache.HadBuildAura && !hasBuildAura) {
} else if (CM.Cache.HadBuildAura && !hasBuildAura) {
CM.Cache.HadBuildAura = false;
CM.Cache.DoRemakeBuildPrices = 1;
}
@@ -72,7 +71,7 @@ CM.Main.Loop = function() {
* Initialization loop of Cookie Monster
* Called by CM.init()
*/
CM.Main.DelayInit = function() {
CM.Main.DelayInit = function () {
// Create CM.Sim functions
CM.Sim.CreateSimFunctions();
@@ -80,7 +79,7 @@ CM.Main.DelayInit = function() {
CM.Cache.InitCache();
// 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
CM.Disp.CreateCssArea();
@@ -89,7 +88,7 @@ CM.Main.DelayInit = function() {
CM.Disp.CreateUpgradeBar();
CM.Disp.CreateWhiteScreen();
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.CreateWrinklerButtons();
@@ -105,61 +104,61 @@ CM.Main.DelayInit = function() {
CM.Config.LoadConfig(); // Must be after all things are created!
CM.Disp.lastAscendState = Game.OnAscend;
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);
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);
Game.Win('Third-party');
};
/********
/**
* Section: Functions related to replacing stuff */
/**
* This function replaces certain native (from the base-game) functions
* It is called by CM.Main.DelayInit()
*/
CM.Main.ReplaceNative = function() {
CM.Main.ReplaceNative = function () {
CM.Backup.Beautify = Beautify;
Beautify = CM.Disp.Beautify;
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'));
Game.CalculateGains = function() {
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')}`);
Game.CalculateGains = function () {
CM.Backup.CalculateGainsMod();
CM.Sim.DoSims = 1;
};
CM.Backup.tooltip = {};
CM.Backup.tooltip.draw = Game.tooltip.draw;
eval('CM.Backup.tooltip.drawMod = ' + Game.tooltip.draw.toString().split('this').join('Game.tooltip'));
Game.tooltip.draw = function(from, text, origin) {
eval(`CM.Backup.tooltip.drawMod = ${Game.tooltip.draw.toString().split('this').join('Game.tooltip')}`);
Game.tooltip.draw = function (from, text, origin) {
CM.Backup.tooltip.drawMod(from, text, origin);
};
CM.Backup.tooltip.update = Game.tooltip.update;
eval('CM.Backup.tooltip.updateMod = ' + Game.tooltip.update.toString().split('this.').join('Game.tooltip.'));
Game.tooltip.update = function() {
eval(`CM.Backup.tooltip.updateMod = ${Game.tooltip.update.toString().split('this.').join('Game.tooltip.')}`);
Game.tooltip.update = function () {
CM.Backup.tooltip.updateMod();
CM.Disp.UpdateTooltipLocation();
};
CM.Backup.UpdateWrinklers = Game.UpdateWrinklers;
Game.UpdateWrinklers = function() {
Game.UpdateWrinklers = function () {
CM.Main.FixMouseY(CM.Backup.UpdateWrinklers);
};
CM.Backup.UpdateSpecial = Game.UpdateSpecial;
Game.UpdateSpecial = function() {
Game.UpdateSpecial = function () {
CM.Main.FixMouseY(CM.Backup.UpdateSpecial);
};
// Assumes newer browsers
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;
Game.RebuildUpgrades = function() {
Game.RebuildUpgrades = function () {
CM.Backup.RebuildUpgrades();
CM.Disp.ReplaceTooltipUpgrade();
Game.CalculateGains();
@@ -170,7 +169,7 @@ CM.Main.ReplaceNative = function() {
* 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.
*/
Game.ClickProduct = function(what) {
Game.ClickProduct = function (what) {
if (!CM.Options.BulkBuyBlock || Game.ObjectsById[what].bulkPrice < Game.cookies) {
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
* @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.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
*/
Game.ToggleSpecialMenu = function(on) {
Game.ToggleSpecialMenu = function (on) {
CM.Backup.ToggleSpecialMenu(on);
CM.Disp.AddDragonLevelUpTooltip();
};
CM.Backup.UpdateMenu = Game.UpdateMenu;
Game.UpdateMenu = function() {
Game.UpdateMenu = function () {
if (typeof jscolor.picker === 'undefined' || typeof jscolor.picker.owner === 'undefined') {
CM.Backup.UpdateMenu();
CM.Disp.AddMenu();
@@ -205,8 +204,8 @@ CM.Main.ReplaceNative = function() {
};
CM.Backup.sayTime = Game.sayTime;
CM.Disp.sayTime = function(time, detail) {
if (isNaN(time) || time <= 0) return CM.Backup.sayTime(time, detail);
CM.Disp.sayTime = function (time, detail) {
if (Number.isNaN(time) || time <= 0) return CM.Backup.sayTime(time, detail);
else return CM.Disp.FormatTime(time / Game.fps, 1);
};
@@ -214,12 +213,12 @@ CM.Main.ReplaceNative = function() {
CM.Backup.Logic = Game.Logic;
CM.Backup.LogicMod = new Function(
`return ${Game.Logic.toString()
.split('document.title')
.join('CM.Disp.Title')
.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>` : ``}`;")}`,
.split('document.title')
.join('CM.Disp.Title')
.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>` : ``}`;")}`,
)();
Game.Logic = function() {
Game.Logic = function () {
CM.Backup.LogicMod();
// Update Title
CM.Disp.UpdateTitle();
@@ -230,7 +229,7 @@ CM.Main.ReplaceNative = function() {
* This function fixes replaces the Launch and Draw functions of the Grimoire
* It is called by CM.Main.DelayInit() and Game.LoadMinigames()
*/
CM.Main.ReplaceNativeGrimoire = function() {
CM.Main.ReplaceNativeGrimoire = function () {
CM.Main.ReplaceNativeGrimoireLaunch();
CM.Main.ReplaceNativeGrimoireDraw();
};
@@ -239,12 +238,12 @@ CM.Main.ReplaceNativeGrimoire = function() {
* This function fixes replaces the .launch function of the Grimoire
* It is called by CM.Main.ReplaceNativeGrimoire()
*/
CM.Main.ReplaceNativeGrimoireLaunch = function() {
CM.Main.ReplaceNativeGrimoireLaunch = function () {
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;
eval('CM.Backup.GrimoireLaunchMod = ' + minigame.launch.toString().split('=this').join('= Game.Objects[\'Wizard tower\'].minigame'));
Game.Objects['Wizard tower'].minigame.launch = function() {
eval(`CM.Backup.GrimoireLaunchMod = ${minigame.launch.toString().split('=this').join('= Game.Objects[\'Wizard tower\'].minigame')}`);
Game.Objects['Wizard tower'].minigame.launch = function () {
CM.Backup.GrimoireLaunchMod();
CM.Main.ReplaceTooltipGrimoire();
CM.HasReplaceNativeGrimoireDraw = false;
@@ -258,35 +257,35 @@ CM.Main.ReplaceNativeGrimoireLaunch = function() {
* This function fixes replaces the .draw function of the Grimoire
* It is called by CM.Main.ReplaceNativeGrimoire()
*/
CM.Main.ReplaceNativeGrimoireDraw = function() {
CM.Main.ReplaceNativeGrimoireDraw = function () {
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;
Game.Objects['Wizard tower'].minigame.draw = function() {
Game.Objects['Wizard tower'].minigame.draw = function () {
CM.Backup.GrimoireDraw();
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;
}
};
/********
/**
* Section: Functions related to first initizalition of CM */
/**
* This function call all functions that replace Game-tooltips with CM-enhanced tooltips
* It is called by CM.Main.DelayInit()
*/
CM.Main.ReplaceTooltips = function() {
CM.Main.ReplaceTooltips = function () {
CM.Main.ReplaceTooltipBuild();
CM.Main.ReplaceTooltipLump();
// Replace Tooltips of Minigames. Nesting it in LoadMinigames makes sure to replace them even if
// they were not loaded initially
CM.Backup.LoadMinigames = Game.LoadMinigames;
Game.LoadMinigames = function() {
Game.LoadMinigames = function () {
CM.Backup.LoadMinigames();
CM.Main.ReplaceTooltipGarden();
CM.Main.ReplaceTooltipGrimoire();
@@ -295,7 +294,7 @@ CM.Main.ReplaceTooltips = function() {
Game.LoadMinigames();
};
/********
/**
* Section: Functions related to replacing tooltips */
/**
@@ -303,13 +302,13 @@ CM.Main.ReplaceTooltips = function() {
* CM.Disp.Tooltip() sets the tooltip type to 'b'
* It is called by CM.Main.ReplaceTooltips()
*/
CM.Main.ReplaceTooltipBuild = function() {
CM.Main.ReplaceTooltipBuild = function () {
CM.Main.TooltipBuildBackup = [];
for (let i of Object.keys(Game.Objects)) {
let me = Game.Objects[i];
if (l('product' + me.id).onmouseover != null) {
CM.Main.TooltipBuildBackup[i] = l('product' + me.id).onmouseover;
eval('l(\'product\' + me.id).onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'b\', \'' + i + '\');}, \'store\'); Game.tooltip.wobble();}');
for (const i of Object.keys(Game.Objects)) {
const me = Game.Objects[i];
if (l(`product${me.id}`).onmouseover !== null) {
CM.Main.TooltipBuildBackup[i] = l(`product${me.id}`).onmouseover;
eval(`l('product' + me.id).onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip('b', '${i}');}, 'store'); Game.tooltip.wobble();}`);
}
}
};
@@ -319,10 +318,10 @@ CM.Main.ReplaceTooltipBuild = function() {
* CM.Disp.Tooltip() sets the tooltip type to 's'
* It is called by CM.Main.ReplaceTooltips()
*/
CM.Main.ReplaceTooltipLump = function() {
CM.Main.ReplaceTooltipLump = function () {
if (Game.canLumps()) {
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'
* It is called by CM.Main.ReplaceTooltips()
*/
CM.Main.ReplaceTooltipGrimoire = function() {
CM.Main.ReplaceTooltipGrimoire = function () {
if (Game.Objects['Wizard tower'].minigameLoaded) {
CM.Main.TooltipGrimoireBackup = [];
for (let i in Game.Objects['Wizard tower'].minigame.spellsById) {
if (l('grimoireSpell' + i).onmouseover != null) {
CM.Main.TooltipGrimoireBackup[i] = l('grimoireSpell' + i).onmouseover;
eval('l(\'grimoireSpell\' + i).onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'g\', \'' + i + '\');}, \'this\'); Game.tooltip.wobble();}');
for (const i in Game.Objects['Wizard tower'].minigame.spellsById) {
if (l(`grimoireSpell${i}`).onmouseover !== null) {
CM.Main.TooltipGrimoireBackup[i] = l(`grimoireSpell${i}`).onmouseover;
eval(`l('grimoireSpell' + i).onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip('g', '${i}');}, 'this'); Game.tooltip.wobble();}`);
}
}
}
@@ -348,17 +347,17 @@ CM.Main.ReplaceTooltipGrimoire = function() {
* CM.Disp.Tooltip() sets the tooltip type to 'p'
* It is called by CM.Main.ReplaceTooltips()
*/
CM.Main.ReplaceTooltipGarden = function() {
CM.Main.ReplaceTooltipGarden = function () {
if (Game.Objects.Farm.minigameLoaded) {
l('gardenTool-1').onmouseover = function() {Game.tooltip.dynamic=1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip('ha', 'HarvestAllButton');}, 'this'); Game.tooltip.wobble();};
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) => {
let 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();};
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(); };
});
}
};
/********
/**
* Section: Functions related to checking for changes in Minigames/GC's/Ticker */
/**
@@ -366,10 +365,10 @@ CM.Main.ReplaceTooltipGarden = function() {
* 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
*/
CM.Main.FindShimmer = function() {
CM.Main.FindShimmer = function () {
CM.Main.currSpawnedGoldenCookieState = 0;
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];
if (Game.shimmers[i].spawnLead && Game.shimmers[i].type === 'golden') {
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
* It is called by CM.Main.Loop
*/
CM.Main.CheckGoldenCookie = function() {
CM.Main.CheckGoldenCookie = function () {
CM.Main.FindShimmer();
for (let i of Object.keys(CM.Disp.GCTimers)) {
if (typeof CM.Cache.goldenShimmersByID[i] === "undefined") {
for (const i of Object.keys(CM.Disp.GCTimers)) {
if (typeof CM.Cache.goldenShimmersByID[i] === 'undefined') {
CM.Disp.GCTimers[i].parentNode.removeChild(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;
if (CM.Main.lastGoldenCookieState) {
if (CM.Main.lastSpawnedGoldenCookieState < CM.Main.currSpawnedGoldenCookieState) {
CM.Disp.Flash(3, 'GCFlash');
CM.Disp.PlaySound(CM.Options.GCSoundURL, 'GCSound', 'GCVolume');
CM.Disp.Notification('GCNotification', "Golden Cookie Spawned", "A Golden Cookie has spawned. Click it now!");
CM.Disp.Notification('GCNotification', 'Golden Cookie Spawned', 'A Golden Cookie has spawned. Click it now!');
}
for (let i of Object.keys(Game.shimmers)) {
if (typeof CM.Disp.GCTimers[Game.shimmers[i].id] === "undefined") {
for (const i of Object.keys(Game.shimmers)) {
if (typeof CM.Disp.GCTimers[Game.shimmers[i].id] === 'undefined') {
CM.Disp.CreateGCTimer(Game.shimmers[i]);
}
}
@@ -408,9 +407,8 @@ CM.Main.CheckGoldenCookie = function() {
CM.Disp.UpdateFavicon();
CM.Main.lastSpawnedGoldenCookieState = CM.Main.currSpawnedGoldenCookieState;
if (CM.Main.currSpawnedGoldenCookieState === 0) CM.Cache.spawnedGoldenShimmer = 0;
}
else if (CM.Options.GCTimer === 1 && CM.Main.lastGoldenCookieState) {
for (let i of Object.keys(CM.Disp.GCTimers)) {
} else if (CM.Options.GCTimer === 1 && CM.Main.lastGoldenCookieState) {
for (const i of Object.keys(CM.Disp.GCTimers)) {
CM.Disp.GCTimers[i].style.opacity = CM.Cache.goldenShimmersByID[i].l.style.opacity;
CM.Disp.GCTimers[i].style.transform = CM.Cache.goldenShimmersByID[i].l.style.transform;
CM.Disp.GCTimers[i].textContent = Math.ceil(CM.Cache.goldenShimmersByID[i].life / Game.fps);
@@ -422,10 +420,10 @@ CM.Main.CheckGoldenCookie = function() {
* This function checks if there is reindeer that has spawned
* It is called by CM.Main.Loop
*/
CM.Main.CheckSeasonPopup = function() {
if (CM.Main.lastSeasonPopupState != Game.shimmerTypes.reindeer.spawned) {
CM.Main.CheckSeasonPopup = function () {
if (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') {
CM.Cache.seasonPopShimmer = Game.shimmers[i];
break;
@@ -433,7 +431,7 @@ CM.Main.CheckSeasonPopup = function() {
}
CM.Disp.Flash(3, 'SeaFlash');
CM.Disp.PlaySound(CM.Options.SeaSoundURL, 'SeaSound', 'SeaVolume');
CM.Disp.Notification('SeaNotification',"Reindeer sighted!", "A Reindeer has spawned. Click it now!");
CM.Disp.Notification('SeaNotification', 'Reindeer sighted!', 'A Reindeer has spawned. Click it now!');
}
};
@@ -441,13 +439,13 @@ CM.Main.CheckSeasonPopup = function() {
* This function checks if there is a fortune cookie on the ticker
* It is called by CM.Main.Loop
*/
CM.Main.CheckTickerFortune = function() {
if (CM.Main.lastTickerFortuneState != (Game.TickerEffect && Game.TickerEffect.type === 'fortune')) {
CM.Main.CheckTickerFortune = function () {
if (CM.Main.lastTickerFortuneState !== (Game.TickerEffect && Game.TickerEffect.type === 'fortune')) {
CM.Main.lastTickerFortuneState = (Game.TickerEffect && Game.TickerEffect.type === 'fortune');
if (CM.Main.lastTickerFortuneState) {
CM.Disp.Flash(3, 'FortuneFlash');
CM.Disp.PlaySound(CM.Options.FortuneSoundURL, 'FortuneSound', 'FortuneVolume');
CM.Disp.Notification('FortuneNotification', "Fortune Cookie found", "A Fortune Cookie has appeared on the Ticker.");
CM.Disp.Notification('FortuneNotification', 'Fortune Cookie found', 'A Fortune Cookie has appeared on the Ticker.');
}
}
};
@@ -456,9 +454,9 @@ CM.Main.CheckTickerFortune = function() {
* This function checks if a garden tick has happened
* It is called by CM.Main.Loop
*/
CM.Main.CheckGardenTick = function() {
if (Game.Objects.Farm.minigameLoaded && CM.Main.lastGardenNextStep != Game.Objects.Farm.minigame.nextStep) {
if (CM.Main.lastGardenNextStep != 0 && CM.Main.lastGardenNextStep < Date.now()) {
CM.Main.CheckGardenTick = function () {
if (Game.Objects.Farm.minigameLoaded && CM.Main.lastGardenNextStep !== Game.Objects.Farm.minigame.nextStep) {
if (CM.Main.lastGardenNextStep !== 0 && CM.Main.lastGardenNextStep < Date.now()) {
CM.Disp.Flash(3, 'GardFlash');
CM.Disp.PlaySound(CM.Options.GardSoundURL, 'GardSound', 'GardVolume');
}
@@ -470,15 +468,15 @@ CM.Main.CheckGardenTick = function() {
* This function checks if the magic meter is full
* 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) {
let minigame = Game.Objects['Wizard tower'].minigame;
const minigame = Game.Objects['Wizard tower'].minigame;
if (minigame.magic < minigame.magicM) CM.Main.lastMagicBarFull = false;
else if (!CM.Main.lastMagicBarFull) {
CM.Main.lastMagicBarFull = true;
CM.Disp.Flash(3, 'MagicFlash');
CM.Disp.PlaySound(CM.Options.MagicSoundURL, 'MagicSound', 'MagicVolume');
CM.Disp.Notification('MagicNotification', "Magic Meter full", "Your Magic Meter is full. Cast a spell!");
CM.Disp.Notification('MagicNotification', 'Magic Meter full', 'Your Magic Meter is full. Cast a spell!');
}
}
};
@@ -487,10 +485,10 @@ CM.Main.CheckMagicMeter = function() {
* This function checks if any new Wrinklers have popped up
* It is called by CM.Main.Loop
*/
CM.Main.CheckWrinklerCount = function() {
CM.Main.CheckWrinklerCount = function () {
if (Game.elderWrath > 0) {
let CurrentWrinklers = 0;
for (let i in Game.wrinklers) {
for (const i in Game.wrinklers) {
if (Game.wrinklers[i].phase === 2) CurrentWrinklers++;
}
if (CurrentWrinklers > CM.Main.lastWrinklerCount) {
@@ -505,10 +503,10 @@ CM.Main.CheckWrinklerCount = function() {
} else {
CM.Disp.PlaySound(CM.Options.WrinklerSoundURL, 'WrinklerSound', 'WrinklerVolume');
}
if (CurrentWrinklers === Game.getWrinklersMax() && CM.Options.WrinklerMaxNotification) {
CM.Disp.Notification('WrinklerMaxNotification', "Maximum Wrinklers Reached", "You have reached your maximum ammount of wrinklers");
if (CurrentWrinklers === Game.getWrinklersMax() && CM.Options.WrinklerMaxNotification) {
CM.Disp.Notification('WrinklerMaxNotification', 'Maximum Wrinklers Reached', 'You have reached your maximum ammount of wrinklers');
} else {
CM.Disp.Notification('WrinklerNotification', "A Wrinkler appeared", "A new wrinkler has appeared");
CM.Disp.Notification('WrinklerNotification', 'A Wrinkler appeared', 'A new wrinkler has appeared');
}
} else {
CM.Main.lastWrinklerCount = CurrentWrinklers;
@@ -521,18 +519,18 @@ CM.Main.CheckWrinklerCount = function() {
* It is called by CM.Main.DelayInit
* As wrinklers are not appended to the DOM we us a different system than for other tooltips
*/
CM.Main.AddWrinklerAreaDetect = function() {
l('backgroundLeftCanvas').onmouseover = function() {CM.Disp.TooltipWrinklerArea = 1;};
l('backgroundLeftCanvas').onmouseout = function() {
CM.Main.AddWrinklerAreaDetect = function () {
l('backgroundLeftCanvas').onmouseover = function () { CM.Disp.TooltipWrinklerArea = 1; };
l('backgroundLeftCanvas').onmouseout = function () {
CM.Disp.TooltipWrinklerArea = 0;
Game.tooltip.hide();
for (let i of Object.keys(Game.wrinklers)) {
for (const i of Object.keys(Game.wrinklers)) {
CM.Disp.TooltipWrinklerBeingShown[i] = 0;
}
};
};
/********
/**
* 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
* 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) {
let timerBarHeight = parseInt(CM.Disp.TimerBar.style.height);
const timerBarHeight = parseInt(CM.Disp.TimerBar.style.height);
Game.mouseY -= timerBarHeight;
target();
Game.mouseY += timerBarHeight;
}
else {
} else {
target();
}
};

View File

@@ -1,8 +1,8 @@
/*******
/**
* Sim *
*******/
*/
/********
/**
* Section: Functions to calculate building buy and sell prices */
/**
@@ -16,10 +16,10 @@
* @param {number} increase Increase of building
* @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;
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 = Math.ceil(price);
moni += price;
@@ -35,13 +35,13 @@ CM.Sim.BuildingGetPrice = function(build, basePrice, start, free, increase) {
* @param {number} price Current price of building
* @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('Santa\'s dominion')) 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('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;
if (Game.hasBuff('Everything must go')) price *= 0.95;
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;
price *= CM.Sim.eff('buildingCost');
if (CM.Sim.Objects.Temple.minigameLoaded) {
let godLvl = CM.Sim.hasGod('creation');
const godLvl = CM.Sim.hasGod('creation');
if (godLvl === 1) price *= 0.93;
else if (godLvl === 2) price *= 0.95;
else if (godLvl === 3) price *= 0.98;
@@ -62,7 +62,7 @@ CM.Sim.modifyBuildingPrice = function(building, price) {
* It is called by CM.Sim.BuildingSell()
* @returns {number} giveBack The multiplier
*/
CM.Sim.getSellMultiplier = function() {
CM.Sim.getSellMultiplier = function () {
let giveBack = 0.25;
giveBack *= 1 + CM.Sim.auraMult('Earth Shatterer');
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
* @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
// 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;
if (amount === -1) amount = start;
if (!amount) amount = Game.buyBulk;
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 = Math.ceil(price);
let giveBack = noSim ? build.getSellMultiplier() : CM.Sim.getSellMultiplier();
const giveBack = noSim ? build.getSellMultiplier() : CM.Sim.getSellMultiplier();
price = Math.floor(price * giveBack);
if (start > 0) {
moni += price;
@@ -101,7 +101,7 @@ CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, noSim) {
return moni;
};
/********
/**
* Section: Functions related to making functions that check against sim data rather than game data */
/**
@@ -113,39 +113,39 @@ CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, noSim) {
* @param {function} funcToBeReplaced Function to be replaced
* @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()
.split("Game.Upgrades[") // Include '[' to not replace Game.UpgradesByPool
.join("CM.Sim.Upgrades[")
.split("Game.Achievements")
.join("CM.Sim.Achievements")
.split("Game.Has")
.join("CM.Sim.Has")
.split("Game.dragonAura]")
.join("CM.Sim.dragonAura]")
.split("Game.dragonAura2]")
.join("CM.Sim.dragonAura2]")
.split("Game.auraMult")
.join("CM.Sim.auraMult")
.split("Game.hasGod")
.join("CM.Sim.hasGod")
.split("M.gods[what]") // Replaces code in the Pantheon minigame
.join("CM.Sim.Objects.Temple.minigame.gods[what]")
.split("M.slot[i]") // Replaces code in the Pantheon minigame
.join("CM.Sim.Objects.Temple.minigame.slot[i]")
.split("Game.effs") // Replaces code in the Pantheon minigame
.join("CM.Sim.effs")
.split("Game.Objects")
.join("CM.Sim.Objects")
.split("Game.GetTieredCpsMult") // Replace in .cps of building objects
.join("CM.Sim.GetTieredCpsMult")
.split('Game.Upgrades[') // Include '[' to not replace Game.UpgradesByPool
.join('CM.Sim.Upgrades[')
.split('Game.Achievements')
.join('CM.Sim.Achievements')
.split('Game.Has')
.join('CM.Sim.Has')
.split('Game.dragonAura]')
.join('CM.Sim.dragonAura]')
.split('Game.dragonAura2]')
.join('CM.Sim.dragonAura2]')
.split('Game.auraMult')
.join('CM.Sim.auraMult')
.split('Game.hasGod')
.join('CM.Sim.hasGod')
.split('M.gods[what]') // Replaces code in the Pantheon minigame
.join('CM.Sim.Objects.Temple.minigame.gods[what]')
.split('M.slot[i]') // Replaces code in the Pantheon minigame
.join('CM.Sim.Objects.Temple.minigame.slot[i]')
.split('Game.effs') // Replaces code in the Pantheon minigame
.join('CM.Sim.effs')
.split('Game.Objects')
.join('CM.Sim.Objects')
.split('Game.GetTieredCpsMult') // Replace in .cps of building objects
.join('CM.Sim.GetTieredCpsMult')
.split('Game.eff') // Replace in .cps of building objects
.join('CM.Sim.eff');
//.split('syn.buildingTie1.amount')
//.join('CM.Sim.Objects[syn.buildingTie1.name].amount')
//.split('syn.buildingTie2.amount')
//.join('CM.Sim.Objects[syn.buildingTie2.name].amount')
}
// .split('syn.buildingTie1.amount')
// .join('CM.Sim.Objects[syn.buildingTie1.name].amount')
// .split('syn.buildingTie2.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
@@ -154,7 +154,7 @@ CM.Sim.ReplaceFunction = function(funcToBeReplaced) {
*
* 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.HasAchiev = new Function(`return ${CM.Sim.ReplaceFunction(Game.HasAchiev)}`)();
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.eff = new Function(`return ${CM.Sim.ReplaceFunction(Game.eff)}`)();
CM.Sim.GetTieredCpsMult = new Function(`return ${CM.Sim.ReplaceFunction(Game.GetTieredCpsMult)}`)();
}
};
/**
* 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
* @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].won === 0) {
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 */
/**
@@ -193,9 +193,9 @@ CM.Sim.Win = function(what) {
* @param {string} buildingName Name of the building
* @returns {Object} you The static object
*/
CM.Sim.InitialBuildingData = function(buildingName) {
let me = Game.Objects[buildingName];
let you = {};
CM.Sim.InitialBuildingData = function (buildingName) {
const me = Game.Objects[buildingName];
const you = {};
you.cps = new Function(`return ${CM.Sim.ReplaceFunction(me.cps)}`)();
// Below is needed for above eval, specifically for the GetTieredCpsMult function
you.baseCps = me.baseCps;
@@ -204,9 +204,9 @@ CM.Sim.InitialBuildingData = function(buildingName) {
you.synergies = me.synergies;
you.fortune = me.fortune;
you.grandma = me.grandma;
you.baseCPS = me.baseCps
you.id = me.id
you.vanilla = me.vanilla
you.baseCPS = me.baseCps;
you.id = me.id;
you.vanilla = me.vanilla;
return you;
};
@@ -216,12 +216,12 @@ CM.Sim.InitialBuildingData = function(buildingName) {
* @param {string} upgradeName Name of the Upgrade
* @returns {Object} you The static object
*/
CM.Sim.InitUpgrade = function(upgradeName) {
let me = Game.Upgrades[upgradeName];
let you = {};
CM.Sim.InitUpgrade = function (upgradeName) {
const me = Game.Upgrades[upgradeName];
const you = {};
// Some upgrades have a function for .power (notably the valentine cookies)
you.power = me.power;
if (typeof(me.power) === 'function') {
if (typeof (me.power) === 'function') {
me.power = new Function(`return ${CM.Sim.ReplaceFunction(me.power)}`)();
}
you.pool = me.pool;
@@ -235,47 +235,46 @@ CM.Sim.InitUpgrade = function(upgradeName) {
* @param {string} achievementName Name of the Achievement
* @returns {Object} you The static object
*/
CM.Sim.InitAchievement = function(achievementName) {
let me = Game.Achievements[achievementName];
let you = {};
CM.Sim.InitAchievement = function (achievementName) {
const me = Game.Achievements[achievementName];
const you = {};
you.name = me.name;
return you;
};
/**
* This function creates static objects for Buildings, Upgrades and Achievements
* It is called by CM.Main.DelayInit()
*/
CM.Sim.InitData = function() {
CM.Sim.InitData = function () {
// Buildings
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);
}
// 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);
}
// 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.CopyData();
};
/********
/**
* 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"
* 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
CM.Sim.UpgradesOwned = Game.UpgradesOwned;
CM.Sim.pledges = Game.pledges;
@@ -284,11 +283,12 @@ CM.Sim.CopyData = function() {
CM.Sim.prestige = Game.prestige;
// Buildings
for (let i of Object.keys(Game.Objects)) {
let me = Game.Objects[i];
for (const i of Object.keys(Game.Objects)) {
const me = Game.Objects[i];
let you = CM.Sim.Objects[i];
if (you === undefined) { // New building!
you = CM.Sim.Objects[i] = CM.Sim.InitialBuildingData(i);
CM.Sim.Objects[i] = CM.Sim.InitialBuildingData(i);
you = CM.Sim.Objects[i];
CM.Disp.CreateBotBarBuildingColumn(i); // Add new building to the bottom bar
}
you.amount = me.amount;
@@ -300,21 +300,23 @@ CM.Sim.CopyData = function() {
}
// Upgrades
for (let i of Object.keys(Game.Upgrades)) {
let me = Game.Upgrades[i];
for (const i of Object.keys(Game.Upgrades)) {
const me = Game.Upgrades[i];
let you = CM.Sim.Upgrades[i];
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;
}
// Achievements
for (let i of Object.keys(Game.Achievements)) {
let me = Game.Achievements[i];
for (const i of Object.keys(Game.Achievements)) {
const me = Game.Achievements[i];
let you = CM.Sim.Achievements[i];
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;
}
@@ -325,7 +327,7 @@ CM.Sim.CopyData = function() {
CM.Sim.dragonAura2 = CM.Cache.dragonAura2;
};
/********
/**
* 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
* @global {number} CM.Sim.cookiesPs The CPS of the current sim data
*/
CM.Sim.CalculateGains = function() {
CM.Sim.CalculateGains = function () {
CM.Sim.cookiesPs = 0;
let mult = 1;
// Include minigame effects
let effs = {};
for (let i of Object.keys(Game.Objects)) {
const effs = {};
for (const i of Object.keys(Game.Objects)) {
if (Game.Objects[i].minigameLoaded && Game.Objects[i].minigame.effs) {
let myEffs = Game.Objects[i].minigame.effs;
for (let ii in myEffs) {
const myEffs = Game.Objects[i].minigame.effs;
for (const ii in myEffs) {
if (effs[ii]) effs[ii] *= myEffs[ii];
else effs[ii] = myEffs[ii];
else effs[ii] = myEffs[ii];
}
}
}
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');
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)) {
let me = Game.cookieUpgrades[i];
for (const i of Object.keys(Game.cookieUpgrades)) {
const me = Game.cookieUpgrades[i];
if (CM.Sim.Has(me.name)) {
// 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.
// 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);
} else mult *= 1 + (me.power * 0.01);
}
@@ -395,8 +397,8 @@ CM.Sim.CalculateGains = function() {
godLvl = CM.Sim.hasGod('ages');
if (godLvl === 1) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 3)) * Math.PI * 2);
else if (godLvl === 2) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 12)) * Math.PI*2);
else if (godLvl === 3) mult *= 1 + 0.15 * Math.sin((CM.Sim.DateAges / 1000 / (60 * 60 * 24)) * Math.PI*2);
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);
godLvl = CM.Sim.hasGod('decadence');
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;
let milkProgress = CM.Sim.AchievementsOwned / 25;
const milkProgress = CM.Sim.AchievementsOwned / 25;
let milkMult = 1;
if (CM.Sim.Has('Santa\'s milk and cookies')) milkMult *= 1.05;
//if (CM.Sim.hasAura('Breath of Milk')) milkMult *= 1.05;
// if (CM.Sim.hasAura('Breath of Milk')) milkMult *= 1.05;
milkMult *= 1 + CM.Sim.auraMult('Breath of Milk') * 0.05;
if (CM.Sim.hasGod) {
let godLvl = CM.Sim.hasGod('mother');
const godLvl = CM.Sim.hasGod('mother');
if (godLvl === 1) milkMult *= 1.1;
else if (godLvl === 2) milkMult *= 1.05;
else if (godLvl === 3) milkMult *= 1.03;
@@ -447,15 +449,15 @@ CM.Sim.CalculateGains = function() {
if (CM.Sim.Has('Kitten angels')) catMult *= (1 + milkProgress * 0.1 * milkMult);
if (CM.Sim.Has('Fortune #103')) catMult *= (1 + milkProgress * 0.05 * milkMult);
for (let i of Object.keys(CM.Sim.Objects)) {
let me = CM.Sim.Objects[i];
for (const i of Object.keys(CM.Sim.Objects)) {
const me = CM.Sim.Objects[i];
let storedCps = me.cps(me);
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 (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;
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;
@@ -477,30 +479,30 @@ CM.Sim.CalculateGains = function() {
let day = Math.floor((CM.Sim.DateCentury - Game.startDate) / 1000 / 10) * 10 / 60 / 60 / 24;
day = Math.min(day, 100);
// 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;
}
mult *= eggMult;
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');
let rawCookiesPs = CM.Sim.cookiesPs * mult;
for (let i of Object.keys(Game.CpsAchievements)) {
const rawCookiesPs = CM.Sim.cookiesPs * mult;
for (const i of Object.keys(Game.CpsAchievements)) {
if (rawCookiesPs >= Game.CpsAchievements[i].threshold) CM.Sim.Win(Game.CpsAchievements[i].name);
}
CM.Sim.cookiesPsRaw = rawCookiesPs;
let n = Game.shimmerTypes.golden.n;
let auraMult = CM.Sim.auraMult('Dragon\'s Fortune');
for (let i = 0; i < n; i++){
const n = Game.shimmerTypes.golden.n;
const auraMult = CM.Sim.auraMult('Dragon\'s Fortune');
for (let i = 0; i < n; i++) {
mult *= 1 + auraMult * 1.23;
}
let name = Game.bakeryName.toLowerCase();
const name = Game.bakeryName.toLowerCase();
if (name === 'orteil') mult *= 0.99;
else if (name === 'ortiel') mult *= 0.98;
@@ -509,8 +511,8 @@ CM.Sim.CalculateGains = function() {
if (CM.Sim.Has('Golden switch [off]')) {
let goldenSwitchMult = 1.5;
if (CM.Sim.Has('Residual luck')) {
let upgrades = Game.goldenCookieUpgrades;
for (let i of Object.keys(upgrades)) {
const upgrades = Game.goldenCookieUpgrades;
for (const i of Object.keys(upgrades)) {
if (CM.Sim.Has(upgrades[i])) goldenSwitchMult += 0.1;
}
}
@@ -522,8 +524,8 @@ CM.Sim.CalculateGains = function() {
mult *= 1 + veilMult;
}
if (CM.Sim.Has('Magic shenanigans')) mult*=1000;
if (CM.Sim.Has('Occult obstruction')) mult*=0;
if (CM.Sim.Has('Magic shenanigans')) mult *= 1000;
if (CM.Sim.Has('Occult obstruction')) mult *= 0;
CM.Sim.cookiesPs = Game.runModHookOnValue('cps', CM.Sim.cookiesPs);
@@ -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()
* It is called at the end of any functions that simulates certain behaviour
*/
CM.Sim.CheckOtherAchiev = function() {
CM.Sim.CheckOtherAchiev = function () {
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.HasAchiev('Elder') && grandmas >= 7) CM.Sim.Win('Elder');
@@ -551,11 +553,11 @@ CM.Sim.CheckOtherAchiev = function() {
let mathematician = 1;
let base10 = 1;
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;
minAmount = Math.min(CM.Sim.Objects[i].amount, minAmount);
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.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');
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 (hasAllHalloCook) CM.Sim.Win('Spooky cookies');
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 (hasAllChristCook) CM.Sim.Win('Let it snow');
if (CM.Sim.Has('Fortune cookies')) {
let list = Game.Tiers.fortune.upgrades;
const list = Game.Tiers.fortune.upgrades;
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 (fortunes >= list.length) CM.Sim.Win('O Fortuna');
@@ -621,14 +623,14 @@ CM.Sim.CheckOtherAchiev = function() {
* This function calculates CPS without the Golden Switch
* It is called by CM.Cache.NoGoldSwitchCPS()
*/
CM.Sim.NoGoldSwitchCPS = function() {
CM.Sim.NoGoldSwitchCPS = function () {
CM.Sim.CopyData();
CM.Sim.Upgrades['Golden switch [off]'].bought = 0;
CM.Sim.CalculateGains();
return CM.Sim.cookiesPs;
};
/********
/**
* Section: Functions related to calculating Bonus Income */
/**
@@ -638,9 +640,9 @@ CM.Sim.NoGoldSwitchCPS = function() {
* @param {number} amount The amount to be bought
* @returns {number} The bonus income of the building
*/
CM.Sim.BuyBuildingsBonusIncome = function(building, amount) {
CM.Sim.BuyBuildingsBonusIncome = function (building, amount) {
CM.Sim.CopyData();
let me = CM.Sim.Objects[building];
const me = CM.Sim.Objects[building];
me.amount += amount;
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 >= 700) CM.Sim.Win('Gotta hand it to you');
if (me.amount >= 800) CM.Sim.Win('The devil\'s workshop');
}
else {
for (let j in Game.Objects[me.name].tieredAchievs) {
if (me.amount >= Game.Tiers[Game.Objects[me.name].tieredAchievs[j].tier].achievUnlock)
} else {
for (const j in Game.Objects[me.name].tieredAchievs) {
if (me.amount >= Game.Tiers[Game.Objects[me.name].tieredAchievs[j].tier].achievUnlock) {
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.CheckOtherAchiev();
if (lastAchievementsOwned != CM.Sim.AchievementsOwned) {
if (lastAchievementsOwned !== CM.Sim.AchievementsOwned) {
CM.Sim.CalculateGains();
}
@@ -682,10 +684,10 @@ CM.Sim.BuyBuildingsBonusIncome = function(building, amount) {
* @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
*/
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')) {
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')) {
CM.Sim.CopyData();
let me = CM.Sim.Upgrades[upgrade];
const me = CM.Sim.Upgrades[upgrade];
me.bought = 1;
if (Game.CountsAsUpgradeOwned(Game.Upgrades[upgrade].pool)) CM.Sim.UpgradesOwned++;
@@ -693,28 +695,25 @@ CM.Sim.BuyUpgradesBonusIncome = function(upgrade) {
CM.Sim.pledges++;
if (CM.Sim.pledges > 0) CM.Sim.Win('Elder nap');
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');
}
else if (upgrade === 'Prism heart biscuits') {
} else if (upgrade === 'Prism heart biscuits') {
CM.Sim.Win('Lovely cookies');
}
else if (upgrade === 'Heavenly key') {
} else if (upgrade === 'Heavenly key') {
CM.Sim.Win('Wholesome');
}
let lastAchievementsOwned = CM.Sim.AchievementsOwned;
const lastAchievementsOwned = CM.Sim.AchievementsOwned;
CM.Sim.CalculateGains();
CM.Sim.CheckOtherAchiev();
if (lastAchievementsOwned != CM.Sim.AchievementsOwned) {
if (lastAchievementsOwned !== CM.Sim.AchievementsOwned) {
CM.Sim.CalculateGains();
}
let diffMouseCPS = CM.Sim.mouseCps() - Game.computedMouseCps;
const diffMouseCPS = CM.Sim.mouseCps() - Game.computedMouseCps;
if (diffMouseCPS) {
return [CM.Sim.cookiesPs - Game.cookiesPs, diffMouseCPS];
}
@@ -724,13 +723,12 @@ CM.Sim.BuyUpgradesBonusIncome = function(upgrade) {
}
};
/**
* 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)
* @returns {number} out The clicking power
*/
CM.Sim.mouseCps = function() {
CM.Sim.mouseCps = function () {
let add = 0;
if (CM.Sim.Has('Thousand fingers')) add += 0.1;
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('Octillion fingers')) add *= 20;
if (CM.Sim.Has('Nonillion fingers')) add *= 20;
let num=0;
for (let i of Object.keys(CM.Sim.Objects)) {num += CM.Sim.Objects[i].amount;}
let num = 0;
for (const i of Object.keys(CM.Sim.Objects)) { num += CM.Sim.Objects[i].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()
if (CM.Sim.Has('Plastic mouse')) add += CM.Sim.cookiesPs * 0.01;
@@ -764,7 +762,7 @@ CM.Sim.mouseCps = function() {
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('Cookie egg')) mult *= 1.1;
if (CM.Sim.Has('Halo gloves')) mult *= 1.1;
@@ -777,18 +775,18 @@ CM.Sim.mouseCps = function() {
mult *= CM.Sim.eff('click');
if (CM.Sim.Objects.Temple.minigameLoaded) {
if (CM.Sim.hasGod) {
let godLvl = CM.Sim.hasGod('labor');
const godLvl = CM.Sim.hasGod('labor');
if (godLvl === 1) mult *= 1.15;
else if (godLvl === 2) mult *= 1.1;
else if (godLvl === 3) mult *= 1.05;
}
}
for (let i of Object.keys(Game.buffs)) {
if (typeof Game.buffs[i].multClick != 'undefined') mult *= Game.buffs[i].multClick;
for (const i of Object.keys(Game.buffs)) {
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;
// No need to make this function a CM function
@@ -801,8 +799,7 @@ CM.Sim.mouseCps = function() {
return out;
};
/********
/**
* 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
* @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();
// 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;
else CM.Sim.dragonAura = aura;
// Sell highest building but only if aura is different
let price = 0;
if (CM.Sim.dragonAura != CM.Cache.dragonAura || CM.Sim.dragonAura2 != CM.Cache.dragonAura2) {
for (let i = Game.ObjectsById.length; i > -1, --i;) {
if (CM.Sim.dragonAura !== CM.Cache.dragonAura || CM.Sim.dragonAura2 !== CM.Cache.dragonAura2) {
for (let i = Game.ObjectsById.length; i > -1; --i) {
if (Game.ObjectsById[i].amount > 0) {
let highestBuilding = CM.Sim.Objects[Game.ObjectsById[i].name].name;
CM.Sim.Objects[highestBuilding].amount -=1;
const highestBuilding = CM.Sim.Objects[Game.ObjectsById[i].name].name;
CM.Sim.Objects[highestBuilding].amount -= 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 = Math.ceil(price);
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.CheckOtherAchiev();
if (lastAchievementsOwned != CM.Sim.AchievementsOwned) {
if (lastAchievementsOwned !== CM.Sim.AchievementsOwned) {
CM.Sim.CalculateGains();
}
return [CM.Sim.cookiesPs - Game.cookiesPs, price];
};
/********
/**
* 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
* @returns {number} ResetCPS The CPS difference after reset
*/
CM.Sim.ResetBonus = function(newHeavenlyChips) {
CM.Sim.ResetBonus = function (newHeavenlyChips) {
// Calculate CPS with all Heavenly upgrades
let curCPS = Game.cookiesPs;
@@ -900,17 +897,17 @@ CM.Sim.ResetBonus = function(newHeavenlyChips) {
CM.Sim.prestige = newHeavenlyChips;
let lastAchievementsOwned = CM.Sim.AchievementsOwned;
const lastAchievementsOwned = CM.Sim.AchievementsOwned;
CM.Sim.CalculateGains();
CM.Sim.CheckOtherAchiev();
if (lastAchievementsOwned != CM.Sim.AchievementsOwned) {
if (lastAchievementsOwned !== CM.Sim.AchievementsOwned) {
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
CM.Sim.prestige = Game.prestige;
@@ -918,7 +915,7 @@ CM.Sim.ResetBonus = function(newHeavenlyChips) {
return ResetCPS;
};
/********
/**
* Section: Functions related to selling builings before buying the chocolate egg */
/**
@@ -926,7 +923,7 @@ CM.Sim.ResetBonus = function(newHeavenlyChips) {
* It is called by CM.Cache.CacheSellForChoEgg()
* @returns {number} sellTotal The maximum cookies to be earned
*/
CM.Sim.SellBuildingsForChoEgg = function() {
CM.Sim.SellBuildingsForChoEgg = function () {
let sellTotal = 0;
CM.Sim.CopyData();
@@ -945,7 +942,7 @@ CM.Sim.SellBuildingsForChoEgg = function() {
// Sacrifice highest buildings for the aura switch
for (let i = 0; i < buildingsToSacrifice; ++i) {
let highestBuilding = 0;
for (let j in CM.Sim.Objects) {
for (const j in CM.Sim.Objects) {
if (CM.Sim.Objects[j].amount > 0) {
highestBuilding = CM.Sim.Objects[j];
}
@@ -955,8 +952,8 @@ CM.Sim.SellBuildingsForChoEgg = function() {
}
// Get money made by selling all remaining buildings
for (let i of Object.keys(CM.Sim.Objects)) {
let me = CM.Sim.Objects[i];
for (const i of Object.keys(CM.Sim.Objects)) {
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);
}