From fa709bfd5e3b14292ab01c615b24d96c4f11262a Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Mon, 5 Jan 2015 14:28:57 +0100 Subject: [PATCH] * Extirpate - Fixed that the hand and library of target card owner could not be serached. --- .../sets/newphyrexia/SurgicalExtraction.java | 72 ++++++++----------- .../src/mage/sets/planarchaos/Extirpate.java | 36 ++++++---- Mage/src/mage/abilities/Ability.java | 2 +- 3 files changed, 53 insertions(+), 57 deletions(-) diff --git a/Mage.Sets/src/mage/sets/newphyrexia/SurgicalExtraction.java b/Mage.Sets/src/mage/sets/newphyrexia/SurgicalExtraction.java index 65dc483e9f..42912b07a2 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/SurgicalExtraction.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/SurgicalExtraction.java @@ -102,73 +102,63 @@ class SurgicalExtractionEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { - Card card = game.getCard(source.getFirstTarget()); - Player player = game.getPlayer(source.getControllerId()); + Card chosenCard = game.getCard(source.getFirstTarget()); + Player controller = game.getPlayer(source.getControllerId()); // 6/1/2011 "Any number of cards" means just that. If you wish, you can choose to // leave some or all of the cards with the same name as the targeted card, // including that card, in the zone they're in. - if (card != null && player != null) { - Player targetPlayer = game.getPlayer(card.getOwnerId()); - if (targetPlayer != null) { - FilterCard filter = new FilterCard("card named " + card.getName()); - filter.add(new NamePredicate(card.getName())); + if (chosenCard != null && controller != null) { + Player owner = game.getPlayer(chosenCard.getOwnerId()); + if (owner != null) { + FilterCard filterNamedCard = new FilterCard("card named " + chosenCard.getName()); + filterNamedCard.add(new NamePredicate(chosenCard.getName())); Cards cardsInLibrary = new CardsImpl(Zone.LIBRARY); - cardsInLibrary.addAll(targetPlayer.getLibrary().getCards(game)); + cardsInLibrary.addAll(owner.getLibrary().getCards(game)); // cards in Graveyard - int cardsCount = targetPlayer.getGraveyard().count(filter, game); + int cardsCount = owner.getGraveyard().count(filterNamedCard, game); if (cardsCount > 0) { - filter.setMessage("card named " + card.getName() + " in the graveyard of " + targetPlayer.getName()); - TargetCardInGraveyard target = new TargetCardInGraveyard(0, cardsCount, filter); - if (player.choose(Outcome.Exile, targetPlayer.getGraveyard(), target, game)) { + filterNamedCard.setMessage("card named " + chosenCard.getName() + " in the graveyard of " + owner.getName()); + TargetCardInGraveyard target = new TargetCardInGraveyard(0, cardsCount, filterNamedCard); + if (controller.choose(Outcome.Exile, owner.getGraveyard(), target, game)) { List targets = target.getTargets(); for (UUID targetId : targets) { - Card targetCard = targetPlayer.getGraveyard().get(targetId, game); + Card targetCard = owner.getGraveyard().get(targetId, game); if (targetCard != null) { - player.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.GRAVEYARD); + controller.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.GRAVEYARD); } } } } // cards in Hand - cardsCount = targetPlayer.getHand().count(filter, game); - if (cardsCount > 0) { - filter.setMessage("card named " + card.getName() + " in the hand of " + targetPlayer.getName()); - TargetCardInHand target = new TargetCardInHand(0, cardsCount, filter); - if (player.choose(Outcome.Exile, targetPlayer.getHand(), target, game)) { - List targets = target.getTargets(); - for (UUID targetId : targets) { - Card targetCard = targetPlayer.getHand().get(targetId, game); - if (targetCard != null) { - player.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.HAND); - } + filterNamedCard.setMessage("card named " + chosenCard.getName() + " in the hand of " + owner.getName()); + TargetCardInHand targetCardInHand = new TargetCardInHand(0, Integer.MAX_VALUE, filterNamedCard); + if (controller.choose(Outcome.Exile, owner.getHand(), targetCardInHand, game)) { + List targets = targetCardInHand.getTargets(); + for (UUID targetId : targets) { + Card targetCard = owner.getHand().get(targetId, game); + if (targetCard != null) { + controller.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.HAND); } } - } else { - player.lookAtCards(targetPlayer.getName() + " hand", targetPlayer.getHand(), game); } // cards in Library - cardsCount = cardsInLibrary.count(filter, game); - if (cardsCount > 0) { - filter.setMessage("card named " + card.getName() + " in the library of " + targetPlayer.getName()); - TargetCardInLibrary target = new TargetCardInLibrary(0, cardsCount, filter); - if (player.searchLibrary(target, game, targetPlayer.getId())) { - List targets = target.getTargets(); - for (UUID targetId : targets) { - Card targetCard = targetPlayer.getLibrary().getCard(targetId, game); - if (targetCard != null) { - player.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.LIBRARY); - } + filterNamedCard.setMessage("card named " + chosenCard.getName() + " in the library of " + owner.getName()); + TargetCardInLibrary targetCardInLibrary = new TargetCardInLibrary(0, Integer.MAX_VALUE, filterNamedCard); + if (controller.searchLibrary(targetCardInLibrary, game, owner.getId())) { + List targets = targetCardInLibrary.getTargets(); + for (UUID targetId : targets) { + Card targetCard = owner.getLibrary().getCard(targetId, game); + if (targetCard != null) { + controller.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.LIBRARY); } } - } else { - player.lookAtCards(targetPlayer.getName() + " library", cardsInLibrary, game); } - targetPlayer.shuffleLibrary(game); + owner.shuffleLibrary(game); return true; } } diff --git a/Mage.Sets/src/mage/sets/planarchaos/Extirpate.java b/Mage.Sets/src/mage/sets/planarchaos/Extirpate.java index 5dbdc3327d..ea6b63df1f 100644 --- a/Mage.Sets/src/mage/sets/planarchaos/Extirpate.java +++ b/Mage.Sets/src/mage/sets/planarchaos/Extirpate.java @@ -116,8 +116,8 @@ class ExtirpateEffect extends OneShotEffect { // Exile all cards with the same name // Building a card filter with the name - FilterCard filterNamedCards = new FilterCard(); - filterNamedCards.add(new NamePredicate(chosenCard.getName())); + FilterCard filterNamedCard = new FilterCard(); + filterNamedCard.add(new NamePredicate(chosenCard.getName())); // The cards you're searching for must be found and exiled if they're in the graveyard because it's a public zone. // Finding those cards in the hand and library is optional, because those zones are hidden (even if the hand is temporarily revealed). @@ -129,22 +129,28 @@ class ExtirpateEffect extends OneShotEffect { } // search cards in hand - TargetCardInHand targetCardsHand = new TargetCardInHand(0, Integer.MAX_VALUE, filterNamedCards); - controller.chooseTarget(outcome, owner.getGraveyard(), targetCardsHand, source, game); - for(UUID cardId: targetCardsHand.getTargets()) { - Card card = game.getCard(cardId); - if (card != null) { - controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.HAND); + filterNamedCard.setMessage("card named " + chosenCard.getName() + " in the hand of " + owner.getName()); + TargetCardInHand targetCardInHand = new TargetCardInHand(0, Integer.MAX_VALUE, filterNamedCard); + if (controller.choose(Outcome.Exile, owner.getHand(), targetCardInHand, game)) { + List targets = targetCardInHand.getTargets(); + for (UUID targetId : targets) { + Card targetCard = owner.getHand().get(targetId, game); + if (targetCard != null) { + controller.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.HAND); + } } } - + // search cards in Library - TargetCardInLibrary targetCardsLibrary = new TargetCardInLibrary(0, Integer.MAX_VALUE, filterNamedCards); - controller.searchLibrary(targetCardsLibrary, game, owner.getId()); - for(UUID cardId: targetCardsLibrary.getTargets()) { - Card card = game.getCard(cardId); - if (card != null) { - controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY); + filterNamedCard.setMessage("card named " + chosenCard.getName() + " in the library of " + owner.getName()); + TargetCardInLibrary targetCardInLibrary = new TargetCardInLibrary(0, Integer.MAX_VALUE, filterNamedCard); + if (controller.searchLibrary(targetCardInLibrary, game, owner.getId())) { + List targets = targetCardInLibrary.getTargets(); + for (UUID targetId : targets) { + Card targetCard = owner.getLibrary().getCard(targetId, game); + if (targetCard != null) { + controller.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.LIBRARY); + } } } owner.shuffleLibrary(game); diff --git a/Mage/src/mage/abilities/Ability.java b/Mage/src/mage/abilities/Ability.java index aab71dc8a9..887f45de75 100644 --- a/Mage/src/mage/abilities/Ability.java +++ b/Mage/src/mage/abilities/Ability.java @@ -371,7 +371,7 @@ public interface Ability extends Controllable, Serializable { boolean isInUseableZone(Game game, MageObject source, boolean checkLKI); /** - * Returns true if this ability has to be shown on top of the card. + * Returns true if this ability has to be shown as topmost of all the rules of the object * * @return */