Added prettier to master (#662)

* Bump dev to 2.031.6

* Added prettier (#661)

* Added prettier

* Added prettier

* Added prettier
This commit is contained in:
Daniël van Noord
2021-03-14 19:08:36 +01:00
committed by GitHub
parent 5dda8cac55
commit 3e07541fd5
131 changed files with 7141 additions and 4892 deletions

View File

@@ -1,40 +1,35 @@
module.exports = { module.exports = {
env: { env: {
browser: true, browser: true,
es2021: true, es2021: true,
}, },
globals: { globals: {
Game: 'writable', Game: 'writable',
l: 'readonly', l: 'readonly',
b64_to_utf8: 'readonly', b64_to_utf8: 'readonly',
utf8_to_b64: 'readonly', utf8_to_b64: 'readonly',
realAudio: 'readonly', realAudio: 'readonly',
BeautifyAll: 'readonly', BeautifyAll: 'readonly',
CM: 'writable', CM: 'writable',
unsafeWindow: 'readonly', unsafeWindow: 'readonly',
}, },
extends: 'airbnb-base', extends: ['airbnb-base', 'plugin:prettier/recommended'],
parserOptions: { parserOptions: {
ecmaVersion: 12, ecmaVersion: 12,
}, },
rules: { rules: {
indent: ['error', 'tab'], 'import/no-named-default': 'off',
'import/no-named-default': 'off', 'import/no-mutable-exports': 'off',
'import/no-mutable-exports': 'off', 'no-param-reassign': 'off',
'no-tabs': 'off', 'no-plusplus': 'off',
'max-len': 'off', 'no-new-func': 'off',
'no-param-reassign': 'off', 'no-restricted-syntax': 'off',
'no-plusplus': 'off', 'prefer-destructuring': 'off',
'no-new-func': 'off', 'func-names': 'off',
'no-restricted-syntax': 'off', 'no-console': 'off',
'no-mixed-operators': 'off', 'no-nested-ternary': 'off',
'prefer-destructuring': 'off', 'no-new': 'off',
'func-names': 'off', 'no-alert': 'off',
'no-console': 'off', 'no-restricted-globals': 'off',
'no-nested-ternary': 'off', },
'prefer-arrow-callback': 'off',
'no-new': 'off',
'no-alert': 'off',
'no-restricted-globals': 'off',
},
}; };

5
.prettierrc.json Normal file
View File

@@ -0,0 +1,5 @@
{
"singleQuote": true,
"trailingComma": "all",
"printWidth": 80
}

File diff suppressed because one or more lines are too long

107
package-lock.json generated
View File

@@ -1,12 +1,12 @@
{ {
"name": "cookiemonster-mod", "name": "cookiemonster-mod",
"version": "2.031.5", "version": "2.031.6",
"lockfileVersion": 2, "lockfileVersion": 2,
"requires": true, "requires": true,
"packages": { "packages": {
"": { "": {
"name": "cookiemonster-mod", "name": "cookiemonster-mod",
"version": "2.031.5", "version": "2.031.6",
"license": "MIT", "license": "MIT",
"dependencies": { "dependencies": {
"@eastdesire/jscolor": "^2.4.5" "@eastdesire/jscolor": "^2.4.5"
@@ -14,8 +14,11 @@
"devDependencies": { "devDependencies": {
"eslint": "^7.19.0", "eslint": "^7.19.0",
"eslint-config-airbnb-base": "^14.2.1", "eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-import": "^2.22.1", "eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.3.1",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"prettier": "2.2.1",
"webpack": "^5.24.4", "webpack": "^5.24.4",
"webpack-cli": "^4.5.0" "webpack-cli": "^4.5.0"
} }
@@ -857,6 +860,18 @@
"eslint-plugin-import": "^2.22.1" "eslint-plugin-import": "^2.22.1"
} }
}, },
"node_modules/eslint-config-prettier": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.1.0.tgz",
"integrity": "sha512-oKMhGv3ihGbCIimCAjqkdzx2Q+jthoqnXSP+d86M9tptwugycmTFdVR4IpLgq2c4SHifbwO90z2fQ8/Aio73yw==",
"dev": true,
"bin": {
"eslint-config-prettier": "bin/cli.js"
},
"peerDependencies": {
"eslint": ">=7.0.0"
}
},
"node_modules/eslint-import-resolver-node": { "node_modules/eslint-import-resolver-node": {
"version": "0.3.4", "version": "0.3.4",
"dev": true, "dev": true,
@@ -954,6 +969,27 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/eslint-plugin-prettier": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.3.1.tgz",
"integrity": "sha512-Rq3jkcFY8RYeQLgk2cCwuc0P7SEFwDravPhsJZOQ5N4YI4DSg50NyqJ/9gdZHzQlHf8MvafSesbNJCcP/FF6pQ==",
"dev": true,
"dependencies": {
"prettier-linter-helpers": "^1.0.0"
},
"engines": {
"node": ">=6.0.0"
},
"peerDependencies": {
"eslint": ">=5.0.0",
"prettier": ">=1.13.0"
},
"peerDependenciesMeta": {
"eslint-config-prettier": {
"optional": true
}
}
},
"node_modules/eslint-scope": { "node_modules/eslint-scope": {
"version": "5.1.1", "version": "5.1.1",
"dev": true, "dev": true,
@@ -1118,6 +1154,12 @@
"dev": true, "dev": true,
"license": "MIT" "license": "MIT"
}, },
"node_modules/fast-diff": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz",
"integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==",
"dev": true
},
"node_modules/fast-json-stable-stringify": { "node_modules/fast-json-stable-stringify": {
"version": "2.1.0", "version": "2.1.0",
"dev": true, "dev": true,
@@ -2271,6 +2313,30 @@
"node": ">= 0.8.0" "node": ">= 0.8.0"
} }
}, },
"node_modules/prettier": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.2.1.tgz",
"integrity": "sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==",
"dev": true,
"bin": {
"prettier": "bin-prettier.js"
},
"engines": {
"node": ">=10.13.0"
}
},
"node_modules/prettier-linter-helpers": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz",
"integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==",
"dev": true,
"dependencies": {
"fast-diff": "^1.1.2"
},
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/progress": { "node_modules/progress": {
"version": "2.0.3", "version": "2.0.3",
"dev": true, "dev": true,
@@ -3639,6 +3705,13 @@
"object.entries": "^1.1.2" "object.entries": "^1.1.2"
} }
}, },
"eslint-config-prettier": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.1.0.tgz",
"integrity": "sha512-oKMhGv3ihGbCIimCAjqkdzx2Q+jthoqnXSP+d86M9tptwugycmTFdVR4IpLgq2c4SHifbwO90z2fQ8/Aio73yw==",
"dev": true,
"requires": {}
},
"eslint-import-resolver-node": { "eslint-import-resolver-node": {
"version": "0.3.4", "version": "0.3.4",
"dev": true, "dev": true,
@@ -3721,6 +3794,15 @@
} }
} }
}, },
"eslint-plugin-prettier": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.3.1.tgz",
"integrity": "sha512-Rq3jkcFY8RYeQLgk2cCwuc0P7SEFwDravPhsJZOQ5N4YI4DSg50NyqJ/9gdZHzQlHf8MvafSesbNJCcP/FF6pQ==",
"dev": true,
"requires": {
"prettier-linter-helpers": "^1.0.0"
}
},
"eslint-scope": { "eslint-scope": {
"version": "5.1.1", "version": "5.1.1",
"dev": true, "dev": true,
@@ -3822,6 +3904,12 @@
"version": "3.1.3", "version": "3.1.3",
"dev": true "dev": true
}, },
"fast-diff": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz",
"integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==",
"dev": true
},
"fast-json-stable-stringify": { "fast-json-stable-stringify": {
"version": "2.1.0", "version": "2.1.0",
"dev": true "dev": true
@@ -4538,6 +4626,21 @@
"version": "1.2.1", "version": "1.2.1",
"dev": true "dev": true
}, },
"prettier": {
"version": "2.2.1",
"resolved": "https://registry.npmjs.org/prettier/-/prettier-2.2.1.tgz",
"integrity": "sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==",
"dev": true
},
"prettier-linter-helpers": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz",
"integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==",
"dev": true,
"requires": {
"fast-diff": "^1.1.2"
}
},
"progress": { "progress": {
"version": "2.0.3", "version": "2.0.3",
"dev": true "dev": true

View File

@@ -45,8 +45,11 @@
"devDependencies": { "devDependencies": {
"eslint": "^7.19.0", "eslint": "^7.19.0",
"eslint-config-airbnb-base": "^14.2.1", "eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^8.1.0",
"eslint-plugin-import": "^2.22.1", "eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.3.1",
"npm-run-all": "^4.1.5", "npm-run-all": "^4.1.5",
"prettier": "2.2.1",
"webpack": "^5.24.4", "webpack": "^5.24.4",
"webpack-cli": "^4.5.0" "webpack-cli": "^4.5.0"
}, },

View File

@@ -1,7 +1,11 @@
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
import { ClickTimes, CookieTimes } from '../../Disp/VariablesAndData'; import { ClickTimes, CookieTimes } from '../../Disp/VariablesAndData';
import { import {
ChoEggDiff, ClicksDiff, CookiesDiff, WrinkDiff, WrinkFattestDiff, ChoEggDiff,
ClicksDiff,
CookiesDiff,
WrinkDiff,
WrinkFattestDiff,
} from '../VariablesAndData'; } from '../VariablesAndData';
/** /**
@@ -13,34 +17,38 @@ import {
* @method calcAverage(timePeriod) Returns the average over the specified timeperiod * @method calcAverage(timePeriod) Returns the average over the specified timeperiod
*/ */
export class CMAvgQueue { export class CMAvgQueue {
constructor(maxLength) { constructor(maxLength) {
this.maxLength = maxLength; this.maxLength = maxLength;
this.queue = []; this.queue = [];
} }
addLatest(newValue) { addLatest(newValue) {
if (this.queue.push(newValue) > this.maxLength) { if (this.queue.push(newValue) > this.maxLength) {
this.queue.shift(); this.queue.shift();
} }
} }
/** /**
* This functions returns the average of the values in the queue * This functions returns the average of the values in the queue
* @param {number} timePeriod The period in seconds to computer average over * @param {number} timePeriod The period in seconds to computer average over
* @returns {number} ret The average * @returns {number} ret The average
*/ */
calcAverage(timePeriod) { calcAverage(timePeriod) {
if (timePeriod > this.maxLength) timePeriod = this.maxLength; if (timePeriod > this.maxLength) timePeriod = this.maxLength;
if (timePeriod > this.queue.length) timePeriod = this.queue.length; if (timePeriod > this.queue.length) timePeriod = this.queue.length;
let ret = 0; let ret = 0;
for (let i = this.queue.length - 1; i >= 0 && i > this.queue.length - 1 - timePeriod; i--) { for (
ret += this.queue[i]; let i = this.queue.length - 1;
} i >= 0 && i > this.queue.length - 1 - timePeriod;
if (ret === 0) { i--
return 0; ) {
} ret += this.queue[i];
return ret / timePeriod; }
} if (ret === 0) {
return 0;
}
return ret / timePeriod;
}
} }
/** /**
@@ -48,9 +56,9 @@ export class CMAvgQueue {
* Called by CM.Cache.InitCache() * Called by CM.Cache.InitCache()
*/ */
export function InitCookiesDiff() { export function InitCookiesDiff() {
CookiesDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]); CookiesDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]);
WrinkDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]); WrinkDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]);
WrinkFattestDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]); WrinkFattestDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]);
ChoEggDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]); ChoEggDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]);
ClicksDiff = new CMAvgQueue(ClickTimes[ClickTimes.length - 1]); ClicksDiff = new CMAvgQueue(ClickTimes[ClickTimes.length - 1]);
} }

View File

@@ -3,7 +3,28 @@
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import { ClickTimes, CookieTimes } from '../../Disp/VariablesAndData'; import { ClickTimes, CookieTimes } from '../../Disp/VariablesAndData';
import { import {
CacheAverageClicks, CacheAverageCPS, CacheAverageGainBank, CacheAverageGainChoEgg, CacheAverageGainWrink, CacheAverageGainWrinkFattest, CacheAvgCPSWithChoEgg, CacheLastChoEgg, CacheLastClicks, CacheLastCookies, CacheLastCPSCheck, CacheLastWrinkCookies, CacheLastWrinkFattestCookies, CacheRealCookiesEarned, CacheSellForChoEgg, CacheWrinklersFattest, CacheWrinklersTotal, ChoEggDiff, ClicksDiff, CookiesDiff, WrinkDiff, WrinkFattestDiff, CacheAverageClicks,
CacheAverageCPS,
CacheAverageGainBank,
CacheAverageGainChoEgg,
CacheAverageGainWrink,
CacheAverageGainWrinkFattest,
CacheAvgCPSWithChoEgg,
CacheLastChoEgg,
CacheLastClicks,
CacheLastCookies,
CacheLastCPSCheck,
CacheLastWrinkCookies,
CacheLastWrinkFattestCookies,
CacheRealCookiesEarned,
CacheSellForChoEgg,
CacheWrinklersFattest,
CacheWrinklersTotal,
ChoEggDiff,
ClicksDiff,
CookiesDiff,
WrinkDiff,
WrinkFattestDiff,
} from '../VariablesAndData'; } from '../VariablesAndData';
/** /**
@@ -15,53 +36,63 @@ import {
* @global {number} CM.Cache.AvgCPSChoEgg Average cookies from combination of normal CPS and average Chocolate Cookie CPS * @global {number} CM.Cache.AvgCPSChoEgg Average cookies from combination of normal CPS and average Chocolate Cookie CPS
*/ */
export default function CacheAvgCPS() { export default function CacheAvgCPS() {
const currDate = Math.floor(Date.now() / 1000); const currDate = Math.floor(Date.now() / 1000);
// Only calculate every new second // Only calculate every new second
if ((Game.T / Game.fps) % 1 === 0) { if ((Game.T / Game.fps) % 1 === 0) {
let choEggTotal = Game.cookies + CacheSellForChoEgg; let choEggTotal = Game.cookies + CacheSellForChoEgg;
if (Game.cpsSucked > 0) choEggTotal += CacheWrinklersTotal; if (Game.cpsSucked > 0) choEggTotal += CacheWrinklersTotal;
CacheRealCookiesEarned = Math.max(Game.cookiesEarned, choEggTotal); CacheRealCookiesEarned = Math.max(Game.cookiesEarned, choEggTotal);
choEggTotal *= 0.05; choEggTotal *= 0.05;
// Add recent gains to AvgQueue's // Add recent gains to AvgQueue's
const timeDiff = currDate - CacheLastCPSCheck; const timeDiff = currDate - CacheLastCPSCheck;
const bankDiffAvg = Math.max(0, (Game.cookies - CacheLastCookies)) / timeDiff; const bankDiffAvg = Math.max(0, Game.cookies - CacheLastCookies) / timeDiff;
const wrinkDiffAvg = Math.max(0, (CacheWrinklersTotal - CacheLastWrinkCookies)) / timeDiff; const wrinkDiffAvg =
const wrinkFattestDiffAvg = Math.max(0, (CacheWrinklersFattest[0] - CacheLastWrinkFattestCookies)) / timeDiff; Math.max(0, CacheWrinklersTotal - CacheLastWrinkCookies) / timeDiff;
const choEggDiffAvg = Math.max(0, (choEggTotal - CacheLastChoEgg)) / timeDiff; const wrinkFattestDiffAvg =
const clicksDiffAvg = (Game.cookieClicks - CacheLastClicks) / timeDiff; Math.max(0, CacheWrinklersFattest[0] - CacheLastWrinkFattestCookies) /
for (let i = 0; i < timeDiff; i++) { timeDiff;
CookiesDiff.addLatest(bankDiffAvg); const choEggDiffAvg = Math.max(0, choEggTotal - CacheLastChoEgg) / timeDiff;
WrinkDiff.addLatest(wrinkDiffAvg); const clicksDiffAvg = (Game.cookieClicks - CacheLastClicks) / timeDiff;
WrinkFattestDiff.addLatest(wrinkFattestDiffAvg); for (let i = 0; i < timeDiff; i++) {
ChoEggDiff.addLatest(choEggDiffAvg); CookiesDiff.addLatest(bankDiffAvg);
ClicksDiff.addLatest(clicksDiffAvg); WrinkDiff.addLatest(wrinkDiffAvg);
} WrinkFattestDiff.addLatest(wrinkFattestDiffAvg);
ChoEggDiff.addLatest(choEggDiffAvg);
ClicksDiff.addLatest(clicksDiffAvg);
}
// Store current data for next loop // Store current data for next loop
CacheLastCPSCheck = currDate; CacheLastCPSCheck = currDate;
CacheLastCookies = Game.cookies; CacheLastCookies = Game.cookies;
CacheLastWrinkCookies = CacheWrinklersTotal; CacheLastWrinkCookies = CacheWrinklersTotal;
CacheLastWrinkFattestCookies = CacheWrinklersFattest[0]; CacheLastWrinkFattestCookies = CacheWrinklersFattest[0];
CacheLastChoEgg = choEggTotal; CacheLastChoEgg = choEggTotal;
CacheLastClicks = Game.cookieClicks; CacheLastClicks = Game.cookieClicks;
// Get average gain over period of cpsLength seconds // Get average gain over period of cpsLength seconds
const cpsLength = CookieTimes[CMOptions.AvgCPSHist]; const cpsLength = CookieTimes[CMOptions.AvgCPSHist];
CacheAverageGainBank = CookiesDiff.calcAverage(cpsLength); CacheAverageGainBank = CookiesDiff.calcAverage(cpsLength);
CacheAverageGainWrink = WrinkDiff.calcAverage(cpsLength); CacheAverageGainWrink = WrinkDiff.calcAverage(cpsLength);
CacheAverageGainWrinkFattest = WrinkFattestDiff.calcAverage(cpsLength); CacheAverageGainWrinkFattest = WrinkFattestDiff.calcAverage(cpsLength);
CacheAverageGainChoEgg = ChoEggDiff.calcAverage(cpsLength); CacheAverageGainChoEgg = ChoEggDiff.calcAverage(cpsLength);
CacheAverageCPS = CacheAverageGainBank; CacheAverageCPS = CacheAverageGainBank;
if (CMOptions.CalcWrink === 1) CacheAverageCPS += CacheAverageGainWrink; if (CMOptions.CalcWrink === 1) CacheAverageCPS += CacheAverageGainWrink;
if (CMOptions.CalcWrink === 2) CacheAverageCPS += CacheAverageGainWrinkFattest; if (CMOptions.CalcWrink === 2)
CacheAverageCPS += CacheAverageGainWrinkFattest;
const choEgg = (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg')); const choEgg =
Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg');
if (choEgg || CMOptions.CalcWrink === 0) { if (choEgg || CMOptions.CalcWrink === 0) {
CacheAvgCPSWithChoEgg = CacheAverageGainBank + CacheAverageGainWrink + (choEgg ? CacheAverageGainChoEgg : 0); CacheAvgCPSWithChoEgg =
} else CacheAvgCPSWithChoEgg = CacheAverageCPS; CacheAverageGainBank +
CacheAverageGainWrink +
(choEgg ? CacheAverageGainChoEgg : 0);
} else CacheAvgCPSWithChoEgg = CacheAverageCPS;
CacheAverageClicks = ClicksDiff.calcAverage(ClickTimes[CMOptions.AvgClicksHist]); CacheAverageClicks = ClicksDiff.calcAverage(
} ClickTimes[CMOptions.AvgClicksHist],
);
}
} }

View File

@@ -1,6 +1,9 @@
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
import { SimObjects } from '../../Sim/VariablesAndData'; import { SimObjects } from '../../Sim/VariablesAndData';
import { CacheCurrWrinklerCount, CacheCurrWrinklerCPSMult } from '../VariablesAndData'; import {
CacheCurrWrinklerCount,
CacheCurrWrinklerCPSMult,
} from '../VariablesAndData';
/** /**
* This functions caches the current Wrinkler CPS multiplier * This functions caches the current Wrinkler CPS multiplier
@@ -8,18 +11,23 @@ import { CacheCurrWrinklerCount, CacheCurrWrinklerCPSMult } from '../VariablesAn
* @global {number} CM.Cache.CurrWrinklerCPSMult Current multiplier of CPS because of wrinklers (excluding their negative sucking effect) * @global {number} CM.Cache.CurrWrinklerCPSMult Current multiplier of CPS because of wrinklers (excluding their negative sucking effect)
*/ */
export default function CacheCurrWrinklerCPS() { export default function CacheCurrWrinklerCPS() {
CacheCurrWrinklerCPSMult = 0; CacheCurrWrinklerCPSMult = 0;
let count = 0; let count = 0;
for (const i in Game.wrinklers) { for (const i in Game.wrinklers) {
if (Game.wrinklers[i].phase === 2) count++; if (Game.wrinklers[i].phase === 2) count++;
} }
let godMult = 1; let godMult = 1;
if (SimObjects.Temple.minigameLoaded) { if (SimObjects.Temple.minigameLoaded) {
const godLvl = Game.hasGod('scorn'); const godLvl = Game.hasGod('scorn');
if (godLvl === 1) godMult *= 1.15; if (godLvl === 1) godMult *= 1.15;
else if (godLvl === 2) godMult *= 1.1; else if (godLvl === 2) godMult *= 1.1;
else if (godLvl === 3) godMult *= 1.05; else if (godLvl === 3) godMult *= 1.05;
} }
CacheCurrWrinklerCount = count; CacheCurrWrinklerCount = count;
CacheCurrWrinklerCPSMult = count * (count * 0.05 * 1.1) * (Game.Has('Sacrilegious corruption') * 0.05 + 1) * (Game.Has('Wrinklerspawn') * 0.05 + 1) * godMult; CacheCurrWrinklerCPSMult =
count *
(count * 0.05 * 1.1) *
(Game.Has('Sacrilegious corruption') * 0.05 + 1) *
(Game.Has('Wrinklerspawn') * 0.05 + 1) *
godMult;
} }

View File

@@ -3,9 +3,10 @@
* @returns {number} mult The multiplier * @returns {number} mult The multiplier
*/ */
export default function GetCPSBuffMult() { export default function GetCPSBuffMult() {
let mult = 1; let mult = 1;
for (const i of Object.keys(Game.buffs)) { for (const i of Object.keys(Game.buffs)) {
if (typeof Game.buffs[i].multCpS !== 'undefined') mult *= Game.buffs[i].multCpS; if (typeof Game.buffs[i].multCpS !== 'undefined')
} mult *= Game.buffs[i].multCpS;
return mult; }
return mult;
} }

View File

@@ -8,7 +8,7 @@ import { CacheNoGoldSwitchCookiesPS } from '../VariablesAndData';
* It is called at the end of any functions that simulates certain behaviour * It is called at the end of any functions that simulates certain behaviour
*/ */
export default function CacheNoGoldSwitchCPS() { export default function CacheNoGoldSwitchCPS() {
if (Game.Has('Golden switch [off]')) { if (Game.Has('Golden switch [off]')) {
CacheNoGoldSwitchCookiesPS = CalcNoGoldSwitchCPS(); CacheNoGoldSwitchCookiesPS = CalcNoGoldSwitchCPS();
} else CacheNoGoldSwitchCookiesPS = Game.cookiesPs; } else CacheNoGoldSwitchCookiesPS = Game.cookiesPs;
} }

View File

@@ -8,18 +8,18 @@ import { CacheSellForChoEgg } from '../VariablesAndData';
* @global {number} CM.Cache.SellForChoEgg Total cookies to be gained from selling Chocolate egg * @global {number} CM.Cache.SellForChoEgg Total cookies to be gained from selling Chocolate egg
*/ */
export default function CacheSellAllForChoEgg() { export default function CacheSellAllForChoEgg() {
let sellTotal = 0; let sellTotal = 0;
// Compute cookies earned by selling stock market goods // Compute cookies earned by selling stock market goods
if (Game.Objects.Bank.minigameLoaded) { if (Game.Objects.Bank.minigameLoaded) {
const marketGoods = Game.Objects.Bank.minigame.goods; const marketGoods = Game.Objects.Bank.minigame.goods;
let goodsVal = 0; let goodsVal = 0;
for (const i of Object.keys(marketGoods)) { for (const i of Object.keys(marketGoods)) {
const marketGood = marketGoods[i]; const marketGood = marketGoods[i];
goodsVal += marketGood.stock * marketGood.val; goodsVal += marketGood.stock * marketGood.val;
} }
sellTotal += goodsVal * Game.cookiesPsRawHighest; sellTotal += goodsVal * Game.cookiesPsRawHighest;
} }
// Compute cookies earned by selling all buildings with optimal auras (ES + RB) // Compute cookies earned by selling all buildings with optimal auras (ES + RB)
sellTotal += SellBuildingsForChoEgg(); sellTotal += SellBuildingsForChoEgg();
CacheSellForChoEgg = sellTotal; CacheSellForChoEgg = sellTotal;
} }

View File

@@ -3,12 +3,18 @@ import { CMAvgQueue, InitCookiesDiff } from './CPS/AverageQueue';
import CacheAvgCPS from './CPS/CPS'; import CacheAvgCPS from './CPS/CPS';
import CacheDragonAuras from './Dragon/CacheDragonAuras'; import CacheDragonAuras from './Dragon/CacheDragonAuras';
import CachePP from './PP/PP'; import CachePP from './PP/PP';
import { CacheBuildingsPrices, CacheIncome } from './PriceAndIncome/PriceAndIncome'; import {
CacheBuildingsPrices,
CacheIncome,
} from './PriceAndIncome/PriceAndIncome';
import { CacheChain } from './Stats/ChainCookies'; import { CacheChain } from './Stats/ChainCookies';
import CacheHeavenlyChipsPS from './Stats/HeavenlyChips'; import CacheHeavenlyChipsPS from './Stats/HeavenlyChips';
import CacheAllMissingUpgrades from './Stats/MissingUpgrades'; import CacheAllMissingUpgrades from './Stats/MissingUpgrades';
import CacheSeasonSpec from './Stats/Reindeer'; import CacheSeasonSpec from './Stats/Reindeer';
import { CacheGoldenAndWrathCookiesMults, CacheStatsCookies } from './Stats/Stats'; import {
CacheGoldenAndWrathCookiesMults,
CacheStatsCookies,
} from './Stats/Stats';
import { HeavenlyChipsDiff } from './VariablesAndData'; import { HeavenlyChipsDiff } from './VariablesAndData';
import CacheWrinklers from './Wrinklers/Wrinklers'; import CacheWrinklers from './Wrinklers/Wrinklers';
@@ -16,18 +22,18 @@ import CacheWrinklers from './Wrinklers/Wrinklers';
* This functions runs all cache-functions to generate all "full" cache * This functions runs all cache-functions to generate all "full" cache
*/ */
export default function InitCache() { export default function InitCache() {
CacheDragonAuras(); CacheDragonAuras();
CacheWrinklers(); CacheWrinklers();
CacheStatsCookies(); CacheStatsCookies();
CacheGoldenAndWrathCookiesMults(); CacheGoldenAndWrathCookiesMults();
CacheChain(); CacheChain();
CacheAllMissingUpgrades(); CacheAllMissingUpgrades();
CacheSeasonSpec(); CacheSeasonSpec();
InitCookiesDiff(); InitCookiesDiff();
HeavenlyChipsDiff = new CMAvgQueue(5); // Used by CM.Cache.CacheHeavenlyChipsPS() HeavenlyChipsDiff = new CMAvgQueue(5); // Used by CM.Cache.CacheHeavenlyChipsPS()
CacheHeavenlyChipsPS(); CacheHeavenlyChipsPS();
CacheAvgCPS(); CacheAvgCPS();
CacheIncome(); CacheIncome();
CacheBuildingsPrices(); CacheBuildingsPrices();
CachePP(); CachePP();
} }

View File

@@ -13,14 +13,19 @@ import CacheWrinklers from './Wrinklers/Wrinklers';
* @global {string} CM.Cache.TimeTillNextPrestige Time requried till next prestige level * @global {string} CM.Cache.TimeTillNextPrestige Time requried till next prestige level
*/ */
export default function LoopCache() { export default function LoopCache() {
// Update Wrinkler Bank // Update Wrinkler Bank
CacheWrinklers(); CacheWrinklers();
CachePP(); CachePP();
CacheCurrWrinklerCPS(); CacheCurrWrinklerCPS();
CacheAvgCPS(); CacheAvgCPS();
CacheHeavenlyChipsPS(); CacheHeavenlyChipsPS();
const cookiesToNext = Game.HowManyCookiesReset(Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)) + 1) - (Game.cookiesEarned + Game.cookiesReset); const cookiesToNext =
CacheTimeTillNextPrestige = FormatTime(cookiesToNext / GetCPS()); Game.HowManyCookiesReset(
Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)) +
1,
) -
(Game.cookiesEarned + Game.cookiesReset);
CacheTimeTillNextPrestige = FormatTime(cookiesToNext / GetCPS());
} }

View File

@@ -5,6 +5,6 @@ import { CacheDragonAura, CacheDragonAura2 } from '../VariablesAndData';
* This functions caches the currently selected Dragon Auras * This functions caches the currently selected Dragon Auras
*/ */
export default function CacheDragonAuras() { export default function CacheDragonAuras() {
CacheDragonAura = Game.dragonAura; CacheDragonAura = Game.dragonAura;
CacheDragonAura2 = Game.dragonAura2; CacheDragonAura2 = Game.dragonAura2;
} }

View File

@@ -5,54 +5,76 @@ import { Beautify } from '../../Disp/BeautifyAndFormatting/BeautifyFormatting';
import CopyData from '../../Sim/SimulationData/CopyData'; import CopyData from '../../Sim/SimulationData/CopyData';
import { SimDoSims, SimObjects } from '../../Sim/VariablesAndData'; import { SimDoSims, SimObjects } from '../../Sim/VariablesAndData';
import { import {
CacheCostDragonUpgrade, CacheDragonAura, CacheDragonAura2, CacheLastDragonLevel, CacheCostDragonUpgrade,
CacheDragonAura,
CacheDragonAura2,
CacheLastDragonLevel,
} from '../VariablesAndData'; } from '../VariablesAndData';
/** /**
* This functions caches the current cost of upgrading the dragon level so it can be displayed in the tooltip * This functions caches the current cost of upgrading the dragon level so it can be displayed in the tooltip
*/ */
export default function CacheDragonCost() { export default function CacheDragonCost() {
if (CacheLastDragonLevel !== Game.dragonLevel || SimDoSims) { if (CacheLastDragonLevel !== Game.dragonLevel || SimDoSims) {
if (Game.dragonLevel < 25 && Game.dragonLevels[Game.dragonLevel].buy.toString().includes('sacrifice')) { if (
let target = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/Objects\[(.*)\]/)[1]; Game.dragonLevel < 25 &&
const amount = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/sacrifice\((.*?)\)/)[1]; Game.dragonLevels[Game.dragonLevel].buy.toString().includes('sacrifice')
if (target !== 'i') { ) {
target = target.replaceAll("'", ''); let target = Game.dragonLevels[Game.dragonLevel].buy
if (Game.Objects[target].amount < amount) { .toString()
CacheCostDragonUpgrade = 'Not enough buildings to sell'; .match(/Objects\[(.*)\]/)[1];
} else { const amount = Game.dragonLevels[Game.dragonLevel].buy
let cost = 0; .toString()
CopyData(); .match(/sacrifice\((.*?)\)/)[1];
for (let i = 0; i < amount; i++) { if (target !== 'i') {
let price = SimObjects[target].basePrice * Game.priceIncrease ** Math.max(0, SimObjects[target].amount - 1 - SimObjects[target].free); target = target.replaceAll("'", '');
price = Game.modifyBuildingPrice(SimObjects[target], price); if (Game.Objects[target].amount < amount) {
price = Math.ceil(price); CacheCostDragonUpgrade = 'Not enough buildings to sell';
cost += price; } else {
SimObjects[target].amount--; let cost = 0;
} CopyData();
CacheCostDragonUpgrade = `Cost to rebuy: ${(cost)}`; for (let i = 0; i < amount; i++) {
} let price =
} else { SimObjects[target].basePrice *
let cost = 0; Game.priceIncrease **
CopyData(); Math.max(
for (const j of Object.keys(Game.Objects)) { 0,
target = j; SimObjects[target].amount - 1 - SimObjects[target].free,
if (Game.Objects[target].amount < amount) { );
CacheCostDragonUpgrade = 'Not enough buildings to sell'; price = Game.modifyBuildingPrice(SimObjects[target], price);
break; price = Math.ceil(price);
} else { cost += price;
for (let i = 0; i < amount; i++) { SimObjects[target].amount--;
let price = SimObjects[target].basePrice * Game.priceIncrease ** Math.max(0, SimObjects[target].amount - 1 - SimObjects[target].free); }
price = Game.modifyBuildingPrice(SimObjects[target], price); CacheCostDragonUpgrade = `Cost to rebuy: ${cost}`;
price = Math.ceil(price); }
cost += price; } else {
SimObjects[target].amount--; let cost = 0;
} CopyData();
} for (const j of Object.keys(Game.Objects)) {
CacheCostDragonUpgrade = `Cost to rebuy: ${Beautify(cost)}`; target = j;
} if (Game.Objects[target].amount < amount) {
} CacheCostDragonUpgrade = 'Not enough buildings to sell';
} break;
CacheLastDragonLevel = Game.dragonLevel; } else {
} for (let i = 0; i < amount; i++) {
let price =
SimObjects[target].basePrice *
Game.priceIncrease **
Math.max(
0,
SimObjects[target].amount - 1 - SimObjects[target].free,
);
price = Game.modifyBuildingPrice(SimObjects[target], price);
price = Math.ceil(price);
cost += price;
SimObjects[target].amount--;
}
}
CacheCostDragonUpgrade = `Cost to rebuy: ${Beautify(cost)}`;
}
}
}
CacheLastDragonLevel = Game.dragonLevel;
}
} }

View File

@@ -3,8 +3,13 @@ import { CMOptions } from '../../Config/VariablesAndData';
import GetWrinkConfigBank from '../../Disp/HelperFunctions/GetWrinkConfigBank'; import GetWrinkConfigBank from '../../Disp/HelperFunctions/GetWrinkConfigBank';
import { ColorGray } from '../../Disp/VariablesAndData'; import { ColorGray } from '../../Disp/VariablesAndData';
import { import {
CacheArrayOfPPs, CacheArrayOfPPs,
CacheMaxPP, CacheMidPP, CacheMinPP, CacheObjects1, CacheObjects10, CacheObjects100, CacheMaxPP,
CacheMidPP,
CacheMinPP,
CacheObjects1,
CacheObjects10,
CacheObjects100,
} from '../VariablesAndData'; } from '../VariablesAndData';
import ColourOfPP from './ColourOfPP'; import ColourOfPP from './ColourOfPP';
@@ -14,13 +19,16 @@ import ColourOfPP from './ColourOfPP';
* It is called by CM.Cache.CacheBuildingsPP() * It is called by CM.Cache.CacheBuildingsPP()
*/ */
function CacheBuildingsBulkPP(target) { function CacheBuildingsBulkPP(target) {
for (const i of Object.keys(target)) { for (const i of Object.keys(target)) {
if (Game.cookiesPs) { if (Game.cookiesPs) {
target[i].pp = (Math.max(target[i].price - (Game.cookies + GetWrinkConfigBank()), 0) / Game.cookiesPs) + (target[i].price / target[i].bonus); target[i].pp =
} else target[i].pp = (target[i].price / target[i].bonus); Math.max(target[i].price - (Game.cookies + GetWrinkConfigBank()), 0) /
Game.cookiesPs +
target[i].price / target[i].bonus;
} else target[i].pp = target[i].price / target[i].bonus;
target[i].color = ColourOfPP(target[i], target[i].price); target[i].color = ColourOfPP(target[i], target[i].price);
} }
} }
/** /**
@@ -28,74 +36,92 @@ function CacheBuildingsBulkPP(target) {
* It is called by CM.Cache.CachePP() * It is called by CM.Cache.CachePP()
*/ */
export default function CacheBuildingsPP() { export default function CacheBuildingsPP() {
CacheMinPP = Infinity; CacheMinPP = Infinity;
CacheMaxPP = 1; CacheMaxPP = 1;
CacheArrayOfPPs = []; CacheArrayOfPPs = [];
if (typeof CMOptions.PPExcludeTop === 'undefined') CMOptions.PPExcludeTop = 0; // Otherwise breaks during initialization if (typeof CMOptions.PPExcludeTop === 'undefined') CMOptions.PPExcludeTop = 0; // Otherwise breaks during initialization
// Calculate PP and colors when compared to purchase of optimal building in single-purchase mode // Calculate PP and colors when compared to purchase of optimal building in single-purchase mode
if (CMOptions.ColorPPBulkMode === 0 && Game.buyMode > 0) { if (CMOptions.ColorPPBulkMode === 0 && Game.buyMode > 0) {
for (const i of Object.keys(CacheObjects1)) { for (const i of Object.keys(CacheObjects1)) {
if (Game.cookiesPs) { if (Game.cookiesPs) {
CacheObjects1[i].pp = (Math.max(Game.Objects[i].getPrice() - (Game.cookies + GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].getPrice() / CacheObjects1[i].bonus); CacheObjects1[i].pp =
} else CacheObjects1[i].pp = (Game.Objects[i].getPrice() / CacheObjects1[i].bonus); Math.max(
CacheArrayOfPPs.push([CacheObjects1[i].pp, Game.Objects[i].getPrice()]); Game.Objects[i].getPrice() - (Game.cookies + GetWrinkConfigBank()),
} 0,
// Set CM.Cache.min to best non-excluded buidliung ) /
CacheArrayOfPPs.sort((a, b) => a[0] - b[0]); Game.cookiesPs +
if (CMOptions.PPOnlyConsiderBuyable) { Game.Objects[i].getPrice() / CacheObjects1[i].bonus;
while (CacheArrayOfPPs[0][1] > Game.cookies) { } else
if (CacheArrayOfPPs.length === 1) { CacheObjects1[i].pp =
break; Game.Objects[i].getPrice() / CacheObjects1[i].bonus;
} CacheArrayOfPPs.push([CacheObjects1[i].pp, Game.Objects[i].getPrice()]);
CacheArrayOfPPs.shift(); }
} // Set CM.Cache.min to best non-excluded buidliung
} CacheArrayOfPPs.sort((a, b) => a[0] - b[0]);
CacheMinPP = CacheArrayOfPPs[CMOptions.PPExcludeTop][0]; if (CMOptions.PPOnlyConsiderBuyable) {
CacheMaxPP = CacheArrayOfPPs[CacheArrayOfPPs.length - 1][0]; while (CacheArrayOfPPs[0][1] > Game.cookies) {
CacheMidPP = ((CacheMaxPP - CacheMinPP) / 2) + CacheMinPP; if (CacheArrayOfPPs.length === 1) {
for (const i of Object.keys(CacheObjects1)) { break;
CacheObjects1[i].color = ColourOfPP(CacheObjects1[i], Game.Objects[i].getPrice()); }
// Colour based on excluding certain top-buildings CacheArrayOfPPs.shift();
for (let j = 0; j < CMOptions.PPExcludeTop; j++) { }
if (CacheObjects1[i].pp === CacheArrayOfPPs[j][0]) CacheObjects1[i].color = ColorGray; }
} CacheMinPP = CacheArrayOfPPs[CMOptions.PPExcludeTop][0];
} CacheMaxPP = CacheArrayOfPPs[CacheArrayOfPPs.length - 1][0];
// Calculate PP of bulk-buy modes CacheMidPP = (CacheMaxPP - CacheMinPP) / 2 + CacheMinPP;
CacheBuildingsBulkPP(CacheObjects10); for (const i of Object.keys(CacheObjects1)) {
CacheBuildingsBulkPP(CacheObjects100); CacheObjects1[i].color = ColourOfPP(
} else if (Game.buyMode > 0) { CacheObjects1[i],
// Calculate PP and colors when compared to purchase of selected bulk mode Game.Objects[i].getPrice(),
let target; );
if (Game.buyBulk === 1) target = CacheObjects1; // Colour based on excluding certain top-buildings
else if (Game.buyBulk === 10) target = CacheObjects10; for (let j = 0; j < CMOptions.PPExcludeTop; j++) {
else if (Game.buyBulk === 100) target = CacheObjects100; if (CacheObjects1[i].pp === CacheArrayOfPPs[j][0])
for (const i of Object.keys(target)) { CacheObjects1[i].color = ColorGray;
if (Game.cookiesPs) { }
target[i].pp = (Math.max(Game.Objects[i].bulkPrice - (Game.cookies + GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].bulkPrice / target[i].bonus); }
} else target[i].pp = (Game.Objects[i].bulkPrice / target[i].bonus); // Calculate PP of bulk-buy modes
CacheArrayOfPPs.push([target[i].pp, Game.Objects[i].bulkPrice]); CacheBuildingsBulkPP(CacheObjects10);
} CacheBuildingsBulkPP(CacheObjects100);
// Set CM.Cache.min to best non-excluded buidliung } else if (Game.buyMode > 0) {
CacheArrayOfPPs.sort((a, b) => a[0] - b[0]); // Calculate PP and colors when compared to purchase of selected bulk mode
if (CMOptions.PPOnlyConsiderBuyable) { let target;
while (CacheArrayOfPPs[0][1] > Game.cookies) { if (Game.buyBulk === 1) target = CacheObjects1;
if (CacheArrayOfPPs.length === 1) { else if (Game.buyBulk === 10) target = CacheObjects10;
break; else if (Game.buyBulk === 100) target = CacheObjects100;
} for (const i of Object.keys(target)) {
CacheArrayOfPPs.shift(); if (Game.cookiesPs) {
} target[i].pp =
} Math.max(
CacheMinPP = CacheArrayOfPPs[CMOptions.PPExcludeTop][0]; Game.Objects[i].bulkPrice - (Game.cookies + GetWrinkConfigBank()),
CacheMaxPP = CacheArrayOfPPs[CacheArrayOfPPs.length - 1][0]; 0,
CacheMidPP = ((CacheMaxPP - CacheMinPP) / 2) + CacheMinPP; ) /
Game.cookiesPs +
Game.Objects[i].bulkPrice / target[i].bonus;
} else target[i].pp = Game.Objects[i].bulkPrice / target[i].bonus;
CacheArrayOfPPs.push([target[i].pp, Game.Objects[i].bulkPrice]);
}
// Set CM.Cache.min to best non-excluded buidliung
CacheArrayOfPPs.sort((a, b) => a[0] - b[0]);
if (CMOptions.PPOnlyConsiderBuyable) {
while (CacheArrayOfPPs[0][1] > Game.cookies) {
if (CacheArrayOfPPs.length === 1) {
break;
}
CacheArrayOfPPs.shift();
}
}
CacheMinPP = CacheArrayOfPPs[CMOptions.PPExcludeTop][0];
CacheMaxPP = CacheArrayOfPPs[CacheArrayOfPPs.length - 1][0];
CacheMidPP = (CacheMaxPP - CacheMinPP) / 2 + CacheMinPP;
for (const i of Object.keys(CacheObjects1)) { for (const i of Object.keys(CacheObjects1)) {
target[i].color = ColourOfPP(target[i], Game.Objects[i].bulkPrice); target[i].color = ColourOfPP(target[i], Game.Objects[i].bulkPrice);
// Colour based on excluding certain top-buildings // Colour based on excluding certain top-buildings
for (let j = 0; j < CMOptions.PPExcludeTop; j++) { for (let j = 0; j < CMOptions.PPExcludeTop; j++) {
if (target[i].pp === CacheArrayOfPPs[j][0]) target[i].color = ColorGray; if (target[i].pp === CacheArrayOfPPs[j][0]) target[i].color = ColorGray;
} }
} }
} }
} }

View File

@@ -1,7 +1,13 @@
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import GetCPS from '../../Disp/HelperFunctions/GetCPS'; import GetCPS from '../../Disp/HelperFunctions/GetCPS';
import { import {
ColorBlue, ColorGray, ColorGreen, ColorOrange, ColorPurple, ColorRed, ColorYellow, ColorBlue,
ColorGray,
ColorGreen,
ColorOrange,
ColorPurple,
ColorRed,
ColorYellow,
} from '../../Disp/VariablesAndData'; } from '../../Disp/VariablesAndData';
import { CacheMaxPP, CacheMidPP, CacheMinPP } from '../VariablesAndData'; import { CacheMaxPP, CacheMidPP, CacheMinPP } from '../VariablesAndData';
@@ -13,23 +19,24 @@ import { CacheMaxPP, CacheMidPP, CacheMinPP } from '../VariablesAndData';
* @returns {string} color The colour assosciated with the pp value * @returns {string} color The colour assosciated with the pp value
*/ */
export default function ColourOfPP(me, price) { export default function ColourOfPP(me, price) {
let color = ''; let color = '';
// Colour based on PP // Colour based on PP
if (me.pp <= 0 || me.pp === Infinity) color = ColorGray; if (me.pp <= 0 || me.pp === Infinity) color = ColorGray;
else if (me.pp < CacheMinPP) color = ColorBlue; else if (me.pp < CacheMinPP) color = ColorBlue;
else if (me.pp === CacheMinPP) color = ColorGreen; else if (me.pp === CacheMinPP) color = ColorGreen;
else if (me.pp === CacheMaxPP) color = ColorRed; else if (me.pp === CacheMaxPP) color = ColorRed;
else if (me.pp > CacheMaxPP) color = ColorPurple; else if (me.pp > CacheMaxPP) color = ColorPurple;
else if (me.pp > CacheMidPP) color = ColorOrange; else if (me.pp > CacheMidPP) color = ColorOrange;
else color = ColorYellow; else color = ColorYellow;
// Colour based on price in terms of CPS // Colour based on price in terms of CPS
if (Number(CMOptions.PPSecondsLowerLimit) !== 0) { if (Number(CMOptions.PPSecondsLowerLimit) !== 0) {
if (price / GetCPS() < Number(CMOptions.PPSecondsLowerLimit)) color = ColorBlue; if (price / GetCPS() < Number(CMOptions.PPSecondsLowerLimit))
} color = ColorBlue;
// Colour based on being able to purchase }
if (CMOptions.PPOnlyConsiderBuyable) { // Colour based on being able to purchase
if (price - Game.cookies > 0) color = ColorRed; if (CMOptions.PPOnlyConsiderBuyable) {
} if (price - Game.cookies > 0) color = ColorRed;
return color; }
return color;
} }

View File

@@ -9,6 +9,6 @@ import CacheUpgradePP from './Upgrade';
* It is called by CM.Cache.LoopCache() and CM.Cache.InitCache() * It is called by CM.Cache.LoopCache() and CM.Cache.InitCache()
*/ */
export default function CachePP() { export default function CachePP() {
CacheBuildingsPP(); CacheBuildingsPP();
CacheUpgradePP(); CacheUpgradePP();
} }

View File

@@ -7,12 +7,23 @@ import ColourOfPP from './ColourOfPP';
* It is called by CM.Cache.CachePP() * It is called by CM.Cache.CachePP()
*/ */
export default function CacheUpgradePP() { export default function CacheUpgradePP() {
for (const i of Object.keys(CacheUpgrades)) { for (const i of Object.keys(CacheUpgrades)) {
if (Game.cookiesPs) { if (Game.cookiesPs) {
CacheUpgrades[i].pp = (Math.max(Game.Upgrades[i].getPrice() - (Game.cookies + GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Upgrades[i].getPrice() / CacheUpgrades[i].bonus); CacheUpgrades[i].pp =
} else CacheUpgrades[i].pp = (Game.Upgrades[i].getPrice() / CacheUpgrades[i].bonus); Math.max(
if (Number.isNaN(CacheUpgrades[i].pp)) CacheUpgrades[i].pp = Infinity; Game.Upgrades[i].getPrice() - (Game.cookies + GetWrinkConfigBank()),
0,
) /
Game.cookiesPs +
Game.Upgrades[i].getPrice() / CacheUpgrades[i].bonus;
} else
CacheUpgrades[i].pp =
Game.Upgrades[i].getPrice() / CacheUpgrades[i].bonus;
if (Number.isNaN(CacheUpgrades[i].pp)) CacheUpgrades[i].pp = Infinity;
CacheUpgrades[i].color = ColourOfPP(CacheUpgrades[i], Game.Upgrades[i].getPrice()); CacheUpgrades[i].color = ColourOfPP(
} CacheUpgrades[i],
Game.Upgrades[i].getPrice(),
);
}
} }

View File

@@ -5,7 +5,11 @@ import BuildingGetPrice from '../../Sim/SimulationEvents/BuyBuilding';
import BuyBuildingsBonusIncome from '../../Sim/SimulationEvents/BuyBuildingBonusIncome'; import BuyBuildingsBonusIncome from '../../Sim/SimulationEvents/BuyBuildingBonusIncome';
import BuyUpgradesBonusIncome from '../../Sim/SimulationEvents/BuyUpgrades'; import BuyUpgradesBonusIncome from '../../Sim/SimulationEvents/BuyUpgrades';
import { import {
CacheDoRemakeBuildPrices, CacheObjects1, CacheObjects10, CacheObjects100, CacheUpgrades, CacheDoRemakeBuildPrices,
CacheObjects1,
CacheObjects10,
CacheObjects100,
CacheUpgrades,
} from '../VariablesAndData'; } from '../VariablesAndData';
/** /**
@@ -15,15 +19,15 @@ import {
* @parem {string} target The target Cache object ("Objects1", "Objects10" or "Objects100") * @parem {string} target The target Cache object ("Objects1", "Objects10" or "Objects100")
*/ */
function CacheBuildingIncome(amount, target) { function CacheBuildingIncome(amount, target) {
const result = []; const result = [];
for (const i of Object.keys(Game.Objects)) { for (const i of Object.keys(Game.Objects)) {
result[i] = {}; result[i] = {};
result[i].bonus = BuyBuildingsBonusIncome(i, amount); result[i].bonus = BuyBuildingsBonusIncome(i, amount);
if (amount !== 1) { if (amount !== 1) {
CacheDoRemakeBuildPrices = 1; CacheDoRemakeBuildPrices = 1;
} }
} }
return result; return result;
} }
/** /**
@@ -31,24 +35,42 @@ function CacheBuildingIncome(amount, target) {
* It is called by CM.Cache.CacheIncome() * It is called by CM.Cache.CacheIncome()
*/ */
function CacheUpgradeIncome() { function CacheUpgradeIncome() {
CacheUpgrades = []; CacheUpgrades = [];
for (const i of Object.keys(Game.Upgrades)) { for (const i of Object.keys(Game.Upgrades)) {
const bonusIncome = BuyUpgradesBonusIncome(i); const bonusIncome = BuyUpgradesBonusIncome(i);
CacheUpgrades[i] = {}; CacheUpgrades[i] = {};
if (bonusIncome[0]) CacheUpgrades[i].bonus = bonusIncome[0]; if (bonusIncome[0]) CacheUpgrades[i].bonus = bonusIncome[0];
if (bonusIncome[1]) CacheUpgrades[i].bonusMouse = bonusIncome[1]; if (bonusIncome[1]) CacheUpgrades[i].bonusMouse = bonusIncome[1];
} }
} }
/** /**
* This functions caches the price of each building and stores it in the cache * This functions caches the price of each building and stores it in the cache
*/ */
export function CacheBuildingsPrices() { export function CacheBuildingsPrices() {
for (const i of Object.keys(Game.Objects)) { for (const i of Object.keys(Game.Objects)) {
CacheObjects1[i].price = BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 1); CacheObjects1[i].price = BuildingGetPrice(
CacheObjects10[i].price = BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 10); Game.Objects[i],
CacheObjects100[i].price = BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 100); Game.Objects[i].basePrice,
} Game.Objects[i].amount,
Game.Objects[i].free,
1,
);
CacheObjects10[i].price = BuildingGetPrice(
Game.Objects[i],
Game.Objects[i].basePrice,
Game.Objects[i].amount,
Game.Objects[i].free,
10,
);
CacheObjects100[i].price = BuildingGetPrice(
Game.Objects[i],
Game.Objects[i].basePrice,
Game.Objects[i].amount,
Game.Objects[i].free,
100,
);
}
} }
/** /**
@@ -56,11 +78,11 @@ export function CacheBuildingsPrices() {
* It is called by CM.Main.Loop() and CM.Cache.InitCache() * It is called by CM.Main.Loop() and CM.Cache.InitCache()
*/ */
export function CacheIncome() { export function CacheIncome() {
// Simulate Building Buys for 1, 10 and 100 amount // Simulate Building Buys for 1, 10 and 100 amount
CacheObjects1 = CacheBuildingIncome(1); CacheObjects1 = CacheBuildingIncome(1);
CacheObjects10 = CacheBuildingIncome(10); CacheObjects10 = CacheBuildingIncome(10);
CacheObjects100 = CacheBuildingIncome(100); CacheObjects100 = CacheBuildingIncome(100);
// Simulate Upgrade Buys // Simulate Upgrade Buys
CacheUpgradeIncome(); CacheUpgradeIncome();
} }

View File

@@ -1,7 +1,22 @@
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
import GetCPSBuffMult from '../CPS/GetCPSBuffMult'; import GetCPSBuffMult from '../CPS/GetCPSBuffMult';
import { import {
CacheChainFrenzyMaxReward, CacheChainFrenzyRequired, CacheChainFrenzyRequiredNext, CacheChainFrenzyWrathMaxReward, CacheChainFrenzyWrathRequired, CacheChainFrenzyWrathRequiredNext, CacheChainMaxReward, CacheChainRequired, CacheChainRequiredNext, CacheChainWrathMaxReward, CacheChainWrathRequired, CacheChainWrathRequiredNext, CacheDragonsFortuneMultAdjustment, CacheGoldenCookiesMult, CacheNoGoldSwitchCookiesPS, CacheWrathCookiesMult, CacheChainFrenzyMaxReward,
CacheChainFrenzyRequired,
CacheChainFrenzyRequiredNext,
CacheChainFrenzyWrathMaxReward,
CacheChainFrenzyWrathRequired,
CacheChainFrenzyWrathRequiredNext,
CacheChainMaxReward,
CacheChainRequired,
CacheChainRequiredNext,
CacheChainWrathMaxReward,
CacheChainWrathRequired,
CacheChainWrathRequiredNext,
CacheDragonsFortuneMultAdjustment,
CacheGoldenCookiesMult,
CacheNoGoldSwitchCookiesPS,
CacheWrathCookiesMult,
} from '../VariablesAndData'; } from '../VariablesAndData';
/** /**
@@ -13,19 +28,32 @@ import {
* @returns [{number, number, number}] Total cookies earned, cookie needed for this and next level * @returns [{number, number, number}] Total cookies earned, cookie needed for this and next level
*/ */
export function MaxChainCookieReward(digit, maxPayout, mult) { export function MaxChainCookieReward(digit, maxPayout, mult) {
let totalFromChain = 0; let totalFromChain = 0;
let moni = 0; let moni = 0;
let nextMoni = 0; let nextMoni = 0;
let nextRequired = 0; let nextRequired = 0;
let chain = 1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10); let chain =
while (nextMoni < maxPayout) { 1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10);
moni = Math.max(digit, Math.min(Math.floor(1 / 9 * 10 ** chain * digit * mult), maxPayout * mult)); while (nextMoni < maxPayout) {
nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * 10 ** (chain + 1) * digit * mult), maxPayout * mult)); moni = Math.max(
nextRequired = Math.floor(1 / 9 * 10 ** (chain + 1) * digit * mult); digit,
totalFromChain += moni; Math.min(
chain++; Math.floor((1 / 9) * 10 ** chain * digit * mult),
} maxPayout * mult,
return [totalFromChain, moni, nextRequired]; ),
);
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++;
}
return [totalFromChain, moni, nextRequired];
} }
/** /**
@@ -45,25 +73,65 @@ export function MaxChainCookieReward(digit, maxPayout, mult) {
* @global {number} CM.Cache.ChainFrenzyWrathRequiredNext Total cookies needed for next level for wrath frenzy chain * @global {number} CM.Cache.ChainFrenzyWrathRequiredNext Total cookies needed for next level for wrath frenzy chain
*/ */
export function CacheChain() { export function CacheChain() {
let maxPayout = CacheNoGoldSwitchCookiesPS * 60 * 60 * 6 * CacheDragonsFortuneMultAdjustment; let maxPayout =
// Removes effect of Frenzy etc. CacheNoGoldSwitchCookiesPS *
const cpsBuffMult = GetCPSBuffMult(); 60 *
if (cpsBuffMult > 0) maxPayout /= cpsBuffMult; 60 *
else maxPayout = 0; 6 *
CacheDragonsFortuneMultAdjustment;
// Removes effect of Frenzy etc.
const cpsBuffMult = GetCPSBuffMult();
if (cpsBuffMult > 0) maxPayout /= cpsBuffMult;
else maxPayout = 0;
CacheChainMaxReward = MaxChainCookieReward(7, maxPayout, CacheGoldenCookiesMult); CacheChainMaxReward = MaxChainCookieReward(
CacheChainRequired = CacheChainMaxReward[1] * 2 / CacheGoldenCookiesMult; 7,
CacheChainRequiredNext = CacheChainMaxReward[2] / 60 / 60 / 6 / CacheDragonsFortuneMultAdjustment; maxPayout,
CacheGoldenCookiesMult,
);
CacheChainRequired = (CacheChainMaxReward[1] * 2) / CacheGoldenCookiesMult;
CacheChainRequiredNext =
CacheChainMaxReward[2] / 60 / 60 / 6 / CacheDragonsFortuneMultAdjustment;
CacheChainWrathMaxReward = MaxChainCookieReward(6, maxPayout, CacheWrathCookiesMult); CacheChainWrathMaxReward = MaxChainCookieReward(
CacheChainWrathRequired = CacheChainWrathMaxReward[1] * 2 / CacheWrathCookiesMult; 6,
CacheChainWrathRequiredNext = CacheChainWrathMaxReward[2] / 60 / 60 / 6 / CacheDragonsFortuneMultAdjustment; maxPayout,
CacheWrathCookiesMult,
);
CacheChainWrathRequired =
(CacheChainWrathMaxReward[1] * 2) / CacheWrathCookiesMult;
CacheChainWrathRequiredNext =
CacheChainWrathMaxReward[2] /
60 /
60 /
6 /
CacheDragonsFortuneMultAdjustment;
CacheChainFrenzyMaxReward = MaxChainCookieReward(7, maxPayout * 7, CacheGoldenCookiesMult); CacheChainFrenzyMaxReward = MaxChainCookieReward(
CacheChainFrenzyRequired = CacheChainFrenzyMaxReward[1] * 2 / CacheGoldenCookiesMult; 7,
CacheChainFrenzyRequiredNext = CacheChainFrenzyMaxReward[2] / 60 / 60 / 6 / CacheDragonsFortuneMultAdjustment; maxPayout * 7,
CacheGoldenCookiesMult,
);
CacheChainFrenzyRequired =
(CacheChainFrenzyMaxReward[1] * 2) / CacheGoldenCookiesMult;
CacheChainFrenzyRequiredNext =
CacheChainFrenzyMaxReward[2] /
60 /
60 /
6 /
CacheDragonsFortuneMultAdjustment;
CacheChainFrenzyWrathMaxReward = MaxChainCookieReward(6, maxPayout * 7, CacheWrathCookiesMult); CacheChainFrenzyWrathMaxReward = MaxChainCookieReward(
CacheChainFrenzyWrathRequired = CacheChainFrenzyWrathMaxReward[1] * 2 / CacheWrathCookiesMult; 6,
CacheChainFrenzyWrathRequiredNext = CacheChainFrenzyWrathMaxReward[2] / 60 / 60 / 6 / CacheDragonsFortuneMultAdjustment; maxPayout * 7,
CacheWrathCookiesMult,
);
CacheChainFrenzyWrathRequired =
(CacheChainFrenzyWrathMaxReward[1] * 2) / CacheWrathCookiesMult;
CacheChainFrenzyWrathRequiredNext =
CacheChainFrenzyWrathMaxReward[2] /
60 /
60 /
6 /
CacheDragonsFortuneMultAdjustment;
} }

View File

@@ -1,6 +1,9 @@
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
import { import {
CacheHCPerSecond, CacheLastHeavenlyCheck, CacheLastHeavenlyChips, HeavenlyChipsDiff, CacheHCPerSecond,
CacheLastHeavenlyCheck,
CacheLastHeavenlyChips,
HeavenlyChipsDiff,
} from '../VariablesAndData'; } from '../VariablesAndData';
/** /**
@@ -9,25 +12,28 @@ import {
* @global {number} CM.Cache.HCPerSecond The Heavenly Chips per second in the last five seconds * @global {number} CM.Cache.HCPerSecond The Heavenly Chips per second in the last five seconds
*/ */
export default function CacheHeavenlyChipsPS() { export default function CacheHeavenlyChipsPS() {
const currDate = Math.floor(Date.now() / 1000); const currDate = Math.floor(Date.now() / 1000);
// Only calculate every new second // Only calculate every new second
if ((Game.T / Game.fps) % 1 === 0) { if ((Game.T / Game.fps) % 1 === 0) {
const chipsOwned = Game.HowMuchPrestige(Game.cookiesReset); const chipsOwned = Game.HowMuchPrestige(Game.cookiesReset);
const ascendNowToOwn = Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)); const ascendNowToOwn = Math.floor(
const ascendNowToGet = ascendNowToOwn - Math.floor(chipsOwned); Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned),
);
const ascendNowToGet = ascendNowToOwn - Math.floor(chipsOwned);
// Add recent gains to AvgQueue's // Add recent gains to AvgQueue's
const timeDiff = currDate - CacheLastHeavenlyCheck; const timeDiff = currDate - CacheLastHeavenlyCheck;
const heavenlyChipsDiffAvg = Math.max(0, (ascendNowToGet - CacheLastHeavenlyChips)) / timeDiff; const heavenlyChipsDiffAvg =
for (let i = 0; i < timeDiff; i++) { Math.max(0, ascendNowToGet - CacheLastHeavenlyChips) / timeDiff;
HeavenlyChipsDiff.addLatest(heavenlyChipsDiffAvg); for (let i = 0; i < timeDiff; i++) {
} HeavenlyChipsDiff.addLatest(heavenlyChipsDiffAvg);
}
// Store current data for next loop // Store current data for next loop
CacheLastHeavenlyCheck = currDate; CacheLastHeavenlyCheck = currDate;
CacheLastHeavenlyChips = ascendNowToGet; CacheLastHeavenlyChips = ascendNowToGet;
// Get average gain over period of 5 seconds // Get average gain over period of 5 seconds
CacheHCPerSecond = HeavenlyChipsDiff.calcAverage(5); CacheHCPerSecond = HeavenlyChipsDiff.calcAverage(5);
} }
} }

View File

@@ -1,6 +1,10 @@
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
import { crateMissing } from '../../Disp/MenuSections/CreateMissingUpgrades'; import { crateMissing } from '../../Disp/MenuSections/CreateMissingUpgrades';
import { CacheMissingUpgrades, CacheMissingUpgradesCookies, CacheMissingUpgradesPrestige } from '../VariablesAndData'; import {
CacheMissingUpgrades,
CacheMissingUpgradesCookies,
CacheMissingUpgradesPrestige,
} from '../VariablesAndData';
/** /**
* This functions caches variables related to missing upgrades * This functions caches variables related to missing upgrades
@@ -10,31 +14,36 @@ import { CacheMissingUpgrades, CacheMissingUpgradesCookies, CacheMissingUpgrades
* @global {string} CM.Cache.MissingUpgradesPrestige String containig the HTML to create the "crates" for missing prestige upgrades * @global {string} CM.Cache.MissingUpgradesPrestige String containig the HTML to create the "crates" for missing prestige upgrades
*/ */
export default function CacheAllMissingUpgrades() { export default function CacheAllMissingUpgrades() {
CacheMissingUpgrades = ''; CacheMissingUpgrades = '';
CacheMissingUpgradesCookies = ''; CacheMissingUpgradesCookies = '';
CacheMissingUpgradesPrestige = ''; CacheMissingUpgradesPrestige = '';
const list = []; const list = [];
// sort the upgrades // sort the upgrades
for (const i of Object.keys(Game.Upgrades)) { for (const i of Object.keys(Game.Upgrades)) {
list.push(Game.Upgrades[i]); list.push(Game.Upgrades[i]);
} }
const sortMap = function (a, b) { const sortMap = function (a, b) {
if (a.order > b.order) return 1; if (a.order > b.order) return 1;
if (a.order < b.order) return -1; if (a.order < b.order) return -1;
return 0; return 0;
}; };
list.sort(sortMap); list.sort(sortMap);
for (const i of Object.keys(list)) { for (const i of Object.keys(list)) {
const me = list[i]; const me = list[i];
if (me.bought === 0) { if (me.bought === 0) {
let str = ''; let str = '';
str += crateMissing(me); str += crateMissing(me);
if (me.pool === 'prestige') CacheMissingUpgradesPrestige += str; if (me.pool === 'prestige') CacheMissingUpgradesPrestige += str;
else if (me.pool === 'cookie') CacheMissingUpgradesCookies += str; else if (me.pool === 'cookie') CacheMissingUpgradesCookies += str;
else if (me.pool !== 'toggle' && me.pool !== 'unused' && me.pool !== 'debug') CacheMissingUpgrades += str; else if (
} me.pool !== 'toggle' &&
} me.pool !== 'unused' &&
me.pool !== 'debug'
)
CacheMissingUpgrades += str;
}
}
} }

View File

@@ -7,11 +7,11 @@ import { CacheSeaSpec } from '../VariablesAndData';
* @global {number} CM.Cache.SeaSpec The reward for popping a reindeer * @global {number} CM.Cache.SeaSpec The reward for popping a reindeer
*/ */
export default function CacheSeasonSpec() { export default function CacheSeasonSpec() {
if (Game.season === 'christmas') { if (Game.season === 'christmas') {
let val = Game.cookiesPs * 60; let val = Game.cookiesPs * 60;
if (Game.hasBuff('Elder frenzy')) val *= 0.5; if (Game.hasBuff('Elder frenzy')) val *= 0.5;
if (Game.hasBuff('Frenzy')) val *= 0.75; if (Game.hasBuff('Frenzy')) val *= 0.75;
CacheSeaSpec = Math.max(25, val); CacheSeaSpec = Math.max(25, val);
if (Game.Has('Ho ho ho-flavored frosting')) CacheSeaSpec *= 2; if (Game.Has('Ho ho ho-flavored frosting')) CacheSeaSpec *= 2;
} }
} }

View File

@@ -4,70 +4,88 @@
import SimHas from '../../Sim/ReplacedGameFunctions/SimHas'; import SimHas from '../../Sim/ReplacedGameFunctions/SimHas';
import GetCPSBuffMult from '../CPS/GetCPSBuffMult'; import GetCPSBuffMult from '../CPS/GetCPSBuffMult';
import { import {
CacheConjure, CacheConjureReward, CacheDragonsFortuneMultAdjustment, CacheEdifice, CacheEdificeBuilding, CacheGoldenCookiesMult, CacheLucky, CacheLuckyFrenzy, CacheLuckyReward, CacheLuckyRewardFrenzy, CacheLuckyWrathReward, CacheLuckyWrathRewardFrenzy, CacheNoGoldSwitchCookiesPS, CacheWrathCookiesMult, CacheConjure,
CacheConjureReward,
CacheDragonsFortuneMultAdjustment,
CacheEdifice,
CacheEdificeBuilding,
CacheGoldenCookiesMult,
CacheLucky,
CacheLuckyFrenzy,
CacheLuckyReward,
CacheLuckyRewardFrenzy,
CacheLuckyWrathReward,
CacheLuckyWrathRewardFrenzy,
CacheNoGoldSwitchCookiesPS,
CacheWrathCookiesMult,
} from '../VariablesAndData'; } from '../VariablesAndData';
/** /**
* This functions caches variables related to the stats page * This functions caches variables related to the stats page
*/ */
export function CacheStatsCookies() { export function CacheStatsCookies() {
CacheLucky = (CacheNoGoldSwitchCookiesPS * 900) / 0.15; CacheLucky = (CacheNoGoldSwitchCookiesPS * 900) / 0.15;
CacheLucky *= CacheDragonsFortuneMultAdjustment; CacheLucky *= CacheDragonsFortuneMultAdjustment;
const cpsBuffMult = GetCPSBuffMult(); const cpsBuffMult = GetCPSBuffMult();
if (cpsBuffMult > 0) CacheLucky /= cpsBuffMult; if (cpsBuffMult > 0) CacheLucky /= cpsBuffMult;
else CacheLucky = 0; else CacheLucky = 0;
CacheLuckyReward = CacheGoldenCookiesMult * (CacheLucky * 0.15) + 13; CacheLuckyReward = CacheGoldenCookiesMult * (CacheLucky * 0.15) + 13;
CacheLuckyWrathReward = CacheWrathCookiesMult * (CacheLucky * 0.15) + 13; CacheLuckyWrathReward = CacheWrathCookiesMult * (CacheLucky * 0.15) + 13;
CacheLuckyFrenzy = CacheLucky * 7; CacheLuckyFrenzy = CacheLucky * 7;
CacheLuckyRewardFrenzy = CacheGoldenCookiesMult * (CacheLuckyFrenzy * 0.15) + 13; CacheLuckyRewardFrenzy =
CacheLuckyWrathRewardFrenzy = CacheWrathCookiesMult * (CacheLuckyFrenzy * 0.15) + 13; CacheGoldenCookiesMult * (CacheLuckyFrenzy * 0.15) + 13;
CacheConjure = CacheLucky * 2; CacheLuckyWrathRewardFrenzy =
CacheConjureReward = CacheConjure * 0.15; CacheWrathCookiesMult * (CacheLuckyFrenzy * 0.15) + 13;
CacheConjure = CacheLucky * 2;
CacheConjureReward = CacheConjure * 0.15;
CacheEdifice = 0; CacheEdifice = 0;
let max = 0; let max = 0;
let n = 0; let n = 0;
for (const i of Object.keys(Game.Objects)) { for (const i of Object.keys(Game.Objects)) {
if (Game.Objects[i].amount > max) max = Game.Objects[i].amount; if (Game.Objects[i].amount > max) max = Game.Objects[i].amount;
if (Game.Objects[i].amount > 0) n++; if (Game.Objects[i].amount > 0) n++;
} }
for (const i of Object.keys(Game.Objects)) { for (const i of Object.keys(Game.Objects)) {
if ((Game.Objects[i].amount < max || n === 1) if (
&& Game.Objects[i].amount < 400 (Game.Objects[i].amount < max || n === 1) &&
&& Game.Objects[i].price * 2 > CacheEdifice) { Game.Objects[i].amount < 400 &&
CacheEdifice = Game.Objects[i].price * 2; Game.Objects[i].price * 2 > CacheEdifice
CacheEdificeBuilding = i; ) {
} CacheEdifice = Game.Objects[i].price * 2;
} CacheEdificeBuilding = i;
}
}
} }
/** /**
* This functions calculates the multipliers of Golden and Wrath cookie rewards * This functions calculates the multipliers of Golden and Wrath cookie rewards
*/ */
export function CacheGoldenAndWrathCookiesMults() { export function CacheGoldenAndWrathCookiesMults() {
let goldenMult = 1; let goldenMult = 1;
let wrathMult = 1; let wrathMult = 1;
let mult = 1; let mult = 1;
// Factor auras and upgrade in mults // Factor auras and upgrade in mults
if (SimHas('Green yeast digestives')) mult *= 1.01; if (SimHas('Green yeast digestives')) mult *= 1.01;
if (SimHas('Dragon fang')) mult *= 1.03; if (SimHas('Dragon fang')) mult *= 1.03;
goldenMult *= 1 + Game.auraMult('Ancestral Metamorphosis') * 0.1; goldenMult *= 1 + Game.auraMult('Ancestral Metamorphosis') * 0.1;
goldenMult *= Game.eff('goldenCookieGain'); goldenMult *= Game.eff('goldenCookieGain');
wrathMult *= 1 + Game.auraMult('Unholy Dominion') * 0.1; wrathMult *= 1 + Game.auraMult('Unholy Dominion') * 0.1;
wrathMult *= Game.eff('wrathCookieGain'); wrathMult *= Game.eff('wrathCookieGain');
// Calculate final golden and wrath multipliers // Calculate final golden and wrath multipliers
CacheGoldenCookiesMult = mult * goldenMult; CacheGoldenCookiesMult = mult * goldenMult;
CacheWrathCookiesMult = mult * wrathMult; CacheWrathCookiesMult = mult * wrathMult;
// Calculate Dragon's Fortune multiplier adjustment: // Calculate Dragon's Fortune multiplier adjustment:
// If Dragon's Fortune (or Reality Bending) aura is active and there are currently no golden cookies, // If Dragon's Fortune (or Reality Bending) aura is active and there are currently no golden cookies,
// compute a multiplier adjustment to apply on the current CPS to simulate 1 golden cookie on screen. // compute a multiplier adjustment to apply on the current CPS to simulate 1 golden cookie on screen.
// Otherwise, the aura effect will be factored in the base CPS making the multiplier not requiring adjustment. // Otherwise, the aura effect will be factored in the base CPS making the multiplier not requiring adjustment.
CacheDragonsFortuneMultAdjustment = 1; CacheDragonsFortuneMultAdjustment = 1;
if (Game.shimmerTypes.golden.n === 0) { if (Game.shimmerTypes.golden.n === 0) {
CacheDragonsFortuneMultAdjustment *= 1 + Game.auraMult('Dragon\'s Fortune') * 1.23; CacheDragonsFortuneMultAdjustment *=
} 1 + Game.auraMult("Dragon's Fortune") * 1.23;
}
} }

View File

@@ -3,7 +3,9 @@
import { SimObjects } from '../../Sim/VariablesAndData'; import { SimObjects } from '../../Sim/VariablesAndData';
import { import {
CacheWrinklersFattest, CacheWrinklersNormal, CacheWrinklersTotal, CacheWrinklersFattest,
CacheWrinklersNormal,
CacheWrinklersTotal,
} from '../VariablesAndData'; } from '../VariablesAndData';
/** /**
@@ -14,23 +16,24 @@ import {
* @global {[{number}, {number}]} CM.Cache.WrinklersFattest A list containing the cookies and the id of the fattest non-shiny wrinkler * @global {[{number}, {number}]} CM.Cache.WrinklersFattest A list containing the cookies and the id of the fattest non-shiny wrinkler
*/ */
export default function CacheWrinklers() { export default function CacheWrinklers() {
for (let i = 0; i < Game.wrinklers.length; i++) { for (let i = 0; i < Game.wrinklers.length; i++) {
let sucked = Game.wrinklers[i].sucked; let sucked = Game.wrinklers[i].sucked;
let toSuck = 1.1; let toSuck = 1.1;
if (Game.Has('Sacrilegious corruption')) toSuck *= 1.05; if (Game.Has('Sacrilegious corruption')) toSuck *= 1.05;
if (Game.wrinklers[i].type === 1) toSuck *= 3; // Shiny wrinklers if (Game.wrinklers[i].type === 1) toSuck *= 3; // Shiny wrinklers
sucked *= toSuck; sucked *= toSuck;
if (Game.Has('Wrinklerspawn')) sucked *= 1.05; if (Game.Has('Wrinklerspawn')) sucked *= 1.05;
if (SimObjects.Temple.minigameLoaded) { if (SimObjects.Temple.minigameLoaded) {
const godLvl = Game.hasGod('scorn'); const godLvl = Game.hasGod('scorn');
if (godLvl === 1) sucked *= 1.15; if (godLvl === 1) sucked *= 1.15;
else if (godLvl === 2) sucked *= 1.1; else if (godLvl === 2) sucked *= 1.1;
else if (godLvl === 3) sucked *= 1.05; else if (godLvl === 3) sucked *= 1.05;
} }
CacheWrinklersTotal += sucked; CacheWrinklersTotal += sucked;
if (Game.wrinklers[i].type === 0) { if (Game.wrinklers[i].type === 0) {
CacheWrinklersNormal += sucked; CacheWrinklersNormal += sucked;
if (sucked > CacheWrinklersFattest[0]) CacheWrinklersFattest = [sucked, i]; if (sucked > CacheWrinklersFattest[0])
} CacheWrinklersFattest = [sucked, i];
} }
}
} }

View File

@@ -5,26 +5,26 @@
* @param {number} ToggleOnOff A number indicating whether the option has been turned off (0) or on (1) * @param {number} ToggleOnOff A number indicating whether the option has been turned off (0) or on (1)
*/ */
function CheckNotificationPermissions(ToggleOnOff) { function CheckNotificationPermissions(ToggleOnOff) {
if (ToggleOnOff === 1) { if (ToggleOnOff === 1) {
// Check if browser support Promise version of Notification Permissions // Check if browser support Promise version of Notification Permissions
const checkNotificationPromise = function () { const checkNotificationPromise = function () {
try { try {
Notification.requestPermission().then(); Notification.requestPermission().then();
} catch (e) { } catch (e) {
return false; return false;
} }
return true; return true;
}; };
// Check if the browser supports notifications and which type // Check if the browser supports notifications and which type
if (!('Notification' in window)) { if (!('Notification' in window)) {
console.log('This browser does not support notifications.'); console.log('This browser does not support notifications.');
} else if (checkNotificationPromise()) { } else if (checkNotificationPromise()) {
Notification.requestPermission().then(); Notification.requestPermission().then();
} else { } else {
Notification.requestPermission(); Notification.requestPermission();
} }
} }
} }
export default CheckNotificationPermissions; export default CheckNotificationPermissions;

View File

@@ -13,12 +13,20 @@ import CMLoop from '../../Main/Loop';
* CM.ToggleConfigVolume() and changes in options with type "url", "color" or "numscale" * CM.ToggleConfigVolume() and changes in options with type "url", "color" or "numscale"
*/ */
export function SaveConfig() { export function SaveConfig() {
const saveString = b64_to_utf8(unescape(localStorage.getItem('CookieClickerGame')).split('!END!')[0]); const saveString = b64_to_utf8(
const CookieMonsterSave = saveString.match(/CookieMonster.*(;|$)/); unescape(localStorage.getItem('CookieClickerGame')).split('!END!')[0],
if (CookieMonsterSave !== null) { );
const newSaveString = saveString.replace(CookieMonsterSave[0], `CookieMonster:${save()}`); const CookieMonsterSave = saveString.match(/CookieMonster.*(;|$)/);
localStorage.setItem('CookieClickerGame', escape(`${utf8_to_b64(newSaveString)}!END!`)); if (CookieMonsterSave !== null) {
} const newSaveString = saveString.replace(
CookieMonsterSave[0],
`CookieMonster:${save()}`,
);
localStorage.setItem(
'CookieClickerGame',
escape(`${utf8_to_b64(newSaveString)}!END!`),
);
}
} }
/** /**
@@ -26,53 +34,64 @@ export function SaveConfig() {
* It is called by CM.Main.DelayInit() and CM.Config.RestoreDefault() * It is called by CM.Main.DelayInit() and CM.Config.RestoreDefault()
*/ */
export function LoadConfig(settings) { export function LoadConfig(settings) {
// This removes cookies left from earlier versions of CookieMonster // This removes cookies left from earlier versions of CookieMonster
if (typeof localStorage.CMConfig !== 'undefined') { if (typeof localStorage.CMConfig !== 'undefined') {
delete localStorage.CMConfig; delete localStorage.CMConfig;
} }
if (settings !== undefined) { if (settings !== undefined) {
CMOptions = settings; CMOptions = settings;
// Check values // Check values
let mod = false; let mod = false;
for (const i in ConfigDefault) { for (const i in ConfigDefault) {
if (typeof CMOptions[i] === 'undefined') { if (typeof CMOptions[i] === 'undefined') {
mod = true; mod = true;
CMOptions[i] = ConfigDefault[i]; CMOptions[i] = ConfigDefault[i];
} else if (i !== 'Header' && i !== 'Colors') { } else if (i !== 'Header' && i !== 'Colors') {
if (i.indexOf('SoundURL') === -1) { if (i.indexOf('SoundURL') === -1) {
if (!(CMOptions[i] > -1 && CMOptions[i] < ConfigData[i].label.length)) { if (
mod = true; !(CMOptions[i] > -1 && CMOptions[i] < ConfigData[i].label.length)
CMOptions[i] = ConfigDefault[i]; ) {
} mod = true;
} else if (typeof CMOptions[i] !== 'string') { // Sound URLs CMOptions[i] = ConfigDefault[i];
mod = true; }
CMOptions[i] = ConfigDefault[i]; } else if (typeof CMOptions[i] !== 'string') {
} // Sound URLs
} else if (i === 'Header') { mod = true;
for (const j in ConfigDefault.Header) { CMOptions[i] = ConfigDefault[i];
if (typeof CMOptions[i][j] === 'undefined' || !(CMOptions[i][j] > -1 && CMOptions[i][j] < 2)) { }
mod = true; } else if (i === 'Header') {
CMOptions[i][j] = ConfigDefault[i][j]; for (const j in ConfigDefault.Header) {
} if (
} typeof CMOptions[i][j] === 'undefined' ||
} else { // Colors !(CMOptions[i][j] > -1 && CMOptions[i][j] < 2)
for (const j in ConfigDefault.Colors) { ) {
if (typeof CMOptions[i][j] === 'undefined' || typeof CMOptions[i][j] !== 'string') { mod = true;
mod = true; CMOptions[i][j] = ConfigDefault[i][j];
CMOptions[i][j] = ConfigDefault[i][j]; }
} }
} } else {
} // Colors
} for (const j in ConfigDefault.Colors) {
if (mod) SaveConfig(); if (
CMLoop(); // Do loop once typeof CMOptions[i][j] === 'undefined' ||
for (const i in ConfigDefault) { typeof CMOptions[i][j] !== 'string'
if (i !== 'Header' && typeof ConfigData[i].func !== 'undefined') { ) {
ConfigData[i].func(); mod = true;
} CMOptions[i][j] = ConfigDefault[i][j];
} }
} else { // Default values }
LoadConfig(ConfigDefault); }
} }
if (mod) SaveConfig();
CMLoop(); // Do loop once
for (const i in ConfigDefault) {
if (i !== 'Header' && typeof ConfigData[i].func !== 'undefined') {
ConfigData[i].func();
}
}
} else {
// Default values
LoadConfig(ConfigDefault);
}
} }

View File

@@ -7,48 +7,55 @@ import { CMOptions } from './VariablesAndData';
* This function changes the position of both the bottom and timer bar * This function changes the position of both the bottom and timer bar
*/ */
export function UpdateBotTimerBarPosition() { export function UpdateBotTimerBarPosition() {
if (CMOptions.BotBar === 1 && CMOptions.TimerBar === 1 && CMOptions.TimerBarPos === 1) { if (
l('CMBotBar').style.bottom = l('CMTimerBar').style.height; CMOptions.BotBar === 1 &&
l('game').style.bottom = `${Number(l('CMTimerBar').style.height.replace('px', '')) + 70}px`; CMOptions.TimerBar === 1 &&
} else if (CMOptions.BotBar === 1) { CMOptions.TimerBarPos === 1
l('CMBotBar').style.bottom = '0px'; ) {
l('game').style.bottom = '70px'; l('CMBotBar').style.bottom = l('CMTimerBar').style.height;
} else if (CMOptions.TimerBar === 1 && CMOptions.TimerBarPos === 1) { l('game').style.bottom = `${
l('game').style.bottom = l('CMTimerBar').style.height; Number(l('CMTimerBar').style.height.replace('px', '')) + 70
} else { // No bars }px`;
l('game').style.bottom = '0px'; } else if (CMOptions.BotBar === 1) {
} l('CMBotBar').style.bottom = '0px';
l('game').style.bottom = '70px';
} else if (CMOptions.TimerBar === 1 && CMOptions.TimerBarPos === 1) {
l('game').style.bottom = l('CMTimerBar').style.height;
} else {
// No bars
l('game').style.bottom = '0px';
}
if (CMOptions.TimerBar === 1 && CMOptions.TimerBarPos === 0) { if (CMOptions.TimerBar === 1 && CMOptions.TimerBarPos === 0) {
l('sectionLeft').style.top = l('CMTimerBar').style.height; l('sectionLeft').style.top = l('CMTimerBar').style.height;
} else { } else {
l('sectionLeft').style.top = ''; l('sectionLeft').style.top = '';
} }
UpdateBackground(); UpdateBackground();
} }
/** /**
* This function changes the visibility of the timer bar * This function changes the visibility of the timer bar
*/ */
export function ToggleTimerBar() { export function ToggleTimerBar() {
if (CMOptions.TimerBar === 1) l('CMTimerBar').style.display = ''; if (CMOptions.TimerBar === 1) l('CMTimerBar').style.display = '';
else l('CMTimerBar').style.display = 'none'; else l('CMTimerBar').style.display = 'none';
UpdateBotTimerBarPosition(); UpdateBotTimerBarPosition();
} }
/** /**
* This function changes the position of the timer bar * This function changes the position of the timer bar
*/ */
export function ToggleTimerBarPos() { export function ToggleTimerBarPos() {
if (CMOptions.TimerBarPos === 0) { if (CMOptions.TimerBarPos === 0) {
l('CMTimerBar').style.width = '30%'; l('CMTimerBar').style.width = '30%';
l('CMTimerBar').style.bottom = ''; l('CMTimerBar').style.bottom = '';
l('game').insertBefore(l('CMTimerBar'), l('sectionLeft')); l('game').insertBefore(l('CMTimerBar'), l('sectionLeft'));
} else { } else {
l('CMTimerBar').style.width = '100%'; l('CMTimerBar').style.width = '100%';
l('CMTimerBar').style.bottom = '0px'; l('CMTimerBar').style.bottom = '0px';
l('wrapper').appendChild(l('CMTimerBar')); l('wrapper').appendChild(l('CMTimerBar'));
} }
UpdateBotTimerBarPosition(); UpdateBotTimerBarPosition();
} }

View File

@@ -13,19 +13,21 @@ export const ConfigPrefix = 'CMConfig';
* @param {string} config The name of the option * @param {string} config The name of the option
*/ */
export function ToggleConfig(config) { export function ToggleConfig(config) {
CMOptions[config]++; CMOptions[config]++;
if (CMOptions[config] === ConfigData[config].label.length) { if (CMOptions[config] === ConfigData[config].label.length) {
CMOptions[config] = 0; CMOptions[config] = 0;
if (ConfigData[config].toggle) l(ConfigPrefix + config).className = 'option off'; if (ConfigData[config].toggle)
} else l(ConfigPrefix + config).className = 'option'; l(ConfigPrefix + config).className = 'option off';
} else l(ConfigPrefix + config).className = 'option';
if (typeof ConfigData[config].func !== 'undefined') { if (typeof ConfigData[config].func !== 'undefined') {
ConfigData[config].func(); ConfigData[config].func();
} }
l(ConfigPrefix + config).innerHTML = ConfigData[config].label[CMOptions[config]]; l(ConfigPrefix + config).innerHTML =
SaveConfig(); ConfigData[config].label[CMOptions[config]];
SaveConfig();
} }
/** /**
@@ -34,11 +36,11 @@ export function ToggleConfig(config) {
* @param {string} config The name of the option * @param {string} config The name of the option
*/ */
export function ToggleConfigVolume(config) { export function ToggleConfigVolume(config) {
if (l(`slider${config}`) !== null) { if (l(`slider${config}`) !== null) {
l(`slider${config}right`).innerHTML = `${l(`slider${config}`).value}%`; l(`slider${config}right`).innerHTML = `${l(`slider${config}`).value}%`;
CMOptions[config] = Math.round(l(`slider${config}`).value); CMOptions[config] = Math.round(l(`slider${config}`).value);
} }
SaveConfig(); SaveConfig();
} }
/** /**
@@ -47,7 +49,7 @@ export function ToggleConfigVolume(config) {
* @param {string} config The name of the header * @param {string} config The name of the header
*/ */
export function ToggleHeader(config) { export function ToggleHeader(config) {
CMOptions.Header[config]++; CMOptions.Header[config]++;
if (CMOptions.Header[config] > 1) CMOptions.Header[config] = 0; if (CMOptions.Header[config] > 1) CMOptions.Header[config] = 0;
SaveConfig(); SaveConfig();
} }

View File

@@ -7,11 +7,11 @@ import { CMOptions } from '../VariablesAndData';
* It is called by CM.Disp.UpdateAscendState() and a change in CMOptions.BotBar * It is called by CM.Disp.UpdateAscendState() and a change in CMOptions.BotBar
*/ */
export default function ToggleBotBar() { export default function ToggleBotBar() {
if (CMOptions.BotBar === 1) { if (CMOptions.BotBar === 1) {
l('CMBotBar').style.display = ''; l('CMBotBar').style.display = '';
UpdateBotBar(); UpdateBotBar();
} else { } else {
l('CMBotBar').style.display = 'none'; l('CMBotBar').style.display = 'none';
} }
UpdateBotTimerBarPosition(); UpdateBotTimerBarPosition();
} }

View File

@@ -7,6 +7,6 @@ import { CMOptions } from '../VariablesAndData';
* It is called by a change in CM.Options.DetailedTime * It is called by a change in CM.Options.DetailedTime
*/ */
export default function ToggleDetailedTime() { export default function ToggleDetailedTime() {
if (CMOptions.DetailedTime === 1) Game.sayTime = CMSayTime; if (CMOptions.DetailedTime === 1) Game.sayTime = CMSayTime;
else Game.sayTime = BackupFunctions.sayTime; else Game.sayTime = BackupFunctions.sayTime;
} }

View File

@@ -7,13 +7,13 @@ import { CMOptions } from '../VariablesAndData';
* It is called by a change in CM.Options.GCTimer * It is called by a change in CM.Options.GCTimer
*/ */
export default function ToggleGCTimer() { export default function ToggleGCTimer() {
if (CMOptions.GCTimer === 1) { if (CMOptions.GCTimer === 1) {
for (const i of Object.keys(GCTimers)) { for (const i of Object.keys(GCTimers)) {
GCTimers[i].style.display = 'block'; GCTimers[i].style.display = 'block';
GCTimers[i].style.left = CacheGoldenShimmersByID[i].l.style.left; GCTimers[i].style.left = CacheGoldenShimmersByID[i].l.style.left;
GCTimers[i].style.top = CacheGoldenShimmersByID[i].l.style.top; GCTimers[i].style.top = CacheGoldenShimmersByID[i].l.style.top;
} }
} else { } else {
for (const i of Object.keys(GCTimers)) GCTimers[i].style.display = 'none'; for (const i of Object.keys(GCTimers)) GCTimers[i].style.display = 'none';
} }
} }

View File

@@ -6,15 +6,15 @@ import { CMOptions } from '../VariablesAndData';
* and upon creation of the warning tooltip by CM.Disp.UpdateTooltipWarnings() * and upon creation of the warning tooltip by CM.Disp.UpdateTooltipWarnings()
*/ */
export default function ToggleToolWarnPos() { export default function ToggleToolWarnPos() {
if (l('CMDispTooltipWarningParent') !== null) { if (l('CMDispTooltipWarningParent') !== null) {
if (CMOptions.ToolWarnPos === 0) { if (CMOptions.ToolWarnPos === 0) {
l('CMDispTooltipWarningParent').style.top = 'auto'; l('CMDispTooltipWarningParent').style.top = 'auto';
l('CMDispTooltipWarningParent').style.margin = '4px -4px'; l('CMDispTooltipWarningParent').style.margin = '4px -4px';
l('CMDispTooltipWarningParent').style.padding = '3px 4px'; l('CMDispTooltipWarningParent').style.padding = '3px 4px';
} else { } else {
l('CMDispTooltipWarningParent').style.right = 'auto'; l('CMDispTooltipWarningParent').style.right = 'auto';
l('CMDispTooltipWarningParent').style.margin = '4px'; l('CMDispTooltipWarningParent').style.margin = '4px';
l('CMDispTooltipWarningParent').style.padding = '4px 3px'; l('CMDispTooltipWarningParent').style.padding = '4px 3px';
} }
} }
} }

View File

@@ -9,14 +9,17 @@ import { CMOptions } from '../VariablesAndData';
* It is called by a change in CM.Options.UpBarColor * It is called by a change in CM.Options.UpBarColor
*/ */
export default function ToggleUpgradeBarAndColor() { export default function ToggleUpgradeBarAndColor() {
if (CMOptions.UpBarColor === 1) { // Colours and bar on if (CMOptions.UpBarColor === 1) {
l('CMUpgradeBar').style.display = ''; // Colours and bar on
UpdateUpgrades(); l('CMUpgradeBar').style.display = '';
} else if (CMOptions.UpBarColor === 2) { // Colours on and bar off UpdateUpgrades();
l('CMUpgradeBar').style.display = 'none'; } else if (CMOptions.UpBarColor === 2) {
UpdateUpgrades(); // Colours on and bar off
} else { // Colours and bar off l('CMUpgradeBar').style.display = 'none';
l('CMUpgradeBar').style.display = 'none'; UpdateUpgrades();
Game.RebuildUpgrades(); } else {
} // Colours and bar off
l('CMUpgradeBar').style.display = 'none';
Game.RebuildUpgrades();
}
} }

View File

@@ -5,10 +5,11 @@ import { CMOptions } from '../VariablesAndData';
* It is called by a change in CM.Options.UpgradeBarFixedPos * It is called by a change in CM.Options.UpgradeBarFixedPos
*/ */
export default function ToggleUpgradeBarFixedPos() { export default function ToggleUpgradeBarFixedPos() {
if (CMOptions.UpgradeBarFixedPos === 1) { // Fix to top of screen when scrolling if (CMOptions.UpgradeBarFixedPos === 1) {
l('CMUpgradeBar').style.position = 'sticky'; // Fix to top of screen when scrolling
l('CMUpgradeBar').style.top = '0px'; l('CMUpgradeBar').style.position = 'sticky';
} else { l('CMUpgradeBar').style.top = '0px';
l('CMUpgradeBar').style.position = ''; // Possible to scroll offscreen } else {
} l('CMUpgradeBar').style.position = ''; // Possible to scroll offscreen
}
} }

View File

@@ -5,11 +5,11 @@ import { CMOptions } from '../VariablesAndData';
* It is called by changes in CM.Options.WrinklerButtons * It is called by changes in CM.Options.WrinklerButtons
*/ */
export default function ToggleWrinklerButtons() { export default function ToggleWrinklerButtons() {
if (CMOptions.WrinklerButtons) { if (CMOptions.WrinklerButtons) {
l('PopAllNormalWrinklerButton').style.display = ''; l('PopAllNormalWrinklerButton').style.display = '';
l('PopFattestWrinklerButton').style.display = ''; l('PopFattestWrinklerButton').style.display = '';
} else { } else {
l('PopAllNormalWrinklerButton').style.display = 'none'; l('PopAllNormalWrinklerButton').style.display = 'none';
l('PopFattestWrinklerButton').style.display = 'none'; l('PopFattestWrinklerButton').style.display = 'none';
} }
} }

View File

@@ -4,9 +4,9 @@ import load from './InitSaveLoad/load';
import save from './InitSaveLoad/save'; import save from './InitSaveLoad/save';
const CM = { const CM = {
init, init,
load, load,
save, save,
}; };
Game.registerMod('CookieMonster', CM); Game.registerMod('CookieMonster', CM);

View File

@@ -2,93 +2,96 @@
/** Array of the names of all fortune cookies obtainable from the ticker */ /** Array of the names of all fortune cookies obtainable from the ticker */
export const Fortunes = [ export const Fortunes = [
'Fortune #001', 'Fortune #001',
'Fortune #002', 'Fortune #002',
'Fortune #003', 'Fortune #003',
'Fortune #004', 'Fortune #004',
'Fortune #005', 'Fortune #005',
'Fortune #006', 'Fortune #006',
'Fortune #007', 'Fortune #007',
'Fortune #008', 'Fortune #008',
'Fortune #009', 'Fortune #009',
'Fortune #010', 'Fortune #010',
'Fortune #011', 'Fortune #011',
'Fortune #012', 'Fortune #012',
'Fortune #013', 'Fortune #013',
'Fortune #014', 'Fortune #014',
'Fortune #015', 'Fortune #015',
'Fortune #016', 'Fortune #016',
'Fortune #017', 'Fortune #017',
'Fortune #018', 'Fortune #018',
'Fortune #100', 'Fortune #100',
'Fortune #101', 'Fortune #101',
'Fortune #102', 'Fortune #102',
'Fortune #103', 'Fortune #103',
'Fortune #104', 'Fortune #104',
]; ];
/** Array of the names of all Halloween cookies */ /** Array of the names of all Halloween cookies */
export const HalloCookies = [ export const HalloCookies = [
'Skull cookies', 'Skull cookies',
'Ghost cookies', 'Ghost cookies',
'Bat cookies', 'Bat cookies',
'Slime cookies', 'Slime cookies',
'Pumpkin cookies', 'Pumpkin cookies',
'Eyeball cookies', 'Eyeball cookies',
'Spider cookies', 'Spider cookies',
]; ];
/** Array of the names of all Christmas cookies */ /** Array of the names of all Christmas cookies */
export const ChristCookies = ['Christmas tree biscuits', export const ChristCookies = [
'Snowflake biscuits', 'Christmas tree biscuits',
'Snowman biscuits', 'Snowflake biscuits',
'Holly biscuits', 'Snowman biscuits',
'Candy cane biscuits', 'Holly biscuits',
'Bell biscuits', 'Candy cane biscuits',
'Present biscuits', 'Bell biscuits',
'Present biscuits',
]; ];
/** Array of the names of all Valentine cookies */ /** Array of the names of all Valentine cookies */
export const ValCookies = ['Pure heart biscuits', export const ValCookies = [
'Ardent heart biscuits', 'Pure heart biscuits',
'Sour heart biscuits', 'Ardent heart biscuits',
'Weeping heart biscuits', 'Sour heart biscuits',
'Golden heart biscuits', 'Weeping heart biscuits',
'Eternal heart biscuits', 'Golden heart biscuits',
'Prism heart biscuits', 'Eternal heart biscuits',
'Prism heart biscuits',
]; ];
/** Array of the names of all plant drops */ /** Array of the names of all plant drops */
export const PlantDrops = ['Elderwort biscuits', export const PlantDrops = [
'Bakeberry cookies', 'Elderwort biscuits',
'Duketater cookies', 'Bakeberry cookies',
'Green yeast digestives', 'Duketater cookies',
'Wheat slims', 'Green yeast digestives',
'Fern tea', 'Wheat slims',
'Ichor syrup', 'Fern tea',
'Ichor syrup',
]; ];
/** All possible effects plants and other items can have with a display-title */ /** All possible effects plants and other items can have with a display-title */
export const Effects = { export const Effects = {
buildingCost: 'Building prices', buildingCost: 'Building prices',
click: 'Cookies per click', click: 'Cookies per click',
cps: 'Total CPS', cps: 'Total CPS',
cursorCps: 'Cursor CPS', cursorCps: 'Cursor CPS',
goldenCookieDur: 'Golden cookie duration', goldenCookieDur: 'Golden cookie duration',
goldenCookieEffDur: 'Golden cookie effect duration', goldenCookieEffDur: 'Golden cookie effect duration',
goldenCookieFreq: 'Golden cookie frequency', goldenCookieFreq: 'Golden cookie frequency',
goldenCookieGain: 'Golden cookie gains', goldenCookieGain: 'Golden cookie gains',
grandmaCps: 'Grandma CPS', grandmaCps: 'Grandma CPS',
itemDrops: 'Random item drop chance', itemDrops: 'Random item drop chance',
milk: 'Effect from milk', milk: 'Effect from milk',
reindeerDur: 'Reindeer duration', reindeerDur: 'Reindeer duration',
reindeerFreq: 'Reindeer frequency', reindeerFreq: 'Reindeer frequency',
reindeerGain: 'Reindeer gains', reindeerGain: 'Reindeer gains',
upgradeCost: 'Upgrade prices', upgradeCost: 'Upgrade prices',
wrathCookieDur: 'Wrath cookie duration', wrathCookieDur: 'Wrath cookie duration',
wrathCookieEffDur: 'Wrath cookie effect duration', wrathCookieEffDur: 'Wrath cookie effect duration',
wrathCookieFreq: 'Wrath cookie frequency', wrathCookieFreq: 'Wrath cookie frequency',
wrathCookieGain: 'Wrath cookie gains', wrathCookieGain: 'Wrath cookie gains',
wrinklerEat: 'Wrinkler ', wrinklerEat: 'Wrinkler ',
wrinklerSpawn: 'Wrinkler spawn frequency', wrinklerSpawn: 'Wrinkler spawn frequency',
}; };

View File

@@ -1,148 +1,141 @@
/** Data related directly to the scales used by Cookie Monster */ /** Data related directly to the scales used by Cookie Monster */
/** Array of abbreviations used in the "Metric" scale */ /** Array of abbreviations used in the "Metric" scale */
export const metric = ['', export const metric = ['', '', 'M', 'G', 'T', 'P', 'E', 'Z', 'Y'];
'',
'M',
'G',
'T',
'P',
'E',
'Z',
'Y',
];
/** Array of abbreviations used in the "Short" scale */ /** Array of abbreviations used in the "Short" scale */
export const shortScale = ['', export const shortScale = [
'', '',
'M', '',
'B', 'M',
'Tr', 'B',
'Quadr', 'Tr',
'Quint', 'Quadr',
'Sext', 'Quint',
'Sept', 'Sext',
'Oct', 'Sept',
'Non', 'Oct',
'Dec', 'Non',
'Undec', 'Dec',
'Duodec', 'Undec',
'Tredec', 'Duodec',
'Quattuordec', 'Tredec',
'Quindec', 'Quattuordec',
'Sexdec', 'Quindec',
'Septendec', 'Sexdec',
'Octodec', 'Septendec',
'Novemdec', 'Octodec',
'Vigint', 'Novemdec',
'Unvigint', 'Vigint',
'Duovigint', 'Unvigint',
'Trevigint', 'Duovigint',
'Quattuorvigint', 'Trevigint',
'Quattuorvigint',
]; ];
/** Array of abbreviations used in the "Abbreviated Short" scale */ /** Array of abbreviations used in the "Abbreviated Short" scale */
export const shortScaleAbbreviated = ['', export const shortScaleAbbreviated = [
'K', '',
'M', 'K',
'B', 'M',
'T', 'B',
'Qa', 'T',
'Qi', 'Qa',
'Sx', 'Qi',
'Sp', 'Sx',
'Oc', 'Sp',
'No', 'Oc',
'De', 'No',
'UDe', 'De',
'DDe', 'UDe',
'TDe', 'DDe',
'QaDe', 'TDe',
'QiDe', 'QaDe',
'SxDe', 'QiDe',
'SpDe', 'SxDe',
'ODe', 'SpDe',
'NDe', 'ODe',
'Vi', 'NDe',
'UVi', 'Vi',
'DVi', 'UVi',
'TVi', 'DVi',
'QaVi', 'TVi',
'QiVi', 'QaVi',
'SxVi', 'QiVi',
'SpVi', 'SxVi',
'OVi', 'SpVi',
'NVi', 'OVi',
'Tr', 'NVi',
'UTr', 'Tr',
'DTr', 'UTr',
'TTr', 'DTr',
'QaTr', 'TTr',
'QiTr', 'QaTr',
'SxTr', 'QiTr',
'SpTr', 'SxTr',
'OTr', 'SpTr',
'NTr', 'OTr',
'Qaa', 'NTr',
'UQa', 'Qaa',
'DQa', 'UQa',
'TQa', 'DQa',
'QaQa', 'TQa',
'QiQa', 'QaQa',
'SxQa', 'QiQa',
'SpQa', 'SxQa',
'OQa', 'SpQa',
'NQa', 'OQa',
'Qia', 'NQa',
'UQi', 'Qia',
'DQi', 'UQi',
'TQi', 'DQi',
'QaQi', 'TQi',
'QiQi', 'QaQi',
'SxQi', 'QiQi',
'SpQi', 'SxQi',
'OQi', 'SpQi',
'NQi', 'OQi',
'Sxa', 'NQi',
'USx', 'Sxa',
'DSx', 'USx',
'TSx', 'DSx',
'QaSx', 'TSx',
'QiSx', 'QaSx',
'SxSx', 'QiSx',
'SpSx', 'SxSx',
'OSx', 'SpSx',
'NSx', 'OSx',
'Spa', 'NSx',
'USp', 'Spa',
'DSp', 'USp',
'TSp', 'DSp',
'QaSp', 'TSp',
'QiSp', 'QaSp',
'SxSp', 'QiSp',
'SpSp', 'SxSp',
'OSp', 'SpSp',
'NSp', 'OSp',
'Oco', 'NSp',
'UOc', 'Oco',
'DOc', 'UOc',
'TOc', 'DOc',
'QaOc', 'TOc',
'QiOc', 'QaOc',
'SxOc', 'QiOc',
'SpOc', 'SxOc',
'OOc', 'SpOc',
'NOc', 'OOc',
'Noa', 'NOc',
'UNo', 'Noa',
'DNo', 'UNo',
'TNo', 'DNo',
'QaNo', 'TNo',
'QiNo', 'QaNo',
'SxNo', 'QiNo',
'SpNo', 'SxNo',
'ONo', 'SpNo',
'NNo', 'ONo',
'Ct', 'NNo',
'UCt', 'Ct',
'UCt',
]; ];

View File

@@ -2,23 +2,23 @@
/** Display titles of the headers of the Cookie Monster settings section */ /** Display titles of the headers of the Cookie Monster settings section */
export const ConfigGroups = { export const ConfigGroups = {
BarsColors: 'Bars/Colors', BarsColors: 'Bars/Colors',
Calculation: 'Calculation', Calculation: 'Calculation',
Notification: 'Notification', Notification: 'Notification',
Tooltip: 'Tooltips and additional insights', Tooltip: 'Tooltips and additional insights',
Statistics: 'Statistics', Statistics: 'Statistics',
Notation: 'Notation', Notation: 'Notation',
Miscellaneous: 'Miscellaneous', Miscellaneous: 'Miscellaneous',
}; };
/** Display titles of the headers of the notification section of the Cookie Monster settings */ /** Display titles of the headers of the notification section of the Cookie Monster settings */
export const ConfigGroupsNotification = { export const ConfigGroupsNotification = {
NotificationGeneral: 'General Notifications', NotificationGeneral: 'General Notifications',
NotificationGC: 'Golden Cookie', NotificationGC: 'Golden Cookie',
NotificationFC: 'Fortune Cookie', NotificationFC: 'Fortune Cookie',
NotificationSea: 'Season Special', NotificationSea: 'Season Special',
NotificationGard: 'Garden Tick', NotificationGard: 'Garden Tick',
NotificationMagi: 'Full Magic Bar', NotificationMagi: 'Full Magic Bar',
NotificationWrink: 'Wrinkler', NotificationWrink: 'Wrinkler',
NotificationWrinkMax: 'Maximum Wrinklers', NotificationWrinkMax: 'Maximum Wrinklers',
}; };

View File

@@ -3,52 +3,52 @@
/** The basic setting class */ /** The basic setting class */
export class Setting { export class Setting {
constructor(type, group) { constructor(type, group) {
this.type = type; this.type = type;
this.group = group; this.group = group;
} }
} }
/** The standard toggle setting class */ /** The standard toggle setting class */
export class SettingStandard extends Setting { export class SettingStandard extends Setting {
constructor(type, group, label, desc, toggle, func = null) { constructor(type, group, label, desc, toggle, func = null) {
super(type, group); super(type, group);
this.label = label; this.label = label;
this.desc = desc; this.desc = desc;
this.toggle = toggle; this.toggle = toggle;
if (func) { if (func) {
this.func = func; this.func = func;
} }
} }
} }
/** The colour picker setting class */ /** The colour picker setting class */
export class SettingColours extends Setting { export class SettingColours extends Setting {
constructor(type, group, desc, func) { constructor(type, group, desc, func) {
super(type, group); super(type, group);
this.desc = desc; this.desc = desc;
this.func = func; this.func = func;
} }
} }
/** The volume level setting class */ /** The volume level setting class */
export class SettingVolume extends Setting { export class SettingVolume extends Setting {
constructor(type, group, label, desc) { constructor(type, group, label, desc) {
super(type, group); super(type, group);
this.label = label; this.label = label;
this.desc = desc; this.desc = desc;
for (let i = 0; i < 101; i++) { for (let i = 0; i < 101; i++) {
this.label[i] = `${i}%`; this.label[i] = `${i}%`;
} }
} }
} }
/** The number input setting class */ /** The number input setting class */
export class SettingInputNumber extends Setting { export class SettingInputNumber extends Setting {
constructor(type, group, label, desc, min, max) { constructor(type, group, label, desc, min, max) {
super(type, group); super(type, group);
this.label = label; this.label = label;
this.desc = desc; this.desc = desc;
this.min = min; this.min = min;
this.max = max; this.max = max;
} }
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,97 +1,133 @@
/** This array describes all default settings */ /** This array describes all default settings */
const ConfigDefault = { const ConfigDefault = {
BotBar: 1, BotBar: 1,
TimerBar: 1, TimerBar: 1,
TimerBarPos: 0, TimerBarPos: 0,
TimerBarOverlay: 2, TimerBarOverlay: 2,
BuildColor: 1, BuildColor: 1,
BulkBuildColor: 0, BulkBuildColor: 0,
UpBarColor: 1, UpBarColor: 1,
UpgradeBarFixedPos: 1, UpgradeBarFixedPos: 1,
CalcWrink: 0, CalcWrink: 0,
CPSMode: 1, CPSMode: 1,
AvgCPSHist: 3, AvgCPSHist: 3,
AvgClicksHist: 0, AvgClicksHist: 0,
ColorPPBulkMode: 1, ColorPPBulkMode: 1,
PPExcludeTop: 0, PPExcludeTop: 0,
PPSecondsLowerLimit: 0, PPSecondsLowerLimit: 0,
PPOnlyConsiderBuyable: 0, PPOnlyConsiderBuyable: 0,
ToolWarnBon: 0, ToolWarnBon: 0,
Title: 1, Title: 1,
GeneralSound: 1, GeneralSound: 1,
GCNotification: 0, GCNotification: 0,
GCFlash: 1, GCFlash: 1,
GCSound: 1, GCSound: 1,
GCVolume: 100, GCVolume: 100,
GCSoundURL: 'https://freesound.org/data/previews/66/66717_931655-lq.mp3', GCSoundURL: 'https://freesound.org/data/previews/66/66717_931655-lq.mp3',
FortuneNotification: 0, FortuneNotification: 0,
FortuneFlash: 1, FortuneFlash: 1,
FortuneSound: 1, FortuneSound: 1,
FortuneVolume: 100, FortuneVolume: 100,
FortuneSoundURL: 'https://freesound.org/data/previews/174/174027_3242494-lq.mp3', FortuneSoundURL:
SeaNotification: 0, 'https://freesound.org/data/previews/174/174027_3242494-lq.mp3',
SeaFlash: 1, SeaNotification: 0,
SeaSound: 1, SeaFlash: 1,
SeaVolume: 100, SeaSound: 1,
SeaSoundURL: 'https://www.freesound.org/data/previews/121/121099_2193266-lq.mp3', SeaVolume: 100,
GardFlash: 1, SeaSoundURL:
GardSound: 1, 'https://www.freesound.org/data/previews/121/121099_2193266-lq.mp3',
GardVolume: 100, GardFlash: 1,
GardSoundURL: 'https://freesound.org/data/previews/103/103046_861714-lq.mp3', GardSound: 1,
MagicNotification: 0, GardVolume: 100,
MagicFlash: 1, GardSoundURL: 'https://freesound.org/data/previews/103/103046_861714-lq.mp3',
MagicSound: 1, MagicNotification: 0,
MagicVolume: 100, MagicFlash: 1,
MagicSoundURL: 'https://freesound.org/data/previews/221/221683_1015240-lq.mp3', MagicSound: 1,
WrinklerNotification: 0, MagicVolume: 100,
WrinklerFlash: 1, MagicSoundURL:
WrinklerSound: 1, 'https://freesound.org/data/previews/221/221683_1015240-lq.mp3',
WrinklerVolume: 100, WrinklerNotification: 0,
WrinklerSoundURL: 'https://freesound.org/data/previews/124/124186_8043-lq.mp3', WrinklerFlash: 1,
WrinklerMaxNotification: 0, WrinklerSound: 1,
WrinklerMaxFlash: 1, WrinklerVolume: 100,
WrinklerMaxSound: 1, WrinklerSoundURL:
WrinklerMaxVolume: 100, 'https://freesound.org/data/previews/124/124186_8043-lq.mp3',
WrinklerMaxSoundURL: 'https://freesound.org/data/previews/152/152743_15663-lq.mp3', WrinklerMaxNotification: 0,
TooltipBuildUpgrade: 1, WrinklerMaxFlash: 1,
TooltipAmor: 0, WrinklerMaxSound: 1,
ToolWarnLucky: 1, WrinklerMaxVolume: 100,
ToolWarnLuckyFrenzy: 1, WrinklerMaxSoundURL:
ToolWarnConjure: 1, 'https://freesound.org/data/previews/152/152743_15663-lq.mp3',
ToolWarnConjureFrenzy: 1, TooltipBuildUpgrade: 1,
ToolWarnEdifice: 1, TooltipAmor: 0,
ToolWarnUser: 0, ToolWarnLucky: 1,
ToolWarnPos: 1, ToolWarnLuckyFrenzy: 1,
TooltipGrim: 1, ToolWarnConjure: 1,
TooltipWrink: 1, ToolWarnConjureFrenzy: 1,
TooltipLump: 1, ToolWarnEdifice: 1,
TooltipPlots: 1, ToolWarnUser: 0,
DragonAuraInfo: 1, ToolWarnPos: 1,
TooltipAscendButton: 1, TooltipGrim: 1,
Stats: 1, TooltipWrink: 1,
MissingUpgrades: 1, TooltipLump: 1,
UpStats: 1, TooltipPlots: 1,
TimeFormat: 0, DragonAuraInfo: 1,
DetailedTime: 1, TooltipAscendButton: 1,
GrimoireBar: 1, Stats: 1,
HeavenlyChipsTarget: 1, MissingUpgrades: 1,
ShowMissedGC: 1, UpStats: 1,
Scale: 2, TimeFormat: 0,
ScaleDecimals: 2, DetailedTime: 1,
ScaleSeparator: 0, GrimoireBar: 1,
ScaleCutoff: 999999, HeavenlyChipsTarget: 1,
Colors: { ShowMissedGC: 1,
Blue: '#4bb8f0', Green: '#00ff00', Yellow: '#ffff00', Orange: '#ff7f00', Red: '#ff0000', Purple: '#ff00ff', Gray: '#b3b3b3', Pink: '#ff1493', Brown: '#8b4513', Scale: 2,
}, ScaleDecimals: 2,
SortBuildings: 0, ScaleSeparator: 0,
SortUpgrades: 0, ScaleCutoff: 999999,
GCTimer: 1, Colors: {
Favicon: 1, Blue: '#4bb8f0',
WrinklerButtons: 1, Green: '#00ff00',
BulkBuyBlock: 0, Yellow: '#ffff00',
Header: { Orange: '#ff7f00',
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, 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,
},
}; };
export default ConfigDefault; export default ConfigDefault;

View File

@@ -4,7 +4,10 @@ import { CMOptions } from '../../Config/VariablesAndData';
import { metric, shortScale, shortScaleAbbreviated } from '../../Data/Scales'; import { metric, shortScale, shortScaleAbbreviated } from '../../Data/Scales';
import { BackupFunctions } from '../../Main/VariablesAndData'; import { BackupFunctions } from '../../Main/VariablesAndData';
import { import {
ColorGreen, ColorOrange, ColorRed, ColorYellow, ColorGreen,
ColorOrange,
ColorRed,
ColorYellow,
} from '../VariablesAndData'; } from '../VariablesAndData';
/** /**
@@ -15,53 +18,70 @@ import {
* @returns {string} Formatted number * @returns {string} Formatted number
*/ */
export function Beautify(num, floats, forced) { export function Beautify(num, floats, forced) {
const decimals = CMOptions.ScaleDecimals + 1; const decimals = CMOptions.ScaleDecimals + 1;
if (num === Infinity) { if (num === Infinity) {
return 'Infinity'; return 'Infinity';
} if (typeof num === 'undefined') { }
return '0'; if (typeof num === 'undefined') {
} if (CMOptions.Scale === 0) { return '0';
return BackupFunctions.Beautify(num, floats); }
} if (Number.isFinite(num)) { if (CMOptions.Scale === 0) {
let answer = ''; return BackupFunctions.Beautify(num, floats);
if (num === 0) { }
return num.toString(); if (Number.isFinite(num)) {
} if (num > 0.001 && num < CMOptions.ScaleCutoff) { let answer = '';
if (CMOptions.ScaleSeparator) answer = num.toLocaleString('nl'); if (num === 0) {
else answer = num.toLocaleString('en'); return num.toString();
return answer; }
} if (CMOptions.Scale === 4 && !forced || forced === 4) { // Scientific notation, 123456789 => 1.235E+8 if (num > 0.001 && num < CMOptions.ScaleCutoff) {
answer = num.toExponential(decimals).toString().replace('e', 'E'); if (CMOptions.ScaleSeparator) answer = num.toLocaleString('nl');
} else { else answer = num.toLocaleString('en');
const exponential = num.toExponential().toString(); return answer;
const AmountOfTenPowerThree = Math.floor(exponential.slice(exponential.indexOf('e') + 1) / 3); }
answer = (num / Number(`1e${AmountOfTenPowerThree * 3}`)).toFixed(decimals); if ((CMOptions.Scale === 4 && !forced) || forced === 4) {
// answer is now "xxx.xx" (e.g., 123456789 would be 123.46) // Scientific notation, 123456789 => 1.235E+8
if (CMOptions.Scale === 1 && !forced || forced === 1) { // Metric scale, 123456789 => 123.457 M answer = num.toExponential(decimals).toString().replace('e', 'E');
if (num >= 0.01 && num < Number(`1e${metric.length * 3}`)) { } else {
answer += ` ${metric[AmountOfTenPowerThree]}`; const exponential = num.toExponential().toString();
} else answer = Beautify(num, 0, 4); // If number is too large or little, revert to scientific notation const AmountOfTenPowerThree = Math.floor(
} else if (CMOptions.Scale === 2 && !forced || forced === 2) { // Short scale, 123456789 => 123.457 M exponential.slice(exponential.indexOf('e') + 1) / 3,
if (num >= 0.01 && num < Number(`1e${shortScale.length * 3}`)) { );
answer += ` ${shortScale[AmountOfTenPowerThree]}`; answer = (num / Number(`1e${AmountOfTenPowerThree * 3}`)).toFixed(
} else answer = Beautify(num, 0, 4); // If number is too large or little, revert to scientific notation decimals,
} else if (CMOptions.Scale === 3 && !forced || forced === 3) { // Short scale, 123456789 => 123.457 M );
if (num >= 0.01 && num < Number(`1e${shortScaleAbbreviated.length * 3}`)) { // answer is now "xxx.xx" (e.g., 123456789 would be 123.46)
answer += ` ${shortScaleAbbreviated[AmountOfTenPowerThree]}`; if ((CMOptions.Scale === 1 && !forced) || forced === 1) {
} else answer = Beautify(num, 0, 4); // If number is too large or little, revert to scientific notation // Metric scale, 123456789 => 123.457 M
} else if (CMOptions.Scale === 5 && !forced || forced === 5) { // Engineering notation, 123456789 => 123.457E+6 if (num >= 0.01 && num < Number(`1e${metric.length * 3}`)) {
answer += `E${AmountOfTenPowerThree * 3}`; answer += ` ${metric[AmountOfTenPowerThree]}`;
} } else answer = Beautify(num, 0, 4); // If number is too large or little, revert to scientific notation
} } else if ((CMOptions.Scale === 2 && !forced) || forced === 2) {
if (answer === '') { // Short scale, 123456789 => 123.457 M
console.log(`Could not beautify number with CM.Disp.Beautify: ${num}`); if (num >= 0.01 && num < Number(`1e${shortScale.length * 3}`)) {
answer = BackupFunctions.Beautify(num, floats); answer += ` ${shortScale[AmountOfTenPowerThree]}`;
} } else answer = Beautify(num, 0, 4); // If number is too large or little, revert to scientific notation
if (CMOptions.ScaleSeparator) answer = answer.replace('.', ','); } else if ((CMOptions.Scale === 3 && !forced) || forced === 3) {
return answer; // Short scale, 123456789 => 123.457 M
} if (
console.log(`Could not beautify number with CM.Disp.Beautify: ${num}`); num >= 0.01 &&
return BackupFunctions.Beautify(num, floats); num < Number(`1e${shortScaleAbbreviated.length * 3}`)
) {
answer += ` ${shortScaleAbbreviated[AmountOfTenPowerThree]}`;
} else answer = Beautify(num, 0, 4); // If number is too large or little, revert to scientific notation
} else if ((CMOptions.Scale === 5 && !forced) || forced === 5) {
// Engineering notation, 123456789 => 123.457E+6
answer += `E${AmountOfTenPowerThree * 3}`;
}
}
if (answer === '') {
console.log(`Could not beautify number with CM.Disp.Beautify: ${num}`);
answer = BackupFunctions.Beautify(num, floats);
}
if (CMOptions.ScaleSeparator) answer = answer.replace('.', ',');
return answer;
}
console.log(`Could not beautify number with CM.Disp.Beautify: ${num}`);
return BackupFunctions.Beautify(num, floats);
} }
/** /**
@@ -71,30 +91,36 @@ export function Beautify(num, floats, forced) {
* @returns {string} Formatted time * @returns {string} Formatted time
*/ */
export function FormatTime(time, longFormat) { export function FormatTime(time, longFormat) {
if (time === Infinity) return time; if (time === Infinity) return time;
time = Math.ceil(time); time = Math.ceil(time);
const y = Math.floor(time / 31557600); const y = Math.floor(time / 31557600);
const d = Math.floor(time % 31557600 / 86400); const d = Math.floor((time % 31557600) / 86400);
const h = Math.floor(time % 86400 / 3600); const h = Math.floor((time % 86400) / 3600);
const m = Math.floor(time % 3600 / 60); const m = Math.floor((time % 3600) / 60);
const s = Math.floor(time % 60); const s = Math.floor(time % 60);
let str = ''; let str = '';
if (CMOptions.TimeFormat) { if (CMOptions.TimeFormat) {
if (time > 3155760000) return 'XX:XX:XX:XX:XX'; if (time > 3155760000) return 'XX:XX:XX:XX:XX';
str += `${(y < 10 ? '0' : '') + y}:`; str += `${(y < 10 ? '0' : '') + y}:`;
str += `${(d < 10 ? '0' : '') + d}:`; str += `${(d < 10 ? '0' : '') + d}:`;
str += `${(h < 10 ? '0' : '') + h}:`; str += `${(h < 10 ? '0' : '') + h}:`;
str += `${(m < 10 ? '0' : '') + m}:`; str += `${(m < 10 ? '0' : '') + m}:`;
str += (s < 10 ? '0' : '') + s; str += (s < 10 ? '0' : '') + s;
} else { } else {
if (time > 777600000) return longFormat ? 'Over 9000 days!' : '>9000d'; if (time > 777600000) return longFormat ? 'Over 9000 days!' : '>9000d';
str += (y > 0 ? `${y + (longFormat ? (y === 1 ? ' year' : ' years') : 'y')}, ` : ''); str +=
str += (d > 0 ? `${d + (longFormat ? (d === 1 ? ' day' : ' days') : 'd')}, ` : ''); y > 0
if (str.length > 0 || h > 0) str += `${h + (longFormat ? (h === 1 ? ' hour' : ' hours') : 'h')}, `; ? `${y + (longFormat ? (y === 1 ? ' year' : ' years') : 'y')}, `
if (str.length > 0 || m > 0) str += `${m + (longFormat ? (m === 1 ? ' minute' : ' minutes') : 'm')}, `; : '';
str += s + (longFormat ? (s === 1 ? ' second' : ' seconds') : 's'); str +=
} d > 0 ? `${d + (longFormat ? (d === 1 ? ' day' : ' days') : 'd')}, ` : '';
return str; if (str.length > 0 || h > 0)
str += `${h + (longFormat ? (h === 1 ? ' hour' : ' hours') : 'h')}, `;
if (str.length > 0 || m > 0)
str += `${m + (longFormat ? (m === 1 ? ' minute' : ' minutes') : 'm')}, `;
str += s + (longFormat ? (s === 1 ? ' second' : ' seconds') : 's');
}
return str;
} }
/** /**
@@ -103,17 +129,17 @@ export function FormatTime(time, longFormat) {
* @returns {{string, string}} {text, color} Both the formatted time and color as strings in an array * @returns {{string, string}} {text, color} Both the formatted time and color as strings in an array
*/ */
export function GetTimeColor(time) { export function GetTimeColor(time) {
let color; let color;
let text; let text;
if (time <= 0) { if (time <= 0) {
if (CMOptions.TimeFormat) text = '00:00:00:00:00'; if (CMOptions.TimeFormat) text = '00:00:00:00:00';
else text = 'Done!'; else text = 'Done!';
color = ColorGreen; color = ColorGreen;
} else { } else {
text = FormatTime(time); text = FormatTime(time);
if (time > 300) color = ColorRed; if (time > 300) color = ColorRed;
else if (time > 60) color = ColorOrange; else if (time > 60) color = ColorOrange;
else color = ColorYellow; else color = ColorYellow;
} }
return { text, color }; return { text, color };
} }

View File

@@ -1,4 +1,8 @@
import { CacheObjects1, CacheObjects10, CacheObjects100 } from '../../Cache/VariablesAndData'; import {
CacheObjects1,
CacheObjects10,
CacheObjects100,
} from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import BuildingSell from '../../Sim/SimulationEvents/SellBuilding'; import BuildingSell from '../../Sim/SimulationEvents/SellBuilding';
import { Beautify } from '../BeautifyAndFormatting/BeautifyFormatting'; import { Beautify } from '../BeautifyAndFormatting/BeautifyFormatting';
@@ -14,68 +18,79 @@ import { Colors, LastTargetBuildings } from '../VariablesAndData';
* And by changes in CM.Options.BuildColor, CM.Options.SortBuild & CM.Data.Config.BulkBuildColor * And by changes in CM.Options.BuildColor, CM.Options.SortBuild & CM.Data.Config.BulkBuildColor
*/ */
export default function UpdateBuildings() { export default function UpdateBuildings() {
let target = Game.buyBulk; let target = Game.buyBulk;
if (Game.buyMode === 1) { if (Game.buyMode === 1) {
LastTargetBuildings = target; LastTargetBuildings = target;
} else { } else {
target = LastTargetBuildings; target = LastTargetBuildings;
} }
if (target === 1) target = CacheObjects1; if (target === 1) target = CacheObjects1;
else if (target === 10) target = CacheObjects10; else if (target === 10) target = CacheObjects10;
else if (target === 100) target = CacheObjects100; else if (target === 100) target = CacheObjects100;
if (Game.buyMode === 1) { if (Game.buyMode === 1) {
if (CMOptions.BuildColor === 1) { if (CMOptions.BuildColor === 1) {
for (const i of Object.keys(target)) { for (const i of Object.keys(target)) {
l(`productPrice${Game.Objects[i].id}`).style.color = CMOptions.Colors[target[i].color]; l(`productPrice${Game.Objects[i].id}`).style.color =
} CMOptions.Colors[target[i].color];
} else { }
for (const i of Object.keys(Game.Objects)) { } else {
l(`productPrice${Game.Objects[i].id}`).style.removeProperty('color'); for (const i of Object.keys(Game.Objects)) {
} l(`productPrice${Game.Objects[i].id}`).style.removeProperty('color');
} }
} else if (Game.buyMode === -1) { }
for (const i of Object.keys(CacheObjects1)) { } else if (Game.buyMode === -1) {
const o = Game.Objects[i]; for (const i of Object.keys(CacheObjects1)) {
l(`productPrice${o.id}`).style.color = ''; const o = Game.Objects[i];
/* l(`productPrice${o.id}`).style.color = '';
* Fix sell price displayed in the object in the store. /*
* * Fix sell price displayed in the object in the store.
* The buildings sell price displayed by the game itself (without any mod) is incorrect. *
* The following line of code fixes this issue, and can be safely removed when the game gets fixed. * The buildings sell price displayed by the game itself (without any mod) is incorrect.
* * The following line of code fixes this issue, and can be safely removed when the game gets fixed.
* This issue is extensively detailed here: https://github.com/Aktanusa/CookieMonster/issues/359#issuecomment-735658262 *
*/ * This issue is extensively detailed here: https://github.com/Aktanusa/CookieMonster/issues/359#issuecomment-735658262
l(`productPrice${o.id}`).innerHTML = Beautify(BuildingSell(o, o.basePrice, o.amount, o.free, Game.buyBulk, 1)); */
} l(`productPrice${o.id}`).innerHTML = Beautify(
} BuildingSell(o, o.basePrice, o.amount, o.free, Game.buyBulk, 1),
);
}
}
// Build array of pointers, sort by pp, use array index (+2) as the grid row number // Build array of pointers, sort by pp, use array index (+2) as the grid row number
// (grid rows are 1-based indexing, and row 1 is the bulk buy/sell options) // (grid rows are 1-based indexing, and row 1 is the bulk buy/sell options)
// This regulates sorting of buildings // This regulates sorting of buildings
if (Game.buyMode === 1 && CMOptions.SortBuildings) { if (Game.buyMode === 1 && CMOptions.SortBuildings) {
const arr = Object.keys(target).map((k) => { const arr = Object.keys(target).map((k) => {
const o = target[k]; const o = target[k];
o.name = k; o.name = k;
o.id = Game.Objects[k].id; o.id = Game.Objects[k].id;
return o; return o;
}); });
arr.sort(function (a, b) { return (Colors.indexOf(a.color) > Colors.indexOf(b.color) ? 1 : (Colors.indexOf(a.color) < Colors.indexOf(b.color) ? -1 : (a.pp < b.pp) ? -1 : 0)); }); arr.sort(function (a, b) {
return Colors.indexOf(a.color) > Colors.indexOf(b.color)
? 1
: Colors.indexOf(a.color) < Colors.indexOf(b.color)
? -1
: a.pp < b.pp
? -1
: 0;
});
for (let x = 0; x < arr.length; x++) { for (let x = 0; x < arr.length; x++) {
Game.Objects[arr[x].name].l.style.gridRow = `${x + 2}/${x + 2}`; Game.Objects[arr[x].name].l.style.gridRow = `${x + 2}/${x + 2}`;
} }
} else { } else {
const arr = Object.keys(CacheObjects1).map((k) => { const arr = Object.keys(CacheObjects1).map((k) => {
const o = CacheObjects1[k]; const o = CacheObjects1[k];
o.name = k; o.name = k;
o.id = Game.Objects[k].id; o.id = Game.Objects[k].id;
return o; return o;
}); });
arr.sort((a, b) => a.id - b.id); arr.sort((a, b) => a.id - b.id);
for (let x = 0; x < arr.length; x++) { for (let x = 0; x < arr.length; x++) {
Game.Objects[arr[x].name].l.style.gridRow = `${x + 2}/${x + 2}`; Game.Objects[arr[x].name].l.style.gridRow = `${x + 2}/${x + 2}`;
} }
} }
} }

View File

@@ -1,5 +1,13 @@
import { import {
ColorBackPre, ColorBlue, ColorGray, ColorGreen, ColorOrange, ColorPurple, ColorRed, ColorTextPre, ColorYellow, ColorBackPre,
ColorBlue,
ColorGray,
ColorGreen,
ColorOrange,
ColorPurple,
ColorRed,
ColorTextPre,
ColorYellow,
} from '../VariablesAndData'; } from '../VariablesAndData';
/** /**
@@ -7,73 +15,90 @@ import {
* @returns {object} legend The legend-object to be added * @returns {object} legend The legend-object to be added
*/ */
function CreateUpgradeBarLegend() { function CreateUpgradeBarLegend() {
const legend = document.createElement('div'); const legend = document.createElement('div');
legend.style.minWidth = '330px'; legend.style.minWidth = '330px';
legend.style.marginBottom = '4px'; legend.style.marginBottom = '4px';
const title = document.createElement('div'); const title = document.createElement('div');
title.className = 'name'; title.className = 'name';
title.style.marginBottom = '4px'; title.style.marginBottom = '4px';
title.textContent = 'Legend'; title.textContent = 'Legend';
legend.appendChild(title); legend.appendChild(title);
const legendLine = function (color, text) { const legendLine = function (color, text) {
const div = document.createElement('div'); const div = document.createElement('div');
div.style.verticalAlign = 'middle'; div.style.verticalAlign = 'middle';
const span = document.createElement('span'); const span = document.createElement('span');
span.className = ColorBackPre + color; span.className = ColorBackPre + color;
span.style.display = 'inline-block'; span.style.display = 'inline-block';
span.style.height = '10px'; span.style.height = '10px';
span.style.width = '10px'; span.style.width = '10px';
span.style.marginRight = '4px'; span.style.marginRight = '4px';
div.appendChild(span); div.appendChild(span);
div.appendChild(document.createTextNode(text)); div.appendChild(document.createTextNode(text));
return div; return div;
}; };
legend.appendChild(legendLine(ColorBlue, 'Better than best PP building')); legend.appendChild(legendLine(ColorBlue, 'Better than best PP building'));
legend.appendChild(legendLine(ColorGreen, 'Same as best PP building')); legend.appendChild(legendLine(ColorGreen, 'Same as best PP building'));
legend.appendChild(legendLine(ColorYellow, 'Between best and worst PP buildings closer to best')); legend.appendChild(
legend.appendChild(legendLine(ColorOrange, 'Between best and worst PP buildings closer to worst')); legendLine(
legend.appendChild(legendLine(ColorRed, 'Same as worst PP building')); ColorYellow,
legend.appendChild(legendLine(ColorPurple, 'Worse than worst PP building')); 'Between best and worst PP buildings closer to best',
legend.appendChild(legendLine(ColorGray, 'Negative or infinity PP')); ),
return legend; );
legend.appendChild(
legendLine(
ColorOrange,
'Between best and worst PP buildings closer to worst',
),
);
legend.appendChild(legendLine(ColorRed, 'Same as worst PP building'));
legend.appendChild(legendLine(ColorPurple, 'Worse than worst PP building'));
legend.appendChild(legendLine(ColorGray, 'Negative or infinity PP'));
return legend;
} }
/** /**
* This function creates the upgrade bar above the upgrade-section in the right section of the screen * This function creates the upgrade bar above the upgrade-section in the right section of the screen
*/ */
export default function CreateUpgradeBar() { export default function CreateUpgradeBar() {
const UpgradeBar = document.createElement('div'); const UpgradeBar = document.createElement('div');
UpgradeBar.id = 'CMUpgradeBar'; UpgradeBar.id = 'CMUpgradeBar';
UpgradeBar.style.width = '100%'; UpgradeBar.style.width = '100%';
UpgradeBar.style.backgroundColor = 'black'; UpgradeBar.style.backgroundColor = 'black';
UpgradeBar.style.textAlign = 'center'; UpgradeBar.style.textAlign = 'center';
UpgradeBar.style.fontWeight = 'bold'; UpgradeBar.style.fontWeight = 'bold';
UpgradeBar.style.display = 'none'; UpgradeBar.style.display = 'none';
UpgradeBar.style.zIndex = '21'; UpgradeBar.style.zIndex = '21';
UpgradeBar.onmouseout = function () { Game.tooltip.hide(); }; UpgradeBar.onmouseout = function () {
Game.tooltip.hide();
};
const placeholder = document.createElement('div'); const placeholder = document.createElement('div');
placeholder.appendChild(CreateUpgradeBarLegend()); placeholder.appendChild(CreateUpgradeBarLegend());
UpgradeBar.onmouseover = function () { Game.tooltip.draw(this, escape(placeholder.innerHTML), 'store'); }; UpgradeBar.onmouseover = function () {
Game.tooltip.draw(this, escape(placeholder.innerHTML), 'store');
};
const upgradeNumber = function (id, color) { const upgradeNumber = function (id, color) {
const span = document.createElement('span'); const span = document.createElement('span');
span.id = id; span.id = id;
span.className = ColorTextPre + color; span.className = ColorTextPre + color;
span.style.width = '14.28571428571429%'; span.style.width = '14.28571428571429%';
span.style.display = 'inline-block'; span.style.display = 'inline-block';
span.textContent = '0'; span.textContent = '0';
return span; return span;
}; };
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarBlue', ColorBlue)); UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarBlue', ColorBlue));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarGreen', ColorGreen)); UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarGreen', ColorGreen));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarYellow', ColorYellow)); UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarYellow', ColorYellow));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarOrange', ColorOrange)); UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarOrange', ColorOrange));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarRed', ColorRed)); UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarRed', ColorRed));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarPurple', ColorPurple)); UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarPurple', ColorPurple));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarGray', ColorGray)); UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarGray', ColorGray));
l('upgrades').parentNode.insertBefore(UpgradeBar, l('upgrades').parentNode.childNodes[3]); l('upgrades').parentNode.insertBefore(
UpgradeBar,
l('upgrades').parentNode.childNodes[3],
);
} }

View File

@@ -1,7 +1,15 @@
import { CacheUpgrades } from '../../Cache/VariablesAndData'; import { CacheUpgrades } from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import { import {
ColorBackPre, ColorBlue, ColorGray, ColorGreen, ColorOrange, ColorPurple, ColorRed, Colors, ColorYellow, ColorBackPre,
ColorBlue,
ColorGray,
ColorGreen,
ColorOrange,
ColorPurple,
ColorRed,
Colors,
ColorYellow,
} from '../VariablesAndData'; } from '../VariablesAndData';
/** /**
@@ -11,72 +19,84 @@ import {
* And by changes in CM.Options.SortUpgrades * And by changes in CM.Options.SortUpgrades
*/ */
export default function UpdateUpgrades() { export default function UpdateUpgrades() {
// This counts the amount of upgrades for each pp group and updates the Upgrade Bar // This counts the amount of upgrades for each pp group and updates the Upgrade Bar
if (CMOptions.UpBarColor > 0) { if (CMOptions.UpBarColor > 0) {
let blue = 0; let blue = 0;
let green = 0; let green = 0;
let yellow = 0; let yellow = 0;
let orange = 0; let orange = 0;
let red = 0; let red = 0;
let purple = 0; let purple = 0;
let gray = 0; let gray = 0;
for (const i of Object.keys(Game.UpgradesInStore)) { for (const i of Object.keys(Game.UpgradesInStore)) {
const me = Game.UpgradesInStore[i]; const me = Game.UpgradesInStore[i];
let addedColor = false; let addedColor = false;
for (let j = 0; j < l(`upgrade${i}`).childNodes.length; j++) { for (let j = 0; j < l(`upgrade${i}`).childNodes.length; j++) {
if (l(`upgrade${i}`).childNodes[j].className.indexOf(ColorBackPre) !== -1) { if (
l(`upgrade${i}`).childNodes[j].className = ColorBackPre + CacheUpgrades[me.name].color; l(`upgrade${i}`).childNodes[j].className.indexOf(ColorBackPre) !== -1
addedColor = true; ) {
break; l(`upgrade${i}`).childNodes[j].className =
} ColorBackPre + CacheUpgrades[me.name].color;
} addedColor = true;
if (!addedColor) { break;
const div = document.createElement('div'); }
div.style.width = '10px'; }
div.style.height = '10px'; if (!addedColor) {
div.className = ColorBackPre + CacheUpgrades[me.name].color; const div = document.createElement('div');
l(`upgrade${i}`).appendChild(div); div.style.width = '10px';
} div.style.height = '10px';
if (CacheUpgrades[me.name].color === ColorBlue) blue++; div.className = ColorBackPre + CacheUpgrades[me.name].color;
else if (CacheUpgrades[me.name].color === ColorGreen) green++; l(`upgrade${i}`).appendChild(div);
else if (CacheUpgrades[me.name].color === ColorYellow) yellow++; }
else if (CacheUpgrades[me.name].color === ColorOrange) orange++; if (CacheUpgrades[me.name].color === ColorBlue) blue++;
else if (CacheUpgrades[me.name].color === ColorRed) red++; else if (CacheUpgrades[me.name].color === ColorGreen) green++;
else if (CacheUpgrades[me.name].color === ColorPurple) purple++; else if (CacheUpgrades[me.name].color === ColorYellow) yellow++;
else if (CacheUpgrades[me.name].color === ColorGray) gray++; else if (CacheUpgrades[me.name].color === ColorOrange) orange++;
} else if (CacheUpgrades[me.name].color === ColorRed) red++;
else if (CacheUpgrades[me.name].color === ColorPurple) purple++;
else if (CacheUpgrades[me.name].color === ColorGray) gray++;
}
l('CMUpgradeBarBlue').textContent = blue; l('CMUpgradeBarBlue').textContent = blue;
l('CMUpgradeBarGreen').textContent = green; l('CMUpgradeBarGreen').textContent = green;
l('CMUpgradeBarYellow').textContent = yellow; l('CMUpgradeBarYellow').textContent = yellow;
l('CMUpgradeBarOrange').textContent = orange; l('CMUpgradeBarOrange').textContent = orange;
l('CMUpgradeBarRed').textContent = red; l('CMUpgradeBarRed').textContent = red;
l('CMUpgradeBarPurple').textContent = purple; l('CMUpgradeBarPurple').textContent = purple;
l('CMUpgradeBarGray').textContent = gray; l('CMUpgradeBarGray').textContent = gray;
} }
const arr = []; const arr = [];
// Build array of pointers, sort by pp, set flex positions // Build array of pointers, sort by pp, set flex positions
// This regulates sorting of upgrades // This regulates sorting of upgrades
for (let x = 0; x < Game.UpgradesInStore.length; x++) { for (let x = 0; x < Game.UpgradesInStore.length; x++) {
const o = {}; const o = {};
o.name = Game.UpgradesInStore[x].name; o.name = Game.UpgradesInStore[x].name;
o.price = Game.UpgradesInStore[x].basePrice; o.price = Game.UpgradesInStore[x].basePrice;
o.pp = CacheUpgrades[o.name].pp; o.pp = CacheUpgrades[o.name].pp;
arr.push(o); arr.push(o);
} }
if (CMOptions.SortUpgrades) { if (CMOptions.SortUpgrades) {
arr.sort(function (a, b) { return (Colors.indexOf(a.color) > Colors.indexOf(b.color) ? 1 : (Colors.indexOf(a.color) < Colors.indexOf(b.color) ? -1 : (a.pp < b.pp) ? -1 : 0)); }); arr.sort(function (a, b) {
} else { return Colors.indexOf(a.color) > Colors.indexOf(b.color)
arr.sort((a, b) => a.price - b.price); ? 1
} : Colors.indexOf(a.color) < Colors.indexOf(b.color)
? -1
: a.pp < b.pp
? -1
: 0;
});
} else {
arr.sort((a, b) => a.price - b.price);
}
const nameChecker = function (arr2, upgrade) { const nameChecker = function (arr2, upgrade) {
return arr2.findIndex((e) => e.name === upgrade.name); return arr2.findIndex((e) => e.name === upgrade.name);
}; };
for (let x = 0; x < Game.UpgradesInStore.length; x++) { for (let x = 0; x < Game.UpgradesInStore.length; x++) {
l(`upgrade${x}`).style.order = nameChecker(arr, Game.UpgradesInStore[x]) + 1; l(`upgrade${x}`).style.order =
} nameChecker(arr, Game.UpgradesInStore[x]) + 1;
}
} }

View File

@@ -4,32 +4,40 @@ import CacheDragonCost from '../../Cache/Dragon/Dragon';
import { CacheCostDragonUpgrade } from '../../Cache/VariablesAndData'; import { CacheCostDragonUpgrade } from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import CalculateChangeAura from '../../Sim/SimulationEvents/AuraChange'; import CalculateChangeAura from '../../Sim/SimulationEvents/AuraChange';
import { Beautify, FormatTime } from '../BeautifyAndFormatting/BeautifyFormatting'; import {
Beautify,
FormatTime,
} from '../BeautifyAndFormatting/BeautifyFormatting';
/** /**
* This functions adds the two extra lines about CPS and time to recover to the aura picker infoscreen * This functions adds the two extra lines about CPS and time to recover to the aura picker infoscreen
* @param {number} aura The number of the aura currently selected by the mouse/user * @param {number} aura The number of the aura currently selected by the mouse/user
*/ */
export function AddAuraInfo(aura) { export function AddAuraInfo(aura) {
if (CMOptions.DragonAuraInfo === 1) { if (CMOptions.DragonAuraInfo === 1) {
const [bonusCPS, priceOfChange] = CalculateChangeAura(aura); const [bonusCPS, priceOfChange] = CalculateChangeAura(aura);
const timeToRecover = FormatTime(priceOfChange / (bonusCPS + Game.cookiesPs)); const timeToRecover = FormatTime(
const bonusCPSPercentage = Beautify(bonusCPS / Game.cookiesPs); priceOfChange / (bonusCPS + Game.cookiesPs),
);
const bonusCPSPercentage = Beautify(bonusCPS / Game.cookiesPs);
l('dragonAuraInfo').style.minHeight = '60px'; l('dragonAuraInfo').style.minHeight = '60px';
l('dragonAuraInfo').style.margin = '8px'; l('dragonAuraInfo').style.margin = '8px';
l('dragonAuraInfo').appendChild(document.createElement('div')).className = 'line'; l('dragonAuraInfo').appendChild(document.createElement('div')).className =
const div = document.createElement('div'); 'line';
div.style.minWidth = '200px'; const div = document.createElement('div');
div.style.textAlign = 'center'; div.style.minWidth = '200px';
div.textContent = `Picking this aura will change CPS by ${Beautify(bonusCPS)} (${bonusCPSPercentage}% of current CPS).`; div.style.textAlign = 'center';
l('dragonAuraInfo').appendChild(div); div.textContent = `Picking this aura will change CPS by ${Beautify(
const div2 = document.createElement('div'); bonusCPS,
div2.style.minWidth = '200px'; )} (${bonusCPSPercentage}% of current CPS).`;
div2.style.textAlign = 'center'; l('dragonAuraInfo').appendChild(div);
div2.textContent = `It will take ${timeToRecover} to recover the cost.`; const div2 = document.createElement('div');
l('dragonAuraInfo').appendChild(div2); div2.style.minWidth = '200px';
} div2.style.textAlign = 'center';
div2.textContent = `It will take ${timeToRecover} to recover the cost.`;
l('dragonAuraInfo').appendChild(div2);
}
} }
/** /**
@@ -37,18 +45,27 @@ export function AddAuraInfo(aura) {
* It is called by Game.ToggleSpecialMenu() after CM.Main.ReplaceNative() * It is called by Game.ToggleSpecialMenu() after CM.Main.ReplaceNative()
*/ */
export function AddDragonLevelUpTooltip() { export function AddDragonLevelUpTooltip() {
// Check if it is the dragon popup that is on screen // Check if it is the dragon popup that is on screen
if ((l('specialPopup').className.match(/onScreen/) && l('specialPopup').children[0].style.background.match(/dragon/)) !== null) { if (
for (let i = 0; i < l('specialPopup').childNodes.length; i++) { (l('specialPopup').className.match(/onScreen/) &&
if (l('specialPopup').childNodes[i].className === 'optionBox') { l('specialPopup').children[0].style.background.match(/dragon/)) !== null
l('specialPopup').children[i].onmouseover = function () { ) {
CacheDragonCost(); for (let i = 0; i < l('specialPopup').childNodes.length; i++) {
Game.tooltip.dynamic = 1; if (l('specialPopup').childNodes[i].className === 'optionBox') {
Game.tooltip.draw(l('specialPopup'), `<div style="min-width:200px;text-align:center;">${CacheCostDragonUpgrade}</div>`, 'this'); l('specialPopup').children[i].onmouseover = function () {
Game.tooltip.wobble(); CacheDragonCost();
}; Game.tooltip.dynamic = 1;
l('specialPopup').children[i].onmouseout = function () { Game.tooltip.shouldHide = 1; }; Game.tooltip.draw(
} l('specialPopup'),
} `<div style="min-width:200px;text-align:center;">${CacheCostDragonUpgrade}</div>`,
} 'this',
);
Game.tooltip.wobble();
};
l('specialPopup').children[i].onmouseout = function () {
Game.tooltip.shouldHide = 1;
};
}
}
}
} }

View File

@@ -6,44 +6,55 @@ import { UpdateBotBar } from './InfoBars/BottomBar';
import { UpdateTimerBar } from './InfoBars/TimerBar'; import { UpdateTimerBar } from './InfoBars/TimerBar';
import RefreshMenu from './MenuSections/Refreshmenu'; import RefreshMenu from './MenuSections/Refreshmenu';
import { UpdateTooltips } from './Tooltips/Tooltip'; import { UpdateTooltips } from './Tooltips/Tooltip';
import { CheckWrinklerTooltip, UpdateWrinklerTooltip } from './Tooltips/WrinklerTooltips'; import {
CheckWrinklerTooltip,
UpdateWrinklerTooltip,
} from './Tooltips/WrinklerTooltips';
/** /**
* This function handles all custom drawing for the Game.Draw() function. * This function handles all custom drawing for the Game.Draw() function.
* It is hooked on 'draw' by CM.RegisterHooks() * It is hooked on 'draw' by CM.RegisterHooks()
*/ */
export default function Draw() { export default function Draw() {
// Draw autosave timer in stats menu, this must be done here to make it count down correctly // Draw autosave timer in stats menu, this must be done here to make it count down correctly
if ( if (
(Game.prefs.autosave && Game.drawT % 10 === 0) // with autosave ON and every 10 ticks Game.prefs.autosave &&
&& (Game.onMenu === 'stats' && CMOptions.Stats) // while being on the stats menu only Game.drawT % 10 === 0 && // with autosave ON and every 10 ticks
) { Game.onMenu === 'stats' &&
const timer = document.getElementById('CMStatsAutosaveTimer'); CMOptions.Stats // while being on the stats menu only
if (timer) { ) {
timer.innerText = Game.sayTime(Game.fps * 60 - (Game.T % (Game.fps * 60)), 4); const timer = document.getElementById('CMStatsAutosaveTimer');
} if (timer) {
} timer.innerText = Game.sayTime(
Game.fps * 60 - (Game.T % (Game.fps * 60)),
4,
);
}
}
// Update colors // Update colors
UpdateBuildings(); UpdateBuildings();
UpdateUpgrades(); UpdateUpgrades();
// Redraw timers // Redraw timers
UpdateTimerBar(); UpdateTimerBar();
// Update Bottom Bar // Update Bottom Bar
UpdateBotBar(); UpdateBotBar();
// Update Tooltip // Update Tooltip
UpdateTooltips(); UpdateTooltips();
// Update Wrinkler Tooltip // Update Wrinkler Tooltip
CheckWrinklerTooltip(); CheckWrinklerTooltip();
UpdateWrinklerTooltip(); UpdateWrinklerTooltip();
// Change menu refresh interval // Change menu refresh interval
RefreshMenu(); RefreshMenu();
// Replace Cookies counter because Orteil uses very weird code to "pad" it... // Replace Cookies counter because Orteil uses very weird code to "pad" it...
l('cookies').innerHTML = l('cookies').innerHTML.replace(/.*(?=<br>)/i, Beautify(Game.cookies)); l('cookies').innerHTML = l('cookies').innerHTML.replace(
/.*(?=<br>)/i,
Beautify(Game.cookies),
);
} }

View File

@@ -8,25 +8,35 @@ import { GCTimers } from '../VariablesAndData';
* @param {object} cookie A Golden Cookie object * @param {object} cookie A Golden Cookie object
*/ */
export default function CreateGCTimer(cookie) { export default function CreateGCTimer(cookie) {
const GCTimer = document.createElement('div'); const GCTimer = document.createElement('div');
GCTimer.id = `GCTimer${cookie.id}`; GCTimer.id = `GCTimer${cookie.id}`;
GCTimer.style.width = '96px'; GCTimer.style.width = '96px';
GCTimer.style.height = '96px'; GCTimer.style.height = '96px';
GCTimer.style.position = 'absolute'; GCTimer.style.position = 'absolute';
GCTimer.style.zIndex = '10000000001'; GCTimer.style.zIndex = '10000000001';
GCTimer.style.textAlign = 'center'; GCTimer.style.textAlign = 'center';
GCTimer.style.lineHeight = '96px'; GCTimer.style.lineHeight = '96px';
GCTimer.style.fontFamily = '"Kavoon", Georgia, serif'; GCTimer.style.fontFamily = '"Kavoon", Georgia, serif';
GCTimer.style.fontSize = '35px'; GCTimer.style.fontSize = '35px';
GCTimer.style.cursor = 'pointer'; GCTimer.style.cursor = 'pointer';
GCTimer.style.display = 'block'; GCTimer.style.display = 'block';
if (CMOptions.GCTimer === 0) GCTimer.style.display = 'none'; if (CMOptions.GCTimer === 0) GCTimer.style.display = 'none';
GCTimer.style.left = cookie.l.style.left; GCTimer.style.left = cookie.l.style.left;
GCTimer.style.top = cookie.l.style.top; GCTimer.style.top = cookie.l.style.top;
GCTimer.onclick = function () { cookie.pop(); }; GCTimer.onclick = function () {
GCTimer.onmouseover = function () { cookie.l.style.filter = 'brightness(125%) drop-shadow(0px 0px 3px rgba(255,255,255,1))'; cookie.l.style.webkitFilter = 'brightness(125%) drop-shadow(0px 0px 3px rgba(255,255,255,1))'; }; cookie.pop();
GCTimer.onmouseout = function () { cookie.l.style.filter = ''; cookie.l.style.webkitFilter = ''; }; };
GCTimer.onmouseover = function () {
cookie.l.style.filter =
'brightness(125%) drop-shadow(0px 0px 3px rgba(255,255,255,1))';
cookie.l.style.webkitFilter =
'brightness(125%) drop-shadow(0px 0px 3px rgba(255,255,255,1))';
};
GCTimer.onmouseout = function () {
cookie.l.style.filter = '';
cookie.l.style.webkitFilter = '';
};
GCTimers[cookie.id] = GCTimer; GCTimers[cookie.id] = GCTimer;
l('shimmers').appendChild(GCTimer); l('shimmers').appendChild(GCTimer);
} }

View File

@@ -5,11 +5,16 @@
* @param {number} targetMagic The target magic level * @param {number} targetMagic The target magic level
* @returns {number} count / Game.fps The time it takes to reach targetMagic * @returns {number} count / Game.fps The time it takes to reach targetMagic
*/ */
export default function CalculateGrimoireRefillTime(currentMagic, maxMagic, targetMagic) { export default function CalculateGrimoireRefillTime(
let count = 0; currentMagic,
while (currentMagic < targetMagic) { maxMagic,
currentMagic += Math.max(0.002, (currentMagic / Math.max(maxMagic, 100)) ** 0.5) * 0.002; targetMagic,
count++; ) {
} let count = 0;
return count / Game.fps; while (currentMagic < targetMagic) {
currentMagic +=
Math.max(0.002, (currentMagic / Math.max(maxMagic, 100)) ** 0.5) * 0.002;
count++;
}
return count / Game.fps;
} }

View File

@@ -1,5 +1,8 @@
import { import {
CacheAverageCPS, CacheCurrWrinklerCount, CacheCurrWrinklerCPSMult, CacheWrinklersFattest, CacheAverageCPS,
CacheCurrWrinklerCount,
CacheCurrWrinklerCPSMult,
CacheWrinklersFattest,
} from '../../Cache/VariablesAndData'; } from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
@@ -8,14 +11,31 @@ import { CMOptions } from '../../Config/VariablesAndData';
* @returns {number} The average or current cps * @returns {number} The average or current cps
*/ */
export default function GetCPS() { export default function GetCPS() {
if (CMOptions.CPSMode) { if (CMOptions.CPSMode) {
return CacheAverageCPS; return CacheAverageCPS;
} if (CMOptions.CalcWrink === 0) { }
return (Game.cookiesPs * (1 - Game.cpsSucked)); if (CMOptions.CalcWrink === 0) {
} if (CMOptions.CalcWrink === 1) { return Game.cookiesPs * (1 - Game.cpsSucked);
return Game.cookiesPs * (CacheCurrWrinklerCPSMult + (1 - (CacheCurrWrinklerCount * 0.05))); }
} if (CMOptions.CalcWrink === 2 && Game.wrinklers[CacheWrinklersFattest[1]].type === 1) { if (CMOptions.CalcWrink === 1) {
return Game.cookiesPs * ((CacheCurrWrinklerCPSMult * 3 / CacheCurrWrinklerCount) + (1 - (CacheCurrWrinklerCount * 0.05))); return (
} Game.cookiesPs *
return Game.cookiesPs * ((CacheCurrWrinklerCPSMult / CacheCurrWrinklerCount) + (1 - (CacheCurrWrinklerCount * 0.05))); (CacheCurrWrinklerCPSMult + (1 - CacheCurrWrinklerCount * 0.05))
);
}
if (
CMOptions.CalcWrink === 2 &&
Game.wrinklers[CacheWrinklersFattest[1]].type === 1
) {
return (
Game.cookiesPs *
((CacheCurrWrinklerCPSMult * 3) / CacheCurrWrinklerCount +
(1 - CacheCurrWrinklerCount * 0.05))
);
}
return (
Game.cookiesPs *
(CacheCurrWrinklerCPSMult / CacheCurrWrinklerCount +
(1 - CacheCurrWrinklerCount * 0.05))
);
} }

View File

@@ -1,5 +1,10 @@
import { import {
ColorGray, ColorGreen, ColorOrange, ColorPurple, ColorRed, ColorYellow, ColorGray,
ColorGreen,
ColorOrange,
ColorPurple,
ColorRed,
ColorYellow,
} from '../VariablesAndData'; } from '../VariablesAndData';
/** /**
@@ -9,16 +14,20 @@ import {
* @returns {{string}, {string}} text, color An array containing the text and display-color of the sugar lump * @returns {{string}, {string}} text, color An array containing the text and display-color of the sugar lump
*/ */
export default function GetLumpColor(type) { export default function GetLumpColor(type) {
if (type === 0) { if (type === 0) {
return { text: 'Normal', color: ColorGray }; return { text: 'Normal', color: ColorGray };
} if (type === 1) { }
return { text: 'Bifurcated', color: ColorGreen }; if (type === 1) {
} if (type === 2) { return { text: 'Bifurcated', color: ColorGreen };
return { text: 'Golden', color: ColorYellow }; }
} if (type === 3) { if (type === 2) {
return { text: 'Meaty', color: ColorOrange }; return { text: 'Golden', color: ColorYellow };
} if (type === 4) { }
return { text: 'Caramelized', color: ColorPurple }; if (type === 3) {
} return { text: 'Meaty', color: ColorOrange };
return { text: 'Unknown Sugar Lump', color: ColorRed }; }
if (type === 4) {
return { text: 'Caramelized', color: ColorPurple };
}
return { text: 'Unknown Sugar Lump', color: ColorRed };
} }

View File

@@ -1,4 +1,7 @@
import { CacheWrinklersFattest, CacheWrinklersTotal } from '../../Cache/VariablesAndData'; import {
CacheWrinklersFattest,
CacheWrinklersTotal,
} from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
/** /**
@@ -7,10 +10,11 @@ import { CMOptions } from '../../Config/VariablesAndData';
* @returns {number} 0 or the amount of cookies stored (CM.Cache.WrinklersTotal) * @returns {number} 0 or the amount of cookies stored (CM.Cache.WrinklersTotal)
*/ */
export default function GetWrinkConfigBank() { export default function GetWrinkConfigBank() {
if (CMOptions.CalcWrink === 1) { if (CMOptions.CalcWrink === 1) {
return CacheWrinklersTotal; return CacheWrinklersTotal;
} if (CMOptions.CalcWrink === 2) { }
return CacheWrinklersFattest[0]; if (CMOptions.CalcWrink === 2) {
} return CacheWrinklersFattest[0];
return 0; }
return 0;
} }

View File

@@ -3,9 +3,9 @@
* It is called by a click of the 'pop all' button created by CM.Disp.AddMenuStats() * It is called by a click of the 'pop all' button created by CM.Disp.AddMenuStats()
*/ */
export default function PopAllNormalWrinklers() { export default function PopAllNormalWrinklers() {
for (const i of Object.keys(Game.wrinklers)) { for (const i of Object.keys(Game.wrinklers)) {
if (Game.wrinklers[i].sucked > 0 && Game.wrinklers[i].type === 0) { if (Game.wrinklers[i].sucked > 0 && Game.wrinklers[i].type === 0) {
Game.wrinklers[i].hp = 0; Game.wrinklers[i].hp = 0;
} }
} }
} }

View File

@@ -7,11 +7,11 @@ import { UpdateBotBar } from '../InfoBars/BottomBar';
* It is therefore called by a changes in CM.Options.Scale, CM.Options.ScaleDecimals, CM.Options.ScaleSeparator and CM.Options.ScaleCutoff * It is therefore called by a changes in CM.Options.Scale, CM.Options.ScaleDecimals, CM.Options.ScaleSeparator and CM.Options.ScaleCutoff
*/ */
export default function RefreshScale() { export default function RefreshScale() {
BeautifyAll(); BeautifyAll();
Game.RefreshStore(); Game.RefreshStore();
Game.RebuildUpgrades(); Game.RebuildUpgrades();
UpdateBotBar(); UpdateBotBar();
UpdateBuildings(); UpdateBuildings();
UpdateUpgrades(); UpdateUpgrades();
} }

View File

@@ -8,13 +8,13 @@ import UpdateBackground from './UpdateBackground';
* It is called by CM.Disp.Draw() * It is called by CM.Disp.Draw()
*/ */
export default function UpdateAscendState() { export default function UpdateAscendState() {
if (Game.OnAscend) { if (Game.OnAscend) {
l('game').style.bottom = '0px'; l('game').style.bottom = '0px';
if (CMOptions.BotBar === 1) l('CMBotBar').style.display = 'none'; if (CMOptions.BotBar === 1) l('CMBotBar').style.display = 'none';
if (CMOptions.TimerBar === 1) l('CMTimerBar').style.display = 'none'; if (CMOptions.TimerBar === 1) l('CMTimerBar').style.display = 'none';
} else { } else {
ToggleBotBar(); ToggleBotBar();
ToggleTimerBar(); ToggleTimerBar();
} }
UpdateBackground(); UpdateBackground();
} }

View File

@@ -4,8 +4,11 @@
* It is called by CM.Disp.UpdateAscendState() and CM.Disp.UpdateBotTimerBarPosition() * It is called by CM.Disp.UpdateAscendState() and CM.Disp.UpdateBotTimerBarPosition()
*/ */
export default function UpdateBackground() { export default function UpdateBackground() {
Game.Background.canvas.width = Game.Background.canvas.parentNode.offsetWidth; Game.Background.canvas.width = Game.Background.canvas.parentNode.offsetWidth;
Game.Background.canvas.height = Game.Background.canvas.parentNode.offsetHeight; Game.Background.canvas.height =
Game.LeftBackground.canvas.width = Game.LeftBackground.canvas.parentNode.offsetWidth; Game.Background.canvas.parentNode.offsetHeight;
Game.LeftBackground.canvas.height = Game.LeftBackground.canvas.parentNode.offsetHeight; Game.LeftBackground.canvas.width =
Game.LeftBackground.canvas.parentNode.offsetWidth;
Game.LeftBackground.canvas.height =
Game.LeftBackground.canvas.parentNode.offsetHeight;
} }

View File

@@ -1,7 +1,10 @@
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import UpdateBuildings from '../BuildingsUpgrades/Buildings'; import UpdateBuildings from '../BuildingsUpgrades/Buildings';
import { import {
ColorBackPre, ColorBorderPre, Colors, ColorTextPre, ColorBackPre,
ColorBorderPre,
Colors,
ColorTextPre,
} from '../VariablesAndData'; } from '../VariablesAndData';
/** /**
@@ -9,16 +12,22 @@ import {
* The function is therefore called by a change in CM.Options.Colors * The function is therefore called by a change in CM.Options.Colors
*/ */
export default function UpdateColors() { export default function UpdateColors() {
let str = ''; let str = '';
for (let i = 0; i < Colors.length; i++) { for (let i = 0; i < Colors.length; i++) {
str += `.${ColorTextPre}${Colors[i]} { color: ${CMOptions.Colors[Colors[i]]}; }\n`; str += `.${ColorTextPre}${Colors[i]} { color: ${
} CMOptions.Colors[Colors[i]]
for (let i = 0; i < Colors.length; i++) { }; }\n`;
str += `.${ColorBackPre}${Colors[i]} { background-color: ${CMOptions.Colors[Colors[i]]}; }\n`; }
} for (let i = 0; i < Colors.length; i++) {
for (let i = 0; i < Colors.length; i++) { str += `.${ColorBackPre}${Colors[i]} { background-color: ${
str += `.${ColorBorderPre}${Colors[i]} { border: 1px solid ${CMOptions.Colors[Colors[i]]}; }\n`; CMOptions.Colors[Colors[i]]
} }; }\n`;
l('CMCSS').textContent = str; }
UpdateBuildings(); // Class has been already set for (let i = 0; i < Colors.length; i++) {
str += `.${ColorBorderPre}${Colors[i]} { border: 1px solid ${
CMOptions.Colors[Colors[i]]
}; }\n`;
}
l('CMCSS').textContent = str;
UpdateBuildings(); // Class has been already set
} }

View File

@@ -1,13 +1,23 @@
/** Functions related to the Bottom Bar */ /** Functions related to the Bottom Bar */
import { CacheObjects1, CacheObjects10, CacheObjects100 } from '../../Cache/VariablesAndData'; import {
CacheObjects1,
CacheObjects10,
CacheObjects100,
} from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import { VersionMajor, VersionMinor } from '../../Data/Moddata'; import { VersionMajor, VersionMinor } from '../../Data/Moddata';
import { Beautify, GetTimeColor } from '../BeautifyAndFormatting/BeautifyFormatting'; import {
Beautify,
GetTimeColor,
} from '../BeautifyAndFormatting/BeautifyFormatting';
import GetCPS from '../HelperFunctions/GetCPS'; import GetCPS from '../HelperFunctions/GetCPS';
import GetWrinkConfigBank from '../HelperFunctions/GetWrinkConfigBank'; import GetWrinkConfigBank from '../HelperFunctions/GetWrinkConfigBank';
import { import {
ColorBlue, ColorTextPre, ColorYellow, LastTargetBotBar, ColorBlue,
ColorTextPre,
ColorYellow,
LastTargetBotBar,
} from '../VariablesAndData'; } from '../VariablesAndData';
import { CreateBotBarBuildingColumn } from './CreateDOMElements'; import { CreateBotBarBuildingColumn } from './CreateDOMElements';
@@ -15,74 +25,96 @@ import { CreateBotBarBuildingColumn } from './CreateDOMElements';
* This function creates the bottom bar and appends it to l('wrapper') * This function creates the bottom bar and appends it to l('wrapper')
*/ */
export function CreateBotBar() { export function CreateBotBar() {
const BotBar = document.createElement('div'); const BotBar = document.createElement('div');
BotBar.id = 'CMBotBar'; BotBar.id = 'CMBotBar';
BotBar.style.height = '69px'; BotBar.style.height = '69px';
BotBar.style.width = '100%'; BotBar.style.width = '100%';
BotBar.style.position = 'absolute'; BotBar.style.position = 'absolute';
BotBar.style.display = 'none'; BotBar.style.display = 'none';
BotBar.style.backgroundColor = '#262224'; BotBar.style.backgroundColor = '#262224';
BotBar.style.backgroundImage = 'linear-gradient(to bottom, #4d4548, #000000)'; BotBar.style.backgroundImage = 'linear-gradient(to bottom, #4d4548, #000000)';
BotBar.style.borderTop = '1px solid black'; BotBar.style.borderTop = '1px solid black';
BotBar.style.overflow = 'auto'; BotBar.style.overflow = 'auto';
BotBar.style.textShadow = '-1px 0 black, 0 1px black, 1px 0 black, 0 -1px black'; BotBar.style.textShadow =
'-1px 0 black, 0 1px black, 1px 0 black, 0 -1px black';
const table = BotBar.appendChild(document.createElement('table')); const table = BotBar.appendChild(document.createElement('table'));
table.style.width = '100%'; table.style.width = '100%';
table.style.textAlign = 'center'; table.style.textAlign = 'center';
table.style.whiteSpace = 'nowrap'; table.style.whiteSpace = 'nowrap';
const tbody = table.appendChild(document.createElement('tbody')); const tbody = table.appendChild(document.createElement('tbody'));
const firstCol = function (text, color) { const firstCol = function (text, color) {
const td = document.createElement('td'); const td = document.createElement('td');
td.style.textAlign = 'right'; td.style.textAlign = 'right';
td.className = ColorTextPre + color; td.className = ColorTextPre + color;
td.textContent = text; td.textContent = text;
return td; return td;
}; };
const type = tbody.appendChild(document.createElement('tr')); const type = tbody.appendChild(document.createElement('tr'));
type.style.fontWeight = 'bold'; type.style.fontWeight = 'bold';
type.appendChild(firstCol(`CM ${VersionMajor}.${VersionMinor}`, ColorYellow)); type.appendChild(firstCol(`CM ${VersionMajor}.${VersionMinor}`, ColorYellow));
const bonus = tbody.appendChild(document.createElement('tr')); const bonus = tbody.appendChild(document.createElement('tr'));
bonus.appendChild(firstCol('Bonus Income', ColorBlue)); bonus.appendChild(firstCol('Bonus Income', ColorBlue));
const pp = tbody.appendChild(document.createElement('tr')); const pp = tbody.appendChild(document.createElement('tr'));
pp.appendChild(firstCol('Payback Period', ColorBlue)); pp.appendChild(firstCol('Payback Period', ColorBlue));
const time = tbody.appendChild(document.createElement('tr')); const time = tbody.appendChild(document.createElement('tr'));
time.appendChild(firstCol('Time Left', ColorBlue)); time.appendChild(firstCol('Time Left', ColorBlue));
l('wrapper').appendChild(BotBar); l('wrapper').appendChild(BotBar);
for (const i of Object.keys(Game.Objects)) { for (const i of Object.keys(Game.Objects)) {
CreateBotBarBuildingColumn(i); CreateBotBarBuildingColumn(i);
} }
} }
/** /**
* This function updates the bonus-, pp-, and time-rows in the the bottom bar * This function updates the bonus-, pp-, and time-rows in the the bottom bar
*/ */
export function UpdateBotBar() { export function UpdateBotBar() {
if (CMOptions.BotBar === 1 && CacheObjects1 && Game.buyMode === 1) { if (CMOptions.BotBar === 1 && CacheObjects1 && Game.buyMode === 1) {
let count = 0; let count = 0;
for (const i of Object.keys(CacheObjects1)) { for (const i of Object.keys(CacheObjects1)) {
let target = Game.buyBulk; let target = Game.buyBulk;
if (Game.buyMode === 1) { if (Game.buyMode === 1) {
LastTargetBotBar = target; LastTargetBotBar = target;
} else { } else {
target = LastTargetBotBar; target = LastTargetBotBar;
} }
if (target === 1) target = CacheObjects1; if (target === 1) target = CacheObjects1;
if (target === 10) target = CacheObjects10; if (target === 10) target = CacheObjects10;
if (target === 100) target = CacheObjects100; if (target === 100) target = CacheObjects100;
count++; count++;
l('CMBotBar').firstChild.firstChild.childNodes[0].childNodes[count].childNodes[1].textContent = Game.Objects[i].amount; l('CMBotBar').firstChild.firstChild.childNodes[0].childNodes[
l('CMBotBar').firstChild.firstChild.childNodes[1].childNodes[count].textContent = Beautify(target[i].bonus, 2); count
l('CMBotBar').firstChild.firstChild.childNodes[2].childNodes[count].className = ColorTextPre + target[i].color; ].childNodes[1].textContent = Game.Objects[i].amount;
l('CMBotBar').firstChild.firstChild.childNodes[2].childNodes[count].textContent = Beautify(target[i].pp, 2); l('CMBotBar').firstChild.firstChild.childNodes[1].childNodes[
const timeColor = GetTimeColor((Game.Objects[i].bulkPrice - (Game.cookies + GetWrinkConfigBank())) / GetCPS()); count
l('CMBotBar').firstChild.firstChild.childNodes[3].childNodes[count].className = ColorTextPre + timeColor.color; ].textContent = Beautify(target[i].bonus, 2);
if (timeColor.text === 'Done!' && Game.cookies < Game.Objects[i].bulkPrice) { l('CMBotBar').firstChild.firstChild.childNodes[2].childNodes[
l('CMBotBar').firstChild.firstChild.childNodes[3].childNodes[count].textContent = `${timeColor.text} (with Wrink)`; count
} else l('CMBotBar').firstChild.firstChild.childNodes[3].childNodes[count].textContent = timeColor.text; ].className = ColorTextPre + target[i].color;
} l('CMBotBar').firstChild.firstChild.childNodes[2].childNodes[
} count
].textContent = Beautify(target[i].pp, 2);
const timeColor = GetTimeColor(
(Game.Objects[i].bulkPrice - (Game.cookies + GetWrinkConfigBank())) /
GetCPS(),
);
l('CMBotBar').firstChild.firstChild.childNodes[3].childNodes[
count
].className = ColorTextPre + timeColor.color;
if (
timeColor.text === 'Done!' &&
Game.cookies < Game.Objects[i].bulkPrice
) {
l('CMBotBar').firstChild.firstChild.childNodes[3].childNodes[
count
].textContent = `${timeColor.text} (with Wrink)`;
} else
l('CMBotBar').firstChild.firstChild.childNodes[3].childNodes[
count
].textContent = timeColor.text;
}
}
} }

View File

@@ -9,58 +9,58 @@ import { ColorBackPre, ColorBlue, ColorTextPre } from '../VariablesAndData';
* @param [{{string}, {string}}, ...] bars ([id, color]) The id and colours of individual parts of the timer * @param [{{string}, {string}}, ...] bars ([id, color]) The id and colours of individual parts of the timer
*/ */
export function CreateTimer(id, name, bars) { export function CreateTimer(id, name, bars) {
const timerBar = document.createElement('div'); const timerBar = document.createElement('div');
timerBar.id = id; timerBar.id = id;
timerBar.style.height = '12px'; timerBar.style.height = '12px';
timerBar.style.margin = '0px 10px'; timerBar.style.margin = '0px 10px';
timerBar.style.position = 'relative'; timerBar.style.position = 'relative';
const div = document.createElement('div'); const div = document.createElement('div');
div.style.width = '100%'; div.style.width = '100%';
div.style.height = '10px'; div.style.height = '10px';
div.style.margin = 'auto'; div.style.margin = 'auto';
div.style.position = 'absolute'; div.style.position = 'absolute';
div.style.left = '0px'; div.style.left = '0px';
div.style.top = '0px'; div.style.top = '0px';
div.style.right = '0px'; div.style.right = '0px';
div.style.bottom = '0px'; div.style.bottom = '0px';
const type = document.createElement('span'); const type = document.createElement('span');
type.style.display = 'inline-block'; type.style.display = 'inline-block';
type.style.textAlign = 'right'; type.style.textAlign = 'right';
type.style.fontSize = '10px'; type.style.fontSize = '10px';
type.style.width = '108px'; type.style.width = '108px';
type.style.marginRight = '5px'; type.style.marginRight = '5px';
type.style.verticalAlign = 'text-top'; type.style.verticalAlign = 'text-top';
type.textContent = name; type.textContent = name;
div.appendChild(type); div.appendChild(type);
for (let i = 0; i < bars.length; i++) { for (let i = 0; i < bars.length; i++) {
const colorBar = document.createElement('span'); const colorBar = document.createElement('span');
colorBar.id = bars[i].id; colorBar.id = bars[i].id;
colorBar.style.display = 'inline-block'; colorBar.style.display = 'inline-block';
colorBar.style.height = '10px'; colorBar.style.height = '10px';
colorBar.style.verticalAlign = 'text-top'; colorBar.style.verticalAlign = 'text-top';
colorBar.style.textAlign = 'center'; colorBar.style.textAlign = 'center';
if (bars.length - 1 === i) { if (bars.length - 1 === i) {
colorBar.style.borderTopRightRadius = '10px'; colorBar.style.borderTopRightRadius = '10px';
colorBar.style.borderBottomRightRadius = '10px'; colorBar.style.borderBottomRightRadius = '10px';
} }
if (typeof bars[i].color !== 'undefined') { if (typeof bars[i].color !== 'undefined') {
colorBar.className = ColorBackPre + bars[i].color; colorBar.className = ColorBackPre + bars[i].color;
} }
div.appendChild(colorBar); div.appendChild(colorBar);
} }
const timer = document.createElement('span'); const timer = document.createElement('span');
timer.id = `${id}Time`; timer.id = `${id}Time`;
timer.style.marginLeft = '5px'; timer.style.marginLeft = '5px';
timer.style.verticalAlign = 'text-top'; timer.style.verticalAlign = 'text-top';
div.appendChild(timer); div.appendChild(timer);
timerBar.appendChild(div); timerBar.appendChild(div);
return timerBar; return timerBar;
} }
/** /**
@@ -68,22 +68,26 @@ export function CreateTimer(id, name, bars) {
* @param {string} buildingName Objectname to be added (e.g., "Cursor") * @param {string} buildingName Objectname to be added (e.g., "Cursor")
*/ */
export function CreateBotBarBuildingColumn(buildingName) { export function CreateBotBarBuildingColumn(buildingName) {
if (l('CMBotBar') !== null) { if (l('CMBotBar') !== null) {
const type = l('CMBotBar').firstChild.firstChild.childNodes[0]; const type = l('CMBotBar').firstChild.firstChild.childNodes[0];
const bonus = l('CMBotBar').firstChild.firstChild.childNodes[1]; const bonus = l('CMBotBar').firstChild.firstChild.childNodes[1];
const pp = l('CMBotBar').firstChild.firstChild.childNodes[2]; const pp = l('CMBotBar').firstChild.firstChild.childNodes[2];
const time = l('CMBotBar').firstChild.firstChild.childNodes[3]; const time = l('CMBotBar').firstChild.firstChild.childNodes[3];
const i = buildingName; const i = buildingName;
const header = type.appendChild(document.createElement('td')); const header = type.appendChild(document.createElement('td'));
header.appendChild(document.createTextNode(`${i.indexOf(' ') !== -1 ? i.substring(0, i.indexOf(' ')) : i} (`)); header.appendChild(
document.createTextNode(
`${i.indexOf(' ') !== -1 ? i.substring(0, i.indexOf(' ')) : i} (`,
),
);
const span = header.appendChild(document.createElement('span')); const span = header.appendChild(document.createElement('span'));
span.className = ColorTextPre + ColorBlue; span.className = ColorTextPre + ColorBlue;
header.appendChild(document.createTextNode(')')); header.appendChild(document.createTextNode(')'));
bonus.appendChild(document.createElement('td')); bonus.appendChild(document.createElement('td'));
pp.appendChild(document.createElement('td')); pp.appendChild(document.createElement('td'));
time.appendChild(document.createElement('td')); time.appendChild(document.createElement('td'));
} }
} }

View File

@@ -3,8 +3,12 @@
import { UpdateBotTimerBarPosition } from '../../Config/SpecificToggles'; import { UpdateBotTimerBarPosition } from '../../Config/SpecificToggles';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import { import {
BuffColors, BuffColors,
ColorBackPre, ColorGray, ColorOrange, ColorPurple, LastNumberOfTimers, ColorBackPre,
ColorGray,
ColorOrange,
ColorPurple,
LastNumberOfTimers,
} from '../VariablesAndData'; } from '../VariablesAndData';
import { CreateTimer } from './CreateDOMElements'; import { CreateTimer } from './CreateDOMElements';
@@ -12,111 +16,191 @@ import { CreateTimer } from './CreateDOMElements';
* This function creates the TimerBar and appends it to l('wrapper') * This function creates the TimerBar and appends it to l('wrapper')
*/ */
export function CreateTimerBar() { export function CreateTimerBar() {
const TimerBar = document.createElement('div'); const TimerBar = document.createElement('div');
TimerBar.id = 'CMTimerBar'; TimerBar.id = 'CMTimerBar';
TimerBar.style.position = 'absolute'; TimerBar.style.position = 'absolute';
TimerBar.style.display = 'none'; TimerBar.style.display = 'none';
TimerBar.style.height = '0px'; TimerBar.style.height = '0px';
TimerBar.style.fontSize = '10px'; TimerBar.style.fontSize = '10px';
TimerBar.style.fontWeight = 'bold'; TimerBar.style.fontWeight = 'bold';
TimerBar.style.backgroundColor = 'black'; TimerBar.style.backgroundColor = 'black';
// Create standard Golden Cookie bar // Create standard Golden Cookie bar
const CMTimerBarGC = CreateTimer('CMTimerBarGC', const CMTimerBarGC = CreateTimer('CMTimerBarGC', 'Next Cookie', [
'Next Cookie', { id: 'CMTimerBarGCMinBar', color: ColorGray },
[{ id: 'CMTimerBarGCMinBar', color: ColorGray }, { id: 'CMTimerBarGCBar', color: ColorPurple }]); { id: 'CMTimerBarGCBar', color: ColorPurple },
TimerBar.appendChild(CMTimerBarGC); ]);
TimerBar.appendChild(CMTimerBarGC);
// Create standard Reindeer bar // Create standard Reindeer bar
const CMTimerBarRen = CreateTimer('CMTimerBarRen', const CMTimerBarRen = CreateTimer('CMTimerBarRen', 'Next Reindeer', [
'Next Reindeer', { id: 'CMTimerBarRenMinBar', color: ColorGray },
[{ id: 'CMTimerBarRenMinBar', color: ColorGray }, { id: 'CMTimerBarRenBar', color: ColorOrange }]); { id: 'CMTimerBarRenBar', color: ColorOrange },
TimerBar.appendChild(CMTimerBarRen); ]);
const TimerBarBuffTimers = document.createElement('div'); TimerBar.appendChild(CMTimerBarRen);
TimerBarBuffTimers.id = 'CMTimerBarBuffTimers'; const TimerBarBuffTimers = document.createElement('div');
TimerBar.appendChild(TimerBarBuffTimers); TimerBarBuffTimers.id = 'CMTimerBarBuffTimers';
TimerBar.appendChild(TimerBarBuffTimers);
l('wrapper').appendChild(TimerBar); l('wrapper').appendChild(TimerBar);
} }
/** /**
* This function updates indivudual timers in the timer bar * This function updates indivudual timers in the timer bar
*/ */
export function UpdateTimerBar() { export function UpdateTimerBar() {
if (CMOptions.TimerBar === 1) { if (CMOptions.TimerBar === 1) {
// label width: 113, timer width: 30, div margin: 20 // label width: 113, timer width: 30, div margin: 20
const maxWidthTwoBar = l('CMTimerBar').offsetWidth - 163; const maxWidthTwoBar = l('CMTimerBar').offsetWidth - 163;
// label width: 113, div margin: 20, calculate timer width at runtime // label width: 113, div margin: 20, calculate timer width at runtime
const maxWidthOneBar = l('CMTimerBar').offsetWidth - 133; const maxWidthOneBar = l('CMTimerBar').offsetWidth - 133;
let numberOfTimers = 0; let numberOfTimers = 0;
// Regulates visibility of Golden Cookie timer // Regulates visibility of Golden Cookie timer
if (Game.shimmerTypes.golden.spawned === 0 && !Game.Has('Golden switch [off]')) { if (
l('CMTimerBarGC').style.display = ''; Game.shimmerTypes.golden.spawned === 0 &&
l('CMTimerBarGCMinBar').style.width = `${Math.round(Math.max(0, Game.shimmerTypes.golden.minTime - Game.shimmerTypes.golden.time) * maxWidthTwoBar / Game.shimmerTypes.golden.maxTime)}px`; !Game.Has('Golden switch [off]')
if (CMOptions.TimerBarOverlay >= 1) l('CMTimerBarGCMinBar').textContent = Math.ceil((Game.shimmerTypes.golden.minTime - Game.shimmerTypes.golden.time) / Game.fps); ) {
else l('CMTimerBarGCMinBar').textContent = ''; l('CMTimerBarGC').style.display = '';
if (Game.shimmerTypes.golden.minTime === Game.shimmerTypes.golden.maxTime) { l('CMTimerBarGCMinBar').style.width = `${Math.round(
l('CMTimerBarGCMinBar').style.borderTopRightRadius = '10px'; (Math.max(
l('CMTimerBarGCMinBar').style.borderBottomRightRadius = '10px'; 0,
} else { Game.shimmerTypes.golden.minTime - Game.shimmerTypes.golden.time,
l('CMTimerBarGCMinBar').style.borderTopRightRadius = ''; ) *
l('CMTimerBarGCMinBar').style.borderBottomRightRadius = ''; maxWidthTwoBar) /
} Game.shimmerTypes.golden.maxTime,
l('CMTimerBarGCBar').style.width = `${Math.round(Math.min(Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.minTime, Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.time) * maxWidthTwoBar / Game.shimmerTypes.golden.maxTime)}px`; )}px`;
if (CMOptions.TimerBarOverlay >= 1) l('CMTimerBarGCBar').textContent = Math.ceil(Math.min(Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.minTime, Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.time) / Game.fps); if (CMOptions.TimerBarOverlay >= 1)
else l('CMTimerBarGCBar').textContent = ''; l('CMTimerBarGCMinBar').textContent = Math.ceil(
l('CMTimerBarGCTime').textContent = Math.ceil((Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.time) / Game.fps); (Game.shimmerTypes.golden.minTime - Game.shimmerTypes.golden.time) /
numberOfTimers++; Game.fps,
} else l('CMTimerBarGC').style.display = 'none'; );
else l('CMTimerBarGCMinBar').textContent = '';
if (
Game.shimmerTypes.golden.minTime === Game.shimmerTypes.golden.maxTime
) {
l('CMTimerBarGCMinBar').style.borderTopRightRadius = '10px';
l('CMTimerBarGCMinBar').style.borderBottomRightRadius = '10px';
} else {
l('CMTimerBarGCMinBar').style.borderTopRightRadius = '';
l('CMTimerBarGCMinBar').style.borderBottomRightRadius = '';
}
l('CMTimerBarGCBar').style.width = `${Math.round(
(Math.min(
Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.minTime,
Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.time,
) *
maxWidthTwoBar) /
Game.shimmerTypes.golden.maxTime,
)}px`;
if (CMOptions.TimerBarOverlay >= 1)
l('CMTimerBarGCBar').textContent = Math.ceil(
Math.min(
Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.minTime,
Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.time,
) / Game.fps,
);
else l('CMTimerBarGCBar').textContent = '';
l('CMTimerBarGCTime').textContent = Math.ceil(
(Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.time) /
Game.fps,
);
numberOfTimers++;
} else l('CMTimerBarGC').style.display = 'none';
// Regulates visibility of Reindeer timer // Regulates visibility of Reindeer timer
if (Game.season === 'christmas' && Game.shimmerTypes.reindeer.spawned === 0) { if (
l('CMTimerBarRen').style.display = ''; Game.season === 'christmas' &&
l('CMTimerBarRenMinBar').style.width = `${Math.round(Math.max(0, Game.shimmerTypes.reindeer.minTime - Game.shimmerTypes.reindeer.time) * maxWidthTwoBar / Game.shimmerTypes.reindeer.maxTime)}px`; Game.shimmerTypes.reindeer.spawned === 0
if (CMOptions.TimerBarOverlay >= 1) l('CMTimerBarRenMinBar').textContent = Math.ceil((Game.shimmerTypes.reindeer.minTime - Game.shimmerTypes.reindeer.time) / Game.fps); ) {
else l('CMTimerBarRenMinBar').textContent = ''; l('CMTimerBarRen').style.display = '';
l('CMTimerBarRenBar').style.width = `${Math.round(Math.min(Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.minTime, Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.time) * maxWidthTwoBar / Game.shimmerTypes.reindeer.maxTime)}px`; l('CMTimerBarRenMinBar').style.width = `${Math.round(
if (CMOptions.TimerBarOverlay >= 1) l('CMTimerBarRenBar').textContent = Math.ceil(Math.min(Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.minTime, Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.time) / Game.fps); (Math.max(
else l('CMTimerBarRenBar').textContent = ''; 0,
l('CMTimerBarRenTime').textContent = Math.ceil((Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.time) / Game.fps); Game.shimmerTypes.reindeer.minTime - Game.shimmerTypes.reindeer.time,
numberOfTimers++; ) *
} else { maxWidthTwoBar) /
l('CMTimerBarRen').style.display = 'none'; Game.shimmerTypes.reindeer.maxTime,
} )}px`;
if (CMOptions.TimerBarOverlay >= 1)
l('CMTimerBarRenMinBar').textContent = Math.ceil(
(Game.shimmerTypes.reindeer.minTime -
Game.shimmerTypes.reindeer.time) /
Game.fps,
);
else l('CMTimerBarRenMinBar').textContent = '';
l('CMTimerBarRenBar').style.width = `${Math.round(
(Math.min(
Game.shimmerTypes.reindeer.maxTime -
Game.shimmerTypes.reindeer.minTime,
Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.time,
) *
maxWidthTwoBar) /
Game.shimmerTypes.reindeer.maxTime,
)}px`;
if (CMOptions.TimerBarOverlay >= 1)
l('CMTimerBarRenBar').textContent = Math.ceil(
Math.min(
Game.shimmerTypes.reindeer.maxTime -
Game.shimmerTypes.reindeer.minTime,
Game.shimmerTypes.reindeer.maxTime -
Game.shimmerTypes.reindeer.time,
) / Game.fps,
);
else l('CMTimerBarRenBar').textContent = '';
l('CMTimerBarRenTime').textContent = Math.ceil(
(Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.time) /
Game.fps,
);
numberOfTimers++;
} else {
l('CMTimerBarRen').style.display = 'none';
}
// On every frame all buff-timers are deleted and re-created // On every frame all buff-timers are deleted and re-created
const BuffTimerBars = {}; const BuffTimerBars = {};
l('CMTimerBarBuffTimers').innerHTML = ''; l('CMTimerBarBuffTimers').innerHTML = '';
for (const i of Object.keys(Game.buffs)) { for (const i of Object.keys(Game.buffs)) {
if (Game.buffs[i]) { if (Game.buffs[i]) {
const timer = CreateTimer(Game.buffs[i].name, Game.buffs[i].name, [{ id: `${Game.buffs[i].name}Bar` }]); const timer = CreateTimer(Game.buffs[i].name, Game.buffs[i].name, [
timer.style.display = ''; { id: `${Game.buffs[i].name}Bar` },
let classColor = ''; ]);
// Gives specific timers specific colors timer.style.display = '';
if (typeof BuffColors[Game.buffs[i].name] !== 'undefined') { let classColor = '';
classColor = BuffColors[Game.buffs[i].name]; // Gives specific timers specific colors
} else classColor = ColorPurple; if (typeof BuffColors[Game.buffs[i].name] !== 'undefined') {
timer.lastChild.children[1].className = ColorBackPre + classColor; classColor = BuffColors[Game.buffs[i].name];
timer.lastChild.children[1].style.color = 'black'; } else classColor = ColorPurple;
if (CMOptions.TimerBarOverlay === 2) timer.lastChild.children[1].textContent = `${Math.round(100 * (Game.buffs[i].time / Game.buffs[i].maxTime))}%`; timer.lastChild.children[1].className = ColorBackPre + classColor;
else timer.lastChild.children[1].textContent = ''; timer.lastChild.children[1].style.color = 'black';
timer.lastChild.children[1].style.width = `${Math.round(Game.buffs[i].time * (maxWidthOneBar - Math.ceil(Game.buffs[i].time / Game.fps).toString().length * 8) / Game.buffs[i].maxTime)}px`; if (CMOptions.TimerBarOverlay === 2)
timer.lastChild.children[2].textContent = Math.ceil(Game.buffs[i].time / Game.fps); timer.lastChild.children[1].textContent = `${Math.round(
numberOfTimers++; 100 * (Game.buffs[i].time / Game.buffs[i].maxTime),
BuffTimerBars[Game.buffs[i].name] = timer; )}%`;
} else timer.lastChild.children[1].textContent = '';
} timer.lastChild.children[1].style.width = `${Math.round(
for (const i of Object.keys(BuffTimerBars)) { (Game.buffs[i].time *
l('CMTimerBarBuffTimers').appendChild(BuffTimerBars[i]); (maxWidthOneBar -
} Math.ceil(Game.buffs[i].time / Game.fps).toString().length * 8)) /
Game.buffs[i].maxTime,
)}px`;
timer.lastChild.children[2].textContent = Math.ceil(
Game.buffs[i].time / Game.fps,
);
numberOfTimers++;
BuffTimerBars[Game.buffs[i].name] = timer;
}
}
for (const i of Object.keys(BuffTimerBars)) {
l('CMTimerBarBuffTimers').appendChild(BuffTimerBars[i]);
}
if (numberOfTimers !== 0) { if (numberOfTimers !== 0) {
l('CMTimerBar').style.height = `${numberOfTimers * 12 + 2}px`; l('CMTimerBar').style.height = `${numberOfTimers * 12 + 2}px`;
} }
if (LastNumberOfTimers !== numberOfTimers) { if (LastNumberOfTimers !== numberOfTimers) {
LastNumberOfTimers = numberOfTimers; LastNumberOfTimers = numberOfTimers;
UpdateBotTimerBarPosition(); UpdateBotTimerBarPosition();
} }
} }
} }

View File

@@ -5,16 +5,21 @@ import PopAllNormalWrinklers from '../HelperFunctions/PopWrinklers';
* This function creates two objects at the bottom of the left column that allowing popping of wrinklers * This function creates two objects at the bottom of the left column that allowing popping of wrinklers
*/ */
export default function CreateWrinklerButtons() { export default function CreateWrinklerButtons() {
const popAllA = document.createElement('a'); const popAllA = document.createElement('a');
popAllA.id = 'PopAllNormalWrinklerButton'; popAllA.id = 'PopAllNormalWrinklerButton';
popAllA.textContent = 'Pop All Normal'; popAllA.textContent = 'Pop All Normal';
popAllA.className = 'option'; popAllA.className = 'option';
popAllA.onclick = function () { PopAllNormalWrinklers(); }; popAllA.onclick = function () {
l('sectionLeftExtra').children[0].append(popAllA); PopAllNormalWrinklers();
const popFattestA = document.createElement('a'); };
popFattestA.id = 'PopFattestWrinklerButton'; l('sectionLeftExtra').children[0].append(popAllA);
popFattestA.textContent = 'Pop Single Fattest'; const popFattestA = document.createElement('a');
popFattestA.className = 'option'; popFattestA.id = 'PopFattestWrinklerButton';
popFattestA.onclick = function () { if (CacheWrinklersFattest[1] !== null) Game.wrinklers[CacheWrinklersFattest[1]].hp = 0; }; popFattestA.textContent = 'Pop Single Fattest';
l('sectionLeftExtra').children[0].append(popFattestA); popFattestA.className = 'option';
popFattestA.onclick = function () {
if (CacheWrinklersFattest[1] !== null)
Game.wrinklers[CacheWrinklersFattest[1]].hp = 0;
};
l('sectionLeftExtra').children[0].append(popFattestA);
} }

View File

@@ -5,9 +5,9 @@ import { DispCSS } from '../VariablesAndData';
*/ */
export default function CreateCssArea() { export default function CreateCssArea() {
DispCSS = document.createElement('style'); DispCSS = document.createElement('style');
DispCSS.type = 'text/css'; DispCSS.type = 'text/css';
DispCSS.id = 'CMCSS'; DispCSS.id = 'CMCSS';
document.head.appendChild(DispCSS); document.head.appendChild(DispCSS);
} }

View File

@@ -2,9 +2,9 @@
* This function updates the style of the building and upgrade sections to make these sortable * This function updates the style of the building and upgrade sections to make these sortable
*/ */
export default function UpdateBuildingUpgradeStyle() { export default function UpdateBuildingUpgradeStyle() {
l('products').style.display = 'grid'; l('products').style.display = 'grid';
l('storeBulk').style.gridRow = '1/1'; l('storeBulk').style.gridRow = '1/1';
l('upgrades').style.display = 'flex'; l('upgrades').style.display = 'flex';
l('upgrades').style['flex-wrap'] = 'wrap'; l('upgrades').style['flex-wrap'] = 'wrap';
} }

View File

@@ -2,13 +2,13 @@
* This function creates a white square over the full screen and appends it to l('wrapper') * This function creates a white square over the full screen and appends it to l('wrapper')
*/ */
export default function CreateWhiteScreen() { export default function CreateWhiteScreen() {
const WhiteScreen = document.createElement('div'); const WhiteScreen = document.createElement('div');
WhiteScreen.id = 'CMWhiteScreen'; WhiteScreen.id = 'CMWhiteScreen';
WhiteScreen.style.width = '100%'; WhiteScreen.style.width = '100%';
WhiteScreen.style.height = '100%'; WhiteScreen.style.height = '100%';
WhiteScreen.style.backgroundColor = 'white'; WhiteScreen.style.backgroundColor = 'white';
WhiteScreen.style.display = 'none'; WhiteScreen.style.display = 'none';
WhiteScreen.style.zIndex = '9999999999'; WhiteScreen.style.zIndex = '9999999999';
WhiteScreen.style.position = 'absolute'; WhiteScreen.style.position = 'absolute';
l('wrapper').appendChild(WhiteScreen); l('wrapper').appendChild(WhiteScreen);
} }

View File

@@ -7,19 +7,19 @@ import AddMenuPref from './SettingsPage';
* This function adds the calll the functions to add extra info to the stats and options pages * This function adds the calll the functions to add extra info to the stats and options pages
*/ */
export default function AddMenu() { export default function AddMenu() {
const title = document.createElement('div'); const title = document.createElement('div');
title.className = 'title'; title.className = 'title';
if (Game.onMenu === 'prefs') { if (Game.onMenu === 'prefs') {
title.textContent = 'Cookie Monster Settings'; title.textContent = 'Cookie Monster Settings';
AddMenuPref(title); AddMenuPref(title);
} else if (Game.onMenu === 'stats') { } else if (Game.onMenu === 'stats') {
if (CMOptions.Stats) { if (CMOptions.Stats) {
title.textContent = 'Cookie Monster Statistics'; title.textContent = 'Cookie Monster Statistics';
AddMenuStats(title); AddMenuStats(title);
} }
} else if (Game.onMenu === 'log') { } else if (Game.onMenu === 'log') {
title.textContent = 'Cookie Monster '; // To create space between name and button title.textContent = 'Cookie Monster '; // To create space between name and button
AddMenuInfo(title); AddMenuInfo(title);
} }
} }

View File

@@ -7,7 +7,13 @@ import * as GameData from '../../Data/Gamedata';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import { import {
CacheAverageClicks, CacheCentEgg, CacheLastChoEgg, CacheSeaSpec, CacheWrinklersFattest, CacheWrinklersNormal, CacheWrinklersTotal, CacheAverageClicks,
CacheCentEgg,
CacheLastChoEgg,
CacheSeaSpec,
CacheWrinklersFattest,
CacheWrinklersNormal,
CacheWrinklersTotal,
} from '../../Cache/VariablesAndData'; } from '../../Cache/VariablesAndData';
import PopAllNormalWrinklers from '../HelperFunctions/PopWrinklers'; import PopAllNormalWrinklers from '../HelperFunctions/PopWrinklers';
import { ClickTimes, CookieTimes } from '../VariablesAndData'; import { ClickTimes, CookieTimes } from '../VariablesAndData';
@@ -20,156 +26,285 @@ import { Beautify } from '../BeautifyAndFormatting/BeautifyFormatting';
* @param {object} title On object that includes the title of the menu * @param {object} title On object that includes the title of the menu
*/ */
export default function AddMenuStats(title) { export default function AddMenuStats(title) {
const stats = document.createElement('div'); const stats = document.createElement('div');
stats.className = 'subsection'; stats.className = 'subsection';
stats.appendChild(title); stats.appendChild(title);
stats.appendChild(CreateElements.StatsHeader('Lucky Cookies', 'Lucky')); stats.appendChild(CreateElements.StatsHeader('Lucky Cookies', 'Lucky'));
if (CMOptions.Header.Lucky) { if (CMOptions.Header.Lucky) {
stats.appendChild(CreateSections.LuckySection()); stats.appendChild(CreateSections.LuckySection());
} }
stats.appendChild(CreateElements.StatsHeader('Chain Cookies', 'Chain')); stats.appendChild(CreateElements.StatsHeader('Chain Cookies', 'Chain'));
if (CMOptions.Header.Chain) { if (CMOptions.Header.Chain) {
stats.appendChild(CreateSections.ChainSection()); stats.appendChild(CreateSections.ChainSection());
} }
if (Game.Objects['Wizard tower'].minigameLoaded) { if (Game.Objects['Wizard tower'].minigameLoaded) {
stats.appendChild(CreateElements.StatsHeader('Spells', 'Spells')); stats.appendChild(CreateElements.StatsHeader('Spells', 'Spells'));
if (CMOptions.Header.Spells) { if (CMOptions.Header.Spells) {
stats.appendChild(CreateSections.SpellsSection()); stats.appendChild(CreateSections.SpellsSection());
} }
} }
if (Game.Objects.Farm.minigameLoaded) { if (Game.Objects.Farm.minigameLoaded) {
stats.appendChild(CreateElements.StatsHeader('Garden', 'Garden')); stats.appendChild(CreateElements.StatsHeader('Garden', 'Garden'));
if (CMOptions.Header.Garden) { if (CMOptions.Header.Garden) {
stats.appendChild(CreateSections.GardenSection()); stats.appendChild(CreateSections.GardenSection());
} }
} }
stats.appendChild(CreateElements.StatsHeader('Prestige', 'Prestige')); stats.appendChild(CreateElements.StatsHeader('Prestige', 'Prestige'));
if (CMOptions.Header.Prestige) { if (CMOptions.Header.Prestige) {
stats.appendChild(CreateSections.PrestigeSection()); stats.appendChild(CreateSections.PrestigeSection());
} }
if (Game.cpsSucked > 0) { if (Game.cpsSucked > 0) {
stats.appendChild(CreateElements.StatsHeader('Wrinklers', 'Wrink')); stats.appendChild(CreateElements.StatsHeader('Wrinklers', 'Wrink'));
if (CMOptions.Header.Wrink) { if (CMOptions.Header.Wrink) {
const popAllFrag = document.createDocumentFragment(); const popAllFrag = document.createDocumentFragment();
popAllFrag.appendChild(document.createTextNode(`${Beautify(CacheWrinklersTotal)} / ${Beautify(CacheWrinklersNormal)} `)); popAllFrag.appendChild(
const popAllA = document.createElement('a'); document.createTextNode(
popAllA.textContent = 'Pop All Normal'; `${Beautify(CacheWrinklersTotal)} / ${Beautify(
popAllA.className = 'option'; CacheWrinklersNormal,
popAllA.onclick = function () { PopAllNormalWrinklers(); }; )} `,
popAllFrag.appendChild(popAllA); ),
stats.appendChild(CreateElements.StatsListing('basic', 'Rewards of Popping (All/Normal)', popAllFrag)); );
const popFattestFrag = document.createDocumentFragment(); const popAllA = document.createElement('a');
popFattestFrag.appendChild(document.createTextNode(`${Beautify(CacheWrinklersFattest[0])} `)); popAllA.textContent = 'Pop All Normal';
const popFattestA = document.createElement('a'); popAllA.className = 'option';
popFattestA.textContent = 'Pop Single Fattest'; popAllA.onclick = function () {
popFattestA.className = 'option'; PopAllNormalWrinklers();
popFattestA.onclick = function () { if (CacheWrinklersFattest[1] !== null) Game.wrinklers[CacheWrinklersFattest[1]].hp = 0; }; };
popFattestFrag.appendChild(popFattestA); popAllFrag.appendChild(popAllA);
stats.appendChild(CreateElements.StatsListing('basic', `Rewards of Popping Single Fattest Non-Shiny Wrinkler (id: ${CacheWrinklersFattest[1] !== null ? CacheWrinklersFattest[1] : 'None'})`, popFattestFrag)); stats.appendChild(
} CreateElements.StatsListing(
} 'basic',
'Rewards of Popping (All/Normal)',
popAllFrag,
),
);
const popFattestFrag = document.createDocumentFragment();
popFattestFrag.appendChild(
document.createTextNode(`${Beautify(CacheWrinklersFattest[0])} `),
);
const popFattestA = document.createElement('a');
popFattestA.textContent = 'Pop Single Fattest';
popFattestA.className = 'option';
popFattestA.onclick = function () {
if (CacheWrinklersFattest[1] !== null)
Game.wrinklers[CacheWrinklersFattest[1]].hp = 0;
};
popFattestFrag.appendChild(popFattestA);
stats.appendChild(
CreateElements.StatsListing(
'basic',
`Rewards of Popping Single Fattest Non-Shiny Wrinkler (id: ${
CacheWrinklersFattest[1] !== null
? CacheWrinklersFattest[1]
: 'None'
})`,
popFattestFrag,
),
);
}
}
let specDisp = false; let specDisp = false;
const missingHalloweenCookies = []; const missingHalloweenCookies = [];
for (const i of Object.keys(GameData.HalloCookies)) { for (const i of Object.keys(GameData.HalloCookies)) {
if (!Game.Has(GameData.HalloCookies[i])) { if (!Game.Has(GameData.HalloCookies[i])) {
missingHalloweenCookies.push(GameData.HalloCookies[i]); missingHalloweenCookies.push(GameData.HalloCookies[i]);
specDisp = true; specDisp = true;
} }
} }
const missingChristmasCookies = []; const missingChristmasCookies = [];
for (const i of Object.keys(GameData.ChristCookies)) { for (const i of Object.keys(GameData.ChristCookies)) {
if (!Game.Has(GameData.ChristCookies[i])) { if (!Game.Has(GameData.ChristCookies[i])) {
missingChristmasCookies.push(GameData.ChristCookies[i]); missingChristmasCookies.push(GameData.ChristCookies[i]);
specDisp = true; specDisp = true;
} }
} }
const missingValentineCookies = []; const missingValentineCookies = [];
for (const i of Object.keys(GameData.ValCookies)) { for (const i of Object.keys(GameData.ValCookies)) {
if (!Game.Has(GameData.ValCookies[i])) { if (!Game.Has(GameData.ValCookies[i])) {
missingValentineCookies.push(GameData.ValCookies[i]); missingValentineCookies.push(GameData.ValCookies[i]);
specDisp = true; specDisp = true;
} }
} }
const missingNormalEggs = []; const missingNormalEggs = [];
for (const i of Object.keys(Game.eggDrops)) { for (const i of Object.keys(Game.eggDrops)) {
if (!Game.HasUnlocked(Game.eggDrops[i])) { if (!Game.HasUnlocked(Game.eggDrops[i])) {
missingNormalEggs.push(Game.eggDrops[i]); missingNormalEggs.push(Game.eggDrops[i]);
specDisp = true; specDisp = true;
} }
} }
const missingRareEggs = []; const missingRareEggs = [];
for (const i of Object.keys(Game.rareEggDrops)) { for (const i of Object.keys(Game.rareEggDrops)) {
if (!Game.HasUnlocked(Game.rareEggDrops[i])) { if (!Game.HasUnlocked(Game.rareEggDrops[i])) {
missingRareEggs.push(Game.rareEggDrops[i]); missingRareEggs.push(Game.rareEggDrops[i]);
specDisp = true; specDisp = true;
} }
} }
const missingPlantDrops = []; const missingPlantDrops = [];
for (const i of Object.keys(GameData.PlantDrops)) { for (const i of Object.keys(GameData.PlantDrops)) {
if (!Game.HasUnlocked(GameData.PlantDrops[i])) { if (!Game.HasUnlocked(GameData.PlantDrops[i])) {
missingPlantDrops.push(GameData.PlantDrops[i]); missingPlantDrops.push(GameData.PlantDrops[i]);
specDisp = true; specDisp = true;
} }
} }
const choEgg = (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg')); const choEgg =
const centEgg = Game.Has('Century egg'); Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg');
const centEgg = Game.Has('Century egg');
if (Game.season === 'christmas' || specDisp || choEgg || centEgg) { if (Game.season === 'christmas' || specDisp || choEgg || centEgg) {
stats.appendChild(CreateElements.StatsHeader('Season Specials', 'Sea')); stats.appendChild(CreateElements.StatsHeader('Season Specials', 'Sea'));
if (CMOptions.Header.Sea) { if (CMOptions.Header.Sea) {
if (missingHalloweenCookies.length !== 0) stats.appendChild(CreateElements.StatsListing('basic', 'Halloween Cookies Left to Buy', CreateElements.StatsMissDisp(missingHalloweenCookies))); if (missingHalloweenCookies.length !== 0)
if (missingChristmasCookies.length !== 0) stats.appendChild(CreateElements.StatsListing('basic', 'Christmas Cookies Left to Buy', CreateElements.StatsMissDisp(missingChristmasCookies))); stats.appendChild(
if (missingValentineCookies.length !== 0) stats.appendChild(CreateElements.StatsListing('basic', 'Valentine Cookies Left to Buy', CreateElements.StatsMissDisp(missingValentineCookies))); CreateElements.StatsListing(
if (missingNormalEggs.length !== 0) stats.appendChild(CreateElements.StatsListing('basic', 'Normal Easter Eggs Left to Unlock', CreateElements.StatsMissDisp(missingNormalEggs))); 'basic',
if (missingRareEggs.length !== 0) stats.appendChild(CreateElements.StatsListing('basic', 'Rare Easter Eggs Left to Unlock', CreateElements.StatsMissDisp(missingRareEggs))); 'Halloween Cookies Left to Buy',
if (missingPlantDrops.length !== 0) stats.appendChild(CreateElements.StatsListing('basic', 'Rare Plant Drops Left to Unlock', CreateElements.StatsMissDisp(missingPlantDrops))); CreateElements.StatsMissDisp(missingHalloweenCookies),
),
);
if (missingChristmasCookies.length !== 0)
stats.appendChild(
CreateElements.StatsListing(
'basic',
'Christmas Cookies Left to Buy',
CreateElements.StatsMissDisp(missingChristmasCookies),
),
);
if (missingValentineCookies.length !== 0)
stats.appendChild(
CreateElements.StatsListing(
'basic',
'Valentine Cookies Left to Buy',
CreateElements.StatsMissDisp(missingValentineCookies),
),
);
if (missingNormalEggs.length !== 0)
stats.appendChild(
CreateElements.StatsListing(
'basic',
'Normal Easter Eggs Left to Unlock',
CreateElements.StatsMissDisp(missingNormalEggs),
),
);
if (missingRareEggs.length !== 0)
stats.appendChild(
CreateElements.StatsListing(
'basic',
'Rare Easter Eggs Left to Unlock',
CreateElements.StatsMissDisp(missingRareEggs),
),
);
if (missingPlantDrops.length !== 0)
stats.appendChild(
CreateElements.StatsListing(
'basic',
'Rare Plant Drops Left to Unlock',
CreateElements.StatsMissDisp(missingPlantDrops),
),
);
if (Game.season === 'christmas') stats.appendChild(CreateElements.StatsListing('basic', 'Reindeer Reward', document.createTextNode(Beautify(CacheSeaSpec)))); if (Game.season === 'christmas')
if (choEgg) { stats.appendChild(
stats.appendChild(CreateElements.StatsListing('withTooltip', 'Chocolate Egg Cookies', document.createTextNode(Beautify(CacheLastChoEgg)), 'ChoEggTooltipPlaceholder')); CreateElements.StatsListing(
} 'basic',
if (centEgg) { 'Reindeer Reward',
stats.appendChild(CreateElements.StatsListing('basic', 'Century Egg Multiplier', document.createTextNode(`${Math.round((CacheCentEgg - 1) * 10000) / 100}%`))); document.createTextNode(Beautify(CacheSeaSpec)),
} ),
} );
} if (choEgg) {
stats.appendChild(
CreateElements.StatsListing(
'withTooltip',
'Chocolate Egg Cookies',
document.createTextNode(Beautify(CacheLastChoEgg)),
'ChoEggTooltipPlaceholder',
),
);
}
if (centEgg) {
stats.appendChild(
CreateElements.StatsListing(
'basic',
'Century Egg Multiplier',
document.createTextNode(
`${Math.round((CacheCentEgg - 1) * 10000) / 100}%`,
),
),
);
}
}
}
stats.appendChild(CreateElements.StatsHeader('Miscellaneous', 'Misc')); stats.appendChild(CreateElements.StatsHeader('Miscellaneous', 'Misc'));
if (CMOptions.Header.Misc) { if (CMOptions.Header.Misc) {
stats.appendChild(CreateElements.StatsListing('basic', stats.appendChild(
`Average Cookies Per Second (Past ${CookieTimes[CMOptions.AvgCPSHist] < 60 ? (`${CookieTimes[CMOptions.AvgCPSHist]} seconds`) : ((CookieTimes[CMOptions.AvgCPSHist] / 60) + (CMOptions.AvgCPSHist === 3 ? ' minute' : ' minutes'))})`, CreateElements.StatsListing(
document.createTextNode(Beautify(GetCPS(), 3)))); 'basic',
stats.appendChild(CreateElements.StatsListing('basic', `Average Cookie Clicks Per Second (Past ${ClickTimes[CMOptions.AvgClicksHist]}${CMOptions.AvgClicksHist === 0 ? ' second' : ' seconds'})`, document.createTextNode(Beautify(CacheAverageClicks, 1)))); `Average Cookies Per Second (Past ${
if (Game.Has('Fortune cookies')) { CookieTimes[CMOptions.AvgCPSHist] < 60
const fortunes = []; ? `${CookieTimes[CMOptions.AvgCPSHist]} seconds`
for (const i of Object.keys(GameData.Fortunes)) { : CookieTimes[CMOptions.AvgCPSHist] / 60 +
if (!Game.Has(GameData.Fortunes[i])) { (CMOptions.AvgCPSHist === 3 ? ' minute' : ' minutes')
fortunes.push(GameData.Fortunes[i]); })`,
} document.createTextNode(Beautify(GetCPS(), 3)),
} ),
if (fortunes.length !== 0) stats.appendChild(CreateElements.StatsListing('basic', 'Fortune Upgrades Left to Buy', CreateElements.StatsMissDisp(fortunes))); );
} stats.appendChild(
if (CMOptions.ShowMissedGC) { CreateElements.StatsListing(
stats.appendChild(CreateElements.StatsListing('basic', 'Missed Golden Cookies', document.createTextNode(Beautify(Game.missedGoldenClicks)))); 'basic',
} `Average Cookie Clicks Per Second (Past ${
if (Game.prefs.autosave) { ClickTimes[CMOptions.AvgClicksHist]
const timer = document.createElement('span'); }${CMOptions.AvgClicksHist === 0 ? ' second' : ' seconds'})`,
timer.id = 'CMStatsAutosaveTimer'; document.createTextNode(Beautify(CacheAverageClicks, 1)),
timer.innerText = Game.sayTime(Game.fps * 60 - (Game.OnAscend ? 0 : (Game.T % (Game.fps * 60))), 4); ),
stats.appendChild(CreateElements.StatsListing('basic', 'Time till autosave', timer)); );
} if (Game.Has('Fortune cookies')) {
} const fortunes = [];
for (const i of Object.keys(GameData.Fortunes)) {
if (!Game.Has(GameData.Fortunes[i])) {
fortunes.push(GameData.Fortunes[i]);
}
}
if (fortunes.length !== 0)
stats.appendChild(
CreateElements.StatsListing(
'basic',
'Fortune Upgrades Left to Buy',
CreateElements.StatsMissDisp(fortunes),
),
);
}
if (CMOptions.ShowMissedGC) {
stats.appendChild(
CreateElements.StatsListing(
'basic',
'Missed Golden Cookies',
document.createTextNode(Beautify(Game.missedGoldenClicks)),
),
);
}
if (Game.prefs.autosave) {
const timer = document.createElement('span');
timer.id = 'CMStatsAutosaveTimer';
timer.innerText = Game.sayTime(
Game.fps * 60 - (Game.OnAscend ? 0 : Game.T % (Game.fps * 60)),
4,
);
stats.appendChild(
CreateElements.StatsListing('basic', 'Time till autosave', timer),
);
}
}
l('menu').insertBefore(stats, l('menu').childNodes[2]); l('menu').insertBefore(stats, l('menu').childNodes[2]);
if (CMOptions.MissingUpgrades) { if (CMOptions.MissingUpgrades) {
AddMissingUpgrades(); AddMissingUpgrades();
} }
} }

View File

@@ -12,28 +12,31 @@ import { TooltipText } from '../VariablesAndData';
* @returns {object} div The header object * @returns {object} div The header object
*/ */
export function StatsHeader(text, config) { export function StatsHeader(text, config) {
const div = document.createElement('div'); const div = document.createElement('div');
div.className = 'title'; div.className = 'title';
div.style.padding = '0px 16px'; div.style.padding = '0px 16px';
div.style.opacity = '0.7'; div.style.opacity = '0.7';
div.style.fontSize = '17px'; div.style.fontSize = '17px';
div.style.fontFamily = '"Kavoon", Georgia, serif'; div.style.fontFamily = '"Kavoon", Georgia, serif';
div.appendChild(document.createTextNode(`${text} `)); div.appendChild(document.createTextNode(`${text} `));
const span = document.createElement('span'); const span = document.createElement('span');
span.style.cursor = 'pointer'; span.style.cursor = 'pointer';
span.style.display = 'inline-block'; span.style.display = 'inline-block';
span.style.height = '14px'; span.style.height = '14px';
span.style.width = '14px'; span.style.width = '14px';
span.style.borderRadius = '7px'; span.style.borderRadius = '7px';
span.style.textAlign = 'center'; span.style.textAlign = 'center';
span.style.backgroundColor = '#C0C0C0'; span.style.backgroundColor = '#C0C0C0';
span.style.color = 'black'; span.style.color = 'black';
span.style.fontSize = '13px'; span.style.fontSize = '13px';
span.style.verticalAlign = 'middle'; span.style.verticalAlign = 'middle';
span.textContent = CMOptions.Header[config] ? '-' : '+'; span.textContent = CMOptions.Header[config] ? '-' : '+';
span.onclick = function () { ToggleHeader(config); Game.UpdateMenu(); }; span.onclick = function () {
div.appendChild(span); ToggleHeader(config);
return div; Game.UpdateMenu();
};
div.appendChild(span);
return div;
} }
/** /**
@@ -46,35 +49,39 @@ export function StatsHeader(text, config) {
* @returns {object} div The option object * @returns {object} div The option object
*/ */
export function StatsListing(type, name, text, placeholder) { export function StatsListing(type, name, text, placeholder) {
const div = document.createElement('div'); const div = document.createElement('div');
div.className = 'listing'; div.className = 'listing';
const listingName = document.createElement('b'); const listingName = document.createElement('b');
listingName.textContent = name; listingName.textContent = name;
div.appendChild(listingName); div.appendChild(listingName);
if (type === 'withTooltip') { if (type === 'withTooltip') {
div.className = 'listing'; div.className = 'listing';
div.appendChild(document.createTextNode(' ')); div.appendChild(document.createTextNode(' '));
const tooltip = document.createElement('span'); const tooltip = document.createElement('span');
tooltip.onmouseout = function () { Game.tooltip.hide(); }; tooltip.onmouseout = function () {
tooltip.onmouseover = function () { Game.tooltip.draw(this, escape(TooltipText[placeholder].innerHTML)); }; Game.tooltip.hide();
tooltip.style.cursor = 'default'; };
tooltip.style.display = 'inline-block'; tooltip.onmouseover = function () {
tooltip.style.height = '10px'; Game.tooltip.draw(this, escape(TooltipText[placeholder].innerHTML));
tooltip.style.width = '10px'; };
tooltip.style.borderRadius = '5px'; tooltip.style.cursor = 'default';
tooltip.style.textAlign = 'center'; tooltip.style.display = 'inline-block';
tooltip.style.backgroundColor = '#C0C0C0'; tooltip.style.height = '10px';
tooltip.style.color = 'black'; tooltip.style.width = '10px';
tooltip.style.fontSize = '9px'; tooltip.style.borderRadius = '5px';
tooltip.style.verticalAlign = 'bottom'; tooltip.style.textAlign = 'center';
tooltip.textContent = '?'; tooltip.style.backgroundColor = '#C0C0C0';
div.appendChild(tooltip); tooltip.style.color = 'black';
} tooltip.style.fontSize = '9px';
div.appendChild(document.createTextNode(': ')); tooltip.style.verticalAlign = 'bottom';
div.appendChild(text); tooltip.textContent = '?';
return div; div.appendChild(tooltip);
}
div.appendChild(document.createTextNode(': '));
div.appendChild(text);
return div;
} }
/** /**
@@ -83,39 +90,43 @@ export function StatsListing(type, name, text, placeholder) {
* @returns {object} frag The tooltip object * @returns {object} frag The tooltip object
*/ */
export function StatsMissDisp(theMissDisp) { export function StatsMissDisp(theMissDisp) {
const frag = document.createDocumentFragment(); const frag = document.createDocumentFragment();
frag.appendChild(document.createTextNode(`${theMissDisp.length} `)); frag.appendChild(document.createTextNode(`${theMissDisp.length} `));
const span = document.createElement('span'); const span = document.createElement('span');
span.onmouseout = function () { Game.tooltip.hide(); }; span.onmouseout = function () {
const placeholder = document.createElement('div'); Game.tooltip.hide();
const missing = document.createElement('div'); };
missing.style.minWidth = '140px'; const placeholder = document.createElement('div');
missing.style.marginBottom = '4px'; const missing = document.createElement('div');
const title = document.createElement('div'); missing.style.minWidth = '140px';
title.className = 'name'; missing.style.marginBottom = '4px';
title.style.marginBottom = '4px'; const title = document.createElement('div');
title.style.textAlign = 'center'; title.className = 'name';
title.textContent = 'Missing'; title.style.marginBottom = '4px';
missing.appendChild(title); title.style.textAlign = 'center';
for (const i of Object.keys(theMissDisp)) { title.textContent = 'Missing';
const div = document.createElement('div'); missing.appendChild(title);
div.style.textAlign = 'center'; for (const i of Object.keys(theMissDisp)) {
div.appendChild(document.createTextNode(theMissDisp[i])); const div = document.createElement('div');
missing.appendChild(div); div.style.textAlign = 'center';
} div.appendChild(document.createTextNode(theMissDisp[i]));
placeholder.appendChild(missing); missing.appendChild(div);
span.onmouseover = function () { Game.tooltip.draw(this, escape(placeholder.innerHTML)); }; }
span.style.cursor = 'default'; placeholder.appendChild(missing);
span.style.display = 'inline-block'; span.onmouseover = function () {
span.style.height = '10px'; Game.tooltip.draw(this, escape(placeholder.innerHTML));
span.style.width = '10px'; };
span.style.borderRadius = '5px'; span.style.cursor = 'default';
span.style.textAlign = 'center'; span.style.display = 'inline-block';
span.style.backgroundColor = '#C0C0C0'; span.style.height = '10px';
span.style.color = 'black'; span.style.width = '10px';
span.style.fontSize = '9px'; span.style.borderRadius = '5px';
span.style.verticalAlign = 'bottom'; span.style.textAlign = 'center';
span.textContent = '?'; span.style.backgroundColor = '#C0C0C0';
frag.appendChild(span); span.style.color = 'black';
return frag; span.style.fontSize = '9px';
span.style.verticalAlign = 'bottom';
span.textContent = '?';
frag.appendChild(span);
return frag;
} }

View File

@@ -1,58 +1,88 @@
/** Functions related to displaying the missing upgrades in the Statistics page */ /** Functions related to displaying the missing upgrades in the Statistics page */
import { CacheMissingUpgrades, CacheMissingUpgradesCookies, CacheMissingUpgradesPrestige } from '../../Cache/VariablesAndData'; import {
CacheMissingUpgrades,
CacheMissingUpgradesCookies,
CacheMissingUpgradesPrestige,
} from '../../Cache/VariablesAndData';
/** /**
* This function creates the missing upgrades sections for prestige, normal and cookie upgrades * This function creates the missing upgrades sections for prestige, normal and cookie upgrades
*/ */
export function AddMissingUpgrades() { export function AddMissingUpgrades() {
for (const menuSection of (l('menu').children)) { for (const menuSection of l('menu').children) {
if (menuSection.children[0]) { if (menuSection.children[0]) {
if (menuSection.children[0].innerHTML === 'Prestige' && CacheMissingUpgradesPrestige) { if (
const prestigeUpgradesMissing = CacheMissingUpgradesPrestige.match(new RegExp('div', 'g') || []).length / 2; menuSection.children[0].innerHTML === 'Prestige' &&
const title = document.createElement('div'); CacheMissingUpgradesPrestige
title.id = 'CMMissingUpgradesPrestigeTitle'; ) {
title.className = 'listing'; const prestigeUpgradesMissing =
const titlefrag = document.createElement('div'); CacheMissingUpgradesPrestige.match(new RegExp('div', 'g') || [])
titlefrag.innerHTML = `<b>Missing Prestige upgrades:</b> ${prestigeUpgradesMissing}/${Game.PrestigeUpgrades.length} (${Math.floor((prestigeUpgradesMissing / Game.PrestigeUpgrades.length) * 100)}%)`; .length / 2;
title.appendChild(titlefrag); const title = document.createElement('div');
menuSection.appendChild(title); title.id = 'CMMissingUpgradesPrestigeTitle';
const upgrades = document.createElement('div'); title.className = 'listing';
upgrades.className = 'listing crateBox'; const titlefrag = document.createElement('div');
upgrades.innerHTML = CacheMissingUpgradesPrestige; titlefrag.innerHTML = `<b>Missing Prestige upgrades:</b> ${prestigeUpgradesMissing}/${
menuSection.appendChild(upgrades); Game.PrestigeUpgrades.length
} else if (menuSection.children[0].innerHTML === 'Upgrades') { } (${Math.floor(
if (CacheMissingUpgrades) { (prestigeUpgradesMissing / Game.PrestigeUpgrades.length) * 100,
const normalUpgradesMissing = CacheMissingUpgrades.match(new RegExp('div', 'g') || []).length / 2; )}%)`;
const title = document.createElement('div'); title.appendChild(titlefrag);
title.id = 'CMMissingUpgradesTitle'; menuSection.appendChild(title);
title.className = 'listing'; const upgrades = document.createElement('div');
const titlefrag = document.createElement('div'); upgrades.className = 'listing crateBox';
titlefrag.innerHTML = `<b>Missing normal upgrades:</b> ${normalUpgradesMissing}/${Game.UpgradesByPool[''].length + Game.UpgradesByPool.tech.length} (${Math.floor((normalUpgradesMissing / (Game.UpgradesByPool[''].length + Game.UpgradesByPool.tech.length)) * 100)}%)`; upgrades.innerHTML = CacheMissingUpgradesPrestige;
title.appendChild(titlefrag); menuSection.appendChild(upgrades);
menuSection.insertBefore(title, menuSection.childNodes[3]); } else if (menuSection.children[0].innerHTML === 'Upgrades') {
const upgrades = document.createElement('div'); if (CacheMissingUpgrades) {
upgrades.className = 'listing crateBox'; const normalUpgradesMissing =
upgrades.innerHTML = CacheMissingUpgrades; CacheMissingUpgrades.match(new RegExp('div', 'g') || []).length / 2;
menuSection.insertBefore(upgrades, document.getElementById('CMMissingUpgradesTitle').nextSibling); const title = document.createElement('div');
} title.id = 'CMMissingUpgradesTitle';
if (CacheMissingUpgradesCookies) { title.className = 'listing';
const cookieUpgradesMissing = CacheMissingUpgradesCookies.match(new RegExp('div', 'g') || []).length / 2; const titlefrag = document.createElement('div');
const title = document.createElement('div'); titlefrag.innerHTML = `<b>Missing normal upgrades:</b> ${normalUpgradesMissing}/${
title.id = 'CMMissingUpgradesCookiesTitle'; Game.UpgradesByPool[''].length + Game.UpgradesByPool.tech.length
title.className = 'listing'; } (${Math.floor(
const titlefrag = document.createElement('div'); (normalUpgradesMissing /
titlefrag.innerHTML = `<b>Missing Cookie upgrades:</b> ${cookieUpgradesMissing}/${Game.UpgradesByPool.cookie.length} (${Math.floor((cookieUpgradesMissing / Game.UpgradesByPool.cookie.length) * 100)}%)`; (Game.UpgradesByPool[''].length +
title.appendChild(titlefrag); Game.UpgradesByPool.tech.length)) *
menuSection.appendChild(title); 100,
const upgrades = document.createElement('div'); )}%)`;
upgrades.className = 'listing crateBox'; title.appendChild(titlefrag);
upgrades.innerHTML = CacheMissingUpgradesCookies; menuSection.insertBefore(title, menuSection.childNodes[3]);
menuSection.appendChild(upgrades); const upgrades = document.createElement('div');
} upgrades.className = 'listing crateBox';
} upgrades.innerHTML = CacheMissingUpgrades;
} menuSection.insertBefore(
} upgrades,
document.getElementById('CMMissingUpgradesTitle').nextSibling,
);
}
if (CacheMissingUpgradesCookies) {
const cookieUpgradesMissing =
CacheMissingUpgradesCookies.match(new RegExp('div', 'g') || [])
.length / 2;
const title = document.createElement('div');
title.id = 'CMMissingUpgradesCookiesTitle';
title.className = 'listing';
const titlefrag = document.createElement('div');
titlefrag.innerHTML = `<b>Missing Cookie upgrades:</b> ${cookieUpgradesMissing}/${
Game.UpgradesByPool.cookie.length
} (${Math.floor(
(cookieUpgradesMissing / Game.UpgradesByPool.cookie.length) * 100,
)}%)`;
title.appendChild(titlefrag);
menuSection.appendChild(title);
const upgrades = document.createElement('div');
upgrades.className = 'listing crateBox';
upgrades.innerHTML = CacheMissingUpgradesCookies;
menuSection.appendChild(upgrades);
}
}
}
}
} }
/** /**
@@ -62,18 +92,20 @@ export function AddMissingUpgrades() {
* @returns {string} ? The HTML string that creates the icon. * @returns {string} ? The HTML string that creates the icon.
*/ */
export function crateMissing(me) { export function crateMissing(me) {
let classes = 'crate upgrade missing'; let classes = 'crate upgrade missing';
if (me.pool === 'prestige') classes += ' heavenly'; if (me.pool === 'prestige') classes += ' heavenly';
let noFrame = 0; let noFrame = 0;
if (!Game.prefs.crates) noFrame = 1; if (!Game.prefs.crates) noFrame = 1;
if (noFrame) classes += ' noFrame'; if (noFrame) classes += ' noFrame';
let icon = me.icon; let icon = me.icon;
if (me.iconFunction) icon = me.iconFunction(); if (me.iconFunction) icon = me.iconFunction();
const tooltip = `function() {return Game.crateTooltip(Game.UpgradesById[${me.id}], 'stats');}`; const tooltip = `function() {return Game.crateTooltip(Game.UpgradesById[${me.id}], 'stats');}`;
return `<div class="${classes}" return `<div class="${classes}"
${Game.getDynamicTooltip(tooltip, 'top', true)} ${Game.getDynamicTooltip(tooltip, 'top', true)}
style = "${(`${icon[2] ? `background-image: url(${icon[2]});` : ''}background-position:${-icon[0] * 48}px ${-icon[1] * 48}px`)};"> style = "${`${
icon[2] ? `background-image: url(${icon[2]});` : ''
}background-position:${-icon[0] * 48}px ${-icon[1] * 48}px`};">
</div>`; </div>`;
} }

View File

@@ -2,29 +2,43 @@
import { MaxChainCookieReward } from '../../Cache/Stats/ChainCookies'; import { MaxChainCookieReward } from '../../Cache/Stats/ChainCookies';
import { import {
CacheAvgCPSWithChoEgg, CacheAvgCPSWithChoEgg,
CacheChainFrenzyMaxReward, CacheChainFrenzyMaxReward,
CacheChainFrenzyRequired, CacheChainFrenzyRequired,
CacheChainFrenzyRequiredNext, CacheChainFrenzyRequiredNext,
CacheChainFrenzyWrathRequired, CacheChainFrenzyWrathRequired,
CacheChainFrenzyWrathRequiredNext, CacheChainFrenzyWrathRequiredNext,
CacheChainMaxReward, CacheChainMaxReward,
CacheChainRequired, CacheChainRequired,
CacheChainRequiredNext, CacheChainRequiredNext,
CacheChainWrathMaxReward, CacheChainWrathMaxReward,
CacheChainWrathRequired, CacheChainWrathRequired,
CacheChainWrathRequiredNext, CacheChainWrathRequiredNext,
CacheConjure, CacheConjure,
CacheConjureReward, CacheConjureReward,
CacheDragonsFortuneMultAdjustment, CacheDragonsFortuneMultAdjustment,
CacheEdifice, CacheEdifice,
CacheEdificeBuilding, CacheEdificeBuilding,
CacheGoldenCookiesMult, CacheGoldenCookiesMult,
CacheHCPerSecond, CacheLastChoEgg, CacheLucky, CacheLuckyFrenzy, CacheLuckyReward, CacheLuckyRewardFrenzy, CacheLuckyWrathReward, CacheLuckyWrathRewardFrenzy, CacheNoGoldSwitchCookiesPS, CacheRealCookiesEarned, CacheWrathCookiesMult, CacheWrinklersTotal, CacheHCPerSecond,
CacheLastChoEgg,
CacheLucky,
CacheLuckyFrenzy,
CacheLuckyReward,
CacheLuckyRewardFrenzy,
CacheLuckyWrathReward,
CacheLuckyWrathRewardFrenzy,
CacheNoGoldSwitchCookiesPS,
CacheRealCookiesEarned,
CacheWrathCookiesMult,
CacheWrinklersTotal,
} from '../../Cache/VariablesAndData'; } from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import ResetBonus from '../../Sim/SimulationEvents/ResetAscension'; import ResetBonus from '../../Sim/SimulationEvents/ResetAscension';
import { Beautify, FormatTime } from '../BeautifyAndFormatting/BeautifyFormatting'; import {
Beautify,
FormatTime,
} from '../BeautifyAndFormatting/BeautifyFormatting';
import GetCPS from '../HelperFunctions/GetCPS'; import GetCPS from '../HelperFunctions/GetCPS';
import GetWrinkConfigBank from '../HelperFunctions/GetWrinkConfigBank'; import GetWrinkConfigBank from '../HelperFunctions/GetWrinkConfigBank';
@@ -36,63 +50,124 @@ import { StatsListing } from './CreateDOMElements';
* @returns {object} section The object contating the Lucky section * @returns {object} section The object contating the Lucky section
*/ */
export function LuckySection() { export function LuckySection() {
// This sets which tooltip to display for certain stats // This sets which tooltip to display for certain stats
const goldCookTooltip = Game.auraMult('Dragon\'s Fortune') ? 'GoldCookDragonsFortuneTooltipPlaceholder' : 'GoldCookTooltipPlaceholder'; const goldCookTooltip = Game.auraMult("Dragon's Fortune")
? 'GoldCookDragonsFortuneTooltipPlaceholder'
: 'GoldCookTooltipPlaceholder';
const section = document.createElement('div'); const section = document.createElement('div');
section.className = 'CMStatsLuckySection'; section.className = 'CMStatsLuckySection';
const luckyColor = ((Game.cookies + GetWrinkConfigBank()) < CacheLucky) ? ColorRed : ColorGreen; const luckyColor =
const luckyTime = ((Game.cookies + GetWrinkConfigBank()) < CacheLucky) ? FormatTime((CacheLucky - (Game.cookies + GetWrinkConfigBank())) / GetCPS()) : ''; Game.cookies + GetWrinkConfigBank() < CacheLucky ? ColorRed : ColorGreen;
const luckyReqFrag = document.createDocumentFragment(); const luckyTime =
const luckyReqSpan = document.createElement('span'); Game.cookies + GetWrinkConfigBank() < CacheLucky
luckyReqSpan.style.fontWeight = 'bold'; ? FormatTime(
luckyReqSpan.className = ColorTextPre + luckyColor; (CacheLucky - (Game.cookies + GetWrinkConfigBank())) / GetCPS(),
luckyReqSpan.textContent = Beautify(CacheLucky); )
luckyReqFrag.appendChild(luckyReqSpan); : '';
if (luckyTime !== '') { const luckyReqFrag = document.createDocumentFragment();
const luckyReqSmall = document.createElement('small'); const luckyReqSpan = document.createElement('span');
luckyReqSmall.textContent = ` (${luckyTime})`; luckyReqSpan.style.fontWeight = 'bold';
luckyReqFrag.appendChild(luckyReqSmall); luckyReqSpan.className = ColorTextPre + luckyColor;
} luckyReqSpan.textContent = Beautify(CacheLucky);
section.appendChild(StatsListing('withTooltip', '"Lucky!" Cookies Required', luckyReqFrag, goldCookTooltip)); luckyReqFrag.appendChild(luckyReqSpan);
if (luckyTime !== '') {
const luckyReqSmall = document.createElement('small');
luckyReqSmall.textContent = ` (${luckyTime})`;
luckyReqFrag.appendChild(luckyReqSmall);
}
section.appendChild(
StatsListing(
'withTooltip',
'"Lucky!" Cookies Required',
luckyReqFrag,
goldCookTooltip,
),
);
const luckyColorFrenzy = ((Game.cookies + GetWrinkConfigBank()) < CacheLuckyFrenzy) ? ColorRed : ColorGreen; const luckyColorFrenzy =
const luckyTimeFrenzy = ((Game.cookies + GetWrinkConfigBank()) < CacheLuckyFrenzy) ? FormatTime((CacheLuckyFrenzy - (Game.cookies + GetWrinkConfigBank())) / GetCPS()) : ''; Game.cookies + GetWrinkConfigBank() < CacheLuckyFrenzy
const luckyReqFrenFrag = document.createDocumentFragment(); ? ColorRed
const luckyReqFrenSpan = document.createElement('span'); : ColorGreen;
luckyReqFrenSpan.style.fontWeight = 'bold'; const luckyTimeFrenzy =
luckyReqFrenSpan.className = ColorTextPre + luckyColorFrenzy; Game.cookies + GetWrinkConfigBank() < CacheLuckyFrenzy
luckyReqFrenSpan.textContent = Beautify(CacheLuckyFrenzy); ? FormatTime(
luckyReqFrenFrag.appendChild(luckyReqFrenSpan); (CacheLuckyFrenzy - (Game.cookies + GetWrinkConfigBank())) / GetCPS(),
if (luckyTimeFrenzy !== '') { )
const luckyReqFrenSmall = document.createElement('small'); : '';
luckyReqFrenSmall.textContent = ` (${luckyTimeFrenzy})`; const luckyReqFrenFrag = document.createDocumentFragment();
luckyReqFrenFrag.appendChild(luckyReqFrenSmall); const luckyReqFrenSpan = document.createElement('span');
} luckyReqFrenSpan.style.fontWeight = 'bold';
section.appendChild(StatsListing('withTooltip', '"Lucky!" Cookies Required (Frenzy)', luckyReqFrenFrag, goldCookTooltip)); luckyReqFrenSpan.className = ColorTextPre + luckyColorFrenzy;
luckyReqFrenSpan.textContent = Beautify(CacheLuckyFrenzy);
luckyReqFrenFrag.appendChild(luckyReqFrenSpan);
if (luckyTimeFrenzy !== '') {
const luckyReqFrenSmall = document.createElement('small');
luckyReqFrenSmall.textContent = ` (${luckyTimeFrenzy})`;
luckyReqFrenFrag.appendChild(luckyReqFrenSmall);
}
section.appendChild(
StatsListing(
'withTooltip',
'"Lucky!" Cookies Required (Frenzy)',
luckyReqFrenFrag,
goldCookTooltip,
),
);
const luckySplit = CacheLuckyReward !== CacheLuckyWrathReward; const luckySplit = CacheLuckyReward !== CacheLuckyWrathReward;
const luckyRewardMaxSpan = document.createElement('span'); const luckyRewardMaxSpan = document.createElement('span');
luckyRewardMaxSpan.style.fontWeight = 'bold'; luckyRewardMaxSpan.style.fontWeight = 'bold';
luckyRewardMaxSpan.className = ColorTextPre + CacheLuckyReward; luckyRewardMaxSpan.className = ColorTextPre + CacheLuckyReward;
luckyRewardMaxSpan.textContent = Beautify(CacheLuckyReward) + (luckySplit ? (` / ${Beautify(CacheLuckyWrathReward)}`) : ''); luckyRewardMaxSpan.textContent =
section.appendChild(StatsListing('withTooltip', `"Lucky!" Reward (MAX)${luckySplit ? ' (Golden / Wrath)' : ''}`, luckyRewardMaxSpan, goldCookTooltip)); Beautify(CacheLuckyReward) +
(luckySplit ? ` / ${Beautify(CacheLuckyWrathReward)}` : '');
section.appendChild(
StatsListing(
'withTooltip',
`"Lucky!" Reward (MAX)${luckySplit ? ' (Golden / Wrath)' : ''}`,
luckyRewardMaxSpan,
goldCookTooltip,
),
);
const luckyRewardFrenzyMaxSpan = document.createElement('span'); const luckyRewardFrenzyMaxSpan = document.createElement('span');
luckyRewardFrenzyMaxSpan.style.fontWeight = 'bold'; luckyRewardFrenzyMaxSpan.style.fontWeight = 'bold';
luckyRewardFrenzyMaxSpan.className = ColorTextPre + luckyRewardFrenzyMaxSpan; luckyRewardFrenzyMaxSpan.className = ColorTextPre + luckyRewardFrenzyMaxSpan;
luckyRewardFrenzyMaxSpan.textContent = Beautify(CacheLuckyRewardFrenzy) + (luckySplit ? (` / ${Beautify(CacheLuckyWrathRewardFrenzy)}`) : ''); luckyRewardFrenzyMaxSpan.textContent =
section.appendChild(StatsListing('withTooltip', `"Lucky!" Reward (MAX) (Frenzy)${luckySplit ? ' (Golden / Wrath)' : ''}`, luckyRewardFrenzyMaxSpan, goldCookTooltip)); Beautify(CacheLuckyRewardFrenzy) +
(luckySplit ? ` / ${Beautify(CacheLuckyWrathRewardFrenzy)}` : '');
section.appendChild(
StatsListing(
'withTooltip',
`"Lucky!" Reward (MAX) (Frenzy)${luckySplit ? ' (Golden / Wrath)' : ''}`,
luckyRewardFrenzyMaxSpan,
goldCookTooltip,
),
);
const luckyCurBase = Math.min((Game.cookies + GetWrinkConfigBank()) * 0.15, CacheNoGoldSwitchCookiesPS * CacheDragonsFortuneMultAdjustment * 60 * 15) + 13; const luckyCurBase =
const luckyCurSpan = document.createElement('span'); Math.min(
luckyCurSpan.style.fontWeight = 'bold'; (Game.cookies + GetWrinkConfigBank()) * 0.15,
luckyCurSpan.className = ColorTextPre + luckyCurSpan; CacheNoGoldSwitchCookiesPS * CacheDragonsFortuneMultAdjustment * 60 * 15,
luckyCurSpan.textContent = Beautify(CacheGoldenCookiesMult * luckyCurBase) + (luckySplit ? (` / ${Beautify(CacheWrathCookiesMult * luckyCurBase)}`) : ''); ) + 13;
section.appendChild(StatsListing('withTooltip', `"Lucky!" Reward (CUR)${luckySplit ? ' (Golden / Wrath)' : ''}`, luckyCurSpan, goldCookTooltip)); const luckyCurSpan = document.createElement('span');
return section; luckyCurSpan.style.fontWeight = 'bold';
luckyCurSpan.className = ColorTextPre + luckyCurSpan;
luckyCurSpan.textContent =
Beautify(CacheGoldenCookiesMult * luckyCurBase) +
(luckySplit ? ` / ${Beautify(CacheWrathCookiesMult * luckyCurBase)}` : '');
section.appendChild(
StatsListing(
'withTooltip',
`"Lucky!" Reward (CUR)${luckySplit ? ' (Golden / Wrath)' : ''}`,
luckyCurSpan,
goldCookTooltip,
),
);
return section;
} }
/** /**
@@ -100,84 +175,215 @@ export function LuckySection() {
* @returns {object} section The object contating the Chain section * @returns {object} section The object contating the Chain section
*/ */
export function ChainSection() { export function ChainSection() {
// This sets which tooltip to display for certain stats // This sets which tooltip to display for certain stats
const goldCookTooltip = Game.auraMult('Dragon\'s Fortune') ? 'GoldCookDragonsFortuneTooltipPlaceholder' : 'GoldCookTooltipPlaceholder'; const goldCookTooltip = Game.auraMult("Dragon's Fortune")
? 'GoldCookDragonsFortuneTooltipPlaceholder'
: 'GoldCookTooltipPlaceholder';
const section = document.createElement('div'); const section = document.createElement('div');
section.className = 'CMStatsChainSection'; section.className = 'CMStatsChainSection';
const chainColor = ((Game.cookies + GetWrinkConfigBank()) < CacheChainRequired) ? ColorRed : ColorGreen; const chainColor =
const chainTime = ((Game.cookies + GetWrinkConfigBank()) < CacheChainRequired) ? FormatTime((CacheChainRequired - (Game.cookies + GetWrinkConfigBank())) / GetCPS()) : ''; Game.cookies + GetWrinkConfigBank() < CacheChainRequired
const chainReqFrag = document.createDocumentFragment(); ? ColorRed
const chainReqSpan = document.createElement('span'); : ColorGreen;
chainReqSpan.style.fontWeight = 'bold'; const chainTime =
chainReqSpan.className = ColorTextPre + chainColor; Game.cookies + GetWrinkConfigBank() < CacheChainRequired
chainReqSpan.textContent = Beautify(CacheChainRequired); ? FormatTime(
chainReqFrag.appendChild(chainReqSpan); (CacheChainRequired - (Game.cookies + GetWrinkConfigBank())) /
if (chainTime !== '') { GetCPS(),
const chainReqSmall = document.createElement('small'); )
chainReqSmall.textContent = ` (${chainTime})`; : '';
chainReqFrag.appendChild(chainReqSmall); const chainReqFrag = document.createDocumentFragment();
} const chainReqSpan = document.createElement('span');
section.appendChild(StatsListing('withTooltip', '"Chain" Cookies Required', chainReqFrag, goldCookTooltip)); chainReqSpan.style.fontWeight = 'bold';
chainReqSpan.className = ColorTextPre + chainColor;
chainReqSpan.textContent = Beautify(CacheChainRequired);
chainReqFrag.appendChild(chainReqSpan);
if (chainTime !== '') {
const chainReqSmall = document.createElement('small');
chainReqSmall.textContent = ` (${chainTime})`;
chainReqFrag.appendChild(chainReqSmall);
}
section.appendChild(
StatsListing(
'withTooltip',
'"Chain" Cookies Required',
chainReqFrag,
goldCookTooltip,
),
);
const chainWrathColor = ((Game.cookies + GetWrinkConfigBank()) < CacheChainWrathRequired) ? ColorRed : ColorGreen; const chainWrathColor =
const chainWrathTime = ((Game.cookies + GetWrinkConfigBank()) < CacheChainWrathRequired) ? FormatTime((CacheChainWrathRequired - (Game.cookies + GetWrinkConfigBank())) / GetCPS()) : ''; Game.cookies + GetWrinkConfigBank() < CacheChainWrathRequired
const chainWrathReqFrag = document.createDocumentFragment(); ? ColorRed
const chainWrathReqSpan = document.createElement('span'); : ColorGreen;
chainWrathReqSpan.style.fontWeight = 'bold'; const chainWrathTime =
chainWrathReqSpan.className = ColorTextPre + chainWrathColor; Game.cookies + GetWrinkConfigBank() < CacheChainWrathRequired
chainWrathReqSpan.textContent = Beautify(CacheChainWrathRequired); ? FormatTime(
chainWrathReqFrag.appendChild(chainWrathReqSpan); (CacheChainWrathRequired - (Game.cookies + GetWrinkConfigBank())) /
if (chainWrathTime !== '') { GetCPS(),
const chainWrathReqSmall = document.createElement('small'); )
chainWrathReqSmall.textContent = ` (${chainWrathTime})`; : '';
chainWrathReqFrag.appendChild(chainWrathReqSmall); const chainWrathReqFrag = document.createDocumentFragment();
} const chainWrathReqSpan = document.createElement('span');
section.appendChild(StatsListing('withTooltip', '"Chain" Cookies Required (Wrath)', chainWrathReqFrag, goldCookTooltip)); chainWrathReqSpan.style.fontWeight = 'bold';
chainWrathReqSpan.className = ColorTextPre + chainWrathColor;
chainWrathReqSpan.textContent = Beautify(CacheChainWrathRequired);
chainWrathReqFrag.appendChild(chainWrathReqSpan);
if (chainWrathTime !== '') {
const chainWrathReqSmall = document.createElement('small');
chainWrathReqSmall.textContent = ` (${chainWrathTime})`;
chainWrathReqFrag.appendChild(chainWrathReqSmall);
}
section.appendChild(
StatsListing(
'withTooltip',
'"Chain" Cookies Required (Wrath)',
chainWrathReqFrag,
goldCookTooltip,
),
);
const chainColorFrenzy = ((Game.cookies + GetWrinkConfigBank()) < CacheChainFrenzyRequired) ? ColorRed : ColorGreen; const chainColorFrenzy =
const chainTimeFrenzy = ((Game.cookies + GetWrinkConfigBank()) < CacheChainFrenzyRequired) ? FormatTime((CacheChainFrenzyRequired - (Game.cookies + GetWrinkConfigBank())) / GetCPS()) : ''; Game.cookies + GetWrinkConfigBank() < CacheChainFrenzyRequired
const chainReqFrenFrag = document.createDocumentFragment(); ? ColorRed
const chainReqFrenSpan = document.createElement('span'); : ColorGreen;
chainReqFrenSpan.style.fontWeight = 'bold'; const chainTimeFrenzy =
chainReqFrenSpan.className = ColorTextPre + chainColorFrenzy; Game.cookies + GetWrinkConfigBank() < CacheChainFrenzyRequired
chainReqFrenSpan.textContent = Beautify(CacheChainFrenzyRequired); ? FormatTime(
chainReqFrenFrag.appendChild(chainReqFrenSpan); (CacheChainFrenzyRequired - (Game.cookies + GetWrinkConfigBank())) /
if (chainTimeFrenzy !== '') { GetCPS(),
const chainReqFrenSmall = document.createElement('small'); )
chainReqFrenSmall.textContent = ` (${chainTimeFrenzy})`; : '';
chainReqFrenFrag.appendChild(chainReqFrenSmall); const chainReqFrenFrag = document.createDocumentFragment();
} const chainReqFrenSpan = document.createElement('span');
section.appendChild(StatsListing('withTooltip', '"Chain" Cookies Required (Frenzy)', chainReqFrenFrag, goldCookTooltip)); chainReqFrenSpan.style.fontWeight = 'bold';
chainReqFrenSpan.className = ColorTextPre + chainColorFrenzy;
chainReqFrenSpan.textContent = Beautify(CacheChainFrenzyRequired);
chainReqFrenFrag.appendChild(chainReqFrenSpan);
if (chainTimeFrenzy !== '') {
const chainReqFrenSmall = document.createElement('small');
chainReqFrenSmall.textContent = ` (${chainTimeFrenzy})`;
chainReqFrenFrag.appendChild(chainReqFrenSmall);
}
section.appendChild(
StatsListing(
'withTooltip',
'"Chain" Cookies Required (Frenzy)',
chainReqFrenFrag,
goldCookTooltip,
),
);
const chainWrathColorFrenzy = ((Game.cookies + GetWrinkConfigBank()) < CacheChainFrenzyWrathRequired) ? ColorRed : ColorGreen; const chainWrathColorFrenzy =
const chainWrathTimeFrenzy = ((Game.cookies + GetWrinkConfigBank()) < CacheChainFrenzyWrathRequired) ? FormatTime((CacheChainFrenzyWrathRequired - (Game.cookies + GetWrinkConfigBank())) / GetCPS()) : ''; Game.cookies + GetWrinkConfigBank() < CacheChainFrenzyWrathRequired
const chainWrathReqFrenFrag = document.createDocumentFragment(); ? ColorRed
const chainWrathReqFrenSpan = document.createElement('span'); : ColorGreen;
chainWrathReqFrenSpan.style.fontWeight = 'bold'; const chainWrathTimeFrenzy =
chainWrathReqFrenSpan.className = ColorTextPre + chainWrathColorFrenzy; Game.cookies + GetWrinkConfigBank() < CacheChainFrenzyWrathRequired
chainWrathReqFrenSpan.textContent = Beautify(CacheChainFrenzyWrathRequired); ? FormatTime(
chainWrathReqFrenFrag.appendChild(chainWrathReqFrenSpan); (CacheChainFrenzyWrathRequired -
if (chainWrathTimeFrenzy !== '') { (Game.cookies + GetWrinkConfigBank())) /
const chainWrathReqFrenSmall = document.createElement('small'); GetCPS(),
chainWrathReqFrenSmall.textContent = ` (${chainWrathTimeFrenzy})`; )
chainWrathReqFrenFrag.appendChild(chainWrathReqFrenSmall); : '';
} const chainWrathReqFrenFrag = document.createDocumentFragment();
section.appendChild(StatsListing('withTooltip', '"Chain" Cookies Required (Frenzy) (Wrath)', chainWrathReqFrenFrag, goldCookTooltip)); const chainWrathReqFrenSpan = document.createElement('span');
chainWrathReqFrenSpan.style.fontWeight = 'bold';
chainWrathReqFrenSpan.className = ColorTextPre + chainWrathColorFrenzy;
chainWrathReqFrenSpan.textContent = Beautify(CacheChainFrenzyWrathRequired);
chainWrathReqFrenFrag.appendChild(chainWrathReqFrenSpan);
if (chainWrathTimeFrenzy !== '') {
const chainWrathReqFrenSmall = document.createElement('small');
chainWrathReqFrenSmall.textContent = ` (${chainWrathTimeFrenzy})`;
chainWrathReqFrenFrag.appendChild(chainWrathReqFrenSmall);
}
section.appendChild(
StatsListing(
'withTooltip',
'"Chain" Cookies Required (Frenzy) (Wrath)',
chainWrathReqFrenFrag,
goldCookTooltip,
),
);
section.appendChild(StatsListing('withTooltip', '"Chain" Reward (MAX) (Golden / Wrath)', document.createTextNode(`${Beautify(CacheChainMaxReward[0])} / ${Beautify(CacheChainWrathMaxReward[0])}`), goldCookTooltip)); section.appendChild(
StatsListing(
'withTooltip',
'"Chain" Reward (MAX) (Golden / Wrath)',
document.createTextNode(
`${Beautify(CacheChainMaxReward[0])} / ${Beautify(
CacheChainWrathMaxReward[0],
)}`,
),
goldCookTooltip,
),
);
section.appendChild(StatsListing('withTooltip', '"Chain" Reward (MAX) (Frenzy) (Golden / Wrath)', document.createTextNode((`${Beautify(CacheChainFrenzyMaxReward[0])} / ${Beautify(CacheChainFrenzyMaxReward[0])}`)), goldCookTooltip)); section.appendChild(
StatsListing(
'withTooltip',
'"Chain" Reward (MAX) (Frenzy) (Golden / Wrath)',
document.createTextNode(
`${Beautify(CacheChainFrenzyMaxReward[0])} / ${Beautify(
CacheChainFrenzyMaxReward[0],
)}`,
),
goldCookTooltip,
),
);
const chainCurMax = Math.min(Game.cookiesPs * 60 * 60 * 6 * CacheDragonsFortuneMultAdjustment, Game.cookies * 0.5); const chainCurMax = Math.min(
const chainCur = MaxChainCookieReward(7, chainCurMax, CacheGoldenCookiesMult)[0]; Game.cookiesPs * 60 * 60 * 6 * CacheDragonsFortuneMultAdjustment,
const chainCurWrath = MaxChainCookieReward(6, chainCurMax, CacheWrathCookiesMult)[0]; Game.cookies * 0.5,
section.appendChild(StatsListing('withTooltip', '"Chain" Reward (CUR) (Golden / Wrath)', document.createTextNode((`${Beautify(chainCur)} / ${Beautify(chainCurWrath)}`)), goldCookTooltip)); );
const chainCur = MaxChainCookieReward(
7,
chainCurMax,
CacheGoldenCookiesMult,
)[0];
const chainCurWrath = MaxChainCookieReward(
6,
chainCurMax,
CacheWrathCookiesMult,
)[0];
section.appendChild(
StatsListing(
'withTooltip',
'"Chain" Reward (CUR) (Golden / Wrath)',
document.createTextNode(
`${Beautify(chainCur)} / ${Beautify(chainCurWrath)}`,
),
goldCookTooltip,
),
);
section.appendChild(StatsListing('withTooltip', 'CPS Needed For Next Level (G / W)', document.createTextNode((`${Beautify(CacheChainRequiredNext)} / ${Beautify(CacheChainWrathRequiredNext)}`)), 'ChainNextLevelPlaceholder')); section.appendChild(
section.appendChild(StatsListing('withTooltip', 'CPS Needed For Next Level (Frenzy) (G / W)', document.createTextNode((`${Beautify(CacheChainFrenzyRequiredNext)} / ${Beautify(CacheChainFrenzyWrathRequiredNext)}`)), 'ChainNextLevelPlaceholder')); StatsListing(
return section; 'withTooltip',
'CPS Needed For Next Level (G / W)',
document.createTextNode(
`${Beautify(CacheChainRequiredNext)} / ${Beautify(
CacheChainWrathRequiredNext,
)}`,
),
'ChainNextLevelPlaceholder',
),
);
section.appendChild(
StatsListing(
'withTooltip',
'CPS Needed For Next Level (Frenzy) (G / W)',
document.createTextNode(
`${Beautify(CacheChainFrenzyRequiredNext)} / ${Beautify(
CacheChainFrenzyWrathRequiredNext,
)}`,
),
'ChainNextLevelPlaceholder',
),
);
return section;
} }
/** /**
@@ -185,48 +391,109 @@ export function ChainSection() {
* @returns {object} section The object contating the Spells section * @returns {object} section The object contating the Spells section
*/ */
export function SpellsSection() { export function SpellsSection() {
const section = document.createElement('div'); const section = document.createElement('div');
section.className = 'CMStatsSpellsSection'; section.className = 'CMStatsSpellsSection';
const conjureColor = ((Game.cookies + GetWrinkConfigBank()) < CacheConjure) ? ColorRed : ColorGreen; const conjureColor =
const conjureTime = ((Game.cookies + GetWrinkConfigBank()) < CacheConjure) ? FormatTime((CacheConjure - (Game.cookies + GetWrinkConfigBank())) / GetCPS()) : ''; Game.cookies + GetWrinkConfigBank() < CacheConjure ? ColorRed : ColorGreen;
const conjureTime =
Game.cookies + GetWrinkConfigBank() < CacheConjure
? FormatTime(
(CacheConjure - (Game.cookies + GetWrinkConfigBank())) / GetCPS(),
)
: '';
const conjureReqFrag = document.createDocumentFragment(); const conjureReqFrag = document.createDocumentFragment();
const conjureReqSpan = document.createElement('span'); const conjureReqSpan = document.createElement('span');
conjureReqSpan.style.fontWeight = 'bold'; conjureReqSpan.style.fontWeight = 'bold';
conjureReqSpan.className = ColorTextPre + conjureColor; conjureReqSpan.className = ColorTextPre + conjureColor;
conjureReqSpan.textContent = Beautify(CacheConjure); conjureReqSpan.textContent = Beautify(CacheConjure);
conjureReqFrag.appendChild(conjureReqSpan); conjureReqFrag.appendChild(conjureReqSpan);
if (conjureTime !== '') { if (conjureTime !== '') {
const conjureReqSmall = document.createElement('small'); const conjureReqSmall = document.createElement('small');
conjureReqSmall.textContent = ` (${conjureTime})`; conjureReqSmall.textContent = ` (${conjureTime})`;
conjureReqFrag.appendChild(conjureReqSmall); conjureReqFrag.appendChild(conjureReqSmall);
} }
section.appendChild(StatsListing('withTooltip', '"Conjure Baked Goods" Cookies Required', conjureReqFrag, 'GoldCookTooltipPlaceholder')); section.appendChild(
section.appendChild(StatsListing('withTooltip', '"Conjure Baked Goods" Reward (MAX)', document.createTextNode(Beautify(CacheConjureReward)), 'GoldCookTooltipPlaceholder')); StatsListing(
'withTooltip',
'"Conjure Baked Goods" Cookies Required',
conjureReqFrag,
'GoldCookTooltipPlaceholder',
),
);
section.appendChild(
StatsListing(
'withTooltip',
'"Conjure Baked Goods" Reward (MAX)',
document.createTextNode(Beautify(CacheConjureReward)),
'GoldCookTooltipPlaceholder',
),
);
const conjureFrenzyColor = ((Game.cookies + GetWrinkConfigBank()) < CacheConjure * 7) ? ColorRed : ColorGreen; const conjureFrenzyColor =
const conjureFrenzyCur = Math.min((Game.cookies + GetWrinkConfigBank()) * 0.15, CacheNoGoldSwitchCookiesPS * 60 * 30); Game.cookies + GetWrinkConfigBank() < CacheConjure * 7
const conjureFrenzyTime = ((Game.cookies + GetWrinkConfigBank()) < CacheConjure * 7) ? FormatTime((CacheConjure * 7 - (Game.cookies + GetWrinkConfigBank())) / GetCPS()) : ''; ? ColorRed
: ColorGreen;
const conjureFrenzyCur = Math.min(
(Game.cookies + GetWrinkConfigBank()) * 0.15,
CacheNoGoldSwitchCookiesPS * 60 * 30,
);
const conjureFrenzyTime =
Game.cookies + GetWrinkConfigBank() < CacheConjure * 7
? FormatTime(
(CacheConjure * 7 - (Game.cookies + GetWrinkConfigBank())) / GetCPS(),
)
: '';
const conjureFrenzyReqFrag = document.createDocumentFragment(); const conjureFrenzyReqFrag = document.createDocumentFragment();
const conjureFrenzyReqSpan = document.createElement('span'); const conjureFrenzyReqSpan = document.createElement('span');
conjureFrenzyReqSpan.style.fontWeight = 'bold'; conjureFrenzyReqSpan.style.fontWeight = 'bold';
conjureFrenzyReqSpan.className = ColorTextPre + conjureFrenzyColor; conjureFrenzyReqSpan.className = ColorTextPre + conjureFrenzyColor;
conjureFrenzyReqSpan.textContent = Beautify(CacheConjure * 7); conjureFrenzyReqSpan.textContent = Beautify(CacheConjure * 7);
conjureFrenzyReqFrag.appendChild(conjureFrenzyReqSpan); conjureFrenzyReqFrag.appendChild(conjureFrenzyReqSpan);
if (conjureFrenzyTime !== '') { if (conjureFrenzyTime !== '') {
const conjureFrenzyReqSmall = document.createElement('small'); const conjureFrenzyReqSmall = document.createElement('small');
conjureFrenzyReqSmall.textContent = ` (${conjureFrenzyTime})`; conjureFrenzyReqSmall.textContent = ` (${conjureFrenzyTime})`;
conjureFrenzyReqFrag.appendChild(conjureFrenzyReqSmall); conjureFrenzyReqFrag.appendChild(conjureFrenzyReqSmall);
} }
section.appendChild(StatsListing('withTooltip', '"Conjure Baked Goods" Cookies Required (Frenzy)', conjureFrenzyReqFrag, 'GoldCookTooltipPlaceholder')); section.appendChild(
section.appendChild(StatsListing('withTooltip', '"Conjure Baked Goods" Reward (MAX) (Frenzy)', document.createTextNode(Beautify(CacheConjureReward * 7)), 'GoldCookTooltipPlaceholder')); StatsListing(
section.appendChild(StatsListing('withTooltip', '"Conjure Baked Goods" Reward (CUR)', document.createTextNode(Beautify(conjureFrenzyCur)), 'GoldCookTooltipPlaceholder')); 'withTooltip',
if (CacheEdifice) { '"Conjure Baked Goods" Cookies Required (Frenzy)',
section.appendChild(StatsListing('withTooltip', '"Spontaneous Edifice" Cookies Required (most expensive building)', document.createTextNode(`${Beautify(CacheEdifice)} (${CacheEdificeBuilding})`), 'GoldCookTooltipPlaceholder')); conjureFrenzyReqFrag,
} 'GoldCookTooltipPlaceholder',
return section; ),
);
section.appendChild(
StatsListing(
'withTooltip',
'"Conjure Baked Goods" Reward (MAX) (Frenzy)',
document.createTextNode(Beautify(CacheConjureReward * 7)),
'GoldCookTooltipPlaceholder',
),
);
section.appendChild(
StatsListing(
'withTooltip',
'"Conjure Baked Goods" Reward (CUR)',
document.createTextNode(Beautify(conjureFrenzyCur)),
'GoldCookTooltipPlaceholder',
),
);
if (CacheEdifice) {
section.appendChild(
StatsListing(
'withTooltip',
'"Spontaneous Edifice" Cookies Required (most expensive building)',
document.createTextNode(
`${Beautify(CacheEdifice)} (${CacheEdificeBuilding})`,
),
'GoldCookTooltipPlaceholder',
),
);
}
return section;
} }
/** /**
@@ -234,37 +501,65 @@ export function SpellsSection() {
* @returns {object} section The object contating the Spells section * @returns {object} section The object contating the Spells section
*/ */
export function GardenSection() { export function GardenSection() {
const section = document.createElement('div'); const section = document.createElement('div');
section.className = 'CMStatsGardenSection'; section.className = 'CMStatsGardenSection';
const bakeberryColor = (Game.cookies < Game.cookiesPs * 60 * 30) ? ColorRed : ColorGreen; const bakeberryColor =
const bakeberryFrag = document.createElement('span'); Game.cookies < Game.cookiesPs * 60 * 30 ? ColorRed : ColorGreen;
bakeberryFrag.style.fontWeight = 'bold'; const bakeberryFrag = document.createElement('span');
bakeberryFrag.className = ColorTextPre + bakeberryColor; bakeberryFrag.style.fontWeight = 'bold';
bakeberryFrag.textContent = Beautify(Game.cookiesPs * 60 * 30); bakeberryFrag.className = ColorTextPre + bakeberryColor;
section.appendChild(StatsListing('basic', 'Cookies required for max reward of Bakeberry: ', bakeberryFrag)); bakeberryFrag.textContent = Beautify(Game.cookiesPs * 60 * 30);
section.appendChild(
StatsListing(
'basic',
'Cookies required for max reward of Bakeberry: ',
bakeberryFrag,
),
);
const chocorootColor = (Game.cookies < Game.cookiesPs * 60 * 3) ? ColorRed : ColorGreen; const chocorootColor =
const chocorootFrag = document.createElement('span'); Game.cookies < Game.cookiesPs * 60 * 3 ? ColorRed : ColorGreen;
chocorootFrag.style.fontWeight = 'bold'; const chocorootFrag = document.createElement('span');
chocorootFrag.className = ColorTextPre + chocorootColor; chocorootFrag.style.fontWeight = 'bold';
chocorootFrag.textContent = Beautify(Game.cookiesPs * 60 * 3); chocorootFrag.className = ColorTextPre + chocorootColor;
section.appendChild(StatsListing('basic', 'Cookies required for max reward of Chocoroot: ', chocorootFrag)); chocorootFrag.textContent = Beautify(Game.cookiesPs * 60 * 3);
section.appendChild(
StatsListing(
'basic',
'Cookies required for max reward of Chocoroot: ',
chocorootFrag,
),
);
const queenbeetColor = (Game.cookies < Game.cookiesPs * 60 * 60) ? ColorRed : ColorGreen; const queenbeetColor =
const queenbeetFrag = document.createElement('span'); Game.cookies < Game.cookiesPs * 60 * 60 ? ColorRed : ColorGreen;
queenbeetFrag.style.fontWeight = 'bold'; const queenbeetFrag = document.createElement('span');
queenbeetFrag.className = ColorTextPre + queenbeetColor; queenbeetFrag.style.fontWeight = 'bold';
queenbeetFrag.textContent = Beautify(Game.cookiesPs * 60 * 60); queenbeetFrag.className = ColorTextPre + queenbeetColor;
section.appendChild(StatsListing('basic', 'Cookies required for max reward of Queenbeet: ', queenbeetFrag)); queenbeetFrag.textContent = Beautify(Game.cookiesPs * 60 * 60);
section.appendChild(
StatsListing(
'basic',
'Cookies required for max reward of Queenbeet: ',
queenbeetFrag,
),
);
const duketaterColor = (Game.cookies < Game.cookiesPs * 60 * 120) ? ColorRed : ColorGreen; const duketaterColor =
const duketaterFrag = document.createElement('span'); Game.cookies < Game.cookiesPs * 60 * 120 ? ColorRed : ColorGreen;
duketaterFrag.style.fontWeight = 'bold'; const duketaterFrag = document.createElement('span');
duketaterFrag.className = ColorTextPre + duketaterColor; duketaterFrag.style.fontWeight = 'bold';
duketaterFrag.textContent = Beautify(Game.cookiesPs * 60 * 120); duketaterFrag.className = ColorTextPre + duketaterColor;
section.appendChild(StatsListing('basic', 'Cookies required for max reward of Duketater: ', duketaterFrag)); duketaterFrag.textContent = Beautify(Game.cookiesPs * 60 * 120);
return section; section.appendChild(
StatsListing(
'basic',
'Cookies required for max reward of Duketater: ',
duketaterFrag,
),
);
return section;
} }
/** /**
@@ -272,78 +567,175 @@ export function GardenSection() {
* @returns {object} section The object contating the Prestige section * @returns {object} section The object contating the Prestige section
*/ */
export function PrestigeSection() { export function PrestigeSection() {
const section = document.createElement('div'); const section = document.createElement('div');
section.className = 'CMStatsPrestigeSection'; section.className = 'CMStatsPrestigeSection';
const possiblePresMax = Math.floor(Game.HowMuchPrestige(CacheRealCookiesEarned const possiblePresMax = Math.floor(
+ Game.cookiesReset + CacheWrinklersTotal Game.HowMuchPrestige(
+ (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg') ? CacheLastChoEgg : 0))); CacheRealCookiesEarned +
section.appendChild(StatsListing('withTooltip', 'Prestige Level (CUR / MAX)', document.createTextNode(`${Beautify(Game.prestige)} / ${Beautify(possiblePresMax)}`), 'PrestMaxTooltipPlaceholder')); Game.cookiesReset +
CacheWrinklersTotal +
(Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg')
? CacheLastChoEgg
: 0),
),
);
section.appendChild(
StatsListing(
'withTooltip',
'Prestige Level (CUR / MAX)',
document.createTextNode(
`${Beautify(Game.prestige)} / ${Beautify(possiblePresMax)}`,
),
'PrestMaxTooltipPlaceholder',
),
);
const neededCook = Game.HowManyCookiesReset(possiblePresMax + 1) - (CacheRealCookiesEarned + Game.cookiesReset + CacheWrinklersTotal + ((Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg') ? CacheLastChoEgg : 0) ? CacheLastChoEgg : 0)); const neededCook =
const cookiesNextFrag = document.createDocumentFragment(); Game.HowManyCookiesReset(possiblePresMax + 1) -
cookiesNextFrag.appendChild(document.createTextNode(Beautify(neededCook))); (CacheRealCookiesEarned +
const cookiesNextSmall = document.createElement('small'); Game.cookiesReset +
cookiesNextSmall.textContent = ` (${FormatTime(neededCook / CacheAvgCPSWithChoEgg, 1)})`; CacheWrinklersTotal +
cookiesNextFrag.appendChild(cookiesNextSmall); ((
section.appendChild(StatsListing('withTooltip', 'Cookies To Next Level', cookiesNextFrag, 'NextPrestTooltipPlaceholder')); Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg')
? CacheLastChoEgg
: 0
)
? CacheLastChoEgg
: 0));
const cookiesNextFrag = document.createDocumentFragment();
cookiesNextFrag.appendChild(document.createTextNode(Beautify(neededCook)));
const cookiesNextSmall = document.createElement('small');
cookiesNextSmall.textContent = ` (${FormatTime(
neededCook / CacheAvgCPSWithChoEgg,
1,
)})`;
cookiesNextFrag.appendChild(cookiesNextSmall);
section.appendChild(
StatsListing(
'withTooltip',
'Cookies To Next Level',
cookiesNextFrag,
'NextPrestTooltipPlaceholder',
),
);
section.appendChild(StatsListing('withTooltip', 'Heavenly Chips (CUR / MAX)', document.createTextNode(`${Beautify(Game.heavenlyChips)} / ${Beautify((possiblePresMax - Game.prestige) + Game.heavenlyChips)}`), 'HeavenChipMaxTooltipPlaceholder')); section.appendChild(
StatsListing(
'withTooltip',
'Heavenly Chips (CUR / MAX)',
document.createTextNode(
`${Beautify(Game.heavenlyChips)} / ${Beautify(
possiblePresMax - Game.prestige + Game.heavenlyChips,
)}`,
),
'HeavenChipMaxTooltipPlaceholder',
),
);
section.appendChild(StatsListing('basic', 'Heavenly Chips Per Second (last 5 seconds)', document.createTextNode(Beautify(CacheHCPerSecond, 2)))); section.appendChild(
StatsListing(
'basic',
'Heavenly Chips Per Second (last 5 seconds)',
document.createTextNode(Beautify(CacheHCPerSecond, 2)),
),
);
const HCTarget = Number(CMOptions.HeavenlyChipsTarget); const HCTarget = Number(CMOptions.HeavenlyChipsTarget);
if (!Number.isNaN(HCTarget)) { if (!Number.isNaN(HCTarget)) {
const CookiesTillTarget = HCTarget - Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)); const CookiesTillTarget =
if (CookiesTillTarget > 0) { HCTarget -
section.appendChild(StatsListing('basic', 'Heavenly Chips To Target Set In Settings (CUR)', document.createTextNode(Beautify(CookiesTillTarget)))); Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned));
section.appendChild(StatsListing('basic', 'Time To Target (CUR, Current 5 Second Average)', document.createTextNode(FormatTime(CookiesTillTarget / CacheHCPerSecond)))); if (CookiesTillTarget > 0) {
} section.appendChild(
} StatsListing(
'basic',
'Heavenly Chips To Target Set In Settings (CUR)',
document.createTextNode(Beautify(CookiesTillTarget)),
),
);
section.appendChild(
StatsListing(
'basic',
'Time To Target (CUR, Current 5 Second Average)',
document.createTextNode(
FormatTime(CookiesTillTarget / CacheHCPerSecond),
),
),
);
}
}
const resetBonus = ResetBonus(possiblePresMax); const resetBonus = ResetBonus(possiblePresMax);
const resetFrag = document.createDocumentFragment(); const resetFrag = document.createDocumentFragment();
resetFrag.appendChild(document.createTextNode(Beautify(resetBonus))); resetFrag.appendChild(document.createTextNode(Beautify(resetBonus)));
const increase = Math.round(resetBonus / Game.cookiesPs * 10000); const increase = Math.round((resetBonus / Game.cookiesPs) * 10000);
if (Number.isFinite(increase) && increase !== 0) { if (Number.isFinite(increase) && increase !== 0) {
const resetSmall = document.createElement('small'); const resetSmall = document.createElement('small');
resetSmall.textContent = ` (${increase / 100}% of income)`; resetSmall.textContent = ` (${increase / 100}% of income)`;
resetFrag.appendChild(resetSmall); resetFrag.appendChild(resetSmall);
} }
section.appendChild(StatsListing('withTooltip', 'Reset Bonus Income', resetFrag, 'ResetTooltipPlaceholder')); section.appendChild(
StatsListing(
'withTooltip',
'Reset Bonus Income',
resetFrag,
'ResetTooltipPlaceholder',
),
);
const currentPrestige = Math.floor(Game.HowMuchPrestige(Game.cookiesReset)); const currentPrestige = Math.floor(Game.HowMuchPrestige(Game.cookiesReset));
const willHave = Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)); const willHave = Math.floor(
const willGet = willHave - currentPrestige; Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned),
if (!Game.Has('Lucky digit')) { );
let delta7 = 7 - (willHave % 10); const willGet = willHave - currentPrestige;
if (delta7 < 0) delta7 += 10; if (!Game.Has('Lucky digit')) {
const next7Reset = willGet + delta7; let delta7 = 7 - (willHave % 10);
const next7Total = willHave + delta7; if (delta7 < 0) delta7 += 10;
const frag7 = document.createDocumentFragment(); const next7Reset = willGet + delta7;
frag7.appendChild(document.createTextNode(`${next7Total.toLocaleString()} / ${next7Reset.toLocaleString()} (+${delta7})`)); const next7Total = willHave + delta7;
section.appendChild(StatsListing('basic', 'Next "Lucky Digit" (total / reset)', frag7)); const frag7 = document.createDocumentFragment();
} frag7.appendChild(
document.createTextNode(
`${next7Total.toLocaleString()} / ${next7Reset.toLocaleString()} (+${delta7})`,
),
);
section.appendChild(
StatsListing('basic', 'Next "Lucky Digit" (total / reset)', frag7),
);
}
if (!Game.Has('Lucky number')) { if (!Game.Has('Lucky number')) {
let delta777 = 777 - (willHave % 1000); let delta777 = 777 - (willHave % 1000);
if (delta777 < 0) delta777 += 1000; if (delta777 < 0) delta777 += 1000;
const next777Reset = willGet + delta777; const next777Reset = willGet + delta777;
const next777Total = willHave + delta777; const next777Total = willHave + delta777;
const frag777 = document.createDocumentFragment(); const frag777 = document.createDocumentFragment();
frag777.appendChild(document.createTextNode(`${next777Total.toLocaleString()} / ${next777Reset.toLocaleString()} (+${delta777})`)); frag777.appendChild(
section.appendChild(StatsListing('basic', 'Next "Lucky Number" (total / reset)', frag777)); document.createTextNode(
} `${next777Total.toLocaleString()} / ${next777Reset.toLocaleString()} (+${delta777})`,
),
);
section.appendChild(
StatsListing('basic', 'Next "Lucky Number" (total / reset)', frag777),
);
}
if (!Game.Has('Lucky payout')) { if (!Game.Has('Lucky payout')) {
let delta777777 = 777777 - (willHave % 1000000); let delta777777 = 777777 - (willHave % 1000000);
if (delta777777 < 0) delta777777 += 1000000; if (delta777777 < 0) delta777777 += 1000000;
const next777777Reset = willGet + delta777777; const next777777Reset = willGet + delta777777;
const next777777Total = willHave + delta777777; const next777777Total = willHave + delta777777;
const frag777777 = document.createDocumentFragment(); const frag777777 = document.createDocumentFragment();
frag777777.appendChild(document.createTextNode(`${next777777Total.toLocaleString()} / ${next777777Reset.toLocaleString()} (+${delta777777})`)); frag777777.appendChild(
section.appendChild(StatsListing('basic', 'Next "Lucky Payout" (total / reset)', frag777777)); document.createTextNode(
} `${next777777Total.toLocaleString()} / ${next777777Reset.toLocaleString()} (+${delta777777})`,
),
);
section.appendChild(
StatsListing('basic', 'Next "Lucky Payout" (total / reset)', frag777777),
);
}
return section; return section;
} }

View File

@@ -9,34 +9,37 @@ import { LatestReleaseNotes, ModDescription } from '../../Data/Moddata';
* @param {object} title On object that includes the title of the menu * @param {object} title On object that includes the title of the menu
*/ */
export default function AddMenuInfo(title) { export default function AddMenuInfo(title) {
const info = document.createElement('div'); const info = document.createElement('div');
info.className = 'subsection'; info.className = 'subsection';
const span = document.createElement('span'); const span = document.createElement('span');
span.style.cursor = 'pointer'; span.style.cursor = 'pointer';
span.style.display = 'inline-block'; span.style.display = 'inline-block';
span.style.height = '14px'; span.style.height = '14px';
span.style.width = '14px'; span.style.width = '14px';
span.style.borderRadius = '7px'; span.style.borderRadius = '7px';
span.style.textAlign = 'center'; span.style.textAlign = 'center';
span.style.backgroundColor = '#C0C0C0'; span.style.backgroundColor = '#C0C0C0';
span.style.color = 'black'; span.style.color = 'black';
span.style.fontSize = '13px'; span.style.fontSize = '13px';
span.style.verticalAlign = 'middle'; span.style.verticalAlign = 'middle';
span.textContent = CMOptions.Header.InfoTab ? '-' : '+'; span.textContent = CMOptions.Header.InfoTab ? '-' : '+';
span.onclick = function () { ToggleHeader('InfoTab'); Game.UpdateMenu(); }; span.onclick = function () {
title.appendChild(span); ToggleHeader('InfoTab');
info.appendChild(title); Game.UpdateMenu();
};
title.appendChild(span);
info.appendChild(title);
if (CMOptions.Header.InfoTab) { if (CMOptions.Header.InfoTab) {
const description = document.createElement('div'); const description = document.createElement('div');
description.innerHTML = ModDescription; description.innerHTML = ModDescription;
info.appendChild(description); info.appendChild(description);
const notes = document.createElement('div'); const notes = document.createElement('div');
notes.innerHTML = LatestReleaseNotes; notes.innerHTML = LatestReleaseNotes;
info.appendChild(notes); info.appendChild(notes);
} }
const menu = l('menu').children[1]; const menu = l('menu').children[1];
menu.insertBefore(info, menu.children[1]); menu.insertBefore(info, menu.children[1]);
} }

View File

@@ -5,5 +5,11 @@ import { CMOptions } from '../../Config/VariablesAndData';
* It is called by CM.Disp.Draw() * It is called by CM.Disp.Draw()
*/ */
export default function RefreshMenu() { export default function RefreshMenu() {
if (CMOptions.UpStats && Game.onMenu === 'stats' && (Game.drawT - 1) % (Game.fps * 5) !== 0 && (Game.drawT - 1) % Game.fps === 0) Game.UpdateMenu(); if (
CMOptions.UpStats &&
Game.onMenu === 'stats' &&
(Game.drawT - 1) % (Game.fps * 5) !== 0 &&
(Game.drawT - 1) % Game.fps === 0
)
Game.UpdateMenu();
} }

View File

@@ -1,12 +1,21 @@
/** Functions related to the Options/Preferences page */ /** Functions related to the Options/Preferences page */
import jscolor, * as JsColor from '@eastdesire/jscolor'; import jscolor, * as JsColor from '@eastdesire/jscolor';
import { LoadConfig, SaveConfig } from '../../Config/SaveLoadReload/SaveLoadReloadSettings';
import { import {
ConfigPrefix, ToggleConfig, ToggleConfigVolume, ToggleHeader, LoadConfig,
SaveConfig,
} from '../../Config/SaveLoadReload/SaveLoadReloadSettings';
import {
ConfigPrefix,
ToggleConfig,
ToggleConfigVolume,
ToggleHeader,
} from '../../Config/ToggleSetting'; } from '../../Config/ToggleSetting';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import { ConfigGroups, ConfigGroupsNotification } from '../../Data/Sectionheaders'; import {
ConfigGroups,
ConfigGroupsNotification,
} from '../../Data/Sectionheaders';
import Config from '../../Data/SettingsData'; import Config from '../../Data/SettingsData';
import ConfigDefault from '../../Data/SettingsDefault'; import ConfigDefault from '../../Data/SettingsDefault';
import RefreshScale from '../HelperFunctions/RefreshScale'; import RefreshScale from '../HelperFunctions/RefreshScale';
@@ -20,27 +29,30 @@ import { Colors } from '../VariablesAndData';
* @returns {object} div The header object * @returns {object} div The header object
*/ */
function CreatePrefHeader(config, text) { function CreatePrefHeader(config, text) {
const div = document.createElement('div'); const div = document.createElement('div');
div.className = 'title'; div.className = 'title';
div.style.opacity = '0.7'; div.style.opacity = '0.7';
div.style.fontSize = '17px'; div.style.fontSize = '17px';
div.appendChild(document.createTextNode(`${text} `)); div.appendChild(document.createTextNode(`${text} `));
const span = document.createElement('span'); // Creates the +/- button const span = document.createElement('span'); // Creates the +/- button
span.style.cursor = 'pointer'; span.style.cursor = 'pointer';
span.style.display = 'inline-block'; span.style.display = 'inline-block';
span.style.height = '14px'; span.style.height = '14px';
span.style.width = '14px'; span.style.width = '14px';
span.style.borderRadius = '7px'; span.style.borderRadius = '7px';
span.style.textAlign = 'center'; span.style.textAlign = 'center';
span.style.backgroundColor = '#C0C0C0'; span.style.backgroundColor = '#C0C0C0';
span.style.color = 'black'; span.style.color = 'black';
span.style.fontSize = '13px'; span.style.fontSize = '13px';
span.style.verticalAlign = 'middle'; span.style.verticalAlign = 'middle';
span.textContent = CMOptions.Header[config] ? '-' : '+'; span.textContent = CMOptions.Header[config] ? '-' : '+';
span.onclick = function () { ToggleHeader(config); Game.UpdateMenu(); }; span.onclick = function () {
div.appendChild(span); ToggleHeader(config);
return div; Game.UpdateMenu();
};
div.appendChild(span);
return div;
} }
/** /**
@@ -49,129 +61,150 @@ function CreatePrefHeader(config, text) {
* @returns {object} div The option object * @returns {object} div The option object
*/ */
function CreatePrefOption(config) { function CreatePrefOption(config) {
const div = document.createElement('div'); const div = document.createElement('div');
div.className = 'listing'; div.className = 'listing';
if (Config[config].type === 'bool') { if (Config[config].type === 'bool') {
const a = document.createElement('a'); const a = document.createElement('a');
if (Config[config].toggle && CMOptions[config] === 0) { if (Config[config].toggle && CMOptions[config] === 0) {
a.className = 'option off'; a.className = 'option off';
} else { } else {
a.className = 'option'; a.className = 'option';
} }
a.id = ConfigPrefix + config; a.id = ConfigPrefix + config;
a.onclick = function () { ToggleConfig(config); }; a.onclick = function () {
a.textContent = Config[config].label[CMOptions[config]]; ToggleConfig(config);
div.appendChild(a); };
const label = document.createElement('label'); a.textContent = Config[config].label[CMOptions[config]];
label.textContent = Config[config].desc; div.appendChild(a);
div.appendChild(label); const label = document.createElement('label');
return div; label.textContent = Config[config].desc;
} if (Config[config].type === 'vol') { div.appendChild(label);
const volume = document.createElement('div'); return div;
volume.className = 'sliderBox'; }
const title = document.createElement('div'); if (Config[config].type === 'vol') {
title.style.float = 'left'; const volume = document.createElement('div');
title.innerHTML = Config[config].desc; volume.className = 'sliderBox';
volume.appendChild(title); const title = document.createElement('div');
const percent = document.createElement('div'); title.style.float = 'left';
percent.id = `slider${config}right`; title.innerHTML = Config[config].desc;
percent.style.float = 'right'; volume.appendChild(title);
percent.innerHTML = `${CMOptions[config]}%`; const percent = document.createElement('div');
volume.appendChild(percent); percent.id = `slider${config}right`;
const slider = document.createElement('input'); percent.style.float = 'right';
slider.className = 'slider'; percent.innerHTML = `${CMOptions[config]}%`;
slider.id = `slider${config}`; volume.appendChild(percent);
slider.style.clear = 'both'; const slider = document.createElement('input');
slider.type = 'range'; slider.className = 'slider';
slider.min = '0'; slider.id = `slider${config}`;
slider.max = '100'; slider.style.clear = 'both';
slider.step = '1'; slider.type = 'range';
slider.value = CMOptions[config]; slider.min = '0';
slider.oninput = function () { ToggleConfigVolume(config); }; slider.max = '100';
slider.onchange = function () { ToggleConfigVolume(config); }; slider.step = '1';
volume.appendChild(slider); slider.value = CMOptions[config];
div.appendChild(volume); slider.oninput = function () {
return div; ToggleConfigVolume(config);
} if (Config[config].type === 'url') { };
const span = document.createElement('span'); slider.onchange = function () {
span.className = 'option'; ToggleConfigVolume(config);
span.textContent = `${Config[config].label} `; };
div.appendChild(span); volume.appendChild(slider);
const input = document.createElement('input'); div.appendChild(volume);
input.id = ConfigPrefix + config; return div;
input.className = 'option'; }
input.type = 'text'; if (Config[config].type === 'url') {
input.readOnly = true; const span = document.createElement('span');
input.setAttribute('value', CMOptions[config]); span.className = 'option';
input.style.width = '300px'; span.textContent = `${Config[config].label} `;
div.appendChild(input); div.appendChild(span);
div.appendChild(document.createTextNode(' ')); const input = document.createElement('input');
const inputPrompt = document.createElement('input'); input.id = ConfigPrefix + config;
inputPrompt.id = `${ConfigPrefix + config}Prompt`; input.className = 'option';
inputPrompt.className = 'option'; input.type = 'text';
inputPrompt.type = 'text'; input.readOnly = true;
inputPrompt.setAttribute('value', CMOptions[config]); input.setAttribute('value', CMOptions[config]);
const a = document.createElement('a'); input.style.width = '300px';
a.className = 'option'; div.appendChild(input);
a.onclick = function () { div.appendChild(document.createTextNode(' '));
Game.Prompt(inputPrompt.outerHTML, [['Save', function () { CMOptions[`${config}`] = l(`${ConfigPrefix}${config}Prompt`).value; SaveConfig(); Game.ClosePrompt(); Game.UpdateMenu(); }], 'Cancel']); const inputPrompt = document.createElement('input');
}; inputPrompt.id = `${ConfigPrefix + config}Prompt`;
a.textContent = 'Edit'; inputPrompt.className = 'option';
div.appendChild(a); inputPrompt.type = 'text';
const label = document.createElement('label'); inputPrompt.setAttribute('value', CMOptions[config]);
label.textContent = Config[config].desc; const a = document.createElement('a');
div.appendChild(label); a.className = 'option';
return div; a.onclick = function () {
} if (Config[config].type === 'color') { Game.Prompt(inputPrompt.outerHTML, [
div.className = ''; [
for (let i = 0; i < Colors.length; i++) { 'Save',
const innerDiv = document.createElement('div'); function () {
innerDiv.className = 'listing'; CMOptions[`${config}`] = l(`${ConfigPrefix}${config}Prompt`).value;
const input = document.createElement('input'); SaveConfig();
input.id = Colors[i]; Game.ClosePrompt();
input.style.width = '65px'; Game.UpdateMenu();
input.setAttribute('value', CMOptions.Colors[Colors[i]]); },
innerDiv.appendChild(input); ],
const change = function () { 'Cancel',
CMOptions.Colors[this.targetElement.id] = this.toHEXString(); ]);
UpdateColors(); };
SaveConfig(); a.textContent = 'Edit';
Game.UpdateMenu(); div.appendChild(a);
}; const label = document.createElement('label');
new JsColor(input, { hash: true, position: 'right', onInput: change }); label.textContent = Config[config].desc;
const label = document.createElement('label'); div.appendChild(label);
label.textContent = Config.Colors.desc[Colors[i]]; return div;
innerDiv.appendChild(label); }
div.appendChild(innerDiv); if (Config[config].type === 'color') {
} div.className = '';
jscolor.init(); for (let i = 0; i < Colors.length; i++) {
return div; const innerDiv = document.createElement('div');
} if (Config[config].type === 'numscale') { innerDiv.className = 'listing';
const span = document.createElement('span'); const input = document.createElement('input');
span.className = 'option'; input.id = Colors[i];
span.textContent = `${Config[config].label} `; input.style.width = '65px';
div.appendChild(span); input.setAttribute('value', CMOptions.Colors[Colors[i]]);
const input = document.createElement('input'); innerDiv.appendChild(input);
input.id = ConfigPrefix + config; const change = function () {
input.className = 'option'; CMOptions.Colors[this.targetElement.id] = this.toHEXString();
input.type = 'number'; UpdateColors();
input.value = (CMOptions[config]); SaveConfig();
input.min = Config[config].min; Game.UpdateMenu();
input.max = Config[config].max; };
input.oninput = function () { new JsColor(input, { hash: true, position: 'right', onInput: change });
if (this.value > this.max) console.log('TEST'); const label = document.createElement('label');
CMOptions[config] = this.value; label.textContent = Config.Colors.desc[Colors[i]];
SaveConfig(); innerDiv.appendChild(label);
RefreshScale(); div.appendChild(innerDiv);
}; }
div.appendChild(input); jscolor.init();
div.appendChild(document.createTextNode(' ')); return div;
const label = document.createElement('label'); }
label.textContent = Config[config].desc; if (Config[config].type === 'numscale') {
div.appendChild(label); const span = document.createElement('span');
return div; span.className = 'option';
} span.textContent = `${Config[config].label} `;
return div; div.appendChild(span);
const input = document.createElement('input');
input.id = ConfigPrefix + config;
input.className = 'option';
input.type = 'number';
input.value = CMOptions[config];
input.min = Config[config].min;
input.max = Config[config].max;
input.oninput = function () {
if (this.value > this.max) console.log('TEST');
CMOptions[config] = this.value;
SaveConfig();
RefreshScale();
};
div.appendChild(input);
div.appendChild(document.createTextNode(' '));
const label = document.createElement('label');
label.textContent = Config[config].desc;
div.appendChild(label);
return div;
}
return div;
} }
/** /**
@@ -180,42 +213,55 @@ function CreatePrefOption(config) {
* @param {object} title On object that includes the title of the menu * @param {object} title On object that includes the title of the menu
*/ */
export default function AddMenuPref(title) { export default function AddMenuPref(title) {
const frag = document.createDocumentFragment(); const frag = document.createDocumentFragment();
frag.appendChild(title); frag.appendChild(title);
for (const group of Object.keys(ConfigGroups)) { for (const group of Object.keys(ConfigGroups)) {
const groupObject = CreatePrefHeader(group, ConfigGroups[group]); // (group, display-name of group) const groupObject = CreatePrefHeader(group, ConfigGroups[group]); // (group, display-name of group)
frag.appendChild(groupObject); frag.appendChild(groupObject);
if (CMOptions.Header[group]) { // 0 is show, 1 is collapsed if (CMOptions.Header[group]) {
// Make sub-sections of Notification section // 0 is show, 1 is collapsed
if (group === 'Notification') { // Make sub-sections of Notification section
for (const subGroup of Object.keys(ConfigGroupsNotification)) { if (group === 'Notification') {
const subGroupObject = CreatePrefHeader(subGroup, ConfigGroupsNotification[subGroup]); // (group, display-name of group) for (const subGroup of Object.keys(ConfigGroupsNotification)) {
subGroupObject.style.fontSize = '15px'; const subGroupObject = CreatePrefHeader(
subGroupObject.style.opacity = '0.5'; subGroup,
frag.appendChild(subGroupObject); ConfigGroupsNotification[subGroup],
if (CMOptions.Header[subGroup]) { ); // (group, display-name of group)
for (const option in Config) { subGroupObject.style.fontSize = '15px';
if (Config[option].group === subGroup) frag.appendChild(CreatePrefOption(option)); subGroupObject.style.opacity = '0.5';
} frag.appendChild(subGroupObject);
} if (CMOptions.Header[subGroup]) {
} for (const option in Config) {
} else { if (Config[option].group === subGroup)
for (const option of Object.keys(Config)) { frag.appendChild(CreatePrefOption(option));
if (Config[option].group === group) frag.appendChild(CreatePrefOption(option)); }
} }
} }
} } else {
} for (const option of Object.keys(Config)) {
if (Config[option].group === group)
frag.appendChild(CreatePrefOption(option));
}
}
}
}
const resDef = document.createElement('div'); const resDef = document.createElement('div');
resDef.className = 'listing'; resDef.className = 'listing';
const resDefBut = document.createElement('a'); const resDefBut = document.createElement('a');
resDefBut.className = 'option'; resDefBut.className = 'option';
resDefBut.onclick = function () { LoadConfig(ConfigDefault); }; resDefBut.onclick = function () {
resDefBut.textContent = 'Restore Default'; LoadConfig(ConfigDefault);
resDef.appendChild(resDefBut); };
frag.appendChild(resDef); resDefBut.textContent = 'Restore Default';
resDef.appendChild(resDefBut);
frag.appendChild(resDef);
l('menu').childNodes[2].insertBefore(frag, l('menu').childNodes[2].childNodes[l('menu').childNodes[2].childNodes.length - 1]); l('menu').childNodes[2].insertBefore(
frag,
l('menu').childNodes[2].childNodes[
l('menu').childNodes[2].childNodes.length - 1
],
);
} }

View File

@@ -9,17 +9,26 @@ import { isInitializing } from '../../InitSaveLoad/Variables';
* @param {string} config The setting in CM.Options that is checked before creating the flash * @param {string} config The setting in CM.Options that is checked before creating the flash
*/ */
export default function Flash(mode, config) { export default function Flash(mode, config) {
// The arguments check makes the sound not play upon initialization of the mod // The arguments check makes the sound not play upon initialization of the mod
if ((CMOptions[config] === 1 && mode === 3 && isInitializing === false) || mode === 1) { if (
l('CMWhiteScreen').style.opacity = '0.5'; (CMOptions[config] === 1 && mode === 3 && isInitializing === false) ||
if (mode === 3) { mode === 1
l('CMWhiteScreen').style.display = 'inline'; ) {
setTimeout(function () { Flash(2, config); }, 1000 / Game.fps); l('CMWhiteScreen').style.opacity = '0.5';
} else { if (mode === 3) {
setTimeout(function () { Flash(0, config); }, 1000 / Game.fps); l('CMWhiteScreen').style.display = 'inline';
} setTimeout(function () {
} else if (mode === 2) { Flash(2, config);
l('CMWhiteScreen').style.opacity = '1'; }, 1000 / Game.fps);
setTimeout(function () { Flash(1, config); }, 1000 / Game.fps); } else {
} else if (mode === 0) l('CMWhiteScreen').style.display = 'none'; setTimeout(function () {
Flash(0, config);
}, 1000 / Game.fps);
}
} else if (mode === 2) {
l('CMWhiteScreen').style.opacity = '1';
setTimeout(function () {
Flash(1, config);
}, 1000 / Game.fps);
} else if (mode === 0) l('CMWhiteScreen').style.display = 'none';
} }

View File

@@ -11,9 +11,13 @@ import { isInitializing } from '../../InitSaveLoad/Variables';
* @param {string} message The text of the to-be created notifications * @param {string} message The text of the to-be created notifications
*/ */
export default function Notification(notifyConfig, title, message) { export default function Notification(notifyConfig, title, message) {
// The arguments check makes the sound not play upon initialization of the mod // The arguments check makes the sound not play upon initialization of the mod
if (CMOptions[notifyConfig] === 1 && document.visibilityState === 'hidden' && isInitializing === false) { if (
const CookieIcon = 'https://orteil.dashnet.org/cookieclicker/favicon.ico'; CMOptions[notifyConfig] === 1 &&
new Notification(title, { body: message, badge: CookieIcon }); document.visibilityState === 'hidden' &&
} isInitializing === false
) {
const CookieIcon = 'https://orteil.dashnet.org/cookieclicker/favicon.ico';
new Notification(title, { body: message, badge: CookieIcon });
}
} }

View File

@@ -9,12 +9,13 @@ import { isInitializing } from '../../InitSaveLoad/Variables';
* @param {string} volConfig The setting in CM.Options that is checked to determine volume * @param {string} volConfig The setting in CM.Options that is checked to determine volume
*/ */
export default function PlaySound(url, sndConfig, volConfig) { export default function PlaySound(url, sndConfig, volConfig) {
// The arguments check makes the sound not play upon initialization of the mod // The arguments check makes the sound not play upon initialization of the mod
if (CMOptions[sndConfig] === 1 && isInitializing === false) { if (CMOptions[sndConfig] === 1 && isInitializing === false) {
// eslint-disable-next-line new-cap // eslint-disable-next-line new-cap
const sound = new realAudio(url); const sound = new realAudio(url);
if (CMOptions.GeneralSound) sound.volume = (CMOptions[volConfig] / 100) * (Game.volume / 100); if (CMOptions.GeneralSound)
else sound.volume = (CMOptions[volConfig] / 100); sound.volume = (CMOptions[volConfig] / 100) * (Game.volume / 100);
sound.play(); else sound.volume = CMOptions[volConfig] / 100;
} sound.play();
}
} }

View File

@@ -6,11 +6,11 @@ import { LastGoldenCookieState } from '../../Main/VariablesAndData';
* This function creates the Favicon, it is called by CM.Main.DelayInit() * This function creates the Favicon, it is called by CM.Main.DelayInit()
*/ */
export function CreateFavicon() { export function CreateFavicon() {
const Favicon = document.createElement('link'); const Favicon = document.createElement('link');
Favicon.id = 'CMFavicon'; Favicon.id = 'CMFavicon';
Favicon.rel = 'shortcut icon'; Favicon.rel = 'shortcut icon';
Favicon.href = 'https://orteil.dashnet.org/cookieclicker/favicon.ico'; Favicon.href = 'https://orteil.dashnet.org/cookieclicker/favicon.ico';
document.getElementsByTagName('head')[0].appendChild(Favicon); document.getElementsByTagName('head')[0].appendChild(Favicon);
} }
/** /**
@@ -18,8 +18,14 @@ export function CreateFavicon() {
* By relying on CM.Cache.spawnedGoldenShimmer it only changes for non-user spawned cookie * By relying on CM.Cache.spawnedGoldenShimmer it only changes for non-user spawned cookie
*/ */
export function UpdateFavicon() { export function UpdateFavicon() {
if (CMOptions.Favicon === 1 && LastGoldenCookieState > 0) { if (CMOptions.Favicon === 1 && LastGoldenCookieState > 0) {
if (CacheSpawnedGoldenShimmer.wrath) l('CMFavicon').href = 'https://aktanusa.github.io/CookieMonster/favicon/wrathCookie.ico'; if (CacheSpawnedGoldenShimmer.wrath)
else l('CMFavicon').href = 'https://aktanusa.github.io/CookieMonster/favicon/goldenCookie.ico'; l('CMFavicon').href =
} else l('CMFavicon').href = 'https://orteil.dashnet.org/cookieclicker/favicon.ico'; 'https://aktanusa.github.io/CookieMonster/favicon/wrathCookie.ico';
else
l('CMFavicon').href =
'https://aktanusa.github.io/CookieMonster/favicon/goldenCookie.ico';
} else
l('CMFavicon').href =
'https://orteil.dashnet.org/cookieclicker/favicon.ico';
} }

View File

@@ -1,8 +1,14 @@
/** Functions related to updating the tab in the browser's tab-bar */ /** Functions related to updating the tab in the browser's tab-bar */
import { CacheSeasonPopShimmer, CacheSpawnedGoldenShimmer } from '../../Cache/VariablesAndData'; import {
CacheSeasonPopShimmer,
CacheSpawnedGoldenShimmer,
} from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import { LastSeasonPopupState, LastTickerFortuneState } from '../../Main/VariablesAndData'; import {
LastSeasonPopupState,
LastTickerFortuneState,
} from '../../Main/VariablesAndData';
import { Title } from '../VariablesAndData'; import { Title } from '../VariablesAndData';
/** /**
@@ -10,61 +16,78 @@ import { Title } from '../VariablesAndData';
* It is called on every loop by Game.Logic() which also sets CM.Disp.Title to Game.cookies * It is called on every loop by Game.Logic() which also sets CM.Disp.Title to Game.cookies
*/ */
export default function UpdateTitle() { export default function UpdateTitle() {
if (Game.OnAscend || CMOptions.Title === 0) { if (Game.OnAscend || CMOptions.Title === 0) {
document.title = Title; document.title = Title;
} else if (CMOptions.Title === 1) { } else if (CMOptions.Title === 1) {
let addFC = false; let addFC = false;
let addSP = false; let addSP = false;
let titleGC; let titleGC;
let titleFC; let titleFC;
let titleSP; let titleSP;
if (CacheSpawnedGoldenShimmer) { if (CacheSpawnedGoldenShimmer) {
if (CacheSpawnedGoldenShimmer.wrath) titleGC = `[W${Math.ceil(CacheSpawnedGoldenShimmer.life / Game.fps)}]`; if (CacheSpawnedGoldenShimmer.wrath)
else titleGC = `[G${Math.ceil(CacheSpawnedGoldenShimmer.life / Game.fps)}]`; titleGC = `[W${Math.ceil(CacheSpawnedGoldenShimmer.life / Game.fps)}]`;
} else if (!Game.Has('Golden switch [off]')) { else
titleGC = `[${Number(l('CMTimerBarGCMinBar').textContent) < 0 ? '!' : ''}${Math.ceil((Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.time) / Game.fps)}]`; titleGC = `[G${Math.ceil(CacheSpawnedGoldenShimmer.life / Game.fps)}]`;
} else titleGC = '[GS]'; } else if (!Game.Has('Golden switch [off]')) {
titleGC = `[${
Number(l('CMTimerBarGCMinBar').textContent) < 0 ? '!' : ''
}${Math.ceil(
(Game.shimmerTypes.golden.maxTime - Game.shimmerTypes.golden.time) /
Game.fps,
)}]`;
} else titleGC = '[GS]';
if (LastTickerFortuneState) { if (LastTickerFortuneState) {
addFC = true; addFC = true;
titleFC = '[F]'; titleFC = '[F]';
} }
if (Game.season === 'christmas') { if (Game.season === 'christmas') {
addSP = true; addSP = true;
if (LastSeasonPopupState) titleSP = `[R${Math.ceil(CacheSeasonPopShimmer.life / Game.fps)}]`; if (LastSeasonPopupState)
else { titleSP = `[R${Math.ceil(CacheSeasonPopShimmer.life / Game.fps)}]`;
titleSP = `[${Number(l('CMTimerBarRenMinBar').textContent) < 0 ? '!' : ''}${Math.ceil((Game.shimmerTypes.reindeer.maxTime - Game.shimmerTypes.reindeer.time) / Game.fps)}]`; else {
} titleSP = `[${
} Number(l('CMTimerBarRenMinBar').textContent) < 0 ? '!' : ''
}${Math.ceil(
(Game.shimmerTypes.reindeer.maxTime -
Game.shimmerTypes.reindeer.time) /
Game.fps,
)}]`;
}
}
// Remove previous timers and add current cookies // Remove previous timers and add current cookies
let str = Title; let str = Title;
if (str.charAt(0) === '[') { if (str.charAt(0) === '[') {
str = str.substring(str.lastIndexOf(']') + 1); str = str.substring(str.lastIndexOf(']') + 1);
} }
document.title = `${titleGC + (addFC ? titleFC : '') + (addSP ? titleSP : '')} ${str}`; document.title = `${
} else if (CMOptions.Title === 2) { titleGC + (addFC ? titleFC : '') + (addSP ? titleSP : '')
let str = ''; } ${str}`;
let spawn = false; } else if (CMOptions.Title === 2) {
if (CacheSpawnedGoldenShimmer) { let str = '';
spawn = true; let spawn = false;
if (CacheSpawnedGoldenShimmer.wrath) str += `[W${Math.ceil(CacheSpawnedGoldenShimmer.life / Game.fps)}]`; if (CacheSpawnedGoldenShimmer) {
else str += `[G${Math.ceil(CacheSpawnedGoldenShimmer.life / Game.fps)}]`; spawn = true;
} if (CacheSpawnedGoldenShimmer.wrath)
if (LastTickerFortuneState) { str += `[W${Math.ceil(CacheSpawnedGoldenShimmer.life / Game.fps)}]`;
spawn = true; else str += `[G${Math.ceil(CacheSpawnedGoldenShimmer.life / Game.fps)}]`;
str += '[F]'; }
} if (LastTickerFortuneState) {
if (Game.season === 'christmas' && LastSeasonPopupState) { spawn = true;
str += `[R${Math.ceil(CacheSeasonPopShimmer.life / Game.fps)}]`; str += '[F]';
spawn = true; }
} if (Game.season === 'christmas' && LastSeasonPopupState) {
if (spawn) str += ' - '; str += `[R${Math.ceil(CacheSeasonPopShimmer.life / Game.fps)}]`;
let title = 'Cookie Clicker'; spawn = true;
if (Game.season === 'fools') title = 'Cookie Baker'; }
str += title; if (spawn) str += ' - ';
document.title = str; let title = 'Cookie Clicker';
} if (Game.season === 'fools') title = 'Cookie Baker';
str += title;
document.title = str;
}
} }

View File

@@ -1,4 +1,7 @@
import { CacheHCPerSecond, CacheTimeTillNextPrestige } from '../../Cache/VariablesAndData'; import {
CacheHCPerSecond,
CacheTimeTillNextPrestige,
} from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import { Beautify } from '../BeautifyAndFormatting/BeautifyFormatting'; import { Beautify } from '../BeautifyAndFormatting/BeautifyFormatting';
@@ -8,21 +11,53 @@ import { Beautify } from '../BeautifyAndFormatting/BeautifyFormatting';
* @returns {object} div An object containing the stylized header * @returns {object} div An object containing the stylized header
*/ */
export default function ReplaceAscendTooltip() { export default function ReplaceAscendTooltip() {
const ascendNowToGet = Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)) - Math.floor(Game.HowMuchPrestige(Game.cookiesReset)); const ascendNowToGet =
const cookiesToNext = Game.HowManyCookiesReset(Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)) + 1) - (Game.cookiesEarned + Game.cookiesReset); Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)) -
const startDate = Game.sayTime(((Date.now() - Game.startDate) / 1000) * Game.fps, -1); Math.floor(Game.HowMuchPrestige(Game.cookiesReset));
let str = ''; const cookiesToNext =
str += `You've been on this run for <b>${startDate === '' ? 'not very long' : (startDate)}</b>.<br>`; Game.HowManyCookiesReset(
str += '<div class="line"></div>'; Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)) +
if (Game.prestige > 0) { 1,
str += `Your prestige level is currently <b>${Beautify(Game.prestige)}</b>.<br>(CpS +${Beautify(Game.prestige)}%)`; ) -
str += '<div class="line"></div>'; (Game.cookiesEarned + Game.cookiesReset);
} const startDate = Game.sayTime(
if (ascendNowToGet < 1) str += 'Ascending now would grant you no prestige.'; ((Date.now() - Game.startDate) / 1000) * Game.fps,
else if (ascendNowToGet < 2) str += 'Ascending now would grant you<br><b>1 prestige level</b> (+1% CpS)<br>and <b>1 heavenly chip</b> to spend.'; -1,
else str += `Ascending now would grant you<br><b>${Beautify(ascendNowToGet)} prestige levels</b> (+${Beautify(ascendNowToGet)}% CpS)<br>and <b>${Beautify(ascendNowToGet)} heavenly chips</b> to spend.`; );
str += '<div class="line"></div>'; let str = '';
str += `You need <b>${Beautify(cookiesToNext)} more cookies</b> for the next level.<br>`; str += `You've been on this run for <b>${
str += `${CMOptions.TooltipAscendButton ? `<div class='line'></div>It takes ${CacheTimeTillNextPrestige} to reach the next level and you are making ${Beautify(CacheHCPerSecond, 2)} chips on average in the last 5 seconds.<br>` : ''}`; startDate === '' ? 'not very long' : startDate
l('ascendTooltip').innerHTML = str; }</b>.<br>`;
str += '<div class="line"></div>';
if (Game.prestige > 0) {
str += `Your prestige level is currently <b>${Beautify(
Game.prestige,
)}</b>.<br>(CpS +${Beautify(Game.prestige)}%)`;
str += '<div class="line"></div>';
}
if (ascendNowToGet < 1) str += 'Ascending now would grant you no prestige.';
else if (ascendNowToGet < 2)
str +=
'Ascending now would grant you<br><b>1 prestige level</b> (+1% CpS)<br>and <b>1 heavenly chip</b> to spend.';
else
str += `Ascending now would grant you<br><b>${Beautify(
ascendNowToGet,
)} prestige levels</b> (+${Beautify(
ascendNowToGet,
)}% CpS)<br>and <b>${Beautify(
ascendNowToGet,
)} heavenly chips</b> to spend.`;
str += '<div class="line"></div>';
str += `You need <b>${Beautify(
cookiesToNext,
)} more cookies</b> for the next level.<br>`;
str += `${
CMOptions.TooltipAscendButton
? `<div class='line'></div>It takes ${CacheTimeTillNextPrestige} to reach the next level and you are making ${Beautify(
CacheHCPerSecond,
2,
)} chips on average in the last 5 seconds.<br>`
: ''
}`;
l('ascendTooltip').innerHTML = str;
} }

View File

@@ -1,6 +1,13 @@
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import { import {
ColorTextPre, ColorBorderPre, ColorGray, ColorBlue, ColorRed, ColorYellow, ColorPurple, TooltipType, ColorTextPre,
ColorBorderPre,
ColorGray,
ColorBlue,
ColorRed,
ColorYellow,
ColorPurple,
TooltipType,
} from '../VariablesAndData'; } from '../VariablesAndData';
/** Creates various sections of tooltips */ /** Creates various sections of tooltips */
@@ -10,14 +17,14 @@ import {
* @returns {object} div An object containing the stylized box * @returns {object} div An object containing the stylized box
*/ */
export function TooltipCreateTooltipBox() { export function TooltipCreateTooltipBox() {
l('tooltip').firstChild.style.paddingBottom = '4px'; // Sets padding on base-tooltip l('tooltip').firstChild.style.paddingBottom = '4px'; // Sets padding on base-tooltip
const tooltipBox = document.createElement('div'); const tooltipBox = document.createElement('div');
tooltipBox.style.border = '1px solid'; tooltipBox.style.border = '1px solid';
tooltipBox.style.padding = '4px'; tooltipBox.style.padding = '4px';
tooltipBox.style.margin = '0px -4px'; tooltipBox.style.margin = '0px -4px';
tooltipBox.id = 'CMTooltipBorder'; tooltipBox.id = 'CMTooltipBorder';
tooltipBox.className = ColorTextPre + ColorGray; tooltipBox.className = ColorTextPre + ColorGray;
return tooltipBox; return tooltipBox;
} }
/** /**
@@ -26,12 +33,12 @@ export function TooltipCreateTooltipBox() {
* @returns {object} div An object containing the stylized header * @returns {object} div An object containing the stylized header
*/ */
export function TooltipCreateHeader(text) { export function TooltipCreateHeader(text) {
const div = document.createElement('div'); const div = document.createElement('div');
div.style.fontWeight = 'bold'; div.style.fontWeight = 'bold';
div.id = `${text}Title`; div.id = `${text}Title`;
div.className = ColorTextPre + ColorBlue; div.className = ColorTextPre + ColorBlue;
div.textContent = text; div.textContent = text;
return div; return div;
} }
/** /**
@@ -40,51 +47,105 @@ export function TooltipCreateHeader(text) {
* @returns {object} TooltipWarn The Warnings-tooltip object * @returns {object} TooltipWarn The Warnings-tooltip object
*/ */
export function TooltipCreateWarningSection() { export function TooltipCreateWarningSection() {
const TooltipWarn = document.createElement('div'); const TooltipWarn = document.createElement('div');
TooltipWarn.style.position = 'absolute'; TooltipWarn.style.position = 'absolute';
TooltipWarn.style.display = 'block'; TooltipWarn.style.display = 'block';
TooltipWarn.style.left = 'auto'; TooltipWarn.style.left = 'auto';
TooltipWarn.style.bottom = 'auto'; TooltipWarn.style.bottom = 'auto';
TooltipWarn.id = 'CMDispTooltipWarningParent'; TooltipWarn.id = 'CMDispTooltipWarningParent';
const create = function (boxId, color, labelTextFront, labelTextBack, deficitId) { const create = function (
const box = document.createElement('div'); boxId,
box.id = boxId; color,
box.style.display = 'none'; labelTextFront,
box.style.transition = 'opacity 0.1s ease-out'; labelTextBack,
box.className = ColorBorderPre + color; deficitId,
box.style.padding = '2px'; ) {
box.style.background = '#000 url(img/darkNoise.png)'; const box = document.createElement('div');
const labelDiv = document.createElement('div'); box.id = boxId;
box.appendChild(labelDiv); box.style.display = 'none';
const labelSpan = document.createElement('span'); box.style.transition = 'opacity 0.1s ease-out';
labelSpan.className = ColorTextPre + color; box.className = ColorBorderPre + color;
labelSpan.style.fontWeight = 'bold'; box.style.padding = '2px';
labelSpan.textContent = labelTextFront; box.style.background = '#000 url(img/darkNoise.png)';
labelDiv.appendChild(labelSpan); const labelDiv = document.createElement('div');
labelDiv.appendChild(document.createTextNode(labelTextBack)); box.appendChild(labelDiv);
const deficitDiv = document.createElement('div'); const labelSpan = document.createElement('span');
box.appendChild(deficitDiv); labelSpan.className = ColorTextPre + color;
const deficitSpan = document.createElement('span'); labelSpan.style.fontWeight = 'bold';
deficitSpan.id = deficitId; labelSpan.textContent = labelTextFront;
deficitDiv.appendChild(document.createTextNode('Deficit: ')); labelDiv.appendChild(labelSpan);
deficitDiv.appendChild(deficitSpan); labelDiv.appendChild(document.createTextNode(labelTextBack));
return box; const deficitDiv = document.createElement('div');
}; box.appendChild(deficitDiv);
const deficitSpan = document.createElement('span');
deficitSpan.id = deficitId;
deficitDiv.appendChild(document.createTextNode('Deficit: '));
deficitDiv.appendChild(deficitSpan);
return box;
};
TooltipWarn.appendChild(create('CMDispTooltipWarnLucky', ColorRed, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!"', 'CMDispTooltipWarnLuckyText')); TooltipWarn.appendChild(
TooltipWarn.firstChild.style.marginBottom = '4px'; create(
TooltipWarn.appendChild(create('CMDispTooltipWarnLuckyFrenzy', ColorYellow, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Lucky!" (Frenzy)', 'CMDispTooltipWarnLuckyFrenzyText')); 'CMDispTooltipWarnLucky',
TooltipWarn.lastChild.style.marginBottom = '4px'; ColorRed,
TooltipWarn.appendChild(create('CMDispTooltipWarnConjure', ColorPurple, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Conjure Baked Goods"', 'CMDispTooltipWarnConjureText')); 'Warning: ',
TooltipWarn.lastChild.style.marginBottom = '4px'; 'Purchase of this item will put you under the number of Cookies required for "Lucky!"',
TooltipWarn.appendChild(create('CMDispTooltipWarnConjureFrenzy', ColorPurple, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Conjure Baked Goods" (Frenzy)', 'CMDispTooltipWarnConjureFrenzyText')); 'CMDispTooltipWarnLuckyText',
TooltipWarn.lastChild.style.marginBottom = '4px'; ),
TooltipWarn.appendChild(create('CMDispTooltipWarnEdifice', ColorPurple, 'Warning: ', 'Purchase of this item will put you under the number of Cookies needed for "Spontaneous Edifice" to possibly give you your most expensive building"', 'CMDispTooltipWarnEdificeText')); );
TooltipWarn.lastChild.style.marginBottom = '4px'; TooltipWarn.firstChild.style.marginBottom = '4px';
TooltipWarn.appendChild(create('CMDispTooltipWarnUser', ColorRed, 'Warning: ', `Purchase of this item will put you under the number of Cookies equal to ${CMOptions.ToolWarnUser} seconds of CPS`, 'CMDispTooltipWarnUserText')); TooltipWarn.appendChild(
create(
'CMDispTooltipWarnLuckyFrenzy',
ColorYellow,
'Warning: ',
'Purchase of this item will put you under the number of Cookies required for "Lucky!" (Frenzy)',
'CMDispTooltipWarnLuckyFrenzyText',
),
);
TooltipWarn.lastChild.style.marginBottom = '4px';
TooltipWarn.appendChild(
create(
'CMDispTooltipWarnConjure',
ColorPurple,
'Warning: ',
'Purchase of this item will put you under the number of Cookies required for "Conjure Baked Goods"',
'CMDispTooltipWarnConjureText',
),
);
TooltipWarn.lastChild.style.marginBottom = '4px';
TooltipWarn.appendChild(
create(
'CMDispTooltipWarnConjureFrenzy',
ColorPurple,
'Warning: ',
'Purchase of this item will put you under the number of Cookies required for "Conjure Baked Goods" (Frenzy)',
'CMDispTooltipWarnConjureFrenzyText',
),
);
TooltipWarn.lastChild.style.marginBottom = '4px';
TooltipWarn.appendChild(
create(
'CMDispTooltipWarnEdifice',
ColorPurple,
'Warning: ',
'Purchase of this item will put you under the number of Cookies needed for "Spontaneous Edifice" to possibly give you your most expensive building"',
'CMDispTooltipWarnEdificeText',
),
);
TooltipWarn.lastChild.style.marginBottom = '4px';
TooltipWarn.appendChild(
create(
'CMDispTooltipWarnUser',
ColorRed,
'Warning: ',
`Purchase of this item will put you under the number of Cookies equal to ${CMOptions.ToolWarnUser} seconds of CPS`,
'CMDispTooltipWarnUserText',
),
);
return TooltipWarn; return TooltipWarn;
} }
/** /**
@@ -93,38 +154,40 @@ export function TooltipCreateWarningSection() {
* @param {object} tooltip Object of a TooltipBox, normally created by a call to CM.Disp.TooltipCreateTooltipBox() * @param {object} tooltip Object of a TooltipBox, normally created by a call to CM.Disp.TooltipCreateTooltipBox()
*/ */
export function TooltipCreateCalculationSection(tooltip) { export function TooltipCreateCalculationSection(tooltip) {
tooltip.appendChild(TooltipCreateHeader('Bonus Income')); tooltip.appendChild(TooltipCreateHeader('Bonus Income'));
const income = document.createElement('div'); const income = document.createElement('div');
income.style.marginBottom = '4px'; income.style.marginBottom = '4px';
income.style.color = 'white'; income.style.color = 'white';
income.id = 'CMTooltipIncome'; income.id = 'CMTooltipIncome';
tooltip.appendChild(income); tooltip.appendChild(income);
tooltip.appendChild(TooltipCreateHeader('Bonus Cookies per Click')); tooltip.appendChild(TooltipCreateHeader('Bonus Cookies per Click'));
tooltip.lastChild.style.display = 'none'; tooltip.lastChild.style.display = 'none';
const click = document.createElement('div'); const click = document.createElement('div');
click.style.marginBottom = '4px'; click.style.marginBottom = '4px';
click.style.color = 'white'; click.style.color = 'white';
click.style.display = 'none'; click.style.display = 'none';
click.id = 'CMTooltipCookiePerClick'; click.id = 'CMTooltipCookiePerClick';
tooltip.appendChild(click); tooltip.appendChild(click);
tooltip.appendChild(TooltipCreateHeader('Payback Period')); tooltip.appendChild(TooltipCreateHeader('Payback Period'));
const pp = document.createElement('div'); const pp = document.createElement('div');
pp.style.marginBottom = '4px'; pp.style.marginBottom = '4px';
pp.id = 'CMTooltipPP'; pp.id = 'CMTooltipPP';
tooltip.appendChild(pp); tooltip.appendChild(pp);
tooltip.appendChild(TooltipCreateHeader('Time Left')); tooltip.appendChild(TooltipCreateHeader('Time Left'));
const time = document.createElement('div'); const time = document.createElement('div');
time.id = 'CMTooltipTime'; time.id = 'CMTooltipTime';
tooltip.appendChild(time); tooltip.appendChild(time);
if (TooltipType === 'b') { if (TooltipType === 'b') {
tooltip.appendChild(TooltipCreateHeader('Production left till next achievement')); tooltip.appendChild(
tooltip.lastChild.id = 'CMTooltipProductionHeader'; // Assign a id in order to hid when no achiev's are left TooltipCreateHeader('Production left till next achievement'),
const production = document.createElement('div'); );
production.id = 'CMTooltipProduction'; tooltip.lastChild.id = 'CMTooltipProductionHeader'; // Assign a id in order to hid when no achiev's are left
tooltip.appendChild(production); const production = document.createElement('div');
} production.id = 'CMTooltipProduction';
tooltip.appendChild(production);
}
} }

View File

@@ -5,15 +5,26 @@ import { CMOptions } from '../../Config/VariablesAndData';
* It is called by Game.tooltip.update() because of CM.Main.ReplaceNative() * It is called by Game.tooltip.update() because of CM.Main.ReplaceNative()
*/ */
export default function UpdateTooltipLocation() { export default function UpdateTooltipLocation() {
if (Game.tooltip.origin === 'store') { if (Game.tooltip.origin === 'store') {
let warnOffset = 0; let warnOffset = 0;
if (CMOptions.ToolWarnLucky === 1 && CMOptions.ToolWarnPos === 1 && l('CMDispTooltipWarningParent') !== null) { if (
warnOffset = l('CMDispTooltipWarningParent').clientHeight - 4; CMOptions.ToolWarnLucky === 1 &&
} CMOptions.ToolWarnPos === 1 &&
Game.tooltip.tta.style.top = `${Math.min(parseInt(Game.tooltip.tta.style.top, 10), (l('game').clientHeight + l('topBar').clientHeight) - Game.tooltip.tt.clientHeight - warnOffset - 46)}px`; l('CMDispTooltipWarningParent') !== null
} ) {
// Kept for future possible use if the code changes again warnOffset = l('CMDispTooltipWarningParent').clientHeight - 4;
/* else if (!Game.onCrate && !Game.OnAscend && CM.Options.TimerBar === 1 && CM.Options.TimerBarPos === 0) { }
Game.tooltip.tta.style.top = `${Math.min(
parseInt(Game.tooltip.tta.style.top, 10),
l('game').clientHeight +
l('topBar').clientHeight -
Game.tooltip.tt.clientHeight -
warnOffset -
46,
)}px`;
}
// Kept for future possible use if the code changes again
/* else if (!Game.onCrate && !Game.OnAscend && CM.Options.TimerBar === 1 && CM.Options.TimerBarPos === 0) {
Game.tooltip.tta.style.top = (parseInt(Game.tooltip.tta.style.top) + parseInt(CM.Disp.TimerBar.style.height)) + 'px'; Game.tooltip.tta.style.top = (parseInt(Game.tooltip.tta.style.top) + parseInt(CM.Disp.TimerBar.style.height)) + 'px';
} */ } */
} }

View File

@@ -1,7 +1,10 @@
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
import * as UpdateTooltip from './UpdateTooltips'; import * as UpdateTooltip from './UpdateTooltips';
import { TooltipCreateTooltipBox } from './CreateTooltip'; import { TooltipCreateTooltipBox } from './CreateTooltip';
import { Beautify, GetTimeColor } from '../BeautifyAndFormatting/BeautifyFormatting'; import {
Beautify,
GetTimeColor,
} from '../BeautifyAndFormatting/BeautifyFormatting';
import CopyData from '../../Sim/SimulationData/CopyData'; import CopyData from '../../Sim/SimulationData/CopyData';
import { TooltipName, TooltipType } from '../VariablesAndData'; import { TooltipName, TooltipType } from '../VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
@@ -17,47 +20,48 @@ import BuildingGetPrice from '../../Sim/SimulationEvents/BuyBuilding';
* @param {string} minWidth The minimum width of the tooltip * @param {string} minWidth The minimum width of the tooltip
*/ */
export function CreateSimpleTooltip(placeholder, text, minWidth) { export function CreateSimpleTooltip(placeholder, text, minWidth) {
const Tooltip = document.createElement('div'); const Tooltip = document.createElement('div');
Tooltip.id = placeholder; Tooltip.id = placeholder;
const desc = document.createElement('div'); const desc = document.createElement('div');
desc.style.minWidth = minWidth; desc.style.minWidth = minWidth;
desc.style.marginBottom = '4px'; desc.style.marginBottom = '4px';
const div = document.createElement('div'); const div = document.createElement('div');
div.style.textAlign = 'left'; div.style.textAlign = 'left';
div.textContent = text; div.textContent = text;
desc.appendChild(div); desc.appendChild(div);
Tooltip.appendChild(desc); Tooltip.appendChild(desc);
} }
/** /**
* This function updates the sections of the tooltips created by CookieMonster * This function updates the sections of the tooltips created by CookieMonster
*/ */
export function UpdateTooltips() { export function UpdateTooltips() {
CopyData(); CopyData();
if (l('tooltipAnchor').style.display !== 'none' && l('CMTooltipArea')) { if (l('tooltipAnchor').style.display !== 'none' && l('CMTooltipArea')) {
l('CMTooltipArea').innerHTML = ''; l('CMTooltipArea').innerHTML = '';
const tooltipBox = TooltipCreateTooltipBox(); const tooltipBox = TooltipCreateTooltipBox();
l('CMTooltipArea').appendChild(tooltipBox); l('CMTooltipArea').appendChild(tooltipBox);
if (TooltipType === 'b') { if (TooltipType === 'b') {
UpdateTooltip.Building(); UpdateTooltip.Building();
} else if (TooltipType === 'u') { } else if (TooltipType === 'u') {
UpdateTooltip.Upgrade(); UpdateTooltip.Upgrade();
} else if (TooltipType === 's') { } else if (TooltipType === 's') {
UpdateTooltip.SugarLump(); UpdateTooltip.SugarLump();
} else if (TooltipType === 'g') { } else if (TooltipType === 'g') {
UpdateTooltip.Grimoire(); UpdateTooltip.Grimoire();
} else if (TooltipType === 'p') { } else if (TooltipType === 'p') {
UpdateTooltip.GardenPlots(); UpdateTooltip.GardenPlots();
} else if (TooltipType === 'ha') { } else if (TooltipType === 'ha') {
UpdateTooltip.HarvestAll(); UpdateTooltip.HarvestAll();
} }
UpdateTooltip.Warnings(); UpdateTooltip.Warnings();
} else if (l('CMTooltipArea') === null) { // Remove warnings if its a basic tooltip } else if (l('CMTooltipArea') === null) {
if (l('CMDispTooltipWarningParent') !== null) { // Remove warnings if its a basic tooltip
l('CMDispTooltipWarningParent').remove(); if (l('CMDispTooltipWarningParent') !== null) {
} l('CMDispTooltipWarningParent').remove();
} }
}
} }
/** /**
@@ -68,49 +72,98 @@ export function UpdateTooltips() {
* @returns {string} l('tooltip').innerHTML The HTML of the l('tooltip')-object * @returns {string} l('tooltip').innerHTML The HTML of the l('tooltip')-object
*/ */
export function CreateTooltip(type, name) { export function CreateTooltip(type, name) {
if (type === 'b') { // Buildings if (type === 'b') {
l('tooltip').innerHTML = Game.Objects[name].tooltip(); // Buildings
// Adds amortization info to the list of info per building l('tooltip').innerHTML = Game.Objects[name].tooltip();
if (CMOptions.TooltipAmor === 1) { // Adds amortization info to the list of info per building
const buildPrice = BuildingGetPrice(Game.Objects[name], Game.Objects[name].basePrice, 0, Game.Objects[name].free, Game.Objects[name].amount); if (CMOptions.TooltipAmor === 1) {
const amortizeAmount = buildPrice - Game.Objects[name].totalCookies; const buildPrice = BuildingGetPrice(
if (amortizeAmount > 0) { Game.Objects[name],
l('tooltip').innerHTML = l('tooltip').innerHTML Game.Objects[name].basePrice,
.split('so far</div>') 0,
.join(`so far<br/>&bull; <b>${Beautify(amortizeAmount)}</b> ${Math.floor(amortizeAmount) === 1 ? 'cookie' : 'cookies'} left to amortize (${GetTimeColor((buildPrice - Game.Objects[name].totalCookies) / (Game.Objects[name].storedTotalCps * Game.globalCpsMult)).text})</div>`); Game.Objects[name].free,
} Game.Objects[name].amount,
} );
if (Game.buyMode === -1) { const amortizeAmount = buildPrice - Game.Objects[name].totalCookies;
/* if (amortizeAmount > 0) {
* Fix sell price displayed in the object tooltip. l('tooltip').innerHTML = l('tooltip')
* .innerHTML.split('so far</div>')
* The buildings sell price displayed by the game itself (without any mod) is incorrect. .join(
* The following line of code fixes this issue, and can be safely removed when the game gets fixed. `so far<br/>&bull; <b>${Beautify(amortizeAmount)}</b> ${
* Math.floor(amortizeAmount) === 1 ? 'cookie' : 'cookies'
* This issue is extensively detailed here: https://github.com/Aktanusa/CookieMonster/issues/359#issuecomment-735658262 } left to amortize (${
*/ GetTimeColor(
l('tooltip').innerHTML = l('tooltip').innerHTML.split(Beautify(Game.Objects[name].bulkPrice)).join(Beautify((Game.Objects[name], Game.Objects[name].basePrice, Game.Objects[name].amount, Game.Objects[name].free, Game.buyBulk, 1))); (buildPrice - Game.Objects[name].totalCookies) /
} (Game.Objects[name].storedTotalCps * Game.globalCpsMult),
} else if (type === 'u') { // Upgrades ).text
if (!Game.UpgradesInStore[name]) return ''; })</div>`,
l('tooltip').innerHTML = Game.crateTooltip(Game.UpgradesInStore[name], 'store'); );
} else if (type === 's') l('tooltip').innerHTML = Game.lumpTooltip(); // Sugar Lumps }
else if (type === 'g') l('tooltip').innerHTML = Game.Objects['Wizard tower'].minigame.spellTooltip(name)(); // Grimoire }
else if (type === 'p') l('tooltip').innerHTML = Game.ObjectsById[2].minigame.tileTooltip(name[0], name[1])(); // Garden plots if (Game.buyMode === -1) {
else if (type === 'ha') l('tooltip').innerHTML = Game.ObjectsById[2].minigame.toolTooltip(1)(); // Harvest all button in garden /*
* Fix sell price displayed in the object tooltip.
*
* The buildings sell price displayed by the game itself (without any mod) is incorrect.
* The following line of code fixes this issue, and can be safely removed when the game gets fixed.
*
* This issue is extensively detailed here: https://github.com/Aktanusa/CookieMonster/issues/359#issuecomment-735658262
*/
l('tooltip').innerHTML = l('tooltip')
.innerHTML.split(Beautify(Game.Objects[name].bulkPrice))
.join(
Beautify(
(Game.Objects[name],
Game.Objects[name].basePrice,
Game.Objects[name].amount,
Game.Objects[name].free,
Game.buyBulk,
1),
),
);
}
} else if (type === 'u') {
// Upgrades
if (!Game.UpgradesInStore[name]) return '';
l('tooltip').innerHTML = Game.crateTooltip(
Game.UpgradesInStore[name],
'store',
);
} else if (type === 's') l('tooltip').innerHTML = Game.lumpTooltip();
// Sugar Lumps
else if (type === 'g')
l('tooltip').innerHTML = Game.Objects['Wizard tower'].minigame.spellTooltip(
name,
)();
// Grimoire
else if (type === 'p')
l('tooltip').innerHTML = Game.ObjectsById[2].minigame.tileTooltip(
name[0],
name[1],
)();
// Garden plots
else if (type === 'ha')
l('tooltip').innerHTML = Game.ObjectsById[2].minigame.toolTooltip(1)(); // Harvest all button in garden
// Adds area for extra tooltip-sections // Adds area for extra tooltip-sections
if ((type === 'b' && Game.buyMode === 1) || type === 'u' || type === 's' || type === 'g' || (type === 'p' && !Game.keys[16]) || type === 'ha') { if (
const area = document.createElement('div'); (type === 'b' && Game.buyMode === 1) ||
area.id = 'CMTooltipArea'; type === 'u' ||
l('tooltip').appendChild(area); type === 's' ||
} type === 'g' ||
(type === 'p' && !Game.keys[16]) ||
type === 'ha'
) {
const area = document.createElement('div');
area.id = 'CMTooltipArea';
l('tooltip').appendChild(area);
}
// Sets global variables used by CM.Disp.UpdateTooltip() // Sets global variables used by CM.Disp.UpdateTooltip()
TooltipType = type; TooltipType = type;
TooltipName = name; TooltipName = name;
UpdateTooltips(); UpdateTooltips();
return l('tooltip').innerHTML; return l('tooltip').innerHTML;
} }

View File

@@ -1,17 +1,34 @@
import GetCPSBuffMult from '../../Cache/CPS/GetCPSBuffMult'; import GetCPSBuffMult from '../../Cache/CPS/GetCPSBuffMult';
import { import {
CacheEdifice, CacheLastChoEgg, CacheLucky, CacheNoGoldSwitchCookiesPS, CacheObjects1, CacheObjects10, CacheObjects100, CacheUpgrades, CacheEdifice,
CacheLastChoEgg,
CacheLucky,
CacheNoGoldSwitchCookiesPS,
CacheObjects1,
CacheObjects10,
CacheObjects100,
CacheUpgrades,
} from '../../Cache/VariablesAndData'; } from '../../Cache/VariablesAndData';
import ToggleToolWarnPos from '../../Config/Toggles/ToggleToolWarnPos'; import ToggleToolWarnPos from '../../Config/Toggles/ToggleToolWarnPos';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import { SimObjects } from '../../Sim/VariablesAndData'; import { SimObjects } from '../../Sim/VariablesAndData';
import { Beautify, FormatTime, GetTimeColor } from '../BeautifyAndFormatting/BeautifyFormatting'; import {
Beautify,
FormatTime,
GetTimeColor,
} from '../BeautifyAndFormatting/BeautifyFormatting';
import CalculateGrimoireRefillTime from '../HelperFunctions/CalculateGrimoireRefillTime'; import CalculateGrimoireRefillTime from '../HelperFunctions/CalculateGrimoireRefillTime';
import GetCPS from '../HelperFunctions/GetCPS'; import GetCPS from '../HelperFunctions/GetCPS';
import GetLumpColor from '../HelperFunctions/GetLumpColor'; import GetLumpColor from '../HelperFunctions/GetLumpColor';
import GetWrinkConfigBank from '../HelperFunctions/GetWrinkConfigBank'; import GetWrinkConfigBank from '../HelperFunctions/GetWrinkConfigBank';
import { import {
ColorTextPre, LastTargetTooltipBuilding, TooltipBonusIncome, TooltipBonusMouse, TooltipName, TooltipPrice, TooltipType, ColorTextPre,
LastTargetTooltipBuilding,
TooltipBonusIncome,
TooltipBonusMouse,
TooltipName,
TooltipPrice,
TooltipType,
} from '../VariablesAndData'; } from '../VariablesAndData';
import * as Create from './CreateTooltip'; import * as Create from './CreateTooltip';
@@ -21,114 +38,154 @@ import * as Create from './CreateTooltip';
* This function adds extra info to the Building tooltips * This function adds extra info to the Building tooltips
*/ */
export function Building() { export function Building() {
if (CMOptions.TooltipBuildUpgrade === 1 && Game.buyMode === 1) { if (CMOptions.TooltipBuildUpgrade === 1 && Game.buyMode === 1) {
const tooltipBox = l('CMTooltipBorder'); const tooltipBox = l('CMTooltipBorder');
Create.TooltipCreateCalculationSection(tooltipBox); Create.TooltipCreateCalculationSection(tooltipBox);
let target; let target;
if (Game.buyMode === 1) { if (Game.buyMode === 1) {
LastTargetTooltipBuilding = target; LastTargetTooltipBuilding = target;
} else { } else {
target = LastTargetTooltipBuilding; target = LastTargetTooltipBuilding;
} }
if (Game.buyBulk === 1) target = CacheObjects1; if (Game.buyBulk === 1) target = CacheObjects1;
else if (Game.buyBulk === 10) target = CacheObjects10; else if (Game.buyBulk === 10) target = CacheObjects10;
else if (Game.buyBulk === 100) target = CacheObjects100; else if (Game.buyBulk === 100) target = CacheObjects100;
TooltipPrice = Game.Objects[TooltipName].bulkPrice; TooltipPrice = Game.Objects[TooltipName].bulkPrice;
TooltipBonusIncome = target[TooltipName].bonus; TooltipBonusIncome = target[TooltipName].bonus;
if (CMOptions.TooltipBuildUpgrade === 1 && Game.buyMode === 1) { if (CMOptions.TooltipBuildUpgrade === 1 && Game.buyMode === 1) {
l('CMTooltipIncome').textContent = Beautify(TooltipBonusIncome, 2); l('CMTooltipIncome').textContent = Beautify(TooltipBonusIncome, 2);
const increase = Math.round(TooltipBonusIncome / Game.cookiesPs * 10000); const increase = Math.round(
if (Number.isFinite(increase) && increase !== 0) { (TooltipBonusIncome / Game.cookiesPs) * 10000,
l('CMTooltipIncome').textContent += ` (${increase / 100}% of income)`; );
} if (Number.isFinite(increase) && increase !== 0) {
l('CMTooltipBorder').className = ColorTextPre + target[TooltipName].color; l('CMTooltipIncome').textContent += ` (${increase / 100}% of income)`;
l('CMTooltipPP').textContent = Beautify(target[TooltipName].pp, 2); }
l('CMTooltipPP').className = ColorTextPre + target[TooltipName].color; l('CMTooltipBorder').className = ColorTextPre + target[TooltipName].color;
const timeColor = GetTimeColor((TooltipPrice - (Game.cookies + GetWrinkConfigBank())) / GetCPS()); l('CMTooltipPP').textContent = Beautify(target[TooltipName].pp, 2);
l('CMTooltipTime').textContent = timeColor.text; l('CMTooltipPP').className = ColorTextPre + target[TooltipName].color;
if (timeColor.text === 'Done!' && Game.cookies < target[TooltipName].price) { const timeColor = GetTimeColor(
l('CMTooltipTime').textContent = `${timeColor.text} (with Wrink)`; (TooltipPrice - (Game.cookies + GetWrinkConfigBank())) / GetCPS(),
} else l('CMTooltipTime').textContent = timeColor.text; );
l('CMTooltipTime').className = ColorTextPre + timeColor.color; l('CMTooltipTime').textContent = timeColor.text;
} if (
timeColor.text === 'Done!' &&
Game.cookies < target[TooltipName].price
) {
l('CMTooltipTime').textContent = `${timeColor.text} (with Wrink)`;
} else l('CMTooltipTime').textContent = timeColor.text;
l('CMTooltipTime').className = ColorTextPre + timeColor.color;
}
// Add "production left till next achievement"-bar // Add "production left till next achievement"-bar
l('CMTooltipProductionHeader').style.display = 'none'; l('CMTooltipProductionHeader').style.display = 'none';
l('CMTooltipTime').style.marginBottom = '0px'; l('CMTooltipTime').style.marginBottom = '0px';
for (const i of Object.keys(Game.Objects[TooltipName].productionAchievs)) { for (const i of Object.keys(Game.Objects[TooltipName].productionAchievs)) {
if (!Game.HasAchiev(Game.Objects[TooltipName].productionAchievs[i].achiev.name)) { if (
const nextProductionAchiev = Game.Objects[TooltipName].productionAchievs[i]; !Game.HasAchiev(
l('CMTooltipTime').style.marginBottom = '4px'; Game.Objects[TooltipName].productionAchievs[i].achiev.name,
l('CMTooltipProductionHeader').style.display = ''; )
l('CMTooltipProduction').className = `ProdAchievement${TooltipName}`; ) {
l('CMTooltipProduction').textContent = Beautify(nextProductionAchiev.pow - SimObjects[TooltipName].totalCookies, 15); const nextProductionAchiev =
l('CMTooltipProduction').style.color = 'white'; Game.Objects[TooltipName].productionAchievs[i];
break; l('CMTooltipTime').style.marginBottom = '4px';
} l('CMTooltipProductionHeader').style.display = '';
} l('CMTooltipProduction').className = `ProdAchievement${TooltipName}`;
} else l('CMTooltipArea').style.display = 'none'; l('CMTooltipProduction').textContent = Beautify(
nextProductionAchiev.pow - SimObjects[TooltipName].totalCookies,
15,
);
l('CMTooltipProduction').style.color = 'white';
break;
}
}
} else l('CMTooltipArea').style.display = 'none';
} }
/** /**
* This function adds extra info to the Upgrade tooltips * This function adds extra info to the Upgrade tooltips
*/ */
export function Upgrade() { export function Upgrade() {
const tooltipBox = l('CMTooltipBorder'); const tooltipBox = l('CMTooltipBorder');
Create.TooltipCreateCalculationSection(tooltipBox); Create.TooltipCreateCalculationSection(tooltipBox);
TooltipBonusIncome = CacheUpgrades[Game.UpgradesInStore[TooltipName].name].bonus; TooltipBonusIncome =
TooltipPrice = Game.Upgrades[Game.UpgradesInStore[TooltipName].name].getPrice(); CacheUpgrades[Game.UpgradesInStore[TooltipName].name].bonus;
TooltipBonusMouse = CacheUpgrades[Game.UpgradesInStore[TooltipName].name].bonusMouse; TooltipPrice = Game.Upgrades[
Game.UpgradesInStore[TooltipName].name
].getPrice();
TooltipBonusMouse =
CacheUpgrades[Game.UpgradesInStore[TooltipName].name].bonusMouse;
if (CMOptions.TooltipBuildUpgrade === 1) { if (CMOptions.TooltipBuildUpgrade === 1) {
l('CMTooltipIncome').textContent = Beautify(TooltipBonusIncome, 2); l('CMTooltipIncome').textContent = Beautify(TooltipBonusIncome, 2);
const increase = Math.round(TooltipBonusIncome / Game.cookiesPs * 10000); const increase = Math.round((TooltipBonusIncome / Game.cookiesPs) * 10000);
// Don't display certain parts of tooltip if not applicable // Don't display certain parts of tooltip if not applicable
if (l('CMTooltipIncome').textContent === '0' && (TooltipType === 'b' || TooltipType === 'u')) { if (
l('Bonus IncomeTitle').style.display = 'none'; l('CMTooltipIncome').textContent === '0' &&
l('CMTooltipIncome').style.display = 'none'; (TooltipType === 'b' || TooltipType === 'u')
l('Payback PeriodTitle').style.display = 'none'; ) {
l('CMTooltipPP').style.display = 'none'; l('Bonus IncomeTitle').style.display = 'none';
} else { l('CMTooltipIncome').style.display = 'none';
if (Number.isFinite(increase) && increase !== 0) { l('Payback PeriodTitle').style.display = 'none';
l('CMTooltipIncome').textContent += ` (${increase / 100}% of income)`; l('CMTooltipPP').style.display = 'none';
} } else {
l('CMTooltipBorder').className = ColorTextPre + CacheUpgrades[Game.UpgradesInStore[TooltipName].name].color; if (Number.isFinite(increase) && increase !== 0) {
// If clicking power upgrade l('CMTooltipIncome').textContent += ` (${increase / 100}% of income)`;
if (TooltipBonusMouse) { }
l('CMTooltipCookiePerClick').textContent = Beautify(TooltipBonusMouse); l('CMTooltipBorder').className =
l('CMTooltipCookiePerClick').style.display = 'block'; ColorTextPre +
l('CMTooltipCookiePerClick').previousSibling.style.display = 'block'; CacheUpgrades[Game.UpgradesInStore[TooltipName].name].color;
} // If clicking power upgrade
// If only a clicking power upgrade change PP to click-based period if (TooltipBonusMouse) {
if (TooltipBonusIncome === 0 && TooltipBonusMouse) { l('CMTooltipCookiePerClick').textContent = Beautify(TooltipBonusMouse);
l('CMTooltipPP').textContent = `${Beautify(TooltipPrice / TooltipBonusMouse)} Clicks`; l('CMTooltipCookiePerClick').style.display = 'block';
l('CMTooltipPP').style.color = 'white'; l('CMTooltipCookiePerClick').previousSibling.style.display = 'block';
} else { }
l('CMTooltipPP').textContent = Beautify(CacheUpgrades[Game.UpgradesInStore[TooltipName].name].pp, 2); // If only a clicking power upgrade change PP to click-based period
l('CMTooltipPP').className = ColorTextPre + CacheUpgrades[Game.UpgradesInStore[TooltipName].name].color; if (TooltipBonusIncome === 0 && TooltipBonusMouse) {
} l('CMTooltipPP').textContent = `${Beautify(
} TooltipPrice / TooltipBonusMouse,
const timeColor = GetTimeColor((TooltipPrice - (Game.cookies + GetWrinkConfigBank())) / GetCPS()); )} Clicks`;
l('CMTooltipTime').textContent = timeColor.text; l('CMTooltipPP').style.color = 'white';
if (timeColor.text === 'Done!' && Game.cookies < Game.UpgradesInStore[TooltipName].getPrice()) { } else {
l('CMTooltipTime').textContent = `${timeColor.text} (with Wrink)`; l('CMTooltipPP').textContent = Beautify(
} else l('CMTooltipTime').textContent = timeColor.text; CacheUpgrades[Game.UpgradesInStore[TooltipName].name].pp,
l('CMTooltipTime').className = ColorTextPre + timeColor.color; 2,
);
l('CMTooltipPP').className =
ColorTextPre +
CacheUpgrades[Game.UpgradesInStore[TooltipName].name].color;
}
}
const timeColor = GetTimeColor(
(TooltipPrice - (Game.cookies + GetWrinkConfigBank())) / GetCPS(),
);
l('CMTooltipTime').textContent = timeColor.text;
if (
timeColor.text === 'Done!' &&
Game.cookies < Game.UpgradesInStore[TooltipName].getPrice()
) {
l('CMTooltipTime').textContent = `${timeColor.text} (with Wrink)`;
} else l('CMTooltipTime').textContent = timeColor.text;
l('CMTooltipTime').className = ColorTextPre + timeColor.color;
// Add extra info to Chocolate egg tooltip // Add extra info to Chocolate egg tooltip
if (Game.UpgradesInStore[TooltipName].name === 'Chocolate egg') { if (Game.UpgradesInStore[TooltipName].name === 'Chocolate egg') {
l('CMTooltipBorder').lastChild.style.marginBottom = '4px'; l('CMTooltipBorder').lastChild.style.marginBottom = '4px';
l('CMTooltipBorder').appendChild(Create.TooltipCreateHeader('Cookies to be gained (Currently/Max)')); l('CMTooltipBorder').appendChild(
const chocolate = document.createElement('div'); Create.TooltipCreateHeader('Cookies to be gained (Currently/Max)'),
chocolate.style.color = 'white'; );
chocolate.textContent = `${Beautify(Game.cookies * 0.05)} / ${Beautify(CacheLastChoEgg)}`; const chocolate = document.createElement('div');
l('CMTooltipBorder').appendChild(chocolate); chocolate.style.color = 'white';
} chocolate.textContent = `${Beautify(Game.cookies * 0.05)} / ${Beautify(
} else l('CMTooltipArea').style.display = 'none'; CacheLastChoEgg,
)}`;
l('CMTooltipBorder').appendChild(chocolate);
}
} else l('CMTooltipArea').style.display = 'none';
} }
/** /**
@@ -136,18 +193,18 @@ export function Upgrade() {
* It adds to the additional information to l('CMTooltipArea') * It adds to the additional information to l('CMTooltipArea')
*/ */
export function SugarLump() { export function SugarLump() {
if (CMOptions.TooltipLump === 1) { if (CMOptions.TooltipLump === 1) {
const tooltipBox = l('CMTooltipBorder'); const tooltipBox = l('CMTooltipBorder');
tooltipBox.appendChild(Create.TooltipCreateHeader('Current Sugar Lump')); tooltipBox.appendChild(Create.TooltipCreateHeader('Current Sugar Lump'));
const lumpType = document.createElement('div'); const lumpType = document.createElement('div');
lumpType.id = 'CMTooltipTime'; lumpType.id = 'CMTooltipTime';
tooltipBox.appendChild(lumpType); tooltipBox.appendChild(lumpType);
const lumpColor = GetLumpColor(Game.lumpCurrentType); const lumpColor = GetLumpColor(Game.lumpCurrentType);
lumpType.textContent = lumpColor.text; lumpType.textContent = lumpColor.text;
lumpType.className = ColorTextPre + lumpColor.color; lumpType.className = ColorTextPre + lumpColor.color;
} else l('CMTooltipArea').style.display = 'none'; } else l('CMTooltipArea').style.display = 'none';
} }
/** /**
@@ -155,53 +212,69 @@ export function SugarLump() {
* It adds to the additional information to l('CMTooltipArea') * It adds to the additional information to l('CMTooltipArea')
*/ */
export function Grimoire() { export function Grimoire() {
const minigame = Game.Objects['Wizard tower'].minigame; const minigame = Game.Objects['Wizard tower'].minigame;
const spellCost = minigame.getSpellCost(minigame.spellsById[TooltipName]); const spellCost = minigame.getSpellCost(minigame.spellsById[TooltipName]);
if (CMOptions.TooltipGrim === 1 && spellCost <= minigame.magicM) { if (CMOptions.TooltipGrim === 1 && spellCost <= minigame.magicM) {
const tooltipBox = l('CMTooltipBorder'); const tooltipBox = l('CMTooltipBorder');
// Time left till enough magic for spell // Time left till enough magic for spell
tooltipBox.appendChild(Create.TooltipCreateHeader('Time Left')); tooltipBox.appendChild(Create.TooltipCreateHeader('Time Left'));
const time = document.createElement('div'); const time = document.createElement('div');
time.id = 'CMTooltipTime'; time.id = 'CMTooltipTime';
tooltipBox.appendChild(time); tooltipBox.appendChild(time);
const timeColor = GetTimeColor(CalculateGrimoireRefillTime(minigame.magic, minigame.magicM, spellCost)); const timeColor = GetTimeColor(
time.textContent = timeColor.text; CalculateGrimoireRefillTime(minigame.magic, minigame.magicM, spellCost),
time.className = ColorTextPre + timeColor.color; );
time.textContent = timeColor.text;
time.className = ColorTextPre + timeColor.color;
// Time left untill magic spent is recovered // Time left untill magic spent is recovered
if (spellCost <= minigame.magic) { if (spellCost <= minigame.magic) {
tooltipBox.appendChild(Create.TooltipCreateHeader('Recover Time')); tooltipBox.appendChild(Create.TooltipCreateHeader('Recover Time'));
const recover = document.createElement('div'); const recover = document.createElement('div');
recover.id = 'CMTooltipRecover'; recover.id = 'CMTooltipRecover';
tooltipBox.appendChild(recover); tooltipBox.appendChild(recover);
const recoverColor = GetTimeColor(CalculateGrimoireRefillTime(Math.max(0, minigame.magic - spellCost), minigame.magicM, minigame.magic)); const recoverColor = GetTimeColor(
recover.textContent = recoverColor.text; CalculateGrimoireRefillTime(
recover.className = ColorTextPre + recoverColor.color; Math.max(0, minigame.magic - spellCost),
} minigame.magicM,
minigame.magic,
),
);
recover.textContent = recoverColor.text;
recover.className = ColorTextPre + recoverColor.color;
}
// Extra information on cookies gained when spell is Conjure Baked Goods (Name === 0) // Extra information on cookies gained when spell is Conjure Baked Goods (Name === 0)
if (TooltipName === '0') { if (TooltipName === '0') {
tooltipBox.appendChild(Create.TooltipCreateHeader('Cookies to be gained/lost')); tooltipBox.appendChild(
const conjure = document.createElement('div'); Create.TooltipCreateHeader('Cookies to be gained/lost'),
conjure.id = 'x'; );
tooltipBox.appendChild(conjure); const conjure = document.createElement('div');
const reward = document.createElement('span'); conjure.id = 'x';
reward.style.color = '#33FF00'; tooltipBox.appendChild(conjure);
reward.textContent = Beautify(Math.min((Game.cookies + GetWrinkConfigBank()) * 0.15, CacheNoGoldSwitchCookiesPS * 60 * 30), 2); const reward = document.createElement('span');
conjure.appendChild(reward); reward.style.color = '#33FF00';
const seperator = document.createElement('span'); reward.textContent = Beautify(
seperator.textContent = ' / '; Math.min(
conjure.appendChild(seperator); (Game.cookies + GetWrinkConfigBank()) * 0.15,
const loss = document.createElement('span'); CacheNoGoldSwitchCookiesPS * 60 * 30,
loss.style.color = 'red'; ),
loss.textContent = Beautify((CacheNoGoldSwitchCookiesPS * 60 * 15), 2); 2,
conjure.appendChild(loss); );
} conjure.appendChild(reward);
const seperator = document.createElement('span');
seperator.textContent = ' / ';
conjure.appendChild(seperator);
const loss = document.createElement('span');
loss.style.color = 'red';
loss.textContent = Beautify(CacheNoGoldSwitchCookiesPS * 60 * 15, 2);
conjure.appendChild(loss);
}
l('CMTooltipArea').appendChild(tooltipBox); l('CMTooltipArea').appendChild(tooltipBox);
} else l('CMTooltipArea').style.display = 'none'; } else l('CMTooltipArea').style.display = 'none';
} }
/** /**
@@ -209,24 +282,50 @@ export function Grimoire() {
* It adds to the additional information to l('CMTooltipArea') * It adds to the additional information to l('CMTooltipArea')
*/ */
export function GardenPlots() { export function GardenPlots() {
const minigame = Game.Objects.Farm.minigame; const minigame = Game.Objects.Farm.minigame;
if (CMOptions.TooltipPlots && minigame.plot[TooltipName[1]][TooltipName[0]][0] !== 0) { if (
const mature = minigame.plot[TooltipName[1]][TooltipName[0]][1] > minigame.plantsById[minigame.plot[TooltipName[1]][TooltipName[0]][0] - 1].matureBase; CMOptions.TooltipPlots &&
const plantName = minigame.plantsById[minigame.plot[TooltipName[1]][TooltipName[0]][0] - 1].name; minigame.plot[TooltipName[1]][TooltipName[0]][0] !== 0
l('CMTooltipBorder').appendChild(Create.TooltipCreateHeader('Reward (Current / Maximum)')); ) {
const reward = document.createElement('div'); const mature =
reward.id = 'CMTooltipPlantReward'; minigame.plot[TooltipName[1]][TooltipName[0]][1] >
l('CMTooltipBorder').appendChild(reward); minigame.plantsById[minigame.plot[TooltipName[1]][TooltipName[0]][0] - 1]
if (plantName === 'Bakeberry') { .matureBase;
l('CMTooltipPlantReward').textContent = `${mature ? Beautify(Math.min(Game.cookies * 0.03, Game.cookiesPs * 60 * 30)) : '0'} / ${Beautify(Game.cookiesPs * 60 * 30)}`; const plantName =
} else if (plantName === 'Chocoroot' || plantName === 'White chocoroot') { minigame.plantsById[minigame.plot[TooltipName[1]][TooltipName[0]][0] - 1]
l('CMTooltipPlantReward').textContent = `${mature ? Beautify(Math.min(Game.cookies * 0.03, Game.cookiesPs * 60 * 3)) : '0'} / ${Beautify(Game.cookiesPs * 60 * 3)}`; .name;
} else if (plantName === 'Queenbeet') { l('CMTooltipBorder').appendChild(
l('CMTooltipPlantReward').textContent = `${mature ? Beautify(Math.min(Game.cookies * 0.04, Game.cookiesPs * 60 * 60)) : '0'} / ${Beautify(Game.cookiesPs * 60 * 60)}`; Create.TooltipCreateHeader('Reward (Current / Maximum)'),
} else if (plantName === 'Duketater') { );
l('CMTooltipPlantReward').textContent = `${mature ? Beautify(Math.min(Game.cookies * 0.08, Game.cookiesPs * 60 * 120)) : '0'} / ${Beautify(Game.cookiesPs * 60 * 120)}`; const reward = document.createElement('div');
} else l('CMTooltipArea').style.display = 'none'; reward.id = 'CMTooltipPlantReward';
} else l('CMTooltipArea').style.display = 'none'; l('CMTooltipBorder').appendChild(reward);
if (plantName === 'Bakeberry') {
l('CMTooltipPlantReward').textContent = `${
mature
? Beautify(Math.min(Game.cookies * 0.03, Game.cookiesPs * 60 * 30))
: '0'
} / ${Beautify(Game.cookiesPs * 60 * 30)}`;
} else if (plantName === 'Chocoroot' || plantName === 'White chocoroot') {
l('CMTooltipPlantReward').textContent = `${
mature
? Beautify(Math.min(Game.cookies * 0.03, Game.cookiesPs * 60 * 3))
: '0'
} / ${Beautify(Game.cookiesPs * 60 * 3)}`;
} else if (plantName === 'Queenbeet') {
l('CMTooltipPlantReward').textContent = `${
mature
? Beautify(Math.min(Game.cookies * 0.04, Game.cookiesPs * 60 * 60))
: '0'
} / ${Beautify(Game.cookiesPs * 60 * 60)}`;
} else if (plantName === 'Duketater') {
l('CMTooltipPlantReward').textContent = `${
mature
? Beautify(Math.min(Game.cookies * 0.08, Game.cookiesPs * 60 * 120))
: '0'
} / ${Beautify(Game.cookiesPs * 60 * 120)}`;
} else l('CMTooltipArea').style.display = 'none';
} else l('CMTooltipArea').style.display = 'none';
} }
/** /**
@@ -235,36 +334,52 @@ export function GardenPlots() {
* It adds to the additional information to l('CMTooltipArea') * It adds to the additional information to l('CMTooltipArea')
*/ */
export function HarvestAll() { export function HarvestAll() {
const minigame = Game.Objects.Farm.minigame; const minigame = Game.Objects.Farm.minigame;
if (CMOptions.TooltipLump) { if (CMOptions.TooltipLump) {
l('CMTooltipBorder').appendChild(Create.TooltipCreateHeader('Cookies gained from harvesting:')); l('CMTooltipBorder').appendChild(
let totalGain = 0; Create.TooltipCreateHeader('Cookies gained from harvesting:'),
let mortal = 0; );
if (Game.keys[16] && Game.keys[17]) mortal = 1; let totalGain = 0;
for (let y = 0; y < 6; y++) { let mortal = 0;
for (let x = 0; x < 6; x++) { if (Game.keys[16] && Game.keys[17]) mortal = 1;
if (minigame.plot[y][x][0] >= 1) { for (let y = 0; y < 6; y++) {
const tile = minigame.plot[y][x]; for (let x = 0; x < 6; x++) {
const me = minigame.plantsById[tile[0] - 1]; if (minigame.plot[y][x][0] >= 1) {
const plantName = me.name; const tile = minigame.plot[y][x];
const me = minigame.plantsById[tile[0] - 1];
const plantName = me.name;
let count = true; let count = true;
if (mortal && me.immortal) count = false; if (mortal && me.immortal) count = false;
if (tile[1] < me.matureBase) count = false; if (tile[1] < me.matureBase) count = false;
if (count && plantName === 'Bakeberry') { if (count && plantName === 'Bakeberry') {
totalGain += Math.min(Game.cookies * 0.03, Game.cookiesPs * 60 * 30); totalGain += Math.min(
} else if (count && plantName === 'Chocoroot' || plantName === 'White chocoroot') { Game.cookies * 0.03,
totalGain += Math.min(Game.cookies * 0.03, Game.cookiesPs * 60 * 3); Game.cookiesPs * 60 * 30,
} else if (count && plantName === 'Queenbeet') { );
totalGain += Math.min(Game.cookies * 0.04, Game.cookiesPs * 60 * 60); } else if (
} else if (count && plantName === 'Duketater') { (count && plantName === 'Chocoroot') ||
totalGain += Math.min(Game.cookies * 0.08, Game.cookiesPs * 60 * 120); plantName === 'White chocoroot'
} ) {
} totalGain += Math.min(Game.cookies * 0.03, Game.cookiesPs * 60 * 3);
} } else if (count && plantName === 'Queenbeet') {
} totalGain += Math.min(
l('CMTooltipBorder').appendChild(document.createTextNode(Beautify(totalGain))); Game.cookies * 0.04,
} else l('CMTooltipArea').style.display = 'none'; Game.cookiesPs * 60 * 60,
);
} else if (count && plantName === 'Duketater') {
totalGain += Math.min(
Game.cookies * 0.08,
Game.cookiesPs * 60 * 120,
);
}
}
}
}
l('CMTooltipBorder').appendChild(
document.createTextNode(Beautify(totalGain)),
);
} else l('CMTooltipArea').style.display = 'none';
} }
/** /**
@@ -272,73 +387,125 @@ export function HarvestAll() {
* It is called by CM.Disp.UpdateTooltip() * It is called by CM.Disp.UpdateTooltip()
*/ */
export function Warnings() { export function Warnings() {
if (TooltipType === 'b' || TooltipType === 'u') { if (TooltipType === 'b' || TooltipType === 'u') {
if (document.getElementById('CMDispTooltipWarningParent') === null) { if (document.getElementById('CMDispTooltipWarningParent') === null) {
l('tooltipAnchor').appendChild(Create.TooltipCreateWarningSection()); l('tooltipAnchor').appendChild(Create.TooltipCreateWarningSection());
ToggleToolWarnPos(); ToggleToolWarnPos();
} }
if (CMOptions.ToolWarnPos === 0) l('CMDispTooltipWarningParent').style.right = '0px'; if (CMOptions.ToolWarnPos === 0)
else l('CMDispTooltipWarningParent').style.top = `${l('tooltip').offsetHeight}px`; l('CMDispTooltipWarningParent').style.right = '0px';
else
l('CMDispTooltipWarningParent').style.top = `${
l('tooltip').offsetHeight
}px`;
l('CMDispTooltipWarningParent').style.width = `${l('tooltip').offsetWidth - 6}px`; l('CMDispTooltipWarningParent').style.width = `${
l('tooltip').offsetWidth - 6
}px`;
const amount = (Game.cookies + GetWrinkConfigBank()) - TooltipPrice; const amount = Game.cookies + GetWrinkConfigBank() - TooltipPrice;
const bonusIncomeUsed = CMOptions.ToolWarnBon ? TooltipBonusIncome : 0; const bonusIncomeUsed = CMOptions.ToolWarnBon ? TooltipBonusIncome : 0;
let limitLucky = CacheLucky; let limitLucky = CacheLucky;
if (CMOptions.ToolWarnBon === 1) { if (CMOptions.ToolWarnBon === 1) {
let bonusNoFren = TooltipBonusIncome; let bonusNoFren = TooltipBonusIncome;
bonusNoFren /= GetCPSBuffMult(); bonusNoFren /= GetCPSBuffMult();
limitLucky += ((bonusNoFren * 60 * 15) / 0.15); limitLucky += (bonusNoFren * 60 * 15) / 0.15;
} }
if (CMOptions.ToolWarnLucky === 1) { if (CMOptions.ToolWarnLucky === 1) {
if (amount < limitLucky && (TooltipType !== 'b' || Game.buyMode === 1)) { if (amount < limitLucky && (TooltipType !== 'b' || Game.buyMode === 1)) {
l('CMDispTooltipWarnLucky').style.display = ''; l('CMDispTooltipWarnLucky').style.display = '';
l('CMDispTooltipWarnLuckyText').textContent = `${Beautify(limitLucky - amount)} (${FormatTime((limitLucky - amount) / (GetCPS() + bonusIncomeUsed))})`; l('CMDispTooltipWarnLuckyText').textContent = `${Beautify(
} else l('CMDispTooltipWarnLucky').style.display = 'none'; limitLucky - amount,
} else l('CMDispTooltipWarnLucky').style.display = 'none'; )} (${FormatTime(
(limitLucky - amount) / (GetCPS() + bonusIncomeUsed),
)})`;
} else l('CMDispTooltipWarnLucky').style.display = 'none';
} else l('CMDispTooltipWarnLucky').style.display = 'none';
if (CMOptions.ToolWarnLuckyFrenzy === 1) { if (CMOptions.ToolWarnLuckyFrenzy === 1) {
const limitLuckyFrenzy = limitLucky * 7; const limitLuckyFrenzy = limitLucky * 7;
if (amount < limitLuckyFrenzy && (TooltipType !== 'b' || Game.buyMode === 1)) { if (
l('CMDispTooltipWarnLuckyFrenzy').style.display = ''; amount < limitLuckyFrenzy &&
l('CMDispTooltipWarnLuckyFrenzyText').textContent = `${Beautify(limitLuckyFrenzy - amount)} (${FormatTime((limitLuckyFrenzy - amount) / (GetCPS() + bonusIncomeUsed))})`; (TooltipType !== 'b' || Game.buyMode === 1)
} else l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; ) {
} else l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; l('CMDispTooltipWarnLuckyFrenzy').style.display = '';
l('CMDispTooltipWarnLuckyFrenzyText').textContent = `${Beautify(
limitLuckyFrenzy - amount,
)} (${FormatTime(
(limitLuckyFrenzy - amount) / (GetCPS() + bonusIncomeUsed),
)})`;
} else l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none';
} else l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none';
if (CMOptions.ToolWarnConjure === 1) { if (CMOptions.ToolWarnConjure === 1) {
const limitConjure = limitLucky * 2; const limitConjure = limitLucky * 2;
if ((amount < limitConjure) && (TooltipType !== 'b' || Game.buyMode === 1)) { if (
l('CMDispTooltipWarnConjure').style.display = ''; amount < limitConjure &&
l('CMDispTooltipWarnConjureText').textContent = `${Beautify(limitConjure - amount)} (${FormatTime((limitConjure - amount) / (GetCPS() + bonusIncomeUsed))})`; (TooltipType !== 'b' || Game.buyMode === 1)
} else l('CMDispTooltipWarnConjure').style.display = 'none'; ) {
} else l('CMDispTooltipWarnConjure').style.display = 'none'; l('CMDispTooltipWarnConjure').style.display = '';
l('CMDispTooltipWarnConjureText').textContent = `${Beautify(
limitConjure - amount,
)} (${FormatTime(
(limitConjure - amount) / (GetCPS() + bonusIncomeUsed),
)})`;
} else l('CMDispTooltipWarnConjure').style.display = 'none';
} else l('CMDispTooltipWarnConjure').style.display = 'none';
if (CMOptions.ToolWarnConjureFrenzy === 1) { if (CMOptions.ToolWarnConjureFrenzy === 1) {
const limitConjureFrenzy = limitLucky * 2 * 7; const limitConjureFrenzy = limitLucky * 2 * 7;
if ((amount < limitConjureFrenzy) && (TooltipType !== 'b' || Game.buyMode === 1)) { if (
l('CMDispTooltipWarnConjureFrenzy').style.display = ''; amount < limitConjureFrenzy &&
l('CMDispTooltipWarnConjureFrenzyText').textContent = `${Beautify(limitConjureFrenzy - amount)} (${FormatTime((limitConjureFrenzy - amount) / (GetCPS() + bonusIncomeUsed))})`; (TooltipType !== 'b' || Game.buyMode === 1)
} else l('CMDispTooltipWarnConjureFrenzy').style.display = 'none'; ) {
} else l('CMDispTooltipWarnConjureFrenzy').style.display = 'none'; l('CMDispTooltipWarnConjureFrenzy').style.display = '';
l('CMDispTooltipWarnConjureFrenzyText').textContent = `${Beautify(
limitConjureFrenzy - amount,
)} (${FormatTime(
(limitConjureFrenzy - amount) / (GetCPS() + bonusIncomeUsed),
)})`;
} else l('CMDispTooltipWarnConjureFrenzy').style.display = 'none';
} else l('CMDispTooltipWarnConjureFrenzy').style.display = 'none';
if (CMOptions.ToolWarnEdifice === 1 && Game.Objects['Wizard tower'].minigameLoaded) { if (
if (CacheEdifice && amount < CacheEdifice && (TooltipType !== 'b' || Game.buyMode === 1)) { CMOptions.ToolWarnEdifice === 1 &&
l('CMDispTooltipWarnEdifice').style.display = ''; Game.Objects['Wizard tower'].minigameLoaded
l('CMDispTooltipWarnEdificeText').textContent = `${Beautify(CacheEdifice - amount)} (${FormatTime((CacheEdifice - amount) / (GetCPS() + bonusIncomeUsed))})`; ) {
} else l('CMDispTooltipWarnEdifice').style.display = 'none'; if (
} else l('CMDispTooltipWarnEdifice').style.display = 'none'; CacheEdifice &&
amount < CacheEdifice &&
(TooltipType !== 'b' || Game.buyMode === 1)
) {
l('CMDispTooltipWarnEdifice').style.display = '';
l('CMDispTooltipWarnEdificeText').textContent = `${Beautify(
CacheEdifice - amount,
)} (${FormatTime(
(CacheEdifice - amount) / (GetCPS() + bonusIncomeUsed),
)})`;
} else l('CMDispTooltipWarnEdifice').style.display = 'none';
} else l('CMDispTooltipWarnEdifice').style.display = 'none';
if (CMOptions.ToolWarnUser > 0) { if (CMOptions.ToolWarnUser > 0) {
if (amount < CMOptions.ToolWarnUser * GetCPS() && (TooltipType !== 'b' || Game.buyMode === 1)) { if (
l('CMDispTooltipWarnUser').style.display = ''; amount < CMOptions.ToolWarnUser * GetCPS() &&
// Need to update tooltip text dynamically (TooltipType !== 'b' || Game.buyMode === 1)
l('CMDispTooltipWarnUser').children[0].textContent = `Purchase of this item will put you under the number of Cookies equal to ${CMOptions.ToolWarnUser} seconds of CPS`; ) {
l('CMDispTooltipWarnUserText').textContent = `${Beautify(CMOptions.ToolWarnUser * GetCPS() - amount)} (${FormatTime((CMOptions.ToolWarnUser * GetCPS() - amount) / (GetCPS() + bonusIncomeUsed))})`; l('CMDispTooltipWarnUser').style.display = '';
} else l('CMDispTooltipWarnUser').style.display = 'none'; // Need to update tooltip text dynamically
} else l('CMDispTooltipWarnUser').style.display = 'none'; l(
} else if (l('CMDispTooltipWarningParent') !== null) { 'CMDispTooltipWarnUser',
l('CMDispTooltipWarningParent').remove(); ).children[0].textContent = `Purchase of this item will put you under the number of Cookies equal to ${CMOptions.ToolWarnUser} seconds of CPS`;
} l('CMDispTooltipWarnUserText').textContent = `${Beautify(
CMOptions.ToolWarnUser * GetCPS() - amount,
)} (${FormatTime(
(CMOptions.ToolWarnUser * GetCPS() - amount) /
(GetCPS() + bonusIncomeUsed),
)})`;
} else l('CMDispTooltipWarnUser').style.display = 'none';
} else l('CMDispTooltipWarnUser').style.display = 'none';
} else if (l('CMDispTooltipWarningParent') !== null) {
l('CMDispTooltipWarningParent').remove();
}
} }

View File

@@ -1,7 +1,11 @@
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import { SimObjects } from '../../Sim/VariablesAndData'; import { SimObjects } from '../../Sim/VariablesAndData';
import { Beautify } from '../BeautifyAndFormatting/BeautifyFormatting'; import { Beautify } from '../BeautifyAndFormatting/BeautifyFormatting';
import { TooltipWrinkler, TooltipWrinklerArea, TooltipWrinklerBeingShown } from '../VariablesAndData'; import {
TooltipWrinkler,
TooltipWrinklerArea,
TooltipWrinklerBeingShown,
} from '../VariablesAndData';
/** /**
* This function checks and create a tooltip for the wrinklers * This function checks and create a tooltip for the wrinklers
@@ -9,34 +13,38 @@ import { TooltipWrinkler, TooltipWrinklerArea, TooltipWrinklerBeingShown } from
* As wrinklers are not appended to the DOM we us a different system than for other tooltips * As wrinklers are not appended to the DOM we us a different system than for other tooltips
*/ */
export function CheckWrinklerTooltip() { export function CheckWrinklerTooltip() {
if (CMOptions.TooltipWrink === 1 && TooltipWrinklerArea === 1) { // Latter is set by CM.Main.AddWrinklerAreaDetect if (CMOptions.TooltipWrink === 1 && TooltipWrinklerArea === 1) {
let showingTooltip = false; // Latter is set by CM.Main.AddWrinklerAreaDetect
for (const i of Object.keys(Game.wrinklers)) { let showingTooltip = false;
const me = Game.wrinklers[i]; for (const i of Object.keys(Game.wrinklers)) {
if (me.phase > 0 && me.selected) { const me = Game.wrinklers[i];
showingTooltip = true; if (me.phase > 0 && me.selected) {
if (TooltipWrinklerBeingShown[i] === 0 || TooltipWrinklerBeingShown[i] === undefined) { showingTooltip = true;
const placeholder = document.createElement('div'); if (
const wrinkler = document.createElement('div'); TooltipWrinklerBeingShown[i] === 0 ||
wrinkler.style.minWidth = '120px'; TooltipWrinklerBeingShown[i] === undefined
wrinkler.style.marginBottom = '4px'; ) {
const div = document.createElement('div'); const placeholder = document.createElement('div');
div.style.textAlign = 'center'; const wrinkler = document.createElement('div');
div.id = 'CMTooltipWrinkler'; wrinkler.style.minWidth = '120px';
wrinkler.appendChild(div); wrinkler.style.marginBottom = '4px';
placeholder.appendChild(wrinkler); const div = document.createElement('div');
Game.tooltip.draw(this, escape(placeholder.innerHTML)); div.style.textAlign = 'center';
TooltipWrinkler = i; div.id = 'CMTooltipWrinkler';
TooltipWrinklerBeingShown[i] = 1; wrinkler.appendChild(div);
} else break; placeholder.appendChild(wrinkler);
} else { Game.tooltip.draw(this, escape(placeholder.innerHTML));
TooltipWrinklerBeingShown[i] = 0; TooltipWrinkler = i;
} TooltipWrinklerBeingShown[i] = 1;
} } else break;
if (!showingTooltip) { } else {
Game.tooltip.hide(); TooltipWrinklerBeingShown[i] = 0;
} }
} }
if (!showingTooltip) {
Game.tooltip.hide();
}
}
} }
/** /**
@@ -45,19 +53,19 @@ export function CheckWrinklerTooltip() {
* As wrinklers are not appended to the DOM we us a different system than for other tooltips * As wrinklers are not appended to the DOM we us a different system than for other tooltips
*/ */
export function UpdateWrinklerTooltip() { export function UpdateWrinklerTooltip() {
if (CMOptions.TooltipWrink === 1 && l('CMTooltipWrinkler') !== null) { if (CMOptions.TooltipWrink === 1 && l('CMTooltipWrinkler') !== null) {
let sucked = Game.wrinklers[TooltipWrinkler].sucked; let sucked = Game.wrinklers[TooltipWrinkler].sucked;
let toSuck = 1.1; let toSuck = 1.1;
if (Game.Has('Sacrilegious corruption')) toSuck *= 1.05; if (Game.Has('Sacrilegious corruption')) toSuck *= 1.05;
if (Game.wrinklers[TooltipWrinkler].type === 1) toSuck *= 3; // Shiny wrinklers if (Game.wrinklers[TooltipWrinkler].type === 1) toSuck *= 3; // Shiny wrinklers
sucked *= toSuck; sucked *= toSuck;
if (Game.Has('Wrinklerspawn')) sucked *= 1.05; if (Game.Has('Wrinklerspawn')) sucked *= 1.05;
if (SimObjects.Temple.minigameLoaded) { if (SimObjects.Temple.minigameLoaded) {
const godLvl = Game.hasGod('scorn'); const godLvl = Game.hasGod('scorn');
if (godLvl === 1) sucked *= 1.15; if (godLvl === 1) sucked *= 1.15;
else if (godLvl === 2) sucked *= 1.1; else if (godLvl === 2) sucked *= 1.1;
else if (godLvl === 3) sucked *= 1.05; else if (godLvl === 3) sucked *= 1.05;
} }
l('CMTooltipWrinkler').textContent = Beautify(sucked); l('CMTooltipWrinkler').textContent = Beautify(sucked);
} }
} }

View File

@@ -23,7 +23,17 @@ export const ColorPurple = 'Purple';
export const ColorGray = 'Gray'; export const ColorGray = 'Gray';
export const ColorPink = 'Pink'; export const ColorPink = 'Pink';
export const ColorBrown = 'Brown'; export const ColorBrown = 'Brown';
export const Colors = [ColorGray, ColorBlue, ColorGreen, ColorYellow, ColorOrange, ColorRed, ColorPurple, ColorPink, ColorBrown]; export const Colors = [
ColorGray,
ColorBlue,
ColorGreen,
ColorYellow,
ColorOrange,
ColorRed,
ColorPurple,
ColorPink,
ColorBrown,
];
/** /**
* This list is used to make some very basic tooltips. * This list is used to make some very basic tooltips.
@@ -33,14 +43,42 @@ export const Colors = [ColorGray, ColorBlue, ColorGreen, ColorYellow, ColorOrang
* @item {string} minWidth * @item {string} minWidth
*/ */
export const TooltipText = [ export const TooltipText = [
['GoldCookTooltipPlaceholder', 'Calculated with Golden Switch off', '200px'], ['GoldCookTooltipPlaceholder', 'Calculated with Golden Switch off', '200px'],
['GoldCookDragonsFortuneTooltipPlaceholder', 'Calculated with Golden Switch off and at least one golden cookie on-screen', '240px'], [
['PrestMaxTooltipPlaceholder', 'The MAX prestige is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all stock market goods, selling all buildings with Earth Shatterer and Reality Bending auras, and buying Chocolate egg', '320px'], 'GoldCookDragonsFortuneTooltipPlaceholder',
['NextPrestTooltipPlaceholder', 'Calculated with cookies gained from wrinklers and Chocolate egg', '200px'], 'Calculated with Golden Switch off and at least one golden cookie on-screen',
['HeavenChipMaxTooltipPlaceholder', 'The MAX heavenly chips is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all stock market goods, selling all buildings with Earth Shatterer and Reality Bending auras, and buying Chocolate egg', '330px'], '240px',
['ResetTooltipPlaceholder', 'The bonus income you would get from new prestige levels unlocked at 100% of its potential and from ascension achievements if you have the same buildings/upgrades after reset', '370px'], ],
['ChoEggTooltipPlaceholder', 'The amount of cookies you would get from popping all wrinklers with Skruuia god in Diamond slot, selling all stock market goods, selling all buildings with Earth Shatterer and Reality Bending auras, and then buying Chocolate egg', '300px'], [
['ChainNextLevelPlaceholder', 'Cheated cookies might break this formula', '250px'], 'PrestMaxTooltipPlaceholder',
'The MAX prestige is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all stock market goods, selling all buildings with Earth Shatterer and Reality Bending auras, and buying Chocolate egg',
'320px',
],
[
'NextPrestTooltipPlaceholder',
'Calculated with cookies gained from wrinklers and Chocolate egg',
'200px',
],
[
'HeavenChipMaxTooltipPlaceholder',
'The MAX heavenly chips is calculated with the cookies gained from popping all wrinklers with Skruuia god in Diamond slot, selling all stock market goods, selling all buildings with Earth Shatterer and Reality Bending auras, and buying Chocolate egg',
'330px',
],
[
'ResetTooltipPlaceholder',
'The bonus income you would get from new prestige levels unlocked at 100% of its potential and from ascension achievements if you have the same buildings/upgrades after reset',
'370px',
],
[
'ChoEggTooltipPlaceholder',
'The amount of cookies you would get from popping all wrinklers with Skruuia god in Diamond slot, selling all stock market goods, selling all buildings with Earth Shatterer and Reality Bending auras, and then buying Chocolate egg',
'300px',
],
[
'ChainNextLevelPlaceholder',
'Cheated cookies might break this formula',
'250px',
],
]; ];
/** /**
@@ -78,7 +116,12 @@ export const ClickTimes = [1, 5, 10, 15, 30];
* This array is used to give certain timers specific colours * This array is used to give certain timers specific colours
*/ */
export const BuffColors = { export const BuffColors = {
Frenzy: ColorYellow, 'Dragon Harvest': ColorBrown, 'Elder frenzy': ColorGreen, Clot: ColorRed, 'Click frenzy': ColorBlue, Dragonflight: ColorPink, Frenzy: ColorYellow,
'Dragon Harvest': ColorBrown,
'Elder frenzy': ColorGreen,
Clot: ColorRed,
'Click frenzy': ColorBlue,
Dragonflight: ColorPink,
}; };
/** /**

View File

@@ -6,21 +6,23 @@ import CMLoop from '../Main/Loop';
import { isInitializing } from './Variables'; import { isInitializing } from './Variables';
/** /**
* This creates a init function for the CM object. Per Game code/comments: * This creates a init function for the CM object. Per Game code/comments:
* "this function is called as soon as the mod is registered * "this function is called as soon as the mod is registered
* declare hooks here" * declare hooks here"
* It starts the further initialization of CookieMonster and registers hooks * It starts the further initialization of CookieMonster and registers hooks
*/ */
export default function init() { export default function init() {
isInitializing = true; isInitializing = true;
let proceed = true; let proceed = true;
if (Game.version !== Number(VersionMajor)) { if (Game.version !== Number(VersionMajor)) {
proceed = confirm(`Cookie Monster version ${VersionMajor}.${VersionMinor} is meant for Game version ${VersionMajor}. Loading a different version may cause errors. Do you still want to load Cookie Monster?`); proceed = confirm(
} `Cookie Monster version ${VersionMajor}.${VersionMinor} is meant for Game version ${VersionMajor}. Loading a different version may cause errors. Do you still want to load Cookie Monster?`,
if (proceed) { );
InitializeCookieMonster(); }
Game.registerHook('draw', Draw); if (proceed) {
Game.registerHook('logic', CMLoop); InitializeCookieMonster();
isInitializing = false; Game.registerHook('draw', Draw);
} Game.registerHook('logic', CMLoop);
isInitializing = false;
}
} }

View File

@@ -7,11 +7,21 @@ import InitData from '../Sim/InitializeData/InitData';
* "do stuff with the string data you saved previously" * "do stuff with the string data you saved previously"
*/ */
export default function load(str) { export default function load(str) {
const save = JSON.parse(str); const save = JSON.parse(str);
InitData(); InitData();
LoadConfig(save.settings); LoadConfig(save.settings);
if (save.version !== `${VersionMajor}.${VersionMinor}`) { if (save.version !== `${VersionMajor}.${VersionMinor}`) {
if (Game.prefs.popups) Game.Popup('A new version of Cookie Monster has been loaded, check out the release notes in the info tab!'); if (Game.prefs.popups)
else Game.Notify('A new version of Cookie Monster has been loaded, check out the release notes in the info tab!', '', '', 0, 1); 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,
);
}
} }

View File

@@ -7,8 +7,8 @@ import { VersionMajor, VersionMinor } from '../Data/Moddata';
* return 'a string to be saved';" * return 'a string to be saved';"
*/ */
export default function save() { export default function save() {
return JSON.stringify({ return JSON.stringify({
settings: CMOptions, settings: CMOptions,
version: `${VersionMajor}.${VersionMinor}`, version: `${VersionMajor}.${VersionMinor}`,
}); });
} }

View File

@@ -7,11 +7,14 @@ import { LastGardenNextStep } from '../VariablesAndData';
* This function checks if a garden tick has happened * This function checks if a garden tick has happened
*/ */
export default function CheckGardenTick() { export default function CheckGardenTick() {
if (Game.Objects.Farm.minigameLoaded && LastGardenNextStep !== Game.Objects.Farm.minigame.nextStep) { if (
if (LastGardenNextStep !== 0 && LastGardenNextStep < Date.now()) { Game.Objects.Farm.minigameLoaded &&
Flash(3, 'GardFlash'); LastGardenNextStep !== Game.Objects.Farm.minigame.nextStep
PlaySound(CMOptions.GardSoundURL, 'GardSound', 'GardVolume'); ) {
} if (LastGardenNextStep !== 0 && LastGardenNextStep < Date.now()) {
LastGardenNextStep = Game.Objects.Farm.minigame.nextStep; Flash(3, 'GardFlash');
} PlaySound(CMOptions.GardSoundURL, 'GardSound', 'GardVolume');
}
LastGardenNextStep = Game.Objects.Farm.minigame.nextStep;
}
} }

View File

@@ -1,5 +1,8 @@
/* eslint-disable no-unused-vars */ /* eslint-disable no-unused-vars */
import { CacheSpawnedGoldenShimmer, CacheGoldenShimmersByID } from '../../Cache/VariablesAndData'; import {
CacheSpawnedGoldenShimmer,
CacheGoldenShimmersByID,
} from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData'; import { CMOptions } from '../../Config/VariablesAndData';
import CreateGCTimer from '../../Disp/GoldenCookieTimers/GoldenCookieTimers'; import CreateGCTimer from '../../Disp/GoldenCookieTimers/GoldenCookieTimers';
import Flash from '../../Disp/Notifications/Flash'; import Flash from '../../Disp/Notifications/Flash';
@@ -7,7 +10,11 @@ import Notification from '../../Disp/Notifications/Notification';
import PlaySound from '../../Disp/Notifications/Sound'; import PlaySound from '../../Disp/Notifications/Sound';
import { UpdateFavicon } from '../../Disp/TabTitle/FavIcon'; import { UpdateFavicon } from '../../Disp/TabTitle/FavIcon';
import { GCTimers } from '../../Disp/VariablesAndData'; import { GCTimers } from '../../Disp/VariablesAndData';
import { CurrSpawnedGoldenCookieState, LastGoldenCookieState, LastSpawnedGoldenCookieState } from '../VariablesAndData'; import {
CurrSpawnedGoldenCookieState,
LastGoldenCookieState,
LastSpawnedGoldenCookieState,
} from '../VariablesAndData';
/** /**
* Auxilirary function that finds all currently spawned shimmers. * Auxilirary function that finds all currently spawned shimmers.
@@ -15,15 +22,15 @@ import { CurrSpawnedGoldenCookieState, LastGoldenCookieState, LastSpawnedGoldenC
* It is called by CM.CM.Main.CheckGoldenCookie * It is called by CM.CM.Main.CheckGoldenCookie
*/ */
function FindShimmer() { function FindShimmer() {
CurrSpawnedGoldenCookieState = 0; CurrSpawnedGoldenCookieState = 0;
CacheGoldenShimmersByID = {}; CacheGoldenShimmersByID = {};
for (const i of Object.keys(Game.shimmers)) { for (const i of Object.keys(Game.shimmers)) {
CacheGoldenShimmersByID[Game.shimmers[i].id] = Game.shimmers[i]; CacheGoldenShimmersByID[Game.shimmers[i].id] = Game.shimmers[i];
if (Game.shimmers[i].spawnLead && Game.shimmers[i].type === 'golden') { if (Game.shimmers[i].spawnLead && Game.shimmers[i].type === 'golden') {
CacheSpawnedGoldenShimmer = Game.shimmers[i]; CacheSpawnedGoldenShimmer = Game.shimmers[i];
CurrSpawnedGoldenCookieState += 1; CurrSpawnedGoldenCookieState += 1;
} }
} }
} }
/** /**
@@ -31,36 +38,43 @@ function FindShimmer() {
* It is called by CM.Main.Loop * It is called by CM.Main.Loop
*/ */
export default function CheckGoldenCookie() { export default function CheckGoldenCookie() {
FindShimmer(); FindShimmer();
for (const i of Object.keys(GCTimers)) { for (const i of Object.keys(GCTimers)) {
if (typeof CacheGoldenShimmersByID[i] === 'undefined') { if (typeof CacheGoldenShimmersByID[i] === 'undefined') {
GCTimers[i].parentNode.removeChild(GCTimers[i]); GCTimers[i].parentNode.removeChild(GCTimers[i]);
delete GCTimers[i]; delete GCTimers[i];
} }
} }
if (LastGoldenCookieState !== Game.shimmerTypes.golden.n) { if (LastGoldenCookieState !== Game.shimmerTypes.golden.n) {
LastGoldenCookieState = Game.shimmerTypes.golden.n; LastGoldenCookieState = Game.shimmerTypes.golden.n;
if (LastGoldenCookieState) { if (LastGoldenCookieState) {
if (LastSpawnedGoldenCookieState < CurrSpawnedGoldenCookieState) { if (LastSpawnedGoldenCookieState < CurrSpawnedGoldenCookieState) {
Flash(3, 'GCFlash'); Flash(3, 'GCFlash');
PlaySound(CMOptions.GCSoundURL, 'GCSound', 'GCVolume'); PlaySound(CMOptions.GCSoundURL, 'GCSound', 'GCVolume');
Notification('GCNotification', 'Golden Cookie Spawned', 'A Golden Cookie has spawned. Click it now!'); Notification(
} 'GCNotification',
'Golden Cookie Spawned',
'A Golden Cookie has spawned. Click it now!',
);
}
for (const i of Object.keys(Game.shimmers)) { for (const i of Object.keys(Game.shimmers)) {
if (typeof GCTimers[Game.shimmers[i].id] === 'undefined') { if (typeof GCTimers[Game.shimmers[i].id] === 'undefined') {
CreateGCTimer(Game.shimmers[i]); CreateGCTimer(Game.shimmers[i]);
} }
} }
} }
UpdateFavicon(); UpdateFavicon();
LastSpawnedGoldenCookieState = CurrSpawnedGoldenCookieState; LastSpawnedGoldenCookieState = CurrSpawnedGoldenCookieState;
if (CurrSpawnedGoldenCookieState === 0) CacheSpawnedGoldenShimmer = 0; if (CurrSpawnedGoldenCookieState === 0) CacheSpawnedGoldenShimmer = 0;
} else if (CMOptions.GCTimer === 1 && LastGoldenCookieState) { } else if (CMOptions.GCTimer === 1 && LastGoldenCookieState) {
for (const i of Object.keys(GCTimers)) { for (const i of Object.keys(GCTimers)) {
GCTimers[i].style.opacity = CacheGoldenShimmersByID[i].l.style.opacity; GCTimers[i].style.opacity = CacheGoldenShimmersByID[i].l.style.opacity;
GCTimers[i].style.transform = CacheGoldenShimmersByID[i].l.style.transform; GCTimers[i].style.transform =
GCTimers[i].textContent = Math.ceil(CacheGoldenShimmersByID[i].life / Game.fps); CacheGoldenShimmersByID[i].l.style.transform;
} GCTimers[i].textContent = Math.ceil(
} CacheGoldenShimmersByID[i].life / Game.fps,
);
}
}
} }

View File

@@ -9,14 +9,21 @@ import { LastMagicBarFull } from '../VariablesAndData';
* It is called by CM.Main.Loop * It is called by CM.Main.Loop
*/ */
export default function CheckMagicMeter() { export default function CheckMagicMeter() {
if (Game.Objects['Wizard tower'].minigameLoaded && CMOptions.GrimoireBar === 1) { if (
const minigame = Game.Objects['Wizard tower'].minigame; Game.Objects['Wizard tower'].minigameLoaded &&
if (minigame.magic < minigame.magicM) LastMagicBarFull = false; CMOptions.GrimoireBar === 1
else if (!LastMagicBarFull) { ) {
LastMagicBarFull = true; const minigame = Game.Objects['Wizard tower'].minigame;
Flash(3, 'MagicFlash'); if (minigame.magic < minigame.magicM) LastMagicBarFull = false;
PlaySound(CMOptions.MagicSoundURL, 'MagicSound', 'MagicVolume'); else if (!LastMagicBarFull) {
Notification('MagicNotification', 'Magic Meter full', 'Your Magic Meter is full. Cast a spell!'); LastMagicBarFull = true;
} Flash(3, 'MagicFlash');
} PlaySound(CMOptions.MagicSoundURL, 'MagicSound', 'MagicVolume');
Notification(
'MagicNotification',
'Magic Meter full',
'Your Magic Meter is full. Cast a spell!',
);
}
}
} }

View File

@@ -11,16 +11,20 @@ import { LastSeasonPopupState } from '../VariablesAndData';
* It is called by CM.Main.Loop * It is called by CM.Main.Loop
*/ */
export default function CheckSeasonPopup() { export default function CheckSeasonPopup() {
if (LastSeasonPopupState !== Game.shimmerTypes.reindeer.spawned) { if (LastSeasonPopupState !== Game.shimmerTypes.reindeer.spawned) {
LastSeasonPopupState = Game.shimmerTypes.reindeer.spawned; LastSeasonPopupState = Game.shimmerTypes.reindeer.spawned;
for (const i of Object.keys(Game.shimmers)) { for (const i of Object.keys(Game.shimmers)) {
if (Game.shimmers[i].spawnLead && Game.shimmers[i].type === 'reindeer') { if (Game.shimmers[i].spawnLead && Game.shimmers[i].type === 'reindeer') {
CacheSeasonPopShimmer = Game.shimmers[i]; CacheSeasonPopShimmer = Game.shimmers[i];
break; break;
} }
} }
Flash(3, 'SeaFlash'); Flash(3, 'SeaFlash');
PlaySound(CMOptions.SeaSoundURL, 'SeaSound', 'SeaVolume'); PlaySound(CMOptions.SeaSoundURL, 'SeaSound', 'SeaVolume');
Notification('SeaNotification', 'Reindeer sighted!', 'A Reindeer has spawned. Click it now!'); Notification(
} 'SeaNotification',
'Reindeer sighted!',
'A Reindeer has spawned. Click it now!',
);
}
} }

View File

@@ -8,12 +8,20 @@ import { LastTickerFortuneState } from '../VariablesAndData';
* It is called by CM.Main.Loop * It is called by CM.Main.Loop
*/ */
export default function CheckTickerFortune() { export default function CheckTickerFortune() {
if (LastTickerFortuneState !== (Game.TickerEffect && Game.TickerEffect.type === 'fortune')) { if (
LastTickerFortuneState = (Game.TickerEffect && Game.TickerEffect.type === 'fortune'); LastTickerFortuneState !==
if (LastTickerFortuneState) { (Game.TickerEffect && Game.TickerEffect.type === 'fortune')
Flash(3, 'FortuneFlash'); ) {
PlaySound(CM.Options.FortuneSoundURL, 'FortuneSound', 'FortuneVolume'); LastTickerFortuneState =
Notification('FortuneNotification', 'Fortune Cookie found', 'A Fortune Cookie has appeared on the Ticker.'); Game.TickerEffect && Game.TickerEffect.type === 'fortune';
} if (LastTickerFortuneState) {
} Flash(3, 'FortuneFlash');
PlaySound(CM.Options.FortuneSoundURL, 'FortuneSound', 'FortuneVolume');
Notification(
'FortuneNotification',
'Fortune Cookie found',
'A Fortune Cookie has appeared on the Ticker.',
);
}
}
} }

View File

@@ -9,30 +9,55 @@ import { LastWrinklerCount } from '../VariablesAndData';
* It is called by CM.Main.Loop * It is called by CM.Main.Loop
*/ */
export default function CheckWrinklerCount() { export default function CheckWrinklerCount() {
if (Game.elderWrath > 0) { if (Game.elderWrath > 0) {
let CurrentWrinklers = 0; let CurrentWrinklers = 0;
for (const i in Game.wrinklers) { for (const i in Game.wrinklers) {
if (Game.wrinklers[i].phase === 2) CurrentWrinklers++; if (Game.wrinklers[i].phase === 2) CurrentWrinklers++;
} }
if (CurrentWrinklers > LastWrinklerCount) { if (CurrentWrinklers > LastWrinklerCount) {
LastWrinklerCount = CurrentWrinklers; LastWrinklerCount = CurrentWrinklers;
if (CurrentWrinklers === Game.getWrinklersMax() && CMOptions.WrinklerMaxFlash) { if (
Flash(3, 'WrinklerMaxFlash'); CurrentWrinklers === Game.getWrinklersMax() &&
} else { CMOptions.WrinklerMaxFlash
Flash(3, 'WrinklerFlash'); ) {
} Flash(3, 'WrinklerMaxFlash');
if (CurrentWrinklers === Game.getWrinklersMax() && CMOptions.WrinklerMaxSound) { } else {
PlaySound(CMOptions.WrinklerMaxSoundURL, 'WrinklerMaxSound', 'WrinklerMaxVolume'); Flash(3, 'WrinklerFlash');
} else { }
PlaySound(CMOptions.WrinklerSoundURL, 'WrinklerSound', 'WrinklerVolume'); if (
} CurrentWrinklers === Game.getWrinklersMax() &&
if (CurrentWrinklers === Game.getWrinklersMax() && CMOptions.WrinklerMaxNotification) { CMOptions.WrinklerMaxSound
Notification('WrinklerMaxNotification', 'Maximum Wrinklers Reached', 'You have reached your maximum ammount of wrinklers'); ) {
} else { PlaySound(
Notification('WrinklerNotification', 'A Wrinkler appeared', 'A new wrinkler has appeared'); CMOptions.WrinklerMaxSoundURL,
} 'WrinklerMaxSound',
} else { 'WrinklerMaxVolume',
LastWrinklerCount = CurrentWrinklers; );
} } else {
} PlaySound(
CMOptions.WrinklerSoundURL,
'WrinklerSound',
'WrinklerVolume',
);
}
if (
CurrentWrinklers === Game.getWrinklersMax() &&
CMOptions.WrinklerMaxNotification
) {
Notification(
'WrinklerMaxNotification',
'Maximum Wrinklers Reached',
'You have reached your maximum ammount of wrinklers',
);
} else {
Notification(
'WrinklerNotification',
'A Wrinkler appeared',
'A new wrinkler has appeared',
);
}
} else {
LastWrinklerCount = CurrentWrinklers;
}
}
} }

View File

@@ -24,39 +24,53 @@ import AddWrinklerAreaDetect from './WrinklerArea/AddDetectArea';
* Initialization loop of Cookie Monster * Initialization loop of Cookie Monster
*/ */
export default function InitializeCookieMonster() { export default function InitializeCookieMonster() {
InitData(); InitData();
CacheStatsCookies(); CacheStatsCookies();
InitCache(); InitCache();
// Stored to check if we need to re-initiliaze data // Stored to check if we need to re-initiliaze data
LastModCount = Object.keys(Game.mods).length; LastModCount = Object.keys(Game.mods).length;
// Creating visual elements // Creating visual elements
CreateCssArea(); CreateCssArea();
CreateBotBar(); CreateBotBar();
CreateTimerBar(); CreateTimerBar();
CreateUpgradeBar(); CreateUpgradeBar();
CreateWhiteScreen(); CreateWhiteScreen();
CreateFavicon(); CreateFavicon();
for (const i of Object.keys(TooltipText)) { for (const i of Object.keys(TooltipText)) {
CreateSimpleTooltip(TooltipText[i][0], TooltipText[i][1], TooltipText[i][2]); CreateSimpleTooltip(
} TooltipText[i][0],
CreateWrinklerButtons(); TooltipText[i][1],
UpdateBuildingUpgradeStyle(); TooltipText[i][2],
);
}
CreateWrinklerButtons();
UpdateBuildingUpgradeStyle();
ReplaceTooltips(); ReplaceTooltips();
AddWrinklerAreaDetect(); AddWrinklerAreaDetect();
// Replace native functions // Replace native functions
ReplaceNative(); ReplaceNative();
ReplaceNativeGrimoire(); ReplaceNativeGrimoire();
Game.CalculateGains(); Game.CalculateGains();
LoadConfig(); // Must be after all things are created! LoadConfig(); // Must be after all things are created!
CMLastAscendState = Game.OnAscend; CMLastAscendState = Game.OnAscend;
if (Game.prefs.popups) Game.Popup(`Cookie Monster version ${VersionMajor}.${VersionMinor} loaded!`); if (Game.prefs.popups)
else Game.Notify(`Cookie Monster version ${VersionMajor}.${VersionMinor} loaded!`, '', '', 1, 1); Game.Popup(
`Cookie Monster version ${VersionMajor}.${VersionMinor} loaded!`,
);
else
Game.Notify(
`Cookie Monster version ${VersionMajor}.${VersionMinor} loaded!`,
'',
'',
1,
1,
);
Game.Win('Third-party'); Game.Win('Third-party');
} }

View File

@@ -3,13 +3,20 @@ import LoopCache from '../Cache/CacheLoop';
import CacheNoGoldSwitchCPS from '../Cache/CPS/NoGoldSwitchCPS'; import CacheNoGoldSwitchCPS from '../Cache/CPS/NoGoldSwitchCPS';
import CacheSellAllForChoEgg from '../Cache/CPS/SellChoEgg'; import CacheSellAllForChoEgg from '../Cache/CPS/SellChoEgg';
import CacheDragonCost from '../Cache/Dragon/Dragon'; import CacheDragonCost from '../Cache/Dragon/Dragon';
import { CacheBuildingsPrices, CacheIncome } from '../Cache/PriceAndIncome/PriceAndIncome'; import {
CacheBuildingsPrices,
CacheIncome,
} from '../Cache/PriceAndIncome/PriceAndIncome';
import { CacheChain } from '../Cache/Stats/ChainCookies'; import { CacheChain } from '../Cache/Stats/ChainCookies';
import CacheAllMissingUpgrades from '../Cache/Stats/MissingUpgrades'; import CacheAllMissingUpgrades from '../Cache/Stats/MissingUpgrades';
import CacheSeasonSpec from '../Cache/Stats/Reindeer'; import CacheSeasonSpec from '../Cache/Stats/Reindeer';
import { CacheGoldenAndWrathCookiesMults, CacheStatsCookies } from '../Cache/Stats/Stats';
import { import {
CacheDoRemakeBuildPrices, CacheHadBuildAura, CacheGoldenAndWrathCookiesMults,
CacheStatsCookies,
} from '../Cache/Stats/Stats';
import {
CacheDoRemakeBuildPrices,
CacheHadBuildAura,
} from '../Cache/VariablesAndData'; } from '../Cache/VariablesAndData';
import UpdateAscendState from '../Disp/HelperFunctions/UpdateAscendState'; import UpdateAscendState from '../Disp/HelperFunctions/UpdateAscendState';
import { LastAscendState } from '../Disp/VariablesAndData'; import { LastAscendState } from '../Disp/VariablesAndData';
@@ -28,58 +35,58 @@ import { LastModCount } from './VariablesAndData';
* CM.init registers it to the "logic" hook provided by the modding api * CM.init registers it to the "logic" hook provided by the modding api
*/ */
export default function CMLoop() { export default function CMLoop() {
if (LastAscendState !== Game.OnAscend) { if (LastAscendState !== Game.OnAscend) {
LastAscendState = Game.OnAscend; LastAscendState = Game.OnAscend;
UpdateAscendState(); UpdateAscendState();
} }
if (!Game.OnAscend && Game.AscendTimer === 0) { if (!Game.OnAscend && Game.AscendTimer === 0) {
// Check if any other mods have been loaded // Check if any other mods have been loaded
if (LastModCount !== Object.keys(Game.mods).length) { if (LastModCount !== Object.keys(Game.mods).length) {
InitData(); InitData();
InitCache(); InitCache();
LastModCount = Object.keys(Game.mods).length; LastModCount = Object.keys(Game.mods).length;
} }
// CM.Sim.DoSims is set whenever CPS has changed // CM.Sim.DoSims is set whenever CPS has changed
if (SimDoSims) { if (SimDoSims) {
CacheIncome(); CacheIncome();
CacheNoGoldSwitchCPS(); // Needed first CacheNoGoldSwitchCPS(); // Needed first
CacheGoldenAndWrathCookiesMults(); CacheGoldenAndWrathCookiesMults();
CacheStatsCookies(); CacheStatsCookies();
CacheAllMissingUpgrades(); CacheAllMissingUpgrades();
CacheChain(); CacheChain();
CacheDragonCost(); CacheDragonCost();
CacheSeasonSpec(); CacheSeasonSpec();
CacheSellAllForChoEgg(); CacheSellAllForChoEgg();
SimDoSims = 0; SimDoSims = 0;
} }
// Check for aura change to recalculate buildings prices // Check for aura change to recalculate buildings prices
const hasBuildAura = Game.auraMult('Fierce Hoarder') > 0; const hasBuildAura = Game.auraMult('Fierce Hoarder') > 0;
if (!CacheHadBuildAura && hasBuildAura) { if (!CacheHadBuildAura && hasBuildAura) {
CacheHadBuildAura = true; CacheHadBuildAura = true;
CacheDoRemakeBuildPrices = 1; CacheDoRemakeBuildPrices = 1;
} else if (CacheHadBuildAura && !hasBuildAura) { } else if (CacheHadBuildAura && !hasBuildAura) {
CacheHadBuildAura = false; CacheHadBuildAura = false;
CacheDoRemakeBuildPrices = 1; CacheDoRemakeBuildPrices = 1;
} }
if (CacheDoRemakeBuildPrices) { if (CacheDoRemakeBuildPrices) {
CacheBuildingsPrices(); CacheBuildingsPrices();
CacheDoRemakeBuildPrices = 0; CacheDoRemakeBuildPrices = 0;
} }
LoopCache(); LoopCache();
// Check all changing minigames and game-states // Check all changing minigames and game-states
CheckGoldenCookie(); CheckGoldenCookie();
CheckTickerFortune(); CheckTickerFortune();
CheckSeasonPopup(); CheckSeasonPopup();
CheckGardenTick(); CheckGardenTick();
CheckMagicMeter(); CheckMagicMeter();
CheckWrinklerCount(); CheckWrinklerCount();
} }
} }

View File

@@ -4,7 +4,11 @@ import { FormatTime } from '../../Disp/BeautifyAndFormatting/BeautifyFormatting'
import CalculateGrimoireRefillTime from '../../Disp/HelperFunctions/CalculateGrimoireRefillTime'; import CalculateGrimoireRefillTime from '../../Disp/HelperFunctions/CalculateGrimoireRefillTime';
import { import {
BackupGrimoireDraw, BackupGrimoireLaunch, BackupGrimoireLaunchMod, HasReplaceNativeGrimoireDraw, HasReplaceNativeGrimoireLaunch, BackupGrimoireDraw,
BackupGrimoireLaunch,
BackupGrimoireLaunchMod,
HasReplaceNativeGrimoireDraw,
HasReplaceNativeGrimoireLaunch,
} from '../VariablesAndData'; } from '../VariablesAndData';
import ReplaceTooltipGrimoire from './TooltipGrimoire'; import ReplaceTooltipGrimoire from './TooltipGrimoire';
@@ -12,42 +16,59 @@ import ReplaceTooltipGrimoire from './TooltipGrimoire';
* This function fixes replaces the .draw function of the Grimoire * This function fixes replaces the .draw function of the Grimoire
*/ */
function ReplaceNativeGrimoireDraw() { function ReplaceNativeGrimoireDraw() {
if (!HasReplaceNativeGrimoireDraw && Game.Objects['Wizard tower'].minigameLoaded) { if (
const minigame = Game.Objects['Wizard tower'].minigame; !HasReplaceNativeGrimoireDraw &&
BackupGrimoireDraw = minigame.draw; Game.Objects['Wizard tower'].minigameLoaded
Game.Objects['Wizard tower'].minigame.draw = function () { ) {
BackupGrimoireDraw(); const minigame = Game.Objects['Wizard tower'].minigame;
if (CMOptions.GrimoireBar === 1 && minigame.magic < minigame.magicM) { BackupGrimoireDraw = minigame.draw;
minigame.magicBarTextL.innerHTML += ` (${FormatTime(CalculateGrimoireRefillTime(minigame.magic, minigame.magicM, minigame.magicM))})`; Game.Objects['Wizard tower'].minigame.draw = function () {
} BackupGrimoireDraw();
}; if (CMOptions.GrimoireBar === 1 && minigame.magic < minigame.magicM) {
HasReplaceNativeGrimoireDraw = true; minigame.magicBarTextL.innerHTML += ` (${FormatTime(
} CalculateGrimoireRefillTime(
minigame.magic,
minigame.magicM,
minigame.magicM,
),
)})`;
}
};
HasReplaceNativeGrimoireDraw = true;
}
} }
/** /**
* This function fixes replaces the .launch function of the Grimoire * This function fixes replaces the .launch function of the Grimoire
*/ */
function ReplaceNativeGrimoireLaunch() { function ReplaceNativeGrimoireLaunch() {
if (!HasReplaceNativeGrimoireLaunch && Game.Objects['Wizard tower'].minigameLoaded) { if (
const minigame = Game.Objects['Wizard tower'].minigame; !HasReplaceNativeGrimoireLaunch &&
BackupGrimoireLaunch = minigame.launch; Game.Objects['Wizard tower'].minigameLoaded
BackupGrimoireLaunchMod = new Function(`return ${minigame.launch.toString().split('=this').join('= Game.Objects[\'Wizard tower\'].minigame')}`); ) {
Game.Objects['Wizard tower'].minigame.launch = function () { const minigame = Game.Objects['Wizard tower'].minigame;
BackupGrimoireLaunchMod(); BackupGrimoireLaunch = minigame.launch;
ReplaceTooltipGrimoire(); BackupGrimoireLaunchMod = new Function(
HasReplaceNativeGrimoireDraw = false; `return ${minigame.launch
ReplaceNativeGrimoireDraw(); .toString()
.split('=this')
.join("= Game.Objects['Wizard tower'].minigame")}`,
);
Game.Objects['Wizard tower'].minigame.launch = function () {
BackupGrimoireLaunchMod();
ReplaceTooltipGrimoire();
HasReplaceNativeGrimoireDraw = false;
ReplaceNativeGrimoireDraw();
HasReplaceNativeGrimoireLaunch = true; HasReplaceNativeGrimoireLaunch = true;
}; };
} }
} }
/** /**
* This function fixes replaces the Launch and Draw functions of the Grimoire * This function fixes replaces the Launch and Draw functions of the Grimoire
*/ */
export default function ReplaceNativeGrimoire() { export default function ReplaceNativeGrimoire() {
ReplaceNativeGrimoireLaunch(); ReplaceNativeGrimoireLaunch();
ReplaceNativeGrimoireDraw(); ReplaceNativeGrimoireDraw();
} }

View File

@@ -5,16 +5,22 @@ import { TooltipGrimoireBackup } from '../VariablesAndData';
* This function replaces the original .onmouseover functions of the Grimoire minigame * This function replaces the original .onmouseover functions of the Grimoire minigame
*/ */
export default function ReplaceTooltipGrimoire() { export default function ReplaceTooltipGrimoire() {
if (Game.Objects['Wizard tower'].minigameLoaded) { if (Game.Objects['Wizard tower'].minigameLoaded) {
for (const i in Game.Objects['Wizard tower'].minigame.spellsById) { for (const i in Game.Objects['Wizard tower'].minigame.spellsById) {
if (l(`grimoireSpell${i}`).onmouseover !== null) { if (l(`grimoireSpell${i}`).onmouseover !== null) {
TooltipGrimoireBackup[i] = l(`grimoireSpell${i}`).onmouseover; TooltipGrimoireBackup[i] = l(`grimoireSpell${i}`).onmouseover;
l(`grimoireSpell${i}`).onmouseover = function () { l(`grimoireSpell${i}`).onmouseover = function () {
Game.tooltip.dynamic = 1; Game.tooltip.dynamic = 1;
Game.tooltip.draw(this, function () { return CreateTooltip('g', `${i}`); }, 'this'); Game.tooltip.draw(
Game.tooltip.wobble(); this,
}; function () {
} return CreateTooltip('g', `${i}`);
} },
} 'this',
);
Game.tooltip.wobble();
};
}
}
}
} }

Some files were not shown because too many files have changed in this diff Show More