File diff suppressed because one or more lines are too long
143
src/Cache.js
143
src/Cache.js
@@ -25,6 +25,27 @@ CM.Cache.InitCache = function() {
|
|||||||
CM.Cache.CachePP();
|
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 */
|
* Section: Functions related to Dragon Auras */
|
||||||
|
|
||||||
@@ -45,7 +66,7 @@ CM.Cache.CacheDragonAuras = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This functions caches data related to Wrinklers
|
* 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.WrinklersTotal The cookies of all wrinklers
|
||||||
* @global {number} CM.Cache.WrinklersNormal The cookies of all normal 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
|
* @global {[{number}, {number}]} CM.Cache.WrinklersFattest A list containing the cookies and the id of the fattest non-shiny wrinkler
|
||||||
@@ -55,14 +76,14 @@ CM.Cache.CacheWrinklers = function() {
|
|||||||
CM.Cache.WrinklersNormal = 0;
|
CM.Cache.WrinklersNormal = 0;
|
||||||
CM.Cache.WrinklersFattest = [0, null];
|
CM.Cache.WrinklersFattest = [0, null];
|
||||||
for (let i = 0; i < Game.wrinklers.length; i++) {
|
for (let i = 0; i < Game.wrinklers.length; i++) {
|
||||||
var sucked = Game.wrinklers[i].sucked;
|
let sucked = Game.wrinklers[i].sucked;
|
||||||
var toSuck = 1.1;
|
let toSuck = 1.1;
|
||||||
if (Game.Has('Sacrilegious corruption')) toSuck *= 1.05;
|
if (Game.Has('Sacrilegious corruption')) toSuck *= 1.05;
|
||||||
if (Game.wrinklers[i].type==1) toSuck *= 3; // Shiny wrinklers
|
if (Game.wrinklers[i].type==1) toSuck *= 3; // Shiny wrinklers
|
||||||
sucked *= toSuck;
|
sucked *= toSuck;
|
||||||
if (Game.Has('Wrinklerspawn')) sucked *= 1.05;
|
if (Game.Has('Wrinklerspawn')) sucked *= 1.05;
|
||||||
if (CM.Sim.Objects.Temple.minigameLoaded) {
|
if (CM.Sim.Objects.Temple.minigameLoaded) {
|
||||||
var godLvl = Game.hasGod('scorn');
|
let godLvl = Game.hasGod('scorn');
|
||||||
if (godLvl === 1) sucked *= 1.15;
|
if (godLvl === 1) sucked *= 1.15;
|
||||||
else if (godLvl === 2) sucked *= 1.1;
|
else if (godLvl === 2) sucked *= 1.1;
|
||||||
else if (godLvl === 3) sucked *= 1.05;
|
else if (godLvl === 3) sucked *= 1.05;
|
||||||
@@ -79,7 +100,7 @@ CM.Cache.CacheWrinklers = function() {
|
|||||||
* Section: Functions related to Caching stats */
|
* 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()
|
* 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.Lucky Cookies required for max Lucky
|
||||||
* @global {number} CM.Cache.LuckyReward Reward for max normal Lucky
|
* @global {number} CM.Cache.LuckyReward Reward for max normal Lucky
|
||||||
@@ -125,7 +146,7 @@ CM.Cache.CacheStats = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This functions calculates the multipliers of Golden and Wrath cookie rewards
|
* This functions calculates the multipliers of Golden and Wrath cookie rewards
|
||||||
* It is mostly used by CM.Cache.MaxChainMoni() and CM.Cache.CacheChain()
|
* It is mostly used by CM.Cache.MaxChainCookieReward() and CM.Cache.CacheChain()
|
||||||
* It is called by CM.Disp.CreateStatsChainSection() and CM.Cache.CacheChain()
|
* It is called by CM.Disp.CreateStatsChainSection() and CM.Cache.CacheChain()
|
||||||
* @param {number} CM.Cache.GoldenCookiesMult Multiplier for golden cookies
|
* @param {number} CM.Cache.GoldenCookiesMult Multiplier for golden cookies
|
||||||
* @param {number} CM.Cache.WrathCookiesMult Multiplier for wrath cookies
|
* @param {number} CM.Cache.WrathCookiesMult Multiplier for wrath cookies
|
||||||
@@ -137,9 +158,9 @@ CM.Cache.CacheGoldenAndWrathCookiesMults = function() {
|
|||||||
CM.Cache.WrathCookiesMult = 1;
|
CM.Cache.WrathCookiesMult = 1;
|
||||||
CM.Cache.DragonsFortuneMultAdjustment = 1;
|
CM.Cache.DragonsFortuneMultAdjustment = 1;
|
||||||
} else {
|
} else {
|
||||||
var goldenMult = 1;
|
let goldenMult = 1;
|
||||||
var wrathMult = 1;
|
let wrathMult = 1;
|
||||||
var mult = 1;
|
let mult = 1;
|
||||||
|
|
||||||
// Factor auras and upgrade in mults
|
// Factor auras and upgrade in mults
|
||||||
if (CM.Sim.Has('Green yeast digestives')) mult *= 1.01;
|
if (CM.Sim.Has('Green yeast digestives')) mult *= 1.01;
|
||||||
@@ -166,21 +187,21 @@ CM.Cache.CacheGoldenAndWrathCookiesMults = function() {
|
|||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This functions calculates the max possible payout
|
* This functions calculates the max possible payout given a set of variables
|
||||||
* It is called by CM.Disp.CreateStatsChainSection() and CM.Cache.CacheChain()
|
* It is called by CM.Disp.CreateStatsChainSection() and CM.Cache.CacheChain()
|
||||||
* @param {number} digit Number of Golden Cookies in chain
|
* @param {number} digit Number of Golden Cookies in chain
|
||||||
* @param {number} maxPayout Maximum payout
|
* @param {number} maxPayout Maximum payout
|
||||||
* @param {number} mult Multiplier
|
* @param {number} mult Multiplier
|
||||||
* @returns [{number, number}] Total cookies earned, and cookies needed for next level
|
* @returns [{number, number}] Total cookies earned, and cookies needed for next level
|
||||||
*/
|
*/
|
||||||
CM.Cache.MaxChainMoni = function(digit, maxPayout, mult) {
|
CM.Cache.MaxChainCookieReward = function(digit, maxPayout, mult) {
|
||||||
let totalFromChain = 0;
|
let totalFromChain = 0;
|
||||||
let moni = 0;
|
let moni = 0;
|
||||||
let nextMoni = 0;
|
let nextMoni = 0;
|
||||||
var chain = 1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10);
|
let chain = 1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10);
|
||||||
while (nextMoni < maxPayout) {
|
while (nextMoni < maxPayout) {
|
||||||
moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit * mult), maxPayout));
|
moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit * mult), maxPayout));
|
||||||
// TODO: Calculate Cookies or cps needed for next level of chain
|
// TODO: Calculate Cookies or cps needed for next level of chain. Related to issue #580
|
||||||
nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * mult), maxPayout));
|
nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit * mult), maxPayout));
|
||||||
totalFromChain += moni;
|
totalFromChain += moni;
|
||||||
chain++;
|
chain++;
|
||||||
@@ -211,20 +232,21 @@ CM.Cache.CacheChain = function() {
|
|||||||
if (cpsBuffMult > 0) maxPayout /= cpsBuffMult;
|
if (cpsBuffMult > 0) maxPayout /= cpsBuffMult;
|
||||||
else maxPayout = 0;
|
else maxPayout = 0;
|
||||||
|
|
||||||
CM.Cache.ChainReward = CM.Cache.MaxChainMoni(7, maxPayout * CM.Cache.GoldenCookiesMult, CM.Cache.GoldenCookiesMult);
|
CM.Cache.ChainReward = CM.Cache.MaxChainCookieReward(7, maxPayout * CM.Cache.GoldenCookiesMult, CM.Cache.GoldenCookiesMult);
|
||||||
// TODO: All "required" variables are incorrect. Perhaps something to do with going over the required amount during the chain
|
// TODO: All "required" variables are incorrect. Perhaps something to do with going over the required amount during the chain.
|
||||||
|
// See issue #580 on the Github
|
||||||
CM.Cache.ChainRequired = CM.Cache.ChainReward[0] * 2;
|
CM.Cache.ChainRequired = CM.Cache.ChainReward[0] * 2;
|
||||||
CM.Cache.ChainRequiredNext = CM.Cache.ChainReward[1] / 60 / 60 / 6 / CM.Cache.DragonsFortuneMultAdjustment;
|
CM.Cache.ChainRequiredNext = CM.Cache.ChainReward[1] / 60 / 60 / 6 / CM.Cache.DragonsFortuneMultAdjustment;
|
||||||
|
|
||||||
CM.Cache.ChainWrathReward = CM.Cache.MaxChainMoni(6, maxPayout * CM.Cache.WrathCookiesMult, CM.Cache.WrathCookiesMult);
|
CM.Cache.ChainWrathReward = CM.Cache.MaxChainCookieReward(6, maxPayout * CM.Cache.WrathCookiesMult, CM.Cache.WrathCookiesMult);
|
||||||
CM.Cache.ChainWrathRequired = CM.Cache.ChainWrathReward[0] * 2;
|
CM.Cache.ChainWrathRequired = CM.Cache.ChainWrathReward[0] * 2;
|
||||||
CM.Cache.ChainWrathRequiredNext = CM.Cache.ChainWrathReward[1] / 60 / 60 / 6 / CM.Cache.DragonsFortuneMultAdjustment;
|
CM.Cache.ChainWrathRequiredNext = CM.Cache.ChainWrathReward[1] / 60 / 60 / 6 / CM.Cache.DragonsFortuneMultAdjustment;
|
||||||
|
|
||||||
CM.Cache.ChainFrenzyReward = CM.Cache.MaxChainMoni(7, maxPayout * 7 * CM.Cache.GoldenCookiesMult, CM.Cache.GoldenCookiesMult);
|
CM.Cache.ChainFrenzyReward = CM.Cache.MaxChainCookieReward(7, maxPayout * 7 * CM.Cache.GoldenCookiesMult, CM.Cache.GoldenCookiesMult);
|
||||||
CM.Cache.ChainFrenzyRequired = CM.Cache.ChainFrenzyReward[0] * 2;
|
CM.Cache.ChainFrenzyRequired = CM.Cache.ChainFrenzyReward[0] * 2;
|
||||||
CM.Cache.ChainFrenzyRequiredNext = CM.Cache.ChainFrenzyReward[1] / 60 / 60 / 6 / CM.Cache.DragonsFortuneMultAdjustment;
|
CM.Cache.ChainFrenzyRequiredNext = CM.Cache.ChainFrenzyReward[1] / 60 / 60 / 6 / CM.Cache.DragonsFortuneMultAdjustment;
|
||||||
|
|
||||||
CM.Cache.ChainFrenzyWrathReward = CM.Cache.MaxChainMoni(6, maxPayout * 7 * CM.Cache.WrathCookiesMult, CM.Cache.WrathCookiesMult);
|
CM.Cache.ChainFrenzyWrathReward = CM.Cache.MaxChainCookieReward(6, maxPayout * 7 * CM.Cache.WrathCookiesMult, CM.Cache.WrathCookiesMult);
|
||||||
CM.Cache.ChainFrenzyWrathRequired = CM.Cache.ChainFrenzyReward[0] * 2;
|
CM.Cache.ChainFrenzyWrathRequired = CM.Cache.ChainFrenzyReward[0] * 2;
|
||||||
CM.Cache.ChainFrenzyWrathRequiredNext = CM.Cache.ChainFrenzyReward[1] / 60 / 60 / 6 / CM.Cache.DragonsFortuneMultAdjustment;
|
CM.Cache.ChainFrenzyWrathRequiredNext = CM.Cache.ChainFrenzyReward[1] / 60 / 60 / 6 / CM.Cache.DragonsFortuneMultAdjustment;
|
||||||
};
|
};
|
||||||
@@ -240,12 +262,12 @@ CM.Cache.CacheMissingUpgrades = function() {
|
|||||||
CM.Cache.MissingUpgrades = "";
|
CM.Cache.MissingUpgrades = "";
|
||||||
CM.Cache.MissingUpgradesCookies = "";
|
CM.Cache.MissingUpgradesCookies = "";
|
||||||
CM.Cache.MissingUpgradesPrestige = "";
|
CM.Cache.MissingUpgradesPrestige = "";
|
||||||
var list = [];
|
let list = [];
|
||||||
//sort the upgrades
|
//sort the upgrades
|
||||||
for (let i of Object.keys(Game.Upgrades)) {
|
for (let i of Object.keys(Game.Upgrades)) {
|
||||||
list.push(Game.Upgrades[i]);
|
list.push(Game.Upgrades[i]);
|
||||||
}
|
}
|
||||||
var sortMap = function(a, b) {
|
let sortMap = function(a, b) {
|
||||||
if (a.order>b.order) return 1;
|
if (a.order>b.order) return 1;
|
||||||
else if (a.order<b.order) return -1;
|
else if (a.order<b.order) return -1;
|
||||||
else return 0;
|
else return 0;
|
||||||
@@ -253,10 +275,10 @@ CM.Cache.CacheMissingUpgrades = function() {
|
|||||||
list.sort(sortMap);
|
list.sort(sortMap);
|
||||||
|
|
||||||
for (let i of Object.keys(list)) {
|
for (let i of Object.keys(list)) {
|
||||||
var me = list[i];
|
let me = list[i];
|
||||||
|
|
||||||
if (me.bought === 0) {
|
if (me.bought === 0) {
|
||||||
var str = '';
|
let str = '';
|
||||||
|
|
||||||
str += CM.Disp.crateMissing(me);
|
str += CM.Disp.crateMissing(me);
|
||||||
if (me.pool === 'prestige') CM.Cache.MissingUpgradesPrestige += str;
|
if (me.pool === 'prestige') CM.Cache.MissingUpgradesPrestige += str;
|
||||||
@@ -273,7 +295,7 @@ CM.Cache.CacheMissingUpgrades = function() {
|
|||||||
*/
|
*/
|
||||||
CM.Cache.CacheSeaSpec = function() {
|
CM.Cache.CacheSeaSpec = function() {
|
||||||
if (Game.season === 'christmas') {
|
if (Game.season === 'christmas') {
|
||||||
var val = Game.cookiesPs * 60;
|
let val = Game.cookiesPs * 60;
|
||||||
if (Game.hasBuff('Elder frenzy')) val *= 0.5;
|
if (Game.hasBuff('Elder frenzy')) val *= 0.5;
|
||||||
if (Game.hasBuff('Frenzy')) val *= 0.75;
|
if (Game.hasBuff('Frenzy')) val *= 0.75;
|
||||||
CM.Cache.SeaSpec = Math.max(25, val);
|
CM.Cache.SeaSpec = Math.max(25, val);
|
||||||
@@ -304,11 +326,15 @@ class CMAvgQueue {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
// TODO: Might want to do this according to "https://stackoverflow.com/questions/10359907/how-to-compute-the-sum-and-average-of-elements-in-an-array"
|
/**
|
||||||
|
* This functions returns the average of the values in the queue
|
||||||
|
* @param {number} timePeriod The period in seconds to computer average over
|
||||||
|
* @returns {number} ret The average
|
||||||
|
*/
|
||||||
calcAverage (timePeriod) {
|
calcAverage (timePeriod) {
|
||||||
if (timePeriod > this.maxLength) timePeriod = this.maxLength;
|
if (timePeriod > this.maxLength) timePeriod = this.maxLength;
|
||||||
if (timePeriod > this.queue.length) timePeriod = this.queue.length;
|
if (timePeriod > this.queue.length) timePeriod = this.queue.length;
|
||||||
var ret = 0;
|
let ret = 0;
|
||||||
for (let i = this.queue.length - 1; i >= 0 && i > this.queue.length - 1 - timePeriod; i--) {
|
for (let i = this.queue.length - 1; i >= 0 && i > this.queue.length - 1 - timePeriod; i--) {
|
||||||
ret += this.queue[i];
|
ret += this.queue[i];
|
||||||
}
|
}
|
||||||
@@ -330,39 +356,37 @@ CM.Cache.InitCookiesDiff = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This functions caches two variables related average CPS and Clicks
|
* This functions caches two variables related average CPS and Clicks
|
||||||
* It is called by CM.Main.Loop()
|
* It is called by CM.Cache.LoopCache()
|
||||||
* TODO: Check if this can be made more concise
|
|
||||||
* @global {number} CM.Cache.RealCookiesEarned Cookies earned including the Chocolate Egg
|
* @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.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
|
* @global {number} CM.Cache.AverageClicks Average cookies from clicking over time-period as defined by AvgClicksHist
|
||||||
* @global {number} CM.Cache.AvgCPSChoEgg Average cookies from combination of normal CPS and average Chocolate Cookie CPS
|
* @global {number} CM.Cache.AvgCPSChoEgg Average cookies from combination of normal CPS and average Chocolate Cookie CPS
|
||||||
*/
|
*/
|
||||||
CM.Cache.CacheAvgCPS = function() {
|
CM.Cache.CacheAvgCPS = function() {
|
||||||
var currDate = Math.floor(Date.now() / 1000);
|
let currDate = Math.floor(Date.now() / 1000);
|
||||||
// Only calculate every new second
|
// Only calculate every new second
|
||||||
if ((Game.T / Game.fps) % 1 === 0) {
|
if ((Game.T / Game.fps) % 1 === 0) {
|
||||||
var choEggTotal = Game.cookies + CM.Cache.SellForChoEgg;
|
let choEggTotal = Game.cookies + CM.Cache.SellForChoEgg;
|
||||||
if (Game.cpsSucked > 0) {
|
if (Game.cpsSucked > 0) choEggTotal += CM.Cache.WrinklersTotal;
|
||||||
choEggTotal += CM.Cache.WrinklersTotal;
|
|
||||||
}
|
|
||||||
CM.Cache.RealCookiesEarned = Math.max(Game.cookiesEarned, choEggTotal);
|
CM.Cache.RealCookiesEarned = Math.max(Game.cookiesEarned, choEggTotal);
|
||||||
choEggTotal *= 0.05;
|
choEggTotal *= 0.05;
|
||||||
|
|
||||||
if (CM.Cache.lastDate != -1) {
|
// Add recent gains to AvgQueue's
|
||||||
var timeDiff = currDate - CM.Cache.lastDate;
|
let timeDiff = currDate - CM.Cache.lastDate;
|
||||||
var bankDiffAvg = Math.max(0, (Game.cookies - CM.Cache.lastCookies)) / timeDiff;
|
let bankDiffAvg = Math.max(0, (Game.cookies - CM.Cache.lastCookies)) / timeDiff;
|
||||||
var wrinkDiffAvg = Math.max(0, (CM.Cache.WrinklersTotal - CM.Cache.lastWrinkCookies)) / timeDiff;
|
let wrinkDiffAvg = Math.max(0, (CM.Cache.WrinklersTotal - CM.Cache.lastWrinkCookies)) / timeDiff;
|
||||||
var wrinkFattestDiffAvg = Math.max(0, (CM.Cache.WrinklersFattest[0] - CM.Cache.lastWrinkFattestCookies)) / timeDiff;
|
let wrinkFattestDiffAvg = Math.max(0, (CM.Cache.WrinklersFattest[0] - CM.Cache.lastWrinkFattestCookies)) / timeDiff;
|
||||||
var choEggDiffAvg = Math.max(0,(choEggTotal - CM.Cache.lastChoEgg)) / timeDiff;
|
let choEggDiffAvg = Math.max(0,(choEggTotal - CM.Cache.lastChoEgg)) / timeDiff;
|
||||||
var clicksDiffAvg = (Game.cookieClicks - CM.Cache.lastClicks) / timeDiff;
|
let clicksDiffAvg = (Game.cookieClicks - CM.Cache.lastClicks) / timeDiff;
|
||||||
for (let i = 0; i < timeDiff; i++) {
|
for (let i = 0; i < timeDiff; i++) {
|
||||||
CM.Cache.CookiesDiff.addLatest(bankDiffAvg);
|
CM.Cache.CookiesDiff.addLatest(bankDiffAvg);
|
||||||
CM.Cache.WrinkDiff.addLatest(wrinkDiffAvg);
|
CM.Cache.WrinkDiff.addLatest(wrinkDiffAvg);
|
||||||
CM.Cache.WrinkFattestDiff.addLatest(wrinkFattestDiffAvg);
|
CM.Cache.WrinkFattestDiff.addLatest(wrinkFattestDiffAvg);
|
||||||
CM.Cache.ChoEggDiff.addLatest(choEggDiffAvg);
|
CM.Cache.ChoEggDiff.addLatest(choEggDiffAvg);
|
||||||
CM.Cache.ClicksDiff.addLatest(clicksDiffAvg);
|
CM.Cache.ClicksDiff.addLatest(clicksDiffAvg);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Store current data for next loop
|
||||||
CM.Cache.lastDate = currDate;
|
CM.Cache.lastDate = currDate;
|
||||||
CM.Cache.lastCookies = Game.cookies;
|
CM.Cache.lastCookies = Game.cookies;
|
||||||
CM.Cache.lastWrinkCookies = CM.Cache.WrinklersTotal;
|
CM.Cache.lastWrinkCookies = CM.Cache.WrinklersTotal;
|
||||||
@@ -370,18 +394,17 @@ CM.Cache.CacheAvgCPS = function() {
|
|||||||
CM.Cache.lastChoEgg = choEggTotal;
|
CM.Cache.lastChoEgg = choEggTotal;
|
||||||
CM.Cache.lastClicks = Game.cookieClicks;
|
CM.Cache.lastClicks = Game.cookieClicks;
|
||||||
|
|
||||||
var cpsLength = CM.Disp.cookieTimes[CM.Options.AvgCPSHist];
|
// Get average gain over period of cpsLength seconds
|
||||||
|
let cpsLength = CM.Disp.cookieTimes[CM.Options.AvgCPSHist];
|
||||||
CM.Cache.AverageGainBank = CM.Cache.CookiesDiff.calcAverage(cpsLength);
|
CM.Cache.AverageGainBank = CM.Cache.CookiesDiff.calcAverage(cpsLength);
|
||||||
CM.Cache.AverageGainWrink = CM.Cache.WrinkDiff.calcAverage(cpsLength);
|
CM.Cache.AverageGainWrink = CM.Cache.WrinkDiff.calcAverage(cpsLength);
|
||||||
CM.Cache.AverageGainWrinkFattest = CM.Cache.WrinkFattestDiff.calcAverage(cpsLength);
|
CM.Cache.AverageGainWrinkFattest = CM.Cache.WrinkFattestDiff.calcAverage(cpsLength);
|
||||||
CM.Cache.AverageGainChoEgg = CM.Cache.ChoEggDiff.calcAverage(cpsLength);
|
CM.Cache.AverageGainChoEgg = CM.Cache.ChoEggDiff.calcAverage(cpsLength);
|
||||||
|
|
||||||
CM.Cache.AvgCPS = CM.Cache.AverageGainBank;
|
CM.Cache.AvgCPS = CM.Cache.AverageGainBank;
|
||||||
if (CM.Options.CalcWrink === 1) CM.Cache.AvgCPS += CM.Cache.AverageGainWrink;
|
if (CM.Options.CalcWrink === 1) CM.Cache.AvgCPS += CM.Cache.AverageGainWrink;
|
||||||
if (CM.Options.CalcWrink === 2) CM.Cache.AvgCPS += CM.Cache.AverageGainWrinkFattest;
|
if (CM.Options.CalcWrink === 2) CM.Cache.AvgCPS += CM.Cache.AverageGainWrinkFattest;
|
||||||
|
|
||||||
var choEgg = (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg'));
|
let choEgg = (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg'));
|
||||||
|
|
||||||
if (choEgg || CM.Options.CalcWrink === 0) {
|
if (choEgg || CM.Options.CalcWrink === 0) {
|
||||||
CM.Cache.AvgCPSWithChoEgg = CM.Cache.AverageGainBank + CM.Cache.AverageGainWrink + (choEgg ? CM.Cache.AverageGainChoEgg : 0);
|
CM.Cache.AvgCPSWithChoEgg = CM.Cache.AverageGainBank + CM.Cache.AverageGainWrink + (choEgg ? CM.Cache.AverageGainChoEgg : 0);
|
||||||
@@ -398,13 +421,13 @@ CM.Cache.CacheAvgCPS = function() {
|
|||||||
* @global {number} CM.Cache.SellForChoEgg Total cookies to be gained from selling Chocolate egg
|
* @global {number} CM.Cache.SellForChoEgg Total cookies to be gained from selling Chocolate egg
|
||||||
*/
|
*/
|
||||||
CM.Cache.CacheSellForChoEgg = function() {
|
CM.Cache.CacheSellForChoEgg = function() {
|
||||||
var sellTotal = 0;
|
let sellTotal = 0;
|
||||||
// Compute cookies earned by selling stock market goods
|
// Compute cookies earned by selling stock market goods
|
||||||
if (Game.Objects.Bank.minigameLoaded) {
|
if (Game.Objects.Bank.minigameLoaded) {
|
||||||
var marketGoods = Game.Objects.Bank.minigame.goods;
|
let marketGoods = Game.Objects.Bank.minigame.goods;
|
||||||
var goodsVal = 0;
|
let goodsVal = 0;
|
||||||
for (let i of Object.keys(marketGoods)) {
|
for (let i of Object.keys(marketGoods)) {
|
||||||
var marketGood = marketGoods[i];
|
let marketGood = marketGoods[i];
|
||||||
goodsVal += marketGood.stock * marketGood.val;
|
goodsVal += marketGood.stock * marketGood.val;
|
||||||
}
|
}
|
||||||
sellTotal += goodsVal * Game.cookiesPsRawHighest;
|
sellTotal += goodsVal * Game.cookiesPsRawHighest;
|
||||||
@@ -416,7 +439,7 @@ CM.Cache.CacheSellForChoEgg = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This functions caches the current Wrinkler CPS multiplier
|
* 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.CurrWrinklerCount Current number of wrinklers
|
||||||
* @global {number} CM.Cache.CurrWrinklerCPSMult Current multiplier of CPS because of wrinklers (excluding their negative sucking effect)
|
* @global {number} CM.Cache.CurrWrinklerCPSMult Current multiplier of CPS because of wrinklers (excluding their negative sucking effect)
|
||||||
*/
|
*/
|
||||||
@@ -428,7 +451,7 @@ CM.Cache.CacheCurrWrinklerCPS = function() {
|
|||||||
}
|
}
|
||||||
let godMult = 1;
|
let godMult = 1;
|
||||||
if (CM.Sim.Objects.Temple.minigameLoaded) {
|
if (CM.Sim.Objects.Temple.minigameLoaded) {
|
||||||
var godLvl = Game.hasGod('scorn');
|
let godLvl = Game.hasGod('scorn');
|
||||||
if (godLvl === 1) godMult *= 1.15;
|
if (godLvl === 1) godMult *= 1.15;
|
||||||
else if (godLvl === 2) godMult *= 1.1;
|
else if (godLvl === 2) godMult *= 1.1;
|
||||||
else if (godLvl === 3) godMult *= 1.05;
|
else if (godLvl === 3) godMult *= 1.05;
|
||||||
@@ -443,7 +466,7 @@ CM.Cache.CacheCurrWrinklerCPS = function() {
|
|||||||
* @returns {number} mult The multiplier
|
* @returns {number} mult The multiplier
|
||||||
*/
|
*/
|
||||||
CM.Cache.getCPSBuffMult = function() {
|
CM.Cache.getCPSBuffMult = function() {
|
||||||
var mult = 1;
|
let mult = 1;
|
||||||
for (let i of Object.keys(Game.buffs)) {
|
for (let i of Object.keys(Game.buffs)) {
|
||||||
if (typeof Game.buffs[i].multCpS != 'undefined') mult *= Game.buffs[i].multCpS;
|
if (typeof Game.buffs[i].multCpS != 'undefined') mult *= Game.buffs[i].multCpS;
|
||||||
}
|
}
|
||||||
@@ -474,8 +497,8 @@ CM.Cache.NoGoldSwitchCPS = function() {
|
|||||||
CM.Cache.CacheDragonCost = function() {
|
CM.Cache.CacheDragonCost = function() {
|
||||||
if (CM.Cache.lastDragonLevel != Game.dragonLevel || CM.Sim.DoSims) {
|
if (CM.Cache.lastDragonLevel != Game.dragonLevel || CM.Sim.DoSims) {
|
||||||
if (Game.dragonLevel < 25 && Game.dragonLevels[Game.dragonLevel].buy.toString().includes("sacrifice")) {
|
if (Game.dragonLevel < 25 && Game.dragonLevels[Game.dragonLevel].buy.toString().includes("sacrifice")) {
|
||||||
var target = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/Objects\[(.*)\]/)[1];
|
let target = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/Objects\[(.*)\]/)[1];
|
||||||
var amount = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/sacrifice\((.*?)\)/)[1];
|
let amount = Game.dragonLevels[Game.dragonLevel].buy.toString().match(/sacrifice\((.*?)\)/)[1];
|
||||||
if (target != "i") {
|
if (target != "i") {
|
||||||
target = target.replaceAll("'", "");
|
target = target.replaceAll("'", "");
|
||||||
if (Game.Objects[target].amount < amount) {
|
if (Game.Objects[target].amount < amount) {
|
||||||
@@ -588,7 +611,7 @@ CM.Cache.CacheBuildingsPrices = function() {
|
|||||||
|
|
||||||
/**
|
/**
|
||||||
* This functions caches the PP of each building and upgrade and stores it in the cache
|
* 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.CachePP = function() {
|
||||||
CM.Cache.CacheBuildingsPP();
|
CM.Cache.CacheBuildingsPP();
|
||||||
|
|||||||
@@ -33,7 +33,7 @@ CM.Config.LoadConfig = function(settings) {
|
|||||||
CM.Options = settings;
|
CM.Options = settings;
|
||||||
|
|
||||||
// Check values
|
// Check values
|
||||||
var mod = false;
|
let mod = false;
|
||||||
for (let i in CM.Data.ConfigDefault) {
|
for (let i in CM.Data.ConfigDefault) {
|
||||||
if (typeof CM.Options[i] === 'undefined') {
|
if (typeof CM.Options[i] === 'undefined') {
|
||||||
mod = true;
|
mod = true;
|
||||||
|
|||||||
@@ -86,7 +86,7 @@ CM.Data.ConfigGroups = {
|
|||||||
BarsColors: "Bars/Colors",
|
BarsColors: "Bars/Colors",
|
||||||
Calculation: "Calculation",
|
Calculation: "Calculation",
|
||||||
Notification: "Notification",
|
Notification: "Notification",
|
||||||
Tooltip: "Tooltips",
|
Tooltip: "Tooltips and additional insights",
|
||||||
Statistics: "Statistics",
|
Statistics: "Statistics",
|
||||||
Notation: "Notation",
|
Notation: "Notation",
|
||||||
Miscellaneous: "Miscellaneous"
|
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.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.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.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
|
// Statistics
|
||||||
CM.Data.Config.Stats = {type: 'bool', group: 'Statistics', label: ['Statistics OFF', 'Statistics ON'], desc: 'Extra Cookie Monster statistics!', toggle: true};
|
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,
|
TooltipLump: 1,
|
||||||
TooltipPlots: 1,
|
TooltipPlots: 1,
|
||||||
DragonAuraInfo: 1,
|
DragonAuraInfo: 1,
|
||||||
|
TooltipAscendButton: 1,
|
||||||
Stats: 1,
|
Stats: 1,
|
||||||
MissingUpgrades: 1,
|
MissingUpgrades: 1,
|
||||||
UpStats: 1,
|
UpStats: 1,
|
||||||
|
|||||||
506
src/Disp.js
506
src/Disp.js
File diff suppressed because it is too large
Load Diff
@@ -13,7 +13,7 @@
|
|||||||
*/
|
*/
|
||||||
CM.init = function() {
|
CM.init = function() {
|
||||||
CM.Footer.isInitzializing = true
|
CM.Footer.isInitzializing = true
|
||||||
var proceed = true;
|
let proceed = true;
|
||||||
if (Game.version != CM.VersionMajor) {
|
if (Game.version != CM.VersionMajor) {
|
||||||
proceed = confirm('Cookie Monster version ' + CM.VersionMajor + '.' + CM.VersionMinor + ' is meant for Game version ' + CM.VersionMajor + '. Loading a different version may cause errors. Do you still want to load Cookie Monster?');
|
proceed = confirm('Cookie Monster version ' + CM.VersionMajor + '.' + CM.VersionMinor + ' is meant for Game version ' + CM.VersionMajor + '. Loading a different version may cause errors. Do you still want to load Cookie Monster?');
|
||||||
}
|
}
|
||||||
@@ -67,7 +67,7 @@ CM.Footer.AddJscolor = function() {
|
|||||||
*/
|
*/
|
||||||
if (typeof CM.Footer.isInitzializing === 'undefined') {
|
if (typeof CM.Footer.isInitzializing === 'undefined') {
|
||||||
CM.Footer.AddJscolor();
|
CM.Footer.AddJscolor();
|
||||||
var delay = setInterval(function() {
|
let delay = setInterval(function() {
|
||||||
if (typeof jscolor !== 'undefined') {
|
if (typeof jscolor !== 'undefined') {
|
||||||
jscolor.init();
|
jscolor.init();
|
||||||
Game.registerMod('CookieMonster', CM);
|
Game.registerMod('CookieMonster', CM);
|
||||||
|
|||||||
81
src/Main.js
81
src/Main.js
@@ -33,7 +33,7 @@ CM.Main.Loop = function() {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Check for aura change to recalculate buildings prices
|
// Check for aura change to recalculate buildings prices
|
||||||
var hasBuildAura = Game.auraMult('Fierce Hoarder') > 0;
|
let hasBuildAura = Game.auraMult('Fierce Hoarder') > 0;
|
||||||
if (!CM.Cache.HadBuildAura && hasBuildAura) {
|
if (!CM.Cache.HadBuildAura && hasBuildAura) {
|
||||||
CM.Cache.HadBuildAura = true;
|
CM.Cache.HadBuildAura = true;
|
||||||
CM.Cache.DoRemakeBuildPrices = 1;
|
CM.Cache.DoRemakeBuildPrices = 1;
|
||||||
@@ -48,24 +48,16 @@ CM.Main.Loop = function() {
|
|||||||
CM.Cache.DoRemakeBuildPrices = 0;
|
CM.Cache.DoRemakeBuildPrices = 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Update Wrinkler Bank
|
CM.Cache.LoopCache();
|
||||||
CM.Cache.CacheWrinklers();
|
|
||||||
|
|
||||||
// Calculate PP
|
// Check all changing minigames and game-states
|
||||||
CM.Cache.CachePP();
|
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();
|
|
||||||
};
|
};
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -87,6 +79,7 @@ CM.Main.DelayInit = function() {
|
|||||||
CM.Disp.CreateSimpleTooltip(CM.Disp.TooltipText[i][0], CM.Disp.TooltipText[i][1], CM.Disp.TooltipText[i][2]);
|
CM.Disp.CreateSimpleTooltip(CM.Disp.TooltipText[i][0], CM.Disp.TooltipText[i][1], CM.Disp.TooltipText[i][2]);
|
||||||
}
|
}
|
||||||
CM.Disp.CreateWrinklerButtons();
|
CM.Disp.CreateWrinklerButtons();
|
||||||
|
CM.Disp.UpdateBuildingUpgradeStyle();
|
||||||
CM.Main.ReplaceTooltips();
|
CM.Main.ReplaceTooltips();
|
||||||
CM.Main.AddWrinklerAreaDetect();
|
CM.Main.AddWrinklerAreaDetect();
|
||||||
|
|
||||||
@@ -101,14 +94,6 @@ CM.Main.DelayInit = function() {
|
|||||||
if (Game.prefs.popups) Game.Popup('Cookie Monster version ' + CM.VersionMajor + '.' + CM.VersionMinor + ' loaded!');
|
if (Game.prefs.popups) Game.Popup('Cookie Monster version ' + CM.VersionMajor + '.' + CM.VersionMinor + ' loaded!');
|
||||||
else Game.Notify('Cookie Monster version ' + CM.VersionMajor + '.' + CM.VersionMinor + ' loaded!', '', '', 1, 1);
|
else Game.Notify('Cookie Monster version ' + CM.VersionMajor + '.' + CM.VersionMinor + ' loaded!', '', '', 1, 1);
|
||||||
|
|
||||||
// TODO: given the architecture of your code, you probably want these lines somewhere else,
|
|
||||||
// but I stuck them here for convenience
|
|
||||||
l("products").style.display = "grid";
|
|
||||||
l("storeBulk").style.gridRow = "1/1";
|
|
||||||
|
|
||||||
l("upgrades").style.display = "flex";
|
|
||||||
l("upgrades").style["flex-wrap"] = "wrap";
|
|
||||||
|
|
||||||
Game.Win('Third-party');
|
Game.Win('Third-party');
|
||||||
};
|
};
|
||||||
|
|
||||||
@@ -210,8 +195,11 @@ CM.Main.ReplaceNative = function() {
|
|||||||
else return CM.Disp.FormatTime(time / Game.fps, 1);
|
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;
|
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() {
|
Game.Logic = function() {
|
||||||
CM.Backup.LogicMod();
|
CM.Backup.LogicMod();
|
||||||
// Update Title
|
// Update Title
|
||||||
@@ -234,7 +222,7 @@ CM.Main.ReplaceNativeGrimoire = function() {
|
|||||||
*/
|
*/
|
||||||
CM.Main.ReplaceNativeGrimoireLaunch = function() {
|
CM.Main.ReplaceNativeGrimoireLaunch = function() {
|
||||||
if (!CM.Main.HasReplaceNativeGrimoireLaunch && Game.Objects['Wizard tower'].minigameLoaded) {
|
if (!CM.Main.HasReplaceNativeGrimoireLaunch && Game.Objects['Wizard tower'].minigameLoaded) {
|
||||||
var minigame = Game.Objects['Wizard tower'].minigame;
|
let minigame = Game.Objects['Wizard tower'].minigame;
|
||||||
CM.Backup.GrimoireLaunch = minigame.launch;
|
CM.Backup.GrimoireLaunch = minigame.launch;
|
||||||
eval('CM.Backup.GrimoireLaunchMod = ' + minigame.launch.toString().split('=this').join('= Game.Objects[\'Wizard tower\'].minigame'));
|
eval('CM.Backup.GrimoireLaunchMod = ' + minigame.launch.toString().split('=this').join('= Game.Objects[\'Wizard tower\'].minigame'));
|
||||||
Game.Objects['Wizard tower'].minigame.launch = function() {
|
Game.Objects['Wizard tower'].minigame.launch = function() {
|
||||||
@@ -253,7 +241,7 @@ CM.Main.ReplaceNativeGrimoireLaunch = function() {
|
|||||||
*/
|
*/
|
||||||
CM.Main.ReplaceNativeGrimoireDraw = function() {
|
CM.Main.ReplaceNativeGrimoireDraw = function() {
|
||||||
if (!CM.Main.HasReplaceNativeGrimoireDraw && Game.Objects['Wizard tower'].minigameLoaded) {
|
if (!CM.Main.HasReplaceNativeGrimoireDraw && Game.Objects['Wizard tower'].minigameLoaded) {
|
||||||
var minigame = Game.Objects['Wizard tower'].minigame;
|
let minigame = Game.Objects['Wizard tower'].minigame;
|
||||||
CM.Backup.GrimoireDraw = minigame.draw;
|
CM.Backup.GrimoireDraw = minigame.draw;
|
||||||
Game.Objects['Wizard tower'].minigame.draw = function() {
|
Game.Objects['Wizard tower'].minigame.draw = function() {
|
||||||
CM.Backup.GrimoireDraw();
|
CM.Backup.GrimoireDraw();
|
||||||
@@ -299,7 +287,7 @@ CM.Main.ReplaceTooltips = function() {
|
|||||||
CM.Main.ReplaceTooltipBuild = function() {
|
CM.Main.ReplaceTooltipBuild = function() {
|
||||||
CM.Main.TooltipBuildBackup = [];
|
CM.Main.TooltipBuildBackup = [];
|
||||||
for (let i of Object.keys(Game.Objects)) {
|
for (let i of Object.keys(Game.Objects)) {
|
||||||
var me = Game.Objects[i];
|
let me = Game.Objects[i];
|
||||||
if (l('product' + me.id).onmouseover != null) {
|
if (l('product' + me.id).onmouseover != null) {
|
||||||
CM.Main.TooltipBuildBackup[i] = l('product' + me.id).onmouseover;
|
CM.Main.TooltipBuildBackup[i] = l('product' + me.id).onmouseover;
|
||||||
eval('l(\'product\' + me.id).onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'b\', \'' + i + '\');}, \'store\'); Game.tooltip.wobble();}');
|
eval('l(\'product\' + me.id).onmouseover = function() {Game.tooltip.dynamic = 1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip(\'b\', \'' + i + '\');}, \'store\'); Game.tooltip.wobble();}');
|
||||||
@@ -307,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()
|
* 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'
|
* CM.Disp.Tooltip() sets the tooltip type to 'g'
|
||||||
@@ -324,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()
|
* 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'
|
* CM.Disp.Tooltip() sets the tooltip type to 'p'
|
||||||
@@ -345,7 +333,7 @@ CM.Main.ReplaceTooltipGarden = function() {
|
|||||||
if (Game.Objects.Farm.minigameLoaded) {
|
if (Game.Objects.Farm.minigameLoaded) {
|
||||||
l('gardenTool-1').onmouseover = function() {Game.tooltip.dynamic=1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip('ha', 'HarvestAllButton');}, 'this'); Game.tooltip.wobble();};
|
l('gardenTool-1').onmouseover = function() {Game.tooltip.dynamic=1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip('ha', 'HarvestAllButton');}, 'this'); Game.tooltip.wobble();};
|
||||||
Array.from(l('gardenPlot').children).forEach((child) => {
|
Array.from(l('gardenPlot').children).forEach((child) => {
|
||||||
var coords = child.id.slice(-3,);
|
let coords = child.id.slice(-3,);
|
||||||
child.onmouseover = function() {Game.tooltip.dynamic=1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip('p', [`${coords[0]}`,`${coords[2]}`]);}, 'this'); Game.tooltip.wobble();};
|
child.onmouseover = function() {Game.tooltip.dynamic=1; Game.tooltip.draw(this, function() {return CM.Disp.Tooltip('p', [`${coords[0]}`,`${coords[2]}`]);}, 'this'); Game.tooltip.wobble();};
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
@@ -465,7 +453,7 @@ CM.Main.CheckGardenTick = function() {
|
|||||||
*/
|
*/
|
||||||
CM.Main.CheckMagicMeter = function() {
|
CM.Main.CheckMagicMeter = function() {
|
||||||
if (Game.Objects['Wizard tower'].minigameLoaded && CM.Options.GrimoireBar === 1) {
|
if (Game.Objects['Wizard tower'].minigameLoaded && CM.Options.GrimoireBar === 1) {
|
||||||
var minigame = Game.Objects['Wizard tower'].minigame;
|
let minigame = Game.Objects['Wizard tower'].minigame;
|
||||||
if (minigame.magic < minigame.magicM) CM.Main.lastMagicBarFull = false;
|
if (minigame.magic < minigame.magicM) CM.Main.lastMagicBarFull = false;
|
||||||
else if (!CM.Main.lastMagicBarFull) {
|
else if (!CM.Main.lastMagicBarFull) {
|
||||||
CM.Main.lastMagicBarFull = true;
|
CM.Main.lastMagicBarFull = true;
|
||||||
@@ -482,7 +470,7 @@ CM.Main.CheckMagicMeter = function() {
|
|||||||
*/
|
*/
|
||||||
CM.Main.CheckWrinklerCount = function() {
|
CM.Main.CheckWrinklerCount = function() {
|
||||||
if (Game.elderWrath > 0) {
|
if (Game.elderWrath > 0) {
|
||||||
var CurrentWrinklers = 0;
|
let CurrentWrinklers = 0;
|
||||||
for (let i in Game.wrinklers) {
|
for (let i in Game.wrinklers) {
|
||||||
if (Game.wrinklers[i].phase === 2) CurrentWrinklers++;
|
if (Game.wrinklers[i].phase === 2) CurrentWrinklers++;
|
||||||
}
|
}
|
||||||
@@ -512,8 +500,7 @@ CM.Main.CheckWrinklerCount = function() {
|
|||||||
/**
|
/**
|
||||||
* This function creates .onmouseover/out events that determine if the mouse is hovering-over a Wrinkler
|
* This function creates .onmouseover/out events that determine if the mouse is hovering-over a Wrinkler
|
||||||
* It is called by CM.Main.DelayInit
|
* It is called by CM.Main.DelayInit
|
||||||
* TODO: The system for displaying wrinklers should ideally use a similar system as other tooltips
|
* As wrinklers are not appended to the DOM we us a different system than for other tooltips
|
||||||
* Thus, writing a CM.Main.ReplaceTooltipWrinkler function etc.
|
|
||||||
*/
|
*/
|
||||||
CM.Main.AddWrinklerAreaDetect = function() {
|
CM.Main.AddWrinklerAreaDetect = function() {
|
||||||
l('backgroundLeftCanvas').onmouseover = function() {CM.Disp.TooltipWrinklerArea = 1;};
|
l('backgroundLeftCanvas').onmouseover = function() {CM.Disp.TooltipWrinklerArea = 1;};
|
||||||
@@ -536,7 +523,7 @@ CM.Main.AddWrinklerAreaDetect = function() {
|
|||||||
*/
|
*/
|
||||||
CM.Main.FixMouseY = function(target) {
|
CM.Main.FixMouseY = function(target) {
|
||||||
if (CM.Options.TimerBar === 1 && CM.Options.TimerBarPos === 0) {
|
if (CM.Options.TimerBar === 1 && CM.Options.TimerBarPos === 0) {
|
||||||
var timerBarHeight = parseInt(CM.Disp.TimerBar.style.height);
|
let timerBarHeight = parseInt(CM.Disp.TimerBar.style.height);
|
||||||
Game.mouseY -= timerBarHeight;
|
Game.mouseY -= timerBarHeight;
|
||||||
target();
|
target();
|
||||||
Game.mouseY += timerBarHeight;
|
Game.mouseY += timerBarHeight;
|
||||||
|
|||||||
24
src/Sim.js
24
src/Sim.js
@@ -17,7 +17,7 @@
|
|||||||
* @returns {number} moni Total price
|
* @returns {number} moni Total price
|
||||||
*/
|
*/
|
||||||
CM.Sim.BuildingGetPrice = function(build, basePrice, start, free, increase) {
|
CM.Sim.BuildingGetPrice = function(build, basePrice, start, free, increase) {
|
||||||
var moni = 0;
|
let moni = 0;
|
||||||
for (let i = 0; i < increase; i++) {
|
for (let i = 0; i < increase; i++) {
|
||||||
let price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free));
|
let price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free));
|
||||||
price = Game.modifyBuildingPrice(build, price);
|
price = Game.modifyBuildingPrice(build, price);
|
||||||
@@ -84,14 +84,14 @@ CM.Sim.BuildingSell = function(build, basePrice, start, free, amount, noSim) {
|
|||||||
// Calculate money gains from selling buildings
|
// Calculate money gains from selling buildings
|
||||||
// If noSim is set, use Game methods to compute price instead of Sim ones.
|
// If noSim is set, use Game methods to compute price instead of Sim ones.
|
||||||
noSim = typeof noSim === "undefined" ? 0 : noSim;
|
noSim = typeof noSim === "undefined" ? 0 : noSim;
|
||||||
var moni = 0;
|
let moni = 0;
|
||||||
if (amount === -1) amount = start;
|
if (amount === -1) amount = start;
|
||||||
if (!amount) amount = Game.buyBulk;
|
if (!amount) amount = Game.buyBulk;
|
||||||
for (let i = 0; i < amount; i++) {
|
for (let i = 0; i < amount; i++) {
|
||||||
let price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free));
|
let price = basePrice * Math.pow(Game.priceIncrease, Math.max(0, start - free));
|
||||||
price = noSim ? Game.modifyBuildingPrice(build, price) : CM.Sim.modifyBuildingPrice(build, price);
|
price = noSim ? Game.modifyBuildingPrice(build, price) : CM.Sim.modifyBuildingPrice(build, price);
|
||||||
price = Math.ceil(price);
|
price = Math.ceil(price);
|
||||||
var giveBack = noSim ? build.getSellMultiplier() : CM.Sim.getSellMultiplier();
|
let giveBack = noSim ? build.getSellMultiplier() : CM.Sim.getSellMultiplier();
|
||||||
price = Math.floor(price * giveBack);
|
price = Math.floor(price * giveBack);
|
||||||
if (start > 0) {
|
if (start > 0) {
|
||||||
moni += price;
|
moni += price;
|
||||||
@@ -192,7 +192,7 @@ CM.Sim.hasAura = function(what) {
|
|||||||
* @returns {number} The multiplier
|
* @returns {number} The multiplier
|
||||||
*/
|
*/
|
||||||
CM.Sim.auraMult = function(what) {
|
CM.Sim.auraMult = function(what) {
|
||||||
var n = 0;
|
let n = 0;
|
||||||
if (Game.dragonAuras[CM.Sim.dragonAura].name === what || Game.dragonAuras[CM.Sim.dragonAura2].name === what)
|
if (Game.dragonAuras[CM.Sim.dragonAura].name === what || Game.dragonAuras[CM.Sim.dragonAura2].name === what)
|
||||||
n = 1;
|
n = 1;
|
||||||
if (Game.dragonAuras[CM.Sim.dragonAura].name === 'Reality Bending' || Game.dragonAuras[CM.Sim.dragonAura2].name === 'Reality Bending')
|
if (Game.dragonAuras[CM.Sim.dragonAura].name === 'Reality Bending' || Game.dragonAuras[CM.Sim.dragonAura2].name === 'Reality Bending')
|
||||||
@@ -211,8 +211,8 @@ CM.Sim.hasGod = function(what) {
|
|||||||
if (!CM.Sim.Objects.Temple.minigameLoaded) {
|
if (!CM.Sim.Objects.Temple.minigameLoaded) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
var possibleGods = CM.Sim.Objects.Temple.minigame.gods;
|
let possibleGods = CM.Sim.Objects.Temple.minigame.gods;
|
||||||
var god=possibleGods[what];
|
let god=possibleGods[what];
|
||||||
for (let i=0;i<3;i++)
|
for (let i=0;i<3;i++)
|
||||||
{
|
{
|
||||||
if (CM.Sim.Objects.Temple.minigame.slot[i]==god.id) return (i+1);
|
if (CM.Sim.Objects.Temple.minigame.slot[i]==god.id) return (i+1);
|
||||||
@@ -559,7 +559,7 @@ CM.Sim.CalculateGains = function() {
|
|||||||
if (CM.Sim.Has('Ant larva')) eggMult *= 1.01;
|
if (CM.Sim.Has('Ant larva')) eggMult *= 1.01;
|
||||||
if (CM.Sim.Has('Century egg')) {
|
if (CM.Sim.Has('Century egg')) {
|
||||||
// The boost increases a little every day, with diminishing returns up to +10% on the 100th day
|
// The boost increases a little every day, with diminishing returns up to +10% on the 100th day
|
||||||
var day = Math.floor((CM.Sim.DateCentury - Game.startDate) / 1000 / 10) * 10 / 60 / 60 / 24;
|
let day = Math.floor((CM.Sim.DateCentury - Game.startDate) / 1000 / 10) * 10 / 60 / 60 / 24;
|
||||||
day = Math.min(day, 100);
|
day = Math.min(day, 100);
|
||||||
// Sets a Cache value to be displayed in the Stats page, could be moved...
|
// Sets a Cache value to be displayed in the Stats page, could be moved...
|
||||||
CM.Cache.CentEgg = 1 + (1 - Math.pow(1 - day / 100, 3)) * 0.1;
|
CM.Cache.CentEgg = 1 + (1 - Math.pow(1 - day / 100, 3)) * 0.1;
|
||||||
@@ -748,7 +748,7 @@ CM.Sim.BuyBuildingsBonusIncome = function(building, amount) {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
var lastAchievementsOwned = CM.Sim.AchievementsOwned;
|
let lastAchievementsOwned = CM.Sim.AchievementsOwned;
|
||||||
|
|
||||||
CM.Sim.CalculateGains();
|
CM.Sim.CalculateGains();
|
||||||
|
|
||||||
@@ -789,7 +789,7 @@ CM.Sim.BuyUpgradesBonusIncome = function(upgrade) {
|
|||||||
CM.Sim.Win('Wholesome');
|
CM.Sim.Win('Wholesome');
|
||||||
}
|
}
|
||||||
|
|
||||||
var lastAchievementsOwned = CM.Sim.AchievementsOwned;
|
let lastAchievementsOwned = CM.Sim.AchievementsOwned;
|
||||||
|
|
||||||
CM.Sim.CalculateGains();
|
CM.Sim.CalculateGains();
|
||||||
|
|
||||||
@@ -900,7 +900,7 @@ CM.Sim.CalculateChangeAura = function(aura) {
|
|||||||
CM.Sim.CopyData();
|
CM.Sim.CopyData();
|
||||||
|
|
||||||
// Check if aura being changed is first or second aura
|
// Check if aura being changed is first or second aura
|
||||||
var auraToBeChanged = l('promptContent').children[0].innerHTML.includes("secondary");
|
let auraToBeChanged = l('promptContent').children[0].innerHTML.includes("secondary");
|
||||||
if (auraToBeChanged) CM.Sim.dragonAura2 = aura;
|
if (auraToBeChanged) CM.Sim.dragonAura2 = aura;
|
||||||
else CM.Sim.dragonAura = aura;
|
else CM.Sim.dragonAura = aura;
|
||||||
|
|
||||||
@@ -909,7 +909,7 @@ CM.Sim.CalculateChangeAura = function(aura) {
|
|||||||
if (CM.Sim.dragonAura != CM.Cache.dragonAura || CM.Sim.dragonAura2 != CM.Cache.dragonAura2) {
|
if (CM.Sim.dragonAura != CM.Cache.dragonAura || CM.Sim.dragonAura2 != CM.Cache.dragonAura2) {
|
||||||
for (let i = Game.ObjectsById.length; i > -1, --i;) {
|
for (let i = Game.ObjectsById.length; i > -1, --i;) {
|
||||||
if (Game.ObjectsById[i].amount > 0) {
|
if (Game.ObjectsById[i].amount > 0) {
|
||||||
var highestBuilding = CM.Sim.Objects[Game.ObjectsById[i].name].name;
|
let highestBuilding = CM.Sim.Objects[Game.ObjectsById[i].name].name;
|
||||||
CM.Sim.Objects[highestBuilding].amount -=1;
|
CM.Sim.Objects[highestBuilding].amount -=1;
|
||||||
CM.Sim.buildingsOwned -= 1;
|
CM.Sim.buildingsOwned -= 1;
|
||||||
price = CM.Sim.Objects[highestBuilding].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[highestBuilding].amount - 1 -CM.Sim.Objects[highestBuilding].free));
|
price = CM.Sim.Objects[highestBuilding].basePrice * Math.pow(Game.priceIncrease, Math.max(0, CM.Sim.Objects[highestBuilding].amount - 1 -CM.Sim.Objects[highestBuilding].free));
|
||||||
@@ -1029,7 +1029,7 @@ CM.Sim.SellBuildingsForChoEgg = function() {
|
|||||||
|
|
||||||
// Sacrifice highest buildings for the aura switch
|
// Sacrifice highest buildings for the aura switch
|
||||||
for (let i = 0; i < buildingsToSacrifice; ++i) {
|
for (let i = 0; i < buildingsToSacrifice; ++i) {
|
||||||
var highestBuilding = 0;
|
let highestBuilding = 0;
|
||||||
for (let j in CM.Sim.Objects) {
|
for (let j in CM.Sim.Objects) {
|
||||||
if (CM.Sim.Objects[j].amount > 0) {
|
if (CM.Sim.Objects[j].amount > 0) {
|
||||||
highestBuilding = CM.Sim.Objects[j];
|
highestBuilding = CM.Sim.Objects[j];
|
||||||
|
|||||||
Reference in New Issue
Block a user