Fixed some problems that searching for split cards did not always work (e.g. Surgical Extraction).

This commit is contained in:
LevelX2 2017-07-09 19:05:03 +02:00
parent ad645b0af5
commit 8b82e240c8
12 changed files with 172 additions and 123 deletions

View file

@ -27,6 +27,8 @@
*/ */
package mage.cards.e; package mage.cards.e;
import java.util.List;
import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -34,6 +36,7 @@ import mage.abilities.keyword.SplitSecondAbility;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.cards.SplitCard;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.SuperType; import mage.constants.SuperType;
@ -49,9 +52,6 @@ import mage.target.common.TargetCardInGraveyard;
import mage.target.common.TargetCardInHand; import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetCardInLibrary;
import java.util.List;
import java.util.UUID;
/** /**
* *
* @author jonubuu * @author jonubuu
@ -114,7 +114,8 @@ class ExtirpateEffect extends OneShotEffect {
// Exile all cards with the same name // Exile all cards with the same name
// Building a card filter with the name // Building a card filter with the name
FilterCard filterNamedCard = new FilterCard(); FilterCard filterNamedCard = new FilterCard();
filterNamedCard.add(new NamePredicate(chosenCard.getName())); String nameToSearch = chosenCard.isSplitCard() ? ((SplitCard) chosenCard).getLeftHalfCard().getName() : chosenCard.getName();
filterNamedCard.add(new NamePredicate(nameToSearch));
// The cards you're searching for must be found and exiled if they're in the graveyard because it's a public zone. // 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). // Finding those cards in the hand and library is optional, because those zones are hidden (even if the hand is temporarily revealed).

View file

@ -25,27 +25,26 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.cards.h; package mage.cards.h;
import mage.constants.CardType; import java.util.List;
import mage.constants.Outcome; import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.cards.SplitCard;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.common.FilterBasicLandCard; import mage.filter.common.FilterBasicLandCard;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetCardInLibrary;
import java.util.List;
import java.util.UUID;
import mage.filter.predicate.mageobject.NamePredicate;
/** /**
* *
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
@ -92,7 +91,8 @@ class HauntingEchoesEffect extends OneShotEffect {
card.moveToExile(null, "", source.getSourceId(), game); card.moveToExile(null, "", source.getSourceId(), game);
FilterCard filterCard = new FilterCard("cards named " + card.getName()); FilterCard filterCard = new FilterCard("cards named " + card.getName());
filterCard.add(new NamePredicate(card.getName())); String nameToSearch = card.isSplitCard() ? ((SplitCard) card).getLeftHalfCard().getName() : card.getName();
filterCard.add(new NamePredicate(nameToSearch));
int count = targetPlayer.getLibrary().count(filterCard, game); int count = targetPlayer.getLibrary().count(filterCard, game);
TargetCardInLibrary target = new TargetCardInLibrary(count, count, filterCard); TargetCardInLibrary target = new TargetCardInLibrary(count, count, filterCard);

View file

@ -39,6 +39,7 @@ import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.cards.CardsImpl; import mage.cards.CardsImpl;
import mage.cards.SplitCard;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.filter.FilterCard; import mage.filter.FilterCard;
@ -58,7 +59,6 @@ public class InfernalTutor extends CardImpl {
public InfernalTutor(UUID ownerId, CardSetInfo setInfo) { public InfernalTutor(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{B}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{B}");
// Reveal a card from your hand. Search your library for a card with the same name as that card, reveal it, put it into your hand, then shuffle your library. // Reveal a card from your hand. Search your library for a card with the same name as that card, reveal it, put it into your hand, then shuffle your library.
this.getSpellAbility().addEffect(new InfernalTutorEffect()); this.getSpellAbility().addEffect(new InfernalTutorEffect());
// Hellbent - If you have no cards in hand, instead search your library for a card, put it into your hand, then shuffle your library. // Hellbent - If you have no cards in hand, instead search your library for a card, put it into your hand, then shuffle your library.
@ -115,8 +115,9 @@ class InfernalTutorEffect extends OneShotEffect {
FilterCard filterCard; FilterCard filterCard;
if (cardToReveal != null) { if (cardToReveal != null) {
controller.revealCards("from hand :" + sourceObject.getName(), new CardsImpl(cardToReveal), game); controller.revealCards("from hand :" + sourceObject.getName(), new CardsImpl(cardToReveal), game);
filterCard = new FilterCard("card named " + cardToReveal.getName()); String nameToSearch = cardToReveal.isSplitCard() ? ((SplitCard) cardToReveal).getLeftHalfCard().getName() : cardToReveal.getName();
filterCard.add(new NamePredicate(cardToReveal.getName())); filterCard = new FilterCard("card named " + nameToSearch);
filterCard.add(new NamePredicate(nameToSearch));
} else { } else {
filterCard = new FilterCard(); filterCard = new FilterCard();
} }

View file

@ -27,6 +27,7 @@
*/ */
package mage.cards.l; package mage.cards.l;
import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
@ -46,8 +47,6 @@ import mage.target.TargetCard;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetCardInLibrary;
import java.util.UUID;
/** /**
* *
* @author jeffwadsworth * @author jeffwadsworth
@ -110,12 +109,12 @@ class LobotomyEffect extends OneShotEffect {
// Exile all cards with the same name // Exile all cards with the same name
// Building a card filter with the name // Building a card filter with the name
FilterCard filterNamedCards = new FilterCard(); FilterCard filterNamedCards = new FilterCard();
String nameToSearch = "---";// so no card matches
if (chosenCard != null) { if (chosenCard != null) {
filterNamedCards.add(new NamePredicate(chosenCard.getName())); nameToSearch = chosenCard.isSplitCard() ? ((SplitCard) chosenCard).getLeftHalfCard().getName() : chosenCard.getName();
filterNamedCards.setMessage("cards named " + chosenCard.getName()); filterNamedCards.setMessage("cards named " + chosenCard.getName());
} else {
filterNamedCards.add(new NamePredicate("----")); // so no card matches
} }
filterNamedCards.add(new NamePredicate(nameToSearch));
Cards cardsToExile = new CardsImpl(); Cards cardsToExile = new CardsImpl();
// The cards you're searching for must be found and exiled if they're in the graveyard because it's a public zone. // 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). // Finding those cards in the hand and library is optional, because those zones are hidden (even if the hand is temporarily revealed).

View file

@ -37,6 +37,7 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.cards.Cards; import mage.cards.Cards;
import mage.cards.CardsImpl; import mage.cards.CardsImpl;
import mage.cards.SplitCard;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
@ -60,7 +61,6 @@ public class ReapIntellect extends CardImpl {
public ReapIntellect(UUID ownerId, CardSetInfo setInfo) { public ReapIntellect(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{2}{U}{B}"); super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{2}{U}{B}");
// Target opponent reveals his or her hand. You choose up to X nonland cards from it and exile them. For each card exiled this way, search that player's graveyard, hand, and library for any number of cards with the same name as that card and exile them. Then that player shuffles his or her library. // Target opponent reveals his or her hand. You choose up to X nonland cards from it and exile them. For each card exiled this way, search that player's graveyard, hand, and library for any number of cards with the same name as that card and exile them. Then that player shuffles his or her library.
this.getSpellAbility().addEffect(new ReapIntellectEffect()); this.getSpellAbility().addEffect(new ReapIntellectEffect());
this.getSpellAbility().addTarget(new TargetOpponent()); this.getSpellAbility().addTarget(new TargetOpponent());
@ -126,9 +126,9 @@ class ReapIntellectEffect extends OneShotEffect {
FilterCard filterNamedCards = new FilterCard(); FilterCard filterNamedCards = new FilterCard();
for (Card card : exiledCards.getCards(game)) { for (Card card : exiledCards.getCards(game)) {
if (exiledCards.size() == 1) { if (exiledCards.size() == 1) {
filterNamedCards.add(new NamePredicate(card.getName())); filterNamedCards.add(new NamePredicate(card.isSplitCard() ? ((SplitCard) card).getLeftHalfCard().getName() : card.getName()));
} else { } else {
names.add(new NamePredicate(card.getName())); names.add(new NamePredicate(card.isSplitCard() ? ((SplitCard) card).getLeftHalfCard().getName() : card.getName()));
} }
} }
if (exiledCards.size() > 1) { if (exiledCards.size() > 1) {

View file

@ -49,7 +49,6 @@ import mage.game.stack.Spell;
import mage.game.turn.TurnMod; import mage.game.turn.TurnMod;
import mage.players.Player; import mage.players.Player;
/** /**
* *
* @author LevelX2 * @author LevelX2
@ -59,7 +58,6 @@ public class SearchTheCity extends CardImpl {
public SearchTheCity(UUID ownerId, CardSetInfo setInfo) { public SearchTheCity(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{4}{U}"); super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{4}{U}");
// When Search the City enters the battlefield, exile the top five cards of your library. // When Search the City enters the battlefield, exile the top five cards of your library.
this.addAbility(new EntersBattlefieldTriggeredAbility(new SearchTheCityExileEffect())); this.addAbility(new EntersBattlefieldTriggeredAbility(new SearchTheCityExileEffect()));
@ -78,7 +76,6 @@ public class SearchTheCity extends CardImpl {
} }
} }
class SearchTheCityExileEffect extends OneShotEffect { class SearchTheCityExileEffect extends OneShotEffect {
public SearchTheCityExileEffect() { public SearchTheCityExileEffect() {
@ -96,7 +93,7 @@ class SearchTheCityExileEffect extends OneShotEffect {
if (player != null) { if (player != null) {
// move cards from library to exile // move cards from library to exile
for (int i = 0; i < 5; i++) { for (int i = 0; i < 5; i++) {
if (player != null && player.getLibrary().hasCards()) { if (player.getLibrary().hasCards()) {
Card topCard = player.getLibrary().getFromTop(game); Card topCard = player.getLibrary().getFromTop(game);
topCard.moveToExile(source.getSourceId(), "Cards exiled by Search the City", source.getSourceId(), game); topCard.moveToExile(source.getSourceId(), "Cards exiled by Search the City", source.getSourceId(), game);
} }
@ -112,7 +109,6 @@ class SearchTheCityExileEffect extends OneShotEffect {
} }
} }
class SearchTheCityTriggeredAbility extends TriggeredAbilityImpl { class SearchTheCityTriggeredAbility extends TriggeredAbilityImpl {
public SearchTheCityTriggeredAbility() { public SearchTheCityTriggeredAbility() {
@ -170,12 +166,11 @@ class SearchTheCityTriggeredAbility extends TriggeredAbilityImpl {
} }
} }
class SearchTheCityExiledCardToHandEffect extends OneShotEffect { class SearchTheCityExiledCardToHandEffect extends OneShotEffect {
public SearchTheCityExiledCardToHandEffect() { public SearchTheCityExiledCardToHandEffect() {
super(Outcome.DrawCard); super(Outcome.DrawCard);
staticText = "you may put one of those cards with that name into its owner's hand. Then if there are no cards exiled with Search the City, sacrifice it. If you do, take an extra turn after this one"; staticText = "you may put one of those cards with that name into its owner's hand. Then if there are no cards exiled with {this}, sacrifice it. If you do, take an extra turn after this one";
} }
public SearchTheCityExiledCardToHandEffect(final SearchTheCityExiledCardToHandEffect effect) { public SearchTheCityExiledCardToHandEffect(final SearchTheCityExiledCardToHandEffect effect) {

View file

@ -36,6 +36,7 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.cards.Cards; import mage.cards.Cards;
import mage.cards.CardsImpl; import mage.cards.CardsImpl;
import mage.cards.SplitCard;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
@ -98,7 +99,8 @@ class SecretSalvageEffect extends OneShotEffect {
if (targetCard != null) { if (targetCard != null) {
controller.moveCards(targetCard, Zone.EXILED, source, game); controller.moveCards(targetCard, Zone.EXILED, source, game);
FilterCard nameFilter = new FilterCard(); FilterCard nameFilter = new FilterCard();
nameFilter.add(new NamePredicate(targetCard.getName())); String nameToSearch = targetCard.isSplitCard() ? ((SplitCard) targetCard).getLeftHalfCard().getName() : targetCard.getName();
nameFilter.add(new NamePredicate(nameToSearch));
TargetCardInLibrary target = new TargetCardInLibrary(0, Integer.MAX_VALUE, nameFilter); TargetCardInLibrary target = new TargetCardInLibrary(0, Integer.MAX_VALUE, nameFilter);
if (controller.searchLibrary(target, game)) { if (controller.searchLibrary(target, game)) {
if (!target.getTargets().isEmpty()) { if (!target.getTargets().isEmpty()) {

View file

@ -37,6 +37,7 @@ import mage.abilities.keyword.FlyingAbility;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.cards.SplitCard;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Zone; import mage.constants.Zone;
@ -118,11 +119,11 @@ class ShimianSpecterEffect extends OneShotEffect {
// Exile all cards with the same name // Exile all cards with the same name
// Building a card filter with the name // Building a card filter with the name
FilterCard filterNamedCards = new FilterCard(); FilterCard filterNamedCards = new FilterCard();
String nameToSearch = "---";// so no card matches
if (chosenCard != null) { if (chosenCard != null) {
filterNamedCards.add(new NamePredicate(chosenCard.getName())); nameToSearch = chosenCard.isSplitCard() ? ((SplitCard) chosenCard).getLeftHalfCard().getName() : chosenCard.getName();
} else {
filterNamedCards.add(new NamePredicate("----")); // so no card matches
} }
filterNamedCards.add(new NamePredicate(nameToSearch));
// The cards you're searching for must be found and exiled if they're in the graveyard because it's a public zone. // 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). // Finding those cards in the hand and library is optional, because those zones are hidden (even if the hand is temporarily revealed).

View file

@ -31,8 +31,6 @@ import java.util.HashSet;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.constants.CardType;
import mage.MageInt; import mage.MageInt;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility; import mage.abilities.common.SimpleActivatedAbility;
@ -44,6 +42,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo; import mage.cards.CardSetInfo;
import mage.cards.Cards; import mage.cards.Cards;
import mage.cards.CardsImpl; import mage.cards.CardsImpl;
import mage.cards.SplitCard;
import mage.constants.CardType;
import mage.constants.Zone; import mage.constants.Zone;
import mage.filter.FilterCard; import mage.filter.FilterCard;
import mage.filter.common.FilterNonlandCard; import mage.filter.common.FilterNonlandCard;
@ -128,19 +128,17 @@ class TargetTwoNonLandCardsWithSameNameInHand extends TargetCardInHand {
Card chosenCard = cardsToCheck.get(entry.getKey(), game); Card chosenCard = cardsToCheck.get(entry.getKey(), game);
if (chosenCard != null) { if (chosenCard != null) {
for (UUID cardToCheck : cardsToCheck) { for (UUID cardToCheck : cardsToCheck) {
if (!cardToCheck.equals(chosenCard.getId()) && chosenCard.getName().equals(game.getCard(cardToCheck).getName())) if (!cardToCheck.equals(chosenCard.getId()) && chosenCard.getName().equals(game.getCard(cardToCheck).getName())) {
{
newPossibleTargets.add(cardToCheck); newPossibleTargets.add(cardToCheck);
} }
} }
} }
} }
} } else {
else
{
for (UUID cardToCheck : cardsToCheck) { for (UUID cardToCheck : cardsToCheck) {
FilterCard nameFilter = new FilterCard(); FilterCard nameFilter = new FilterCard();
nameFilter.add(new NamePredicate(game.getCard(cardToCheck).getName())); Card card = game.getCard(cardToCheck);
nameFilter.add(new NamePredicate(card.isSplitCard() ? ((SplitCard) card).getLeftHalfCard().getName() : card.getName()));
if (cardsToCheck.count(nameFilter, game) > 1) { if (cardsToCheck.count(nameFilter, game) > 1) {
newPossibleTargets.add(cardToCheck); newPossibleTargets.add(cardToCheck);
} }
@ -149,7 +147,6 @@ class TargetTwoNonLandCardsWithSameNameInHand extends TargetCardInHand {
return newPossibleTargets; return newPossibleTargets;
} }
@Override @Override
public boolean canChoose(UUID sourceControllerId, Game game) { public boolean canChoose(UUID sourceControllerId, Game game) {
Cards cardsToCheck = new CardsImpl(); Cards cardsToCheck = new CardsImpl();
@ -158,9 +155,9 @@ class TargetTwoNonLandCardsWithSameNameInHand extends TargetCardInHand {
cardsToCheck.add(card.getId()); cardsToCheck.add(card.getId());
} }
int possibleCards = 0; int possibleCards = 0;
for (UUID cardToCheck : cardsToCheck) { for (Card card : cardsToCheck.getCards(game)) {
FilterCard nameFilter = new FilterCard(); FilterCard nameFilter = new FilterCard();
nameFilter.add(new NamePredicate(game.getCard(cardToCheck).getName())); nameFilter.add(new NamePredicate(card.isSplitCard() ? ((SplitCard) card).getLeftHalfCard().getName() : card.getName()));
if (cardsToCheck.count(nameFilter, game) > 1) { if (cardsToCheck.count(nameFilter, game) > 1) {
++possibleCards; ++possibleCards;
} }
@ -180,7 +177,7 @@ class TargetTwoNonLandCardsWithSameNameInHand extends TargetCardInHand {
} }
} else { } else {
FilterCard nameFilter = new FilterCard(); FilterCard nameFilter = new FilterCard();
nameFilter.add(new NamePredicate(card.getName())); nameFilter.add(new NamePredicate(card.isSplitCard() ? ((SplitCard) card).getLeftHalfCard().getName() : card.getName()));
Player player = game.getPlayer(card.getOwnerId()); Player player = game.getPlayer(card.getOwnerId());
if (player.getHand().getCards(nameFilter, game).size() > 1) { if (player.getHand().getCards(nameFilter, game).size() > 1) {
return true; return true;

View file

@ -25,9 +25,9 @@
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
package mage.cards.s; package mage.cards.s;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility; import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
@ -51,8 +51,6 @@ import mage.game.permanent.Permanent;
import mage.players.Player; import mage.players.Player;
import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetCardInLibrary;
import java.util.UUID;
/** /**
* *
* @author Loki * @author Loki
@ -79,6 +77,7 @@ public class StrataScythe extends CardImpl {
} }
class StrataScytheImprintEffect extends OneShotEffect { class StrataScytheImprintEffect extends OneShotEffect {
StrataScytheImprintEffect() { StrataScytheImprintEffect() {
super(Outcome.Exile); super(Outcome.Exile);
staticText = "search your library for a land card, exile it, then shuffle your library"; staticText = "search your library for a land card, exile it, then shuffle your library";
@ -91,8 +90,9 @@ class StrataScytheImprintEffect extends OneShotEffect {
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId()); Player player = game.getPlayer(source.getControllerId());
if (player == null) if (player == null) {
return false; return false;
}
TargetCardInLibrary target = new TargetCardInLibrary(new FilterLandCard()); TargetCardInLibrary target = new TargetCardInLibrary(new FilterLandCard());
if (player.searchLibrary(target, game)) { if (player.searchLibrary(target, game)) {
if (!target.getTargets().isEmpty()) { if (!target.getTargets().isEmpty()) {
@ -119,7 +119,8 @@ class StrataScytheImprintEffect extends OneShotEffect {
} }
class SameNameAsExiledCountValue implements DynamicValue { class SameNameAsExiledCountValue implements DynamicValue {
private static SameNameAsExiledCountValue instance = new SameNameAsExiledCountValue();
private static final SameNameAsExiledCountValue instance = new SameNameAsExiledCountValue();
public static SameNameAsExiledCountValue getInstance() { public static SameNameAsExiledCountValue getInstance() {
return instance; return instance;

View file

@ -27,6 +27,8 @@
*/ */
package mage.cards.s; package mage.cards.s;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect; import mage.abilities.effects.OneShotEffect;
import mage.cards.*; import mage.cards.*;
@ -45,9 +47,6 @@ import mage.target.common.TargetCardInGraveyard;
import mage.target.common.TargetCardInHand; import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCardInLibrary; import mage.target.common.TargetCardInLibrary;
import java.util.List;
import java.util.UUID;
/** /**
* *
* @author North * @author North
@ -107,16 +106,14 @@ class SurgicalExtractionEffect extends OneShotEffect {
if (chosenCard != null && controller != null) { if (chosenCard != null && controller != null) {
Player owner = game.getPlayer(chosenCard.getOwnerId()); Player owner = game.getPlayer(chosenCard.getOwnerId());
if (owner != null) { if (owner != null) {
FilterCard filterNamedCard = new FilterCard("card named " + chosenCard.getName()); String nameToSearch = chosenCard.isSplitCard() ? ((SplitCard) chosenCard).getLeftHalfCard().getName() : chosenCard.getName();
filterNamedCard.add(new NamePredicate(chosenCard.getName())); FilterCard filterNamedCard = new FilterCard("card named " + nameToSearch);
filterNamedCard.add(new NamePredicate(nameToSearch));
Cards cardsInLibrary = new CardsImpl();
cardsInLibrary.addAll(owner.getLibrary().getCards(game));
// cards in Graveyard // cards in Graveyard
int cardsCount = owner.getGraveyard().count(filterNamedCard, game); int cardsCount = owner.getGraveyard().count(filterNamedCard, game);
if (cardsCount > 0) { if (cardsCount > 0) {
filterNamedCard.setMessage("card named " + chosenCard.getName() + " in the graveyard of " + owner.getName()); filterNamedCard.setMessage("card named " + nameToSearch + " in the graveyard of " + owner.getName());
TargetCardInGraveyard target = new TargetCardInGraveyard(0, cardsCount, filterNamedCard); TargetCardInGraveyard target = new TargetCardInGraveyard(0, cardsCount, filterNamedCard);
if (controller.chooseTarget(Outcome.Exile, owner.getGraveyard(), target, source, game)) { if (controller.chooseTarget(Outcome.Exile, owner.getGraveyard(), target, source, game)) {
List<UUID> targets = target.getTargets(); List<UUID> targets = target.getTargets();
@ -130,7 +127,7 @@ class SurgicalExtractionEffect extends OneShotEffect {
} }
// cards in Hand // cards in Hand
filterNamedCard.setMessage("card named " + chosenCard.getName() + " in the hand of " + owner.getName()); filterNamedCard.setMessage("card named " + nameToSearch + " in the hand of " + owner.getName());
TargetCardInHand targetCardInHand = new TargetCardInHand(0, Integer.MAX_VALUE, filterNamedCard); TargetCardInHand targetCardInHand = new TargetCardInHand(0, Integer.MAX_VALUE, filterNamedCard);
if (controller.chooseTarget(Outcome.Exile, owner.getHand(), targetCardInHand, source, game)) { if (controller.chooseTarget(Outcome.Exile, owner.getHand(), targetCardInHand, source, game)) {
List<UUID> targets = targetCardInHand.getTargets(); List<UUID> targets = targetCardInHand.getTargets();
@ -143,7 +140,7 @@ class SurgicalExtractionEffect extends OneShotEffect {
} }
// cards in Library // cards in Library
filterNamedCard.setMessage("card named " + chosenCard.getName() + " in the library of " + owner.getName()); filterNamedCard.setMessage("card named " + nameToSearch + " in the library of " + owner.getName());
TargetCardInLibrary targetCardInLibrary = new TargetCardInLibrary(0, Integer.MAX_VALUE, filterNamedCard); TargetCardInLibrary targetCardInLibrary = new TargetCardInLibrary(0, Integer.MAX_VALUE, filterNamedCard);
if (controller.searchLibrary(targetCardInLibrary, game, owner.getId())) { if (controller.searchLibrary(targetCardInLibrary, game, owner.getId())) {
List<UUID> targets = targetCardInLibrary.getTargets(); List<UUID> targets = targetCardInLibrary.getTargets();

View file

@ -0,0 +1,55 @@
/*
* To change this license header, choose License Headers in Project Properties.
* To change this template file, choose Tools | Templates
* and open the template in the editor.
*/
package org.mage.test.cards.abilities.oneshot.exile;
import mage.constants.PhaseStep;
import mage.constants.Zone;
import org.junit.Test;
import org.mage.test.serverside.base.CardTestPlayerBase;
/**
*
* @author LevelX2
*/
public class SurgicalExtractionTest extends CardTestPlayerBase {
/**
* I noticed that surgical extraction did not allow me to select any cards
* to exile when I targeted breaking // entering. It did however allow my
* opponent to target lingering souls so it could be a split card
* interaction or just a random glitch.
*/
@Test
public void testSearchAndExileSplitCards() {
// Choose target card in a graveyard other than a basic land card. Search its owner's graveyard,
// hand, and library for any number of cards with the same name as that card and exile them.
// Then that player shuffles his or her library.
addCard(Zone.HAND, playerA, "Surgical Extraction", 1); // Instant {B/P}
addCard(Zone.BATTLEFIELD, playerA, "Swamp", 2);
addCard(Zone.GRAVEYARD, playerB, "Breaking // Entering", 2);
addCard(Zone.HAND, playerB, "Breaking // Entering", 1);
addCard(Zone.LIBRARY, playerB, "Breaking // Entering", 1);
castSpell(1, PhaseStep.PRECOMBAT_MAIN, playerA, "Surgical Extraction", "Breaking // Entering");
addTarget(playerA, "Breaking // Entering^Breaking // Entering");
addTarget(playerA, "Breaking // Entering");
setChoice(playerA, "Breaking // Entering");
setStopAt(1, PhaseStep.BEGIN_COMBAT);
execute();
assertGraveyardCount(playerA, "Surgical Extraction", 1);
assertGraveyardCount(playerB, "Breaking // Entering", 0);
assertLibraryCount(playerB, "Breaking // Entering", 0);
assertHandCount(playerB, "Breaking // Entering", 0);
assertExileCount(playerB, "Breaking // Entering", 4);
}
}