Changes according to Eslint

This commit is contained in:
Daniël van Noord
2021-03-16 09:32:50 +01:00
parent 26d8e75935
commit a65af049b6
63 changed files with 314 additions and 295 deletions

View File

@@ -6,7 +6,7 @@ import {
import { CMOptions } from '../../Config/VariablesAndData';
import CreateGCTimer from '../../Disp/GoldenCookieTimers/GoldenCookieTimers';
import Flash from '../../Disp/Notifications/Flash';
import Notification from '../../Disp/Notifications/Notification';
import CreateNotification from '../../Disp/Notifications/Notification';
import PlaySound from '../../Disp/Notifications/Sound';
import { UpdateFavicon } from '../../Disp/TabTitle/FavIcon';
import { GCTimers } from '../../Disp/VariablesAndData';
@@ -24,13 +24,13 @@ import {
function FindShimmer() {
CurrSpawnedGoldenCookieState = 0;
CacheGoldenShimmersByID = {};
for (const i of Object.keys(Game.shimmers)) {
Object.keys(Game.shimmers).forEach((i) => {
CacheGoldenShimmersByID[Game.shimmers[i].id] = Game.shimmers[i];
if (Game.shimmers[i].spawnLead && Game.shimmers[i].type === 'golden') {
CacheSpawnedGoldenShimmer = Game.shimmers[i];
CurrSpawnedGoldenCookieState += 1;
}
}
});
}
/**
@@ -39,42 +39,42 @@ function FindShimmer() {
*/
export default function CheckGoldenCookie() {
FindShimmer();
for (const i of Object.keys(GCTimers)) {
Object.keys(GCTimers).forEach((i) => {
if (typeof CacheGoldenShimmersByID[i] === 'undefined') {
GCTimers[i].parentNode.removeChild(GCTimers[i]);
delete GCTimers[i];
}
}
});
if (LastGoldenCookieState !== Game.shimmerTypes.golden.n) {
LastGoldenCookieState = Game.shimmerTypes.golden.n;
if (LastGoldenCookieState) {
if (LastSpawnedGoldenCookieState < CurrSpawnedGoldenCookieState) {
Flash(3, 'GCFlash');
PlaySound(CMOptions.GCSoundURL, 'GCSound', 'GCVolume');
Notification(
CreateNotification(
'GCNotification',
'Golden Cookie Spawned',
'A Golden Cookie has spawned. Click it now!',
);
}
for (const i of Object.keys(Game.shimmers)) {
Object.keys(Game.shimmers).forEach((i) => {
if (typeof GCTimers[Game.shimmers[i].id] === 'undefined') {
CreateGCTimer(Game.shimmers[i]);
}
}
});
}
UpdateFavicon();
LastSpawnedGoldenCookieState = CurrSpawnedGoldenCookieState;
if (CurrSpawnedGoldenCookieState === 0) CacheSpawnedGoldenShimmer = 0;
} else if (CMOptions.GCTimer === 1 && LastGoldenCookieState) {
for (const i of Object.keys(GCTimers)) {
Object.keys(GCTimers).forEach((i) => {
GCTimers[i].style.opacity = CacheGoldenShimmersByID[i].l.style.opacity;
GCTimers[i].style.transform =
CacheGoldenShimmersByID[i].l.style.transform;
GCTimers[i].textContent = Math.ceil(
CacheGoldenShimmersByID[i].life / Game.fps,
);
}
});
}
}

View File

@@ -1,6 +1,6 @@
import { CMOptions } from '../../Config/VariablesAndData';
import Flash from '../../Disp/Notifications/Flash';
import Notification from '../../Disp/Notifications/Notification';
import CreateNotification from '../../Disp/Notifications/Notification';
import PlaySound from '../../Disp/Notifications/Sound';
import { LastMagicBarFull } from '../VariablesAndData';
@@ -13,13 +13,13 @@ export default function CheckMagicMeter() {
Game.Objects['Wizard tower'].minigameLoaded &&
CMOptions.GrimoireBar === 1
) {
const minigame = Game.Objects['Wizard tower'].minigame;
const { minigame } = Game.Objects['Wizard tower'];
if (minigame.magic < minigame.magicM) LastMagicBarFull = false;
else if (!LastMagicBarFull) {
LastMagicBarFull = true;
Flash(3, 'MagicFlash');
PlaySound(CMOptions.MagicSoundURL, 'MagicSound', 'MagicVolume');
Notification(
CreateNotification(
'MagicNotification',
'Magic Meter full',
'Your Magic Meter is full. Cast a spell!',

View File

@@ -2,7 +2,7 @@
import { CacheSeasonPopShimmer } from '../../Cache/VariablesAndData';
import { CMOptions } from '../../Config/VariablesAndData';
import Flash from '../../Disp/Notifications/Flash';
import Notification from '../../Disp/Notifications/Notification';
import CreateNotification from '../../Disp/Notifications/Notification';
import PlaySound from '../../Disp/Notifications/Sound';
import { LastSeasonPopupState } from '../VariablesAndData';
@@ -13,15 +13,14 @@ import { LastSeasonPopupState } from '../VariablesAndData';
export default function CheckSeasonPopup() {
if (LastSeasonPopupState !== Game.shimmerTypes.reindeer.spawned) {
LastSeasonPopupState = Game.shimmerTypes.reindeer.spawned;
for (const i of Object.keys(Game.shimmers)) {
Object.keys(Game.shimmers).forEach((i) => {
if (Game.shimmers[i].spawnLead && Game.shimmers[i].type === 'reindeer') {
CacheSeasonPopShimmer = Game.shimmers[i];
break;
}
}
});
Flash(3, 'SeaFlash');
PlaySound(CMOptions.SeaSoundURL, 'SeaSound', 'SeaVolume');
Notification(
CreateNotification(
'SeaNotification',
'Reindeer sighted!',
'A Reindeer has spawned. Click it now!',

View File

@@ -1,6 +1,6 @@
import { CMOptions } from '../../Config/VariablesAndData';
import Flash from '../../Disp/Notifications/Flash';
import Notification from '../../Disp/Notifications/Notification';
import CreateNotification from '../../Disp/Notifications/Notification';
import PlaySound from '../../Disp/Notifications/Sound';
import { LastTickerFortuneState } from '../VariablesAndData';
@@ -18,7 +18,7 @@ export default function CheckTickerFortune() {
if (LastTickerFortuneState) {
Flash(3, 'FortuneFlash');
PlaySound(CMOptions.FortuneSoundURL, 'FortuneSound', 'FortuneVolume');
Notification(
CreateNotification(
'FortuneNotification',
'Fortune Cookie found',
'A Fortune Cookie has appeared on the Ticker.',

View File

@@ -1,6 +1,6 @@
import { CMOptions } from '../../Config/VariablesAndData';
import Flash from '../../Disp/Notifications/Flash';
import Notification from '../../Disp/Notifications/Notification';
import CreateNotification from '../../Disp/Notifications/Notification';
import PlaySound from '../../Disp/Notifications/Sound';
import { LastWrinklerCount } from '../VariablesAndData';
@@ -11,9 +11,9 @@ import { LastWrinklerCount } from '../VariablesAndData';
export default function CheckWrinklerCount() {
if (Game.elderWrath > 0) {
let CurrentWrinklers = 0;
for (const i in Game.wrinklers) {
if (Game.wrinklers[i].phase === 2) CurrentWrinklers++;
}
Object.keys(Game.wrinklers).forEach((i) => {
if (Game.wrinklers[i].phase === 2) CurrentWrinklers += 1;
});
if (CurrentWrinklers > LastWrinklerCount) {
LastWrinklerCount = CurrentWrinklers;
if (
@@ -44,13 +44,13 @@ export default function CheckWrinklerCount() {
CurrentWrinklers === Game.getWrinklersMax() &&
CMOptions.WrinklerMaxNotification
) {
Notification(
CreateNotification(
'WrinklerMaxNotification',
'Maximum Wrinklers Reached',
'You have reached your maximum ammount of wrinklers',
);
} else {
Notification(
CreateNotification(
'WrinklerNotification',
'A Wrinkler appeared',
'A new wrinkler has appeared',

View File

@@ -38,13 +38,13 @@ export default function InitializeCookieMonster() {
CreateUpgradeBar();
CreateWhiteScreen();
CreateFavicon();
for (const i of Object.keys(TooltipText)) {
Object.keys(TooltipText).forEach((i) => {
CreateSimpleTooltip(
TooltipText[i][0],
TooltipText[i][1],
TooltipText[i][2],
);
}
});
CreateWrinklerButtons();
UpdateBuildingUpgradeStyle();

View File

@@ -20,7 +20,7 @@ function ReplaceNativeGrimoireDraw() {
!HasReplaceNativeGrimoireDraw &&
Game.Objects['Wizard tower'].minigameLoaded
) {
const minigame = Game.Objects['Wizard tower'].minigame;
const { minigame } = Game.Objects['Wizard tower'];
BackupGrimoireDraw = minigame.draw;
Game.Objects['Wizard tower'].minigame.draw = function () {
BackupGrimoireDraw();
@@ -46,7 +46,7 @@ function ReplaceNativeGrimoireLaunch() {
!HasReplaceNativeGrimoireLaunch &&
Game.Objects['Wizard tower'].minigameLoaded
) {
const minigame = Game.Objects['Wizard tower'].minigame;
const { minigame } = Game.Objects['Wizard tower'];
BackupGrimoireLaunch = minigame.launch;
BackupGrimoireLaunchMod = new Function(
`return ${minigame.launch

View File

@@ -6,21 +6,23 @@ import { TooltipGrimoireBackup } from '../VariablesAndData';
*/
export default function ReplaceTooltipGrimoire() {
if (Game.Objects['Wizard tower'].minigameLoaded) {
for (const i in Game.Objects['Wizard tower'].minigame.spellsById) {
if (l(`grimoireSpell${i}`).onmouseover !== null) {
TooltipGrimoireBackup[i] = l(`grimoireSpell${i}`).onmouseover;
l(`grimoireSpell${i}`).onmouseover = function () {
Game.tooltip.dynamic = 1;
Game.tooltip.draw(
this,
function () {
return CreateTooltip('g', `${i}`);
},
'this',
);
Game.tooltip.wobble();
};
}
}
Object.keys(Game.Objects['Wizard tower'].minigame.spellsById).forEach(
(i) => {
if (l(`grimoireSpell${i}`).onmouseover !== null) {
TooltipGrimoireBackup[i] = l(`grimoireSpell${i}`).onmouseover;
l(`grimoireSpell${i}`).onmouseover = function () {
Game.tooltip.dynamic = 1;
Game.tooltip.draw(
this,
function () {
return CreateTooltip('g', `${i}`);
},
'this',
);
Game.tooltip.wobble();
};
}
},
);
}
}

View File

@@ -8,7 +8,7 @@ import { TooltipUpgradeBackup } from '../VariablesAndData';
*/
export default function ReplaceTooltipUpgrade() {
TooltipUpgradeBackup = [];
for (const i of Object.keys(Game.UpgradesInStore)) {
Object.keys(Game.UpgradesInStore).forEach((i) => {
if (l(`upgrade${i}`).onmouseover !== null) {
TooltipUpgradeBackup[i] = l(`upgrade${i}`).onmouseover;
l(`upgrade${i}`).onmouseover = function () {
@@ -26,5 +26,5 @@ export default function ReplaceTooltipUpgrade() {
}
};
}
}
});
}

View File

@@ -1,3 +1,4 @@
/* eslint-disable no-param-reassign */
/* eslint-disable no-unused-vars */
/** Functions related to replacing tooltips */
@@ -14,7 +15,7 @@ import ReplaceTooltipGrimoire from './TooltipGrimoire';
* This function replaces the original .onmouseover functions of buildings
*/
function ReplaceTooltipBuild() {
for (const i of Object.keys(Game.Objects)) {
Object.keys(Game.Objects).forEach((i) => {
const me = Game.Objects[i];
if (l(`product${me.id}`).onmouseover !== null) {
TooltipBuildBackup[i] = l(`product${me.id}`).onmouseover;
@@ -30,7 +31,7 @@ function ReplaceTooltipBuild() {
Game.tooltip.wobble();
};
}
}
});
}
/**
@@ -129,6 +130,7 @@ export default function ReplaceTooltips() {
// Replace Tooltips of Minigames. Nesting it in LoadMinigames makes sure to replace them even if
// they were not loaded initially
// eslint-disable-next-line prefer-destructuring
LoadMinigames = Game.LoadMinigames;
Game.LoadMinigames = function () {
LoadMinigames();

View File

@@ -15,8 +15,8 @@ export default function AddWrinklerAreaDetect() {
l('backgroundLeftCanvas').onmouseout = function () {
TooltipWrinklerArea = 0;
Game.tooltip.hide();
for (const i of Object.keys(Game.wrinklers)) {
Object.keys(Game.wrinklers).forEach((i) => {
TooltipWrinklerBeingShown[i] = 0;
}
});
};
}