Use CookieMonsterFramework for save/load, infoMenu

This commit is contained in:
Daniël van Noord
2021-07-11 10:21:16 +02:00
parent b959b3c024
commit c0e788b143
95 changed files with 809 additions and 675 deletions

View File

@@ -1,4 +1,3 @@
import { CMOptions } from '../../Config/VariablesAndData';
import Flash from '../../Disp/Notifications/Flash';
import PlaySound from '../../Disp/Notifications/Sound';
import { LastGardenNextStep } from '../VariablesAndData';
@@ -13,7 +12,12 @@ export default function CheckGardenTick() {
) {
if (LastGardenNextStep !== 0 && LastGardenNextStep < Date.now()) {
Flash(3, 'GardFlash', false);
PlaySound(CMOptions.GardSoundURL, 'GardSound', 'GardVolume', false);
PlaySound(
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.settings.GardSoundURL,
'GardSound',
'GardVolume',
false,
);
}
LastGardenNextStep = Game.Objects.Farm.minigame.nextStep;
}

View File

@@ -1,5 +1,4 @@
import { CacheSpawnedGoldenShimmer, CacheGoldenShimmersByID } from '../../Cache/VariablesAndData'; // eslint-disable-line no-unused-vars
import { CMOptions } from '../../Config/VariablesAndData';
import CreateGCTimer from '../../Disp/GoldenCookieTimers/GoldenCookieTimers';
import Flash from '../../Disp/Notifications/Flash';
import CreateNotification from '../../Disp/Notifications/Notification';
@@ -46,7 +45,12 @@ export default function CheckGoldenCookie() {
if (LastGoldenCookieState) {
if (LastSpawnedGoldenCookieState < CurrSpawnedGoldenCookieState) {
Flash(3, 'GCFlash', false);
PlaySound(CMOptions.GCSoundURL, 'GCSound', 'GCVolume', false);
PlaySound(
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.settings.GCSoundURL,
'GCSound',
'GCVolume',
false,
);
CreateNotification(
'GCNotification',
'Golden Cookie Spawned',
@@ -63,7 +67,10 @@ export default function CheckGoldenCookie() {
UpdateFavicon();
LastSpawnedGoldenCookieState = CurrSpawnedGoldenCookieState;
if (CurrSpawnedGoldenCookieState === 0) CacheSpawnedGoldenShimmer = 0;
} else if (CMOptions.GCTimer === 1 && LastGoldenCookieState) {
} else if (
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.settings.GCTimer === 1 &&
LastGoldenCookieState
) {
Object.keys(GCTimers).forEach((i) => {
GCTimers[i].style.opacity = CacheGoldenShimmersByID[i].l.style.opacity;
GCTimers[i].style.transform = CacheGoldenShimmersByID[i].l.style.transform;

View File

@@ -1,4 +1,3 @@
import { CMOptions } from '../../Config/VariablesAndData';
import Flash from '../../Disp/Notifications/Flash';
import CreateNotification from '../../Disp/Notifications/Notification';
import PlaySound from '../../Disp/Notifications/Sound';
@@ -9,13 +8,21 @@ import { LastMagicBarFull } from '../VariablesAndData';
* It is called by CM.Main.Loop
*/
export default function CheckMagicMeter() {
if (Game.Objects['Wizard tower'].minigameLoaded && CMOptions.GrimoireBar === 1) {
if (
Game.Objects['Wizard tower'].minigameLoaded &&
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.settings.GrimoireBar === 1
) {
const { minigame } = Game.Objects['Wizard tower'];
if (minigame.magic < minigame.magicM) LastMagicBarFull = false;
else if (!LastMagicBarFull) {
LastMagicBarFull = true;
Flash(3, 'MagicFlash', false);
PlaySound(CMOptions.MagicSoundURL, 'MagicSound', 'MagicVolume', false);
PlaySound(
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.settings.MagicSoundURL,
'MagicSound',
'MagicVolume',
false,
);
CreateNotification(
'MagicNotification',
'Magic Meter full',

View File

@@ -1,5 +1,4 @@
import { CacheSeasonPopShimmer } from '../../Cache/VariablesAndData'; // eslint-disable-line no-unused-vars
import { CMOptions } from '../../Config/VariablesAndData';
import Flash from '../../Disp/Notifications/Flash';
import CreateNotification from '../../Disp/Notifications/Notification';
import PlaySound from '../../Disp/Notifications/Sound';
@@ -18,7 +17,12 @@ export default function CheckSeasonPopup() {
}
});
Flash(3, 'SeaFlash', false);
PlaySound(CMOptions.SeaSoundURL, 'SeaSound', 'SeaVolume', false);
PlaySound(
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.settings.SeaSoundURL,
'SeaSound',
'SeaVolume',
false,
);
CreateNotification(
'SeaNotification',
'Reindeer sighted!',

View File

@@ -1,4 +1,3 @@
import { CMOptions } from '../../Config/VariablesAndData';
import Flash from '../../Disp/Notifications/Flash';
import CreateNotification from '../../Disp/Notifications/Notification';
import PlaySound from '../../Disp/Notifications/Sound';
@@ -13,7 +12,12 @@ export default function CheckTickerFortune() {
LastTickerFortuneState = Game.TickerEffect && Game.TickerEffect.type === 'fortune';
if (LastTickerFortuneState) {
Flash(3, 'FortuneFlash', false);
PlaySound(CMOptions.FortuneSoundURL, 'FortuneSound', 'FortuneVolume', false);
PlaySound(
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.settings.FortuneSoundURL,
'FortuneSound',
'FortuneVolume',
false,
);
CreateNotification(
'FortuneNotification',
'Fortune Cookie found',

View File

@@ -1,4 +1,3 @@
import { CMOptions } from '../../Config/VariablesAndData';
import Flash from '../../Disp/Notifications/Flash';
import CreateNotification from '../../Disp/Notifications/Notification';
import PlaySound from '../../Disp/Notifications/Sound';
@@ -16,17 +15,36 @@ export default function CheckWrinklerCount() {
});
if (CurrentWrinklers > LastWrinklerCount) {
LastWrinklerCount = CurrentWrinklers;
if (CurrentWrinklers === Game.getWrinklersMax() && CMOptions.WrinklerMaxFlash) {
if (
CurrentWrinklers === Game.getWrinklersMax() &&
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.settings.WrinklerMaxFlash
) {
Flash(3, 'WrinklerMaxFlash', false);
} else {
Flash(3, 'WrinklerFlash', false);
}
if (CurrentWrinklers === Game.getWrinklersMax() && CMOptions.WrinklerMaxSound) {
PlaySound(CMOptions.WrinklerMaxSoundURL, 'WrinklerMaxSound', 'WrinklerMaxVolume', false);
if (
CurrentWrinklers === Game.getWrinklersMax() &&
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.settings.WrinklerMaxSound
) {
PlaySound(
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.settings.WrinklerMaxSoundURL,
'WrinklerMaxSound',
'WrinklerMaxVolume',
false,
);
} else {
PlaySound(CMOptions.WrinklerSoundURL, 'WrinklerSound', 'WrinklerVolume', false);
PlaySound(
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.settings.WrinklerSoundURL,
'WrinklerSound',
'WrinklerVolume',
false,
);
}
if (CurrentWrinklers === Game.getWrinklersMax() && CMOptions.WrinklerMaxNotification) {
if (
CurrentWrinklers === Game.getWrinklersMax() &&
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.settings.WrinklerMaxNotification
) {
CreateNotification(
'WrinklerMaxNotification',
'Maximum Wrinklers Reached',

View File

@@ -1,6 +1,5 @@
import InitCache from '../Cache/CacheInit';
import { CacheStatsCookies } from '../Cache/Stats/Stats';
import { LoadConfig } from '../Config/SaveLoadReload/SaveLoadReloadSettings';
import { VersionMajor, VersionMinor } from '../Data/Moddata.ts';
import CreateUpgradeBar from '../Disp/BuildingsUpgrades/UpgradeBar';
import { CreateBotBar } from '../Disp/InfoBars/BottomBar';
@@ -20,6 +19,7 @@ import ReplaceNative from './ReplaceGameFunctions/ReplaceNative';
import { LastModCount } from './VariablesAndData'; // eslint-disable-line no-unused-vars
import AddWrinklerAreaDetect from './WrinklerArea/AddDetectArea';
import CreateBuildingLockButtons from '../Disp/Buildings/CreateBuildingLockButtons';
import createMenuInfo from '../Disp/MenuSections/createMenuInfo';
/**
* Initialization loop of Cookie Monster
@@ -28,6 +28,9 @@ export default function InitializeCookieMonster() {
// Create global data object
window.CookieMonsterData = {};
// Register listeners in Cookie Monster Mod Framework
Game.mods.cookieMonsterFramework.listeners.infoMenu.push(createMenuInfo);
InitData();
CacheStatsCookies();
InitCache();
@@ -58,7 +61,6 @@ export default function InitializeCookieMonster() {
ReplaceNativeGrimoire();
Game.CalculateGains();
LoadConfig();
CMLastAscendState = Game.OnAscend;
if (Game.prefs.popups)

View File

@@ -1,4 +1,3 @@
import { CMOptions } from '../../Config/VariablesAndData';
import FormatTime from '../../Disp/BeautifyAndFormatting/FormatTime';
import CalculateGrimoireRefillTime from '../../Disp/HelperFunctions/CalculateGrimoireRefillTime';
import {
@@ -19,7 +18,10 @@ function ReplaceNativeGrimoireDraw() {
BackupGrimoireDraw = minigame.draw;
Game.Objects['Wizard tower'].minigame.draw = function () {
BackupGrimoireDraw();
if (CMOptions.GrimoireBar === 1 && minigame.magic < minigame.magicM) {
if (
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.settings.GrimoireBar === 1 &&
minigame.magic < minigame.magicM
) {
minigame.magicBarTextL.innerHTML += ` (${FormatTime(
CalculateGrimoireRefillTime(minigame.magic, minigame.magicM, minigame.magicM),
)})`;

View File

@@ -1,12 +1,13 @@
import { CMOptions } from '../../Config/VariablesAndData';
/**
* This function fixes Game.mouseY as a result of bars that are added by CookieMonster
* It is called by Game.UpdateWrinklers(), Game.UpdateSpecial() and the .onmousover of the BigCookie
* before execution of their actual function
*/
export default function FixMouseY(target) {
if (CMOptions.TimerBar === 1 && CMOptions.TimerBarPos === 0) {
if (
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.settings.TimerBar === 1 &&
Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.settings.TimerBarPos === 0
) {
const timerBarHeight = parseInt(l('CMTimerBar').style.height, 10);
Game.mouseY -= timerBarHeight;
target();

View File

@@ -1,5 +1,5 @@
import jscolor from '@eastdesire/jscolor';
import { CMOptions } from '../../Config/VariablesAndData';
import CMBeautify from '../../Disp/BeautifyAndFormatting/Beautify';
import FormatTime from '../../Disp/BeautifyAndFormatting/FormatTime';
import { AddAuraInfo, AddDragonLevelUpTooltip } from '../../Disp/Dragon/Dragon';
@@ -86,7 +86,7 @@ export default function ReplaceNative() {
*/
Game.ClickProduct = function (what) {
if (
!CMOptions.BulkBuyBlock ||
!Game.mods.cookieMonsterFramework.saveData.cookieMonsterMod.settings.BulkBuyBlock ||
Game.ObjectsById[what].bulkPrice < Game.cookies ||
Game.buyMode === -1
) {