Add prettier to pre-commit and run it

This commit is contained in:
Daniël van Noord
2022-06-19 20:57:42 +02:00
parent 8cfc980546
commit ab73a78a01
22 changed files with 18468 additions and 102 deletions

View File

@@ -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

View File

@@ -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:
@@ -26,8 +25,7 @@ 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:
1.

View File

@@ -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:

View File

@@ -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'

View File

@@ -2,7 +2,7 @@ name: Publish
on:
push:
branches:
- "dev"
- 'dev'
jobs:
publish-dev:
runs-on: ubuntu-latest

9
.pre-commit-config.yaml Normal file
View File

@@ -0,0 +1,9 @@
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'

View File

@@ -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
@@ -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
@@ -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.
@@ -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

9185
dist/CookieMonster.js vendored

File diff suppressed because one or more lines are too long

9185
dist/CookieMonsterDev.js vendored

File diff suppressed because one or more lines are too long

View File

@@ -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];

View File

@@ -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)

View File

@@ -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],

View File

@@ -1,4 +1,3 @@
import Beautify from '../../BeautifyAndFormatting/Beautify';
import GetTimeColour from '../../BeautifyAndFormatting/GetTimeColour';
import CalculateGrimoireRefillTime from '../../HelperFunctions/CalculateGrimoireRefillTime';
@@ -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);
@@ -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);
}

View File

@@ -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;

View File

@@ -67,7 +67,7 @@ export default function ReplaceNative() {
l('bigCookie').addEventListener(
'click',
(event) => {
FixMouseY(()=> Game.ClickCookie(event,0));
FixMouseY(() => Game.ClickCookie(event, 0));
},
false,
);

View File

@@ -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;

View File

@@ -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;

View File

@@ -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;
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.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)) {

View File

@@ -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
@@ -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;

View File

@@ -33,7 +33,7 @@ function MouseCps() {
if (SimHas('Octillion fingers')) add *= 20;
if (SimHas('Nonillion fingers')) add *= 20;
if (SimHas('Decillion fingers')) add *= 20;
if (SimHas('Unshackled cursors')) add*= 25;
if (SimHas('Unshackled cursors')) add *= 25;
let num = 0;
Object.keys(SimObjects).forEach((i) => {
num += SimObjects[i].amount;