Added 'time left' to ascend tooltip #80
This commit is contained in:
31
src/Cache.js
31
src/Cache.js
@@ -25,6 +25,27 @@ CM.Cache.InitCache = function() {
|
||||
CM.Cache.CachePP();
|
||||
};
|
||||
|
||||
/**
|
||||
* This functions caches variables that are needed every loop
|
||||
* It is called by CM.Main.Loop()
|
||||
* @global {string} CM.Cache.TimeTillNextPrestige Time requried till next prestige level
|
||||
*/
|
||||
CM.Cache.LoopCache = function() {
|
||||
// Update Wrinkler Bank
|
||||
CM.Cache.CacheWrinklers();
|
||||
|
||||
// Calculate PP
|
||||
CM.Cache.CachePP();
|
||||
|
||||
// Cache average CPS
|
||||
CM.Cache.CacheCurrWrinklerCPS();
|
||||
CM.Cache.CacheAvgCPS();
|
||||
|
||||
let cookiesToNext = Game.HowManyCookiesReset(Math.floor(Game.HowMuchPrestige(Game.cookiesReset + Game.cookiesEarned)) + 1) - (Game.cookiesEarned + Game.cookiesReset);
|
||||
CM.Cache.TimeTillNextPrestige = CM.Disp.FormatTime(cookiesToNext / CM.Cache.AvgCPS);
|
||||
};
|
||||
|
||||
|
||||
/********
|
||||
* Section: Functions related to Dragon Auras */
|
||||
|
||||
@@ -45,7 +66,7 @@ CM.Cache.CacheDragonAuras = function() {
|
||||
|
||||
/**
|
||||
* This functions caches data related to Wrinklers
|
||||
* It is called by CM.Main.Loop() and CM.Cache.InitCache()
|
||||
* It is called by CM.Cache.LoopCache() and CM.Cache.InitCache()
|
||||
* @global {number} CM.Cache.WrinklersTotal The cookies of all wrinklers
|
||||
* @global {number} CM.Cache.WrinklersNormal The cookies of all normal wrinklers
|
||||
* @global {[{number}, {number}]} CM.Cache.WrinklersFattest A list containing the cookies and the id of the fattest non-shiny wrinkler
|
||||
@@ -79,7 +100,7 @@ CM.Cache.CacheWrinklers = function() {
|
||||
* Section: Functions related to Caching stats */
|
||||
|
||||
/**
|
||||
* This functions caches variables related to the stats apge
|
||||
* This functions caches variables related to the stats page
|
||||
* It is called by CM.Main.Loop() upon changes to cps and CM.Cache.InitCache()
|
||||
* @global {number} CM.Cache.Lucky Cookies required for max Lucky
|
||||
* @global {number} CM.Cache.LuckyReward Reward for max normal Lucky
|
||||
@@ -335,7 +356,7 @@ CM.Cache.InitCookiesDiff = function() {
|
||||
|
||||
/**
|
||||
* This functions caches two variables related average CPS and Clicks
|
||||
* It is called by CM.Main.Loop()
|
||||
* It is called by CM.Cache.LoopCache()
|
||||
* @global {number} CM.Cache.RealCookiesEarned Cookies earned including the Chocolate Egg
|
||||
* @global {number} CM.Cache.AvgCPS Average cookies over time-period as defined by AvgCPSHist
|
||||
* @global {number} CM.Cache.AverageClicks Average cookies from clicking over time-period as defined by AvgClicksHist
|
||||
@@ -418,7 +439,7 @@ CM.Cache.CacheSellForChoEgg = function() {
|
||||
|
||||
/**
|
||||
* This functions caches the current Wrinkler CPS multiplier
|
||||
* It is called by CM.Main.Loop(). Variables are mostly used by CM.Disp.GetCPS().
|
||||
* It is called by CM.Cache.LoopCache(). Variables are mostly used by CM.Disp.GetCPS().
|
||||
* @global {number} CM.Cache.CurrWrinklerCount Current number of wrinklers
|
||||
* @global {number} CM.Cache.CurrWrinklerCPSMult Current multiplier of CPS because of wrinklers (excluding their negative sucking effect)
|
||||
*/
|
||||
@@ -590,7 +611,7 @@ CM.Cache.CacheBuildingsPrices = function() {
|
||||
|
||||
/**
|
||||
* This functions caches the PP of each building and upgrade and stores it in the cache
|
||||
* It is called by CM.Main.Loop() and CM.Cache.InitCache()
|
||||
* It is called by CM.Cache.LoopCache() and CM.Cache.InitCache()
|
||||
*/
|
||||
CM.Cache.CachePP = function() {
|
||||
CM.Cache.CacheBuildingsPP();
|
||||
|
||||
@@ -86,7 +86,7 @@ CM.Data.ConfigGroups = {
|
||||
BarsColors: "Bars/Colors",
|
||||
Calculation: "Calculation",
|
||||
Notification: "Notification",
|
||||
Tooltip: "Tooltips",
|
||||
Tooltip: "Tooltips and additional insights",
|
||||
Statistics: "Statistics",
|
||||
Notation: "Notation",
|
||||
Miscellaneous: "Miscellaneous"
|
||||
@@ -223,6 +223,7 @@ CM.Data.Config.TooltipWrink = {type: 'bool', group: 'Tooltip', label: ['Wrinkler
|
||||
CM.Data.Config.TooltipLump = {type: 'bool', group: 'Tooltip', label: ['Sugar Lump Tooltip OFF', 'Sugar Lump Tooltip ON'], desc: 'Shows the current Sugar Lump type in Sugar lump tooltip.', toggle: true};
|
||||
CM.Data.Config.TooltipPlots = {type: 'bool', group: 'Tooltip', label: ['Garden Plots Tooltip OFF', 'Garden Plots Tooltip ON'], desc: 'Shows a tooltip for plants that have a cookie reward.', toggle: true};
|
||||
CM.Data.Config.DragonAuraInfo = {type: 'bool', group: 'Tooltip', label: ['Extra Dragon Aura Info OFF', 'Extra Dragon Aura Info ON'], desc: 'Shows information about changes in CPS and costs in the dragon aura interface.', toggle: true};
|
||||
CM.Data.Config.TooltipAscendButton = {type: 'bool', group: 'Tooltip', label: ['Show Time Left Ascend Tooltip OFF', 'Show Time Left Ascend Tooltip ON'], desc: 'Shows the time left in the ascend tooltip until next heavenly cookie.', toggle: true};
|
||||
|
||||
// Statistics
|
||||
CM.Data.Config.Stats = {type: 'bool', group: 'Statistics', label: ['Statistics OFF', 'Statistics ON'], desc: 'Extra Cookie Monster statistics!', toggle: true};
|
||||
@@ -313,6 +314,7 @@ CM.Data.ConfigDefault = {
|
||||
TooltipLump: 1,
|
||||
TooltipPlots: 1,
|
||||
DragonAuraInfo: 1,
|
||||
TooltipAscendButton: 1,
|
||||
Stats: 1,
|
||||
MissingUpgrades: 1,
|
||||
UpStats: 1,
|
||||
|
||||
57
src/Main.js
57
src/Main.js
@@ -48,24 +48,16 @@ CM.Main.Loop = function() {
|
||||
CM.Cache.DoRemakeBuildPrices = 0;
|
||||
}
|
||||
|
||||
// Update Wrinkler Bank
|
||||
CM.Cache.CacheWrinklers();
|
||||
CM.Cache.LoopCache();
|
||||
|
||||
// Calculate PP
|
||||
CM.Cache.CachePP();
|
||||
// Check all changing minigames and game-states
|
||||
CM.Main.CheckGoldenCookie();
|
||||
CM.Main.CheckTickerFortune();
|
||||
CM.Main.CheckSeasonPopup();
|
||||
CM.Main.CheckGardenTick();
|
||||
CM.Main.CheckMagicMeter();
|
||||
CM.Main.CheckWrinklerCount();
|
||||
}
|
||||
|
||||
// Check all changing minigames and game-states
|
||||
CM.Main.CheckGoldenCookie();
|
||||
CM.Main.CheckTickerFortune();
|
||||
CM.Main.CheckSeasonPopup();
|
||||
CM.Main.CheckGardenTick();
|
||||
CM.Main.CheckMagicMeter();
|
||||
CM.Main.CheckWrinklerCount();
|
||||
|
||||
// Cache average CPS
|
||||
CM.Cache.CacheCurrWrinklerCPS();
|
||||
CM.Cache.CacheAvgCPS();
|
||||
};
|
||||
|
||||
/**
|
||||
@@ -202,9 +194,12 @@ CM.Main.ReplaceNative = function() {
|
||||
if (isNaN(time) || time <= 0) return CM.Backup.sayTime(time, detail);
|
||||
else return CM.Disp.FormatTime(time / Game.fps, 1);
|
||||
};
|
||||
|
||||
|
||||
// Since the Ascend Tooltip is not actually a tooltip we need to add our additional info here...
|
||||
CM.Backup.Logic = Game.Logic;
|
||||
eval('CM.Backup.LogicMod = ' + Game.Logic.toString().split('document.title').join('CM.Disp.Title'));
|
||||
eval('CM.Backup.LogicMod = ' + Game.Logic.toString()
|
||||
.split('document.title').join('CM.Disp.Title')
|
||||
.split("' more cookies</b> for the next level.<br>';").join("` more cookies</b> for the next level.<br>${CM.Options.TooltipAscendButton ? `<div class='line'></div>You need ${CM.Cache.TimeTillNextPrestige} for the next level.<br>` : ``}`;"));
|
||||
Game.Logic = function() {
|
||||
CM.Backup.LogicMod();
|
||||
// Update Title
|
||||
@@ -267,7 +262,7 @@ CM.Main.ReplaceNativeGrimoireDraw = function() {
|
||||
*/
|
||||
CM.Main.ReplaceTooltips = function() {
|
||||
CM.Main.ReplaceTooltipBuild();
|
||||
CM.Main.ReplaceTooltipLump();
|
||||
CM.Main.ReplaceTooltipLump();
|
||||
|
||||
// Replace Tooltips of Minigames. Nesting it in LoadMinigames makes sure to replace them even if
|
||||
// they were not loaded initially
|
||||
@@ -300,6 +295,18 @@ CM.Main.ReplaceTooltipBuild = function() {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This function replaces the original .onmouseover functions of sugar lumps so that it calls CM.Disp.Tooltip()
|
||||
* CM.Disp.Tooltip() sets the tooltip type to 's'
|
||||
* It is called by CM.Main.ReplaceTooltips()
|
||||
*/
|
||||
CM.Main.ReplaceTooltipLump = function() {
|
||||
if (Game.canLumps()) {
|
||||
CM.Main.TooltipLumpBackup = l('lumps').onmouseover;
|
||||
eval('l(\'lumps\').onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'s\', \'Lump\');}, \'this\'); Game.tooltip.wobble();}');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This function replaces the original .onmouseover functions of the Grimoire minigame so that it calls CM.Disp.Tooltip()
|
||||
* CM.Disp.Tooltip() sets the tooltip type to 'g'
|
||||
@@ -317,18 +324,6 @@ CM.Main.ReplaceTooltipGrimoire = function() {
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This function replaces the original .onmouseover functions of sugar lumps so that it calls CM.Disp.Tooltip()
|
||||
* CM.Disp.Tooltip() sets the tooltip type to 's'
|
||||
* It is called by CM.Main.ReplaceTooltips()
|
||||
*/
|
||||
CM.Main.ReplaceTooltipLump = function() {
|
||||
if (Game.canLumps()) {
|
||||
CM.Main.TooltipLumpBackup = l('lumps').onmouseover;
|
||||
eval('l(\'lumps\').onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'s\', \'Lump\');}, \'this\'); Game.tooltip.wobble();}');
|
||||
}
|
||||
};
|
||||
|
||||
/**
|
||||
* This function replaces the original .onmouseover functions of all garden plants so that it calls CM.Disp.Tooltip()
|
||||
* CM.Disp.Tooltip() sets the tooltip type to 'p'
|
||||
|
||||
Reference in New Issue
Block a user