From 2409e229c05557273a98fd8248113ec897a3899b Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Tue, 5 Mar 2013 22:01:01 +0100 Subject: [PATCH] Fixed can't attack alone ability (issue #119), creature wasn't untapped when attack was reverted. --- .../mage/abilities/keyword/CantAttackAloneAbility.java | 2 +- .../mage/abilities/keyword/CantBlockAloneAbility.java | 2 +- Mage/src/mage/game/combat/Combat.java | 9 +++++---- Mage/src/mage/game/combat/CombatGroup.java | 7 ++----- 4 files changed, 9 insertions(+), 11 deletions(-) diff --git a/Mage/src/mage/abilities/keyword/CantAttackAloneAbility.java b/Mage/src/mage/abilities/keyword/CantAttackAloneAbility.java index 08d8ba6e81..0977319688 100644 --- a/Mage/src/mage/abilities/keyword/CantAttackAloneAbility.java +++ b/Mage/src/mage/abilities/keyword/CantAttackAloneAbility.java @@ -55,7 +55,7 @@ public class CantAttackAloneAbility extends StaticAbility @Override public String getRule() { - return "Can't block alone"; + return "{this} can't block alone."; } @Override diff --git a/Mage/src/mage/game/combat/Combat.java b/Mage/src/mage/game/combat/Combat.java index c7637cde7d..a8abbdcc66 100644 --- a/Mage/src/mage/game/combat/Combat.java +++ b/Mage/src/mage/game/combat/Combat.java @@ -177,8 +177,8 @@ public class Combat implements Serializable, Copyable { count += group.getAttackers().size(); } if (count == 1) { + List tobeRemoved = new ArrayList(); for (CombatGroup group: groups) { - List tobeRemoved = new ArrayList(); for (UUID attackingCreatureId: group.getAttackers()) { Permanent attacker = game.getPermanent(attackingCreatureId); if (attacker != null && attacker.getAbilities().containsKey(CantAttackAloneAbility.getInstance().getId())) { @@ -186,10 +186,11 @@ public class Combat implements Serializable, Copyable { tobeRemoved.add(attackingCreatureId); } } - for (UUID attackingCreatureId : tobeRemoved) { - group.remove(attackingCreatureId); - } } + for (UUID attackingCreatureId : tobeRemoved) { + this.removeAttacker(attackingCreatureId, game); + } + } } diff --git a/Mage/src/mage/game/combat/CombatGroup.java b/Mage/src/mage/game/combat/CombatGroup.java index 69b55815fb..84e65e004f 100644 --- a/Mage/src/mage/game/combat/CombatGroup.java +++ b/Mage/src/mage/game/combat/CombatGroup.java @@ -499,12 +499,9 @@ public class CombatGroup implements Serializable, Copyable { toBeRemoved.add(blockerId); } } + for (UUID blockerId : toBeRemoved) { - remove(blockerId); - Permanent creature = game.getPermanent(blockerId); - if (creature != null) { - creature.setBlocking(creature.getBlocking() - 1); - } + game.getCombat().removeBlocker(blockerId, game); } if (blockers.isEmpty()) { this.blocked = false;