Linked Unit Types and Promotions in Civilopedia

This commit is contained in:
Yair Morgenstern 2023-06-19 16:04:35 +03:00
parent e987bbbaad
commit c0e5f9d736
2 changed files with 14 additions and 4 deletions

View File

@ -88,18 +88,21 @@ class Promotion : RulesetObject() {
val types = unitTypes.partition { it in ruleset.units }
if (unitTypes.size == 1) {
if (types.first.isNotEmpty())
types.first.first().let {
textList += FormattedLine("Available for [${it.tr()}]", link = "Unit/$it")
unitTypes.first().let {
textList += FormattedLine("Available for [$it]", link = "Unit/$it")
}
else
textList += FormattedLine("Available for [${types.second.first().tr()}]")
unitTypes.first().let {
textList += FormattedLine("Available for [$it]", link = "UnitType/$it")
}
} else {
textList += FormattedLine("Available for:")
types.first.forEach {
textList += FormattedLine(it, indent = 1, link = "Unit/$it")
}
types.second.forEach {
textList += FormattedLine(it, indent = 1)
textList += FormattedLine(it, indent = 1, link = "UnitType/$it")
}
}
}

View File

@ -227,6 +227,13 @@ object BaseUnitDescriptions {
if (unit.unitType != name) continue
yield(FormattedLine(unit.name, unit.makeLink()))
}
val relevantPromotions = ruleset.unitPromotions.values.filter { it.unitTypes.contains(name) }
if (relevantPromotions.isNotEmpty()) {
yield(FormattedLine("Promotions", header = 4))
for (promotion in relevantPromotions)
yield(FormattedLine(promotion.name, promotion.makeLink()))
}
if (uniqueObjects.isNotEmpty()) {
yield(FormattedLine(separator = true))
for (unique in uniqueObjects) {