mirror of
https://github.com/yairm210/Unciv.git
synced 2025-07-14 01:39:40 +07:00
Fix Garrison bonus logic (#8952)
* City filter for Military Caste * Garrison display in Overview - all credit to @WhoIsJohannes
This commit is contained in:
@ -10,6 +10,7 @@ import com.unciv.logic.city.managers.CityReligionManager
|
|||||||
import com.unciv.logic.civilization.Civilization
|
import com.unciv.logic.civilization.Civilization
|
||||||
import com.unciv.logic.civilization.diplomacy.DiplomacyFlags
|
import com.unciv.logic.civilization.diplomacy.DiplomacyFlags
|
||||||
import com.unciv.logic.map.TileMap
|
import com.unciv.logic.map.TileMap
|
||||||
|
import com.unciv.logic.map.mapunit.MapUnit
|
||||||
import com.unciv.logic.map.tile.RoadStatus
|
import com.unciv.logic.map.tile.RoadStatus
|
||||||
import com.unciv.logic.map.tile.Tile
|
import com.unciv.logic.map.tile.Tile
|
||||||
import com.unciv.models.Counter
|
import com.unciv.models.Counter
|
||||||
@ -153,6 +154,12 @@ class City : IsPartOfGameInfoSerialization {
|
|||||||
return connectionTypePredicate(mediumTypes)
|
return connectionTypePredicate(mediumTypes)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
fun isGarrisoned() = getGarrison() != null
|
||||||
|
fun getGarrison(): MapUnit? =
|
||||||
|
getCenterTile().militaryUnit?.takeIf {
|
||||||
|
it.civ == this.civ && it.canGarrison()
|
||||||
|
}
|
||||||
|
|
||||||
fun hasFlag(flag: CityFlags) = flagsCountdown.containsKey(flag.name)
|
fun hasFlag(flag: CityFlags) = flagsCountdown.containsKey(flag.name)
|
||||||
fun getFlag(flag: CityFlags) = flagsCountdown[flag.name]!!
|
fun getFlag(flag: CityFlags) = flagsCountdown[flag.name]!!
|
||||||
|
|
||||||
@ -512,7 +519,7 @@ class City : IsPartOfGameInfoSerialization {
|
|||||||
"in all cities with a world wonder" -> cityConstructions.getBuiltBuildings()
|
"in all cities with a world wonder" -> cityConstructions.getBuiltBuildings()
|
||||||
.any { it.isWonder }
|
.any { it.isWonder }
|
||||||
"in all cities connected to capital" -> isConnectedToCapital()
|
"in all cities connected to capital" -> isConnectedToCapital()
|
||||||
"in all cities with a garrison" -> getCenterTile().militaryUnit != null
|
"in all cities with a garrison" -> isGarrisoned()
|
||||||
"in all cities in which the majority religion is a major religion" ->
|
"in all cities in which the majority religion is a major religion" ->
|
||||||
religion.getMajorityReligionName() != null
|
religion.getMajorityReligionName() != null
|
||||||
&& religion.getMajorityReligion()!!.isMajorReligion()
|
&& religion.getMajorityReligion()!!.isMajorReligion()
|
||||||
|
@ -126,8 +126,8 @@ class CityOverviewTab(
|
|||||||
"Population" -> city2.population.population - city1.population.population
|
"Population" -> city2.population.population - city1.population.population
|
||||||
WLTK -> city2.isWeLoveTheKingDayActive().compareTo(city1.isWeLoveTheKingDayActive())
|
WLTK -> city2.isWeLoveTheKingDayActive().compareTo(city1.isWeLoveTheKingDayActive())
|
||||||
GARRISON -> collator.compare(
|
GARRISON -> collator.compare(
|
||||||
city2.getCenterTile().militaryUnit?.name?.tr() ?: "",
|
city2.getGarrison()?.name?.tr() ?: "",
|
||||||
city1.getCenterTile().militaryUnit?.name?.tr() ?: "",
|
city1.getGarrison()?.name?.tr() ?: "",
|
||||||
)
|
)
|
||||||
else -> {
|
else -> {
|
||||||
val stat = Stat.safeValueOf(persistableData.sortedBy)!!
|
val stat = Stat.safeValueOf(persistableData.sortedBy)!!
|
||||||
@ -236,7 +236,7 @@ class CityOverviewTab(
|
|||||||
else -> cityInfoTableDetails.add()
|
else -> cityInfoTableDetails.add()
|
||||||
}
|
}
|
||||||
|
|
||||||
val garrisonUnit = city.getCenterTile().militaryUnit
|
val garrisonUnit = city.getGarrison()
|
||||||
if (garrisonUnit == null) {
|
if (garrisonUnit == null) {
|
||||||
cityInfoTableDetails.add()
|
cityInfoTableDetails.add()
|
||||||
} else {
|
} else {
|
||||||
@ -270,7 +270,7 @@ class CityOverviewTab(
|
|||||||
else cityInfoTableTotal.add(viewingPlayer.cities.sumOf { it.getStat(stat) }.toCenteredLabel())
|
else cityInfoTableTotal.add(viewingPlayer.cities.sumOf { it.getStat(stat) }.toCenteredLabel())
|
||||||
}
|
}
|
||||||
cityInfoTableTotal.add(viewingPlayer.cities.count { it.isWeLoveTheKingDayActive() }.toCenteredLabel())
|
cityInfoTableTotal.add(viewingPlayer.cities.count { it.isWeLoveTheKingDayActive() }.toCenteredLabel())
|
||||||
cityInfoTableTotal.add(viewingPlayer.cities.count { it.getCenterTile().militaryUnit != null }.toCenteredLabel())
|
cityInfoTableTotal.add(viewingPlayer.cities.count { it.isGarrisoned() }.toCenteredLabel())
|
||||||
cityInfoTableTotal.pack()
|
cityInfoTableTotal.pack()
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
Reference in New Issue
Block a user