From cafbf0d155e5b74d6f1fb62c646938bf75edd16e Mon Sep 17 00:00:00 2001 From: yairm210 Date: Wed, 3 Nov 2021 10:23:59 +0200 Subject: [PATCH] Units can promote only if they have movement left and have not attacked --- core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt | 4 ++-- core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt index 15419fafa0..ccc184aeba 100644 --- a/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt +++ b/core/src/com/unciv/logic/map/UnitMovementAlgorithms.kt @@ -412,7 +412,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) { unit.action = null unit.removeFromTile() unit.putInTile(destination) - unit.currentMovement -= 1f + unit.useMovementPoints(1f) unit.attacksThisTurn += 1 // Check if unit maintenance changed // Is also done for other units, but because we skip everything else, we have to manually check it @@ -466,7 +466,7 @@ class UnitMovementAlgorithms(val unit:MapUnit) { // We can assume we can pass through this tile, as we would have broken earlier if (unit.movement.canMoveTo(tile, assumeCanPassThrough = true)) { lastReachedEnterableTile = tile - unit.currentMovement -= passingMovementSpent + unit.useMovementPoints(passingMovementSpent) passingMovementSpent = 0f } diff --git a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt index f3ba39db08..650b531162 100644 --- a/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt +++ b/core/src/com/unciv/ui/worldscreen/unit/UnitActions.kt @@ -226,7 +226,7 @@ object UnitActions { actionList += UnitAction(UnitActionType.Promote, action = { UncivGame.Current.setScreen(PromotionPickerScreen(unit)) - }) + }.takeIf { unit.currentMovement > 0 && unit.attacksThisTurn == 0 }) } private fun addSetupAction(unit: MapUnit, actionList: ArrayList) {