Skip to content

Commit

Permalink
Change how chain and missing cookies/eggs stats work
Browse files Browse the repository at this point in the history
  • Loading branch information
Aktanusa committed Jun 10, 2014
1 parent ddf70d1 commit 93f8791
Show file tree
Hide file tree
Showing 3 changed files with 264 additions and 76 deletions.
170 changes: 132 additions & 38 deletions CookieMonster.js
Original file line number Diff line number Diff line change
Expand Up @@ -83,31 +83,48 @@ CM.Cache.RemakeLucky = function() {
CM.Cache.LuckyRewardFrenzy = (CM.Cache.LuckyFrenzy * 0.1) + 13;
}

CM.Cache.RemakeChain = function() {
CM.Cache.Chain = Game.cookiesPs * 60 * 60 * 3 / 0.25;

var digit = 7;
CM.Cache.MaxChainMoni = function(digit, maxPayout) {
var chain = 1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10);
var maxPayout = Game.cookiesPs * 60 * 60 * 3;
var moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit), maxPayout));
var nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit), maxPayout));
while (nextMoni < maxPayout) {
chain++;
moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit), maxPayout));
nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit), maxPayout));
}
CM.Cache.ChainReward = moni;
return moni;
}

CM.Cache.RemakeChain = function() {
var maxPayout = Game.cookiesPs * 60 * 60 * 3;
if (Game.frenzy > 0) {
maxPayout /= Game.frenzyPower;
}

digit = 6;
chain = 1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10);
moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit), maxPayout));
nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit), maxPayout));
while (nextMoni < maxPayout) {
chain++;
moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit), maxPayout));
nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit), maxPayout));
CM.Cache.ChainReward = CM.Cache.MaxChainMoni(7, maxPayout);

CM.Cache.ChainWrathReward = CM.Cache.MaxChainMoni(6, maxPayout);

var base = 0;
if (CM.Cache.ChainReward > CM.Cache.ChainWrathReward) {
base = CM.Cache.ChainReward;
}
CM.Cache.ChainWrathReward = moni;
else {
base = CM.Cache.ChainWrathReward;
}
var count = 1;
while (base == base + count) {
count++;
}
CM.Cache.Chain = (base + count) / 0.25;

CM.Cache.ChainFrenzyReward = CM.Cache.MaxChainMoni(7, maxPayout * 7);

count = 1;
while(CM.Cache.ChainFrenzyReward == CM.Cache.ChainFrenzyReward + count) {
count++;
}
CM.Cache.ChainFrenzy = (CM.Cache.ChainFrenzyReward + count) / 0.25;
}

CM.Cache.RemakeSeaSpec = function() {
Expand All @@ -125,6 +142,8 @@ CM.Cache.SeaSpec = 0;
CM.Cache.Chain = 0;
CM.Cache.ChainReward = 0;
CM.Cache.ChainWrathReward = 0;
CM.Cache.ChainFrenzy = 0;
CM.Cache.ChainFrenzyReward = 0;
/**********
* Config *
**********/
Expand Down Expand Up @@ -973,31 +992,50 @@ CM.Disp.AddMenu = function() {

var chainColor = (Game.cookies < CM.Cache.Chain) ? CM.Disp.colorRed : CM.Disp.colorGreen;
var chainTime = (Game.cookies < CM.Cache.Chain) ? CM.Disp.FormatTime((CM.Cache.Chain - Game.cookies) / (Game.cookiesPs * (1 - Game.cpsSucked))) : '';

var chainColorFrenzy = (Game.cookies < CM.Cache.ChainFrenzy) ? CM.Disp.colorRed : CM.Disp.colorGreen;
var chainTimeFrenzy = (Game.cookies < CM.Cache.ChainFrenzy) ? CM.Disp.FormatTime((CM.Cache.ChainFrenzy - Game.cookies) / (Game.cookiesPs * (1 - Game.cpsSucked))) : '';
var chainCurMax = Math.min(Game.cookiesPs * 60 * 60 * 3, Game.cookies * 0.25);
var chainCur = CM.Cache.MaxChainMoni(7, chainCurMax);
var chainCurWrath = CM.Cache.MaxChainMoni(6, chainCurMax);

var possibleHC = Game.HowMuchPrestige(Game.cookiesEarned + Game.cookiesReset);
var neededCook = CM.Sim.CookNeedPrest(possibleHC + 1) - (Game.cookiesEarned + Game.cookiesReset);

var halloCook = 0;
var specDisp = false;
var halloCook = [];
for (var i in CM.Data.HalloCookies) {
if (Game.Has(CM.Data.HalloCookies[i])) halloCook++;
if (!Game.Has(CM.Data.HalloCookies[i])) {
halloCook.push(CM.Data.HalloCookies[i]);
specDisp = true;
}
}
var christCook = 0;
var christCook = [];
for (var i in CM.Data.ChristCookies) {
if (Game.Has(CM.Data.ChristCookies[i])) christCook++;
if (!Game.Has(CM.Data.ChristCookies[i])) {
christCook.push(CM.Data.ChristCookies[i]);
specDisp = true;
}
}
var valCook = 0;
var valCook = [];
for (var i in CM.Data.ValCookies) {
if (Game.Has(CM.Data.ValCookies[i])) valCook++;
else break;
if (!Game.Has(CM.Data.ValCookies[i])) {
valCook.push(CM.Data.ValCookies[i]);
specDisp = true;
}
}
var normEggs = 0;
var normEggs = [];
for (var i in Game.eggDrops) {
if (Game.HasUnlocked(Game.eggDrops[i])) normEggs++;
if (!Game.HasUnlocked(Game.eggDrops[i])) {
normEggs.push(Game.eggDrops[i]);
specDisp = true;
}
}
var rareEggs = 0;
var rareEggs = [];
for (var i in Game.rareEggDrops) {
if (Game.HasUnlocked(Game.rareEggDrops[i])) rareEggs++;
if (!Game.HasUnlocked(Game.rareEggDrops[i])) {
rareEggs.push(Game.rareEggDrops[i]);
specDisp = true;
}
}

var listing = function(name, text) {
Expand Down Expand Up @@ -1050,9 +1088,24 @@ CM.Disp.AddMenu = function() {
chainReqSmall.textContent = ' (' + chainTime + ')';
chainReqFrag.appendChild(chainReqSmall);
}
stats.appendChild(listing('Chain Cookies Required', chainReqFrag));
stats.appendChild(listing('Chain Reward (MAX)', document.createTextNode(Beautify(CM.Cache.ChainReward))));
stats.appendChild(listing('Chain Reward (MAX) (Wrath)', document.createTextNode(Beautify(CM.Cache.ChainWrathReward))));
stats.appendChild(listing('\"Chain\" Cookies Required', chainReqFrag));
var chainReqFrenFrag = document.createDocumentFragment();
var chainReqFrenSpan = document.createElement('span');
chainReqFrenSpan.style.fontWeight = 'bold';
chainReqFrenSpan.style.color = chainColorFrenzy;
chainReqFrenSpan.textContent = Beautify(CM.Cache.ChainFrenzy);
chainReqFrenFrag.appendChild(chainReqFrenSpan);
if (chainTimeFrenzy != '') {
var chainReqFrenSmall = document.createElement('small');
chainReqFrenSmall.textContent = ' (' + chainTimeFrenzy + ')';
chainReqFrenFrag.appendChild(chainReqFrenSmall);
}
stats.appendChild(listing('\"Chain\" Cookies Required (Frenzy)', chainReqFrenFrag));
stats.appendChild(listing('\"Chain\" Reward (MAX)', document.createTextNode(Beautify(CM.Cache.ChainReward))));
stats.appendChild(listing('\"Chain\" Reward (MAX) (Wrath)', document.createTextNode(Beautify(CM.Cache.ChainWrathReward))));
stats.appendChild(listing('\"Chain\" Reward (MAX) (Frenzy)', document.createTextNode(Beautify(CM.Cache.ChainFrenzyReward))));
stats.appendChild(listing('\"Chain\" Reward (CUR)', document.createTextNode(Beautify(chainCur))));
stats.appendChild(listing('\"Chain\" Reward (CUR) (Wrath)', document.createTextNode(Beautify(chainCurWrath))));
stats.appendChild(header('Heavenly Chips'));
var hcMaxFrag = document.createDocumentFragment();
hcMaxFrag.appendChild(document.createTextNode(Beautify(possibleHC)));
Expand All @@ -1079,14 +1132,55 @@ CM.Disp.AddMenu = function() {
if (Game.Has('Wrinklerspawn')) sucked *= 1.05;
stats.appendChild(listing('Rewards of Popping', document.createTextNode(Beautify(sucked))));
}
stats.appendChild(header('Season Specials'));
stats.appendChild(listing('Halloween Cookies Bought', document.createTextNode(halloCook + ' of ' + CM.Data.HalloCookies.length)));
stats.appendChild(listing('Christmas Cookies Bought', document.createTextNode(christCook + ' of ' + CM.Data.ChristCookies.length)));
stats.appendChild(listing('Valentine Cookies Bought', document.createTextNode(valCook + ' of ' + CM.Data.ValCookies.length)));
stats.appendChild(listing('Normal Easter Eggs Unlocked', document.createTextNode(normEggs + ' of ' + Game.eggDrops.length)));
stats.appendChild(listing('Rare Easter Eggs Unlocked', document.createTextNode(rareEggs + ' of ' + Game.rareEggDrops.length)));
if (Game.season == 'christmas') {
stats.appendChild(listing('Reindeer Reward', document.createTextNode(Beautify(CM.Cache.SeaSpec))));
if (Game.season == 'christmas' || specDisp) {
stats.appendChild(header('Season Specials'));

if (specDisp) {
var createSpecDisp = function(theSpecDisp) {
var frag = document.createDocumentFragment();
frag.appendChild(document.createTextNode(theSpecDisp.length + ' '));
span = document.createElement('span');
span.onmouseout = function() { Game.tooltip.hide(); };
var placeholder = document.createElement('div');
var missing = document.createElement('div');
missing.style.minWidth = '140px';
missing.style.marginBottom = '4px';
var title = document.createElement('div');
title.className = 'name';
title.style.marginBottom = '4px';
title.style.textAlign = 'center';
title.textContent = 'Missing';
missing.appendChild(title);
for (var i in theSpecDisp) {
var div = document.createElement('div');
div.style.textAlign = 'center';
div.appendChild(document.createTextNode(theSpecDisp[i]));
missing.appendChild(div);
}
placeholder.appendChild(missing);
span.onmouseover = function() {Game.tooltip.draw(this, escape(placeholder.innerHTML));};
span.style.cursor = 'default';
span.style.display = 'inline-block';
span.style.height = '10px';
span.style.width = '10px';
span.style.borderRadius = '5px';
span.style.textAlign = 'center';
span.style.backgroundColor = '#C0C0C0';
span.style.color = 'black';
span.style.fontSize = '9px';
span.style.verticalAlign = 'bottom';
span.textContent = '?';
frag.appendChild(span);
return frag;
}
if (halloCook.length != 0) stats.appendChild(listing('Halloween Cookies Left to Buy', createSpecDisp(halloCook)));
if (christCook.length != 0) stats.appendChild(listing('Christmas Cookies Left to Buy', createSpecDisp(christCook)));
if (valCook.length != 0) stats.appendChild(listing('Valentine Cookies Left to Buy', createSpecDisp(valCook)));
if (normEggs.length != 0) stats.appendChild(listing('Normal Easter Eggs Left to Unlock', createSpecDisp(normEggs)));
if (rareEggs.length != 0) stats.appendChild(listing('Rare Easter Eggs Left to Unlock', createSpecDisp(rareEggs)));
}

if (Game.season == 'christmas') stats.appendChild(listing('Reindeer Reward', document.createTextNode(Beautify(CM.Cache.SeaSpec))));
}

l('menu').insertBefore(stats, l('menu').childNodes[2]);
Expand Down
49 changes: 34 additions & 15 deletions src/Cache.js
Original file line number Diff line number Diff line change
Expand Up @@ -63,31 +63,48 @@ CM.Cache.RemakeLucky = function() {
CM.Cache.LuckyRewardFrenzy = (CM.Cache.LuckyFrenzy * 0.1) + 13;
}

CM.Cache.RemakeChain = function() {
CM.Cache.Chain = Game.cookiesPs * 60 * 60 * 3 / 0.25;

var digit = 7;
CM.Cache.MaxChainMoni = function(digit, maxPayout) {
var chain = 1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10);
var maxPayout = Game.cookiesPs * 60 * 60 * 3;
var moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit), maxPayout));
var nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit), maxPayout));
while (nextMoni < maxPayout) {
chain++;
moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit), maxPayout));
nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit), maxPayout));
}
CM.Cache.ChainReward = moni;
return moni;
}

CM.Cache.RemakeChain = function() {
var maxPayout = Game.cookiesPs * 60 * 60 * 3;
if (Game.frenzy > 0) {
maxPayout /= Game.frenzyPower;
}

digit = 6;
chain = 1 + Math.max(0, Math.ceil(Math.log(Game.cookies) / Math.LN10) - 10);
moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit), maxPayout));
nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit), maxPayout));
while (nextMoni < maxPayout) {
chain++;
moni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain) * digit), maxPayout));
nextMoni = Math.max(digit, Math.min(Math.floor(1 / 9 * Math.pow(10, chain + 1) * digit), maxPayout));
CM.Cache.ChainReward = CM.Cache.MaxChainMoni(7, maxPayout);

CM.Cache.ChainWrathReward = CM.Cache.MaxChainMoni(6, maxPayout);

var base = 0;
if (CM.Cache.ChainReward > CM.Cache.ChainWrathReward) {
base = CM.Cache.ChainReward;
}
else {
base = CM.Cache.ChainWrathReward;
}
var count = 1;
while (base == base + count) {
count++;
}
CM.Cache.Chain = (base + count) / 0.25;

CM.Cache.ChainFrenzyReward = CM.Cache.MaxChainMoni(7, maxPayout * 7);

count = 1;
while(CM.Cache.ChainFrenzyReward == CM.Cache.ChainFrenzyReward + count) {
count++;
}
CM.Cache.ChainWrathReward = moni;
CM.Cache.ChainFrenzy = (CM.Cache.ChainFrenzyReward + count) / 0.25;
}

CM.Cache.RemakeSeaSpec = function() {
Expand All @@ -105,3 +122,5 @@ CM.Cache.SeaSpec = 0;
CM.Cache.Chain = 0;
CM.Cache.ChainReward = 0;
CM.Cache.ChainWrathReward = 0;
CM.Cache.ChainFrenzy = 0;
CM.Cache.ChainFrenzyReward = 0;
Loading

0 comments on commit 93f8791

Please sign in to comment.