Compare commits

...

156 Commits

Author SHA1 Message Date
Daniël van Noord
ca5d9bae11 Merge pull request #748 from Aktanusa/dev
Master to version 2.031.7
2021-04-04 20:44:39 +02:00
Daniël van Noord
cba8eb7632 Merge pull request #747 from DanielNoord/version20317
Update to version 2.031.7
2021-04-04 20:44:01 +02:00
Daniël van Noord
119faa5305 Update to version 2.031.7 2021-04-04 20:42:05 +02:00
Daniël van Noord
32c38fd9fa Merge pull request #746 from DanielNoord/fixflicker
Fixflicker
2021-04-04 20:37:08 +02:00
Daniël van Noord
fd2d22564c Merge branch 'dev' of https://github.com/Aktanusa/CookieMonster into fixflicker 2021-04-04 20:29:44 +02:00
Daniël van Noord
48e8fd2154 Fix black flicker at loading & timers change #621 2021-04-04 20:29:29 +02:00
Daniël van Noord
e7cf3b076d Merge pull request #745 from DanielNoord/cyclius
Cyclius and ESLint errors
2021-04-04 20:15:17 +02:00
Daniël van Noord
37bff7df1e Fixed #707 2021-04-04 20:13:44 +02:00
Daniël van Noord
9b04663cd8 Build CookieMonster.js 2021-04-04 17:06:45 +02:00
Daniël van Noord
e3321ebe2f Fixed high number of ESLint errors 2021-04-04 17:05:39 +02:00
Daniël van Noord
e2f99d1cf9 Removed eslintignore file 2021-04-04 15:14:29 +02:00
Daniël van Noord
3f08ed3e2d Additional fixes for #707 2021-04-04 14:04:56 +02:00
Daniël van Noord
444462ae53 Initial fix for #707 2021-04-04 13:52:34 +02:00
Daniël van Noord
5017f1c217 Merge pull request #744 from DanielNoord/missingachievements
Missingachievements
2021-04-04 13:36:35 +02:00
Daniël van Noord
d5aaba3546 Build CookieMonster.js 2021-04-04 13:25:02 +02:00
Daniël van Noord
d511f4f1f2 Show missing achievements toggle 2021-04-04 13:22:44 +02:00
Daniël van Noord
5a14712841 Renamed Draw hook 2021-04-03 16:25:24 +02:00
Daniël van Noord
383be573c9 Merge pull request #743 from DanielNoord/clickscps
Show cookies from clicks in stats
2021-04-03 16:13:56 +02:00
Daniël van Noord
66ede34b92 Fixed some typos 2021-04-03 16:11:42 +02:00
Daniël van Noord
e482a62fe8 Updated npm and dependencies 2021-04-03 16:11:34 +02:00
Daniël van Noord
e1c6f60726 Show cookies from clicking in stats #698 2021-04-03 16:00:00 +02:00
Daniël van Noord
bfc54bf9de Merge pull request #742 from DanielNoord/favouritesettingsfixes
Changes to favourite settings
2021-04-03 09:13:14 +02:00
Daniël van Noord
812a2aaa69 Reordered directory Disp/Settings 2021-04-03 09:09:14 +02:00
Daniël van Noord
08a1e5aa6b Fixed overlapping labels in settings 2021-04-03 09:06:07 +02:00
Daniël van Noord
566efbc68b Made favourite settings stars yellow 2021-04-03 08:50:35 +02:00
Daniël van Noord
66e74bb702 Merge pull request #741 from DanielNoord/favouritesettings
Created favourite settings functionality #727
2021-04-02 23:23:06 +02:00
Daniël van Noord
9a84b0abe5 Created favourite settings functionality #727 2021-04-02 23:20:19 +02:00
Daniël van Noord
ddc77b332d Merge pull request #740 from DanielNoord/bugfixes
Fixed bug in Dragon Aura cps change display #734
2021-04-02 20:11:32 +02:00
Daniël van Noord
2cff52f5c7 Fixed bug in Dragon Aura cps change display #734 2021-04-02 19:29:49 +02:00
Daniël van Noord
3a28263099 Merge pull request #738 from DanielNoord/bugfixes
Bugfixes
2021-04-02 15:12:37 +02:00
Daniël van Noord
822e8a8066 Fixed red and purple PP switched #735 2021-04-02 15:10:13 +02:00
Daniël van Noord
ba0ff40aba Fixed dragon tooltip #736 2021-04-02 15:08:02 +02:00
Daniël van Noord
5f64d2dd9f Fixed notation of negative numbers #736 2021-04-02 14:58:31 +02:00
Daniël van Noord
10eb88cde1 Fixed typo 2021-04-02 14:50:55 +02:00
Daniël van Noord
aebd62317b Merge pull request #733 from DanielNoord/bugfixes
Bugfixes
2021-03-28 15:09:51 +02:00
Daniël van Noord
305762e797 Fixed edit prompts in settings #732 2021-03-28 15:07:41 +02:00
Daniël van Noord
fb0f9c3bf3 Increase max length to 100 2021-03-28 14:53:20 +02:00
Daniël van Noord
f506cb136e Fixed incorrect mature for Garden tooltip #731 2021-03-28 14:11:58 +02:00
Daniël van Noord
adb020dfc2 Merge pull request #730 from DanielNoord/functions
Functions
2021-03-28 10:56:51 +02:00
Daniël van Noord
972d4723ed New colour settings, changeable flash colour #728 2021-03-28 10:55:10 +02:00
Daniël van Noord
fe8749e7b2 Wrinkler button disappear when not active 2021-03-26 16:26:57 +01:00
Daniël van Noord
48c3bad336 Fixed #726 2021-03-26 13:08:04 +01:00
Daniël van Noord
212a358a6a Merge pull request #725 from DanielNoord/reordersettings
Reordersettings
2021-03-23 09:38:45 +01:00
Daniël van Noord
02d49dca2e Changed order and reformatted settings #721 2021-03-23 09:35:48 +01:00
Daniël van Noord
f7c4e23eb3 Merge pull request #723 from Aktanusa/dev
Push to master
2021-03-23 08:42:17 +01:00
Daniël van Noord
202913179c Merge pull request #722 from DanielNoord/fix/hotfixes
Hotfixes
2021-03-23 08:41:44 +01:00
Daniël van Noord
c0a13231ad Fix formatting of Cookie Counter #714 2021-03-23 08:38:03 +01:00
Daniël van Noord
d1daa6d434 Merge pull request #718 from Aktanusa/dev
Push fixes to master
2021-03-22 08:28:28 +01:00
Daniël van Noord
9d9ef9b514 Merge pull request #717 from DanielNoord/fix/hotfixes
Fix/hotfixes
2021-03-22 08:28:03 +01:00
Daniël van Noord
be529d0b71 Update commands and removed comment 2021-03-22 08:21:28 +01:00
Daniël van Noord
68c8cc9d54 Fix break upon 0 wrinklers #715 2021-03-22 08:20:52 +01:00
Daniël van Noord
e882cb15f5 Merge pull request #712 from Aktanusa/dev
Push fixes to master
2021-03-21 14:57:02 +01:00
Daniël van Noord
ae7ea4fbd4 Merge pull request #711 from DanielNoord/fix/hotfixes
Fix/hotfixes
2021-03-21 14:56:35 +01:00
Daniël van Noord
1653c18c55 Fixed negative GC effect breaking mod #710 2021-03-21 14:13:35 +01:00
Daniël van Noord
2438da6e38 Merge pull request #705 from Aktanusa/dev
Push hot fixes to master
2021-03-19 17:51:59 +01:00
Daniël van Noord
79b960bde7 Merge pull request #704 from DanielNoord/fix/hotfixes
Fix/hotfixes
2021-03-19 17:51:31 +01:00
Daniël van Noord
11554722ed Update changelog to reflect hotfixes 2021-03-19 17:49:06 +01:00
Daniël van Noord
a4e2b9f68c Changed name of Rigidel option 2021-03-19 17:44:24 +01:00
Daniël van Noord
823d12fa70 Created RIgidel mode #694 2021-03-19 17:39:27 +01:00
Daniël van Noord
51c89bdc88 Fix upgr bar legend, wrink butt tooltip #700, #695 2021-03-19 17:38:45 +01:00
Daniël van Noord
9e107c7a3a Update README.md 2021-03-19 08:52:07 +01:00
Daniël van Noord
641471b5bc Merge pull request #692 from Aktanusa/dev
Push 2.031.6 to master
2021-03-18 09:30:30 +01:00
Daniël van Noord
b470d13316 Merge pull request #691 from DanielNoord/randomchance
Last functions for 2.031.6
2021-03-18 09:29:34 +01:00
Daniël van Noord
36534be654 Pushed version number and changelog to 2.031.6 2021-03-18 09:28:49 +01:00
Daniël van Noord
1c3a27bc9a Made description of decimal setting clearer #690 2021-03-18 09:17:08 +01:00
Daniël van Noord
8f5e40d3be Display chance for random drops in stats #25 2021-03-18 09:15:30 +01:00
Daniël van Noord
2c309c04c2 Update bug_report.md 2021-03-18 00:01:59 +01:00
Daniël van Noord
6b2425fa19 Updated CONTRIBUTING.md to reflect new structure 2021-03-18 00:00:23 +01:00
Daniël van Noord
104159e4ac Merge pull request #689 from DanielNoord/update
Update
2021-03-17 23:57:44 +01:00
Daniël van Noord
00edec127c Buttons to hide upgrade and building sections #47 2021-03-17 23:52:23 +01:00
Daniël van Noord
4d716e77e4 Toggle to display PP as time period #625 2021-03-17 23:19:34 +01:00
Daniël van Noord
1a0750e8d7 Regenerated package lock 2021-03-17 00:08:07 +01:00
Daniël van Noord
ff81b4ff02 Renamed commands 2021-03-17 00:05:57 +01:00
Daniël van Noord
f3b0bfa16d Merge pull request #688 from DanielNoord/ppvalues
Number of functions
2021-03-17 00:01:36 +01:00
Daniël van Noord
9c2350a8e3 Fixed elder pledge tooltip #613 2021-03-16 23:53:41 +01:00
Daniël van Noord
b66caab11e Set max length of lines 2021-03-16 23:53:28 +01:00
Daniël van Noord
5390c1af58 Updated max length of lines 2021-03-16 23:13:26 +01:00
Daniël van Noord
af508ceee5 Fix simple tooltips #687 2021-03-16 23:10:33 +01:00
Daniël van Noord
f6b2e70f9b Fixed formatting and flickering of bottom bar #686 2021-03-16 22:55:02 +01:00
Daniël van Noord
6caee4d8fb Changed PP colour coding #683 2021-03-16 22:28:54 +01:00
Daniël van Noord
e3d3f649c3 Moved files into Github folder 2021-03-16 13:34:23 +01:00
Daniël van Noord
f138745a0f Formatting changes 2021-03-16 13:31:30 +01:00
Daniël van Noord
0253e9b80d Merge pull request #685 from DanielNoord/soundtest
Test button for sounds and new Audio() code #630
2021-03-16 13:29:10 +01:00
Daniël van Noord
d35217b6d5 Test button for sounds and new Audio() code #630 2021-03-16 13:27:21 +01:00
Daniël van Noord
b201e15c8e Merge pull request #684 from DanielNoord/code/linting
Code/linting
2021-03-16 09:38:24 +01:00
Daniël van Noord
0a30d8e3e8 Removed unnecessary globals 2021-03-16 09:35:53 +01:00
Daniël van Noord
a65af049b6 Changes according to Eslint 2021-03-16 09:32:50 +01:00
Daniël van Noord
26d8e75935 Merge pull request #682 from DanielNoord/fixdev
Fix dev build
2021-03-15 23:48:27 +01:00
Daniël van Noord
87eac02185 Fix dev build 2021-03-15 23:47:48 +01:00
Daniël van Noord
8ff50fbbb9 Merge pull request #681 from DanielNoord/mastertodev
Mastertodev
2021-03-15 23:46:14 +01:00
Daniël van Noord
c3b1637d08 Merge branch 'dev' into mastertodev 2021-03-15 23:46:03 +01:00
Daniël van Noord
c72e01687f Merge pull request #680 from DanielNoord/fix/font
Fix #677
2021-03-15 23:42:40 +01:00
Daniël van Noord
022b3860eb Fix #677 2021-03-15 23:39:42 +01:00
Daniël van Noord
b09dcd6f47 Merge pull request #679 from DanielNoord/tooltip/pantheon
Added tooltips to Pantheon #597
2021-03-15 23:35:47 +01:00
Daniël van Noord
eee72bceb6 Added tooltips to Pantheon #597 2021-03-15 23:32:52 +01:00
Daniël van Noord
7b3a7816f1 Merge pull request #676 from DanielNoord/hotfix/plant
Hotfix/plant
2021-03-15 22:17:05 +01:00
Daniël van Noord
403eb59cfd Actually fix #675 2021-03-15 21:39:59 +01:00
Daniël van Noord
220b67b440 Fixed #675 2021-03-15 21:37:22 +01:00
Daniël van Noord
b6d9ca8dbb Merge pull request #674 from DanielNoord/fix/hotfix
Create tooltip for wrinkler buttons #628
2021-03-15 12:54:01 +01:00
Daniël van Noord
1c955e5da3 Merge pull request #672 from Aktanusa/master
Push hotfixes to dev
2021-03-15 12:51:49 +01:00
Daniël van Noord
9e9158ce81 Create tooltip for wrinkler buttons #628 2021-03-15 12:51:25 +01:00
Daniël van Noord
71479a05e7 Merge pull request #671 from DanielNoord/fix/hotfix
Apply hotfixes
2021-03-15 09:02:32 +01:00
Daniël van Noord
7ec13d80bd Fix #668 and #669 2021-03-15 09:00:12 +01:00
Daniël van Noord
fd2aa16c60 Fix display of cookies needed tk next HC 2021-03-15 08:57:48 +01:00
Daniël van Noord
7831521bc5 Fix #667 2021-03-15 08:47:59 +01:00
Daniël van Noord
6193fc8d3e Fix #647 2021-03-15 08:30:05 +01:00
Daniël van Noord
f85cde5fea Merge pull request #665 from DanielNoord/fix/hotfix
Hotfix
2021-03-14 19:37:48 +01:00
Daniël van Noord
2f34b26602 Fix #660 2021-03-14 19:35:58 +01:00
Daniël van Noord
189ccbce49 Merge pull request #664 from Aktanusa/master
Master into dev
2021-03-14 19:11:38 +01:00
Daniël van Noord
3e07541fd5 Added prettier to master (#662)
* Bump dev to 2.031.6

* Added prettier (#661)

* Added prettier

* Added prettier

* Added prettier
2021-03-14 19:08:36 +01:00
Daniël van Noord
932509a877 Added prettier (#661)
* Added prettier

* Added prettier

* Added prettier
2021-03-14 18:57:07 +01:00
Daniël van Noord
f3e7964262 Merge pull request #656 from DanielNoord/fix/hotfix
Push hot fixes to dev branch
2021-03-14 18:07:25 +01:00
Daniël van Noord
9b0429c141 Merge branch 'dev' into fix/hotfix 2021-03-14 18:06:17 +01:00
Daniël van Noord
5dda8cac55 Merge pull request #658 from DanielNoord/fix/hotfix
Fix #657
2021-03-14 17:24:36 +01:00
Daniël van Noord
d6675fe86d Fix #657 2021-03-14 17:23:55 +01:00
Daniël van Noord
80b8a0b834 Merge pull request #654 from DanielNoord/fix/hotfix
Fixed secondary issues in #648
2021-03-14 16:38:08 +01:00
Daniël van Noord
817c5b0e3c Fixed secondary issues in #648 2021-03-14 16:37:25 +01:00
Daniël van Noord
49b8414edf Merge pull request #652 from DanielNoord/fix/hotfix
Fix #651
2021-03-14 16:22:36 +01:00
Daniël van Noord
99ae657c45 Fix #651 2021-03-14 16:21:58 +01:00
Daniël van Noord
409a8e2911 Merge pull request #649 from DanielNoord/fix/hotfix
Hotfix 1
2021-03-14 16:12:30 +01:00
Daniël van Noord
08c2f99b21 Hotfix 1 2021-03-14 16:10:52 +01:00
Daniël van Noord
3247057394 Merge pull request #646 from DanielNoord/bumpdev
Set up dev for 2.031.6
2021-03-14 14:51:09 +01:00
Daniël van Noord
d1fe5c013c Bump dev to 2.031.6 2021-03-14 14:50:04 +01:00
Daniël van Noord
0cd5732e65 Merge pull request #644 from Aktanusa/dev
Hotfix
2021-03-14 14:46:04 +01:00
Daniël van Noord
2b3b9a6f34 Merge pull request #643 from DanielNoord/hotfix/fix
Hotfix for version 2.051.3
2021-03-14 14:45:35 +01:00
Daniël van Noord
458dd873b4 Hotfix for version 2.051.3 2021-03-14 14:45:05 +01:00
Daniël van Noord
5a3627b6d3 Merge pull request #642 from Aktanusa/dev
Version 2.031.5 to master
2021-03-14 14:38:48 +01:00
Daniël van Noord
8099a5794b Version 2.031.5 and change to action (#641)
* Remove sourcemap comment

* Bumped version and updated release notes

* Updated CI to remove sourcemap comment

* Fixed faulty command in action

* Fixed fault command (again)

* Fixed action

* Update action

* Action

* Try 123512

* Try 123541

* Action?

* Action

* Better Action

* Maybe?

* Maybe

* Please...
2021-03-14 14:38:11 +01:00
Daniël van Noord
a983ec23b0 Update README.md 2021-03-14 13:41:55 +01:00
Daniël van Noord
9a5e2d2e66 Merge pull request #640 from DanielNoord/fix/fixes
Fixed #638 and #636
2021-03-14 13:35:47 +01:00
Daniël van Noord
5f864d9055 Fixed #638 and #636 2021-03-14 13:18:56 +01:00
Daniël van Noord
1bffb58782 Complete overhaul of code structure and relevant files (#639) 2021-03-14 00:41:14 +01:00
Daniël van Noord
bb34bce9a5 Merge pull request #635 from DanielNoord/code/modules
Code/modules
2021-03-09 23:35:04 +01:00
Daniël van Noord
1604b4697e Updated action to reflect new structure 2021-03-09 23:33:20 +01:00
Daniël van Noord
d429719a57 Added comments 2021-03-09 23:31:02 +01:00
Daniël van Noord
3902589306 Change in structure and first use of webpack 2021-03-09 23:14:47 +01:00
Daniël van Noord
1d01caef98 Merge pull request #634 from DanielNoord/fix/bugs
Fix/bugs
2021-03-09 21:37:58 +01:00
Daniël van Noord
b388e2eb9c Fix garden tooltip when pressing shift #632 2021-03-09 21:34:18 +01:00
Daniël van Noord
e60d514ad6 Fix heavenly chips per second display #629 2021-03-09 21:21:22 +01:00
Daniël van Noord
2835438e8e Fixed selling with block buying #627 2021-03-09 21:02:19 +01:00
Daniël van Noord
771180776e Merge pull request #623 from DanielNoord/hotfixes
Hotfixes
2021-02-26 00:13:34 +01:00
Daniël van Noord
5cd266b91f Merge pull request #622 from DanielNoord/hotfixes
Hotfixes
2021-02-26 00:13:22 +01:00
Daniël van Noord
6ca414ed17 Fixed crash on selecting sell all #620 2021-02-25 22:50:06 +01:00
Daniël van Noord
61a30c704f Fix issues with warning not displaying #619 2021-02-25 22:33:35 +01:00
Daniël van Noord
75bf3f5c17 Fix pop fattest wrinkler #618 2021-02-25 22:20:55 +01:00
Daniël van Noord
db22e07d8e Fixed #617 2021-02-25 22:17:21 +01:00
Daniël van Noord
0bd8cc898e Merge pull request #616 from DanielNoord/hotfixes
Hotfixes to dev branch
2021-02-24 18:24:51 +01:00
Daniël van Noord
c96a2f4f89 Merge branch 'dev' into hotfixes 2021-02-24 18:24:31 +01:00
Daniël van Noord
31088ca686 Merge pull request #614 from DanielNoord/hotfixes
Hotfixes
2021-02-24 18:21:20 +01:00
Daniël van Noord
c95711d8b9 Fixed two issues with warning #612, #610 2021-02-24 18:15:25 +01:00
Daniël van Noord
3ce7822854 Fixed Upgrades not sorting on PP #609 2021-02-24 17:58:44 +01:00
Daniël van Noord
57fb8430a0 Fixed Disp.Beautify and tooltips of upgrades #608 2021-02-24 17:56:02 +01:00
Daniël van Noord
3975032f4b Added build-test command 2021-02-24 17:55:34 +01:00
Daniël van Noord
2ccb4ad550 Merge pull request #607 from DanielNoord/pushdev
Push version of dev branch
2021-02-24 00:37:46 +01:00
Daniël van Noord
2cf5ba6820 Pushed dev branch to 2.031.5 2021-02-24 00:33:08 +01:00
Daniël van Noord
a985c3ba89 Removed push stage from actions 2021-02-24 00:32:38 +01:00
180 changed files with 16776 additions and 13364 deletions

View File

@@ -1,2 +0,0 @@
CookieMonster.js
CookieMonster.user.js

View File

@@ -4,47 +4,31 @@ module.exports = {
es2021: true, es2021: true,
}, },
globals: { globals: {
module: 'readonly',
Game: 'writable', Game: 'writable',
l: 'readonly', l: 'readonly',
b64_to_utf8: 'readonly', b64_to_utf8: 'readonly',
utf8_to_b64: 'readonly', utf8_to_b64: 'readonly',
Beautify: 'writable',
realAudio: 'readonly',
JSColor: 'readonly',
jscolor: 'readonly',
BeautifyAll: 'readonly', BeautifyAll: 'readonly',
CM: 'writable', PlaySound: 'readonly',
unsafeWindow: 'readonly',
}, },
extends: 'airbnb-base', extends: ['airbnb-base', 'plugin:prettier/recommended'],
parserOptions: { parserOptions: {
ecmaVersion: 12, ecmaVersion: 12,
}, },
ignorePatterns: ['*CookieMonster*.js', 'dist/*', 'node_modules/*'],
rules: { rules: {
indent: ['error', 'tab'], 'import/no-mutable-exports': 'off',
'no-tabs': 'off', 'no-plusplus': ['error', { allowForLoopAfterthoughts: true }],
'max-len': 'off',
'no-param-reassign': 'off',
'no-plusplus': 'off',
'no-new-func': 'off',
'no-eval': 'off',
'no-restricted-properties': 'off',
'no-restricted-syntax': 'off',
'no-mixed-operators': 'off',
'prefer-destructuring': 'off',
'func-names': 'off', 'func-names': 'off',
'no-use-before-define': 'off', 'prefer-destructuring': ['error', { object: true, array: false }],
'no-console': 'off', 'max-len': [
'no-nested-ternary': 'off', 1,
'object-shorthand': 'off', {
'no-else-return': 'off', code: 100,
'prefer-arrow-callback': 'off', ignoreComments: true,
'no-new': 'off', ignoreStrings: true,
'no-alert': 'off', ignoreTemplateLiterals: true,
'new-cap': 'off', },
'no-restricted-globals': 'off', ],
'no-template-curly-in-string': 'off',
radix: 'off',
}, },
}; };

18
.github/CONTRIBUTING.md vendored Normal file
View File

@@ -0,0 +1,18 @@
Cookie Monster is written to modify Cookie Clicker as little as possible. This means the data is copied to simulate instead of actually modifying the current values and reverting later. The benefit is that CM should never mess up any data. The downside is that there is an extra overhead to copy and store the copied data.
The following is a short description of the various `src` directories and their contents:
JS | Description
-- | -
Cache | Functions related to creating and storing data cache
Config | Functions related to manipulating CM configuration
Data | Hard coded values
Disp | Functions related to displaying CM's UI
InitSaveLoad | Functions related to registering the CM object with the Game's Modding API
Main | Functions related to the main loop and initializing CM
Sim | Functions related to simulate something
These are some additional guidelines:
- Try to use DOM as much as possible instead of using string manipulation to modify HTML.
- Please be descriptive of your commits. If the commit is related to an issue or PR, please add the issue/PR number to the commit message.
- PR's should target the `dev` branch

View File

@@ -19,5 +19,6 @@ If applicable, add screenshots to help explain your problem.
**Save file** **Save file**
``` ```
If applicable please copy your save file here Please add a save file here.
This makes debugging much easier as we do not always have a good test save to debug the issue
``` ```

View File

View File

@@ -1,5 +1,5 @@
name: CI name: CI
on: [push, pull_request] on: pull_request
jobs: jobs:
Check_ESLint: Check_ESLint:
runs-on: ubuntu-latest runs-on: ubuntu-latest
@@ -16,10 +16,16 @@ jobs:
- name: Check if CookieMonster.js is built correctly - name: Check if CookieMonster.js is built correctly
run: | run: |
npm install npm install
npx terser ./src/Header.js ./src/Cache.js ./src/Config.js ./src/Data.js ./src/Disp.js ./src/Main.js ./src/Sim.js ./src/Footer.js -o CookieMonsterTest.js npx webpack -o ./test --env production
if cmp CookieMonster.js CookieMonsterTest.js; then if cmp <(head -n 2 dist/CookieMonster.js) <(head -n 2 test/CookieMonster.js); then
echo '### SUCCESS: CookieMonster is correctly built! ###' echo '### SUCCESS: CookieMonster is correctly built! ###'
else else
echo '### WARNING: CookieMonster.js does not seem to be correct. Make sure to run "npm run build" after saving all your changes! ###' echo '### WARNING: CookieMonster.js does not seem to be correct. Make sure to run "npm run build" after saving all your changes! ###'
exit 1 exit 1
fi fi
if cmp <(head -n 2 CookieMonster.js) <(head -n 2 test/CookieMonster.js); then
echo '### SUCCESS: CookieMonster is correctly built! ###'
else
echo '### WARNING: Make sure to move the file from the /dist folder to the main folder. Otherwise Github Pages won't notice it ###'
exit 1
fi

4
.prettierrc.json Normal file
View File

@@ -0,0 +1,4 @@
{
"singleQuote": true,
"trailingComma": "all"
}

View File

@@ -1,22 +0,0 @@
The following is a description of the our approach to the project.
Cookie Monster is written to modify Cookie Clicker as little as possible. This means the data is copied to simulate instead of actually modifying the current values and reverting later. The benefit is that CM should never mess up any data. The downside is that there is an extra overhead to copy and store the copied data.
Here is a description of what should be stored in each of the source JS. Make edits to the source file first and then use the combine file to compile the final file:
JS | Description
-- | -
Cache | Functions related to creating and storing data cache
Config | Functions related to manipulating CM configuration
Data | Hard coded values
Disp | Functions related to displaying CM's UI
Footer | The footer of CM's JS (not modified often or ever)
Header | The header of CM's JS (not modified often or ever)
Main | Functions related to the main loop and initializing CM
Sim | Functions related to simulate something
These are some additional guidelines:
- Try to use DOM as much as possible instead of using string manipulation to modify HTML.
- Please be descriptive of your commits. If the commit is related to an issue or PR, please add the issue/PR number to the commit message.
- Try to follow the formatting and annotation as specified by JSCode
- PR's should target the `dev` branch

File diff suppressed because one or more lines are too long

View File

@@ -2,11 +2,10 @@
## Cookie Monster ## Cookie Monster
**Cookie Monster** is an addon you can load into Cookie Clicker, that offers a wide range of tools and statistics to enhance the game. **It is not a cheat interface** although it does offer helpers for golden cookies and such, everything can be toggled off at will to only leave how much information you want. **Cookie Monster** is an addon you can load into Cookie Clicker, that offers a wide range of tools and statistics to enhance the game. **It is not a cheat interface** although it does offer helpers for golden cookies and such, everything can be toggled off at will to only leave how much information you want.
The mod helps you to *whichever* degree you want, if you only need some help shortening long numbers, it does that. If you need to be accompanied by hand to pick the best buildings to buy, it does that, but **everything is an option**.
This is a helper, and it is here to help you at *whichever* degree you want, if you only need some help shortening long numbers, it does that. If you need to be accompanied by hand to pick the best buildings to buy, it does that, but **everything is an option**.
### Current version ### Current version
You can see the current version, and a full history of all versions and what they changed by consulting the [releases page](https://github.com/Aktanusa/CookieMonster/releases). The `gh-pages` branch hosts the latest version intended for general users. All development and pull requests should target the `dev` branch.
### What it does ### What it does
@@ -17,24 +16,19 @@ max(cost - cookies in bank, 0)/cps + cost/Δ cps
Cookie Monster also indicates the time left before being able to buy an upgrade or building, and takes it into consideration. It will take *everything* in consideration, meaning if buying a building also unlocks an achievement which boosts your income, which unlocks an achievement, it will know and highlight that building's value. Cookie Monster also indicates the time left before being able to buy an upgrade or building, and takes it into consideration. It will take *everything* in consideration, meaning if buying a building also unlocks an achievement which boosts your income, which unlocks an achievement, it will know and highlight that building's value.
This index is computed for buildings and upgrades. If the relevant option is enabled, it will color-code each of them based on their value: This index is computed for buildings and upgrades. If the relevant option is enabled, it will color-code each of them based on their value. It compares the PP across all possible buy options: if a buy 10 option is better than any of the buy 1 options Cookie Monster will colour them accordingly.
Cookie Monster uses the following standard colours:
* Light Blue: (upgrades) This item has a better PP than any building * Light Blue: (upgrades) This item has a better PP than the best building to buy
* Green: This item has the best PP * Green: This building has the best PP
* Yellow: This item is not the best, but it is closer to best than it is to worst * Yellow: This building is within the top 10 of best PP's
* Orange: This item is not the worst, but it is closer to worst than it is to best * Orange: This building is within the top 20 of best PP's
* Red: This item has the worst PP * Red: This building is within the top 30 of best PP's
* Purple: (upgrades) This item has a worse PP than any building * Purple: This building is worse than the top 10 of best PP's
* Gray: (upgrades) This item has not been calculated and/or cannot be calculated due to no definitive worth. * Gray: This item does not have a PP, often this means that there is no change to CPS
Note: For this index, **lower is better**, meaning a building with a PP of 1 is more interesting than one with a PP of 3. Note: For this index, **lower is better**, meaning a building with a PP of 1 is more interesting than one with a PP of 3.
### What it doesn't do
Some upgrades do not give a direct bonus to your income and will display as gray. These are mainly Golden Cookie upgrades and season upgrades.
Do note though that, although these upgrades have no direct value, if buying them earns you an achievement of some sort which in return gives you milk and income, Cookie Monster **will** display that value.
## Using ## Using
### Bookmarklet ### Bookmarklet
@@ -53,13 +47,13 @@ If (for some reason) the above doesn't work, trying pasting everything after the
If you'd rather use the addon as a [userscript](https://en.wikipedia.org/wiki/Userscript) to automatically load _Cookie Monster_ every time the original game loads, install the `CookieMonster.user.js` file. You can do this by clicking on the file in the file-list and clicking "raw". If you'd rather use the addon as a [userscript](https://en.wikipedia.org/wiki/Userscript) to automatically load _Cookie Monster_ every time the original game loads, install the `CookieMonster.user.js` file. You can do this by clicking on the file in the file-list and clicking "raw".
**Note that to avoid conflicts Cookie Monster should ideally be loaded after any other content mods have been loaded**
## Bugs and suggestions ## Bugs and suggestions
Any bug or suggestion should be **opened as an issue** [in the repository](https://github.com/Aktanusa/CookieMonster/issues) for easier tracking. This allows us to close issues once they're fixed. Any bug or suggestion should be **opened as an issue** [in the repository](https://github.com/Aktanusa/CookieMonster/issues) for easier tracking. This allows us to close issues once they're fixed.
Before submitting a bug, make sure to give a shot at the latest version of the addon on the <code>dev</code> branch. This version can be tested by copying the `CookieMonster.js` file of the dev branch into your console. Before submitting a bug, make sure to give a shot at the latest version of the addon on the `dev` branch. This version can be tested by copying the `CookieMonster.js` file of the dev branch into your console. If the bug is still here, you can submit an issue for it. Please do so by using the bug report template.
If the bug is still here, you can submit an issue for it. Please do so by using the bug report template.
All suggestions are welcome, even the smallest ones. All suggestions are welcome, even the smallest ones.

2
dist/CookieMonster.js vendored Normal file

File diff suppressed because one or more lines are too long

10
dist/CookieMonster.js.LICENSE.txt vendored Normal file
View File

@@ -0,0 +1,10 @@
/**
* jscolor - JavaScript Color Picker
*
* @link http://jscolor.com
* @license For open source use: GPLv3
* For commercial use: JSColor Commercial License
* @author Jan Odvarko - East Desire
*
* See usage examples at http://jscolor.com/examples/
*/

1
dist/CookieMonster.js.map vendored Normal file

File diff suppressed because one or more lines are too long

Binary file not shown.

Before

Width:  |  Height:  |  Size: 66 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 83 B

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.6 KiB

Binary file not shown.

Before

Width:  |  Height:  |  Size: 2.8 KiB

File diff suppressed because it is too large Load Diff

3058
package-lock.json generated

File diff suppressed because it is too large Load Diff

View File

@@ -1,6 +1,6 @@
{ {
"name": "cookiemonster-mod", "name": "cookiemonster-mod",
"version": "2.031.4", "version": "2.031.7",
"description": "Cookie Monster is an add-on that you can load into Cookie Clicker which offers a wide range of tools and statistics to enhance the game. It is not a cheat interface although it does offer helpers for golden cookies and such, everything can be toggled off at will to only leave how much information you want. This is a helper and everything is an option.", "description": "Cookie Monster is an add-on that you can load into Cookie Clicker which offers a wide range of tools and statistics to enhance the game. It is not a cheat interface although it does offer helpers for golden cookies and such, everything can be toggled off at will to only leave how much information you want. This is a helper and everything is an option.",
"main": "CookieMonster.js", "main": "CookieMonster.js",
"keywords": [ "keywords": [
@@ -11,7 +11,13 @@
"Orteil" "Orteil"
], ],
"scripts": { "scripts": {
"build": "npx eslint src && terser ./src/Header.js ./src/Cache.js ./src/Config.js ./src/Data.js ./src/Disp.js ./src/Main.js ./src/Sim.js ./src/Footer.js -o CookieMonster.js" "copy-file": "cp dist/CookieMonster.js CookieMonster.js",
"eslint-src": "eslint src",
"build": "run-s eslint-src pack-prod remove-comment copy-file",
"build-test": "run-s pack-dev",
"pack-prod": "webpack --env production",
"pack-dev": "webpack",
"remove-comment": "sed -i '' -e '/\\/\\/# sourceMappingURL.*/d' dist/CookieMonster.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",
@@ -40,8 +46,13 @@
"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",
"terser": "^5.6.0-beta" "eslint-plugin-prettier": "^3.3.1",
"npm-run-all": "^4.1.5",
"prettier": "2.2.1",
"webpack": "^5.24.4",
"webpack-cli": "^4.5.0"
}, },
"ccrepo": { "ccrepo": {
"icon": [ "icon": [
@@ -49,5 +60,8 @@
0 0
], ],
"name": "Cookie Monster" "name": "Cookie Monster"
},
"dependencies": {
"@eastdesire/jscolor": "^2.4.5"
} }
} }

View File

@@ -1,796 +0,0 @@
/**
* Cache *
*/
/**
* Section: General Cache related functions */
/**
* This functions runs all cache-functions to generate all "full" cache
* The declaration follows the structure of the CM.Cache.js file
* It is called by CM.Main.DelayInit
*/
CM.Cache.InitCache = function () {
CM.Cache.CacheDragonAuras();
CM.Cache.CacheWrinklers();
CM.Cache.CacheStats();
CM.Cache.CacheGoldenAndWrathCookiesMults();
CM.Cache.CacheChain();
CM.Cache.CacheMissingUpgrades();
CM.Cache.CacheSeaSpec();
CM.Cache.InitCookiesDiff();
CM.Cache.HeavenlyChipsDiff = new CMAvgQueue(5); // Used by CM.Cache.CacheHeavenlyChipsPS()
CM.Cache.CacheHeavenlyChipsPS();
CM.Cache.CacheAvgCPS();
CM.Cache.CacheIncome();
CM.Cache.CacheBuildingsPrices();
CM.Cache.CachePP();
};
/**
* This functions caches variables that are needed every loop
* It is called by CM.Main.Loop()
* @global {string} CM.Cache.TimeTillNextPrestige Time requried till next prestige level
*/
CM.Cache.LoopCache = function () {
// Update Wrinkler Bank
CM.Cache.CacheWrinklers();
CM.Cache.CachePP();
CM.Cache.CacheCurrWrinklerCPS();
CM.Cache.CacheAvgCPS();
CM.Cache.CacheHeavenlyChipsPS();
const cookiesToNext = Game.HowManyCookiesReset(Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)) + 1) - (Game.cookiesEarned + Game.cookiesReset);
CM.Cache.TimeTillNextPrestige = CM.Disp.FormatTime(cookiesToNext / CM.Disp.GetCPS());
};
/**
* Section: Helper functions */
/**
* @class
* @classdesc This is a class used to store values used to calculate average over time (mostly cps)
* @var {number} maxLength The maximum length of the value-storage
* @var {[]} queue The values stored
* @method addLatest(newValue) Appends newValue to the value storage
* @method calcAverage(timePeriod) Returns the average over the specified timeperiod
*/
class CMAvgQueue {
constructor(maxLength) {
this.maxLength = maxLength;
this.queue = [];
}
addLatest(newValue) {
if (this.queue.push(newValue) > this.maxLength) {
this.queue.shift();
}
}
/**
* This functions returns the average of the values in the queue
* @param {number} timePeriod The period in seconds to computer average over
* @returns {number} ret The average
*/
calcAverage(timePeriod) {
if (timePeriod > this.maxLength) timePeriod = this.maxLength;
if (timePeriod > this.queue.length) timePeriod = this.queue.length;
let ret = 0;
for (let i = this.queue.length - 1; i >= 0 && i > this.queue.length - 1 - timePeriod; i--) {
ret += this.queue[i];
}
return ret / timePeriod;
}
}
/**
* Section: Functions related to Dragon Auras */
/**
* This functions caches the currently selected Dragon Auras
* It is called by CM.Sim.CopyData() and CM.Cache.InitCache()
* Uncapitalized dragon follows Game-naming
* @global {number} CM.Cache.dragonAura The number of the first (right) Aura
* @global {number} CM.Cache.dragonAura2 The number of the second (left) Aura
*/
CM.Cache.CacheDragonAuras = function () {
CM.Cache.dragonAura = Game.dragonAura;
CM.Cache.dragonAura2 = Game.dragonAura2;
};
/**
* Section: Functions related to Wrinklers */
/**
* This functions caches data related to Wrinklers
* It is called by CM.Cache.LoopCache() and CM.Cache.InitCache()
* @global {number} CM.Cache.WrinklersTotal The cookies of all wrinklers
* @global {number} CM.Cache.WrinklersNormal The cookies of all normal wrinklers
* @global {[{number}, {number}]} CM.Cache.WrinklersFattest A list containing the cookies and the id of the fattest non-shiny wrinkler
*/
CM.Cache.CacheWrinklers = function () {
CM.Cache.WrinklersTotal = 0;
CM.Cache.WrinklersNormal = 0;
CM.Cache.WrinklersFattest = [0, null];
for (let i = 0; i < Game.wrinklers.length; i++) {
let sucked = Game.wrinklers[i].sucked;
let toSuck = 1.1;
if (Game.Has('Sacrilegious corruption')) toSuck *= 1.05;
if (Game.wrinklers[i].type === 1) toSuck *= 3; // Shiny wrinklers
sucked *= toSuck;
if (Game.Has('Wrinklerspawn')) sucked *= 1.05;
if (CM.Sim.Objects.Temple.minigameLoaded) {
const godLvl = Game.hasGod('scorn');
if (godLvl === 1) sucked *= 1.15;
else if (godLvl === 2) sucked *= 1.1;
else if (godLvl === 3) sucked *= 1.05;
}
CM.Cache.WrinklersTotal += sucked;
if (Game.wrinklers[i].type === 0) {
CM.Cache.WrinklersNormal += sucked;
if (sucked > CM.Cache.WrinklersFattest[0]) CM.Cache.WrinklersFattest = [sucked, i];
}
}
};
/**
* Section: Functions related to Caching stats */
/**
* This functions caches variables related to the stats page
* It is called by CM.Main.Loop() upon changes to cps and CM.Cache.InitCache()
* @global {number} CM.Cache.Lucky Cookies required for max Lucky
* @global {number} CM.Cache.LuckyReward Reward for max normal Lucky
* @global {number} CM.Cache.LuckyWrathReward Reward for max normal Lucky from Wrath cookie
* @global {number} CM.Cache.LuckyFrenzy Cookies required for max Lucky Frenzy
* @global {number} CM.Cache.LuckyRewardFrenzy Reward for max Lucky Frenzy
* @global {number} CM.Cache.LuckyWrathRewardFrenzy Reward for max Lucky Frenzy from Wrath cookie
* @global {number} CM.Cache.Conjure Cookies required for max Conjure Baked Goods
* @global {number} CM.Cache.ConjureReward Reward for max Conjure Baked Goods
* @global {number} CM.Cache.Edifice Cookies required for most expensive building through Spontaneous Edifice
* @global {string} CM.Cache.EdificeBuilding Name of most expensive building possible with Spontaneous Edifice
*/
CM.Cache.CacheStats = function () {
CM.Cache.Lucky = (CM.Cache.NoGoldSwitchCookiesPS * 900) / 0.15;
CM.Cache.Lucky *= CM.Cache.DragonsFortuneMultAdjustment;
const cpsBuffMult = CM.Cache.getCPSBuffMult();
if (cpsBuffMult > 0) CM.Cache.Lucky /= cpsBuffMult;
else CM.Cache.Lucky = 0;
CM.Cache.LuckyReward = CM.Cache.GoldenCookiesMult * (CM.Cache.Lucky * 0.15) + 13;
CM.Cache.LuckyWrathReward = CM.Cache.WrathCookiesMult * (CM.Cache.Lucky * 0.15) + 13;
CM.Cache.LuckyFrenzy = CM.Cache.Lucky * 7;
CM.Cache.LuckyRewardFrenzy = CM.Cache.GoldenCookiesMult * (CM.Cache.LuckyFrenzy * 0.15) + 13;
CM.Cache.LuckyWrathRewardFrenzy = CM.Cache.WrathCookiesMult * (CM.Cache.LuckyFrenzy * 0.15) + 13;
CM.Cache.Conjure = CM.Cache.Lucky * 2;
CM.Cache.ConjureReward = CM.Cache.Conjure * 0.15;
CM.Cache.Edifice = 0;
let max = 0;
let n = 0;
for (const i of Object.keys(Game.Objects)) {
if (Game.Objects[i].amount > max) max = Game.Objects[i].amount;
if (Game.Objects[i].amount > 0) n++;
}
for (const i of Object.keys(Game.Objects)) {
if ((Game.Objects[i].amount < max || n === 1)
&& Game.Objects[i].amount < 400
&& Game.Objects[i].price * 2 > CM.Cache.Edifice) {
CM.Cache.Edifice = Game.Objects[i].price * 2;
CM.Cache.EdificeBuilding = i;
}
}
};
/**
* This functions calculates the multipliers of Golden and Wrath cookie rewards
* It is mostly used by CM.Cache.MaxChainCookieReward() and CM.Cache.CacheChain()
* It is called by CM.Disp.CreateStatsChainSection() and CM.Cache.CacheChain()
* @param {number} CM.Cache.GoldenCookiesMult Multiplier for golden cookies
* @param {number} CM.Cache.WrathCookiesMult Multiplier for wrath cookies
* @param {number} CM.Cache.DragonsFortuneMultAdjustment Multiplier for dragon fortune + active golden cookie
*/
CM.Cache.CacheGoldenAndWrathCookiesMults = function () {
if (CM.Footer.isInitzializing) {
CM.Cache.GoldenCookiesMult = 1;
CM.Cache.WrathCookiesMult = 1;
CM.Cache.DragonsFortuneMultAdjustment = 1;
} else {
let goldenMult = 1;
let wrathMult = 1;
let mult = 1;
// Factor auras and upgrade in mults
if (CM.Sim.Has('Green yeast digestives')) mult *= 1.01;
if (CM.Sim.Has('Dragon fang')) mult *= 1.03;
goldenMult *= 1 + Game.auraMult('Ancestral Metamorphosis') * 0.1;
goldenMult *= Game.eff('goldenCookieGain');
wrathMult *= 1 + Game.auraMult('Unholy Dominion') * 0.1;
wrathMult *= Game.eff('wrathCookieGain');
// Calculate final golden and wrath multipliers
CM.Cache.GoldenCookiesMult = mult * goldenMult;
CM.Cache.WrathCookiesMult = mult * wrathMult;
// Calculate Dragon's Fortune multiplier adjustment:
// 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.
// Otherwise, the aura effect will be factored in the base CPS making the multiplier not requiring adjustment.
CM.Cache.DragonsFortuneMultAdjustment = 1;
if (Game.shimmerTypes.golden.n === 0) {
CM.Cache.DragonsFortuneMultAdjustment *= 1 + Game.auraMult('Dragon\'s Fortune') * 1.23;
}
}
};
/**
* This functions calculates the max possible payout given a set of variables
* It is called by CM.Disp.CreateStatsChainSection() and CM.Cache.CacheChain()
* @param {number} digit Number of Golden Cookies in chain
* @param {number} maxPayout Maximum payout
* @param {number} mult Multiplier
* @returns [{number, number, number}] Total cookies earned, cookie needed for this and next level
*/
CM.Cache.MaxChainCookieReward = function (digit, maxPayout, mult) {
let totalFromChain = 0;
let moni = 0;
let nextMoni = 0;
let nextRequired = 0;
let chain = 1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10);
while (nextMoni < maxPayout) {
moni = Math.max(digit, Math.min(Math.floor(1 / 9 * 10 ** chain * digit * mult), maxPayout * mult));
nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * 10 ** (chain + 1) * digit * mult), maxPayout * mult));
nextRequired = Math.floor(1 / 9 * 10 ** (chain + 1) * digit * mult);
totalFromChain += moni;
chain++;
}
return [totalFromChain, moni, nextRequired];
};
/**
* This functions caches data related to Chain Cookies reward from Golden Cookioes
* It is called by CM.Main.Loop() upon changes to cps and CM.Cache.InitCache()
* @global [{number, number}] CM.Cache.ChainMaxReward Total cookies earned, and cookies needed for next level for normal chain
* @global {number} CM.Cache.ChainRequired Cookies needed for maximum reward for normal chain
* @global {number} CM.Cache.ChainRequiredNext Total cookies needed for next level for normal chain
* @global [{number, number}] CM.Cache.ChainMaxWrathReward Total cookies earned, and cookies needed for next level for wrath chain
* @global {number} CM.Cache.ChainWrathRequired Cookies needed for maximum reward for wrath chain
* @global {number} CM.Cache.ChainWrathRequiredNext Total cookies needed for next level for wrath chain
* @global [{number, number}] CM.Cache.ChainFrenzyMaxReward Total cookies earned, and cookies needed for next level for normal frenzy chain
* @global {number} CM.Cache.ChainFrenzyRequired Cookies needed for maximum reward for normal frenzy chain
* @global {number} CM.Cache.ChainFrenzyRequiredNext Total cookies needed for next level for normal frenzy chain
* @global [{number, number}] CM.Cache.ChainFrenzyWrathMaxReward Total cookies earned, and cookies needed for next level for wrath frenzy chain
* @global {number} CM.Cache.ChainFrenzyWrathRequired Cookies needed for maximum reward for wrath frenzy chain
* @global {number} CM.Cache.ChainFrenzyWrathRequiredNext Total cookies needed for next level for wrath frenzy chain
*/
CM.Cache.CacheChain = function () {
let maxPayout = CM.Cache.NoGoldSwitchCookiesPS * 60 * 60 * 6 * CM.Cache.DragonsFortuneMultAdjustment;
// Removes effect of Frenzy etc.
const cpsBuffMult = CM.Cache.getCPSBuffMult();
if (cpsBuffMult > 0) maxPayout /= cpsBuffMult;
else maxPayout = 0;
CM.Cache.ChainMaxReward = CM.Cache.MaxChainCookieReward(7, maxPayout, CM.Cache.GoldenCookiesMult);
CM.Cache.ChainRequired = CM.Cache.ChainMaxReward[1] * 2 / CM.Cache.GoldenCookiesMult;
CM.Cache.ChainRequiredNext = CM.Cache.ChainMaxReward[2] / 60 / 60 / 6 / CM.Cache.DragonsFortuneMultAdjustment;
CM.Cache.ChainMaxWrathReward = CM.Cache.MaxChainCookieReward(6, maxPayout, CM.Cache.WrathCookiesMult);
CM.Cache.ChainWrathRequired = CM.Cache.ChainMaxWrathReward[1] * 2 / CM.Cache.WrathCookiesMult;
CM.Cache.ChainWrathRequiredNext = CM.Cache.ChainMaxWrathReward[2] / 60 / 60 / 6 / CM.Cache.DragonsFortuneMultAdjustment;
CM.Cache.ChainFrenzyMaxReward = CM.Cache.MaxChainCookieReward(7, maxPayout * 7, CM.Cache.GoldenCookiesMult);
CM.Cache.ChainFrenzyRequired = CM.Cache.ChainFrenzyMaxReward[1] * 2 / CM.Cache.GoldenCookiesMult;
CM.Cache.ChainFrenzyRequiredNext = CM.Cache.ChainFrenzyMaxReward[2] / 60 / 60 / 6 / CM.Cache.DragonsFortuneMultAdjustment;
CM.Cache.ChainFrenzyMaxWrathReward = CM.Cache.MaxChainCookieReward(6, maxPayout * 7, CM.Cache.WrathCookiesMult);
CM.Cache.ChainFrenzyWrathRequired = CM.Cache.ChainFrenzyMaxWrathReward[1] * 2 / CM.Cache.WrathCookiesMult;
CM.Cache.ChainFrenzyWrathRequiredNext = CM.Cache.ChainFrenzyMaxWrathReward[2] / 60 / 60 / 6 / CM.Cache.DragonsFortuneMultAdjustment;
};
/**
* This functions caches variables related to missing upgrades
* It is called by CM.Main.Loop() and CM.Cache.InitCache()
* @global {string} CM.Cache.MissingUpgrades String containig the HTML to create the "crates" for missing normal upgrades
* @global {string} CM.Cache.MissingUpgradesCookies String containig the HTML to create the "crates" for missing cookie upgrades
* @global {string} CM.Cache.MissingUpgradesPrestige String containig the HTML to create the "crates" for missing prestige upgrades
*/
CM.Cache.CacheMissingUpgrades = function () {
CM.Cache.MissingUpgrades = '';
CM.Cache.MissingUpgradesCookies = '';
CM.Cache.MissingUpgradesPrestige = '';
const list = [];
// sort the upgrades
for (const i of Object.keys(Game.Upgrades)) {
list.push(Game.Upgrades[i]);
}
const sortMap = function (a, b) {
if (a.order > b.order) return 1;
else if (a.order < b.order) return -1;
return 0;
};
list.sort(sortMap);
for (const i of Object.keys(list)) {
const me = list[i];
if (me.bought === 0) {
let str = '';
str += CM.Disp.crateMissing(me);
if (me.pool === 'prestige') CM.Cache.MissingUpgradesPrestige += str;
else if (me.pool === 'cookie') CM.Cache.MissingUpgradesCookies += str;
else if (me.pool !== 'toggle' && me.pool !== 'unused' && me.pool !== 'debug') CM.Cache.MissingUpgrades += str;
}
}
};
/**
* This functions caches the reward of popping a reindeer
* It is called by CM.Main.Loop() and CM.Cache.InitCache()
* @global {number} CM.Cache.SeaSpec The reward for popping a reindeer
*/
CM.Cache.CacheSeaSpec = function () {
if (Game.season === 'christmas') {
let val = Game.cookiesPs * 60;
if (Game.hasBuff('Elder frenzy')) val *= 0.5;
if (Game.hasBuff('Frenzy')) val *= 0.75;
CM.Cache.SeaSpec = Math.max(25, val);
if (Game.Has('Ho ho ho-flavored frosting')) CM.Cache.SeaSpec *= 2;
}
};
/**
* This functions caches the heavenly chips per second in the last five seconds
* It is called by CM.Cache.LoopCache()
* @global {number} CM.Cache.HCPerSecond The Heavenly Chips per second in the last five seconds
*/
CM.Cache.CacheHeavenlyChipsPS = function () {
CM.Cache.HCPerSecond = 0; // Mainly there to not throw errors during initialization
const currDate = Math.floor(Date.now() / 1000);
// Only calculate every new second
if ((Game.T / Game.fps) % 1 === 0) {
const chipsOwned = Game.HowMuchPrestige(Game.cookiesReset);
const ascendNowToOwn = Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned));
const ascendNowToGet = ascendNowToOwn - Math.floor(chipsOwned);
// Add recent gains to AvgQueue's
const timeDiff = currDate - CM.Cache.lastHeavenlyCheck;
const heavenlyChipsDiffAvg = Math.max(0, (ascendNowToGet - CM.Cache.lastHeavenlyChips)) / timeDiff;
for (let i = 0; i < timeDiff; i++) {
CM.Cache.HeavenlyChipsDiff.addLatest(heavenlyChipsDiffAvg);
}
// Store current data for next loop
CM.Cache.lastHeavenlyCheck = currDate;
CM.Cache.lastHeavenlyChips = ascendNowToGet;
// Get average gain over period of 5 seconds
CM.Cache.HCPerSecond = CM.Cache.HeavenlyChipsDiff.calcAverage(5);
}
};
/**
* Section: Functions related to caching CPS */
/**
* This functions caches creates the CMAvgQueue used by CM.Cache.CacheAvgCPS() to calculate CPS
* Called by CM.Cache.InitCache()
*/
CM.Cache.InitCookiesDiff = function () {
CM.Cache.CookiesDiff = new CMAvgQueue(CM.Disp.cookieTimes[CM.Disp.cookieTimes.length - 1]);
CM.Cache.WrinkDiff = new CMAvgQueue(CM.Disp.cookieTimes[CM.Disp.cookieTimes.length - 1]);
CM.Cache.WrinkFattestDiff = new CMAvgQueue(CM.Disp.cookieTimes[CM.Disp.cookieTimes.length - 1]);
CM.Cache.ChoEggDiff = new CMAvgQueue(CM.Disp.cookieTimes[CM.Disp.cookieTimes.length - 1]);
CM.Cache.ClicksDiff = new CMAvgQueue(CM.Disp.clickTimes[CM.Disp.clickTimes.length - 1]);
};
/**
* This functions caches two variables related average CPS and Clicks
* It is called by CM.Cache.LoopCache()
* @global {number} CM.Cache.RealCookiesEarned Cookies earned including the Chocolate Egg
* @global {number} CM.Cache.AvgCPS Average cookies over time-period as defined by AvgCPSHist
* @global {number} CM.Cache.AverageClicks Average cookies from clicking over time-period as defined by AvgClicksHist
* @global {number} CM.Cache.AvgCPSChoEgg Average cookies from combination of normal CPS and average Chocolate Cookie CPS
*/
CM.Cache.CacheAvgCPS = function () {
const currDate = Math.floor(Date.now() / 1000);
// Only calculate every new second
if ((Game.T / Game.fps) % 1 === 0) {
let choEggTotal = Game.cookies + CM.Cache.SellForChoEgg;
if (Game.cpsSucked > 0) choEggTotal += CM.Cache.WrinklersTotal;
CM.Cache.RealCookiesEarned = Math.max(Game.cookiesEarned, choEggTotal);
choEggTotal *= 0.05;
// Add recent gains to AvgQueue's
const timeDiff = currDate - CM.Cache.lastCPSCheck;
const bankDiffAvg = Math.max(0, (Game.cookies - CM.Cache.lastCookies)) / timeDiff;
const wrinkDiffAvg = Math.max(0, (CM.Cache.WrinklersTotal - CM.Cache.lastWrinkCookies)) / timeDiff;
const wrinkFattestDiffAvg = Math.max(0, (CM.Cache.WrinklersFattest[0] - CM.Cache.lastWrinkFattestCookies)) / timeDiff;
const choEggDiffAvg = Math.max(0, (choEggTotal - CM.Cache.lastChoEgg)) / timeDiff;
const clicksDiffAvg = (Game.cookieClicks - CM.Cache.lastClicks) / timeDiff;
for (let i = 0; i < timeDiff; i++) {
CM.Cache.CookiesDiff.addLatest(bankDiffAvg);
CM.Cache.WrinkDiff.addLatest(wrinkDiffAvg);
CM.Cache.WrinkFattestDiff.addLatest(wrinkFattestDiffAvg);
CM.Cache.ChoEggDiff.addLatest(choEggDiffAvg);
CM.Cache.ClicksDiff.addLatest(clicksDiffAvg);
}
// Store current data for next loop
CM.Cache.lastCPSCheck = currDate;
CM.Cache.lastCookies = Game.cookies;
CM.Cache.lastWrinkCookies = CM.Cache.WrinklersTotal;
CM.Cache.lastWrinkFattestCookies = CM.Cache.WrinklersFattest[0];
CM.Cache.lastChoEgg = choEggTotal;
CM.Cache.lastClicks = Game.cookieClicks;
// Get average gain over period of cpsLength seconds
const cpsLength = CM.Disp.cookieTimes[CM.Options.AvgCPSHist];
CM.Cache.AverageGainBank = CM.Cache.CookiesDiff.calcAverage(cpsLength);
CM.Cache.AverageGainWrink = CM.Cache.WrinkDiff.calcAverage(cpsLength);
CM.Cache.AverageGainWrinkFattest = CM.Cache.WrinkFattestDiff.calcAverage(cpsLength);
CM.Cache.AverageGainChoEgg = CM.Cache.ChoEggDiff.calcAverage(cpsLength);
CM.Cache.AvgCPS = CM.Cache.AverageGainBank;
if (CM.Options.CalcWrink === 1) CM.Cache.AvgCPS += CM.Cache.AverageGainWrink;
if (CM.Options.CalcWrink === 2) CM.Cache.AvgCPS += CM.Cache.AverageGainWrinkFattest;
const choEgg = (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg'));
if (choEgg || CM.Options.CalcWrink === 0) {
CM.Cache.AvgCPSWithChoEgg = CM.Cache.AverageGainBank + CM.Cache.AverageGainWrink + (choEgg ? CM.Cache.AverageGainChoEgg : 0);
} else CM.Cache.AvgCPSWithChoEgg = CM.Cache.AvgCPS;
CM.Cache.AverageClicks = CM.Cache.ClicksDiff.calcAverage(CM.Disp.clickTimes[CM.Options.AvgClicksHist]);
}
};
/**
* This functions caches the reward for selling the Chocolate egg
* It is called by CM.Main.Loop()
* @global {number} CM.Cache.SellForChoEgg Total cookies to be gained from selling Chocolate egg
*/
CM.Cache.CacheSellForChoEgg = function () {
let sellTotal = 0;
// Compute cookies earned by selling stock market goods
if (Game.Objects.Bank.minigameLoaded) {
const marketGoods = Game.Objects.Bank.minigame.goods;
let goodsVal = 0;
for (const i of Object.keys(marketGoods)) {
const marketGood = marketGoods[i];
goodsVal += marketGood.stock * marketGood.val;
}
sellTotal += goodsVal * Game.cookiesPsRawHighest;
}
// Compute cookies earned by selling all buildings with optimal auras (ES + RB)
sellTotal += CM.Sim.SellBuildingsForChoEgg();
CM.Cache.SellForChoEgg = sellTotal;
};
/**
* This functions caches the current Wrinkler CPS multiplier
* It is called by CM.Cache.LoopCache(). Variables are mostly used by CM.Disp.GetCPS().
* @global {number} CM.Cache.CurrWrinklerCount Current number of wrinklers
* @global {number} CM.Cache.CurrWrinklerCPSMult Current multiplier of CPS because of wrinklers (excluding their negative sucking effect)
*/
CM.Cache.CacheCurrWrinklerCPS = function () {
CM.Cache.CurrWrinklerCPSMult = 0;
let count = 0;
for (const i in Game.wrinklers) {
if (Game.wrinklers[i].phase === 2) count++;
}
let godMult = 1;
if (CM.Sim.Objects.Temple.minigameLoaded) {
const godLvl = Game.hasGod('scorn');
if (godLvl === 1) godMult *= 1.15;
else if (godLvl === 2) godMult *= 1.1;
else if (godLvl === 3) godMult *= 1.05;
}
CM.Cache.CurrWrinklerCount = count;
CM.Cache.CurrWrinklerCPSMult = count * (count * 0.05 * 1.1) * (Game.Has('Sacrilegious corruption') * 0.05 + 1) * (Game.Has('Wrinklerspawn') * 0.05 + 1) * godMult;
};
/**
* This function returns the current CPS buff
* It is called by CM.Sim.CalculateGains(), CM.Disp.UpdateTooltipWarnings(), CM.Cache.CacheStats() and CM.Cache.CacheChain()
* @returns {number} mult The multiplier
*/
CM.Cache.getCPSBuffMult = function () {
let mult = 1;
for (const i of Object.keys(Game.buffs)) {
if (typeof Game.buffs[i].multCpS !== 'undefined') mult *= Game.buffs[i].multCpS;
}
return mult;
};
/**
* This function calculates CPS without the Golden Switch as it might be needed in other functions
* If so it CM.Sim.Win()'s them and the caller function will know to recall CM.Sim.CalculateGains()
* It is called at the end of any functions that simulates certain behaviour
*/
CM.Cache.NoGoldSwitchCPS = function () {
if (Game.Has('Golden switch [off]')) {
CM.Cache.NoGoldSwitchCookiesPS = CM.Sim.NoGoldSwitchCPS();
} else CM.Cache.NoGoldSwitchCookiesPS = Game.cookiesPs;
};
/**
* Section: Functions related to "Specials" (Dragon and Santa) */
/**
* This functions caches the current cost of upgrading the dragon level so it can be displayed in the tooltip
* It is called by the relevan tooltip-code as a result of CM.Disp.AddDragonLevelUpTooltip() and by CM.Main.Loop()
* @global {number} CM.Cache.lastDragonLevel The last cached dragon level
* @global {string} CM.Cache.CostDragonUpgrade The Beautified cost of the next upgrade
*/
CM.Cache.CacheDragonCost = function () {
if (CM.Cache.lastDragonLevel !== Game.dragonLevel || CM.Sim.DoSims) {
if (Game.dragonLevel < 25 && Game.dragonLevels[Game.dragonLevel].buy.toString().includes('sacrifice')) {
let target = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/Objects\[(.*)\]/)[1];
const amount = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/sacrifice\((.*?)\)/)[1];
if (target !== 'i') {
target = target.replaceAll("'", '');
if (Game.Objects[target].amount < amount) {
CM.Cache.CostDragonUpgrade = 'Not enough buildings to sell';
} else {
let cost = 0;
CM.Sim.CopyData();
for (let i = 0; i < amount; i++) {
let price = CM.Sim.Objects[target].basePrice * Game.priceIncrease ** Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free);
price = Game.modifyBuildingPrice(CM.Sim.Objects[target], price);
price = Math.ceil(price);
cost += price;
CM.Sim.Objects[target].amount--;
}
CM.Cache.CostDragonUpgrade = `Cost to rebuy: ${CM.Disp.Beautify(cost)}`;
}
} else {
let cost = 0;
CM.Sim.CopyData();
for (const j of Object.keys(Game.Objects)) {
target = j;
if (Game.Objects[target].amount < amount) {
CM.Cache.CostDragonUpgrade = 'Not enough buildings to sell';
break;
} else {
for (let i = 0; i < amount; i++) {
let price = CM.Sim.Objects[target].basePrice * Game.priceIncrease ** Math.max(0, CM.Sim.Objects[target].amount - 1 - CM.Sim.Objects[target].free);
price = Game.modifyBuildingPrice(CM.Sim.Objects[target], price);
price = Math.ceil(price);
cost += price;
CM.Sim.Objects[target].amount--;
}
}
CM.Cache.CostDragonUpgrade = `Cost to rebuy: ${CM.Disp.Beautify(cost)}`;
}
}
}
CM.Cache.lastDragonLevel = Game.dragonLevel;
}
};
/**
* Section: Functions related to caching income */
/**
* This functions caches the income gain of each building and upgrade and stores it in the cache
* It is called by CM.Main.Loop() and CM.Cache.InitCache()
*/
CM.Cache.CacheIncome = function () {
// Simulate Building Buys for 1, 10 and 100 amount
CM.Cache.CacheBuildingIncome(1, 'Objects1');
CM.Cache.CacheBuildingIncome(10, 'Objects10');
CM.Cache.CacheBuildingIncome(100, 'Objects100');
// Simulate Upgrade Buys
CM.Cache.CacheUpgradeIncome();
};
/**
* This functions starts the calculation/simulation of the bonus income of buildings
* It is called by CM.Cache.CacheIncome()
* @param {amount} amount Amount to be bought
* @parem {string} target The target Cache object ("Objects1", "Objects10" or "Objects100")
*/
CM.Cache.CacheBuildingIncome = function (amount, target) {
CM.Cache[target] = [];
for (const i of Object.keys(Game.Objects)) {
CM.Cache[target][i] = {};
CM.Cache[target][i].bonus = CM.Sim.BuyBuildingsBonusIncome(i, amount);
if (amount !== 1) {
CM.Cache.DoRemakeBuildPrices = 1;
}
}
};
/**
* This functions starts the calculation/simulation of the bonus income of upgrades
* It is called by CM.Cache.CacheIncome()
*/
CM.Cache.CacheUpgradeIncome = function () {
CM.Cache.Upgrades = [];
for (const i of Object.keys(Game.Upgrades)) {
const bonusIncome = CM.Sim.BuyUpgradesBonusIncome(i);
CM.Cache.Upgrades[i] = {};
if (bonusIncome[0]) CM.Cache.Upgrades[i].bonus = bonusIncome[0];
if (bonusIncome[1]) CM.Cache.Upgrades[i].bonusMouse = bonusIncome[1];
}
};
/**
* Section: Functions related to caching prices */
/**
* This functions caches the price of each building and stores it in the cache
* It is called by CM.Main.Loop() and CM.Cache.InitCache()
*/
CM.Cache.CacheBuildingsPrices = function () {
for (const i of Object.keys(Game.Objects)) {
CM.Cache.Objects1[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 1);
CM.Cache.Objects10[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 10);
CM.Cache.Objects100[i].price = CM.Sim.BuildingGetPrice(Game.Objects[i], Game.Objects[i].basePrice, Game.Objects[i].amount, Game.Objects[i].free, 100);
}
};
/**
* Section: Functions related to caching PP */
/**
* This functions caches the PP of each building and upgrade and stores it in the cache
* It is called by CM.Cache.LoopCache() and CM.Cache.InitCache()
*/
CM.Cache.CachePP = function () {
CM.Cache.CacheBuildingsPP();
CM.Cache.CacheUpgradePP();
};
/**
* This functions return the colour assosciated with the given pp value
* It is called by CM.Cache.CacheBuildingsPP(), CM.Cache.CacheBuildingsBulkPP() and CM.Cache.CacheUpgradePP()
* @params {object} obj The obj of which the pp value should be checked
* @params {number} price The price of the object
* @returns {string} color The colour assosciated with the pp value
*/
CM.Cache.ColourOfPP = function (me, price) {
let color = '';
// Colour based on PP
if (me.pp <= 0 || me.pp === Infinity) color = CM.Disp.colorGray;
else if (me.pp < CM.Cache.min) color = CM.Disp.colorBlue;
else if (me.pp === CM.Cache.min) color = CM.Disp.colorGreen;
else if (me.pp === CM.Cache.max) color = CM.Disp.colorRed;
else if (me.pp > CM.Cache.max) color = CM.Disp.colorPurple;
else if (me.pp > CM.Cache.mid) color = CM.Disp.colorOrange;
else color = CM.Disp.colorYellow;
// Colour based on price in terms of CPS
if (Number(CM.Options.PPSecondsLowerLimit) !== 0) {
if (price / CM.Disp.GetCPS() < Number(CM.Options.PPSecondsLowerLimit)) color = CM.Disp.colorBlue;
}
// Colour based on being able to purchase
if (CM.Options.PPOnlyConsiderBuyable) {
if (price - Game.cookies > 0) color = CM.Disp.colorRed;
}
return color;
};
/**
* This functions caches the PP of each building it saves all date in CM.Cache.Objects...
* It is called by CM.Cache.CachePP()
*/
CM.Cache.CacheBuildingsPP = function () {
CM.Cache.min = Infinity;
CM.Cache.max = 1;
CM.Cache.ArrayOfPPs = [];
if (typeof CM.Options.PPExcludeTop === 'undefined') CM.Options.PPExcludeTop = 0; // Otherwise breaks during initialization
// Calculate PP and colors when compared to purchase of optimal building in single-purchase mode
if (CM.Options.ColorPPBulkMode === 0) {
for (const i of Object.keys(CM.Cache.Objects1)) {
if (Game.cookiesPs) {
CM.Cache.Objects1[i].pp = (Math.max(Game.Objects[i].getPrice() - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].getPrice() / CM.Cache.Objects1[i].bonus);
} else CM.Cache.Objects1[i].pp = (Game.Objects[i].getPrice() / CM.Cache.Objects1[i].bonus);
CM.Cache.ArrayOfPPs.push([CM.Cache.Objects1[i].pp, Game.Objects[i].getPrice()]);
}
// Set CM.Cache.min to best non-excluded buidliung
CM.Cache.ArrayOfPPs.sort((a, b) => a[0] - b[0]);
if (CM.Options.PPOnlyConsiderBuyable) {
while (CM.Cache.ArrayOfPPs[0][1] > Game.cookies) {
if (CM.Cache.ArrayOfPPs.length === 1) {
break;
}
CM.Cache.ArrayOfPPs.shift();
}
}
CM.Cache.min = CM.Cache.ArrayOfPPs[CM.Options.PPExcludeTop][0];
CM.Cache.max = CM.Cache.ArrayOfPPs[CM.Cache.ArrayOfPPs.length - 1][0];
CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min;
for (const i of Object.keys(CM.Cache.Objects1)) {
CM.Cache.Objects1[i].color = CM.Cache.ColourOfPP(CM.Cache.Objects1[i], Game.Objects[i].getPrice());
// Colour based on excluding certain top-buildings
for (let j = 0; j < CM.Options.PPExcludeTop; j++) {
if (CM.Cache.Objects1[i].pp === CM.Cache.ArrayOfPPs[j][0]) CM.Cache.Objects1[i].color = CM.Disp.colorGray;
}
}
// Calculate PP of bulk-buy modes
CM.Cache.CacheBuildingsBulkPP('Objects10');
CM.Cache.CacheBuildingsBulkPP('Objects100');
} else {
// Calculate PP and colors when compared to purchase of selected bulk mode
const target = `Objects${Game.buyBulk}`;
for (const i of Object.keys(CM.Cache[target])) {
if (Game.cookiesPs) {
CM.Cache[target][i].pp = (Math.max(Game.Objects[i].bulkPrice - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Objects[i].bulkPrice / CM.Cache[target][i].bonus);
} else CM.Cache[target][i].pp = (Game.Objects[i].bulkPrice / CM.Cache[target][i].bonus);
CM.Cache.ArrayOfPPs.push([CM.Cache[target][i].pp, Game.Objects[i].bulkPrice]);
}
// Set CM.Cache.min to best non-excluded buidliung
CM.Cache.ArrayOfPPs.sort((a, b) => a[0] - b[0]);
if (CM.Options.PPOnlyConsiderBuyable) {
while (CM.Cache.ArrayOfPPs[0][1] > Game.cookies) {
if (CM.Cache.ArrayOfPPs.length === 1) {
break;
}
CM.Cache.ArrayOfPPs.shift();
}
}
CM.Cache.min = CM.Cache.ArrayOfPPs[CM.Options.PPExcludeTop][0];
CM.Cache.max = CM.Cache.ArrayOfPPs[CM.Cache.ArrayOfPPs.length - 1][0];
CM.Cache.mid = ((CM.Cache.max - CM.Cache.min) / 2) + CM.Cache.min;
for (const i of Object.keys(CM.Cache.Objects1)) {
CM.Cache[target][i].color = CM.Cache.ColourOfPP(CM.Cache[target][i], Game.Objects[i].bulkPrice);
// Colour based on excluding certain top-buildings
for (let j = 0; j < CM.Options.PPExcludeTop; j++) {
if (CM.Cache[target][i].pp === CM.Cache.ArrayOfPPs[j][0]) CM.Cache[target][i].color = CM.Disp.colorGray;
}
}
}
};
/**
* This functions caches the buildings of bulk-buy mode when PP is compared against optimal single-purchase building
* It saves all date in CM.Cache.Objects...
* It is called by CM.Cache.CacheBuildingsPP()
*/
CM.Cache.CacheBuildingsBulkPP = function (target) {
for (const i of Object.keys(CM.Cache[target])) {
if (Game.cookiesPs) {
CM.Cache[target][i].pp = (Math.max(CM.Cache[target][i].price - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (CM.Cache[target][i].price / CM.Cache[target][i].bonus);
} else CM.Cache[target][i].pp = (CM.Cache[target][i].price / CM.Cache[target][i].bonus);
CM.Cache[target][i].color = CM.Cache.ColourOfPP(CM.Cache[target][i], CM.Cache[target][i].price);
}
};
/**
* This functions caches the PP of each building it saves all date in CM.Cache.Upgrades
* It is called by CM.Cache.CachePP()
*/
CM.Cache.CacheUpgradePP = function () {
for (const i of Object.keys(CM.Cache.Upgrades)) {
if (Game.cookiesPs) {
CM.Cache.Upgrades[i].pp = (Math.max(Game.Upgrades[i].getPrice() - (Game.cookies + CM.Disp.GetWrinkConfigBank()), 0) / Game.cookiesPs) + (Game.Upgrades[i].getPrice() / CM.Cache.Upgrades[i].bonus);
} else CM.Cache.Upgrades[i].pp = (Game.Upgrades[i].getPrice() / CM.Cache.Upgrades[i].bonus);
if (Number.isNaN(CM.Cache.Upgrades[i].pp)) CM.Cache.Upgrades[i].pp = Infinity;
CM.Cache.Upgrades[i].color = CM.Cache.ColourOfPP(CM.Cache.Upgrades[i], Game.Upgrades[i].getPrice());
}
};
/**
* Section: Cached variables */
/**
* Used to store the multiplier of the Century Egg
*/
CM.Cache.CentEgg = 0;
/**
* Used to store if there was a Build Aura (used in CM.Main)
*/
CM.Cache.HadBuildAura = false;
/**
* Used to store CPS without Golden Cookie Switch
*/
CM.Cache.NoGoldSwitchCookiesPS = 0;

View File

@@ -0,0 +1,72 @@
import { ClickTimes, CookieTimes } from '../../Disp/VariablesAndData';
import {
ChoEggDiff,
ClicksDiff,
CookiesDiff,
WrinkDiff,
WrinkFattestDiff,
} from '../VariablesAndData';
/**
* @class
* @classdesc This is a class used to store values used to calculate average over time (mostly cps)
* @var {number} maxLength The maximum length of the value-storage
* @var {[]} queue The values stored
* @method addLatest(newValue) Appends newValue to the value storage
* @method calcAverage(timePeriod) Returns the average over the specified timeperiod
*/
export class CMAvgQueue {
constructor(maxLength) {
this.maxLength = maxLength;
this.queue = [];
}
addLatest(newValue) {
if (this.queue.push(newValue) > this.maxLength) {
this.queue.shift();
}
}
/**
* This functions returns the average of the values in the queue
* @param {number} timePeriod The period in seconds to computer average over
* @returns {number} ret The average
*/
calcAverage(timePeriod) {
let time = timePeriod;
if (time > this.maxLength) time = this.maxLength;
if (time > this.queue.length) time = this.queue.length;
let ret = 0;
for (
let i = this.queue.length - 1;
i >= 0 && i > this.queue.length - 1 - time;
i--
) {
ret += this.queue[i];
}
if (ret === 0) {
return 0;
}
return ret / time;
}
calcSum(timePeriod) {
let time = timePeriod;
if (time > this.maxLength) time = this.maxLength;
if (time > this.queue.length) time = this.queue.length;
if (time === 0) return 0;
return this.queue.slice(-time).reduce((a, b) => a + b, 0);
}
}
/**
* This functions caches creates the CMAvgQueue used by CM.Cache.CacheAvgCPS() to calculate CPS
* Called by CM.Cache.InitCache()
*/
export function InitCookiesDiff() {
CookiesDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]); // eslint-disable-line no-unused-vars
WrinkDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]); // eslint-disable-line no-unused-vars
WrinkFattestDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]); // eslint-disable-line no-unused-vars
ChoEggDiff = new CMAvgQueue(CookieTimes[CookieTimes.length - 1]); // eslint-disable-line no-unused-vars
ClicksDiff = new CMAvgQueue(ClickTimes[ClickTimes.length - 1]); // eslint-disable-line no-unused-vars
}

97
src/Cache/CPS/CPS.js Normal file
View File

@@ -0,0 +1,97 @@
import { CMOptions } from '../../Config/VariablesAndData';
import { ClickTimes, CookieTimes } from '../../Disp/VariablesAndData';
import {
CacheAverageClicks,
CacheAverageCPS,
CacheAverageGainBank,
CacheAverageGainChoEgg,
CacheAverageGainWrink,
CacheAverageGainWrinkFattest,
CacheAvgCPSWithChoEgg,
CacheLastChoEgg,
CacheLastClicks,
CacheLastCookies,
CacheLastCPSCheck,
CacheLastWrinkCookies,
CacheLastWrinkFattestCookies,
CacheRealCookiesEarned,
CacheSellForChoEgg,
CacheWrinklersFattest,
CacheWrinklersTotal,
ChoEggDiff,
ClicksDiff,
CookiesDiff,
WrinkDiff,
WrinkFattestDiff,
} from '../VariablesAndData';
/**
* This functions caches two variables related average CPS and Clicks
* It is called by CM.Cache.LoopCache()
* @global {number} CM.Cache.RealCookiesEarned Cookies earned including the Chocolate Egg
* @global {number} CM.Cache.AvgCPS Average cookies over time-period as defined by AvgCPSHist
* @global {number} CM.Cache.AverageClicks Average cookies from clicking over time-period as defined by AvgClicksHist
* @global {number} CM.Cache.AvgCPSChoEgg Average cookies from combination of normal CPS and average Chocolate Cookie CPS
*/
export default function CacheAvgCPS() {
const currDate = Math.floor(Date.now() / 1000);
// Only calculate every new second
if ((Game.T / Game.fps) % 1 === 0) {
let choEggTotal = Game.cookies + CacheSellForChoEgg;
if (Game.cpsSucked > 0) choEggTotal += CacheWrinklersTotal;
CacheRealCookiesEarned = Math.max(Game.cookiesEarned, choEggTotal); // eslint-disable-line no-unused-vars
choEggTotal *= 0.05;
// Add recent gains to AvgQueue's
const timeDiff = currDate - CacheLastCPSCheck;
const bankDiffAvg = Math.max(0, Game.cookies - CacheLastCookies) / timeDiff;
const wrinkDiffAvg =
Math.max(0, CacheWrinklersTotal - CacheLastWrinkCookies) / timeDiff;
const wrinkFattestDiffAvg =
Math.max(0, CacheWrinklersFattest[0] - CacheLastWrinkFattestCookies) /
timeDiff;
const choEggDiffAvg = Math.max(0, choEggTotal - CacheLastChoEgg) / timeDiff;
const clicksDiffAvg = (Game.cookieClicks - CacheLastClicks) / timeDiff;
for (let i = 0; i < timeDiff; i++) {
CookiesDiff.addLatest(bankDiffAvg);
WrinkDiff.addLatest(wrinkDiffAvg);
WrinkFattestDiff.addLatest(wrinkFattestDiffAvg);
ChoEggDiff.addLatest(choEggDiffAvg);
ClicksDiff.addLatest(clicksDiffAvg);
}
// Store current data for next loop
CacheLastCPSCheck = currDate;
CacheLastCookies = Game.cookies;
CacheLastWrinkCookies = CacheWrinklersTotal;
CacheLastWrinkFattestCookies = CacheWrinklersFattest[0];
CacheLastChoEgg = choEggTotal;
CacheLastClicks = Game.cookieClicks;
// Get average gain over period of cpsLength seconds
const cpsLength = CookieTimes[CMOptions.AvgCPSHist];
CacheAverageGainBank = CookiesDiff.calcAverage(cpsLength);
CacheAverageGainWrink = WrinkDiff.calcAverage(cpsLength);
CacheAverageGainWrinkFattest = WrinkFattestDiff.calcAverage(cpsLength);
CacheAverageGainChoEgg = ChoEggDiff.calcAverage(cpsLength);
CacheAverageCPS = CacheAverageGainBank;
if (CMOptions.CalcWrink === 1) CacheAverageCPS += CacheAverageGainWrink;
if (CMOptions.CalcWrink === 2)
CacheAverageCPS += CacheAverageGainWrinkFattest;
const choEgg =
Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg');
if (choEgg || CMOptions.CalcWrink === 0) {
CacheAvgCPSWithChoEgg =
CacheAverageGainBank +
CacheAverageGainWrink +
(choEgg ? CacheAverageGainChoEgg : 0);
} else CacheAvgCPSWithChoEgg = CacheAverageCPS; // eslint-disable-line no-unused-vars
// eslint-disable-next-line no-unused-vars
CacheAverageClicks = ClicksDiff.calcAverage(
ClickTimes[CMOptions.AvgClicksHist],
);
}
}

View File

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

View File

@@ -0,0 +1,12 @@
/**
* This function returns the current CPS buff
* @returns {number} mult The multiplier
*/
export default function GetCPSBuffMult() {
let mult = 1;
Object.keys(Game.buffs).forEach((i) => {
if (typeof Game.buffs[i].multCpS !== 'undefined')
mult *= Game.buffs[i].multCpS;
});
return mult;
}

View File

@@ -0,0 +1,13 @@
import CalcNoGoldSwitchCPS from '../../Sim/Calculations/NoGoldenSwitchCalc';
import { CacheNoGoldSwitchCookiesPS } from '../VariablesAndData';
/**
* This function calculates CPS without the Golden Switch as it might be needed in other functions
* If so it CM.Sim.Win()'s them and the caller function will know to recall CM.Sim.CalculateGains()
* It is called at the end of any functions that simulates certain behaviour
*/
export default function CacheNoGoldSwitchCPS() {
if (Game.Has('Golden switch [off]')) {
CacheNoGoldSwitchCookiesPS = CalcNoGoldSwitchCPS();
} else CacheNoGoldSwitchCookiesPS = Game.cookiesPs; // eslint-disable-line no-unused-vars
}

View File

@@ -0,0 +1,24 @@
import SellBuildingsForChoEgg from '../../Sim/SimulationEvents/SellBuildingForChoEgg';
import { CacheSellForChoEgg } from '../VariablesAndData';
/**
* This functions caches the reward for selling the Chocolate egg
* It is called by CM.Main.Loop()
* @global {number} CM.Cache.SellForChoEgg Total cookies to be gained from selling Chocolate egg
*/
export default function CacheSellAllForChoEgg() {
let sellTotal = 0;
// Compute cookies earned by selling stock market goods
if (Game.Objects.Bank.minigameLoaded) {
const marketGoods = Game.Objects.Bank.minigame.goods;
let goodsVal = 0;
Object.keys(marketGoods).forEach((i) => {
const marketGood = marketGoods[i];
goodsVal += marketGood.stock * marketGood.val;
});
sellTotal += goodsVal * Game.cookiesPsRawHighest;
}
// Compute cookies earned by selling all buildings with optimal auras (ES + RB)
sellTotal += SellBuildingsForChoEgg();
CacheSellForChoEgg = sellTotal; // eslint-disable-line no-unused-vars
}

46
src/Cache/CacheInit.js Normal file
View File

@@ -0,0 +1,46 @@
import { ClickTimes } from '../Disp/VariablesAndData';
import { CMAvgQueue, InitCookiesDiff } from './CPS/AverageQueue';
import CacheAvgCPS from './CPS/CPS';
import CacheDragonAuras from './Dragon/CacheDragonAuras';
import CachePP from './PP/PP';
import {
CacheBuildingsPrices,
CacheIncome,
} from './PriceAndIncome/PriceAndIncome';
import { CacheChain } from './Stats/ChainCookies';
import CacheHeavenlyChipsPS from './Stats/HeavenlyChips';
import CacheAllMissingUpgrades from './Stats/MissingUpgrades';
import CacheSeasonSpec from './Stats/Reindeer';
import {
CacheGoldenAndWrathCookiesMults,
CacheStatsCookies,
} from './Stats/Stats';
import {
CacheAverageCookiesFromClicks,
HeavenlyChipsDiff,
} from './VariablesAndData';
import CacheWrinklers from './Wrinklers/Wrinklers';
/**
* This functions runs all cache-functions to generate all "full" cache
*/
export default function InitCache() {
CacheDragonAuras();
CacheWrinklers();
CacheStatsCookies();
CacheGoldenAndWrathCookiesMults();
CacheChain();
CacheAllMissingUpgrades();
CacheSeasonSpec();
InitCookiesDiff();
/** Used by CM.Cache.CacheHeavenlyChipsPS() */
HeavenlyChipsDiff = new CMAvgQueue(5); // eslint-disable-line no-unused-vars
CacheAverageCookiesFromClicks = new CMAvgQueue( // eslint-disable-line no-unused-vars
ClickTimes[ClickTimes.length - 1] * 20,
);
CacheHeavenlyChipsPS();
CacheAvgCPS();
CacheIncome();
CacheBuildingsPrices();
CachePP();
}

30
src/Cache/CacheLoop.js Normal file
View File

@@ -0,0 +1,30 @@
import { FormatTime } from '../Disp/BeautifyAndFormatting/BeautifyFormatting';
import GetCPS from '../Disp/HelperFunctions/GetCPS';
import CacheAvgCPS from './CPS/CPS';
import CacheCurrWrinklerCPS from './CPS/CurrWrinklerCPS';
import CachePP from './PP/PP';
import CacheHeavenlyChipsPS from './Stats/HeavenlyChips';
import { CacheTimeTillNextPrestige } from './VariablesAndData';
import CacheWrinklers from './Wrinklers/Wrinklers';
/**
* This functions caches variables that are needed every loop
* @global {string} CM.Cache.TimeTillNextPrestige Time requried till next prestige level
*/
export default function LoopCache() {
// Update Wrinkler Bank
CacheWrinklers();
CachePP();
CacheCurrWrinklerCPS();
CacheAvgCPS();
CacheHeavenlyChipsPS();
const cookiesToNext =
Game.HowManyCookiesReset(
Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)) +
1,
) -
(Game.cookiesEarned + Game.cookiesReset);
CacheTimeTillNextPrestige = FormatTime(cookiesToNext / GetCPS()); // eslint-disable-line no-unused-vars
}

View File

@@ -0,0 +1,9 @@
import { CacheDragonAura, CacheDragonAura2 } from '../VariablesAndData';
/**
* This functions caches the currently selected Dragon Auras
*/
export default function CacheDragonAuras() {
CacheDragonAura = Game.dragonAura; // eslint-disable-line no-unused-vars
CacheDragonAura2 = Game.dragonAura2; // eslint-disable-line no-unused-vars
}

View File

@@ -0,0 +1,76 @@
/** Functions related to the Dragon */
import { Beautify } from '../../Disp/BeautifyAndFormatting/BeautifyFormatting';
import CopyData from '../../Sim/SimulationData/CopyData';
import { SimDoSims, SimObjects } from '../../Sim/VariablesAndData';
import {
CacheCostDragonUpgrade,
CacheLastDragonLevel,
} from '../VariablesAndData';
/**
* This functions caches the current cost of upgrading the dragon level so it can be displayed in the tooltip
*/
export default function CacheDragonCost() {
if (CacheLastDragonLevel !== Game.dragonLevel || SimDoSims) {
if (
Game.dragonLevel < 25 &&
Game.dragonLevels[Game.dragonLevel].buy.toString().includes('sacrifice')
) {
let target = Game.dragonLevels[Game.dragonLevel].buy
.toString()
.match(/Objects\[(.*)\]/)[1];
const amount = Game.dragonLevels[Game.dragonLevel].buy
.toString()
.match(/sacrifice\((.*?)\)/)[1];
if (target !== 'i') {
target = target.replaceAll("'", '');
if (Game.Objects[target].amount < amount) {
CacheCostDragonUpgrade = 'Not enough buildings to sell';
} else {
let cost = 0;
CopyData();
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 -= 1;
}
CacheCostDragonUpgrade = `Cost to rebuy: ${Beautify(cost)}`;
}
} else {
let cost = 0;
CopyData();
Object.keys(Game.Objects).forEach((j) => {
target = j;
if (Game.Objects[target].amount < amount) {
CacheCostDragonUpgrade = 'Not enough buildings to sell';
return;
}
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 -= 1;
}
CacheCostDragonUpgrade = `Cost to rebuy: ${Beautify(cost)}`; // eslint-disable-line no-unused-vars
});
}
}
CacheLastDragonLevel = Game.dragonLevel;
}
}

80
src/Cache/PP/Building.js Normal file
View File

@@ -0,0 +1,80 @@
import { CMOptions } from '../../Config/VariablesAndData';
import GetWrinkConfigBank from '../../Disp/HelperFunctions/GetWrinkConfigBank';
import { ColourGray } from '../../Disp/VariablesAndData';
import {
CacheMinPP,
CacheObjects1,
CacheObjects10,
CacheObjects100,
CachePPArray,
} from '../VariablesAndData';
import ColourOfPP from './ColourOfPP';
/**
* This functions caches the buildings of bulk-buy mode when PP is compared against optimal single-purchase building
* It saves all date in CM.Cache.Objects...
* It is called by CM.Cache.CacheBuildingsPP()
*/
function CacheColour(target, amount) {
Object.keys(target).forEach((i) => {
if (CMOptions.PPRigidelMode && amount === 1) {
target[i].color = ColourGray; // eslint-disable-line no-param-reassign
return;
}
// eslint-disable-next-line no-param-reassign
target[i].color = ColourOfPP(
target[i],
Game.Objects[i].getSumPrice(amount),
);
// Colour based on excluding certain top-buildings
for (let j = 0; j < CMOptions.PPExcludeTop; j++) {
if (target[i].pp === CachePPArray[j][0]) target[i].color = ColourGray; // eslint-disable-line no-param-reassign
}
});
}
function CachePP(target, amount) {
Object.keys(target).forEach((i) => {
const price = Game.Objects[i].getSumPrice(amount);
if (Game.cookiesPs) {
target[i].pp = // eslint-disable-line no-param-reassign
Math.max(price - (Game.cookies + GetWrinkConfigBank()), 0) /
Game.cookiesPs +
price / target[i].bonus;
} else target[i].pp = price / target[i].bonus; // eslint-disable-line no-param-reassign
if (!(CMOptions.PPRigidelMode && amount === 1))
CachePPArray.push([target[i].pp, amount]);
});
}
/**
* This functions caches the PP of each building it saves all date in CM.Cache.Objects...
* It is called by CM.Cache.CachePP()
*/
export default function CacheBuildingsPP() {
CacheMinPP = Infinity;
CachePPArray = [];
if (typeof CMOptions.PPExcludeTop === 'undefined') CMOptions.PPExcludeTop = 0; // Otherwise breaks during initialization
// Calculate PP and colors
CachePP(CacheObjects1, 1);
CachePP(CacheObjects10, 10);
CachePP(CacheObjects100, 100);
// Set CM.Cache.min to best non-excluded buidliung
CachePPArray.sort((a, b) => a[0] - b[0]);
let indexOfMin = 0;
if (CMOptions.PPOnlyConsiderBuyable) {
while (CachePPArray[indexOfMin][1] > Game.cookies) {
indexOfMin += 1;
if (CachePPArray.length === indexOfMin + 1) {
break;
}
}
}
CacheMinPP = CachePPArray[CMOptions.PPExcludeTop][indexOfMin]; // eslint-disable-line no-unused-vars
CacheColour(CacheObjects1, 1);
CacheColour(CacheObjects10, 10);
CacheColour(CacheObjects100, 100);
}

View File

@@ -0,0 +1,42 @@
import { CMOptions } from '../../Config/VariablesAndData';
import GetCPS from '../../Disp/HelperFunctions/GetCPS';
import {
ColourBlue,
ColourGray,
ColourGreen,
ColourOrange,
ColourPurple,
ColourRed,
ColourYellow,
} from '../../Disp/VariablesAndData';
import { CacheMinPP, CachePPArray } from '../VariablesAndData';
/**
* This functions return the colour assosciated with the given pp value
* It is called by CM.Cache.CacheBuildingsPP(), CM.Cache.CacheBuildingsBulkPP() and CM.Cache.CacheUpgradePP()
* @params {object} obj The obj of which the pp value should be checked
* @params {number} price The price of the object
* @returns {string} color The colour assosciated with the pp value
*/
export default function ColourOfPP(me, price) {
let color = '';
// Colour based on PP
if (me.pp <= 0 || me.pp === Infinity) color = ColourGray;
else if (me.pp < CacheMinPP) color = ColourBlue;
else if (me.pp === CacheMinPP) color = ColourGreen;
else if (me.pp < CachePPArray[10][0]) color = ColourYellow;
else if (me.pp < CachePPArray[20][0]) color = ColourOrange;
else if (me.pp < CachePPArray[30][0]) color = ColourRed;
else color = ColourPurple;
// Colour based on price in terms of CPS
if (Number(CMOptions.PPSecondsLowerLimit) !== 0) {
if (price / GetCPS() < Number(CMOptions.PPSecondsLowerLimit))
color = ColourBlue;
}
// Colour based on being able to purchase
if (CMOptions.PPOnlyConsiderBuyable) {
if (price - Game.cookies > 0) color = ColourRed;
}
return color;
}

14
src/Cache/PP/PP.js Normal file
View File

@@ -0,0 +1,14 @@
/**
* Section: Functions related to caching PP */
import CacheBuildingsPP from './Building';
import CacheUpgradePP from './Upgrade';
/**
* This functions caches the PP of each building and upgrade and stores it in the cache
* It is called by CM.Cache.LoopCache() and CM.Cache.InitCache()
*/
export default function CachePP() {
CacheBuildingsPP();
CacheUpgradePP();
}

29
src/Cache/PP/Upgrade.js Normal file
View File

@@ -0,0 +1,29 @@
import GetWrinkConfigBank from '../../Disp/HelperFunctions/GetWrinkConfigBank';
import { CacheUpgrades } from '../VariablesAndData';
import ColourOfPP from './ColourOfPP';
/**
* This functions caches the PP of each building it saves all date in CM.Cache.Upgrades
* It is called by CM.Cache.CachePP()
*/
export default function CacheUpgradePP() {
Object.keys(CacheUpgrades).forEach((i) => {
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;
} 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(),
);
});
}

View File

@@ -0,0 +1,13 @@
import CalculateChangeGod from '../../Sim/SimulationEvents/GodChange';
import { CacheGods } from '../VariablesAndData';
/**
* This functions caches the cps effect of each God in slot 1, 2 or 3
*/
export default function CachePantheonGods() {
for (let god = 0; god < 11; god += 1) {
for (let slot = 0; slot < 3; slot += 1) {
CacheGods[god][slot] = CalculateChangeGod(god, slot);
}
}
}

View File

@@ -0,0 +1,100 @@
/** Section: Functions related to caching income */
import { CMOptions } from '../../Config/VariablesAndData';
import BuildingGetPrice from '../../Sim/SimulationEvents/BuyBuilding';
import BuyBuildingsBonusIncome from '../../Sim/SimulationEvents/BuyBuildingBonusIncome';
import BuyUpgradesBonusIncome from '../../Sim/SimulationEvents/BuyUpgrades';
import {
CacheAverageGainBank,
CacheAverageGainWrink,
CacheAverageGainWrinkFattest,
CacheDoRemakeBuildPrices,
CacheObjects1,
CacheObjects10,
CacheObjects100,
CacheUpgrades,
} from '../VariablesAndData';
/**
* This functions starts the calculation/simulation of the bonus income of buildings
* It is called by CM.Cache.CacheIncome()
* @param {amount} amount Amount to be bought
* @parem {string} target The target Cache object ("Objects1", "Objects10" or "Objects100")
*/
function CacheBuildingIncome(amount) {
const result = {};
Object.keys(Game.Objects).forEach((i) => {
result[i] = {};
result[i].bonus = BuyBuildingsBonusIncome(i, amount);
if (amount !== 1) {
CacheDoRemakeBuildPrices = 1; // eslint-disable-line no-unused-vars
}
});
return result;
}
/**
* This functions starts the calculation/simulation of the bonus income of upgrades
* It is called by CM.Cache.CacheIncome()
*/
function CacheUpgradeIncome() {
CacheUpgrades = [];
Object.keys(Game.Upgrades).forEach((i) => {
const bonusIncome = BuyUpgradesBonusIncome(i);
if (i === 'Elder Pledge') {
CacheUpgrades[i] = { bonus: Game.cookiesPs - CacheAverageGainBank };
if (CMOptions.CalcWrink === 1)
CacheUpgrades[i].bonus -= CacheAverageGainWrink;
else if (CMOptions.CalcWrink === 2)
CacheUpgrades[i].bonus -= CacheAverageGainWrinkFattest;
if (!Number.isFinite(CacheUpgrades[i].bonus)) CacheUpgrades[i].bonus = 0;
} else {
CacheUpgrades[i] = {};
if (bonusIncome[0]) CacheUpgrades[i].bonus = bonusIncome[0];
if (bonusIncome[1]) CacheUpgrades[i].bonusMouse = bonusIncome[1];
}
});
}
/**
* This functions caches the price of each building and stores it in the cache
*/
export function CacheBuildingsPrices() {
Object.keys(Game.Objects).forEach((i) => {
CacheObjects1[i].price = BuildingGetPrice(
Game.Objects[i],
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,
);
});
}
/**
* This functions caches the income gain of each building and upgrade and stores it in the cache
* It is called by CM.Main.Loop() and CM.Cache.InitCache()
*/
export function CacheIncome() {
// Simulate Building Buys for 1, 10 and 100 amount
CacheObjects1 = CacheBuildingIncome(1);
CacheObjects10 = CacheBuildingIncome(10);
CacheObjects100 = CacheBuildingIncome(100);
// Simulate Upgrade Buys
CacheUpgradeIncome();
}

View File

@@ -0,0 +1,136 @@
import GetCPSBuffMult from '../CPS/GetCPSBuffMult';
import {
CacheChainFrenzyMaxReward,
CacheChainFrenzyRequired,
CacheChainFrenzyRequiredNext,
CacheChainFrenzyWrathMaxReward,
CacheChainFrenzyWrathRequired,
CacheChainFrenzyWrathRequiredNext,
CacheChainMaxReward,
CacheChainRequired,
CacheChainRequiredNext,
CacheChainWrathMaxReward,
CacheChainWrathRequired,
CacheChainWrathRequiredNext,
CacheDragonsFortuneMultAdjustment,
CacheGoldenCookiesMult,
CacheNoGoldSwitchCookiesPS,
CacheWrathCookiesMult,
} from '../VariablesAndData';
/**
* This functions calculates the max possible payout given a set of variables
* It is called by CM.Disp.CreateStatsChainSection() and CM.Cache.CacheChain()
* @param {number} digit Number of Golden Cookies in chain
* @param {number} maxPayout Maximum payout
* @param {number} mult Multiplier
* @returns [{number, number, number}] Total cookies earned, cookie needed for this and next level
*/
export function MaxChainCookieReward(digit, maxPayout, mult) {
let totalFromChain = 0;
let moni = 0;
let nextMoni = 0;
let nextRequired = 0;
let chain =
1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10);
while (nextMoni < maxPayout * mult) {
moni = Math.max(
digit,
Math.min(
Math.floor((1 / 9) * 10 ** chain * digit * mult),
maxPayout * mult,
),
);
nextMoni = Math.max(
digit,
Math.min(
Math.floor((1 / 9) * 10 ** (chain + 1) * digit * mult),
maxPayout * mult,
),
);
nextRequired = Math.floor((1 / 9) * 10 ** (chain + 1) * digit * mult);
totalFromChain += moni;
chain += 1;
}
return [totalFromChain, moni, nextRequired];
}
/**
* This functions caches data related to Chain Cookies reward from Golden Cookioes
* It is called by CM.Main.Loop() upon changes to cps and CM.Cache.InitCache()
* @global [{number, number}] CM.Cache.ChainMaxReward Total cookies earned, and cookies needed for next level for normal chain
* @global {number} CM.Cache.ChainRequired Cookies needed for maximum reward for normal chain
* @global {number} CM.Cache.ChainRequiredNext Total cookies needed for next level for normal chain
* @global [{number, number}] CM.Cache.ChainMaxWrathReward Total cookies earned, and cookies needed for next level for wrath chain
* @global {number} CM.Cache.ChainWrathRequired Cookies needed for maximum reward for wrath chain
* @global {number} CM.Cache.ChainWrathRequiredNext Total cookies needed for next level for wrath chain
* @global [{number, number}] CM.Cache.ChainFrenzyMaxReward Total cookies earned, and cookies needed for next level for normal frenzy chain
* @global {number} CM.Cache.ChainFrenzyRequired Cookies needed for maximum reward for normal frenzy chain
* @global {number} CM.Cache.ChainFrenzyRequiredNext Total cookies needed for next level for normal frenzy chain
* @global [{number, number}] CM.Cache.ChainFrenzyWrathMaxReward Total cookies earned, and cookies needed for next level for wrath frenzy chain
* @global {number} CM.Cache.ChainFrenzyWrathRequired Cookies needed for maximum reward for wrath frenzy chain
* @global {number} CM.Cache.ChainFrenzyWrathRequiredNext Total cookies needed for next level for wrath frenzy chain
*/
export function CacheChain() {
let maxPayout =
CacheNoGoldSwitchCookiesPS *
60 *
60 *
6 *
CacheDragonsFortuneMultAdjustment;
// Removes effect of Frenzy etc.
const cpsBuffMult = GetCPSBuffMult();
if (cpsBuffMult > 0) maxPayout /= cpsBuffMult;
else maxPayout = 0;
CacheChainMaxReward = MaxChainCookieReward(
7,
maxPayout,
CacheGoldenCookiesMult,
);
CacheChainRequired = (CacheChainMaxReward[1] * 2) / CacheGoldenCookiesMult; // eslint-disable-line no-unused-vars
CacheChainRequiredNext = // eslint-disable-line no-unused-vars
CacheChainMaxReward[2] / 60 / 60 / 6 / CacheDragonsFortuneMultAdjustment;
CacheChainWrathMaxReward = MaxChainCookieReward(
6,
maxPayout,
CacheWrathCookiesMult,
);
CacheChainWrathRequired = // eslint-disable-line no-unused-vars
(CacheChainWrathMaxReward[1] * 2) / CacheWrathCookiesMult;
CacheChainWrathRequiredNext = // eslint-disable-line no-unused-vars
CacheChainWrathMaxReward[2] /
60 /
60 /
6 /
CacheDragonsFortuneMultAdjustment;
CacheChainFrenzyMaxReward = MaxChainCookieReward(
7,
maxPayout * 7,
CacheGoldenCookiesMult,
);
CacheChainFrenzyRequired = // eslint-disable-line no-unused-vars
(CacheChainFrenzyMaxReward[1] * 2) / CacheGoldenCookiesMult;
CacheChainFrenzyRequiredNext = // eslint-disable-line no-unused-vars
CacheChainFrenzyMaxReward[2] /
60 /
60 /
6 /
CacheDragonsFortuneMultAdjustment;
CacheChainFrenzyWrathMaxReward = MaxChainCookieReward(
6,
maxPayout * 7,
CacheWrathCookiesMult,
);
CacheChainFrenzyWrathRequired = // eslint-disable-line no-unused-vars
(CacheChainFrenzyWrathMaxReward[1] * 2) / CacheWrathCookiesMult;
CacheChainFrenzyWrathRequiredNext = // eslint-disable-line no-unused-vars
CacheChainFrenzyWrathMaxReward[2] /
60 /
60 /
6 /
CacheDragonsFortuneMultAdjustment;
}

View File

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

View File

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

View File

@@ -0,0 +1,16 @@
import { CacheSeaSpec } from '../VariablesAndData';
/**
* This functions caches the reward of popping a reindeer
* It is called by CM.Main.Loop() and CM.Cache.InitCache()
* @global {number} CM.Cache.SeaSpec The reward for popping a reindeer
*/
export default function CacheSeasonSpec() {
if (Game.season === 'christmas') {
let val = Game.cookiesPs * 60;
if (Game.hasBuff('Elder frenzy')) val *= 0.5;
if (Game.hasBuff('Frenzy')) val *= 0.75;
CacheSeaSpec = Math.max(25, val);
if (Game.Has('Ho ho ho-flavored frosting')) CacheSeaSpec *= 2; // eslint-disable-line no-unused-vars
}
}

90
src/Cache/Stats/Stats.js Normal file
View File

@@ -0,0 +1,90 @@
/** Functions related to Caching stats */
import SimHas from '../../Sim/ReplacedGameFunctions/SimHas';
import GetCPSBuffMult from '../CPS/GetCPSBuffMult';
import {
CacheConjure,
CacheConjureReward,
CacheDragonsFortuneMultAdjustment,
CacheEdifice,
CacheEdificeBuilding,
CacheGoldenCookiesMult,
CacheLucky,
CacheLuckyFrenzy,
CacheLuckyReward,
CacheLuckyRewardFrenzy,
CacheLuckyWrathReward,
CacheLuckyWrathRewardFrenzy,
CacheNoGoldSwitchCookiesPS,
CacheWrathCookiesMult,
} from '../VariablesAndData';
/**
* This functions caches variables related to the stats page
*/
export function CacheStatsCookies() {
CacheLucky = (CacheNoGoldSwitchCookiesPS * 900) / 0.15;
CacheLucky *= CacheDragonsFortuneMultAdjustment;
const cpsBuffMult = GetCPSBuffMult();
if (cpsBuffMult > 0) CacheLucky /= cpsBuffMult;
else CacheLucky = 0;
CacheLuckyReward = CacheGoldenCookiesMult * (CacheLucky * 0.15) + 13; // eslint-disable-line no-unused-vars
CacheLuckyWrathReward = CacheWrathCookiesMult * (CacheLucky * 0.15) + 13; // eslint-disable-line no-unused-vars
CacheLuckyFrenzy = CacheLucky * 7;
CacheLuckyRewardFrenzy = // eslint-disable-line no-unused-vars
CacheGoldenCookiesMult * (CacheLuckyFrenzy * 0.15) + 13;
CacheLuckyWrathRewardFrenzy = // eslint-disable-line no-unused-vars
CacheWrathCookiesMult * (CacheLuckyFrenzy * 0.15) + 13;
CacheConjure = CacheLucky * 2;
CacheConjureReward = CacheConjure * 0.15; // eslint-disable-line no-unused-vars
CacheEdifice = 0;
let max = 0;
let n = 0;
Object.keys(Game.Objects).forEach((i) => {
if (Game.Objects[i].amount > max) max = Game.Objects[i].amount;
if (Game.Objects[i].amount > 0) n += 1;
});
Object.keys(Game.Objects).forEach((i) => {
if (
(Game.Objects[i].amount < max || n === 1) &&
Game.Objects[i].amount < 400 &&
Game.Objects[i].price * 2 > CacheEdifice
) {
CacheEdifice = Game.Objects[i].price * 2;
CacheEdificeBuilding = i; // eslint-disable-line no-unused-vars
}
});
}
/**
* This functions calculates the multipliers of Golden and Wrath cookie rewards
*/
export function CacheGoldenAndWrathCookiesMults() {
let goldenMult = 1;
let wrathMult = 1;
let mult = 1;
// Factor auras and upgrade in mults
if (SimHas('Green yeast digestives')) mult *= 1.01;
if (SimHas('Dragon fang')) mult *= 1.03;
goldenMult *= 1 + Game.auraMult('Ancestral Metamorphosis') * 0.1;
goldenMult *= Game.eff('goldenCookieGain');
wrathMult *= 1 + Game.auraMult('Unholy Dominion') * 0.1;
wrathMult *= Game.eff('wrathCookieGain');
// Calculate final golden and wrath multipliers
CacheGoldenCookiesMult = mult * goldenMult;
CacheWrathCookiesMult = mult * wrathMult;
// Calculate Dragon's Fortune multiplier adjustment:
// 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.
// Otherwise, the aura effect will be factored in the base CPS making the multiplier not requiring adjustment.
CacheDragonsFortuneMultAdjustment = 1;
if (Game.shimmerTypes.golden.n === 0) {
CacheDragonsFortuneMultAdjustment *=
1 + Game.auraMult("Dragon's Fortune") * 1.23;
}
}

View File

@@ -0,0 +1,117 @@
/* eslint-disable prefer-const */
export let CacheDragonAura = 0;
export let CacheDragonAura2 = 0;
export let CacheLastDragonLevel = 0;
export let CacheCostDragonUpgrade = 0;
export let CacheLucky = 0;
export let CacheLuckyReward = 0;
export let CacheLuckyWrathReward = 0;
export let CacheLuckyFrenzy = 0;
export let CacheLuckyRewardFrenzy = 0;
export let CacheLuckyWrathRewardFrenzy = 0;
export let CacheConjure = 0;
export let CacheConjureReward = 0;
export let CacheEdifice = 0;
export let CacheEdificeBuilding = 0;
export let CacheNoGoldSwitchCookiesPS = 0;
export let CacheDragonsFortuneMultAdjustment = 1;
export let CacheGoldenCookiesMult = 1;
export let CacheWrathCookiesMult = 1;
export let CacheHCPerSecond = 0;
export let CacheCentEgg = 0;
export let CacheSeaSpec = 0;
export let CacheLastChoEgg = 0;
export let CacheObjects1 = {};
export let CacheObjects10 = {};
export let CacheObjects100 = {};
export let CacheWrinklersTotal = 0;
export let CacheWrinklersNormal = 0;
export let CacheWrinklersFattest = [0, null];
export let CacheCurrWrinklerCPSMult = 0;
export let CacheCurrWrinklerCount = 0;
export let CacheUpgrades = {};
export let CacheAverageClicks = {};
export let CacheAverageCookiesFromClicks;
export let CacheMissingUpgrades = {};
export let CacheMissingUpgradesPrestige = {};
export let CacheMissingUpgradesCookies = {};
export let CacheChainRequired = 0;
export let CacheChainRequiredNext = 0;
export let CacheChainMaxReward = [];
export let CacheChainWrathRequired = 0;
export let CacheChainWrathRequiredNext = 0;
export let CacheChainWrathMaxReward = [];
export let CacheChainFrenzyRequired = 0;
export let CacheChainFrenzyRequiredNext = 0;
export let CacheChainFrenzyMaxReward = [];
export let CacheChainFrenzyWrathRequired = 0;
export let CacheChainFrenzyWrathRequiredNext = 0;
export let CacheChainFrenzyWrathMaxReward = [];
export let CacheRealCookiesEarned = 0;
export let CacheAvgCPSWithChoEgg = 0;
export let CacheSpawnedGoldenShimmer = {};
export let CacheSeasonPopShimmer = {};
export let CacheTimeTillNextPrestige = 0;
/** Stores lowest PP value */
export let CacheMinPP = 0;
/** Stores all PP values of all buildings for all buy settings (1, 10, 100) */
export let CachePPArray = [];
export let CacheGoldenShimmersByID = {};
export let CacheSellForChoEgg = 0;
export let CookiesDiff;
export let WrinkDiff;
export let WrinkFattestDiff;
export let ChoEggDiff;
export let ClicksDiff;
export let HeavenlyChipsDiff;
export let CacheLastCPSCheck;
export let CacheLastCookies;
export let CacheLastWrinkCookies;
export let CacheLastWrinkFattestCookies;
export let CacheLastClicks;
export let CacheAverageGainBank;
export let CacheAverageGainWrink;
export let CacheAverageGainWrinkFattest;
export let CacheAverageGainChoEgg;
export let CacheAverageCPS;
export let CacheLastHeavenlyCheck;
export let CacheLastHeavenlyChips;
export let CacheDoRemakeBuildPrices;
export let CacheHadBuildAura;
/** Store the CPS effect of each god if it was put into each slot */
export let CacheGods = {
0: [0, 0, 0],
1: [0, 0, 0],
2: [0, 0, 0],
3: [0, 0, 0],
4: [0, 0, 0],
5: [0, 0, 0],
6: [0, 0, 0],
7: [0, 0, 0],
8: [0, 0, 0],
9: [0, 0, 0],
10: [0, 0, 0],
};

View File

@@ -0,0 +1,41 @@
/** Caches data related to Wrinklers */
import { SimObjects } from '../../Sim/VariablesAndData';
import {
CacheWrinklersFattest,
CacheWrinklersNormal,
CacheWrinklersTotal,
} from '../VariablesAndData';
/**
* This functions caches data related to Wrinklers
* It is called by CM.Cache.LoopCache() and CM.Cache.InitCache()
* @global {number} CM.Cache.WrinklersTotal The cookies of all wrinklers
* @global {number} CM.Cache.WrinklersNormal The cookies of all normal wrinklers
* @global {[{number}, {number}]} CM.Cache.WrinklersFattest A list containing the cookies and the id of the fattest non-shiny wrinkler
*/
export default function CacheWrinklers() {
CacheWrinklersTotal = 0;
CacheWrinklersNormal = 0;
CacheWrinklersFattest = [0, null];
for (let i = 0; i < Game.wrinklers.length; i++) {
let { sucked } = Game.wrinklers[i];
let toSuck = 1.1;
if (Game.Has('Sacrilegious corruption')) toSuck *= 1.05;
if (Game.wrinklers[i].type === 1) toSuck *= 3; // Shiny wrinklers
sucked *= toSuck;
if (Game.Has('Wrinklerspawn')) sucked *= 1.05;
if (SimObjects.Temple.minigameLoaded) {
const godLvl = Game.hasGod('scorn');
if (godLvl === 1) sucked *= 1.15;
else if (godLvl === 2) sucked *= 1.1;
else if (godLvl === 3) sucked *= 1.05;
}
CacheWrinklersTotal += sucked; // eslint-disable-line no-unused-vars
if (Game.wrinklers[i].type === 0) {
CacheWrinklersNormal += sucked; // eslint-disable-line no-unused-vars
if (sucked > CacheWrinklersFattest[0])
CacheWrinklersFattest = [sucked, i];
}
}
}

View File

@@ -1,175 +0,0 @@
/**
* Config *
*/
/**
* Section: Functions related to saving, loading and restoring configs */
/**
* This function saves the config of CookieMonster without saving any of the other save-data
* This allows saving in between the autosave intervals
* It is called by CM.Config.LoadConfig(), CM.Config.RestoreDefault(), CM.Config.ToggleConfig(),
* CM.ToggleConfigVolume() and changes in options with type "url", "color" or "numscale"
*/
CM.Config.SaveConfig = function () {
const saveString = b64_to_utf8(unescape(localStorage.getItem('CookieClickerGame')).split('!END!')[0]);
const CookieMonsterSave = saveString.match(/CookieMonster.*(;|$)/);
if (CookieMonsterSave !== null) {
const newSaveString = saveString.replace(CookieMonsterSave[0], `CookieMonster:${CM.save()}`);
localStorage.setItem('CookieClickerGame', escape(`${utf8_to_b64(newSaveString)}!END!`));
}
};
/**
* This function loads the config of CookieMonster saved in localStorage and loads it into CM.Options
* It is called by CM.Main.DelayInit() and CM.Config.RestoreDefault()
*/
CM.Config.LoadConfig = function (settings) {
// This removes cookies left from earlier versions of CookieMonster
if (typeof localStorage.CMConfig !== 'undefined') {
delete localStorage.CMConfig;
}
if (settings !== undefined) {
CM.Options = settings;
// Check values
let mod = false;
for (const i in CM.Data.ConfigDefault) {
if (typeof CM.Options[i] === 'undefined') {
mod = true;
CM.Options[i] = CM.Data.ConfigDefault[i];
} else if (i !== 'Header' && i !== 'Colors') {
if (i.indexOf('SoundURL') === -1) {
if (!(CM.Options[i] > -1 && CM.Options[i] < CM.Data.Config[i].label.length)) {
mod = true;
CM.Options[i] = CM.Data.ConfigDefault[i];
}
} else if (typeof CM.Options[i] !== 'string') { // Sound URLs
mod = true;
CM.Options[i] = CM.Data.ConfigDefault[i];
}
} else if (i === 'Header') {
for (const j in CM.Data.ConfigDefault.Header) {
if (typeof CM.Options[i][j] === 'undefined' || !(CM.Options[i][j] > -1 && CM.Options[i][j] < 2)) {
mod = true;
CM.Options[i][j] = CM.Data.ConfigDefault[i][j];
}
}
} else { // Colors
for (const j in CM.Data.ConfigDefault.Colors) {
if (typeof CM.Options[i][j] === 'undefined' || typeof CM.Options[i][j] !== 'string') {
mod = true;
CM.Options[i][j] = CM.Data.ConfigDefault[i][j];
}
}
}
}
if (mod) CM.Config.SaveConfig();
CM.Main.Loop(); // Do loop once
for (const i in CM.Data.ConfigDefault) {
if (i !== 'Header' && typeof CM.Data.Config[i].func !== 'undefined') {
CM.Data.Config[i].func();
}
}
} else { // Default values
CM.Config.RestoreDefault();
}
};
/**
* This function reloads and resaves the default config as stored in CM.Data.ConfigDefault
* It is called by resDefBut.onclick loaded in the options page or by CM.Config.LoadConfig if no localStorage is found
*/
CM.Config.RestoreDefault = function () {
CM.Config.LoadConfig(CM.Data.ConfigDefault);
CM.Config.SaveConfig();
Game.UpdateMenu();
};
/**
* Section: Functions related to toggling or changing configs */
/**
* This function toggles options by incrementing them with 1 and handling changes
* It is called by the onclick event of options of the "bool" type
* @param {string} config The name of the option
*/
CM.Config.ToggleConfig = function (config) {
CM.Options[config]++;
if (CM.Options[config] === CM.Data.Config[config].label.length) {
CM.Options[config] = 0;
if (CM.Data.Config[config].toggle) l(CM.Config.ConfigPrefix + config).className = 'option off';
} else l(CM.Config.ConfigPrefix + config).className = 'option';
if (typeof CM.Data.Config[config].func !== 'undefined') {
CM.Data.Config[config].func();
}
l(CM.Config.ConfigPrefix + config).innerHTML = CM.Data.Config[config].label[CM.Options[config]];
CM.Config.SaveConfig();
};
/**
* This function sets the value of the specified volume-option and updates the display in the options menu
* It is called by the oninput and onchange event of "vol" type options
* @param {string} config The name of the option
*/
CM.Config.ToggleConfigVolume = function (config) {
if (l(`slider${config}`) !== null) {
l(`slider${config}right`).innerHTML = `${l(`slider${config}`).value}%`;
CM.Options[config] = Math.round(l(`slider${config}`).value);
}
CM.Config.SaveConfig();
};
/**
* This function toggles header options by incrementing them with 1 and handling changes
* It is called by the onclick event of the +/- next to headers
* @param {string} config The name of the header
*/
CM.Config.ToggleHeader = function (config) {
CM.Options.Header[config]++;
if (CM.Options.Header[config] > 1) CM.Options.Header[config] = 0;
CM.Config.SaveConfig();
};
/**
* Section: Functions related to notifications */
/**
* This function checks if the user has given permissions for notifications
* It is called by a change in any of the notification options
* Note that most browsers will stop asking if the user has ignored the prompt around 6 times
* @param {number} ToggleOnOff A number indicating whether the option has been turned off (0) or on (1)
*/
CM.Config.CheckNotificationPermissions = function (ToggleOnOff) {
if (ToggleOnOff === 1) {
// Check if browser support Promise version of Notification Permissions
const checkNotificationPromise = function () {
try {
Notification.requestPermission().then();
} catch (e) {
return false;
}
return true;
};
// Check if the browser supports notifications and which type
if (!('Notification' in window)) {
console.log('This browser does not support notifications.');
} else if (checkNotificationPromise()) {
Notification.requestPermission().then();
} else {
Notification.requestPermission();
}
}
};
/**
* Section: Variables used in Config functions */
/**
* Used to name certain DOM elements and refer to them
*/
CM.Config.ConfigPrefix = 'CMConfig';

View File

@@ -0,0 +1,30 @@
/**
* This function checks if the user has given permissions for notifications
* It is called by a change in any of the notification options
* Note that most browsers will stop asking if the user has ignored the prompt around 6 times
* @param {number} ToggleOnOff A number indicating whether the option has been turned off (0) or on (1)
*/
function CheckNotificationPermissions(ToggleOnOff) {
if (ToggleOnOff === 1) {
// Check if browser support Promise version of Notification Permissions
const checkNotificationPromise = function () {
try {
Notification.requestPermission().then();
} catch (e) {
return false;
}
return true;
};
// Check if the browser supports notifications and which type
if (!('Notification' in window)) {
console.log('This browser does not support notifications.'); // eslint-disable-line no-console
} else if (checkNotificationPromise()) {
Notification.requestPermission().then();
} else {
Notification.requestPermission();
}
}
}
export default CheckNotificationPermissions;

View File

@@ -0,0 +1,83 @@
import ConfigDefault from '../../Data/SettingsDefault';
import ConfigData from '../../Data/SettingsData';
import { CMOptions } from '../VariablesAndData';
import save from '../../InitSaveLoad/save';
import CMLoopHook from '../../Main/LoopHook';
import UpdateColours from '../../Disp/HelperFunctions/UpdateColours';
/** Functions related to saving, loading and restoring all settings */
/**
* This function saves the config of CookieMonster without saving any of the other save-data
* This allows saving in between the autosave intervals
* It is called by CM.Config.LoadConfig(), CM.Config.RestoreDefault(), CM.Config.ToggleConfig(),
* CM.ToggleConfigVolume() and changes in options with type "url", "color" or "numscale"
*/
export function SaveConfig() {
const saveString = b64_to_utf8(
unescape(localStorage.getItem('CookieClickerGame')).split('!END!')[0],
);
const CookieMonsterSave = saveString.match(/CookieMonster.*(;|$)/);
if (CookieMonsterSave !== null) {
const newSaveString = saveString.replace(
CookieMonsterSave[0],
`CookieMonster:${save()}`,
);
localStorage.setItem(
'CookieClickerGame',
escape(`${utf8_to_b64(newSaveString)}!END!`),
);
}
}
/**
* This function loads the config of CookieMonster saved in localStorage and loads it into CMOptions
* It is called by CM.Main.DelayInit() and CM.Config.RestoreDefault()
*/
export function LoadConfig(settings) {
// This removes cookies left from earlier versions of CookieMonster
if (typeof localStorage.CMConfig !== 'undefined') {
delete localStorage.CMConfig;
}
if (settings !== undefined) {
CMOptions = settings;
if (typeof CMOptions.Colors !== 'undefined') {
delete CMOptions.Colors;
}
if (typeof CMOptions.Colours !== 'undefined') {
delete CMOptions.Colours;
}
// Check values
let mod = false;
Object.keys(ConfigDefault).forEach((i) => {
if (typeof CMOptions[i] === 'undefined') {
mod = true;
CMOptions[i] = ConfigDefault[i];
} else if (i === 'Header') {
Object.keys(ConfigDefault.Header).forEach((j) => {
if (
typeof CMOptions[i][j] === 'undefined' ||
!(CMOptions[i][j] > -1 && CMOptions[i][j] < 2)
) {
mod = true;
CMOptions[i][j] = ConfigDefault[i][j];
}
});
}
});
if (mod) SaveConfig();
CMLoopHook(); // Do loop once
Object.keys(ConfigDefault).forEach((i) => {
if (i !== 'Header' && typeof ConfigData[i].func !== 'undefined') {
ConfigData[i].func();
}
});
} else {
// Default values
LoadConfig(ConfigDefault);
}
Game.UpdateMenu();
UpdateColours();
}

View File

@@ -0,0 +1,61 @@
/** Called by the "func" of individual settings */
import UpdateBackground from '../Disp/HelperFunctions/UpdateBackground';
import { CMOptions } from './VariablesAndData';
/**
* This function changes the position of both the bottom and timer bar
*/
export function UpdateBotTimerBarPosition() {
if (
CMOptions.BotBar === 1 &&
CMOptions.TimerBar === 1 &&
CMOptions.TimerBarPos === 1
) {
l('CMBotBar').style.bottom = l('CMTimerBar').style.height;
l('game').style.bottom = `${
Number(l('CMTimerBar').style.height.replace('px', '')) + 70
}px`;
} 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) {
l('sectionLeft').style.top = l('CMTimerBar').style.height;
} else {
l('sectionLeft').style.top = '';
}
UpdateBackground();
}
/**
* This function changes the visibility of the timer bar
*/
export function ToggleTimerBar() {
if (CMOptions.TimerBar === 1) l('CMTimerBar').style.display = '';
else l('CMTimerBar').style.display = 'none';
UpdateBotTimerBarPosition();
}
/**
* This function changes the position of the timer bar
*/
export function ToggleTimerBarPos() {
if (CMOptions.TimerBarPos === 0) {
l('CMTimerBar').style.width = '30%';
l('CMTimerBar').style.bottom = '';
l('game').insertBefore(l('CMTimerBar'), l('sectionLeft'));
} else {
l('CMTimerBar').style.width = '100%';
l('CMTimerBar').style.bottom = '0px';
l('wrapper').appendChild(l('CMTimerBar'));
}
UpdateBotTimerBarPosition();
}

View File

@@ -0,0 +1,55 @@
import ConfigData from '../Data/SettingsData';
import { SaveConfig } from './SaveLoadReload/SaveLoadReloadSettings';
import { CMOptions } from './VariablesAndData';
/** Functions related to toggling or changing an individual setting */
/** Used to name certain DOM or outside facing elements and refer to them */
export const ConfigPrefix = 'CMConfig';
/**
* This function toggles options by incrementing them with 1 and handling changes
* It is called by the onclick event of options of the "bool" type
* @param {string} config The name of the option
*/
export function ToggleConfig(config) {
CMOptions[config] += 1;
if (CMOptions[config] === ConfigData[config].label.length) {
CMOptions[config] = 0;
if (ConfigData[config].toggle)
l(ConfigPrefix + config).className = 'option off';
} else l(ConfigPrefix + config).className = 'option';
if (typeof ConfigData[config].func !== 'undefined') {
ConfigData[config].func();
}
l(ConfigPrefix + config).innerHTML =
ConfigData[config].label[CMOptions[config]];
SaveConfig();
}
/**
* This function sets the value of the specified volume-option and updates the display in the options menu
* It is called by the oninput and onchange event of "vol" type options
* @param {string} config The name of the option
*/
export function ToggleConfigVolume(config) {
if (l(`slider${config}`) !== null) {
l(`slider${config}right`).innerHTML = `${l(`slider${config}`).value}%`;
CMOptions[config] = Math.round(l(`slider${config}`).value);
}
SaveConfig();
}
/**
* This function toggles header options by incrementing them with 1 and handling changes
* It is called by the onclick event of the +/- next to headers
* @param {string} config The name of the header
*/
export function ToggleHeader(config) {
CMOptions.Header[config] += 1;
if (CMOptions.Header[config] > 1) CMOptions.Header[config] = 0;
SaveConfig();
}

View File

@@ -0,0 +1,17 @@
import { UpdateBotBar } from '../../Disp/InfoBars/BottomBar';
import { UpdateBotTimerBarPosition } from '../SpecificToggles';
import { CMOptions } from '../VariablesAndData';
/**
* This function toggle the bottom bar
* It is called by CM.Disp.UpdateAscendState() and a change in CMOptions.BotBar
*/
export default function ToggleBotBar() {
if (CMOptions.BotBar === 1) {
l('CMBotBar').style.display = '';
UpdateBotBar();
} else {
l('CMBotBar').style.display = 'none';
}
UpdateBotTimerBarPosition();
}

View File

@@ -0,0 +1,12 @@
import { CMSayTime } from '../../Disp/VariablesAndData';
import { BackupFunctions } from '../../Main/VariablesAndData';
import { CMOptions } from '../VariablesAndData';
/**
* This function changes some of the time-displays in the game to be more detailed
* It is called by a change in CM.Options.DetailedTime
*/
export default function ToggleDetailedTime() {
if (CMOptions.DetailedTime === 1) Game.sayTime = CMSayTime;
else Game.sayTime = BackupFunctions.sayTime;
}

View File

@@ -0,0 +1,13 @@
import { FavouriteSettings } from '../../Disp/VariablesAndData';
/**
* This function toggles whether a setting is part of the favourites section in setting or not
* @param {string} config The name of the toggleable config option
*/
export default function ToggleFavouriteSetting(config) {
if (FavouriteSettings.includes(config))
FavouriteSettings = FavouriteSettings.filter(function (ele) {
return ele !== config;
});
else FavouriteSettings.push(config);
}

View File

@@ -0,0 +1,20 @@
import { CacheGoldenShimmersByID } from '../../Cache/VariablesAndData';
import { GCTimers } from '../../Disp/VariablesAndData';
import { CMOptions } from '../VariablesAndData';
/**
* This function toggles GC Timers are visible
* It is called by a change in CM.Options.GCTimer
*/
export default function ToggleGCTimer() {
if (CMOptions.GCTimer === 1) {
Object.keys(GCTimers).forEach((i) => {
GCTimers[i].style.display = 'block';
GCTimers[i].style.left = CacheGoldenShimmersByID[i].l.style.left;
GCTimers[i].style.top = CacheGoldenShimmersByID[i].l.style.top;
});
} else {
// eslint-disable-next-line no-return-assign
Object.keys(GCTimers).forEach((i) => (GCTimers[i].style.display = 'none'));
}
}

View File

@@ -0,0 +1,13 @@
import { CMOptions } from '../VariablesAndData';
/**
* This function updates the display setting of the two objects created by CM.Disp.CreateWrinklerButtons()
* It is called by changes in CM.Options.WrinklerButtons
*/
export default function ToggleSectionHideButtons() {
if (CMOptions.HideSectionsButtons) {
l('CMSectionHidButtons').style.display = '';
} else {
l('CMSectionHidButtons').style.display = 'none';
}
}

View File

@@ -0,0 +1,20 @@
import { CMOptions } from '../VariablesAndData';
/**
* This function toggles the position of the warnings created by CM.Disp.TooltipCreateWarningSection()
* It is called by a change in CM.Options.ToolWarnPos
* and upon creation of the warning tooltip by CM.Disp.UpdateTooltipWarnings()
*/
export default function ToggleToolWarnPos() {
if (l('CMDispTooltipWarningParent') !== null) {
if (CMOptions.ToolWarnPos === 0) {
l('CMDispTooltipWarningParent').style.top = 'auto';
l('CMDispTooltipWarningParent').style.margin = '4px -4px';
l('CMDispTooltipWarningParent').style.padding = '3px 4px';
} else {
l('CMDispTooltipWarningParent').style.right = 'auto';
l('CMDispTooltipWarningParent').style.margin = '4px';
l('CMDispTooltipWarningParent').style.padding = '4px 3px';
}
}
}

View File

@@ -0,0 +1,22 @@
import UpdateUpgrades from '../../Disp/BuildingsUpgrades/Upgrades';
import { CMOptions } from '../VariablesAndData';
/**
* This function toggles the upgrade bar and the colours of upgrades
* It is called by a change in CM.Options.UpBarColor
*/
export default function ToggleUpgradeBarAndColor() {
if (CMOptions.UpBarColor === 1) {
// Colours and bar on
l('CMUpgradeBar').style.display = '';
UpdateUpgrades();
} else if (CMOptions.UpBarColor === 2) {
// Colours on and bar off
l('CMUpgradeBar').style.display = 'none';
UpdateUpgrades();
} else {
// Colours and bar off
l('CMUpgradeBar').style.display = 'none';
Game.RebuildUpgrades();
}
}

View File

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

View File

@@ -0,0 +1,15 @@
import { CMOptions } from '../VariablesAndData';
/**
* This function updates the display setting of the two objects created by CM.Disp.CreateWrinklerButtons()
* It is called by changes in CM.Options.WrinklerButtons
*/
export default function ToggleWrinklerButtons() {
if (CMOptions.WrinklerButtons && Game.elderWrath) {
l('PopAllNormalWrinklerButton').style.display = '';
l('PopFattestWrinklerButton').style.display = '';
} else {
l('PopAllNormalWrinklerButton').style.display = 'none';
l('PopFattestWrinklerButton').style.display = 'none';
}
}

View File

@@ -0,0 +1,2 @@
export let CMOptions = {}; // eslint-disable-line prefer-const
export const ConfigPrefix = 'CMConfig';

11
src/CookieMonster.js Normal file
View File

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

View File

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

97
src/Data/Gamedata.js Normal file
View File

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

39
src/Data/Moddata.js Normal file
View File

@@ -0,0 +1,39 @@
/** Data related directly to Cookie Monster */
export const VersionMajor = '2.031';
export const VersionMinor = '7';
/** Information about Cookie Monster to be displayed in the info section */
export const ModDescription = `<div class="listing">
<a href="https://github.com/Aktanusa/CookieMonster" target="blank">Cookie Monster</a>
offers a wide range of tools and statistics to enhance your game experience.
It is not a cheat interface although it does offer helpers for golden cookies and such, everything can be toggled off at will to only leave how much information you want.</br>
Progess on new updates and all previous release notes can be found on the GitHub page linked above!</br>
Please also report any bugs you may find over there!</br>
</div>
`;
/** Latest releasenotes of Cookie Monster to be displayed in the info section */
export const LatestReleaseNotes = `<div class="listing">
These are the release notes for the latest update (v 2.031.7).</br>
</br>
This update implements the following functions:</br>
- Updated the ordering and description of all settings of Cookie Monster</br>
- Colours of Flash notifications can now be set by the user</br>
- You can now select a number of settings to be your 'favourite'. They will be displayed at the top of all other settings in a new section. This functionality is toggleable and you can find it in the miscellaneous section</br>
- The statistics page now shows cookies earned by clicking for a selected time period</br>
- The statistics page can now show missing normal achievements, this can be toggled in the settings</br>
</br>
This update fixes the following bugs:</br>
- Fixed some typo's</br>
- No longer show the wrinkler pop buttons when wrinklers can't spawn</br>
- Fixed incorrect calculation of plant maturity for relevant tooltips</br>
- Fixed edit prompts not working in settings</br>
- Fixed red and purple being switched around for PP colour coding</br>
- Fixed incorrect notation of numbers in Dragon tooltip and interface</br>
- Fixed incorrect calculation of changing Dragon aura cost</br>
- Fixed incorrect calculation of changing Pantheon gods effect</br>
- Fixed fluctuating PP values when god Cyclius was selected</br>
- Fixed black flickering when Golden Cookies or buffs start</br>
</div>
`;

141
src/Data/Scales.js Normal file
View File

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

View File

@@ -0,0 +1,26 @@
/** Data related to the display titles of certain sections in menu screens */
/** Display titles of the headers of the Cookie Monster settings section */
export const ConfigGroups = {
Favourite: 'Favourite Settings',
Calculation: 'Calculation',
Notation: 'Notation',
Colours: 'Colours and colour coding',
BarsDisplay: 'Infobars and visual settings',
Tooltip: 'Tooltips',
Statistics: 'Statistics',
Notification: 'Notifications',
Miscellaneous: 'Miscellaneous',
};
/** Display titles of the headers of the notification section of the Cookie Monster settings */
export const ConfigGroupsNotification = {
NotificationGeneral: 'General Notifications',
NotificationGC: 'Golden Cookie',
NotificationFC: 'Fortune Cookie',
NotificationSea: 'Season Special',
NotificationGard: 'Garden Tick',
NotificationMagi: 'Full Magic Bar',
NotificationWrink: 'Wrinkler',
NotificationWrinkMax: 'Maximum Wrinklers',
};

View File

@@ -0,0 +1,53 @@
/* eslint-disable max-classes-per-file */
/** This describes all forms of settings used by Cookie Monster */
/** The basic setting class */
export class Setting {
constructor(type, group) {
this.type = type;
this.group = group;
}
}
/** The standard toggle setting class */
export class SettingStandard extends Setting {
constructor(type, group, label, desc, toggle, func = null) {
super(type, group);
this.label = label;
this.desc = desc;
this.toggle = toggle;
if (func) {
this.func = func;
}
}
}
/** The colour picker setting class */
export class SettingColours extends Setting {
constructor(type, group, desc) {
super(type, group);
this.desc = desc;
}
}
/** The volume level setting class */
export class SettingVolume extends Setting {
constructor(type, group, label, desc) {
super(type, group);
this.label = label;
this.desc = desc;
for (let i = 0; i < 101; i++) {
this.label[i] = `${i}%`;
}
}
}
/** The number input setting class */
export class SettingInputNumber extends Setting {
constructor(type, group, label, desc, min, max) {
super(type, group);
this.label = label;
this.desc = desc;
this.min = min;
this.max = max;
}
}

844
src/Data/SettingsData.js Normal file
View File

@@ -0,0 +1,844 @@
import CheckNotificationPermissions from '../Config/CheckNotificationPermissions';
import { ToggleTimerBar, ToggleTimerBarPos } from '../Config/SpecificToggles';
import ToggleBotBar from '../Config/Toggles/ToggleBotBar';
import ToggleDetailedTime from '../Config/Toggles/ToggleDetailedTime';
import ToggleGCTimer from '../Config/Toggles/ToggleGCTimer';
import ToggleSectionHideButtons from '../Config/Toggles/ToggleSectionHideButtons';
import ToggleToolWarnPos from '../Config/Toggles/ToggleToolWarnPos';
import ToggleUpgradeBarAndColour from '../Config/Toggles/ToggleUpgradeBarAndColour';
import ToggleUpgradeBarFixedPos from '../Config/Toggles/ToggleUpgradeBarFixedPos';
import ToggleWrinklerButtons from '../Config/Toggles/ToggleWrinklerButtons';
import { CMOptions } from '../Config/VariablesAndData';
import UpdateBuildings from '../Disp/BuildingsUpgrades/Buildings';
import UpdateUpgrades from '../Disp/BuildingsUpgrades/Upgrades';
import RefreshScale from '../Disp/HelperFunctions/RefreshScale';
import { UpdateFavicon } from '../Disp/TabTitle/FavIcon';
import { SimDoSims } from '../Sim/VariablesAndData';
import {
SettingStandard,
SettingColours,
SettingVolume,
SettingInputNumber,
} from './SettingClasses';
/** This includes all options of CookieMonster and their relevant data */
const Config = {
// Calculation
CPSMode: new SettingStandard(
'bool',
'Calculation',
['Current cookies per second', 'Average cookies per second'],
'Calculate times using current cookies per second or average cookies per second',
false,
),
AvgCPSHist: new SettingStandard(
'bool',
'Calculation',
[
'Average CPS in past 10s',
'Average CPS in past 15s',
'Average CPS in past 30s',
'Average CPS in past 1m',
'Average CPS in past 5m',
'Average CPS in past 10m',
'Average CPS in past 15m',
'Average CPS in past 30m',
],
'How much time average Cookies Per Second should consider',
false,
),
AvgClicksHist: new SettingStandard(
'bool',
'Calculation',
[
'Average clicks in past 1s',
'Average clicks in past 5s',
'Average clicks in past 10s',
'Average clicks in past 15s',
'Average clicks in past 30s',
],
'How much time average Cookie Clicks should consider',
false,
),
CalcWrink: new SettingStandard(
'bool',
'Calculation',
[
'Calculate with wrinklers OFF',
'Calculate with wrinklers ON',
'Calculate with single fattest wrinkler ON',
],
'Calculate times and average Cookies Per Second with (only the single non-shiny fattest) wrinklers',
true,
function () {
SimDoSims = true; // eslint-disable-line no-unused-vars
},
),
// Notation
Scale: new SettingStandard(
'bool',
'Notation',
[
"Game's setting scale",
'Metric',
'Short scale',
'Short scale (Abbreviated)',
'Scientific notation',
'Engineering notation',
],
'Change how long numbers are formatted',
false,
function () {
RefreshScale();
},
),
ScaleDecimals: new SettingStandard(
'bool',
'Notation',
['1 decimals', '2 decimals', '3 decimals'],
`Set the number of decimals used when applicable. This only works with Cookie Monster scales and not with "Game's Setting Scale"`,
false,
function () {
RefreshScale();
},
),
ScaleSeparator: new SettingStandard(
'bool',
'Notation',
['. for decimals (standard)', '. for thousands'],
'Set the separator used for decimals and thousands',
false,
function () {
RefreshScale();
},
),
ScaleCutoff: new SettingInputNumber(
'numscale',
'Notation',
'Notation cut-off point: ',
'The number from which Cookie Monster will start formatting numbers based on chosen scale. Standard is 999,999. Setting this above 999,999,999 might break certain notations',
1,
999999999,
),
TimeFormat: new SettingStandard(
'bool',
'Notation',
['Time XXd, XXh, XXm, XXs', 'Time XX:XX:XX:XX:XX'],
'Change the time format',
false,
),
DetailedTime: new SettingStandard(
'bool',
'Notation',
['Detailed time OFF', 'Detailed time ON'],
'Change how time is displayed in certain statistics and tooltips',
true,
function () {
ToggleDetailedTime();
},
),
PPDisplayTime: new SettingStandard(
'bool',
'Notation',
['PP as value (standard)', 'PP as time unit'],
'Display PP as calculated value or as approximate time unit. Note that PP does not translate directly into a time unit and this is therefore only an approximation.',
false,
),
// Colours
BuildColour: new SettingStandard(
'bool',
'Colours',
['Building colours OFF', 'Building colours ON'],
'Colour code buildings',
true,
function () {
UpdateBuildings();
},
),
PPOnlyConsiderBuyable: new SettingStandard(
'bool',
'Colours',
["Don't ignore non-buyable", 'Ignore non-buyable'],
"Makes Cookie Monster label buildings and upgrades you can't buy right now red, useful in those situations where you just want to spend your full bank 'most optimally'",
true,
),
PPExcludeTop: new SettingStandard(
'bool',
'Colours',
[
"Don't ignore any",
'Ignore 1st best',
'Ignore 1st and 2nd best',
'Ignore 1st, 2nd and 3rd best',
],
'Makes Cookie Monster ignore the 1st, 2nd or 3rd best buildings in labeling and colouring PP values',
true,
),
PPRigidelMode: new SettingStandard(
'bool',
'Colours',
['Rigidel mode OFF', 'Rigidel mode ON'],
'Makes Cookie Monster ignore all "buy 1" options when colouring PP in order to stay at a total building count ending in 10 for pantheon god Rigidel',
true,
),
PPSecondsLowerLimit: new SettingInputNumber(
'numscale',
'Colours',
'Lower limit for PP (in seconds): ',
'If a building or upgrade costs less than the specified seconds of CPS it will also be considered optimal and label it as such ("PP is less than xx seconds of CPS"); setting to 0 ignores this option',
0,
Infinity,
),
ColourBlue: new SettingColours(
'colour',
'Colours',
'Standard colour is blue. Used to show upgrades better than best PP building, for Click Frenzy bar, and for various labels',
),
ColourGreen: new SettingColours(
'colour',
'Colours',
'Standard colour is green. Used to show best PP building, for Blood Frenzy bar, and for various labels',
),
ColourYellow: new SettingColours(
'colour',
'Colours',
'Standard colour is yellow. Used to show buildings within the top 10 of PP, for Frenzy bar, and for various labels',
),
ColourOrange: new SettingColours(
'colour',
'Colours',
'Standard colour is orange. Used to show buildings within the top 20 of PP, for Next Reindeer bar, and for various labels',
),
ColourRed: new SettingColours(
'colour',
'Colours',
'Standard colour is Red. Used to show buildings within the top 30 of PP, for Clot bar, and for various labels',
),
ColourPurple: new SettingColours(
'colour',
'Colours',
'Standard colour is purple. Used to show buildings outside of the top 30 of PP, for Next Cookie bar, and for various labels',
),
ColourGray: new SettingColours(
'colour',
'Colours',
'Standard colour is gray. Used to show negative or infinity PP, and for Next Cookie/Next Reindeer bar',
),
ColourPink: new SettingColours(
'colour',
'Colours',
'Standard colour is pink. Used for Dragonflight bar',
),
ColourBrown: new SettingColours(
'colour',
'Colours',
'Standard colour is brown. Used for Dragon Harvest bar',
),
// BarsDisplay
BotBar: new SettingStandard(
'bool',
'BarsDisplay',
['Bottom bar OFF', 'Bottom bar ON'],
'Building information',
true,
function () {
ToggleBotBar();
},
),
TimerBar: new SettingStandard(
'bool',
'BarsDisplay',
['Timer bar OFF', 'Timer bar ON'],
'Bar with timers for golden cookie, season popup, Frenzy (Normal, Clot, Elder), Click Frenzy',
true,
function () {
ToggleTimerBar();
},
),
TimerBarPos: new SettingStandard(
'bool',
'BarsDisplay',
['Timer bar position (top left)', 'Timer bar position (bottom)'],
'Placement of the timer bar',
false,
function () {
ToggleTimerBarPos();
},
),
TimerBarOverlay: new SettingStandard(
'bool',
'BarsDisplay',
[
'Timer bar overlay OFF',
'Timer bar overlay only seconds',
'Timer bar overlay full',
],
'Overlay on timers displaying seconds and/or percentage left',
true,
),
UpBarColour: new SettingStandard(
'bool',
'BarsDisplay',
[
'Upgrade colours/bar OFF',
'Upgrade colours with bar ON',
'Upgrade colours without bar ON',
],
'Colour code upgrades and optionally add a counter bar',
false,
function () {
ToggleUpgradeBarAndColour();
},
),
UpgradeBarFixedPos: new SettingStandard(
'bool',
'BarsDisplay',
['Upgrade bar fixed position OFF', 'Upgrade bar fixed position ON'],
'Lock the upgrade bar at top of the screen to prevent it from moving ofscreen when scrolling',
true,
function () {
ToggleUpgradeBarFixedPos();
},
),
SortBuildings: new SettingStandard(
'bool',
'BarsDisplay',
[
'Sort buildings: default',
'Sort buildings: PP of x1 purchase',
'Sort buildings: PP of selected bulk mode',
],
'Sort the display of buildings in either default order or by PP',
false,
function () {
UpdateBuildings();
},
),
SortUpgrades: new SettingStandard(
'bool',
'BarsDisplay',
['Sort upgrades: default', 'Sort upgrades: PP'],
'Sort the display of upgrades in either default order or by PP',
false,
function () {
UpdateUpgrades();
},
),
DragonAuraInfo: new SettingStandard(
'bool',
'BarsDisplay',
['Extra dragon aura info OFF', 'Extra dragon aura info ON'],
'Shows information about changes in CPS and costs in the dragon aura interface.',
true,
),
GrimoireBar: new SettingStandard(
'bool',
'BarsDisplay',
['Grimoire magic meter timer OFF', 'Grimoire magic meter timer ON'],
'A timer on how long before the Grimoire magic meter is full',
true,
),
GCTimer: new SettingStandard(
'bool',
'BarsDisplay',
['Golden cookie timer OFF', 'Golden cookie timer ON'],
'A timer on the golden cookie when it has been spawned',
true,
function () {
ToggleGCTimer();
},
),
Favicon: new SettingStandard(
'bool',
'BarsDisplay',
['Favicon OFF', 'Favicon ON'],
'Update favicon with golden/wrath cookie',
true,
function () {
UpdateFavicon();
},
),
WrinklerButtons: new SettingStandard(
'bool',
'BarsDisplay',
['Extra wrinkler buttons OFF', 'Extra wrinkler buttons ON'],
'Show buttons for popping wrinklers at bottom of cookie section',
true,
function () {
ToggleWrinklerButtons();
},
),
HideSectionsButtons: new SettingStandard(
'bool',
'BarsDisplay',
['Hide buildings/upgrades button OFF', 'Hide buildings/upgrades button ON'],
'Show buttons for hiding and showing the buildings and upgrades sections in the right column',
true,
function () {
ToggleSectionHideButtons();
},
),
// Tooltip
TooltipBuildUpgrade: new SettingStandard(
'bool',
'Tooltip',
[
'Building/upgrade tooltip information OFF',
'Building/upgrade tooltip information ON',
],
'Extra information in building/upgrade tooltips',
true,
),
TooltipAmor: new SettingStandard(
'bool',
'Tooltip',
[
'Buildings tooltip amortization information OFF',
'Buildings tooltip amortization information ON',
],
'Add amortization information to buildings tooltip',
true,
),
ToolWarnLucky: new SettingStandard(
'bool',
'Tooltip',
['Tooltip lucky warning OFF', 'Tooltip lucky warning ON'],
'A warning when buying if it will put the bank under the amount needed for max "Lucky!" rewards',
true,
),
ToolWarnLuckyFrenzy: new SettingStandard(
'bool',
'Tooltip',
['Tooltip lucky frenzy warning OFF', 'Tooltip lucky frenzy warning ON'],
'A warning when buying if it will put the bank under the amount needed for max "Lucky!" (Frenzy) rewards',
true,
),
ToolWarnConjure: new SettingStandard(
'bool',
'Tooltip',
['Tooltip conjure warning OFF', 'Tooltip conjure warning ON'],
'A warning when buying if it will put the bank under the amount needed for max "Conjure Baked Goods" rewards',
true,
),
ToolWarnConjureFrenzy: new SettingStandard(
'bool',
'Tooltip',
['Tooltip conjure frenzy warning OFF', 'Tooltip conjure frenzy warning ON'],
'A warning when buying if it will put the bank under the amount needed for max "Conjure Baked Goods" rewards with Frenzy active',
true,
),
ToolWarnEdifice: new SettingStandard(
'bool',
'Tooltip',
['Tooltip edifice warning OFF', 'Tooltip edifice warning ON'],
'A warning when buying if it will put the bank under the amount needed for "Spontaneous Edifice" to possibly give you your most expensive building',
true,
),
ToolWarnUser: new SettingInputNumber(
'numscale',
'Tooltip',
'Tooltip warning at x times CPS: ',
'Use this to show a customized warning if buying it will put the bank under the amount equal to value times cps; setting to 0 disables the function altogether',
0,
Infinity,
),
ToolWarnBon: new SettingStandard(
'bool',
'Tooltip',
[
'Calculate tooltip warning with bonus CPS OFF',
'Calculate tooltip warning with bonus CPS ON',
],
'Calculate the warning with or without the bonus CPS you get from buying',
true,
),
ToolWarnPos: new SettingStandard(
'bool',
'Tooltip',
['Tooltip warning position (left)', 'Tooltip warning position (bottom)'],
'Placement of the warning boxes',
false,
function () {
ToggleToolWarnPos();
},
),
TooltipGrim: new SettingStandard(
'bool',
'Tooltip',
['Grimoire tooltip information OFF', 'Grimoire tooltip information ON'],
'Extra information in tooltip for grimoire',
true,
),
TooltipWrink: new SettingStandard(
'bool',
'Tooltip',
['Wrinkler tooltip OFF', 'Wrinkler tooltip ON'],
'Shows the amount of cookies a wrinkler will give when popping it',
true,
),
TooltipLump: new SettingStandard(
'bool',
'Tooltip',
['Sugar lump tooltip OFF', 'Sugar lump tooltip ON'],
'Shows the current Sugar Lump type in Sugar lump tooltip.',
true,
),
TooltipPlots: new SettingStandard(
'bool',
'Tooltip',
['Garden plots tooltip OFF', 'Garden plots tooltip ON'],
'Shows a tooltip for plants that have a cookie reward.',
true,
),
TooltipPantheon: new SettingStandard(
'bool',
'Tooltip',
['Pantheon tooltip OFF', 'Pantheon tooltip ON'],
'Shows additional info in the pantheon tooltip',
true,
),
TooltipAscendButton: new SettingStandard(
'bool',
'Tooltip',
['Show Extra Info Ascend Tooltip OFF', 'Show Extra Info Ascend Tooltip ON'],
'Shows additional info in the ascend tooltip',
true,
),
// Statistics
Stats: new SettingStandard(
'bool',
'Statistics',
['Statistics OFF', 'Statistics ON'],
'Extra Cookie Monster statistics!',
true,
),
MissingUpgrades: new SettingStandard(
'bool',
'Statistics',
['Missing upgrades OFF', 'Missing upgrades ON'],
'Shows missing upgrades in statistics menu',
true,
),
MissingAchievements: new SettingStandard(
'bool',
'Statistics',
['Missing Achievements OFF', 'Missing Normal Achievements ON'],
'Shows missing normal achievements in statistics menu.',
false,
),
UpStats: new SettingStandard(
'bool',
'Statistics',
['Statistics update rate (default)', 'Statistics update rate (1s)'],
'Default rate is once every 5 seconds',
false,
),
HeavenlyChipsTarget: new SettingInputNumber(
'numscale',
'Statistics',
'Heavenly chips target: ',
'Use this to set a heavenly chips target that will be counted towards in the "prestige" statsistics sections',
1,
Infinity,
),
ShowMissedGC: new SettingStandard(
'bool',
'Statistics',
['Missed GC OFF', 'Missed GC ON'],
'Show a stat in the statistics screen that counts how many golden cookies you have missed',
true,
),
// Notification
Title: new SettingStandard(
'bool',
'NotificationGeneral',
['Title OFF', 'Title ON', 'Title pinned tab highlight'],
'Update title with colden cookie/season popup timers; pinned tab highlight only changes the title when a golden cookie/season popup spawns; "!" means that golden cookie/reindeer can spawn',
true,
),
GeneralSound: new SettingStandard(
'bool',
'NotificationGeneral',
['Consider game volume setting OFF', 'Consider game volume setting ON'],
'Turning this toggle to "off" makes Cookie Monster no longer consider the volume setting of the base game, allowing mod notifications to play with base game volume turned down',
true,
),
GCNotification: new SettingStandard(
'bool',
'NotificationGC',
['Notification OFF', 'Notification ON'],
'Create a notification when golden cookie spawns',
true,
function () {
CheckNotificationPermissions(CMOptions.GCNotification);
},
),
GCFlash: new SettingStandard(
'bool',
'NotificationGC',
['Flash OFF', 'Flash ON'],
'Flash screen on golden cookie',
true,
),
ColourGCFlash: new SettingColours(
'colour',
'NotificationGC',
'The colour of the GC flash, standard colour is white',
),
GCSound: new SettingStandard(
'bool',
'NotificationGC',
['Sound OFF', 'Sound ON'],
'Play a sound on golden cookie',
true,
),
GCVolume: new SettingVolume('vol', 'NotificationGC', [], 'Volume'),
GCSoundURL: new SettingStandard(
'url',
'NotificationGC',
'Sound URL:',
'URL of the sound to be played when a golden cookie spawns',
),
FortuneNotification: new SettingStandard(
'bool',
'NotificationFC',
['Notification OFF', 'Notification ON'],
'Create a notification when fortune cookie is on the ticker',
true,
function () {
CheckNotificationPermissions(CMOptions.FortuneNotification);
},
),
FortuneFlash: new SettingStandard(
'bool',
'NotificationFC',
['Flash OFF', 'Flash ON'],
'Flash screen on fortune cookie spawn',
true,
),
ColourFortuneFlash: new SettingColours(
'colour',
'NotificationFC',
'The colour of the fortune flash, standard colour is white',
),
FortuneSound: new SettingStandard(
'bool',
'NotificationFC',
['Sound OFF', 'Sound ON'],
'Play a sound on fortune cookie spawn',
true,
),
FortuneVolume: new SettingVolume('vol', 'NotificationFC', [], 'Volume'),
FortuneSoundURL: new SettingStandard(
'url',
'NotificationFC',
'Sound URL:',
'URL of the sound to be played when the ticker has a fortune cookie',
),
SeaNotification: new SettingStandard(
'bool',
'NotificationSea',
['Notification OFF', 'Notification ON'],
'Create a notification on season popup',
true,
function () {
CheckNotificationPermissions(CMOptions.SeaNotification);
},
),
SeaFlash: new SettingStandard(
'bool',
'NotificationSea',
['Flash OFF', 'Flash ON'],
'Flash screen on season popup',
true,
),
ColourSeaFlash: new SettingColours(
'colour',
'NotificationSea',
'The colour of the season popup flash, standard colour is white',
),
SeaSound: new SettingStandard(
'bool',
'NotificationSea',
['Sound OFF', 'Sound ON'],
'Play a sound on season popup',
true,
),
SeaVolume: new SettingVolume('vol', 'NotificationSea', [], 'Volume'),
SeaSoundURL: new SettingStandard(
'url',
'NotificationSea',
'Sound URL:',
'URL of the sound to be played when on season popup spawns',
),
GardFlash: new SettingStandard(
'bool',
'NotificationGard',
['Garden Tick Flash OFF', 'Flash ON'],
'Flash screen on garden tick',
true,
),
ColourGardFlash: new SettingColours(
'colour',
'NotificationGard',
'The colour of the garden flash, standard colour is white',
),
GardSound: new SettingStandard(
'bool',
'NotificationGard',
['Sound OFF', 'Sound ON'],
'Play a sound on garden tick',
true,
),
GardVolume: new SettingVolume('vol', 'NotificationGard', [], 'Volume'),
GardSoundURL: new SettingStandard(
'url',
'NotificationGard',
'Garden Tick Sound URL:',
'URL of the sound to be played when the garden ticks',
),
MagicNotification: new SettingStandard(
'bool',
'NotificationMagi',
['Notification OFF', 'Notification ON'],
'Create a notification when magic reaches maximum',
true,
function () {
CheckNotificationPermissions(CMOptions.MagicNotification);
},
),
MagicFlash: new SettingStandard(
'bool',
'NotificationMagi',
['Flash OFF', 'Flash ON'],
'Flash screen when magic reaches maximum',
true,
),
ColourMagicFlash: new SettingColours(
'colour',
'NotificationMagi',
'The colour of the magic flash, standard colour is white',
),
MagicSound: new SettingStandard(
'bool',
'NotificationMagi',
['Sound OFF', 'Sound ON'],
'Play a sound when magic reaches maximum',
true,
),
MagicVolume: new SettingVolume('vol', 'NotificationMagi', [], 'Volume'),
MagicSoundURL: new SettingStandard(
'url',
'NotificationMagi',
'Sound URL:',
'URL of the sound to be played when magic reaches maxium',
),
WrinklerNotification: new SettingStandard(
'bool',
'NotificationWrink',
['Notification OFF', 'Notification ON'],
'Create a notification when a wrinkler appears',
true,
function () {
CheckNotificationPermissions(CMOptions.WrinklerNotification);
},
),
WrinklerFlash: new SettingStandard(
'bool',
'NotificationWrink',
['Flash OFF', 'Flash ON'],
'Flash screen when a wrinkler appears',
true,
),
ColourWrinklerFlash: new SettingColours(
'colour',
'NotificationWrink',
'The colour of the wrinkler flash, standard colour is white',
),
WrinklerSound: new SettingStandard(
'bool',
'NotificationWrink',
['Sound OFF', 'Sound ON'],
'Play a sound when a wrinkler appears',
true,
),
WrinklerVolume: new SettingVolume('vol', 'NotificationWrink', [], 'Volume'),
WrinklerSoundURL: new SettingStandard(
'url',
'NotificationWrink',
'Sound URL:',
'URL of the sound to be played when a wrinkler appears',
),
WrinklerMaxNotification: new SettingStandard(
'bool',
'NotificationWrinkMax',
['Notification OFF', 'Notification ON'],
'Create a notification when the maximum amount of wrinklers has appeared',
true,
function () {
CheckNotificationPermissions(CMOptions.WrinklerMaxNotification);
},
),
WrinklerMaxFlash: new SettingStandard(
'bool',
'NotificationWrinkMax',
['Flash OFF', 'Flash ON'],
'Flash screen when the maximum amount of Wrinklers has appeared',
true,
),
ColourWrinklerMaxFlash: new SettingColours(
'colour',
'NotificationWrinkMax',
'The colour of the maximum wrinkler flash, standard colour is white',
),
WrinklerMaxSound: new SettingStandard(
'bool',
'NotificationWrinkMax',
['Sound OFF', 'Sound ON'],
'Play a sound when the maximum amount of wrinklers has appeared',
true,
),
WrinklerMaxVolume: new SettingVolume(
'vol',
'NotificationWrinkMax',
[],
'Volume',
),
WrinklerMaxSoundURL: new SettingStandard(
'url',
'NotificationWrinkMax',
'Sound URL:',
'URL of the sound to be played when the maximum amount of wrinklers has appeared',
),
// Miscellaneous
BulkBuyBlock: new SettingStandard(
'bool',
'Miscellaneous',
['Block bulk buying OFF', 'Block bulk buying ON'],
"Block clicking bulk buying when you can't buy all. This prevents buying 7 of a building when you are in buy-10 or buy-100 mode.",
true,
),
FavouriteSettings: new SettingStandard(
'bool',
'Miscellaneous',
[
'Favourite settings section OFF',
'Favourite settings section ON',
'Favourite settings section ON (Locked)',
],
"Show stars before each setting which allows selecting it for a 'favourites' section at the top of the Cookie Monster settings. Setting this to Locked removes the stars but shows the 'favourites' section",
true,
function () {
Game.UpdateMenu();
},
),
};
export default Config;

144
src/Data/SettingsDefault.js Normal file
View File

@@ -0,0 +1,144 @@
/** This array describes all default settings */
const ConfigDefault = {
CPSMode: 1,
AvgCPSHist: 3,
AvgClicksHist: 0,
CalcWrink: 0,
Scale: 2,
ScaleDecimals: 2,
ScaleSeparator: 0,
ScaleCutoff: 999999,
TimeFormat: 0,
DetailedTime: 1,
PPDisplayTime: 0,
BuildColour: 1,
PPOnlyConsiderBuyable: 0,
PPExcludeTop: 0,
PPRigidelMode: 0,
PPSecondsLowerLimit: 0,
ColourBlue: '#4bb8f0',
ColourGreen: '#00ff00',
ColourYellow: '#ffff00',
ColourOrange: '#ff7f00',
ColourRed: '#ff0000',
ColourPurple: '#ff00ff',
ColourGray: '#b3b3b3',
ColourPink: '#ff1493',
ColourBrown: '#8b4513',
BotBar: 1,
TimerBar: 1,
TimerBarPos: 0,
TimerBarOverlay: 2,
UpBarColour: 1,
UpgradeBarFixedPos: 1,
SortBuildings: 0,
SortUpgrades: 0,
DragonAuraInfo: 1,
GrimoireBar: 1,
GCTimer: 1,
Favicon: 1,
WrinklerButtons: 1,
HideSectionsButtons: 0,
TooltipBuildUpgrade: 1,
TooltipAmor: 0,
ToolWarnLucky: 1,
ToolWarnLuckyFrenzy: 1,
ToolWarnConjure: 1,
ToolWarnConjureFrenzy: 1,
ToolWarnEdifice: 1,
ToolWarnUser: 0,
ToolWarnBon: 1,
ToolWarnPos: 1,
TooltipGrim: 1,
TooltipWrink: 1,
TooltipLump: 1,
TooltipPlots: 1,
TooltipPantheon: 1,
TooltipAscendButton: 1,
Stats: 1,
MissingUpgrades: 1,
MissingAchievements: 0,
UpStats: 1,
HeavenlyChipsTarget: 1,
ShowMissedGC: 1,
Title: 1,
GeneralSound: 1,
GCNotification: 0,
GCFlash: 1,
ColourGCFlash: '#ffffff',
GCSound: 1,
GCVolume: 100,
GCSoundURL: 'https://freesound.org/data/previews/66/66717_931655-lq.mp3',
FortuneNotification: 0,
FortuneFlash: 1,
ColourFortuneFlash: '#ffffff',
FortuneSound: 1,
FortuneVolume: 100,
FortuneSoundURL:
'https://freesound.org/data/previews/174/174027_3242494-lq.mp3',
SeaNotification: 0,
SeaFlash: 1,
ColourSeaFlash: '#ffffff',
SeaSound: 1,
SeaVolume: 100,
SeaSoundURL:
'https://www.freesound.org/data/previews/121/121099_2193266-lq.mp3',
GardFlash: 1,
ColourGardFlash: '#ffffff',
GardSound: 1,
GardVolume: 100,
GardSoundURL: 'https://freesound.org/data/previews/103/103046_861714-lq.mp3',
MagicNotification: 0,
MagicFlash: 1,
ColourMagicFlash: '#ffffff',
MagicSound: 1,
MagicVolume: 100,
MagicSoundURL:
'https://freesound.org/data/previews/221/221683_1015240-lq.mp3',
WrinklerNotification: 0,
WrinklerFlash: 1,
ColourWrinklerFlash: '#ffffff',
WrinklerSound: 1,
WrinklerVolume: 100,
WrinklerSoundURL:
'https://freesound.org/data/previews/124/124186_8043-lq.mp3',
WrinklerMaxNotification: 0,
WrinklerMaxFlash: 1,
ColourWrinklerMaxFlash: '#ffffff',
WrinklerMaxSound: 1,
WrinklerMaxVolume: 100,
WrinklerMaxSoundURL:
'https://freesound.org/data/previews/152/152743_15663-lq.mp3',
BulkBuyBlock: 0,
FavouriteSettings: 1,
Header: {
Favourite: 1,
Calculation: 1,
Notation: 1,
Colours: 1,
BarsDisplay: 1,
Tooltip: 1,
Statistics: 1,
Notification: 1,
NotificationGeneral: 1,
NotificationGC: 1,
NotificationFC: 1,
NotificationSea: 1,
NotificationGard: 1,
NotificationMagi: 1,
NotificationWrink: 1,
NotificationWrinkMax: 1,
Miscellaneous: 1,
Lucky: 1,
Chain: 1,
Spells: 1,
Garden: 1,
Prestige: 1,
Wrink: 1,
Sea: 1,
Misc: 1,
InfoTab: 1,
},
};
export default ConfigDefault;

File diff suppressed because it is too large Load Diff

View File

@@ -0,0 +1,154 @@
/** General functions to format or beautify strings */
import { CMOptions } from '../../Config/VariablesAndData';
import { metric, shortScale, shortScaleAbbreviated } from '../../Data/Scales';
import { BackupFunctions } from '../../Main/VariablesAndData';
import {
ColourGreen,
ColourOrange,
ColourRed,
ColourYellow,
} from '../VariablesAndData';
/**
* This function returns formats number based on the Scale setting
* @param {number} num Number to be beautified
* @param {any} floats Used in some scenario's by CM.Backup.Beautify (Game's original function)
* @param {number} forced Used to force (type 3) in certains cases
* @returns {string} Formatted number
*/
export function Beautify(num, floats, forced) {
const decimals = CMOptions.ScaleDecimals + 1;
if (num === Infinity) {
return 'Infinity';
}
if (typeof num === 'undefined') {
return '0';
}
if (CMOptions.Scale === 0) {
return BackupFunctions.Beautify(num, floats);
}
if (Number.isFinite(num)) {
if (num < 0) {
return `-${Beautify(Math.abs(num))}`;
}
let answer = '';
if (num === 0) {
return num.toString();
}
if (num > 0.001 && num < CMOptions.ScaleCutoff) {
if (CMOptions.ScaleSeparator) answer = num.toLocaleString('nl');
else answer = num.toLocaleString('en');
return answer;
}
if ((CMOptions.Scale === 4 && !forced) || forced === 4) {
// Scientific notation, 123456789 => 1.235E+8
answer = num.toExponential(decimals).toString().replace('e', 'E');
} else {
const exponential = num.toExponential().toString();
const AmountOfTenPowerThree = Math.floor(
exponential.slice(exponential.indexOf('e') + 1) / 3,
);
answer = (num / Number(`1e${AmountOfTenPowerThree * 3}`)).toFixed(
decimals,
);
// answer is now "xxx.xx" (e.g., 123456789 would be 123.46)
if ((CMOptions.Scale === 1 && !forced) || forced === 1) {
// Metric scale, 123456789 => 123.457 M
if (num >= 0.01 && num < Number(`1e${metric.length * 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) {
// Short scale, 123456789 => 123.457 M
if (num >= 0.01 && num < Number(`1e${shortScale.length * 3}`)) {
answer += ` ${shortScale[AmountOfTenPowerThree]}`;
} else answer = Beautify(num, 0, 4); // If number is too large or little, revert to scientific notation
} 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 += ` ${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 === '') {
// eslint-disable-next-line no-console
console.log(
`Could not beautify number with Cookie Monster Beautify: ${num}`,
);
answer = BackupFunctions.Beautify(num, floats);
}
if (CMOptions.ScaleSeparator) answer = answer.replace('.', ',');
return answer;
}
console.log(`Could not beautify number with Cookie Monster Beautify: ${num}`); // eslint-disable-line no-console
return BackupFunctions.Beautify(num, floats);
}
/**
* This function returns time as a string depending on TimeFormat setting
* @param {number} time Time to be formatted
* @param {number} longFormat 1 or 0
* @returns {string} Formatted time
*/
export function FormatTime(time, longFormat) {
let formattedTime = time;
if (time === Infinity) return time;
if (time < 0) return 'Negative time period';
formattedTime = Math.ceil(time);
const y = Math.floor(formattedTime / 31557600);
const d = Math.floor((formattedTime % 31557600) / 86400);
const h = Math.floor((formattedTime % 86400) / 3600);
const m = Math.floor((formattedTime % 3600) / 60);
const s = Math.floor(formattedTime % 60);
let str = '';
if (CMOptions.TimeFormat) {
if (formattedTime > 3155760000) return 'XX:XX:XX:XX:XX';
str += `${(y < 10 ? '0' : '') + y}:`;
str += `${(d < 10 ? '0' : '') + d}:`;
str += `${(h < 10 ? '0' : '') + h}:`;
str += `${(m < 10 ? '0' : '') + m}:`;
str += (s < 10 ? '0' : '') + s;
} else {
if (formattedTime > 777600000)
return longFormat ? 'Over 9000 days!' : '>9000d';
str +=
y > 0
? `${y + (longFormat ? (y === 1 ? ' year' : ' years') : 'y')}, ` // eslint-disable-line no-nested-ternary
: '';
str +=
d > 0 ? `${d + (longFormat ? (d === 1 ? ' day' : ' days') : 'd')}, ` : ''; // eslint-disable-line no-nested-ternary
if (str.length > 0 || h > 0)
str += `${h + (longFormat ? (h === 1 ? ' hour' : ' hours') : 'h')}, `; // eslint-disable-line no-nested-ternary
if (str.length > 0 || m > 0)
str += `${m + (longFormat ? (m === 1 ? ' minute' : ' minutes') : 'm')}, `; // eslint-disable-line no-nested-ternary
str += s + (longFormat ? (s === 1 ? ' second' : ' seconds') : 's'); // eslint-disable-line no-nested-ternary
}
return str;
}
/**
* This function returns the color to be used for time-strings
* @param {number} time Time to be coloured
* @returns {{string, string}} {text, color} Both the formatted time and color as strings in an array
*/
export function GetTimeColour(time) {
let color;
let text;
if (time <= 0) {
if (CMOptions.TimeFormat) text = '00:00:00:00:00';
else text = 'Done!';
color = ColourGreen;
} else {
text = FormatTime(time);
if (time > 300) color = ColourRed;
else if (time > 60) color = ColourOrange;
else color = ColourYellow;
}
return { text, color };
}

View File

@@ -0,0 +1,118 @@
import {
CacheObjects1,
CacheObjects10,
CacheObjects100,
} from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData';
import BuildingSell from '../../Sim/SimulationEvents/SellBuilding';
import { Beautify } from '../BeautifyAndFormatting/BeautifyFormatting';
import { ColoursOrdering, LastTargetBuildings } from '../VariablesAndData';
/**
* Section: Functions related to right column of the screen (buildings/upgrades)
/**
* This function adjusts some things in the column of buildings.
* It colours them, helps display the correct sell-price and shuffles the order when CM.Options.SortBuildings is set
* The function is called by CM.Disp.Draw(), CM.Disp.UpdateColours() & CM.Disp.RefreshScale()
* And by changes in CM.Options.BuildColour, CM.Options.SortBuild & CM.Data.Config.BulkBuildColour
*/
export default function UpdateBuildings() {
let target = Game.buyBulk;
if (Game.buyMode === 1) {
LastTargetBuildings = target;
} else {
target = LastTargetBuildings;
}
if (target === 1) target = CacheObjects1;
else if (target === 10) target = CacheObjects10;
else if (target === 100) target = CacheObjects100;
if (Game.buyMode === 1) {
if (CMOptions.BuildColour === 1) {
Object.keys(target).forEach((i) => {
l(`productPrice${Game.Objects[i].id}`).style.color =
CMOptions[`Colour${target[i].color}`];
});
} else {
Object.keys(Game.Objects).forEach((i) => {
l(`productPrice${Game.Objects[i].id}`).style.removeProperty('color');
});
}
} else if (Game.buyMode === -1) {
Object.keys(CacheObjects1).forEach((i) => {
const o = Game.Objects[i];
l(`productPrice${o.id}`).style.color = '';
/*
* 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.
*
* 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),
);
});
}
// 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)
// This regulates sorting of buildings
if (Game.buyMode === 1 && CMOptions.SortBuildings) {
let arr;
if (CMOptions.SortBuildings === 1) {
arr = Object.keys(CacheObjects1).map((k) => {
const o = CacheObjects1[k];
o.name = k;
o.id = Game.Objects[k].id;
return o;
});
arr.sort(function (a, b) {
return ColoursOrdering.indexOf(a.color) > // eslint-disable-line no-nested-ternary
ColoursOrdering.indexOf(b.color)
? 1
: ColoursOrdering.indexOf(a.color) < ColoursOrdering.indexOf(b.color) // eslint-disable-line no-nested-ternary
? -1
: a.pp < b.pp
? -1
: 0;
});
} else if (CMOptions.SortBuildings === 2) {
arr = Object.keys(target).map((k) => {
const o = target[k];
o.name = k;
o.id = Game.Objects[k].id;
return o;
});
arr.sort(function (a, b) {
return ColoursOrdering.indexOf(a.color) > // eslint-disable-line no-nested-ternary
ColoursOrdering.indexOf(b.color)
? 1
: ColoursOrdering.indexOf(a.color) < ColoursOrdering.indexOf(b.color) // eslint-disable-line no-nested-ternary
? -1
: a.pp < b.pp
? -1
: 0;
});
}
for (let x = 0; x < arr.length; x++) {
Game.Objects[arr[x].name].l.style.gridRow = `${x + 2}/${x + 2}`;
}
} else {
const arr = Object.keys(CacheObjects1).map((k) => {
const o = CacheObjects1[k];
o.name = k;
o.id = Game.Objects[k].id;
return o;
});
arr.sort((a, b) => a.id - b.id);
for (let x = 0; x < arr.length; x++) {
Game.Objects[arr[x].name].l.style.gridRow = `${x + 2}/${x + 2}`;
}
}
}

View File

@@ -0,0 +1,106 @@
import {
ColourBackPre,
ColourBlue,
ColourGray,
ColourGreen,
ColourOrange,
ColourPurple,
ColourRed,
ColourTextPre,
ColourYellow,
} from '../VariablesAndData';
/**
* This function creates the legend for the upgrade bar
* @returns {object} legend The legend-object to be added
*/
function CreateUpgradeBarLegend() {
const legend = document.createElement('div');
legend.style.minWidth = '330px';
legend.style.marginBottom = '4px';
const title = document.createElement('div');
title.className = 'name';
title.style.marginBottom = '4px';
title.textContent = 'Legend';
legend.appendChild(title);
const legendLine = function (color, text) {
const div = document.createElement('div');
div.style.verticalAlign = 'middle';
const span = document.createElement('span');
span.className = ColourBackPre + color;
span.style.display = 'inline-block';
span.style.height = '10px';
span.style.width = '10px';
span.style.marginRight = '4px';
div.appendChild(span);
div.appendChild(document.createTextNode(text));
return div;
};
legend.appendChild(
legendLine(ColourBlue, 'Better than the best PP of a building option'),
);
legend.appendChild(
legendLine(ColourGreen, 'Same as the best PP building option'),
);
legend.appendChild(
legendLine(ColourYellow, 'Within the top 10 of PP for buildings'),
);
legend.appendChild(
legendLine(ColourOrange, 'Within the top 20 of PP for buildings'),
);
legend.appendChild(
legendLine(ColourRed, 'Within the top 30 of PP for buildings'),
);
legend.appendChild(
legendLine(ColourPurple, 'Outside of the top 30 of PP for buildings'),
);
legend.appendChild(legendLine(ColourGray, 'Negative or infinity PP'));
return legend;
}
/**
* This function creates the upgrade bar above the upgrade-section in the right section of the screen
*/
export default function CreateUpgradeBar() {
const UpgradeBar = document.createElement('div');
UpgradeBar.id = 'CMUpgradeBar';
UpgradeBar.style.width = '100%';
UpgradeBar.style.backgroundColour = 'black';
UpgradeBar.style.textAlign = 'center';
UpgradeBar.style.fontWeight = 'bold';
UpgradeBar.style.display = 'none';
UpgradeBar.style.zIndex = '21';
UpgradeBar.onmouseout = function () {
Game.tooltip.hide();
};
const placeholder = document.createElement('div');
placeholder.appendChild(CreateUpgradeBarLegend());
UpgradeBar.onmouseover = function () {
Game.tooltip.draw(this, escape(placeholder.innerHTML), 'store');
};
const upgradeNumber = function (id, color) {
const span = document.createElement('span');
span.id = id;
span.className = ColourTextPre + color;
span.style.width = '14.28571428571429%';
span.style.display = 'inline-block';
span.textContent = '0';
return span;
};
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarBlue', ColourBlue));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarGreen', ColourGreen));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarYellow', ColourYellow));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarOrange', ColourOrange));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarRed', ColourRed));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarPurple', ColourPurple));
UpgradeBar.appendChild(upgradeNumber('CMUpgradeBarGray', ColourGray));
l('upgrades').parentNode.insertBefore(
UpgradeBar,
l('upgrades').parentNode.childNodes[3],
);
}

View File

@@ -0,0 +1,102 @@
import { CacheUpgrades } from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData';
import {
ColourBackPre,
ColourBlue,
ColourGray,
ColourGreen,
ColourOrange,
ColourPurple,
ColourRed,
ColoursOrdering,
ColourYellow,
} from '../VariablesAndData';
/**
* This function adjusts some things in the upgrades section
* It colours them and shuffles the order when CM.Options.SortBuildings is set
* The function is called by CM.Disp.Draw(), CM.Disp.ToggleUpgradeBarAndColour & CM.Disp.RefreshScale()
* And by changes in CM.Options.SortUpgrades
*/
export default function UpdateUpgrades() {
// This counts the amount of upgrades for each pp group and updates the Upgrade Bar
if (CMOptions.UpBarColour > 0) {
let blue = 0;
let green = 0;
let yellow = 0;
let orange = 0;
let red = 0;
let purple = 0;
let gray = 0;
Object.keys(Game.UpgradesInStore).forEach((i) => {
const me = Game.UpgradesInStore[i];
let addedColour = false;
for (let j = 0; j < l(`upgrade${i}`).childNodes.length; j += 1) {
if (
l(`upgrade${i}`).childNodes[j].className.indexOf(ColourBackPre) !== -1
) {
l(`upgrade${i}`).childNodes[j].className =
ColourBackPre + CacheUpgrades[me.name].color;
addedColour = true;
break;
}
}
if (!addedColour) {
const div = document.createElement('div');
div.style.width = '10px';
div.style.height = '10px';
div.className = ColourBackPre + CacheUpgrades[me.name].color;
l(`upgrade${i}`).appendChild(div);
}
if (CacheUpgrades[me.name].color === ColourBlue) blue += 1;
else if (CacheUpgrades[me.name].color === ColourGreen) green += 1;
else if (CacheUpgrades[me.name].color === ColourYellow) yellow += 1;
else if (CacheUpgrades[me.name].color === ColourOrange) orange += 1;
else if (CacheUpgrades[me.name].color === ColourRed) red += 1;
else if (CacheUpgrades[me.name].color === ColourPurple) purple += 1;
else if (CacheUpgrades[me.name].color === ColourGray) gray += 1;
});
l('CMUpgradeBarBlue').textContent = blue;
l('CMUpgradeBarGreen').textContent = green;
l('CMUpgradeBarYellow').textContent = yellow;
l('CMUpgradeBarOrange').textContent = orange;
l('CMUpgradeBarRed').textContent = red;
l('CMUpgradeBarPurple').textContent = purple;
l('CMUpgradeBarGray').textContent = gray;
}
const arr = [];
// Build array of pointers, sort by pp, set flex positions
// This regulates sorting of upgrades
for (let x = 0; x < Game.UpgradesInStore.length; x += 1) {
const o = {};
o.name = Game.UpgradesInStore[x].name;
o.price = Game.UpgradesInStore[x].basePrice;
o.pp = CacheUpgrades[o.name].pp;
arr.push(o);
}
if (CMOptions.SortUpgrades) {
arr.sort(function (a, b) {
return ColoursOrdering.indexOf(a.color) > ColoursOrdering.indexOf(b.color) // eslint-disable-line no-nested-ternary
? 1
: ColoursOrdering.indexOf(a.color) < ColoursOrdering.indexOf(b.color) // eslint-disable-line no-nested-ternary
? -1
: a.pp < b.pp
? -1
: 0;
});
} else {
arr.sort((a, b) => a.price - b.price);
}
const nameChecker = function (arr2, upgrade) {
return arr2.findIndex((e) => e.name === upgrade.name);
};
for (let x = 0; x < Game.UpgradesInStore.length; x += 1) {
l(`upgrade${x}`).style.order =
nameChecker(arr, Game.UpgradesInStore[x]) + 1;
}
}

71
src/Disp/Dragon/Dragon.js Normal file
View File

@@ -0,0 +1,71 @@
/** Functions related to the Dragon */
import CacheDragonCost from '../../Cache/Dragon/Dragon';
import { CacheCostDragonUpgrade } from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData';
import CalculateChangeAura from '../../Sim/SimulationEvents/AuraChange';
import {
Beautify,
FormatTime,
} from '../BeautifyAndFormatting/BeautifyFormatting';
/**
* 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
*/
export function AddAuraInfo(aura) {
if (CMOptions.DragonAuraInfo === 1) {
const [bonusCPS, priceOfChange] = CalculateChangeAura(aura);
const timeToRecover = FormatTime(
priceOfChange / (bonusCPS + Game.cookiesPs),
);
const bonusCPSPercentage = Beautify((bonusCPS / Game.cookiesPs) * 100);
l('dragonAuraInfo').style.minHeight = '60px';
l('dragonAuraInfo').style.margin = '8px';
l('dragonAuraInfo').appendChild(document.createElement('div')).className =
'line';
const div = document.createElement('div');
div.style.minWidth = '200px';
div.style.textAlign = 'center';
div.textContent = `Picking this aura will change CPS by ${Beautify(
bonusCPS,
)} (${bonusCPSPercentage}% of current CPS).`;
l('dragonAuraInfo').appendChild(div);
const div2 = document.createElement('div');
div2.style.minWidth = '200px';
div2.style.textAlign = 'center';
div2.textContent = `It will take ${timeToRecover} to recover the cost.`;
l('dragonAuraInfo').appendChild(div2);
}
}
/**
* This functions adds a tooltip to the level up button displaying the cost of rebuying all
* It is called by Game.ToggleSpecialMenu() after CM.Main.ReplaceNative()
*/
export function AddDragonLevelUpTooltip() {
// 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
) {
for (let i = 0; i < l('specialPopup').childNodes.length; i++) {
if (l('specialPopup').childNodes[i].className === 'optionBox') {
l('specialPopup').children[i].onmouseover = function () {
CacheDragonCost();
Game.tooltip.dynamic = 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;
};
}
}
}
}

68
src/Disp/DrawHook.js Normal file
View File

@@ -0,0 +1,68 @@
import ToggleWrinklerButtons from '../Config/Toggles/ToggleWrinklerButtons';
import { CMOptions } from '../Config/VariablesAndData';
import { Beautify } from './BeautifyAndFormatting/BeautifyFormatting';
import UpdateBuildings from './BuildingsUpgrades/Buildings';
import UpdateUpgrades from './BuildingsUpgrades/Upgrades';
import { UpdateBotBar } from './InfoBars/BottomBar';
import { UpdateTimerBar } from './InfoBars/TimerBar';
import RefreshMenu from './MenuSections/Refreshmenu';
import UpdateTooltips from './Tooltips/UpdateTooltips';
import {
CheckWrinklerTooltip,
UpdateWrinklerTooltip,
} from './Tooltips/WrinklerTooltips';
/**
* This function handles all custom drawing for the Game.Draw() function.
* It is hooked on 'draw' by CM.RegisterHooks()
*/
export default function CMDrawHook() {
// Draw autosave timer in stats menu, this must be done here to make it count down correctly
if (
Game.prefs.autosave &&
Game.drawT % 10 === 0 && // with autosave ON and every 10 ticks
Game.onMenu === 'stats' &&
CMOptions.Stats // while being on the stats menu only
) {
const timer = document.getElementById('CMStatsAutosaveTimer');
if (timer) {
timer.innerText = Game.sayTime(
Game.fps * 60 - (Game.T % (Game.fps * 60)),
4,
);
}
}
// Update colors
UpdateBuildings();
UpdateUpgrades();
// Redraw timers
UpdateTimerBar();
// Update Bottom Bar
UpdateBotBar();
// Update Tooltip
UpdateTooltips();
// Update Wrinkler Tooltip
CheckWrinklerTooltip();
UpdateWrinklerTooltip();
// Change menu refresh interval
RefreshMenu();
// Update display of wrinkler buttons, this checks if Elder Pledge has been bought and if they should be disabled
ToggleWrinklerButtons();
// Replace Cookies counter because Orteil uses very weird code to "pad" it...
if (CMOptions.Scale) {
let str = l('cookies').innerHTML.replace(
/.*(?=<br>)/i,
Beautify(Game.cookies),
);
if (Game.prefs.monospace) str = `<span class="monospace">${str}</span>`;
l('cookies').innerHTML = str;
}
}

View File

@@ -0,0 +1,42 @@
/** Section: Functions related to the Golden Cookie Timers */
import { CMOptions } from '../../Config/VariablesAndData';
import { GCTimers } from '../VariablesAndData';
/**
* This function creates a new Golden Cookie Timer and appends it CM.Disp.GCTimers based on the id of the cookie
* @param {object} cookie A Golden Cookie object
*/
export default function CreateGCTimer(cookie) {
const GCTimer = document.createElement('div');
GCTimer.id = `GCTimer${cookie.id}`;
GCTimer.style.width = '96px';
GCTimer.style.height = '96px';
GCTimer.style.position = 'absolute';
GCTimer.style.zIndex = '10000000001';
GCTimer.style.textAlign = 'center';
GCTimer.style.lineHeight = '96px';
GCTimer.style.fontFamily = '"Kavoon", Georgia, serif';
GCTimer.style.fontSize = '35px';
GCTimer.style.cursor = 'pointer';
GCTimer.style.display = 'block';
if (CMOptions.GCTimer === 0) GCTimer.style.display = 'none';
GCTimer.style.left = cookie.l.style.left;
GCTimer.style.top = cookie.l.style.top;
GCTimer.onclick = function () {
cookie.pop();
};
GCTimer.onmouseover = function () {
cookie.l.style.filter = // eslint-disable-line no-param-reassign
'brightness(125%) drop-shadow(0px 0px 3px rgba(255,255,255,1))';
cookie.l.style.webkitFilter = // eslint-disable-line no-param-reassign
'brightness(125%) drop-shadow(0px 0px 3px rgba(255,255,255,1))';
};
GCTimer.onmouseout = function () {
cookie.l.style.filter = ''; // eslint-disable-line no-param-reassign
cookie.l.style.webkitFilter = ''; // eslint-disable-line no-param-reassign
};
GCTimers[cookie.id] = GCTimer;
l('shimmers').appendChild(GCTimer);
}

View File

@@ -0,0 +1,20 @@
/**
* This function calculates the time it takes to reach a certain magic level
* @param {number} currentMagic The current magic level
* @param {number} maxMagic The user's max magic level
* @param {number} targetMagic The target magic level
* @returns {number} count / Game.fps The time it takes to reach targetMagic
*/
export default function CalculateGrimoireRefillTime(
currentMagic,
maxMagic,
targetMagic,
) {
let magic = currentMagic;
let count = 0;
while (magic < targetMagic) {
magic += Math.max(0.002, (magic / Math.max(maxMagic, 100)) ** 0.5) * 0.002;
count += 1;
}
return count / Game.fps;
}

View File

@@ -0,0 +1,42 @@
import {
CacheAverageCPS,
CacheCurrWrinklerCount,
CacheCurrWrinklerCPSMult,
CacheWrinklersFattest,
} from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData';
/**
* This function returns the cps as either current or average CPS depending on CM.Options.CPSMode
* @returns {number} The average or current cps
*/
export default function GetCPS() {
if (CMOptions.CPSMode) {
return CacheAverageCPS;
}
if (CMOptions.CalcWrink === 0) {
return Game.cookiesPs * (1 - Game.cpsSucked);
}
if (CMOptions.CalcWrink === 1) {
return (
Game.cookiesPs *
(CacheCurrWrinklerCPSMult + (1 - CacheCurrWrinklerCount * 0.05))
);
}
if (CacheWrinklersFattest[1] !== null)
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

@@ -0,0 +1,33 @@
import {
ColourGray,
ColourGreen,
ColourOrange,
ColourPurple,
ColourRed,
ColourYellow,
} from '../VariablesAndData';
/**
* This function returns Name and Colour as object for sugar lump type that is given as input param.
* It is called by CM.Disp.UpdateTooltipSugarLump()
* @param {string} type Sugar Lump Type.
* @returns {{string}, {string}} text, color An array containing the text and display-color of the sugar lump
*/
export default function GetLumpColour(type) {
if (type === 0) {
return { text: 'Normal', color: ColourGray };
}
if (type === 1) {
return { text: 'Bifurcated', color: ColourGreen };
}
if (type === 2) {
return { text: 'Golden', color: ColourYellow };
}
if (type === 3) {
return { text: 'Meaty', color: ColourOrange };
}
if (type === 4) {
return { text: 'Caramelized', color: ColourPurple };
}
return { text: 'Unknown Sugar Lump', color: ColourRed };
}

View File

@@ -0,0 +1,20 @@
import {
CacheWrinklersFattest,
CacheWrinklersTotal,
} from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData';
/**
* This function returns the total amount stored in the Wrinkler Bank
* as calculated by CM.Cache.CacheWrinklers() if CM.Options.CalcWrink is set
* @returns {number} 0 or the amount of cookies stored (CM.Cache.WrinklersTotal)
*/
export default function GetWrinkConfigBank() {
if (CMOptions.CalcWrink === 1) {
return CacheWrinklersTotal;
}
if (CMOptions.CalcWrink === 2) {
return CacheWrinklersFattest[0];
}
return 0;
}

View File

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

View File

@@ -0,0 +1,17 @@
import UpdateBuildings from '../BuildingsUpgrades/Buildings';
import UpdateUpgrades from '../BuildingsUpgrades/Upgrades';
import { UpdateBotBar } from '../InfoBars/BottomBar';
/**
* This function refreshes all numbers after a change in scale-setting
* 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() {
BeautifyAll();
Game.RefreshStore();
Game.RebuildUpgrades();
UpdateBotBar();
UpdateBuildings();
UpdateUpgrades();
}

View File

@@ -0,0 +1,20 @@
import { ToggleTimerBar } from '../../Config/SpecificToggles';
import ToggleBotBar from '../../Config/Toggles/ToggleBotBar';
import { CMOptions } from '../../Config/VariablesAndData';
import UpdateBackground from './UpdateBackground';
/**
* This function disables and shows the bars created by CookieMonster when the game is "ascending"
* It is called by CM.Disp.Draw()
*/
export default function UpdateAscendState() {
if (Game.OnAscend) {
l('game').style.bottom = '0px';
if (CMOptions.BotBar === 1) l('CMBotBar').style.display = 'none';
if (CMOptions.TimerBar === 1) l('CMTimerBar').style.display = 'none';
} else {
ToggleBotBar();
ToggleTimerBar();
}
UpdateBackground();
}

View File

@@ -0,0 +1,15 @@
/**
* This function sets the size of the background of the full game and the left column
* depending on whether certain abrs are activated
* It is called by CM.Disp.UpdateAscendState() and CM.Disp.UpdateBotTimerBarPosition()
*/
export default function UpdateBackground() {
Game.Background.canvas.width = Game.Background.canvas.parentNode.offsetWidth;
Game.Background.canvas.height =
Game.Background.canvas.parentNode.offsetHeight;
Game.LeftBackground.canvas.width =
Game.LeftBackground.canvas.parentNode.offsetWidth;
Game.LeftBackground.canvas.height =
Game.LeftBackground.canvas.parentNode.offsetHeight;
Game.DrawBackground();
}

View File

@@ -0,0 +1,33 @@
import { CMOptions } from '../../Config/VariablesAndData';
import UpdateBuildings from '../BuildingsUpgrades/Buildings';
import {
ColourBackPre,
ColourBorderPre,
ColoursOrdering,
ColourTextPre,
} from '../VariablesAndData';
/**
* This function changes/refreshes colours if the user has set new standard colours
* The function is therefore called by a change in CM.Options.Colours
*/
export default function UpdateColours() {
let str = '';
for (let i = 0; i < ColoursOrdering.length; i++) {
str += `.${ColourTextPre}${ColoursOrdering[i]} { color: ${
CMOptions[`Colour${ColoursOrdering[i]}`]
}; }\n`;
}
for (let i = 0; i < ColoursOrdering.length; i++) {
str += `.${ColourBackPre}${ColoursOrdering[i]} { background-color: ${
CMOptions[`Colour${ColoursOrdering[i]}`]
}; }\n`;
}
for (let i = 0; i < ColoursOrdering.length; i++) {
str += `.${ColourBorderPre}${ColoursOrdering[i]} { border: 1px solid ${
CMOptions[`Colour${ColoursOrdering[i]}`]
}; }\n`;
}
l('CMCSS').textContent = str;
UpdateBuildings(); // Class has been already set
}

View File

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

View File

@@ -0,0 +1,97 @@
/** Functions to create various DOM elements used by the Bars */
import { ColourBackPre, ColourBlue, ColourTextPre } from '../VariablesAndData';
/**
* This function creates an indivudual timer for the timer bar
* @param {string} id An id to identify the timer
* @param {string} name The title 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) {
const timerBar = document.createElement('div');
timerBar.id = id;
timerBar.style.height = '12px';
timerBar.style.margin = '0px 10px';
timerBar.style.position = 'relative';
const div = document.createElement('div');
div.style.width = '100%';
div.style.height = '10px';
div.style.margin = 'auto';
div.style.position = 'absolute';
div.style.left = '0px';
div.style.top = '0px';
div.style.right = '0px';
div.style.bottom = '0px';
const type = document.createElement('span');
type.style.display = 'inline-block';
type.style.textAlign = 'right';
type.style.fontSize = '10px';
type.style.width = '108px';
type.style.marginRight = '5px';
type.style.verticalAlign = 'text-top';
type.textContent = name;
div.appendChild(type);
for (let i = 0; i < bars.length; i++) {
const colorBar = document.createElement('span');
colorBar.id = bars[i].id;
colorBar.style.display = 'inline-block';
colorBar.style.height = '10px';
colorBar.style.verticalAlign = 'text-top';
colorBar.style.textAlign = 'center';
if (bars.length - 1 === i) {
colorBar.style.borderTopRightRadius = '10px';
colorBar.style.borderBottomRightRadius = '10px';
}
if (typeof bars[i].color !== 'undefined') {
colorBar.className = ColourBackPre + bars[i].color;
}
div.appendChild(colorBar);
}
const timer = document.createElement('span');
timer.id = `${id}Time`;
timer.style.marginLeft = '5px';
timer.style.verticalAlign = 'text-top';
div.appendChild(timer);
timerBar.appendChild(div);
return timerBar;
}
/**
* This function extends the bottom bar (created by CM.Disp.CreateBotBar) with a column for the given building.
* @param {string} buildingName Objectname to be added (e.g., "Cursor")
*/
export function CreateBotBarBuildingColumn(buildingName) {
if (l('CMBotBar') !== null) {
const type = l('CMBotBar').firstChild.firstChild.childNodes[0];
const bonus = l('CMBotBar').firstChild.firstChild.childNodes[1];
const pp = l('CMBotBar').firstChild.firstChild.childNodes[2];
const time = l('CMBotBar').firstChild.firstChild.childNodes[3];
const i = buildingName;
const header = type.appendChild(document.createElement('td'));
header.appendChild(
document.createTextNode(
`${i.indexOf(' ') !== -1 ? i.substring(0, i.indexOf(' ')) : i} (`,
),
);
const span = header.appendChild(document.createElement('span'));
span.className = ColourTextPre + ColourBlue;
header.appendChild(document.createTextNode(')'));
type.lastChild.style.paddingLeft = '8px';
bonus.appendChild(document.createElement('td'));
bonus.lastChild.style.paddingLeft = '8px';
pp.appendChild(document.createElement('td'));
pp.lastChild.style.paddingLeft = '8px';
time.appendChild(document.createElement('td'));
time.lastChild.style.paddingLeft = '2px';
}
}

View File

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

View File

@@ -0,0 +1,38 @@
/**
* This function creates two objects at the top of the right column that allowing hiding the upgrade and building section
*/
export default function CreateSectionHideButtons() {
const div = document.createElement('div');
div.id = 'CMSectionHidButtons';
div.style.textAlign = 'center';
const a = document.createElement('a');
a.className = 'option';
a.onclick = function () {
if (l('upgrades').style.display === 'flex') {
l('upgrades').style.display = 'none';
l('toggleUpgrades').style.display = 'none';
l('techUpgrades').style.display = 'none';
l('vaultUpgrades').style.display = 'none';
} else {
l('upgrades').style.display = 'flex';
if (l('toggleUpgrades').children.length !== 0)
l('toggleUpgrades').style.display = 'block';
if (l('techUpgrades').children.length !== 0)
l('techUpgrades').style.display = 'block';
if (l('vaultUpgrades').children.length !== 0)
l('vaultUpgrades').style.display = 'block';
}
};
a.textContent = 'Hide/Show Upgrades';
div.appendChild(a);
const b = document.createElement('a');
b.className = 'option';
b.onclick = function () {
if (l('products').style.display === 'grid')
l('products').style.display = 'none';
else l('products').style.display = 'grid';
};
b.textContent = 'Hide/Show Buildings';
div.appendChild(b);
l('store').insertBefore(div, l('store').childNodes[2]);
}

View File

@@ -0,0 +1,54 @@
import { CacheWrinklersFattest } from '../../Cache/VariablesAndData';
import PopAllNormalWrinklers from '../HelperFunctions/PopWrinklers';
import { CreateTooltip } from '../Tooltips/Tooltip';
/**
* This function creates two objects at the bottom of the left column that allowing popping of wrinklers
*/
export default function CreateWrinklerButtons() {
const popAllA = document.createElement('a');
popAllA.id = 'PopAllNormalWrinklerButton';
popAllA.textContent = 'Pop All Normal';
popAllA.className = 'option';
popAllA.onclick = function () {
PopAllNormalWrinklers();
};
popAllA.onmouseout = function () {
Game.tooltip.shouldHide = 1;
};
popAllA.onmouseover = function () {
Game.tooltip.dynamic = 1;
Game.tooltip.draw(
this,
function () {
return CreateTooltip('wb', 'PopAll');
},
'this',
);
Game.tooltip.wobble();
};
l('sectionLeftExtra').children[0].append(popAllA);
const popFattestA = document.createElement('a');
popFattestA.id = 'PopFattestWrinklerButton';
popFattestA.textContent = 'Pop Single Fattest';
popFattestA.className = 'option';
popFattestA.onclick = function () {
if (CacheWrinklersFattest[1] !== null)
Game.wrinklers[CacheWrinklersFattest[1]].hp = 0;
};
popFattestA.onmouseout = function () {
Game.tooltip.shouldHide = 1;
};
popFattestA.onmouseover = function () {
Game.tooltip.dynamic = 1;
Game.tooltip.draw(
this,
function () {
return CreateTooltip('wb', 'PopFattest');
},
'this',
);
Game.tooltip.wobble();
};
l('sectionLeftExtra').children[0].append(popFattestA);
}

View File

@@ -0,0 +1,13 @@
import { DispCSS } from '../VariablesAndData';
/**
* This function creates a CSS style that stores certain standard CSS classes used by CookieMonster
*/
export default function CreateCssArea() {
DispCSS = document.createElement('style');
DispCSS.type = 'text/css';
DispCSS.id = 'CMCSS';
document.head.appendChild(DispCSS);
}

View File

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

View File

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

View File

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

View File

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

View File

@@ -0,0 +1,22 @@
/** Creates a Prompt similar to the base game without some of the stuff breaking them */
export default function CookieMonsterPrompt(content, options) {
Game.promptWrapL.className = 'framed';
const str = content;
Game.promptL.innerHTML = `${str}<div class="optionBox"></div>`;
Object.keys(options).forEach((i) => {
const option = document.createElement('a');
option.id = `promptOption${i}`;
option.className = 'option';
option.onclick = function () {
PlaySound('snd/tick.mp3');
options[i][1]();
};
option.textContent = options[i][0];
Game.promptL.children[1].appendChild(option);
});
Game.promptAnchorL.style.display = 'block';
Game.darkenL.style.display = 'block';
Game.promptL.focus();
Game.promptOn = 1;
Game.UpdatePrompt();
}

View File

@@ -0,0 +1,15 @@
import { CMOptions } from '../../Config/VariablesAndData';
/**
* This function refreshes the stats page, CM.Options.UpStats determines the rate at which that happens
* It is called by CM.Disp.Draw()
*/
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();
}

View File

@@ -0,0 +1,35 @@
import { ToggleHeader } from '../../../Config/ToggleSetting';
import { CMOptions } from '../../../Config/VariablesAndData';
/**
* This function creates a header-object for the options page
* @param {string} config The name of the Config-group
* @param {string} text The to-be displayed name of the header
* @returns {object} div The header object
*/
export default function CreatePrefHeader(config, text) {
const div = document.createElement('div');
div.className = 'title';
div.style.opacity = '0.7';
div.style.fontSize = '17px';
div.appendChild(document.createTextNode(`${text} `));
const span = document.createElement('span'); // Creates the +/- button
span.style.cursor = 'pointer';
span.style.display = 'inline-block';
span.style.height = '14px';
span.style.width = '14px';
span.style.borderRadius = '7px';
span.style.textAlign = 'center';
span.style.backgroundColor = '#C0C0C0';
span.style.color = 'black';
span.style.fontSize = '13px';
span.style.verticalAlign = 'middle';
span.textContent = CMOptions.Header[config] ? '-' : '+';
span.onclick = function () {
ToggleHeader(config);
Game.UpdateMenu();
};
div.appendChild(span);
return div;
}

View File

@@ -0,0 +1,234 @@
import jscolor, * as JsColor from '@eastdesire/jscolor';
import ToggleFavouriteSetting from '../../../Config/Toggles/ToggleFavourites';
import { SaveConfig } from '../../../Config/SaveLoadReload/SaveLoadReloadSettings';
import {
ConfigPrefix,
ToggleConfig,
ToggleConfigVolume,
} from '../../../Config/ToggleSetting';
import { CMOptions } from '../../../Config/VariablesAndData';
import {} from '../../../Data/Sectionheaders';
import Config from '../../../Data/SettingsData';
import RefreshScale from '../../HelperFunctions/RefreshScale';
import UpdateColours from '../../HelperFunctions/UpdateColours';
import Flash from '../../Notifications/Flash';
import PlaySound from '../../Notifications/Sound';
import {
FavouriteSettings,
SimpleTooltipElements,
} from '../../VariablesAndData';
import CookieMonsterPrompt from '../Prompt';
/**
* This function creates the favourite setting star object
* @param {string} config The name of the option
* @returns {object} div The option object
*/
function CreateFavouriteStar(config) {
const FavStar = document.createElement('a');
if (FavouriteSettings.includes(config)) {
FavStar.innerText = '★';
FavStar.style.color = 'yellow';
} else FavStar.innerText = '☆';
FavStar.className = 'option';
FavStar.onclick = function () {
ToggleFavouriteSetting(config);
SaveConfig();
Game.UpdateMenu();
};
FavStar.onmouseover = function () {
Game.tooltip.draw(
this,
escape(SimpleTooltipElements.FavouriteSettingPlaceholder.innerHTML),
);
};
FavStar.onmouseout = function () {
Game.tooltip.hide();
};
FavStar.appendChild(document.createTextNode(' '));
return FavStar;
}
/**
* This function creates an option-object for the options page
* @param {string} config The name of the option
* @returns {object} div The option object
*/
export default function CreatePrefOption(config) {
const div = document.createElement('div');
div.className = 'listing';
if (CMOptions.FavouriteSettings === 1) {
div.appendChild(CreateFavouriteStar(config));
}
if (Config[config].type === 'bool') {
const a = document.createElement('a');
if (Config[config].toggle && CMOptions[config] === 0) {
a.className = 'option off';
} else {
a.className = 'option';
}
a.id = ConfigPrefix + config;
a.onclick = function () {
ToggleConfig(config);
};
a.textContent = Config[config].label[CMOptions[config]];
div.appendChild(a);
const label = document.createElement('label');
label.textContent = Config[config].desc;
label.style.lineHeight = '1.6';
div.appendChild(label);
return div;
}
if (Config[config].type === 'vol') {
const volume = document.createElement('div');
volume.className = 'sliderBox';
const title = document.createElement('div');
title.style.float = 'left';
title.innerHTML = Config[config].desc;
volume.appendChild(title);
const percent = document.createElement('div');
percent.id = `slider${config}right`;
percent.style.float = 'right';
percent.innerHTML = `${CMOptions[config]}%`;
volume.appendChild(percent);
const slider = document.createElement('input');
slider.className = 'slider';
slider.id = `slider${config}`;
slider.style.clear = 'both';
slider.type = 'range';
slider.min = '0';
slider.max = '100';
slider.step = '1';
slider.value = CMOptions[config];
slider.oninput = function () {
ToggleConfigVolume(config);
};
slider.onchange = function () {
ToggleConfigVolume(config);
};
volume.appendChild(slider);
div.appendChild(volume);
const a = document.createElement('a');
a.className = 'option';
a.onclick = function () {
PlaySound(
CMOptions[config.replace('Volume', 'SoundURL')],
config.replace('Volume', 'Sound'),
config,
true,
);
};
a.textContent = 'Test sound';
div.appendChild(a);
return div;
}
if (Config[config].type === 'url') {
const span = document.createElement('span');
span.className = 'option';
span.textContent = `${Config[config].label} `;
span.style.lineHeight = '1.6';
div.appendChild(span);
const input = document.createElement('input');
input.id = ConfigPrefix + config;
input.className = 'option';
input.type = 'text';
input.readOnly = true;
input.setAttribute('value', CMOptions[config]);
input.style.width = '300px';
div.appendChild(input);
div.appendChild(document.createTextNode(' '));
const inputPrompt = document.createElement('input');
inputPrompt.id = `${ConfigPrefix + config}Prompt`;
inputPrompt.className = 'option';
inputPrompt.type = 'text';
inputPrompt.setAttribute('value', CMOptions[config]);
const a = document.createElement('a');
a.className = 'option';
a.onclick = function () {
CookieMonsterPrompt(inputPrompt.outerHTML, [
[
'Save',
function () {
CMOptions[config] = l(`${ConfigPrefix}${config}Prompt`).value;
SaveConfig();
Game.ClosePrompt();
Game.UpdateMenu();
},
],
[
'Cancel',
function () {
Game.ClosePrompt();
},
],
]);
};
a.textContent = 'Edit';
div.appendChild(a);
const label = document.createElement('label');
label.textContent = Config[config].desc;
label.style.lineHeight = '1.6';
div.appendChild(label);
return div;
}
if (Config[config].type === 'colour') {
const innerSpan = document.createElement('span');
innerSpan.className = 'option';
const input = document.createElement('input');
input.id = config;
input.style.width = '65px';
input.setAttribute('value', CMOptions[config]);
innerSpan.appendChild(input);
const change = function () {
CMOptions[this.targetElement.id] = this.toHEXString();
UpdateColours();
SaveConfig();
Game.UpdateMenu();
};
// eslint-disable-next-line no-new
new JsColor(input, { hash: true, position: 'right', onInput: change });
const label = document.createElement('label');
label.textContent = Config[config].desc;
label.style.lineHeight = '1.6';
innerSpan.appendChild(label);
if (config.includes('Flash')) {
const a = document.createElement('a');
a.className = 'option';
a.onclick = function () {
Flash(3, config.replace('Colour', ''), true);
};
a.textContent = 'Test flash';
innerSpan.appendChild(a);
}
div.appendChild(innerSpan);
jscolor.init();
return div;
}
if (Config[config].type === 'numscale') {
const span = document.createElement('span');
span.className = 'option';
span.textContent = `${Config[config].label} `;
span.style.lineHeight = '1.6';
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 () {
CMOptions[config] = this.value;
SaveConfig();
RefreshScale();
};
div.appendChild(input);
div.appendChild(document.createTextNode(' '));
const label = document.createElement('label');
label.textContent = Config[config].desc;
label.style.lineHeight = '1.6';
div.appendChild(label);
return div;
}
return div;
}

View File

@@ -0,0 +1,79 @@
import { LoadConfig } from '../../../Config/SaveLoadReload/SaveLoadReloadSettings';
import { CMOptions } from '../../../Config/VariablesAndData';
import {
ConfigGroups,
ConfigGroupsNotification,
} from '../../../Data/Sectionheaders';
import Config from '../../../Data/SettingsData';
import ConfigDefault from '../../../Data/SettingsDefault';
import { FavouriteSettings } from '../../VariablesAndData';
import CreatePrefHeader from './CreateHeader';
import CreatePrefOption from './CreateOption';
/**
* This function adds the options/settings of CookieMonster to the options page
* It is called by CM.Disp.AddMenu
* @param {object} title On object that includes the title of the menu
*/
export default function AddMenuPref(title) {
const frag = document.createDocumentFragment();
frag.appendChild(title);
Object.keys(ConfigGroups).forEach((group) => {
if (group === 'Favourite') {
if (FavouriteSettings.length !== 0 && CMOptions.FavouriteSettings > 0) {
frag.appendChild(CreatePrefHeader(group, ConfigGroups[group])); // (group, display-name of group)
if (CMOptions.Header[group])
for (let index = 0; index < FavouriteSettings.length; index++) {
frag.appendChild(CreatePrefOption(FavouriteSettings[index]));
}
}
} else {
frag.appendChild(CreatePrefHeader(group, ConfigGroups[group])); // (group, display-name of group)
if (CMOptions.Header[group]) {
// 0 is show, 1 is collapsed
// Make sub-sections of Notification section
if (group === 'Notification') {
Object.keys(ConfigGroupsNotification).forEach((subGroup) => {
const subGroupObject = CreatePrefHeader(
subGroup,
ConfigGroupsNotification[subGroup],
); // (group, display-name of group)
subGroupObject.style.fontSize = '15px';
subGroupObject.style.opacity = '0.5';
frag.appendChild(subGroupObject);
if (CMOptions.Header[subGroup]) {
Object.keys(Config).forEach((option) => {
if (Config[option].group === subGroup)
frag.appendChild(CreatePrefOption(option));
});
}
});
} else {
Object.keys(Config).forEach((option) => {
if (Config[option].group === group)
frag.appendChild(CreatePrefOption(option));
});
}
}
}
});
const resDef = document.createElement('div');
resDef.className = 'listing';
const resDefBut = document.createElement('a');
resDefBut.className = 'option';
resDefBut.onclick = function () {
LoadConfig(ConfigDefault);
};
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
],
);
}

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