Fixed Disp.Beautify and tooltips of upgrades #608

This commit is contained in:
Daniël van Noord
2021-02-24 17:56:02 +01:00
parent 3975032f4b
commit 57fb8430a0
3 changed files with 38 additions and 23 deletions

File diff suppressed because one or more lines are too long

View File

@@ -160,7 +160,11 @@ CM.Disp.GetTimeColor = function (time) {
*/
CM.Disp.Beautify = function (num, floats, forced) {
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);
} else if (Number.isFinite(num)) {
let answer = '';
@@ -202,10 +206,6 @@ CM.Disp.Beautify = function (num, floats, forced) {
}
if (CM.Options.ScaleSeparator) answer = answer.replace('.', ',');
return answer;
} else if (num === Infinity) {
return 'Infinity';
} else if (typeof num === 'undefined') {
return 0;
} else {
console.log(`Could not beautify number with CM.Disp.Beautify: ${num}`);
return CM.Backup.Beautify(num, floats);
@@ -1244,6 +1244,7 @@ CM.Disp.TooltipCreateTooltipBox = function () {
CM.Disp.TooltipCreateHeader = function (text) {
const div = document.createElement('div');
div.style.fontWeight = 'bold';
div.id = `${text}Title`;
div.className = CM.Disp.colorTextPre + CM.Disp.colorBlue;
div.textContent = text;
return div;
@@ -1443,6 +1444,13 @@ CM.Disp.UpdateTooltipUpgrade = function () {
if (CM.Options.TooltipBuildUpgrade === 1) {
l('CMTooltipIncome').textContent = Beautify(CM.Disp.TooltipBonusIncome, 2);
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) {
l('CMTooltipIncome').textContent += ` (${increase / 100}% of income)`;
}
@@ -1461,6 +1469,7 @@ CM.Disp.UpdateTooltipUpgrade = function () {
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;
}
}
const timeColor = CM.Disp.GetTimeColor((CM.Disp.TooltipPrice - (Game.cookies + CM.Disp.GetWrinkConfigBank())) / CM.Disp.GetCPS());
l('CMTooltipTime').textContent = timeColor.text;
if (timeColor.text === 'Done!' && Game.cookies < Game.UpgradesInStore[CM.Disp.tooltipName].getPrice()) {

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')) {
CM.Sim.CopyData();
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 (upgrade === 'Elder Pledge') {