mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-23 11:34:54 -04: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
|
if (civInfo.cities.isEmpty()) return null
|
||||||
|
|
||||||
val unit = civInfo.getEquivalentUnit(baseUnit)
|
val unit = civInfo.getEquivalentUnit(baseUnit)
|
||||||
|
val citiesNotInResistance = civInfo.cities.filterNot { it.isInResistance() }
|
||||||
|
|
||||||
val cityToAddTo = when {
|
val cityToAddTo = when {
|
||||||
unit.isWaterUnit && (city == null || !city.isCoastal()) ->
|
unit.isWaterUnit && (city == null || !city.isCoastal()) ->
|
||||||
|
citiesNotInResistance.filter { it.isCoastal() }.randomOrNull() ?:
|
||||||
civInfo.cities.filter { it.isCoastal() }.randomOrNull()
|
civInfo.cities.filter { it.isCoastal() }.randomOrNull()
|
||||||
city != null -> city
|
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
|
} ?: return null // If we got a free water unit with no coastal city to place it in
|
||||||
val placedUnit = placeUnitNearTile(cityToAddTo.location, unit.name)
|
val placedUnit = placeUnitNearTile(cityToAddTo.location, unit.name)
|
||||||
// silently bail if no tile to place the unit is found
|
// silently bail if no tile to place the unit is found
|
||||||
|
Loading…
x
Reference in New Issue
Block a user