Expose building and upgrade data to global scope

This commit is contained in:
Daniël van Noord
2021-05-06 20:27:17 +02:00
parent cc2a754425
commit 5a045e7ac4
5 changed files with 24 additions and 4 deletions

View File

@@ -19,7 +19,8 @@ max(cost - cookies in bank, 0)/cps + cost/Δ cps
If the relevant option is enabled, CM will color-code each of them based on their value. CM 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. Note that sometimes it is better to buy 10 of a building than to buy only 1, CM will also indicate this! If the relevant option is enabled, CM will color-code each of them based on their value. CM 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. Note that sometimes it is better to buy 10 of a building than to buy only 1, CM will also indicate this!
The following standard colours are used: <details>
<summary>The following standard colours are used:</summary>
* Light Blue: (upgrades) This item has a better PP than the best building to buy * Light Blue: (upgrades) This item has a better PP than the best building to buy
* Green: This building has the best PP * Green: This building has the best PP
@@ -29,6 +30,8 @@ The following standard colours are used:
* Purple: This building is worse than the top 10 of best PP's * Purple: This building is worse than the top 10 of best PP's
* Gray: This item does not have a PP, often this means that there is no change to CPS * Gray: This item does not have a PP, often this means that there is no change to CPS
</details>
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.
## Using ## Using
@@ -59,6 +62,12 @@ Before submitting a bug, make sure to give a shot at the latest version of the a
All suggestions are welcome, even the smallest ones. All suggestions are welcome, even the smallest ones.
## For developers
Cookie Monster exposes some of the data it creates to the global scope. This data can be found in the `CookieMonsterData` object after loading Cookie Monster.
Currently we exposes relevant data for buildings and upgrades (PP, colour and bonus income). If you would like us to add any aditional data, please feel free to open an issue or create a PR doing so!
## Contributing ## Contributing
To contribute you can fork and clone the repository and run `npm install`. To contribute you can fork and clone the repository and run `npm install`.

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,7 @@
/** /**
* Section: Functions related to caching PP */ * Section: Functions related to caching PP */
import { CacheObjects1, CacheObjects10, CacheObjects100, CacheUpgrades } from '../VariablesAndData';
import CacheBuildingsPP from './Building'; import CacheBuildingsPP from './Building';
import CacheUpgradePP from './Upgrade'; import CacheUpgradePP from './Upgrade';
@@ -11,4 +12,11 @@ import CacheUpgradePP from './Upgrade';
export default function CachePP() { export default function CachePP() {
CacheBuildingsPP(); CacheBuildingsPP();
CacheUpgradePP(); CacheUpgradePP();
window.CookieMonsterData.Objects1 = JSON.parse(JSON.stringify(CacheObjects1));
window.CookieMonsterData.Objects10 = JSON.parse(JSON.stringify(CacheObjects10));
window.CookieMonsterData.Objects100 = JSON.parse(JSON.stringify(CacheObjects100));
window.CookieMonsterData.Upgrades = [];
Object.entries(CacheUpgrades).forEach((i) => {
window.CookieMonsterData.Upgrades[i[0]] = JSON.parse(JSON.stringify(i[1]));
});
} }

View File

@@ -24,6 +24,9 @@ import AddWrinklerAreaDetect from './WrinklerArea/AddDetectArea';
* Initialization loop of Cookie Monster * Initialization loop of Cookie Monster
*/ */
export default function InitializeCookieMonster() { export default function InitializeCookieMonster() {
// Create global data object
window.CookieMonsterData = {};
InitData(); InitData();
CacheStatsCookies(); CacheStatsCookies();
InitCache(); InitCache();