Improved building tooltip #766
This commit is contained in:
@@ -15,6 +15,7 @@ import {
|
||||
CacheGoldenAndWrathCookiesMults,
|
||||
CacheStatsCookies,
|
||||
} from './Stats/Stats';
|
||||
import AllAmountTillNextAchievement from './TillNextAchievement/AllAmountTillNextAchievement';
|
||||
import {
|
||||
CacheAverageCookiesFromClicks,
|
||||
HeavenlyChipsDiff,
|
||||
@@ -39,6 +40,7 @@ export default function InitCache() {
|
||||
ClickTimes[ClickTimes.length - 1] * 20,
|
||||
);
|
||||
CacheHeavenlyChipsPS();
|
||||
AllAmountTillNextAchievement();
|
||||
CacheAvgCPS();
|
||||
CacheIncome();
|
||||
CacheBuildingsPrices();
|
||||
|
||||
@@ -12,6 +12,7 @@ import {
|
||||
CacheObjects1,
|
||||
CacheObjects10,
|
||||
CacheObjects100,
|
||||
CacheObjectsNextAchievement,
|
||||
CacheUpgrades,
|
||||
} from '../VariablesAndData';
|
||||
|
||||
@@ -82,6 +83,13 @@ export function CacheBuildingsPrices() {
|
||||
Game.Objects[i].free,
|
||||
100,
|
||||
);
|
||||
CacheObjectsNextAchievement[i].price = BuildingGetPrice(
|
||||
Game.Objects[i],
|
||||
Game.Objects[i].basePrice,
|
||||
Game.Objects[i].amount,
|
||||
Game.Objects[i].free,
|
||||
CacheObjectsNextAchievement[i].AmountNeeded,
|
||||
);
|
||||
});
|
||||
}
|
||||
|
||||
|
||||
@@ -192,7 +192,7 @@ export function TooltipCreateCalculationSection(tooltip) {
|
||||
}
|
||||
if (TooltipType === 'b') {
|
||||
tooltip.appendChild(
|
||||
TooltipCreateHeader('Buildings left till next additional achievement'),
|
||||
TooltipCreateHeader('Buildings (price / PP) left till next achievement'),
|
||||
);
|
||||
tooltip.lastChild.id = 'CMTooltipNextAchievementHeader'; // eslint-disable-line no-param-reassign
|
||||
const production = document.createElement('div');
|
||||
|
||||
@@ -1,3 +1,4 @@
|
||||
import ColourOfPP from '../../../Cache/PP/ColourOfPP';
|
||||
import {
|
||||
CacheObjects1,
|
||||
CacheObjects10,
|
||||
@@ -5,6 +6,7 @@ import {
|
||||
CacheObjectsNextAchievement,
|
||||
} from '../../../Cache/VariablesAndData';
|
||||
import { CMOptions } from '../../../Config/VariablesAndData';
|
||||
import BuyBuildingsBonusIncome from '../../../Sim/SimulationEvents/BuyBuildingBonusIncome';
|
||||
import { SimObjects } from '../../../Sim/VariablesAndData';
|
||||
import {
|
||||
Beautify,
|
||||
@@ -101,13 +103,36 @@ export default function Building() {
|
||||
}
|
||||
}
|
||||
|
||||
if (CacheObjectsNextAchievement[TooltipName].AmountNeeded < 101) {
|
||||
const ObjectsTillNext = CacheObjectsNextAchievement[TooltipName];
|
||||
if (ObjectsTillNext.AmountNeeded < 101) {
|
||||
l('CMTooltipProductionLeft').style.marginBottom = '4px';
|
||||
l('CMTooltipNextAchievementHeader').style.display = '';
|
||||
l('CMTooltipNextAchievement').textContent = Beautify(
|
||||
CacheObjectsNextAchievement[TooltipName].AmountNeeded,
|
||||
);
|
||||
|
||||
let PPOfAmount;
|
||||
if (Game.cookiesPs) {
|
||||
PPOfAmount =
|
||||
Math.max(
|
||||
ObjectsTillNext.price - (Game.cookies + GetWrinkConfigBank()),
|
||||
0,
|
||||
) /
|
||||
Game.cookiesPs +
|
||||
ObjectsTillNext.price /
|
||||
BuyBuildingsBonusIncome(TooltipName, ObjectsTillNext.AmountNeeded);
|
||||
} else
|
||||
PPOfAmount =
|
||||
ObjectsTillNext.price /
|
||||
BuyBuildingsBonusIncome(TooltipName, ObjectsTillNext.AmountNeeded);
|
||||
|
||||
l('CMTooltipNextAchievement').textContent = `${Beautify(
|
||||
ObjectsTillNext.AmountNeeded,
|
||||
)} / ${Beautify(ObjectsTillNext.price)} / `;
|
||||
l('CMTooltipNextAchievement').style.color = 'white';
|
||||
const PPFrag = document.createElement('span');
|
||||
if (CMOptions.PPDisplayTime) PPFrag.textContent = FormatTime(PPOfAmount);
|
||||
else PPFrag.textContent = Beautify(PPOfAmount);
|
||||
PPFrag.className =
|
||||
ColourTextPre + ColourOfPP({ pp: PPOfAmount }, ObjectsTillNext.price);
|
||||
l('CMTooltipNextAchievement').appendChild(PPFrag);
|
||||
} else {
|
||||
l('CMTooltipNextAchievementHeader').style.display = 'none';
|
||||
l('CMTooltipProductionLeft').style.marginBottom = '0px';
|
||||
|
||||
Reference in New Issue
Block a user