Merge pull request #616 from DanielNoord/hotfixes

Hotfixes to dev branch
This commit is contained in:
Daniël van Noord
2021-02-24 18:24:51 +01:00
committed by GitHub
4 changed files with 101 additions and 86 deletions

File diff suppressed because one or more lines are too long

View File

@@ -1,6 +1,6 @@
{ {
"name": "cookiemonster-mod", "name": "cookiemonster-mod",
"version": "2.031.5", "version": "2.031.4",
"description": "Cookie Monster is an add-on that you can load into Cookie Clicker which offers a wide range of tools and statistics to enhance the game. It is not a cheat interface although it does offer helpers for golden cookies and such, everything can be toggled off at will to only leave how much information you want. This is a helper and everything is an option.", "description": "Cookie Monster is an add-on that you can load into Cookie Clicker which offers a wide range of tools and statistics to enhance the game. It is not a cheat interface although it does offer helpers for golden cookies and such, everything can be toggled off at will to only leave how much information you want. This is a helper and everything is an option.",
"main": "CookieMonster.js", "main": "CookieMonster.js",
"keywords": [ "keywords": [
@@ -11,7 +11,8 @@
"Orteil" "Orteil"
], ],
"scripts": { "scripts": {
"build": "npx eslint src && terser ./src/Header.js ./src/Cache.js ./src/Config.js ./src/Data.js ./src/Disp.js ./src/Main.js ./src/Sim.js ./src/Footer.js -o CookieMonster.js" "build": "npx eslint src && terser ./src/Header.js ./src/Cache.js ./src/Config.js ./src/Data.js ./src/Disp.js ./src/Main.js ./src/Sim.js ./src/Footer.js -o CookieMonster.js",
"build-test": "terser ./src/Header.js ./src/Cache.js ./src/Config.js ./src/Data.js ./src/Disp.js ./src/Main.js ./src/Sim.js ./src/Footer.js -o CookieMonster.js"
}, },
"repository": { "repository": {
"type": "git", "type": "git",

View File

@@ -160,7 +160,11 @@ CM.Disp.GetTimeColor = function (time) {
*/ */
CM.Disp.Beautify = function (num, floats, forced) { CM.Disp.Beautify = function (num, floats, forced) {
const decimals = CM.Options.ScaleDecimals + 1; const decimals = CM.Options.ScaleDecimals + 1;
if (CM.Options.Scale === 0) { if (num === Infinity) {
return 'Infinity';
} else if (typeof num === 'undefined') {
return '0';
} else if (CM.Options.Scale === 0) {
return CM.Backup.Beautify(num, floats); return CM.Backup.Beautify(num, floats);
} else if (Number.isFinite(num)) { } else if (Number.isFinite(num)) {
let answer = ''; let answer = '';
@@ -202,10 +206,6 @@ CM.Disp.Beautify = function (num, floats, forced) {
} }
if (CM.Options.ScaleSeparator) answer = answer.replace('.', ','); if (CM.Options.ScaleSeparator) answer = answer.replace('.', ',');
return answer; return answer;
} else if (num === Infinity) {
return 'Infinity';
} else if (typeof num === 'undefined') {
return 0;
} else { } else {
console.log(`Could not beautify number with CM.Disp.Beautify: ${num}`); console.log(`Could not beautify number with CM.Disp.Beautify: ${num}`);
return CM.Backup.Beautify(num, floats); return CM.Backup.Beautify(num, floats);
@@ -791,7 +791,7 @@ CM.Disp.UpdateUpgrades = function () {
} }
if (CM.Options.SortUpgrades) { if (CM.Options.SortUpgrades) {
arr.sort((a, b) => CM.Disp.colors.indexOf(a.color) - CM.Disp.colors.indexOf(b.color)); arr.sort(function (a, b) { return (CM.Disp.colors.indexOf(a.color) > CM.Disp.colors.indexOf(b.color) ? 1 : (CM.Disp.colors.indexOf(a.color) < CM.Disp.colors.indexOf(b.color) ? -1 : (a.pp < b.pp) ? -1 : 0)); });
} else { } else {
arr.sort((a, b) => a.price - b.price); arr.sort((a, b) => a.price - b.price);
} }
@@ -1244,6 +1244,7 @@ CM.Disp.TooltipCreateTooltipBox = function () {
CM.Disp.TooltipCreateHeader = function (text) { CM.Disp.TooltipCreateHeader = function (text) {
const div = document.createElement('div'); const div = document.createElement('div');
div.style.fontWeight = 'bold'; div.style.fontWeight = 'bold';
div.id = `${text}Title`;
div.className = CM.Disp.colorTextPre + CM.Disp.colorBlue; div.className = CM.Disp.colorTextPre + CM.Disp.colorBlue;
div.textContent = text; div.textContent = text;
return div; return div;
@@ -1338,10 +1339,8 @@ CM.Disp.TooltipCreateWarningSection = function () {
CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnConjure', CM.Disp.colorPurple, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Conjure Baked Goods"', 'CMDispTooltipWarnConjureText')); CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnConjure', CM.Disp.colorPurple, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Conjure Baked Goods"', 'CMDispTooltipWarnConjureText'));
CM.Disp.TooltipWarn.lastChild.style.marginBottom = '4px'; CM.Disp.TooltipWarn.lastChild.style.marginBottom = '4px';
CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnConjureFrenzy', CM.Disp.colorPurple, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Conjure Baked Goods" (Frenzy)', 'CMDispTooltipWarnConjureFrenzyText')); CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnConjureFrenzy', CM.Disp.colorPurple, 'Warning: ', 'Purchase of this item will put you under the number of Cookies required for "Conjure Baked Goods" (Frenzy)', 'CMDispTooltipWarnConjureFrenzyText'));
if (Game.Objects['Wizard tower'].minigameLoaded) {
CM.Disp.TooltipWarn.lastChild.style.marginBottom = '4px'; CM.Disp.TooltipWarn.lastChild.style.marginBottom = '4px';
CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnEdifice', CM.Disp.colorPurple, 'Warning: ', 'Purchase of this item will put you under the number of Cookies needed for "Spontaneous Edifice" to possibly give you your most expensive building"', 'CMDispTooltipWarnEdificeText')); CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnEdifice', CM.Disp.colorPurple, 'Warning: ', 'Purchase of this item will put you under the number of Cookies needed for "Spontaneous Edifice" to possibly give you your most expensive building"', 'CMDispTooltipWarnEdificeText'));
}
CM.Disp.TooltipWarn.lastChild.style.marginBottom = '4px'; CM.Disp.TooltipWarn.lastChild.style.marginBottom = '4px';
CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnUser', CM.Disp.colorRed, 'Warning: ', `Purchase of this item will put you under the number of Cookies equal to ${CM.Options.ToolWarnUser} seconds of CPS`, 'CMDispTooltipWarnUserText')); CM.Disp.TooltipWarn.appendChild(create('CMDispTooltipWarnUser', CM.Disp.colorRed, 'Warning: ', `Purchase of this item will put you under the number of Cookies equal to ${CM.Options.ToolWarnUser} seconds of CPS`, 'CMDispTooltipWarnUserText'));
@@ -1443,6 +1442,13 @@ CM.Disp.UpdateTooltipUpgrade = function () {
if (CM.Options.TooltipBuildUpgrade === 1) { if (CM.Options.TooltipBuildUpgrade === 1) {
l('CMTooltipIncome').textContent = Beautify(CM.Disp.TooltipBonusIncome, 2); l('CMTooltipIncome').textContent = Beautify(CM.Disp.TooltipBonusIncome, 2);
const increase = Math.round(CM.Disp.TooltipBonusIncome / Game.cookiesPs * 10000); const increase = Math.round(CM.Disp.TooltipBonusIncome / Game.cookiesPs * 10000);
// Don't display certain parts of tooltip if not applicable
if (l('CMTooltipIncome').textContent === '0') {
l('Bonus IncomeTitle').style.display = 'none';
l('CMTooltipIncome').style.display = 'none';
l('Payback PeriodTitle').style.display = 'none';
l('CMTooltipPP').style.display = 'none';
} else {
if (Number.isFinite(increase) && increase !== 0) { if (Number.isFinite(increase) && increase !== 0) {
l('CMTooltipIncome').textContent += ` (${increase / 100}% of income)`; l('CMTooltipIncome').textContent += ` (${increase / 100}% of income)`;
} }
@@ -1461,6 +1467,7 @@ CM.Disp.UpdateTooltipUpgrade = function () {
l('CMTooltipPP').textContent = Beautify(CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].pp, 2); l('CMTooltipPP').textContent = Beautify(CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].pp, 2);
l('CMTooltipPP').className = CM.Disp.colorTextPre + CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].color; l('CMTooltipPP').className = CM.Disp.colorTextPre + CM.Cache.Upgrades[Game.UpgradesInStore[CM.Disp.tooltipName].name].color;
} }
}
const timeColor = CM.Disp.GetTimeColor((CM.Disp.TooltipPrice - (Game.cookies + CM.Disp.GetWrinkConfigBank())) / CM.Disp.GetCPS()); const timeColor = CM.Disp.GetTimeColor((CM.Disp.TooltipPrice - (Game.cookies + CM.Disp.GetWrinkConfigBank())) / CM.Disp.GetCPS());
l('CMTooltipTime').textContent = timeColor.text; l('CMTooltipTime').textContent = timeColor.text;
if (timeColor.text === 'Done!' && Game.cookies < Game.UpgradesInStore[CM.Disp.tooltipName].getPrice()) { if (timeColor.text === 'Done!' && Game.cookies < Game.UpgradesInStore[CM.Disp.tooltipName].getPrice()) {
@@ -1637,6 +1644,7 @@ CM.Disp.UpdateTooltipWarnings = function () {
CM.Disp.TooltipWarn.style.width = `${l('tooltip').offsetWidth - 6}px`; CM.Disp.TooltipWarn.style.width = `${l('tooltip').offsetWidth - 6}px`;
const amount = (Game.cookies + CM.Disp.GetWrinkConfigBank()) - CM.Disp.TooltipPrice; const amount = (Game.cookies + CM.Disp.GetWrinkConfigBank()) - CM.Disp.TooltipPrice;
const bonusIncomeUsed = CM.Options.ToolWarnBon ? CM.Disp.TooltipBonusIncome : 0;
let limitLucky = CM.Cache.Lucky; let limitLucky = CM.Cache.Lucky;
if (CM.Options.ToolWarnBon === 1) { if (CM.Options.ToolWarnBon === 1) {
let bonusNoFren = CM.Disp.TooltipBonusIncome; let bonusNoFren = CM.Disp.TooltipBonusIncome;
@@ -1647,7 +1655,7 @@ CM.Disp.UpdateTooltipWarnings = function () {
if (CM.Options.ToolWarnLucky === 1) { if (CM.Options.ToolWarnLucky === 1) {
if (amount < limitLucky && (CM.Disp.tooltipType !== 'b' || Game.buyMode === 1)) { if (amount < limitLucky && (CM.Disp.tooltipType !== 'b' || Game.buyMode === 1)) {
l('CMDispTooltipWarnLucky').style.display = ''; l('CMDispTooltipWarnLucky').style.display = '';
l('CMDispTooltipWarnLuckyText').textContent = `${Beautify(limitLucky - amount)} (${CM.Disp.FormatTime((limitLucky - amount) / (CM.Disp.GetCPS() + CM.Disp.TooltipBonusIncome))})`; l('CMDispTooltipWarnLuckyText').textContent = `${Beautify(limitLucky - amount)} (${CM.Disp.FormatTime((limitLucky - amount) / (CM.Disp.GetCPS() + bonusIncomeUsed))})`;
} else l('CMDispTooltipWarnLucky').style.display = 'none'; } else l('CMDispTooltipWarnLucky').style.display = 'none';
} else l('CMDispTooltipWarnLucky').style.display = 'none'; } else l('CMDispTooltipWarnLucky').style.display = 'none';
@@ -1655,7 +1663,7 @@ CM.Disp.UpdateTooltipWarnings = function () {
const limitLuckyFrenzy = limitLucky * 7; const limitLuckyFrenzy = limitLucky * 7;
if (amount < limitLuckyFrenzy && (CM.Disp.tooltipType !== 'b' || Game.buyMode === 1)) { if (amount < limitLuckyFrenzy && (CM.Disp.tooltipType !== 'b' || Game.buyMode === 1)) {
l('CMDispTooltipWarnLuckyFrenzy').style.display = ''; l('CMDispTooltipWarnLuckyFrenzy').style.display = '';
l('CMDispTooltipWarnLuckyFrenzyText').textContent = `${Beautify(limitLuckyFrenzy - amount)} (${CM.Disp.FormatTime((limitLuckyFrenzy - amount) / (CM.Disp.GetCPS() + CM.Disp.TooltipBonusIncome))})`; l('CMDispTooltipWarnLuckyFrenzyText').textContent = `${Beautify(limitLuckyFrenzy - amount)} (${CM.Disp.FormatTime((limitLuckyFrenzy - amount) / (CM.Disp.GetCPS() + bonusIncomeUsed))})`;
} else l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; } else l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none';
} else l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none'; } else l('CMDispTooltipWarnLuckyFrenzy').style.display = 'none';
@@ -1663,7 +1671,7 @@ CM.Disp.UpdateTooltipWarnings = function () {
const limitConjure = limitLucky * 2; const limitConjure = limitLucky * 2;
if ((amount < limitConjure) && (CM.Disp.tooltipType !== 'b' || Game.buyMode === 1)) { if ((amount < limitConjure) && (CM.Disp.tooltipType !== 'b' || Game.buyMode === 1)) {
l('CMDispTooltipWarnConjure').style.display = ''; l('CMDispTooltipWarnConjure').style.display = '';
l('CMDispTooltipWarnConjureText').textContent = `${Beautify(limitConjure - amount)} (${CM.Disp.FormatTime((limitConjure - amount) / (CM.Disp.GetCPS() + CM.Disp.TooltipBonusIncome))})`; l('CMDispTooltipWarnConjureText').textContent = `${Beautify(limitConjure - amount)} (${CM.Disp.FormatTime((limitConjure - amount) / (CM.Disp.GetCPS() + bonusIncomeUsed))})`;
} else l('CMDispTooltipWarnConjure').style.display = 'none'; } else l('CMDispTooltipWarnConjure').style.display = 'none';
} else l('CMDispTooltipWarnConjure').style.display = 'none'; } else l('CMDispTooltipWarnConjure').style.display = 'none';
@@ -1671,14 +1679,14 @@ CM.Disp.UpdateTooltipWarnings = function () {
const limitConjureFrenzy = limitLucky * 2 * 7; const limitConjureFrenzy = limitLucky * 2 * 7;
if ((amount < limitConjureFrenzy) && (CM.Disp.tooltipType !== 'b' || Game.buyMode === 1)) { if ((amount < limitConjureFrenzy) && (CM.Disp.tooltipType !== 'b' || Game.buyMode === 1)) {
l('CMDispTooltipWarnConjureFrenzy').style.display = ''; l('CMDispTooltipWarnConjureFrenzy').style.display = '';
l('CMDispTooltipWarnConjureFrenzyText').textContent = `${Beautify(limitConjureFrenzy - amount)} (${CM.Disp.FormatTime((limitConjureFrenzy - amount) / (CM.Disp.GetCPS() + CM.Disp.TooltipBonusIncome))})`; l('CMDispTooltipWarnConjureFrenzyText').textContent = `${Beautify(limitConjureFrenzy - amount)} (${CM.Disp.FormatTime((limitConjureFrenzy - amount) / (CM.Disp.GetCPS() + bonusIncomeUsed))})`;
} else l('CMDispTooltipWarnConjureFrenzy').style.display = 'none'; } else l('CMDispTooltipWarnConjureFrenzy').style.display = 'none';
} else l('CMDispTooltipWarnConjureFrenzy').style.display = 'none'; } else l('CMDispTooltipWarnConjureFrenzy').style.display = 'none';
if (CM.Options.ToolWarnEdifice === 1) { if (CM.Options.ToolWarnEdifice === 1 && Game.Objects['Wizard tower'].minigameLoaded) {
if (CM.Cache.Edifice && amount < CM.Cache.Edifice && (CM.Disp.tooltipType !== 'b' || Game.buyMode === 1)) { if (CM.Cache.Edifice && amount < CM.Cache.Edifice && (CM.Disp.tooltipType !== 'b' || Game.buyMode === 1)) {
l('CMDispTooltipWarnEdifice').style.display = ''; l('CMDispTooltipWarnEdifice').style.display = '';
l('CMDispTooltipWarnEdificeText').textContent = `${Beautify(CM.Cache.Edifice - amount)} (${CM.Disp.FormatTime((CM.Cache.Edifice - amount) / (CM.Disp.GetCPS() + CM.Disp.TooltipBonusIncome))})`; l('CMDispTooltipWarnEdificeText').textContent = `${Beautify(CM.Cache.Edifice - amount)} (${CM.Disp.FormatTime((CM.Cache.Edifice - amount) / (CM.Disp.GetCPS() + bonusIncomeUsed))})`;
} else l('CMDispTooltipWarnEdifice').style.display = 'none'; } else l('CMDispTooltipWarnEdifice').style.display = 'none';
} else l('CMDispTooltipWarnEdifice').style.display = 'none'; } else l('CMDispTooltipWarnEdifice').style.display = 'none';
@@ -1687,7 +1695,7 @@ CM.Disp.UpdateTooltipWarnings = function () {
l('CMDispTooltipWarnUser').style.display = ''; l('CMDispTooltipWarnUser').style.display = '';
// Need to update tooltip text dynamically // Need to update tooltip text dynamically
l('CMDispTooltipWarnUser').children[0].textContent = `Purchase of this item will put you under the number of Cookies equal to ${CM.Options.ToolWarnUser} seconds of CPS`; l('CMDispTooltipWarnUser').children[0].textContent = `Purchase of this item will put you under the number of Cookies equal to ${CM.Options.ToolWarnUser} seconds of CPS`;
l('CMDispTooltipWarnUserText').textContent = `${Beautify(CM.Options.ToolWarnUser * CM.Disp.GetCPS() - amount)} (${CM.Disp.FormatTime((CM.Options.ToolWarnUser * CM.Disp.GetCPS() - amount) / (CM.Disp.GetCPS() + CM.Disp.TooltipBonusIncome))})`; l('CMDispTooltipWarnUserText').textContent = `${Beautify(CM.Options.ToolWarnUser * CM.Disp.GetCPS() - amount)} (${CM.Disp.FormatTime((CM.Options.ToolWarnUser * CM.Disp.GetCPS() - amount) / (CM.Disp.GetCPS() + bonusIncomeUsed))})`;
} else l('CMDispTooltipWarnUser').style.display = 'none'; } else l('CMDispTooltipWarnUser').style.display = 'none';
} else l('CMDispTooltipWarnUser').style.display = 'none'; } else l('CMDispTooltipWarnUser').style.display = 'none';
} else if (l('CMDispTooltipWarningParent') !== null) { } else if (l('CMDispTooltipWarningParent') !== null) {

View File

@@ -688,7 +688,13 @@ CM.Sim.BuyUpgradesBonusIncome = function (upgrade) {
if (Game.Upgrades[upgrade].pool === 'toggle' || (Game.Upgrades[upgrade].bought === 0 && Game.Upgrades[upgrade].unlocked && Game.Upgrades[upgrade].pool !== 'prestige')) { if (Game.Upgrades[upgrade].pool === 'toggle' || (Game.Upgrades[upgrade].bought === 0 && Game.Upgrades[upgrade].unlocked && Game.Upgrades[upgrade].pool !== 'prestige')) {
CM.Sim.CopyData(); CM.Sim.CopyData();
const me = CM.Sim.Upgrades[upgrade]; const me = CM.Sim.Upgrades[upgrade];
me.bought = 1; if (me.name === 'Shimmering veil [on]') {
CM.Sim.Upgrades['Shimmering veil [off]'].bought = 0;
} else if (me.name === 'Golden switch [on]') {
CM.Sim.Upgrades['Golden switch [off]'].bought = 0;
} else {
me.bought = (me.bought + 1) % 2;
}
if (Game.CountsAsUpgradeOwned(Game.Upgrades[upgrade].pool)) CM.Sim.UpgradesOwned++; if (Game.CountsAsUpgradeOwned(Game.Upgrades[upgrade].pool)) CM.Sim.UpgradesOwned++;
if (upgrade === 'Elder Pledge') { if (upgrade === 'Elder Pledge') {