mirror of
https://github.com/yairm210/Unciv.git
synced 2025-03-10 12:51:16 +07:00
Resolved #12187 - units are not added to cities in resistance if non-resistant cities are available
This commit is contained in:
parent
2a0ff58cc9
commit
9c0e9131f0
@ -53,11 +53,14 @@ class UnitManager(val civInfo: Civilization) {
|
||||
if (civInfo.cities.isEmpty()) return null
|
||||
|
||||
val unit = civInfo.getEquivalentUnit(baseUnit)
|
||||
val citiesNotInResistance = civInfo.cities.filterNot { it.isInResistance() }
|
||||
|
||||
val cityToAddTo = when {
|
||||
unit.isWaterUnit && (city == null || !city.isCoastal()) ->
|
||||
citiesNotInResistance.filter { it.isCoastal() }.randomOrNull() ?:
|
||||
civInfo.cities.filter { it.isCoastal() }.randomOrNull()
|
||||
city != null -> city
|
||||
else -> civInfo.cities.random()
|
||||
else -> citiesNotInResistance.randomOrNull() ?: civInfo.cities.random()
|
||||
} ?: return null // If we got a free water unit with no coastal city to place it in
|
||||
val placedUnit = placeUnitNearTile(cityToAddTo.location, unit.name)
|
||||
// silently bail if no tile to place the unit is found
|
||||
|
Loading…
Reference in New Issue
Block a user