Fixed bug where all units could move after attacking (#4325)

This commit is contained in:
Xander Lenstra 2021-07-01 21:18:49 +02:00 committed by GitHub
parent c350a3c923
commit dd283248c2
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23

View File

@ -248,6 +248,7 @@ object Battle {
private fun reduceAttackerMovementPointsAndAttacks(attacker: ICombatant, defender: ICombatant) {
if (attacker is MapUnitCombatant) {
val unit = attacker.unit
unit.attacksThisTurn += 1
if (unit.hasUnique("Can move after attacking") || unit.maxAttacksPerTurn() > unit.attacksThisTurn) {
// if it was a melee attack and we won, then the unit ALREADY got movement points deducted,
// for the movement to the enemy's tile!
@ -255,7 +256,6 @@ object Battle {
if (!attacker.unit.baseUnit.movesLikeAirUnits() && !(attacker.getUnitType().isMelee() && defender.isDefeated()))
unit.useMovementPoints(1f)
} else unit.currentMovement = 0f
unit.attacksThisTurn += 1
if (unit.isFortified() || unit.isSleeping())
attacker.unit.action = null // but not, for instance, if it's Set Up - then it should definitely keep the action!
} else if (attacker is CityCombatant) {