Automated workers no longer stay on unimprovable tile if another tile is improvable

This commit is contained in:
Yair Morgenstern 2023-05-08 18:29:34 +03:00
parent e0505d1eb7
commit f8b4b202e7

View File

@ -86,7 +86,7 @@ class WorkerAutomation(
if (result.isEmpty())
debug("\tempty")
else result.forEach {
debug("\t$it") // ${it.getCity()?.name} included in Tile toString()
debug("\t$it")
}
}
result
@ -297,8 +297,9 @@ class WorkerAutomation(
val selectedTile = workableTiles.firstOrNull { unit.movement.canReach(it) && (tileCanBeImproved(unit, it) || it.isPillaged()) }
return if (selectedTile != null
&& (!workableTiles.contains(currentTile)
|| getPriority(selectedTile) > getPriority(currentTile)))
&& ((!tileCanBeImproved(unit, currentTile) && !currentTile.isPillaged()) // current tile is unimprovable
|| !workableTiles.contains(currentTile) // current tile is unworkable by city
|| getPriority(selectedTile) > getPriority(currentTile))) // current tile is less important
selectedTile
else currentTile
}