Skip to content

Commit

Permalink
Merge branch 'dev' into dependabot/npm_and_yarn/eslint-config-airbnb-…
Browse files Browse the repository at this point in the history
…base-15.0.0
  • Loading branch information
DanielNoord committed Jun 19, 2022
2 parents 6aa4be9 + 5ebfdfd commit 8eb75d6
Show file tree
Hide file tree
Showing 22 changed files with 117 additions and 109 deletions.
19 changes: 10 additions & 9 deletions .github/CONTRIBUTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -2,17 +2,18 @@ Cookie Monster is written to modify Cookie Clicker as little as possible. This m

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
| 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
8 changes: 3 additions & 5 deletions .github/ISSUE_TEMPLATE/bug-report.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ body:
id: what-happened
attributes:
label: Bug description
description:
What is the bug about?
description: What is the bug about?
placeholder: |
# Please describe the bug and what you would have expected the mod to do
validations:
Expand All @@ -26,10 +25,9 @@ body:
id: reproduce
attributes:
label: To reproduce
description:
How can you reproduce the bug?
description: How can you reproduce the bug?
placeholder: |
The steps needed to reproduce the behavior:
The steps needed to reproduce the behavior:
1.
validations:
required: true
Expand Down
3 changes: 1 addition & 2 deletions .github/ISSUE_TEMPLATE/feature-request.yml
Original file line number Diff line number Diff line change
Expand Up @@ -16,8 +16,7 @@ body:
id: what-is-wanted
attributes:
label: Feature description
description:
Describe the function you'd like to see added to CookieMonster
description: Describe the function you'd like to see added to CookieMonster
placeholder: |
# A clear and concise description of what you want to happen.
validations:
Expand Down
6 changes: 3 additions & 3 deletions .github/dependabot.yml
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@

version: 2
updates:
- package-ecosystem: "npm"
directory: "/" # Location of package manifests
- package-ecosystem: 'npm'
directory: '/' # Location of package manifests
schedule:
interval: "weekly"
interval: 'weekly'
58 changes: 29 additions & 29 deletions .github/workflows/CI.yml
Original file line number Diff line number Diff line change
Expand Up @@ -12,32 +12,32 @@ jobs:
env:
GITHUB_REGISTERY_PAT: ${{ secrets.GITHUB_TOKEN }}
steps:
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 12
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npx eslint src
- name: Run Mocha tests
run: npx mocha
- name: Check if CookieMonsterDev.js is built correctly
run: |
npx webpack -o ./tmp --env minimize
if cmp <(head -n 2 dist/CookieMonsterDev.js) <(head -n 2 tmp/CookieMonsterDev.js); then
echo '### SUCCESS: CookieMonsterDev is built correctly! ###'
else
echo '### WARNING: CookieMonsterDev.js does not seem to be correct. Make sure to run "npm run build-dev" after saving all your changes! ###'
exit 1
fi
- name: Check if CookieMonster.js is built correctly
if: github.ref == 'refs/heads/master'
run: |
npx webpack -o ./tmp --env minimize --env finalfile
if cmp <(head -n 2 dist/CookieMonster.js) <(head -n 2 tmp/CookieMonster.js); then
echo '### SUCCESS: CookieMonster is built correctly! ###'
else
echo '### WARNING: CookieMonster.js does not seem to be correct. Make sure to run "npm run build-final" after saving all your changes! ###'
exit 1
fi
- uses: actions/checkout@v2
- uses: actions/setup-node@v2
with:
node-version: 12
- name: Install dependencies
run: npm ci
- name: Run ESLint
run: npx eslint src
- name: Run Mocha tests
run: npx mocha
- name: Check if CookieMonsterDev.js is built correctly
run: |
npx webpack -o ./tmp --env minimize
if cmp <(head -n 2 dist/CookieMonsterDev.js) <(head -n 2 tmp/CookieMonsterDev.js); then
echo '### SUCCESS: CookieMonsterDev is built correctly! ###'
else
echo '### WARNING: CookieMonsterDev.js does not seem to be correct. Make sure to run "npm run build-dev" after saving all your changes! ###'
exit 1
fi
- name: Check if CookieMonster.js is built correctly
if: github.ref == 'refs/heads/master'
run: |
npx webpack -o ./tmp --env minimize --env finalfile
if cmp <(head -n 2 dist/CookieMonster.js) <(head -n 2 tmp/CookieMonster.js); then
echo '### SUCCESS: CookieMonster is built correctly! ###'
else
echo '### WARNING: CookieMonster.js does not seem to be correct. Make sure to run "npm run build-final" after saving all your changes! ###'
exit 1
fi
2 changes: 1 addition & 1 deletion .github/workflows/publish-dev.yml
Original file line number Diff line number Diff line change
Expand Up @@ -2,7 +2,7 @@ name: Publish
on:
push:
branches:
- "dev"
- 'dev'
jobs:
publish-dev:
runs-on: ubuntu-latest
Expand Down
17 changes: 17 additions & 0 deletions .pre-commit-config.yaml
Original file line number Diff line number Diff line change
@@ -0,0 +1,17 @@
repos:
- repo: https://github.com/pre-commit/mirrors-prettier
rev: v2.7.1
hooks:
- id: prettier
args:
- '--print-width=100'
- '--single-quote'
- '--trailing-comma=all'
exclude: &build 'CookieMonster(Dev)?.js(.map)?'
- repo: https://github.com/pre-commit/pre-commit-hooks
rev: v4.3.0
hooks:
- id: trailing-whitespace
exclude: *build
- id: end-of-file-fixer
exclude: *build
2 changes: 1 addition & 1 deletion LICENSE.md
Original file line number Diff line number Diff line change
Expand Up @@ -18,4 +18,4 @@ FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
SOFTWARE.
SOFTWARE.
36 changes: 18 additions & 18 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -3,7 +3,7 @@
## 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.
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**.
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**.

### Current version

Expand All @@ -13,7 +13,7 @@ Github Pages is hosted from the `gh-pages` branch

### What it does

At its core, Cookie Monster computes an index for both buildings and upgrades: the **Payback Period (PP)**. CM will take *everything* in consideration, meaning if buying a building also unlocks an achievement which boosts your income, which unlocks an achievement, CM will know and highlight that building's value. CM uses the following formula to calculate the PP:
At its core, Cookie Monster computes an index for both buildings and upgrades: the **Payback Period (PP)**. CM will take _everything_ in consideration, meaning if buying a building also unlocks an achievement which boosts your income, which unlocks an achievement, CM will know and highlight that building's value. CM uses the following formula to calculate the PP:

```javascript
max(cost - cookies in bank, 0)/cps + cost/Δ cps
Expand All @@ -23,14 +23,14 @@ If the relevant option is enabled, CM will color-code each of them based on thei

<details>
<summary>The following standard colours are used:</summary>
* Light Blue: (upgrades) This item has a better PP than the best building to buy
* Green: This building has the best PP
* Yellow: This building is within the top 10 of best PP's
* Orange: This building is within the top 20 of best PP's
* Red: This building is within the top 30 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

- Light Blue: (upgrades) This item has a better PP than the best building to buy
- Green: This building has the best PP
- Yellow: This building is within the top 10 of best PP's
- Orange: This building is within the top 20 of best PP's
- Red: This building is within the top 30 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

</details>

Expand All @@ -45,7 +45,7 @@ Copy this code and save it as a bookmark. Paste it in the URL section. To activa
```javascript
javascript: (function () {
Game.LoadMod('https://cookiemonsterteam.github.io/CookieMonster/dist/CookieMonster.js');
}());
})();
```

If (for some reason) the above doesn't work, trying pasting everything after the <code>javascript:</code> bit into your browser's console.
Expand Down Expand Up @@ -80,10 +80,10 @@ Before pushing a new version to `main` and Github pages use the `build-final` co

## Contributors

* **[Raving_Kumquat](https://cookieclicker.wikia.com/wiki/User:Raving_Kumquat)**: Original author
* **[Maxime Fabre](https://github.com/Anahkiasen)**: Previous maintainer
* **[BlackenedGem](https://github.com/BlackenedGem)**: Golden/Wrath Cookie Favicons
* **[Sandworm](https://github.com/svschouw)**: Modified PP calculation
* **[Aktanusa](https://github.com/Aktanusa)**: Current maintainer
* **[DanielNoord](https://github.com/DanielNoord)**: Current maintainer
* **[bitsandbytes1708](https://github.com/bitsandbytes1708)**: Current maintainer
- **[Raving_Kumquat](https://cookieclicker.wikia.com/wiki/User:Raving_Kumquat)**: Original author
- **[Maxime Fabre](https://github.com/Anahkiasen)**: Previous maintainer
- **[BlackenedGem](https://github.com/BlackenedGem)**: Golden/Wrath Cookie Favicons
- **[Sandworm](https://github.com/svschouw)**: Modified PP calculation
- **[Aktanusa](https://github.com/Aktanusa)**: Current maintainer
- **[DanielNoord](https://github.com/DanielNoord)**: Current maintainer
- **[bitsandbytes1708](https://github.com/bitsandbytes1708)**: Current maintainer
2 changes: 1 addition & 1 deletion dist/CookieMonster.js.map

Large diffs are not rendered by default.

2 changes: 1 addition & 1 deletion dist/CookieMonsterDev.js.map

Large diffs are not rendered by default.

7 changes: 5 additions & 2 deletions src/Cache/Dragon/Dragon.js
Original file line number Diff line number Diff line change
Expand Up @@ -15,8 +15,11 @@ export default function CacheDragonCost() {
Game.dragonLevel < 25 &&
Game.dragonLevels[Game.dragonLevel].buy.toString().includes('sacrifice')
) {
const objectMatch = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/Objects\[(.*)\]/);
let target = objectMatch !== null ? objectMatch[1] : Game.ObjectsById[Game.dragonLevel-5].name;
const objectMatch = Game.dragonLevels[Game.dragonLevel].buy
.toString()
.match(/Objects\[(.*)\]/);
let target =
objectMatch !== null ? objectMatch[1] : Game.ObjectsById[Game.dragonLevel - 5].name;
const amount = Game.dragonLevels[Game.dragonLevel].buy
.toString()
.match(/sacrifice\((.*?)\)/)[1];
Expand Down
5 changes: 1 addition & 4 deletions src/Disp/BeautifyAndFormatting/FormatTime.js
Original file line number Diff line number Diff line change
Expand Up @@ -19,10 +19,7 @@ export default function FormatTime(time, longFormat) {

if (Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.settings.TimeFormat === 0) {
if (formattedTime > 777600000) return longFormat ? 'Over 9000 days!' : '>9000d';
str +=
y > 0
? `${y + (longFormat ? (y === 1 ? ' year' : ' years') : 'y')}, `
: '';
str += y > 0 ? `${y + (longFormat ? (y === 1 ? ' year' : ' years') : 'y')}, ` : '';
if (str.length > 0 || d > 0)
str += `${d + (longFormat ? (d === 1 ? ' day' : ' days') : 'd')}, `;
if (str.length > 0 || h > 0)
Expand Down
3 changes: 2 additions & 1 deletion src/Disp/MenuSections/AddMenus.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,8 @@ export default function AddMenu() {
title.textContent = 'Cookie Monster Statistics';
AddMenuStats(title);
}
} else if (Game.onMenu === 'prefs') { // Added because Framework is broken
} else if (Game.onMenu === 'prefs') {
// Added because Framework is broken
l('menu').childNodes[2].insertBefore(
createMenuOptions(),
l('menu').childNodes[2].childNodes[l('menu').childNodes[2].childNodes.length - 1],
Expand Down
19 changes: 3 additions & 16 deletions src/Disp/Tooltips/TypesOfTooltips/Grimoire.js
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@

import Beautify from '../../BeautifyAndFormatting/Beautify';
import GetTimeColour from '../../BeautifyAndFormatting/GetTimeColour';
import CalculateGrimoireRefillTime from '../../HelperFunctions/CalculateGrimoireRefillTime';
Expand Down Expand Up @@ -56,13 +55,7 @@ export default function Grimoire() {
const reward = document.createElement('span');
reward.style.color = '#33FF00';
reward.textContent = Beautify(
Math.max(
Math.min(
Game.cookies * 0.15,
Game.cookiesPs * 60 * 30
),
7
),
Math.max(Math.min(Game.cookies * 0.15, Game.cookiesPs * 60 * 30), 7),
2,
);
conjure.appendChild(reward);
Expand All @@ -72,14 +65,8 @@ export default function Grimoire() {
const loss = document.createElement('span');
loss.style.color = 'red';
loss.textContent = Beautify(
Math.min(
Game.cookies,
Math.min(
Game.cookies * 0.15,
Game.cookiesPs * 60 * 15
) + 13
),
2
Math.min(Game.cookies, Math.min(Game.cookies * 0.15, Game.cookiesPs * 60 * 15) + 13),
2,
);
conjure.appendChild(loss);
}
Expand Down
2 changes: 1 addition & 1 deletion src/Main/ReplaceGameElements/NativeGrimoire.js
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ function ReplaceNativeGrimoireDraw() {
minigame.magicBarTextL.innerHTML += ` (${FormatTime(
CalculateGrimoireRefillTime(minigame.magic, minigame.magicM, minigame.magicM),
)})`;
minigame.magicBarL.style.width = "75%" // TODO: Fix this after Orteil pushes fix to main game;
minigame.magicBarL.style.width = '75%'; // TODO: Fix this after Orteil pushes fix to main game;
}
};
HasReplaceNativeGrimoireDraw = true;
Expand Down
2 changes: 1 addition & 1 deletion src/Main/ReplaceGameFunctions/ReplaceNative.js
Original file line number Diff line number Diff line change
Expand Up @@ -67,7 +67,7 @@ export default function ReplaceNative() {
l('bigCookie').addEventListener(
'click',
(event) => {
FixMouseY(()=> Game.ClickCookie(event,0));
FixMouseY(() => Game.ClickCookie(event, 0));
},
false,
);
Expand Down
3 changes: 2 additions & 1 deletion src/Sim/Calculations/CalculateGains.js
Original file line number Diff line number Diff line change
Expand Up @@ -134,7 +134,8 @@ export default function CalculateGains() {
if (SimHas('Kitten specialists')) catMult *= 1 + milkProgress * 0.2 * milkMult;
if (SimHas('Kitten experts')) catMult *= 1 + milkProgress * 0.2 * milkMult;
if (SimHas('Kitten consultants')) catMult *= 1 + milkProgress * 0.2 * milkMult;
if (SimHas('Kitten assistants to the regional manager')) catMult *= 1 + milkProgress * 0.175 * milkMult;
if (SimHas('Kitten assistants to the regional manager'))
catMult *= 1 + milkProgress * 0.175 * milkMult;
if (SimHas('Kitten marketeers')) catMult *= 1 + milkProgress * 0.15 * milkMult;
if (SimHas('Kitten analysts')) catMult *= 1 + milkProgress * 0.125 * milkMult;
if (SimHas('Kitten executives')) catMult *= 1 + milkProgress * 0.115 * milkMult;
Expand Down
4 changes: 2 additions & 2 deletions src/Sim/ReplacedGameFunctions/SimAuraMult.js
Original file line number Diff line number Diff line change
Expand Up @@ -12,8 +12,8 @@ export default function SimAuraMult(what) {
n = 1;
if (
Game.dragonAuras[SimDragonAura].name === 'Reality Bending' ||
Game.dragonAuras[SimDragonAura2].name === 'Reality Bending' &&
Game.dragonLevel >= Game.dragonAurasBN[what].id + 4
(Game.dragonAuras[SimDragonAura2].name === 'Reality Bending' &&
Game.dragonLevel >= Game.dragonAurasBN[what].id + 4)
)
n += 0.1;
return n;
Expand Down
18 changes: 11 additions & 7 deletions src/Sim/ReplacedGameFunctions/SimGetTieredCpsMult.js
Original file line number Diff line number Diff line change
Expand Up @@ -5,15 +5,19 @@ import SimHas from './SimHas';
* This functions creates functions similarly to Game.GetTieredCpsMult but checks Sim Data instead of Game Data
*/
export default function SimGetTieredCpsMult(me) {

let mult = 1;
Object.keys(me.tieredUpgrades).forEach((i) => {
if (!Game.Tiers[me.tieredUpgrades[i].tier].special && SimHas(me.tieredUpgrades[i].name)){
let tierMult=2;
// unshackled multipliers
if (Game.ascensionMode!==1 && SimHas(me.unshackleUpgrade) && SimHas(Game.Tiers[me.tieredUpgrades[i].tier].unshackleUpgrade)) tierMult+=me.id===1?0.5:(20-me.id)*0.1;
mult*=tierMult;
};
if (!Game.Tiers[me.tieredUpgrades[i].tier].special && SimHas(me.tieredUpgrades[i].name)) {
let tierMult = 2;
// unshackled multipliers
if (
Game.ascensionMode !== 1 &&
SimHas(me.unshackleUpgrade) &&
SimHas(Game.Tiers[me.tieredUpgrades[i].tier].unshackleUpgrade)
)
tierMult += me.id === 1 ? 0.5 : (20 - me.id) * 0.1;
mult *= tierMult;
}
});
Object.keys(me.synergies).forEach((i) => {
if (SimHas(me.synergies[i].name)) {
Expand Down
6 changes: 3 additions & 3 deletions src/Sim/ReplacedGameFunctions/SimHasGod.js
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
import { SimGod1, SimGod2, SimGod3, SimObjects } from '../VariablesAndData';
import SimHasAura from './SimHasAura'
import SimHasAura from './SimHasAura';

/**
* This function checks for the current God level in the sim data
Expand All @@ -16,13 +16,13 @@ export default function SimHasGod(what) {
return 1;
}
if (SimGod2 === god.id) {
if (SimHasAura('Supreme Intellect')){
if (SimHasAura('Supreme Intellect')) {
return 1;
}
return 2;
}
if (SimGod3 === god.id) {
if (SimHasAura('Supreme Intellect')){
if (SimHasAura('Supreme Intellect')) {
return 2;
}
return 3;
Expand Down
Loading

0 comments on commit 8eb75d6

Please sign in to comment.