From f66053a4c507856b9a9d7575c1684196c98ca2af Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Fri, 24 Oct 2014 15:14:46 +0200 Subject: [PATCH] * Commander - Fixed that a countered commander could not be moved instead to command zone if he left the stack. --- .../mage/sets/newphyrexia/PhyrexianIngester.java | 16 ++++++++++------ .../common/LookLibraryControllerEffect.java | 2 +- .../continious/CommanderReplacementEffect.java | 6 +++--- Mage/src/mage/players/PlayerImpl.java | 12 ++++++++---- 4 files changed, 22 insertions(+), 14 deletions(-) diff --git a/Mage.Sets/src/mage/sets/newphyrexia/PhyrexianIngester.java b/Mage.Sets/src/mage/sets/newphyrexia/PhyrexianIngester.java index cdede6ba209..38e7a51ed35 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/PhyrexianIngester.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/PhyrexianIngester.java @@ -48,6 +48,7 @@ import mage.filter.predicate.Predicates; import mage.filter.predicate.permanent.TokenPredicate; import mage.game.Game; import mage.game.permanent.Permanent; +import mage.players.Player; import mage.target.TargetPermanent; /** @@ -107,12 +108,15 @@ class PhyrexianIngesterImprintEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Permanent sourcePermanent = game.getPermanent(source.getSourceId()); - Permanent targetPermanent = game.getPermanent(source.getFirstTarget()); - if (targetPermanent != null) { - targetPermanent.moveToExile(getId(), "Phyrexian Ingester (Imprint)", source.getSourceId(), game); - sourcePermanent.imprint(targetPermanent.getId(), game); - return true; + Player controller = game.getPlayer(source.getControllerId()); + if (controller != null) { + Permanent sourcePermanent = game.getPermanent(source.getSourceId()); + Permanent targetPermanent = game.getPermanent(source.getFirstTarget()); + if (targetPermanent != null) { + controller.moveCardToExileWithInfo(targetPermanent, getId(), "Phyrexian Ingester (Imprint)", source.getSourceId(), game, Zone.BATTLEFIELD); + sourcePermanent.imprint(targetPermanent.getId(), game); + return true; + } } return false; } diff --git a/Mage/src/mage/abilities/effects/common/LookLibraryControllerEffect.java b/Mage/src/mage/abilities/effects/common/LookLibraryControllerEffect.java index de2e4231593..f1493a51e9a 100644 --- a/Mage/src/mage/abilities/effects/common/LookLibraryControllerEffect.java +++ b/Mage/src/mage/abilities/effects/common/LookLibraryControllerEffect.java @@ -227,7 +227,7 @@ public class LookLibraryControllerEffect extends OneShotEffect { } catch (NumberFormatException e) { numberLook = 0; } - StringBuilder sb = new StringBuilder("Look at the top "); + StringBuilder sb = new StringBuilder("look at the top "); switch (numberLook) { case 0: sb.append(" X "); diff --git a/Mage/src/mage/abilities/effects/common/continious/CommanderReplacementEffect.java b/Mage/src/mage/abilities/effects/common/continious/CommanderReplacementEffect.java index 74c0bf93164..b3556363dc3 100644 --- a/Mage/src/mage/abilities/effects/common/continious/CommanderReplacementEffect.java +++ b/Mage/src/mage/abilities/effects/common/continious/CommanderReplacementEffect.java @@ -95,10 +95,10 @@ public class CommanderReplacementEffect extends ReplacementEffectImpl { if (spell != null) { card = game.getCard(spell.getSourceId()); } - } else { - card = game.getCard(event.getTargetId()); } - + if (card == null) { + card = game.getCard(event.getTargetId()); + } if (card != null) { Player player = game.getPlayer(card.getOwnerId()); if (player != null && player.chooseUse(Outcome.Benefit, "Move commander to command zone?", game)){ diff --git a/Mage/src/mage/players/PlayerImpl.java b/Mage/src/mage/players/PlayerImpl.java index c1b42e18d01..d2ccb055df5 100644 --- a/Mage/src/mage/players/PlayerImpl.java +++ b/Mage/src/mage/players/PlayerImpl.java @@ -775,25 +775,29 @@ public abstract class PlayerImpl implements Player, Serializable { if (!anyOrder) { for (UUID cardId : cards) { Card card =game.getCard(cardId); + if (card != null) { - card.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false); + Zone fromZone = game.getState().getZone(cardId); + this.moveCardToLibraryWithInfo(card, source.getSourceId(), game, fromZone, false, false); } } } else { - TargetCard target = new TargetCard(Zone.PICK, new FilterCard("card to put on the bottom of your library")); + TargetCard target = new TargetCard(Zone.PICK, new FilterCard("card to put on the bottom of your library (last one chosen will be bottommost)")); target.setRequired(true); while (isInGame() && cards.size() > 1) { this.choose(Outcome.Neutral, cards, target, game); Card chosenCard = cards.get(target.getFirstTarget(), game); if (chosenCard != null) { cards.remove(chosenCard); - chosenCard.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false); + Zone fromZone = game.getState().getZone(chosenCard.getId()); + this.moveCardToLibraryWithInfo(chosenCard, source.getSourceId(), game, fromZone, false, false); } target.clearChosen(); } if (cards.size() == 1) { Card chosenCard = cards.get(cards.iterator().next(), game); - chosenCard.moveToZone(Zone.LIBRARY, source.getSourceId(), game, false); + Zone fromZone = game.getState().getZone(chosenCard.getId()); + this.moveCardToLibraryWithInfo(chosenCard, source.getSourceId(), game, fromZone, false, false); } } }