Better tech descriptions for increased improvement stats

This commit is contained in:
Yair Morgenstern 2021-02-12 14:13:11 +02:00
parent 4876687e48
commit e92a1dd088
2 changed files with 19 additions and 24 deletions

View File

@ -924,6 +924,7 @@ Are you SURE you want to delete this mod? =
[stats] from every [param] = [stats] from every [param] =
[stats] from [param] tiles in this city = [stats] from [param] tiles in this city =
[stats] from every [param] on [tileFilter] tiles =
[stats] for each adjacent [param] = [stats] for each adjacent [param] =
Must be next to [terrain] = Must be next to [terrain] =
Must be on [terrain] = Must be on [terrain] =

View File

@ -26,43 +26,37 @@ class Technology {
val lineList = ArrayList<String>() // more readable than StringBuilder, with same performance for our use-case val lineList = ArrayList<String>() // more readable than StringBuilder, with same performance for our use-case
for (unique in uniques) lineList += unique.tr() for (unique in uniques) lineList += unique.tr()
val mapOfImprovedImprovements = HashMap<String, ArrayList<String>>() for (improvement in ruleset.tileImprovements.values)
for (improvement in ruleset.tileImprovements.values) for ( unique in improvement.uniqueObjects for (unique in improvement.uniqueObjects) {
.filter { it.placeholderText in setOf("[] once [] is discovered", "[] on [] tiles once [] is discovered") if (unique.placeholderText == "[] once [] is discovered" && unique.params.last() == name)
&& it.params.last() == name }) { lineList += "[${unique.params[0]}] from every [${improvement.name}]"
val key = if (unique.params.size == 2 ) "The following improvements [${unique.params[0]}]:" else "The following improvements on [${unique.params[1]}] tiles [${unique.params[0]}]:" else if (unique.placeholderText == "[] on [] tiles once [] is discovered" && unique.params.last() == name)
if (!mapOfImprovedImprovements.containsKey(key)) mapOfImprovedImprovements[key] = ArrayList() lineList += "[${unique.params[0]}] from every [${improvement.name}] on [${unique.params[1]}] tiles"
mapOfImprovedImprovements[key]!!.add(improvement.name)
}
for (improvements in mapOfImprovedImprovements) {
val impimpString = improvements.key.tr() + improvements.value.joinToString(", "," ") { it.tr() }
lineList += impimpString
} }
val viewingCiv = UncivGame.Current.worldScreen.viewingCiv val viewingCiv = UncivGame.Current.worldScreen.viewingCiv
val enabledUnits = getEnabledUnits(viewingCiv) val enabledUnits = getEnabledUnits(viewingCiv).filter { "Will not be displayed in Civilopedia" !in it.uniques }
if (enabledUnits.any { "Will not be displayed in Civilopedia" !in it.uniques}) { if (enabledUnits.isNotEmpty()) {
lineList += "{Units enabled}: " lineList += "{Units enabled}: "
for (unit in enabledUnits for (unit in enabledUnits)
.filter { "Will not be displayed in Civilopedia" !in it.uniques})
lineList += " * " + unit.name.tr() + " (" + unit.getShortDescription() + ")" lineList += " * " + unit.name.tr() + " (" + unit.getShortDescription() + ")"
} }
val enabledBuildings = getEnabledBuildings(viewingCiv) val enabledBuildings = getEnabledBuildings(viewingCiv)
val regularBuildings = enabledBuildings.filter { !it.isWonder && !it.isNationalWonder } val regularBuildings = enabledBuildings.filter { !it.isWonder && !it.isNationalWonder
if (regularBuildings.any { "Will not be displayed in Civilopedia" !in it.uniques}) { && "Will not be displayed in Civilopedia" !in it.uniques }
if (regularBuildings.isNotEmpty()) {
lineList += "{Buildings enabled}: " lineList += "{Buildings enabled}: "
for (building in regularBuildings for (building in regularBuildings)
.filter { "Will not be displayed in Civilopedia" !in it.uniques})
lineList += "* " + building.name.tr() + " (" + building.getShortDescription(ruleset) + ")" lineList += "* " + building.name.tr() + " (" + building.getShortDescription(ruleset) + ")"
} }
val wonders = enabledBuildings.filter { it.isWonder || it.isNationalWonder } val wonders = enabledBuildings.filter { (it.isWonder || it.isNationalWonder)
if (wonders.any { "Will not be displayed in Civilopedia" !in it.uniques }) { && "Will not be displayed in Civilopedia" !in it.uniques }
if (wonders.isNotEmpty()) {
lineList += "{Wonders enabled}: " lineList += "{Wonders enabled}: "
for (wonder in wonders for (wonder in wonders)
.filter { "Will not be displayed in Civilopedia" !in it.uniques})
lineList += " * " + wonder.name.tr() + " (" + wonder.getShortDescription(ruleset) + ")" lineList += " * " + wonder.name.tr() + " (" + wonder.getShortDescription(ruleset) + ")"
} }