* Fixed #5113

* Better check
This commit is contained in:
Xander Lenstra 2021-09-08 19:42:58 +02:00 committed by GitHub
parent 9a29ce8422
commit a1f7721878
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -281,14 +281,20 @@ class WorkerAutomation(
val city = tile.getCity()
if (city == null || city.civInfo != civInfo)
return false
if (tile.improvement != null && !UncivGame.Current.settings.automatedWorkersReplaceImprovements)
return false
if (tile.improvement != null && !UncivGame.Current.settings.automatedWorkersReplaceImprovements) {
if (unit != null) {
if (unit.civInfo.isPlayerCivilization())
return false
} else if (UncivGame.Current.gameInfo.currentPlayerCiv.isPlayerCivilization())
return false
}
if (tile.improvement == null) {
if (unit == null) return true
if (tile.improvementInProgress != null && unit.canBuildImprovement(tile.getTileImprovementInProgress()!!, tile)) return true
val chosenImprovement = chooseImprovement(unit, tile)
if (chosenImprovement != null && tile.canBuildImprovement(chosenImprovement, civInfo) && unit.canBuildImprovement(chosenImprovement, tile)) return true
} else if (!tile.containsGreatImprovement() && tile.hasViewableResource(civInfo)
&& tile.getTileResource().improvement != tile.improvement
&& (unit == null || chooseImprovement(unit, tile) // if the chosen improvement is not null and buildable