Show buildings left till achievement in tooltip #4

This commit is contained in:
Daniël van Noord
2021-04-09 15:53:33 +02:00
parent d99837df61
commit 3e3945461d
9 changed files with 77 additions and 12 deletions

View File

@@ -185,10 +185,18 @@ export function TooltipCreateCalculationSection(tooltip) {
tooltip.appendChild(
TooltipCreateHeader('Production left till next achievement'),
);
// Assign a id in order to hide when no achiev's are left
tooltip.lastChild.id = 'CMTooltipProductionHeader'; // eslint-disable-line no-param-reassign
tooltip.lastChild.id = 'CMTooltipProductionLeftHeader'; // eslint-disable-line no-param-reassign
const production = document.createElement('div');
production.id = 'CMTooltipProduction';
production.id = 'CMTooltipProductionLeft';
tooltip.appendChild(production);
}
if (TooltipType === 'b') {
tooltip.appendChild(
TooltipCreateHeader('Buildings left till next additional achievement'),
);
tooltip.lastChild.id = 'CMTooltipNextAchievementHeader'; // eslint-disable-line no-param-reassign
const production = document.createElement('div');
production.id = 'CMTooltipNextAchievement';
tooltip.appendChild(production);
}
}

View File

@@ -2,6 +2,7 @@ import {
CacheObjects1,
CacheObjects10,
CacheObjects100,
CacheObjectsNextAchievement,
} from '../../../Cache/VariablesAndData';
import { CMOptions } from '../../../Config/VariablesAndData';
import { SimObjects } from '../../../Sim/VariablesAndData';
@@ -74,10 +75,9 @@ export default function Building() {
}
// Add "production left till next achievement"-bar
l('CMTooltipProductionHeader').style.display = 'none';
l('CMTooltipProductionLeftHeader').style.display = 'none';
l('CMTooltipTime').style.marginBottom = '0px';
// Can this ESLint error be solved while retaining the functionality of break?
// eslint-disable-next-line no-restricted-syntax
for (const i of Object.keys(Game.Objects[TooltipName].productionAchievs)) {
if (
@@ -88,15 +88,29 @@ export default function Building() {
const nextProductionAchiev =
Game.Objects[TooltipName].productionAchievs[i];
l('CMTooltipTime').style.marginBottom = '4px';
l('CMTooltipProductionHeader').style.display = '';
l('CMTooltipProduction').className = `ProdAchievement${TooltipName}`;
l('CMTooltipProduction').textContent = Beautify(
l('CMTooltipProductionLeftHeader').style.display = '';
l(
'CMTooltipProductionLeft',
).className = `ProdAchievement${TooltipName}`;
l('CMTooltipProductionLeft').textContent = Beautify(
nextProductionAchiev.pow - SimObjects[TooltipName].totalCookies,
15,
);
l('CMTooltipProduction').style.color = 'white';
l('CMTooltipProductionLeft').style.color = 'white';
break;
}
}
if (CacheObjectsNextAchievement[TooltipName].AmountNeeded < 101) {
l('CMTooltipProductionLeft').style.marginBottom = '4px';
l('CMTooltipNextAchievementHeader').style.display = '';
l('CMTooltipNextAchievement').textContent = Beautify(
CacheObjectsNextAchievement[TooltipName].AmountNeeded,
);
l('CMTooltipNextAchievement').style.color = 'white';
} else {
l('CMTooltipNextAchievementHeader').style.display = 'none';
l('CMTooltipProductionLeft').style.marginBottom = '0px';
}
} else l('CMTooltipArea').style.display = 'none';
}