mirror of
https://github.com/yairm210/Unciv.git
synced 2025-08-03 08:39:37 +07:00
Fixed a bug where an empty improvement picker screen could open (#5815)
* Fixed a bug where an empty improvement picker screen could open * Moved the check for constructing instead of building to the unit
This commit is contained in:
@ -1050,6 +1050,8 @@ class MapUnit {
|
|||||||
}
|
}
|
||||||
|
|
||||||
fun canBuildImprovement(improvement: TileImprovement, tile: TileInfo = currentTile): Boolean {
|
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
|
||||||
val matchingUniques = getMatchingUniques(UniqueType.BuildImprovements)
|
val matchingUniques = getMatchingUniques(UniqueType.BuildImprovements)
|
||||||
return matchingUniques.any { improvement.matchesFilter(it.params[0]) || tile.matchesTerrainFilter(it.params[0]) }
|
return matchingUniques.any { improvement.matchesFilter(it.params[0]) || tile.matchesTerrainFilter(it.params[0]) }
|
||||||
}
|
}
|
||||||
|
@ -377,8 +377,12 @@ object UnitActions {
|
|||||||
if (unit.isEmbarked()) return
|
if (unit.isEmbarked()) return
|
||||||
|
|
||||||
val canConstruct = unit.currentMovement > 0
|
val canConstruct = unit.currentMovement > 0
|
||||||
&& !tile.isCityCenter()
|
&& !tile.isCityCenter()
|
||||||
&& unit.civInfo.gameInfo.ruleSet.tileImprovements.values.any { tile.canBuildImprovement(it, unit.civInfo) && unit.canBuildImprovement(it) }
|
&& unit.civInfo.gameInfo.ruleSet.tileImprovements.values.any {
|
||||||
|
tile.canBuildImprovement(it, unit.civInfo)
|
||||||
|
&& unit.canBuildImprovement(it)
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
actionList += UnitAction(UnitActionType.ConstructImprovement,
|
actionList += UnitAction(UnitActionType.ConstructImprovement,
|
||||||
isCurrentAction = unit.currentTile.hasImprovementInProgress(),
|
isCurrentAction = unit.currentTile.hasImprovementInProgress(),
|
||||||
|
Reference in New Issue
Block a user