Merge pull request #779 from DanielNoord/lintingandtoggle

Linting and new toggle
This commit is contained in:
Daniël van Noord
2021-04-30 20:44:57 +02:00
committed by GitHub
33 changed files with 235 additions and 351 deletions

View File

@@ -11,24 +11,15 @@
"BeautifyAll": "readonly",
"PlaySound": "readonly"
},
"extends": [
"airbnb-base",
"plugin:prettier/recommended"
],
"extends": ["airbnb-base", "prettier"],
"parserOptions": {
"ecmaVersion": 12
},
"plugins": [
"@typescript-eslint"
],
"plugins": ["@typescript-eslint"],
"overrides": [
{
"files": [
"src/**/*.{ts,tsx}"
],
"extends": [
"plugin:@typescript-eslint/recommended"
],
"files": ["src/**/*.{ts,tsx}"],
"extends": ["plugin:@typescript-eslint/recommended"],
"parser": "@typescript-eslint/parser",
"rules": {
"import/extensions": "off", // To allow importing .ts without errors
@@ -36,11 +27,7 @@
}
}
],
"ignorePatterns": [
"*CookieMonster*.js",
"dist/*",
"node_modules/*"
],
"ignorePatterns": ["*CookieMonster*.js", "dist/*", "node_modules/*"],
"rules": {
"import/no-mutable-exports": "off", // We need to this throughout Cookie Monster
"no-plusplus": [
@@ -56,15 +43,6 @@
"object": true,
"array": false
}
], // Importing arrays and then destructuring them seems to fail
"max-len": [
1,
{
"code": 100,
"ignoreComments": true,
"ignoreStrings": true,
"ignoreTemplateLiterals": true
}
]
] // Importing arrays and then destructuring them seems to fail
}
}

View File

@@ -1,4 +1,5 @@
{
"printWidth": 100,
"singleQuote": true,
"trailingComma": "all"
}

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

File diff suppressed because one or more lines are too long

80
package-lock.json generated
View File

@@ -14,14 +14,13 @@
"devDependencies": {
"@types/chai": "^4.2.16",
"@types/mocha": "^8.2.2",
"@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.21.0",
"chai": "^4.3.4",
"eslint": "^7.23.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^8.1.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.3.1",
"esm": "^3.2.25",
"mocha": "^8.3.2",
"npm-run-all": "^4.1.5",
@@ -1420,9 +1419,9 @@
}
},
"node_modules/eslint-config-prettier": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.1.0.tgz",
"integrity": "sha512-oKMhGv3ihGbCIimCAjqkdzx2Q+jthoqnXSP+d86M9tptwugycmTFdVR4IpLgq2c4SHifbwO90z2fQ8/Aio73yw==",
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.3.0.tgz",
"integrity": "sha512-BgZuLUSeKzvlL/VUjx/Yb787VQ26RU3gGjA3iiFvdsp/2bMfVIWUVP7tjxtjS0e+HP409cPlPvNkQloz8C91ew==",
"dev": true,
"bin": {
"eslint-config-prettier": "bin/cli.js"
@@ -1539,27 +1538,6 @@
"integrity": "sha1-VgiurfwAvmwpAd9fmGF4jeDVl8g=",
"dev": true
},
"node_modules/eslint-plugin-prettier": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.3.1.tgz",
"integrity": "sha512-Rq3jkcFY8RYeQLgk2cCwuc0P7SEFwDravPhsJZOQ5N4YI4DSg50NyqJ/9gdZHzQlHf8MvafSesbNJCcP/FF6pQ==",
"dev": true,
"dependencies": {
"prettier-linter-helpers": "^1.0.0"
},
"engines": {
"node": ">=6.0.0"
},
"peerDependencies": {
"eslint": ">=5.0.0",
"prettier": ">=1.13.0"
},
"peerDependenciesMeta": {
"eslint-config-prettier": {
"optional": true
}
}
},
"node_modules/eslint-scope": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
@@ -1749,12 +1727,6 @@
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
"dev": true
},
"node_modules/fast-diff": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz",
"integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==",
"dev": true
},
"node_modules/fast-glob": {
"version": "3.2.5",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.5.tgz",
@@ -3461,18 +3433,6 @@
"node": ">=10.13.0"
}
},
"node_modules/prettier-linter-helpers": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz",
"integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==",
"dev": true,
"dependencies": {
"fast-diff": "^1.1.2"
},
"engines": {
"node": ">=6.0.0"
}
},
"node_modules/process-nextick-args": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",
@@ -5947,9 +5907,9 @@
}
},
"eslint-config-prettier": {
"version": "8.1.0",
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.1.0.tgz",
"integrity": "sha512-oKMhGv3ihGbCIimCAjqkdzx2Q+jthoqnXSP+d86M9tptwugycmTFdVR4IpLgq2c4SHifbwO90z2fQ8/Aio73yw==",
"version": "8.3.0",
"resolved": "https://registry.npmjs.org/eslint-config-prettier/-/eslint-config-prettier-8.3.0.tgz",
"integrity": "sha512-BgZuLUSeKzvlL/VUjx/Yb787VQ26RU3gGjA3iiFvdsp/2bMfVIWUVP7tjxtjS0e+HP409cPlPvNkQloz8C91ew==",
"dev": true,
"requires": {}
},
@@ -6055,15 +6015,6 @@
}
}
},
"eslint-plugin-prettier": {
"version": "3.3.1",
"resolved": "https://registry.npmjs.org/eslint-plugin-prettier/-/eslint-plugin-prettier-3.3.1.tgz",
"integrity": "sha512-Rq3jkcFY8RYeQLgk2cCwuc0P7SEFwDravPhsJZOQ5N4YI4DSg50NyqJ/9gdZHzQlHf8MvafSesbNJCcP/FF6pQ==",
"dev": true,
"requires": {
"prettier-linter-helpers": "^1.0.0"
}
},
"eslint-scope": {
"version": "5.1.1",
"resolved": "https://registry.npmjs.org/eslint-scope/-/eslint-scope-5.1.1.tgz",
@@ -6203,12 +6154,6 @@
"integrity": "sha512-f3qQ9oQy9j2AhBe/H9VC91wLmKBCCU/gDOnKNAYG5hswO7BLKj09Hc5HYNz9cGI++xlpDCIgDaitVs03ATR84Q==",
"dev": true
},
"fast-diff": {
"version": "1.2.0",
"resolved": "https://registry.npmjs.org/fast-diff/-/fast-diff-1.2.0.tgz",
"integrity": "sha512-xJuoT5+L99XlZ8twedaRf6Ax2TgQVxvgZOYoPKqZufmJib0tL2tegPBOZb1pVNgIhlqDlA0eO0c3wBvQcmzx4w==",
"dev": true
},
"fast-glob": {
"version": "3.2.5",
"resolved": "https://registry.npmjs.org/fast-glob/-/fast-glob-3.2.5.tgz",
@@ -7466,15 +7411,6 @@
"integrity": "sha512-PqyhM2yCjg/oKkFPtTGUojv7gnZAoG80ttl45O6x2Ug/rMJw4wcc9k6aaf2hibP7BGVCCM33gZoGjyvt9mm16Q==",
"dev": true
},
"prettier-linter-helpers": {
"version": "1.0.0",
"resolved": "https://registry.npmjs.org/prettier-linter-helpers/-/prettier-linter-helpers-1.0.0.tgz",
"integrity": "sha512-GbK2cP9nraSSUF9N2XwUwqfzlAFlMNYYl+ShE/V+H8a9uNl/oUqB1w2EL54Jh0OlyRSd8RfWYJ3coVS4TROP2w==",
"dev": true,
"requires": {
"fast-diff": "^1.1.2"
}
},
"process-nextick-args": {
"version": "2.0.1",
"resolved": "https://registry.npmjs.org/process-nextick-args/-/process-nextick-args-2.0.1.tgz",

View File

@@ -47,14 +47,13 @@
"devDependencies": {
"@types/chai": "^4.2.16",
"@types/mocha": "^8.2.2",
"@typescript-eslint/eslint-plugin": "^4.21.0",
"@typescript-eslint/eslint-plugin": "^4.22.0",
"@typescript-eslint/parser": "^4.21.0",
"chai": "^4.3.4",
"eslint": "^7.23.0",
"eslint-config-airbnb-base": "^14.2.1",
"eslint-config-prettier": "^8.1.0",
"eslint-config-prettier": "^8.3.0",
"eslint-plugin-import": "^2.22.1",
"eslint-plugin-prettier": "^3.3.1",
"esm": "^3.2.25",
"mocha": "^8.3.2",
"npm-run-all": "^4.1.5",

View File

@@ -6,8 +6,6 @@ import { FavouriteSettings } from '../../Disp/VariablesAndData';
*/
export default function ToggleFavouriteSetting(config) {
if (FavouriteSettings.includes(config))
FavouriteSettings = FavouriteSettings.filter(function (ele) {
return ele !== config;
});
FavouriteSettings = FavouriteSettings.filter((ele) => ele !== config);
else FavouriteSettings.push(config);
}

View File

@@ -0,0 +1,20 @@
import { CMOptions } from '../VariablesAndData';
/**
* This function toggles the upgrade to be always expanded
* It is called by a change in CM.Options.ToolWarnPos
* and upon creation of the warning tooltip by CM.Disp.UpdateTooltipWarnings()
*/
export default function ToggleUpgradeSectionsAlwaysExpanded() {
Object.values(document.getElementsByClassName('storeSection')).forEach((section) => {
if (CMOptions.UpgradesNeverCollapse || section.id === 'products') {
section.style.height = 'auto'; // eslint-disable-line no-param-reassign
} else if (section.id === 'vaultUpgrades') {
section.style.height = '30px'; // eslint-disable-line no-param-reassign
} else if (section.id === 'upgrades') {
section.style.height = '60px'; // eslint-disable-line no-param-reassign
} else {
section.style.height = '60px'; // eslint-disable-line no-param-reassign
}
});
}

View File

@@ -7,6 +7,7 @@ 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 ToggleUpgradeSectionsAlwaysExpanded from '../Config/Toggles/ToggleUpgradeSectionsAlwaysExpanded';
import ToggleWrinklerButtons from '../Config/Toggles/ToggleWrinklerButtons';
import { CMOptions } from '../Config/VariablesAndData';
import UpdateBuildings from '../Disp/BuildingsUpgrades/Buildings';
@@ -68,7 +69,7 @@ const Config = {
],
'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
},
),
@@ -87,7 +88,7 @@ const Config = {
],
'Change how long numbers are formatted',
false,
function () {
() => {
RefreshScale();
},
),
@@ -97,7 +98,7 @@ const Config = {
['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();
},
),
@@ -107,7 +108,7 @@ const Config = {
['. for decimals (standard)', '. for thousands'],
'Set the separator used for decimals and thousands',
false,
function () {
() => {
RefreshScale();
},
),
@@ -132,7 +133,7 @@ const Config = {
['Detailed time OFF', 'Detailed time ON'],
'Change how time is displayed in certain statistics and tooltips',
true,
function () {
() => {
ToggleDetailedTime();
},
),
@@ -151,7 +152,7 @@ const Config = {
['Building colours OFF', 'Building colours ON'],
'Colour code buildings',
true,
function () {
() => {
UpdateBuildings();
},
),
@@ -242,7 +243,7 @@ const Config = {
['Bottom bar OFF', 'Bottom bar ON'],
'Building information',
true,
function () {
() => {
ToggleBotBar();
},
),
@@ -252,7 +253,7 @@ const Config = {
['Timer bar OFF', 'Timer bar ON'],
'Bar with timers for golden cookie, season popup, Frenzy (Normal, Clot, Elder), Click Frenzy',
true,
function () {
() => {
ToggleTimerBar();
},
),
@@ -262,32 +263,24 @@ const Config = {
['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',
],
['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',
],
['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();
},
),
@@ -297,7 +290,7 @@ const Config = {
['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();
},
),
@@ -311,7 +304,7 @@ const Config = {
],
'Sort the display of buildings in either default order or by PP',
false,
function () {
() => {
UpdateBuildings();
},
),
@@ -321,10 +314,20 @@ const Config = {
['Sort upgrades: default', 'Sort upgrades: PP'],
'Sort the display of upgrades in either default order or by PP',
false,
function () {
() => {
UpdateUpgrades();
},
),
UpgradesNeverCollapse: new SettingStandard(
'bool',
'BarsDisplay',
['Upgrades always expanded OFF', 'Upgrades always expanded ON'],
'Toggle to make the upgrades sections always expanded to the size needed to display all upgrades',
true,
() => {
ToggleUpgradeSectionsAlwaysExpanded();
},
),
DragonAuraInfo: new SettingStandard(
'bool',
'BarsDisplay',
@@ -345,7 +348,7 @@ const Config = {
['Golden cookie timer OFF', 'Golden cookie timer ON'],
'A timer on the golden cookie when it has been spawned',
true,
function () {
() => {
ToggleGCTimer();
},
),
@@ -355,7 +358,7 @@ const Config = {
['Favicon OFF', 'Favicon ON'],
'Update favicon with golden/wrath cookie',
true,
function () {
() => {
UpdateFavicon();
},
),
@@ -365,7 +368,7 @@ const Config = {
['Extra wrinkler buttons OFF', 'Extra wrinkler buttons ON'],
'Show buttons for popping wrinklers at bottom of cookie section',
true,
function () {
() => {
ToggleWrinklerButtons();
},
),
@@ -375,7 +378,7 @@ const Config = {
['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();
},
),
@@ -384,10 +387,7 @@ const Config = {
TooltipBuildUpgrade: new SettingStandard(
'bool',
'Tooltip',
[
'Building/upgrade tooltip information OFF',
'Building/upgrade tooltip information ON',
],
['Building/upgrade tooltip information OFF', 'Building/upgrade tooltip information ON'],
'Extra information in building/upgrade tooltips',
true,
),
@@ -447,10 +447,7 @@ const Config = {
ToolWarnBon: new SettingStandard(
'bool',
'Tooltip',
[
'Calculate tooltip warning with bonus CPS OFF',
'Calculate tooltip warning with bonus CPS ON',
],
['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,
),
@@ -460,7 +457,7 @@ const Config = {
['Tooltip warning position (left)', 'Tooltip warning position (bottom)'],
'Placement of the warning boxes',
false,
function () {
() => {
ToggleToolWarnPos();
},
),
@@ -573,7 +570,7 @@ const Config = {
['Notification OFF', 'Notification ON'],
'Create a notification when golden cookie spawns',
true,
function () {
() => {
CheckNotificationPermissions(CMOptions.GCNotification);
},
),
@@ -609,7 +606,7 @@ const Config = {
['Notification OFF', 'Notification ON'],
'Create a notification when fortune cookie is on the ticker',
true,
function () {
() => {
CheckNotificationPermissions(CMOptions.FortuneNotification);
},
),
@@ -645,7 +642,7 @@ const Config = {
['Notification OFF', 'Notification ON'],
'Create a notification on season popup',
true,
function () {
() => {
CheckNotificationPermissions(CMOptions.SeaNotification);
},
),
@@ -707,7 +704,7 @@ const Config = {
['Notification OFF', 'Notification ON'],
'Create a notification when magic reaches maximum',
true,
function () {
() => {
CheckNotificationPermissions(CMOptions.MagicNotification);
},
),
@@ -743,7 +740,7 @@ const Config = {
['Notification OFF', 'Notification ON'],
'Create a notification when a wrinkler appears',
true,
function () {
() => {
CheckNotificationPermissions(CMOptions.WrinklerNotification);
},
),
@@ -779,7 +776,7 @@ const Config = {
['Notification OFF', 'Notification ON'],
'Create a notification when the maximum amount of wrinklers has appeared',
true,
function () {
() => {
CheckNotificationPermissions(CMOptions.WrinklerMaxNotification);
},
),
@@ -802,12 +799,7 @@ const Config = {
'Play a sound when the maximum amount of wrinklers has appeared',
true,
),
WrinklerMaxVolume: new SettingVolume(
'vol',
'NotificationWrinkMax',
[],
'Volume',
),
WrinklerMaxVolume: new SettingVolume('vol', 'NotificationWrinkMax', [], 'Volume'),
WrinklerMaxSoundURL: new SettingStandard(
'url',
'NotificationWrinkMax',
@@ -833,7 +825,7 @@ const Config = {
],
"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();
},
),

View File

@@ -35,6 +35,7 @@ const ConfigDefault: {
UpgradeBarFixedPos: 1,
SortBuildings: 0,
SortUpgrades: 0,
UpgradesNeverCollapse: 0,
DragonAuraInfo: 1,
GrimoireBar: 1,
GCTimer: 1,

View File

@@ -70,16 +70,14 @@ export default function UpdateBuildings() {
return o;
});
arr.sort(function (a, b) {
return ColoursOrdering.indexOf(a.color) > // eslint-disable-line no-nested-ternary
arr.sort((a, b) => 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;
});
: 0);
} else if (CMOptions.SortBuildings === 2) {
arr = Object.keys(target).map((k) => {
const o = target[k];
@@ -88,16 +86,14 @@ export default function UpdateBuildings() {
return o;
});
arr.sort(function (a, b) {
return ColoursOrdering.indexOf(a.color) > // eslint-disable-line no-nested-ternary
arr.sort((a, b) => 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;
});
: 0);
}
for (let x = 0; x < arr.length; x++) {

View File

@@ -79,15 +79,13 @@ export default function UpdateUpgrades() {
}
if (CMOptions.SortUpgrades) {
arr.sort(function (a, b) {
return ColoursOrdering.indexOf(a.color) > ColoursOrdering.indexOf(b.color) // eslint-disable-line no-nested-ternary
arr.sort((a, b) => 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;
});
: 0);
} else {
arr.sort((a, b) => a.price - b.price);
}

View File

@@ -20,9 +20,7 @@ export default function CreateWrinklerButtons() {
Game.tooltip.dynamic = 1;
Game.tooltip.draw(
this,
function () {
return CreateTooltip('wb', 'PopAll');
},
() => CreateTooltip('wb', 'PopAll'),
'this',
);
Game.tooltip.wobble();
@@ -43,9 +41,7 @@ export default function CreateWrinklerButtons() {
Game.tooltip.dynamic = 1;
Game.tooltip.draw(
this,
function () {
return CreateTooltip('wb', 'PopFattest');
},
() => CreateTooltip('wb', 'PopFattest'),
'this',
);
Game.tooltip.wobble();

View File

@@ -68,13 +68,11 @@ export default function AddMissingAchievements() {
Game.tooltip.dynamic = 1;
Game.tooltip.draw(
this,
function () {
return (function () {
() => (function () {
return CrateTooltipLockedAchievements(
Game.AchievementsById[id],
);
})();
},
})(),
'top',
);
Game.tooltip.wobble();

View File

@@ -21,17 +21,17 @@ export default function Flash(mode, config, forced) {
l('CMFlashScreen').style.opacity = '0.5';
if (mode === 3) {
l('CMFlashScreen').style.display = 'inline';
setTimeout(function () {
setTimeout(() => {
Flash(2, config, true);
}, 1000 / Game.fps);
} else {
setTimeout(function () {
setTimeout(() => {
Flash(0, config, true);
}, 1000 / Game.fps);
}
} else if (mode === 2) {
l('CMFlashScreen').style.opacity = '1';
setTimeout(function () {
setTimeout(() => {
Flash(1, config, true);
}, 1000 / Game.fps);
} else if (mode === 0) l('CMFlashScreen').style.display = 'none';

View File

@@ -54,13 +54,7 @@ export function TooltipCreateWarningSection() {
TooltipWarn.style.bottom = 'auto';
TooltipWarn.id = 'CMDispTooltipWarningParent';
const create = function (
boxId,
color,
labelTextFront,
labelTextBack,
deficitId,
) {
const create = function (boxId, color, labelTextFront, labelTextBack, deficitId) {
const box = document.createElement('div');
box.id = boxId;
box.style.display = 'none';
@@ -182,18 +176,14 @@ export function TooltipCreateCalculationSection(tooltip) {
tooltip.appendChild(time);
if (TooltipType === 'b') {
tooltip.appendChild(
TooltipCreateHeader('Production left till next achievement'),
);
tooltip.appendChild(TooltipCreateHeader('Production left till next achievement'));
tooltip.lastChild.id = 'CMTooltipProductionLeftHeader'; // eslint-disable-line no-param-reassign
const production = document.createElement('div');
production.id = 'CMTooltipProductionLeft';
tooltip.appendChild(production);
}
if (TooltipType === 'b') {
tooltip.appendChild(
TooltipCreateHeader('Buildings (price / PP) left till next achievement'),
);
tooltip.appendChild(TooltipCreateHeader('Buildings (price / PP) left till next achievement'));
tooltip.lastChild.id = 'CMTooltipNextAchievementHeader'; // eslint-disable-line no-param-reassign
const production = document.createElement('div');
production.id = 'CMTooltipNextAchievement';

View File

@@ -14,9 +14,7 @@ export default function ReplaceTooltipGrimoire() {
Game.tooltip.dynamic = 1;
Game.tooltip.draw(
this,
function () {
return CreateTooltip('g', `${i}`);
},
() => CreateTooltip('g', `${i}`),
'this',
);
Game.tooltip.wobble();

View File

@@ -17,9 +17,7 @@ export default function ReplaceTooltipUpgrade() {
Game.tooltip.dynamic = 1;
Game.tooltip.draw(
this,
function () {
return CreateTooltip('u', `${i}`);
},
() => CreateTooltip('u', `${i}`),
'store',
);
Game.tooltip.wobble();

View File

@@ -21,9 +21,7 @@ function ReplaceTooltipBuild() {
Game.tooltip.dynamic = 1;
Game.tooltip.draw(
this,
function () {
return CreateTooltip('b', `${i}`);
},
() => CreateTooltip('b', `${i}`),
'store',
);
Game.tooltip.wobble();
@@ -42,9 +40,7 @@ function ReplaceTooltipLump() {
Game.tooltip.dynamic = 1;
Game.tooltip.draw(
this,
function () {
return CreateTooltip('s', 'Lump');
},
() => CreateTooltip('s', 'Lump'),
'this',
);
Game.tooltip.wobble();
@@ -61,9 +57,7 @@ function ReplaceTooltipGarden() {
Game.tooltip.dynamic = 1;
Game.tooltip.draw(
this,
function () {
return CreateTooltip('ha', 'HarvestAllButton');
},
() => CreateTooltip('ha', 'HarvestAllButton'),
'this',
);
Game.tooltip.wobble();
@@ -75,9 +69,7 @@ function ReplaceTooltipGarden() {
Game.tooltip.dynamic = 1;
Game.tooltip.draw(
this,
function () {
return CreateTooltip('p', [`${coords[0]}`, `${coords[2]}`]);
},
() => CreateTooltip('p', [`${coords[0]}`, `${coords[2]}`]),
'this',
);
Game.tooltip.wobble();
@@ -93,9 +85,7 @@ function ReplaceTooltipPantheon() {
Game.tooltip.dynamic = 1;
Game.tooltip.draw(
this,
function () {
return CreateTooltip('pag', i);
},
() => CreateTooltip('pag', i),
'this',
);
Game.tooltip.wobble();
@@ -106,12 +96,10 @@ function ReplaceTooltipPantheon() {
Game.tooltip.dynamic = 1;
Game.tooltip.draw(
this,
function () {
return CreateTooltip('pas', [
() => CreateTooltip('pas', [
i,
Game.Objects.Temple.minigame.slot[i],
]);
},
]),
'this',
);
Game.tooltip.wobble();

View File

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

View File

@@ -1,8 +1,5 @@
import CacheDragonAuras from '../../Cache/Dragon/CacheDragonAuras';
import {
CacheDragonAura,
CacheDragonAura2,
} from '../../Cache/VariablesAndData';
import { CacheDragonAura, CacheDragonAura2 } from '../../Cache/VariablesAndData';
import { CreateBotBarBuildingColumn } from '../../Disp/InfoBars/CreateDOMElements';
import InitAchievement from '../InitializeData/InitAchievement';
import InitialBuildingData from '../InitializeData/InitialBuildingData';

View File

@@ -5,28 +5,28 @@ import { l, Game } from '../../GlobalsForTesting';
import ToggleBotBar from '../../../src/Config/Toggles/ToggleBotBar';
import { CMOptions } from '../../../src/Config/VariablesAndData';
describe('ToggleBotBar', function () {
describe('ToggleBotBar', () => {
global.l = l;
global.Game = Game;
beforeEach(function () {
beforeEach(() => {
global.domids = {};
ToggleBotBar();
});
describe('BotBar = 0', function () {
before(function () {
describe('BotBar = 0', () => {
before(() => {
CMOptions.BotBar = 0;
});
it('Toggle style correctly', function () {
it('Toggle style correctly', () => {
assert.equal(domids.CMBotBar.style.display, 'none'); // eslint-disable-line no-undef
});
});
describe('BotBar = 1', function () {
before(function () {
describe('BotBar = 1', () => {
before(() => {
CMOptions.BotBar = 1;
});
it('Toggle style correctly', function () {
it('Toggle style correctly', () => {
assert.equal(domids.CMBotBar.style.display, ''); // eslint-disable-line no-undef
});
});

View File

@@ -6,27 +6,27 @@ import { CMOptions } from '../../../src/Config/VariablesAndData';
import ToggleDetailedTime from '../../../src/Config/Toggles/ToggleDetailedTime';
import { BackupFunctions } from '../../../src/Main/VariablesAndData';
describe('ToggleDetailedTime', function () {
describe('ToggleDetailedTime', () => {
global.Game = Game;
beforeEach(function () {
beforeEach(() => {
ToggleDetailedTime();
});
describe('DetailedTime = 0', function () {
before(function () {
describe('DetailedTime = 0', () => {
before(() => {
CMOptions.DetailedTime = 0;
BackupFunctions.sayTime = 'BackupFunctions.sayTime';
});
it('Set correct time function', function () {
it('Set correct time function', () => {
assert.equal(Game.sayTime, 'BackupFunctions.sayTime');
});
});
describe('DetailedTime = 1', function () {
before(function () {
describe('DetailedTime = 1', () => {
before(() => {
CMOptions.DetailedTime = 1;
});
it('Set correct time function', function () {
it('Set correct time function', () => {
assert.equal(Game.sayTime.name, 'CMSayTime');
});
});

View File

@@ -4,12 +4,12 @@ import { assert } from 'chai';
import ToggleFavouriteSetting from '../../../src/Config/Toggles/ToggleFavourites';
import { FavouriteSettings } from '../../../src/Disp/VariablesAndData';
describe('ToggleFavouriteSetting', function () {
beforeEach(function () {
describe('ToggleFavouriteSetting', () => {
beforeEach(() => {
global.domids = {};
});
// TODO: Can't write test for checking existing config due to Babel/Typescript problem
it('New config', function () {
it('New config', () => {
FavouriteSettings.push('TestConfig');
ToggleFavouriteSetting('TestConfig2');
assert.deepEqual(FavouriteSettings, ['TestConfig', 'TestConfig2']);

View File

@@ -7,10 +7,10 @@ import ToggleGCTimer from '../../../src/Config/Toggles/ToggleGCTimer';
import { GCTimers } from '../../../src/Disp/VariablesAndData';
import { CacheGoldenShimmersByID } from '../../../src/Cache/VariablesAndData';
describe('ToggleGCTimer', function () {
describe('ToggleGCTimer', () => {
global.l = l;
beforeEach(function () {
beforeEach(() => {
global.domids = {};
GCTimers[0] = { style: {} };
GCTimers[1] = { style: {} };
@@ -23,20 +23,20 @@ describe('ToggleGCTimer', function () {
ToggleGCTimer();
});
describe('GCTimer = 0', function () {
before(function () {
describe('GCTimer = 0', () => {
before(() => {
CMOptions.GCTimer = 0;
});
it('Toggle style correctly', function () {
it('Toggle style correctly', () => {
assert.equal(GCTimers[0].style.display, 'none');
assert.equal(GCTimers[1].style.display, 'none');
});
});
describe('GCTimer = 1', function () {
before(function () {
describe('GCTimer = 1', () => {
before(() => {
CMOptions.GCTimer = 1;
});
it('Toggle style correctly', function () {
it('Toggle style correctly', () => {
assert.equal(GCTimers[0].style.display, 'block');
assert.equal(GCTimers[0].style.left, 'Test00');
assert.equal(GCTimers[0].style.top, 'Test01');

View File

@@ -5,27 +5,27 @@ import { l } from '../../GlobalsForTesting';
import { CMOptions } from '../../../src/Config/VariablesAndData';
import ToggleSectionHideButtons from '../../../src/Config/Toggles/ToggleSectionHideButtons';
describe('ToggleSectionHideButtons', function () {
describe('ToggleSectionHideButtons', () => {
global.l = l;
beforeEach(function () {
beforeEach(() => {
global.domids = {};
ToggleSectionHideButtons();
});
describe('HideSectionsButtons = 0', function () {
before(function () {
describe('HideSectionsButtons = 0', () => {
before(() => {
CMOptions.HideSectionsButtons = 0;
});
it('Toggle style correctly', function () {
it('Toggle style correctly', () => {
assert.equal(domids.CMSectionHidButtons.style.display, 'none'); // eslint-disable-line no-undef
});
});
describe('HideSectionsButtons = 1', function () {
before(function () {
describe('HideSectionsButtons = 1', () => {
before(() => {
CMOptions.HideSectionsButtons = 1;
});
it('Toggle style correctly', function () {
it('Toggle style correctly', () => {
assert.equal(domids.CMSectionHidButtons.style.display, ''); // eslint-disable-line no-undef
});
});

View File

@@ -5,29 +5,29 @@ import { l } from '../../GlobalsForTesting';
import { CMOptions } from '../../../src/Config/VariablesAndData';
import ToggleToolWarnPos from '../../../src/Config/Toggles/ToggleToolWarnPos';
describe('ToggleToolWarnPos', function () {
describe('ToggleToolWarnPos', () => {
global.l = l;
beforeEach(function () {
beforeEach(() => {
global.domids = {};
ToggleToolWarnPos();
});
describe('ToolWarnPos = 0', function () {
before(function () {
describe('ToolWarnPos = 0', () => {
before(() => {
CMOptions.ToolWarnPos = 0;
});
it('Toggle style correctly', function () {
it('Toggle style correctly', () => {
assert.equal(domids.CMDispTooltipWarningParent.style.top, 'auto'); // eslint-disable-line no-undef
assert.equal(domids.CMDispTooltipWarningParent.style.margin, '4px -4px'); // eslint-disable-line no-undef
assert.equal(domids.CMDispTooltipWarningParent.style.padding, '3px 4px'); // eslint-disable-line no-undef
});
});
describe('ToolWarnPos = 1', function () {
before(function () {
describe('ToolWarnPos = 1', () => {
before(() => {
CMOptions.ToolWarnPos = 1;
});
it('Toggle style correctly', function () {
it('Toggle style correctly', () => {
assert.equal(domids.CMDispTooltipWarningParent.style.right, 'auto'); // eslint-disable-line no-undef
assert.equal(domids.CMDispTooltipWarningParent.style.margin, '4px'); // eslint-disable-line no-undef
assert.equal(domids.CMDispTooltipWarningParent.style.padding, '4px 3px'); // eslint-disable-line no-undef

View File

@@ -5,36 +5,36 @@ import { l, Game } from '../../GlobalsForTesting';
import { CMOptions } from '../../../src/Config/VariablesAndData';
import ToggleUpgradeBarAndColor from '../../../src/Config/Toggles/ToggleUpgradeBarAndColour';
describe('ToggleUpgradeBarAndColor', function () {
describe('ToggleUpgradeBarAndColor', () => {
global.l = l;
global.Game = Game;
beforeEach(function () {
beforeEach(() => {
global.domids = {};
ToggleUpgradeBarAndColor();
});
describe('UpBarColor = 0', function () {
before(function () {
describe('UpBarColor = 0', () => {
before(() => {
CMOptions.UpBarColor = 0;
});
it('Toggle style correctly', function () {
it('Toggle style correctly', () => {
assert.equal(domids.CMUpgradeBar.style.display, 'none'); // eslint-disable-line no-undef
});
});
describe('UpBarColor = 1', function () {
before(function () {
describe('UpBarColor = 1', () => {
before(() => {
CMOptions.UpBarColor = 1;
});
it('Toggle style correctly', function () {
it('Toggle style correctly', () => {
assert.equal(domids.CMUpgradeBar.style.display, ''); // eslint-disable-line no-undef
});
});
describe('UpBarColor = 2', function () {
before(function () {
describe('UpBarColor = 2', () => {
before(() => {
CMOptions.UpBarColor = 2;
});
it('Toggle style correctly', function () {
it('Toggle style correctly', () => {
assert.equal(domids.CMUpgradeBar.style.display, 'none'); // eslint-disable-line no-undef
});
});

View File

@@ -5,27 +5,27 @@ import { l } from '../../GlobalsForTesting';
import { CMOptions } from '../../../src/Config/VariablesAndData';
import ToggleUpgradeBarFixedPos from '../../../src/Config/Toggles/ToggleUpgradeBarFixedPos';
describe('ToggleUpgradeBarFixedPos', function () {
describe('ToggleUpgradeBarFixedPos', () => {
global.l = l;
beforeEach(function () {
beforeEach(() => {
global.domids = {};
ToggleUpgradeBarFixedPos();
});
describe('UpgradeBarFixedPos = 0', function () {
before(function () {
describe('UpgradeBarFixedPos = 0', () => {
before(() => {
CMOptions.UpgradeBarFixedPos = 0;
});
it('Toggle style correctly', function () {
it('Toggle style correctly', () => {
assert.equal(domids.CMUpgradeBar.style.position, ''); // eslint-disable-line no-undef
});
});
describe('UpgradeBarFixedPos = 1', function () {
before(function () {
describe('UpgradeBarFixedPos = 1', () => {
before(() => {
CMOptions.UpgradeBarFixedPos = 1;
});
it('Toggle style correctly', function () {
it('Toggle style correctly', () => {
assert.equal(domids.CMUpgradeBar.style.position, 'sticky'); // eslint-disable-line no-undef
assert.equal(domids.CMUpgradeBar.style.top, '0px'); // eslint-disable-line no-undef
});

View File

@@ -5,56 +5,56 @@ import { l, Game } from '../../GlobalsForTesting';
import { CMOptions } from '../../../src/Config/VariablesAndData';
import ToggleWrinklerButtons from '../../../src/Config/Toggles/ToggleWrinklerButtons';
describe('ToggleWrinklerButtons', function () {
describe('ToggleWrinklerButtons', () => {
global.l = l;
global.Game = Game;
beforeEach(function () {
beforeEach(() => {
global.domids = {};
ToggleWrinklerButtons();
});
describe('WrinklerButtons = 0', function () {
before(function () {
describe('WrinklerButtons = 0', () => {
before(() => {
CMOptions.WrinklerButtons = 0;
});
describe('Game.elderWrath = 0', function () {
before(function () {
describe('Game.elderWrath = 0', () => {
before(() => {
Game.elderWrath = 0;
});
it('Toggle style correctly', function () {
it('Toggle style correctly', () => {
assert.equal(domids.PopAllNormalWrinklerButton.style.display, 'none'); // eslint-disable-line no-undef
assert.equal(domids.PopFattestWrinklerButton.style.display, 'none'); // eslint-disable-line no-undef
});
});
describe('Game.elderWrath = 1', function () {
before(function () {
describe('Game.elderWrath = 1', () => {
before(() => {
Game.elderWrath = 1;
});
it('Toggle style correctly', function () {
it('Toggle style correctly', () => {
assert.equal(domids.PopAllNormalWrinklerButton.style.display, 'none'); // eslint-disable-line no-undef
assert.equal(domids.PopFattestWrinklerButton.style.display, 'none'); // eslint-disable-line no-undef
});
});
});
describe('WrinklerButtons = 1', function () {
before(function () {
describe('WrinklerButtons = 1', () => {
before(() => {
CMOptions.WrinklerButtons = 1;
});
describe('Game.elderWrath = 0', function () {
before(function () {
describe('Game.elderWrath = 0', () => {
before(() => {
Game.elderWrath = 0;
});
it('Toggle style correctly', function () {
it('Toggle style correctly', () => {
assert.equal(domids.PopAllNormalWrinklerButton.style.display, 'none'); // eslint-disable-line no-undef
assert.equal(domids.PopFattestWrinklerButton.style.display, 'none'); // eslint-disable-line no-undef
});
});
describe('Game.elderWrath = 1', function () {
before(function () {
describe('Game.elderWrath = 1', () => {
before(() => {
Game.elderWrath = 1;
});
it('Toggle style correctly', function () {
it('Toggle style correctly', () => {
assert.equal(domids.PopAllNormalWrinklerButton.style.display, ''); // eslint-disable-line no-undef
assert.equal(domids.PopFattestWrinklerButton.style.display, ''); // eslint-disable-line no-undef
});

View File

@@ -4,102 +4,102 @@ import { assert } from 'chai';
import FormatTime from '../../src/Disp/BeautifyAndFormatting/FormatTime';
import { CMOptions } from '../../src/Config/VariablesAndData';
describe('FormatTime', function () {
it('Format when time is Infinity', function () {
describe('FormatTime', () => {
it('Format when time is Infinity', () => {
assert.equal(FormatTime(Infinity, 0), Infinity);
});
it('Format when time is negative', function () {
it('Format when time is negative', () => {
assert.equal(FormatTime(-1, 0), 'Negative time period');
});
describe('TimeFormat = 0', function () {
before(function () {
describe('TimeFormat = 0', () => {
before(() => {
CMOptions.TimeFormat = 0;
});
describe('Longformat = 0', function () {
it('Format when time is 0', function () {
describe('Longformat = 0', () => {
it('Format when time is 0', () => {
assert.equal(FormatTime(0, 0), '0s');
});
it('Format when time is 1 second', function () {
it('Format when time is 1 second', () => {
assert.equal(FormatTime(1, 0), '1s');
});
it('Format when time is over 1 minute', function () {
it('Format when time is over 1 minute', () => {
assert.equal(FormatTime(61, 0), '1m, 1s');
});
it('Format when time is over 1 hour', function () {
it('Format when time is over 1 hour', () => {
assert.equal(FormatTime(3601, 0), '1h, 0m, 1s');
});
it('Format when time is over 1 day', function () {
it('Format when time is over 1 day', () => {
assert.equal(FormatTime(86401, 0), '1d, 0h, 0m, 1s');
});
it('Format when time is over 1 year', function () {
it('Format when time is over 1 year', () => {
assert.equal(FormatTime(31536001, 0), '1y, 0d, 0h, 0m, 1s');
});
it('Format when time is over >9000 days', function () {
it('Format when time is over >9000 days', () => {
assert.equal(FormatTime(777600001, 0), '>9000d');
});
it('Format when time is over >99.9 years', function () {
it('Format when time is over >99.9 years', () => {
assert.equal(FormatTime(3155760001, 0), '>9000d');
});
});
describe('Longformat = 1', function () {
it('Format when time is 0', function () {
describe('Longformat = 1', () => {
it('Format when time is 0', () => {
assert.equal(FormatTime(0, 1), '0 seconds');
});
it('Format when time is 1 second', function () {
it('Format when time is 1 second', () => {
assert.equal(FormatTime(1, 1), '1 second');
});
it('Format when time is over 1 minute', function () {
it('Format when time is over 1 minute', () => {
assert.equal(FormatTime(61, 1), '1 minute, 1 second');
});
it('Format when time is over 1 hour', function () {
it('Format when time is over 1 hour', () => {
assert.equal(FormatTime(3601, 1), '1 hour, 0 minutes, 1 second');
});
it('Format when time is over 1 day', function () {
it('Format when time is over 1 day', () => {
assert.equal(
FormatTime(86401, 1),
'1 day, 0 hours, 0 minutes, 1 second',
);
});
it('Format when time is over 1 year', function () {
it('Format when time is over 1 year', () => {
assert.equal(
FormatTime(31536001, 1),
'1 year, 0 days, 0 hours, 0 minutes, 1 second',
);
});
it('Format when time is over >9000 days', function () {
it('Format when time is over >9000 days', () => {
assert.equal(FormatTime(777600001, 1), 'Over 9000 days!');
});
it('Format when time is over >99.9 years', function () {
it('Format when time is over >99.9 years', () => {
assert.equal(FormatTime(3155760001, 1), 'Over 9000 days!');
});
});
});
describe('TimeFormat = 1', function () {
before(function () {
describe('TimeFormat = 1', () => {
before(() => {
CMOptions.TimeFormat = 1;
});
it('Format when time is 0', function () {
it('Format when time is 0', () => {
assert.equal(FormatTime(0, 0), '00:00:00:00:00');
});
it('Format when time is 1 second', function () {
it('Format when time is 1 second', () => {
assert.equal(FormatTime(1, 0), '00:00:00:00:01');
});
it('Format when time is over 1 minute', function () {
it('Format when time is over 1 minute', () => {
assert.equal(FormatTime(61, 0), '00:00:00:01:01');
});
it('Format when time is over 1 hour', function () {
it('Format when time is over 1 hour', () => {
assert.equal(FormatTime(3601, 0), '00:00:01:00:01');
});
it('Format when time is over 1 day', function () {
it('Format when time is over 1 day', () => {
assert.equal(FormatTime(86401, 0), '00:01:00:00:01');
});
it('Format when time is over 1 year', function () {
it('Format when time is over 1 year', () => {
assert.equal(FormatTime(31536001, 0), '01:00:00:00:01');
});
it('Format when time is over >9000 days', function () {
it('Format when time is over >9000 days', () => {
assert.equal(FormatTime(777600001, 0), '24:240:00:00:01');
});
it('Format when time is over >99.9 years', function () {
it('Format when time is over >99.9 years', () => {
assert.equal(FormatTime(3155760001, 0), 'XX:XX:XX:XX:XX');
});
});

View File

@@ -4,41 +4,41 @@ import { expect } from 'chai';
import GetTimeColour from '../../src/Disp/BeautifyAndFormatting/GetTimeColour';
import { CMOptions } from '../../src/Config/VariablesAndData';
describe('GetTimeColour', function () {
it('Format when time is less than 60', function () {
describe('GetTimeColour', () => {
it('Format when time is less than 60', () => {
expect(GetTimeColour(59).color).to.deep.equal('Yellow');
});
it('Format when time is more than 60', function () {
it('Format when time is more than 60', () => {
expect(GetTimeColour(61).color).to.deep.equal('Orange');
});
it('Format when time is more than 300', function () {
it('Format when time is more than 300', () => {
expect(GetTimeColour(301).color).to.deep.equal('Red');
});
describe('TimeFormat = 0', function () {
before(function () {
describe('TimeFormat = 0', () => {
before(() => {
CMOptions.TimeFormat = 0;
});
it('Format when time is 0', function () {
it('Format when time is 0', () => {
expect(GetTimeColour(0)).to.deep.equal({ text: 'Done!', color: 'Green' });
});
it('Format when time is negative', function () {
it('Format when time is negative', () => {
expect(GetTimeColour(-1)).to.deep.equal({
text: 'Done!',
color: 'Green',
});
});
});
describe('TimeFormat = 1', function () {
before(function () {
describe('TimeFormat = 1', () => {
before(() => {
CMOptions.TimeFormat = 1;
});
it('Format when time is 0', function () {
it('Format when time is 0', () => {
expect(GetTimeColour(0)).to.deep.equal({
text: '00:00:00:00:00',
color: 'Green',
});
});
it('Format when time is negative', function () {
it('Format when time is negative', () => {
expect(GetTimeColour(-1)).to.deep.equal({
text: '00:00:00:00:00',
color: 'Green',