mirror of
https://github.com/yairm210/Unciv.git
synced 2025-09-30 15:30:43 -04:00
Hopefully fixed a recurring bug in tryHeadTowardsEnemyCity
This commit is contained in:
parent
b6512535fb
commit
d0cb10abbe
@ -233,15 +233,14 @@ class UnitAutomation{
|
|||||||
.filter { unit.civInfo.isAtWarWith(it) }
|
.filter { unit.civInfo.isAtWarWith(it) }
|
||||||
.flatMap { it.cities }.asSequence()
|
.flatMap { it.cities }.asSequence()
|
||||||
.filter { it.location in unit.civInfo.exploredTiles }
|
.filter { it.location in unit.civInfo.exploredTiles }
|
||||||
.map { it.getCenterTile() }.toList()
|
|
||||||
|
|
||||||
if(unit.type.isRanged()) // ranged units don't harm capturable cities, waste of a turn
|
if(unit.type.isRanged()) // ranged units don't harm capturable cities, waste of a turn
|
||||||
enemyCities = enemyCities.filterNot { it.getCity()!!.health==1 }
|
enemyCities = enemyCities.filterNot { it.health==1 }
|
||||||
|
|
||||||
val closestReachableEnemyCity = enemyCities
|
val closestReachableEnemyCity = enemyCities
|
||||||
.asSequence()
|
.asSequence().map { it.getCenterTile() }
|
||||||
.sortedBy { city -> // sort enemy cities by closeness to our cities, and only then choose the first reachable - checking canReach is comparatively very time-intensive!
|
.sortedBy { cityCenterTile -> // sort enemy cities by closeness to our cities, and only then choose the first reachable - checking canReach is comparatively very time-intensive!
|
||||||
unit.civInfo.cities.asSequence().map { city.arialDistanceTo(it.getCenterTile()) }.min()!!
|
unit.civInfo.cities.asSequence().map { cityCenterTile.arialDistanceTo(it.getCenterTile()) }.min()!!
|
||||||
}
|
}
|
||||||
.firstOrNull { unit.movementAlgs().canReach(it) }
|
.firstOrNull { unit.movementAlgs().canReach(it) }
|
||||||
|
|
||||||
|
Loading…
x
Reference in New Issue
Block a user