Fixed a bug where great improvements could not be repaired after being pillaged (#5913)

* Fixed a bug where great improvements could not be repaired

* Formatting
This commit is contained in:
Xander Lenstra 2022-01-06 22:29:59 +01:00 committed by GitHub
parent a5bba8dfb0
commit d6a99a7848
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -1104,7 +1104,11 @@ class MapUnit {
fun canBuildImprovement(improvement: TileImprovement, tile: TileInfo = currentTile): Boolean {
// Workers (and similar) should never be able to (instantly) construct things, only build them
if (improvement.turnsToBuild == 0 && improvement.name != Constants.cancelImprovementOrder) return false
// HOWEVER, they should be able to repair such things if they are pillaged
if (improvement.turnsToBuild == 0
&& improvement.name != Constants.cancelImprovementOrder
&& tile.improvementInProgress != improvement.name
) return false
val matchingUniques = getMatchingUniques(UniqueType.BuildImprovements)
return matchingUniques.any { improvement.matchesFilter(it.params[0]) || tile.matchesTerrainFilter(it.params[0]) }
}