Added prettier (#661)
* Added prettier * Added prettier * Added prettier
This commit is contained in:
@@ -4,7 +4,11 @@ import { FormatTime } from '../../Disp/BeautifyAndFormatting/BeautifyFormatting'
|
||||
|
||||
import CalculateGrimoireRefillTime from '../../Disp/HelperFunctions/CalculateGrimoireRefillTime';
|
||||
import {
|
||||
BackupGrimoireDraw, BackupGrimoireLaunch, BackupGrimoireLaunchMod, HasReplaceNativeGrimoireDraw, HasReplaceNativeGrimoireLaunch,
|
||||
BackupGrimoireDraw,
|
||||
BackupGrimoireLaunch,
|
||||
BackupGrimoireLaunchMod,
|
||||
HasReplaceNativeGrimoireDraw,
|
||||
HasReplaceNativeGrimoireLaunch,
|
||||
} from '../VariablesAndData';
|
||||
import ReplaceTooltipGrimoire from './TooltipGrimoire';
|
||||
|
||||
@@ -12,42 +16,59 @@ import ReplaceTooltipGrimoire from './TooltipGrimoire';
|
||||
* This function fixes replaces the .draw function of the Grimoire
|
||||
*/
|
||||
function ReplaceNativeGrimoireDraw() {
|
||||
if (!HasReplaceNativeGrimoireDraw && Game.Objects['Wizard tower'].minigameLoaded) {
|
||||
const minigame = Game.Objects['Wizard tower'].minigame;
|
||||
BackupGrimoireDraw = minigame.draw;
|
||||
Game.Objects['Wizard tower'].minigame.draw = function () {
|
||||
BackupGrimoireDraw();
|
||||
if (CMOptions.GrimoireBar === 1 && minigame.magic < minigame.magicM) {
|
||||
minigame.magicBarTextL.innerHTML += ` (${FormatTime(CalculateGrimoireRefillTime(minigame.magic, minigame.magicM, minigame.magicM))})`;
|
||||
}
|
||||
};
|
||||
HasReplaceNativeGrimoireDraw = true;
|
||||
}
|
||||
if (
|
||||
!HasReplaceNativeGrimoireDraw &&
|
||||
Game.Objects['Wizard tower'].minigameLoaded
|
||||
) {
|
||||
const minigame = Game.Objects['Wizard tower'].minigame;
|
||||
BackupGrimoireDraw = minigame.draw;
|
||||
Game.Objects['Wizard tower'].minigame.draw = function () {
|
||||
BackupGrimoireDraw();
|
||||
if (CMOptions.GrimoireBar === 1 && minigame.magic < minigame.magicM) {
|
||||
minigame.magicBarTextL.innerHTML += ` (${FormatTime(
|
||||
CalculateGrimoireRefillTime(
|
||||
minigame.magic,
|
||||
minigame.magicM,
|
||||
minigame.magicM,
|
||||
),
|
||||
)})`;
|
||||
}
|
||||
};
|
||||
HasReplaceNativeGrimoireDraw = true;
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function fixes replaces the .launch function of the Grimoire
|
||||
*/
|
||||
function ReplaceNativeGrimoireLaunch() {
|
||||
if (!HasReplaceNativeGrimoireLaunch && Game.Objects['Wizard tower'].minigameLoaded) {
|
||||
const minigame = Game.Objects['Wizard tower'].minigame;
|
||||
BackupGrimoireLaunch = minigame.launch;
|
||||
BackupGrimoireLaunchMod = new Function(`return ${minigame.launch.toString().split('=this').join('= Game.Objects[\'Wizard tower\'].minigame')}`);
|
||||
Game.Objects['Wizard tower'].minigame.launch = function () {
|
||||
BackupGrimoireLaunchMod();
|
||||
ReplaceTooltipGrimoire();
|
||||
HasReplaceNativeGrimoireDraw = false;
|
||||
ReplaceNativeGrimoireDraw();
|
||||
if (
|
||||
!HasReplaceNativeGrimoireLaunch &&
|
||||
Game.Objects['Wizard tower'].minigameLoaded
|
||||
) {
|
||||
const minigame = Game.Objects['Wizard tower'].minigame;
|
||||
BackupGrimoireLaunch = minigame.launch;
|
||||
BackupGrimoireLaunchMod = new Function(
|
||||
`return ${minigame.launch
|
||||
.toString()
|
||||
.split('=this')
|
||||
.join("= Game.Objects['Wizard tower'].minigame")}`,
|
||||
);
|
||||
Game.Objects['Wizard tower'].minigame.launch = function () {
|
||||
BackupGrimoireLaunchMod();
|
||||
ReplaceTooltipGrimoire();
|
||||
HasReplaceNativeGrimoireDraw = false;
|
||||
ReplaceNativeGrimoireDraw();
|
||||
|
||||
HasReplaceNativeGrimoireLaunch = true;
|
||||
};
|
||||
}
|
||||
HasReplaceNativeGrimoireLaunch = true;
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function fixes replaces the Launch and Draw functions of the Grimoire
|
||||
*/
|
||||
export default function ReplaceNativeGrimoire() {
|
||||
ReplaceNativeGrimoireLaunch();
|
||||
ReplaceNativeGrimoireDraw();
|
||||
ReplaceNativeGrimoireLaunch();
|
||||
ReplaceNativeGrimoireDraw();
|
||||
}
|
||||
|
||||
@@ -5,16 +5,22 @@ import { TooltipGrimoireBackup } from '../VariablesAndData';
|
||||
* This function replaces the original .onmouseover functions of the Grimoire minigame
|
||||
*/
|
||||
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();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
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();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -7,20 +7,24 @@ import { TooltipUpgradeBackup } from '../VariablesAndData';
|
||||
* It is called by Game.RebuildUpgrades() through CM.Main.ReplaceNative() and is therefore not permanent like the other ReplaceTooltip functions
|
||||
*/
|
||||
export default function ReplaceTooltipUpgrade() {
|
||||
TooltipUpgradeBackup = [];
|
||||
for (const i of Object.keys(Game.UpgradesInStore)) {
|
||||
if (l(`upgrade${i}`).onmouseover !== null) {
|
||||
TooltipUpgradeBackup[i] = l(`upgrade${i}`).onmouseover;
|
||||
l(`upgrade${i}`).onmouseover = function () {
|
||||
if (!Game.mouseDown) {
|
||||
Game.setOnCrate(this);
|
||||
Game.tooltip.dynamic = 1;
|
||||
Game.tooltip.draw(this, function () {
|
||||
return CreateTooltip('u', `${i}`);
|
||||
}, 'store');
|
||||
Game.tooltip.wobble();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
TooltipUpgradeBackup = [];
|
||||
for (const i of Object.keys(Game.UpgradesInStore)) {
|
||||
if (l(`upgrade${i}`).onmouseover !== null) {
|
||||
TooltipUpgradeBackup[i] = l(`upgrade${i}`).onmouseover;
|
||||
l(`upgrade${i}`).onmouseover = function () {
|
||||
if (!Game.mouseDown) {
|
||||
Game.setOnCrate(this);
|
||||
Game.tooltip.dynamic = 1;
|
||||
Game.tooltip.draw(
|
||||
this,
|
||||
function () {
|
||||
return CreateTooltip('u', `${i}`);
|
||||
},
|
||||
'store',
|
||||
);
|
||||
Game.tooltip.wobble();
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,7 +3,9 @@
|
||||
|
||||
import { CreateTooltip } from '../../Disp/Tooltips/Tooltip';
|
||||
import {
|
||||
LoadMinigames, TooltipBuildBackup, TooltipLumpBackup,
|
||||
LoadMinigames,
|
||||
TooltipBuildBackup,
|
||||
TooltipLumpBackup,
|
||||
} from '../VariablesAndData';
|
||||
import ReplaceNativeGrimoire from './NativeGrimoire';
|
||||
import ReplaceTooltipGrimoire from './TooltipGrimoire';
|
||||
@@ -12,65 +14,93 @@ import ReplaceTooltipGrimoire from './TooltipGrimoire';
|
||||
* This function replaces the original .onmouseover functions of buildings
|
||||
*/
|
||||
function ReplaceTooltipBuild() {
|
||||
for (const i of Object.keys(Game.Objects)) {
|
||||
const me = Game.Objects[i];
|
||||
if (l(`product${me.id}`).onmouseover !== null) {
|
||||
TooltipBuildBackup[i] = l(`product${me.id}`).onmouseover;
|
||||
l(`product${me.id}`).onmouseover = function () {
|
||||
Game.tooltip.dynamic = 1;
|
||||
Game.tooltip.draw(this, function () { return CreateTooltip('b', `${i}`); }, 'store');
|
||||
Game.tooltip.wobble();
|
||||
};
|
||||
}
|
||||
}
|
||||
for (const i of Object.keys(Game.Objects)) {
|
||||
const me = Game.Objects[i];
|
||||
if (l(`product${me.id}`).onmouseover !== null) {
|
||||
TooltipBuildBackup[i] = l(`product${me.id}`).onmouseover;
|
||||
l(`product${me.id}`).onmouseover = function () {
|
||||
Game.tooltip.dynamic = 1;
|
||||
Game.tooltip.draw(
|
||||
this,
|
||||
function () {
|
||||
return CreateTooltip('b', `${i}`);
|
||||
},
|
||||
'store',
|
||||
);
|
||||
Game.tooltip.wobble();
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function replaces the original .onmouseover functions of sugar lumps
|
||||
*/
|
||||
function ReplaceTooltipLump() {
|
||||
if (Game.canLumps()) {
|
||||
TooltipLumpBackup = l('lumps').onmouseover;
|
||||
l('lumps').onmouseover = function () {
|
||||
Game.tooltip.dynamic = 1;
|
||||
Game.tooltip.draw(this, function () { return CreateTooltip('s', 'Lump'); }, 'this');
|
||||
Game.tooltip.wobble();
|
||||
};
|
||||
}
|
||||
if (Game.canLumps()) {
|
||||
TooltipLumpBackup = l('lumps').onmouseover;
|
||||
l('lumps').onmouseover = function () {
|
||||
Game.tooltip.dynamic = 1;
|
||||
Game.tooltip.draw(
|
||||
this,
|
||||
function () {
|
||||
return CreateTooltip('s', 'Lump');
|
||||
},
|
||||
'this',
|
||||
);
|
||||
Game.tooltip.wobble();
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function replaces the original .onmouseover functions of all garden plants
|
||||
*/
|
||||
function ReplaceTooltipGarden() {
|
||||
if (Game.Objects.Farm.minigameLoaded) {
|
||||
l('gardenTool-1').onmouseover = function () { Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function () { return CreateTooltip('ha', 'HarvestAllButton'); }, 'this'); Game.tooltip.wobble(); };
|
||||
Array.from(l('gardenPlot').children).forEach((child) => {
|
||||
const coords = child.id.slice(-3);
|
||||
child.onmouseover = function () {
|
||||
Game.tooltip.dynamic = 1;
|
||||
Game.tooltip.draw(this, function () { return CreateTooltip('p', [`${coords[0]}`, `${coords[2]}`]); }, 'this');
|
||||
Game.tooltip.wobble();
|
||||
};
|
||||
});
|
||||
}
|
||||
if (Game.Objects.Farm.minigameLoaded) {
|
||||
l('gardenTool-1').onmouseover = function () {
|
||||
Game.tooltip.dynamic = 1;
|
||||
Game.tooltip.draw(
|
||||
this,
|
||||
function () {
|
||||
return CreateTooltip('ha', 'HarvestAllButton');
|
||||
},
|
||||
'this',
|
||||
);
|
||||
Game.tooltip.wobble();
|
||||
};
|
||||
Array.from(l('gardenPlot').children).forEach((child) => {
|
||||
const coords = child.id.slice(-3);
|
||||
child.onmouseover = function () {
|
||||
Game.tooltip.dynamic = 1;
|
||||
Game.tooltip.draw(
|
||||
this,
|
||||
function () {
|
||||
return CreateTooltip('p', [`${coords[0]}`, `${coords[2]}`]);
|
||||
},
|
||||
'this',
|
||||
);
|
||||
Game.tooltip.wobble();
|
||||
};
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* This function call all functions that replace Game-tooltips with Cookie Monster enhanced tooltips
|
||||
*/
|
||||
export default function ReplaceTooltips() {
|
||||
ReplaceTooltipBuild();
|
||||
ReplaceTooltipLump();
|
||||
ReplaceTooltipBuild();
|
||||
ReplaceTooltipLump();
|
||||
|
||||
// Replace Tooltips of Minigames. Nesting it in LoadMinigames makes sure to replace them even if
|
||||
// they were not loaded initially
|
||||
LoadMinigames = Game.LoadMinigames;
|
||||
Game.LoadMinigames = function () {
|
||||
LoadMinigames();
|
||||
ReplaceTooltipGarden();
|
||||
ReplaceTooltipGrimoire();
|
||||
ReplaceNativeGrimoire();
|
||||
};
|
||||
Game.LoadMinigames();
|
||||
// Replace Tooltips of Minigames. Nesting it in LoadMinigames makes sure to replace them even if
|
||||
// they were not loaded initially
|
||||
LoadMinigames = Game.LoadMinigames;
|
||||
Game.LoadMinigames = function () {
|
||||
LoadMinigames();
|
||||
ReplaceTooltipGarden();
|
||||
ReplaceTooltipGrimoire();
|
||||
ReplaceNativeGrimoire();
|
||||
};
|
||||
Game.LoadMinigames();
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user