mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-21 13:18:56 +07:00
Resolved crash in unit civilopedia lines that depended on unitType being initialized
This commit is contained in:
@ -116,7 +116,7 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText {
|
|||||||
stats += "$rangedStrength${Fonts.rangedStrength}"
|
stats += "$rangedStrength${Fonts.rangedStrength}"
|
||||||
stats += "$range${Fonts.range}"
|
stats += "$range${Fonts.range}"
|
||||||
}
|
}
|
||||||
if (movement != 0 && !movesLikeAirUnits()) stats += "$movement${Fonts.movement}"
|
if (movement != 0 && ruleset.unitTypes[unitType]?.isAirUnit() != true) stats += "$movement${Fonts.movement}"
|
||||||
if (stats.isNotEmpty())
|
if (stats.isNotEmpty())
|
||||||
textList += FormattedLine(stats.joinToString(", "))
|
textList += FormattedLine(stats.joinToString(", "))
|
||||||
|
|
||||||
@ -143,28 +143,39 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText {
|
|||||||
for ((resource, amount) in resourceRequirements) {
|
for ((resource, amount) in resourceRequirements) {
|
||||||
textList += FormattedLine(
|
textList += FormattedLine(
|
||||||
if (amount == 1) "Consumes 1 [$resource]" else "Consumes [$amount] [$resource]",
|
if (amount == 1) "Consumes 1 [$resource]" else "Consumes [$amount] [$resource]",
|
||||||
link="Resource/$resource", color="#F42")
|
link = "Resource/$resource", color = "#F42"
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (uniqueTo != null) {
|
if (uniqueTo != null) {
|
||||||
textList += FormattedLine()
|
textList += FormattedLine()
|
||||||
textList += FormattedLine("Unique to [$uniqueTo]", link="Nation/$uniqueTo")
|
textList += FormattedLine("Unique to [$uniqueTo]", link = "Nation/$uniqueTo")
|
||||||
if (replaces != null)
|
if (replaces != null)
|
||||||
textList += FormattedLine("Replaces [$replaces]", link="Unit/$replaces", indent=1)
|
textList += FormattedLine(
|
||||||
|
"Replaces [$replaces]",
|
||||||
|
link = "Unit/$replaces",
|
||||||
|
indent = 1
|
||||||
|
)
|
||||||
}
|
}
|
||||||
|
|
||||||
if (requiredTech != null || upgradesTo != null || obsoleteTech != null) textList += FormattedLine()
|
if (requiredTech != null || upgradesTo != null || obsoleteTech != null) textList += FormattedLine()
|
||||||
if (requiredTech != null) textList += FormattedLine("Required tech: [$requiredTech]", link="Technology/$requiredTech")
|
if (requiredTech != null) textList += FormattedLine(
|
||||||
|
"Required tech: [$requiredTech]",
|
||||||
|
link = "Technology/$requiredTech"
|
||||||
|
)
|
||||||
|
|
||||||
val canUpgradeFrom = ruleset.units
|
val canUpgradeFrom = ruleset.units
|
||||||
.filterValues {
|
.filterValues {
|
||||||
(it.upgradesTo == name || it.upgradesTo != null && it.upgradesTo == replaces)
|
(it.upgradesTo == name || it.upgradesTo != null && it.upgradesTo == replaces)
|
||||||
&& (it.uniqueTo == uniqueTo || it.uniqueTo == null)
|
&& (it.uniqueTo == uniqueTo || it.uniqueTo == null)
|
||||||
}.keys
|
}.keys
|
||||||
if (canUpgradeFrom.isNotEmpty()) {
|
if (canUpgradeFrom.isNotEmpty()) {
|
||||||
if (canUpgradeFrom.size == 1)
|
if (canUpgradeFrom.size == 1)
|
||||||
textList += FormattedLine("Can upgrade from [${canUpgradeFrom.first()}]", link = "Unit/${canUpgradeFrom.first()}")
|
textList += FormattedLine(
|
||||||
|
"Can upgrade from [${canUpgradeFrom.first()}]",
|
||||||
|
link = "Unit/${canUpgradeFrom.first()}"
|
||||||
|
)
|
||||||
else {
|
else {
|
||||||
textList += FormattedLine()
|
textList += FormattedLine()
|
||||||
textList += FormattedLine("Can upgrade from:")
|
textList += FormattedLine("Can upgrade from:")
|
||||||
@ -174,28 +185,35 @@ class BaseUnit : INamed, INonPerpetualConstruction, ICivilopediaText {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
if (upgradesTo != null) textList += FormattedLine("Upgrades to [$upgradesTo]", link="Unit/$upgradesTo")
|
if (upgradesTo != null) textList += FormattedLine(
|
||||||
if (obsoleteTech != null) textList += FormattedLine("Obsolete with [$obsoleteTech]", link="Technology/$obsoleteTech")
|
"Upgrades to [$upgradesTo]",
|
||||||
|
link = "Unit/$upgradesTo"
|
||||||
|
)
|
||||||
|
if (obsoleteTech != null) textList += FormattedLine(
|
||||||
|
"Obsolete with [$obsoleteTech]",
|
||||||
|
link = "Technology/$obsoleteTech"
|
||||||
|
)
|
||||||
|
|
||||||
if (promotions.isNotEmpty()) {
|
if (promotions.isNotEmpty()) {
|
||||||
textList += FormattedLine()
|
textList += FormattedLine()
|
||||||
promotions.withIndex().forEach {
|
promotions.withIndex().forEach {
|
||||||
textList += FormattedLine(
|
textList += FormattedLine(
|
||||||
when {
|
when {
|
||||||
promotions.size == 1 -> "{Free promotion:} "
|
promotions.size == 1 -> "{Free promotion:} "
|
||||||
it.index == 0 -> "{Free promotions:} "
|
it.index == 0 -> "{Free promotions:} "
|
||||||
else -> ""
|
else -> ""
|
||||||
} + "{${it.value}}" +
|
} + "{${it.value}}" +
|
||||||
(if (promotions.size == 1 || it.index == promotions.size - 1) "" else ","),
|
(if (promotions.size == 1 || it.index == promotions.size - 1) "" else ","),
|
||||||
link="Promotions/${it.value}",
|
link = "Promotions/${it.value}",
|
||||||
indent=if(it.index==0) 0 else 1)
|
indent = if (it.index == 0) 0 else 1
|
||||||
|
)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
val seeAlso = ArrayList<FormattedLine>()
|
val seeAlso = ArrayList<FormattedLine>()
|
||||||
for ((other, unit) in ruleset.units) {
|
for ((other, unit) in ruleset.units) {
|
||||||
if (unit.replaces == name || uniques.contains("[$name]") ) {
|
if (unit.replaces == name || uniques.contains("[$name]")) {
|
||||||
seeAlso += FormattedLine(other, link="Unit/$other", indent=1)
|
seeAlso += FormattedLine(other, link = "Unit/$other", indent = 1)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
if (seeAlso.isNotEmpty()) {
|
if (seeAlso.isNotEmpty()) {
|
||||||
|
Reference in New Issue
Block a user