diff --git a/CookieMonster.js b/CookieMonster.js index 0430d4f..3cb746a 100644 --- a/CookieMonster.js +++ b/CookieMonster.js @@ -21,6 +21,14 @@ CM.Sim = {}; /********* * Cache * *********/ + +CM.Cache.NextNumber = function(base) { + var count = base > Math.pow(2, 53) ? Math.pow(2, Math.floor(Math.log(base) / Math.log(2)) - 53) : 1; + while (base == base + count) { + count = CM.Cache.NextNumber(count); + } + return (base + count); +} CM.Cache.RemakeIncome = function() { // Simulate Building Buys for 1 amount @@ -139,11 +147,7 @@ CM.Cache.RemakeChain = function() { CM.Cache.Chain = 0; } else { - count = base > Math.pow(2, 53) ? Math.pow(2, Math.floor(Math.log(base) / Math.log(2)) - 53) : 1; - while (base == base + count) { - count++; - } - CM.Cache.Chain = (base + count) / 0.25; + CM.Cache.Chain = CM.Cache.NextNumber(base) / 0.25; } CM.Cache.ChainFrenzyReward = CM.Cache.MaxChainMoni(7, maxPayout * 7); @@ -160,11 +164,7 @@ CM.Cache.RemakeChain = function() { CM.Cache.ChainFrenzy = 0; } else { - count = base > Math.pow(2, 53) ? Math.pow(2, Math.floor(Math.log(base) / Math.log(2)) - 53) : 1; - while(base == base + count) { - count++; - } - CM.Cache.ChainFrenzy = (base + count) / 0.25; + CM.Cache.ChainFrenzy = CM.Cache.NextNumber(base) / 0.25; } } @@ -2086,7 +2086,7 @@ CM.VersionMinor = '14'; * Sim * *******/ -CM.Sim.BuildingGetPrice = function (basePrice, start, increase) { +CM.Sim.BuildingGetPrice = function(basePrice, start, increase) { var totalPrice = 0; var count = 0; while(count < increase) { diff --git a/src/Cache.js b/src/Cache.js index 42099f1..a10ed9a 100644 --- a/src/Cache.js +++ b/src/Cache.js @@ -1,6 +1,14 @@ /********* * Cache * *********/ + +CM.Cache.NextNumber = function(base) { + var count = base > Math.pow(2, 53) ? Math.pow(2, Math.floor(Math.log(base) / Math.log(2)) - 53) : 1; + while (base == base + count) { + count = CM.Cache.NextNumber(count); + } + return (base + count); +} CM.Cache.RemakeIncome = function() { // Simulate Building Buys for 1 amount @@ -119,11 +127,7 @@ CM.Cache.RemakeChain = function() { CM.Cache.Chain = 0; } else { - count = base > Math.pow(2, 53) ? Math.pow(2, Math.floor(Math.log(base) / Math.log(2)) - 53) : 1; - while (base == base + count) { - count++; - } - CM.Cache.Chain = (base + count) / 0.25; + CM.Cache.Chain = CM.Cache.NextNumber(base) / 0.25; } CM.Cache.ChainFrenzyReward = CM.Cache.MaxChainMoni(7, maxPayout * 7); @@ -140,11 +144,7 @@ CM.Cache.RemakeChain = function() { CM.Cache.ChainFrenzy = 0; } else { - count = base > Math.pow(2, 53) ? Math.pow(2, Math.floor(Math.log(base) / Math.log(2)) - 53) : 1; - while(base == base + count) { - count++; - } - CM.Cache.ChainFrenzy = (base + count) / 0.25; + CM.Cache.ChainFrenzy = CM.Cache.NextNumber(base) / 0.25; } } diff --git a/src/Sim.js b/src/Sim.js index 0aea15e..b73c1fe 100644 --- a/src/Sim.js +++ b/src/Sim.js @@ -2,7 +2,7 @@ * Sim * *******/ -CM.Sim.BuildingGetPrice = function (basePrice, start, increase) { +CM.Sim.BuildingGetPrice = function(basePrice, start, increase) { var totalPrice = 0; var count = 0; while(count < increase) {