Civilopedia quickie: Units show other direction of upgrade path (#5209)

* Civilopedia quickie: Units show other direction of upgrade path

* Civilopedia quickie: Units show other direction of upgrade path - spacing
This commit is contained in:
SomeTroglodyte 2021-09-14 23:34:20 +02:00 committed by GitHub
parent fe60c100fa
commit 86bbf54cc0
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 20 additions and 0 deletions

View File

@ -953,6 +953,8 @@ Tutorials =
Cost =
May contain [listOfResources] =
May contain: =
Can upgrade from [unit] =
Can upgrade from: =
Upgrades to [upgradedUnit] =
Obsolete with [obsoleteTech] =
Occurs on [listOfTerrains] =

View File

@ -154,6 +154,24 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText {
if (requiredTech != null || upgradesTo != null || obsoleteTech != null) textList += FormattedLine()
if (requiredTech != null) textList += FormattedLine("Required tech: [$requiredTech]", link="Technology/$requiredTech")
val canUpgradeFrom = ruleset.units
.filterValues {
(it.upgradesTo == name || it.upgradesTo != null && it.upgradesTo == replaces)
&& (it.uniqueTo == uniqueTo || it.uniqueTo == null)
}.keys
if (canUpgradeFrom.isNotEmpty()) {
if (canUpgradeFrom.size == 1)
textList += FormattedLine("Can upgrade from [${canUpgradeFrom.first()}]", link = "Unit/${canUpgradeFrom.first()}")
else {
textList += FormattedLine()
textList += FormattedLine("Can upgrade from:")
for (unitName in canUpgradeFrom.sorted())
textList += FormattedLine(unitName, indent = 2, link = "Unit/$unitName")
textList += FormattedLine()
}
}
if (upgradesTo != null) textList += FormattedLine("Upgrades to [$upgradesTo]", link="Unit/$upgradesTo")
if (obsoleteTech != null) textList += FormattedLine("Obsolete with [$obsoleteTech]", link="Technology/$obsoleteTech")