diff --git a/CookieMonster.js b/CookieMonster.js index a33ebf67..556e0c09 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -287,26 +287,28 @@ CM.Cache.UpdateAvgCPS = function() { var totalGainBank = 0; var totalGainWrink = 0; var totalGainChoEgg = 0; + var cpsLength = Math.min(CM.Cache.CookiesDiff.getLength(), CM.Disp.times[CM.Config.AvgCPSHist] * 60); // Assumes the queues are the same length - for (var i = 0; i < Math.min(CM.Cache.CookiesDiff.getLength(), CM.Disp.times[CM.Config.AvgCPSHist] * 60); i++) { + for (var i = CM.Cache.CookiesDiff.getLength() - cpsLength; i < CM.Cache.CookiesDiff.getLength(); i++) { totalGainBank += CM.Cache.CookiesDiff.get(i); totalGainWrink += CM.Cache.WrinkDiff.get(i); totalGainChoEgg += CM.Cache.ChoEggDiff.get(i); } - CM.Cache.AvgCPS = (totalGainBank + (CM.Config.CalcWrink ? totalGainWrink : 0)) / CM.Cache.CookiesDiff.getLength(); + CM.Cache.AvgCPS = (totalGainBank + (CM.Config.CalcWrink ? totalGainWrink : 0)) / cpsLength; if (Game.HasUnlocked('Chocolate egg') && !Game.Has('Chocolate egg')) { - CM.Cache.AvgCPSChoEgg = (totalGainBank + (CM.Config.CalcWrink ? totalGainWrink : 0) + totalGainChoEgg) / CM.Cache.CookiesDiff.getLength(); + CM.Cache.AvgCPSChoEgg = (totalGainBank + (CM.Config.CalcWrink ? totalGainWrink : 0) + totalGainChoEgg) / cpsLength; } else { CM.Cache.AvgCPSChoEgg = CM.Cache.AvgCPS; } var totalClicks = 0; - for (var i = 0; i < Math.min(CM.Cache.ClicksDiff.getLength(), CM.Disp.times[CM.Config.AvgClicksHist]); i++) { + var clicksLength = Math.min(CM.Cache.ClicksDiff.getLength(), CM.Disp.times[CM.Config.AvgClicksHist]); + for (var i = CM.Cache.ClicksDiff.getLength() - clicksLength; i < CM.Cache.ClicksDiff.getLength(); i++) { totalClicks += CM.Cache.ClicksDiff.get(i); } - CM.Cache.AvgClicks = totalClicks / CM.Cache.ClicksDiff.getLength(); + CM.Cache.AvgClicks = totalClicks / clicksLength; } } @@ -471,7 +473,7 @@ CM.ConfigData.Colors = {desc: {Blue: 'Color Blue. Used to show better than best CM.ConfigData.CalcWrink = {label: ['Calculate with Wrinklers OFF', 'Calculate with Wrinklers ON'], desc: 'Calculate times and average Cookies Per Second with Wrinkers', toggle: true}; CM.ConfigData.CPSMode = {label: ['Current Cookies Per Second', 'Average Cookies Per Second'], desc: 'Calculate times using current Cookies Per Second or average Cookies Per Second', toggle: false}; CM.ConfigData.AvgCPSHist = {label: ['Average CPS for past 1m', 'Average CPS for past 5m', 'Average CPS for past 10m', 'Average CPS for past 15m', 'Average CPS for past 30m'], desc: 'How much time average Cookies Per Second should consider', toggle: false}; -CM.ConfigData.AvgClicksHist = {label: ['Average Cookie Clicks for past 1s', 'Average Cookie Clicks for past 5s', 'Average Cookie Clicks for past 10s', 'Average Cookie Clicks for past 15s', 'Average CPS for past 30 mins'], desc: 'How much time average Cookie Clicks should consider', toggle: false}; +CM.ConfigData.AvgClicksHist = {label: ['Average Cookie Clicks for past 1s', 'Average Cookie Clicks for past 5s', 'Average Cookie Clicks for past 10s', 'Average Cookie Clicks for past 15s', 'Average Cookie Clicks for past 30s'], desc: 'How much time average Cookie Clicks should consider', toggle: false}; CM.ConfigData.ToolWarnCautBon = {label: ['Calculate Tooltip Warning/Caution With Bonus CPS OFF', 'Calculate Tooltip Warning/Caution With Bonus CPS ON'], desc: 'Calculate the warning/caution with or without the bonus CPS you get from buying', toggle: true}; CM.ConfigData.Flash = {label: ['Flash OFF', 'Flash ON'], desc: 'Flash screen on Golden Cookie/Season Popup', toggle: true}; CM.ConfigData.Sound = {label: ['Sounds OFF', 'Sounds ON'], desc: 'Play a sound on Golden Cookie/Season Popup', toggle: true}; @@ -1416,6 +1418,8 @@ CM.Disp.AddMenuPref = function(title) { frag.appendChild(header('Calculation')); frag.appendChild(listing('CalcWrink')); frag.appendChild(listing('CPSMode')); + frag.appendChild(listing('AvgCPSHist')); + frag.appendChild(listing('AvgClicksHist')); frag.appendChild(listing('ToolWarnCautBon')); frag.appendChild(header('Golden Cookie/Season Popup Emphasis'));