mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-27 13:55:54 -04:00
Resolved #6188 - don't show 'missing cities that need to build X' for buildings already built in the city
It gives the impression that the buildings stop providing their bonus if the condition is no longer satisfied
This commit is contained in:
parent
99e913ba24
commit
0a4df1ca9f
@ -99,21 +99,13 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** used in CityScreen (CityInfoTable and ConstructionInfoTable) */
|
/** used in CityScreen (CityInfoTable and ConstructionInfoTable) */
|
||||||
fun getDescription(cityInfo: CityInfo): String {
|
fun getDescription(cityInfo: CityInfo, showMissingRequiredCities:Boolean): String {
|
||||||
val stats = getStats(cityInfo)
|
val stats = getStats(cityInfo)
|
||||||
val lines = ArrayList<String>()
|
val lines = ArrayList<String>()
|
||||||
val isFree = name in cityInfo.civInfo.civConstructions.getFreeBuildings(cityInfo.id)
|
val isFree = name in cityInfo.civInfo.civConstructions.getFreeBuildings(cityInfo.id)
|
||||||
if (uniqueTo != null) lines += if (replaces == null) "Unique to [$uniqueTo]"
|
if (uniqueTo != null) lines += if (replaces == null) "Unique to [$uniqueTo]"
|
||||||
else "Unique to [$uniqueTo], replaces [$replaces]"
|
else "Unique to [$uniqueTo], replaces [$replaces]"
|
||||||
val missingUnique = getMatchingUniques(UniqueType.RequiresBuildingInAllCities).firstOrNull()
|
val missingUnique = getMatchingUniques(UniqueType.RequiresBuildingInAllCities).firstOrNull()
|
||||||
// Inefficient in theory. In practice, buildings seem to have only a small handful of uniques.
|
|
||||||
val missingCities = if (missingUnique != null)
|
|
||||||
// TODO: Unify with rejection reasons?
|
|
||||||
cityInfo.civInfo.cities.filterNot {
|
|
||||||
it.isPuppet
|
|
||||||
|| it.cityConstructions.containsBuildingOrEquivalent(missingUnique.params[0])
|
|
||||||
}
|
|
||||||
else listOf()
|
|
||||||
if (isWonder) lines += "Wonder"
|
if (isWonder) lines += "Wonder"
|
||||||
if (isNationalWonder) lines += "National Wonder"
|
if (isNationalWonder) lines += "National Wonder"
|
||||||
if (!isFree) {
|
if (!isFree) {
|
||||||
@ -122,6 +114,15 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
|||||||
else "Consumes [$amount] [$resource]"
|
else "Consumes [$amount] [$resource]"
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
// Inefficient in theory. In practice, buildings seem to have only a small handful of uniques.
|
||||||
|
val missingCities = if (missingUnique != null)
|
||||||
|
// TODO: Unify with rejection reasons?
|
||||||
|
cityInfo.civInfo.cities.filterNot {
|
||||||
|
it.isPuppet
|
||||||
|
|| it.cityConstructions.containsBuildingOrEquivalent(missingUnique.params[0])
|
||||||
|
}
|
||||||
|
else listOf()
|
||||||
if (uniques.isNotEmpty()) {
|
if (uniques.isNotEmpty()) {
|
||||||
if (replacementTextForUniques != "") lines += replacementTextForUniques
|
if (replacementTextForUniques != "") lines += replacementTextForUniques
|
||||||
else lines += getUniquesStringsWithoutDisablers(
|
else lines += getUniquesStringsWithoutDisablers(
|
||||||
@ -148,7 +149,7 @@ class Building : RulesetStatsObject(), INonPerpetualConstruction {
|
|||||||
if (cityStrength != 0) lines += "{City strength} +$cityStrength"
|
if (cityStrength != 0) lines += "{City strength} +$cityStrength"
|
||||||
if (cityHealth != 0) lines += "{City health} +$cityHealth"
|
if (cityHealth != 0) lines += "{City health} +$cityHealth"
|
||||||
if (maintenance != 0 && !isFree) lines += "{Maintenance cost}: $maintenance {Gold}"
|
if (maintenance != 0 && !isFree) lines += "{Maintenance cost}: $maintenance {Gold}"
|
||||||
if (missingCities.isNotEmpty()) {
|
if (showMissingRequiredCities && missingCities.isNotEmpty()) {
|
||||||
// Could be red. But IMO that should be done by enabling GDX's ColorMarkupLanguage globally instead of adding a separate label.
|
// Could be red. But IMO that should be done by enabling GDX's ColorMarkupLanguage globally instead of adding a separate label.
|
||||||
lines += "\n" +
|
lines += "\n" +
|
||||||
"[${cityInfo.civInfo.getEquivalentBuilding(missingUnique!!.params[0])}] required:".tr() +
|
"[${cityInfo.civInfo.getEquivalentBuilding(missingUnique!!.params[0])}] required:".tr() +
|
||||||
|
@ -70,7 +70,7 @@ class CityInfoTable(private val cityScreen: CityScreen) : Table(BaseScreen.skin)
|
|||||||
val isFree = building.name in cityScreen.city.civInfo.civConstructions.getFreeBuildings(cityScreen.city.id)
|
val isFree = building.name in cityScreen.city.civInfo.civConstructions.getFreeBuildings(cityScreen.city.id)
|
||||||
val displayName = if (isFree) "{${building.name}} ({Free})" else building.name
|
val displayName = if (isFree) "{${building.name}} ({Free})" else building.name
|
||||||
val buildingNameAndIconTable = ExpanderTab(displayName, Constants.defaultFontSize, icon, false, 5f) {
|
val buildingNameAndIconTable = ExpanderTab(displayName, Constants.defaultFontSize, icon, false, 5f) {
|
||||||
val detailsString = building.getDescription(cityScreen.city)
|
val detailsString = building.getDescription(cityScreen.city, false)
|
||||||
it.add(detailsString.toLabel().apply { wrap = true })
|
it.add(detailsString.toLabel().apply { wrap = true })
|
||||||
.width(cityScreen.stage.width / 4 - 2 * pad).row() // when you set wrap, then you need to manually set the size of the label
|
.width(cityScreen.stage.width / 4 - 2 * pad).row() // when you set wrap, then you need to manually set the size of the label
|
||||||
if (building.isSellable() && !isFree) {
|
if (building.isSellable() && !isFree) {
|
||||||
|
@ -59,7 +59,7 @@ class ConstructionInfoTable(val cityScreen: CityScreen): Table() {
|
|||||||
|
|
||||||
val (description, link) = when (construction) {
|
val (description, link) = when (construction) {
|
||||||
is BaseUnit -> construction.getDescription() to construction.makeLink()
|
is BaseUnit -> construction.getDescription() to construction.makeLink()
|
||||||
is Building -> construction.getDescription(city) to construction.makeLink()
|
is Building -> construction.getDescription(city, true) to construction.makeLink()
|
||||||
is PerpetualConstruction -> construction.description.replace("[rate]", "[${construction.getConversionRate(city)}]") to ""
|
is PerpetualConstruction -> construction.description.replace("[rate]", "[${construction.getConversionRate(city)}]") to ""
|
||||||
else -> "" to "" // Should never happen
|
else -> "" to "" // Should never happen
|
||||||
}
|
}
|
||||||
|
Loading…
x
Reference in New Issue
Block a user