From 6d0f30178d1b7b25ea203219fd458fbc7afe363b Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Sun, 15 Dec 2013 14:17:39 +0100 Subject: [PATCH] * Commander - Fixed that sacrificing a commander as cost was not possible. Added game log message if creature was removed from combat. --- Mage/src/mage/game/combat/Combat.java | 6 ++++-- Mage/src/mage/game/combat/CombatGroup.java | 20 +++++++++++-------- .../mage/game/permanent/PermanentImpl.java | 9 +++++++-- 3 files changed, 23 insertions(+), 12 deletions(-) diff --git a/Mage/src/mage/game/combat/Combat.java b/Mage/src/mage/game/combat/Combat.java index afa94cb982..4650ae1993 100644 --- a/Mage/src/mage/game/combat/Combat.java +++ b/Mage/src/mage/game/combat/Combat.java @@ -773,15 +773,17 @@ public class Combat implements Serializable, Copyable { } } - public void removeFromCombat(UUID creatureId, Game game) { + public boolean removeFromCombat(UUID creatureId, Game game) { + boolean result = false; Permanent creature = game.getPermanent(creatureId); if (creature != null) { creature.setAttacking(false); creature.setBlocking(0); for (CombatGroup group : groups) { - group.remove(creatureId); + result |= group.remove(creatureId); } } + return result; } public void endCombat(Game game) { diff --git a/Mage/src/mage/game/combat/CombatGroup.java b/Mage/src/mage/game/combat/CombatGroup.java index a1c0a969ec..465f543286 100644 --- a/Mage/src/mage/game/combat/CombatGroup.java +++ b/Mage/src/mage/game/combat/CombatGroup.java @@ -492,18 +492,22 @@ public class CombatGroup implements Serializable, Copyable { return defenderIsPlaneswalker; } - public void remove(UUID creatureId) { + public boolean remove(UUID creatureId) { + boolean result = false; if (attackers.contains(creatureId)) { attackers.remove(creatureId); - } - if (blockers.contains(creatureId)) { - blockers.remove(creatureId); - - //20100423 - 509.2a - if (blockerOrder.contains(creatureId)) { - blockerOrder.remove(creatureId); + result = true; + } else { + if (blockers.contains(creatureId)) { + blockers.remove(creatureId); + result = true; + //20100423 - 509.2a + if (blockerOrder.contains(creatureId)) { + blockerOrder.remove(creatureId); + } } } + return result; } public void acceptBlockers(Game game) { diff --git a/Mage/src/mage/game/permanent/PermanentImpl.java b/Mage/src/mage/game/permanent/PermanentImpl.java index 005bc39112..9279e4b0dc 100644 --- a/Mage/src/mage/game/permanent/PermanentImpl.java +++ b/Mage/src/mage/game/permanent/PermanentImpl.java @@ -817,7 +817,8 @@ public abstract class PermanentImpl> extends CardImpl public boolean sacrifice(UUID sourceId, Game game) { //20091005 - 701.13 if (!game.replaceEvent(GameEvent.getEvent(EventType.SACRIFICE_PERMANENT, objectId, sourceId, controllerId))) { - if (moveToZone(Zone.GRAVEYARD, sourceId, game, true)) { + // Commander replacement effect does not prevent successful sacrifice + if (moveToZone(Zone.GRAVEYARD, sourceId, game, true) || game.getState().getZone(this.getId()).equals(Zone.COMMAND)) { Player player = game.getPlayer(getControllerId()); if (player != null) { game.informPlayers(new StringBuilder(player.getName()).append(" sacrificed ").append(this.getName()).toString()); @@ -976,7 +977,11 @@ public abstract class PermanentImpl> extends CardImpl @Override public boolean removeFromCombat(Game game) { - game.getCombat().removeFromCombat(objectId, game); + if (this.isAttacking() || this.blocking > 0) { + if (game.getCombat().removeFromCombat(objectId, game)) { + game.informPlayers(new StringBuilder(this.getName()).append(" removed from combat").toString()); + } + } return true; }