Fixed Disp.Beautify and tooltips of upgrades #608
This commit is contained in:
File diff suppressed because one or more lines are too long
19
src/Disp.js
19
src/Disp.js
@@ -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);
|
||||||
@@ -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;
|
||||||
@@ -1443,6 +1444,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 +1469,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()) {
|
||||||
|
|||||||
@@ -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') {
|
||||||
|
|||||||
Reference in New Issue
Block a user