Fix energy consumption upgrade not showing its value

This commit is contained in:
DBotThePony 2023-07-05 18:02:51 +07:00
parent 5d69275fd4
commit a8904bf570
Signed by: DBot
GPG Key ID: DCC23B5715498507

View File

@ -75,6 +75,9 @@ interface IMatteryUpgrade {
companion object : IMatteryUpgrade
}
private val positiveBound = Decimal("0.01")
private val negativeBound = Decimal("-0.01")
fun IMatteryUpgrade.addUpgradeTooltipLines(tooltips: MutableCollection<Component>) {
if (upgradeTypes.isNotEmpty() && ShiftPressedCond.asBoolean) {
tooltips.add(TranslatableComponent("otm.gui.upgrade_type.list").withStyle(ChatFormatting.GRAY))
@ -104,9 +107,9 @@ fun IMatteryUpgrade.addUpgradeTooltipLines(tooltips: MutableCollection<Component
tooltips.add(TranslatableComponent("otm.gui.upgrade.energy_storage", TextComponent((energyStorage * 100).toString(0)).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY))
}
if (energyConsumed > Decimal.ONE) {
if (energyConsumed >= positiveBound) {
tooltips.add(TranslatableComponent("otm.gui.upgrade.energy_consumed", TextComponent("+" + (energyConsumed.coerceIn(MachinesConfig.Upgrades.MIN_ENERGY, MachinesConfig.Upgrades.MAX_ENERGY) * 100).toString(0)).withStyle(ChatFormatting.DARK_RED)).withStyle(ChatFormatting.GRAY))
} else if (energyConsumed < Decimal.MINUS_ONE) {
} else if (energyConsumed <= negativeBound) {
tooltips.add(TranslatableComponent("otm.gui.upgrade.energy_consumed", TextComponent((energyConsumed.coerceIn(MachinesConfig.Upgrades.MIN_ENERGY, MachinesConfig.Upgrades.MAX_ENERGY) * 100).toString(0)).withStyle(ChatFormatting.DARK_GREEN)).withStyle(ChatFormatting.GRAY))
}