mirror of
https://github.com/yairm210/Unciv.git
synced 2025-01-19 16:57:38 +07:00
Fixed great engineer automation trying to reach cities it can't
This commit is contained in:
parent
c0bd8c12fb
commit
7602aa4d0d
@ -296,18 +296,15 @@ object SpecificUnitAutomation {
|
|||||||
* of `false` can be interpreted as: the unit doesn't know where to go or is stuck. */
|
* of `false` can be interpreted as: the unit doesn't know where to go or is stuck. */
|
||||||
fun speedupWonderConstruction(unit: MapUnit): Boolean {
|
fun speedupWonderConstruction(unit: MapUnit): Boolean {
|
||||||
val nearbyCityWithAvailableWonders = unit.civ.cities.filter { city ->
|
val nearbyCityWithAvailableWonders = unit.civ.cities.filter { city ->
|
||||||
// Maybe it would be nice to make space in the city if there's already some
|
// Don't speed up construction in small cities. There's a risk the great
|
||||||
// other civilian unit in there for whatever reason, but again that seems a lot of
|
// engineer can't get it done entirely and then it takes forever for the small
|
||||||
// additional complexity for questionable gain.
|
// city to finish the rest.
|
||||||
|
city.population.population >= 3 &&
|
||||||
(unit.movement.canMoveTo(city.getCenterTile()) || unit.currentTile == city.getCenterTile())
|
(unit.movement.canMoveTo(city.getCenterTile()) || unit.currentTile == city.getCenterTile())
|
||||||
// Don't speed up construction in small cities. There's a risk the great
|
|
||||||
// engineer can't get it done entirely and then it takes forever for the small
|
|
||||||
// city to finish the rest.
|
|
||||||
&& city.population.population >= 3
|
|
||||||
&& getWonderThatWouldBenefitFromBeingSpedUp(city) != null
|
&& getWonderThatWouldBenefitFromBeingSpedUp(city) != null
|
||||||
}.mapNotNull { city ->
|
}.mapNotNull { city ->
|
||||||
val path = unit.movement.getShortestPath(city.getCenterTile())
|
val path = unit.movement.getShortestPath(city.getCenterTile())
|
||||||
if (path.size <= 5) city to path.size else null
|
if (path.any() && path.size <= 5) city to path.size else null
|
||||||
}.minByOrNull { it.second }?.first
|
}.minByOrNull { it.second }?.first
|
||||||
|
|
||||||
if (nearbyCityWithAvailableWonders == null) {
|
if (nearbyCityWithAvailableWonders == null) {
|
||||||
|
Loading…
Reference in New Issue
Block a user