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;
import java.util.List;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
@ -34,6 +36,7 @@ import mage.abilities.keyword.SplitSecondAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.SplitCard;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.SuperType;
@ -49,9 +52,6 @@ import mage.target.common.TargetCardInGraveyard;
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCardInLibrary;
import java.util.List;
import java.util.UUID;
/**
*
* @author jonubuu
@ -65,7 +65,7 @@ public class Extirpate extends CardImpl {
}
public Extirpate(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{B}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{B}");
// Split second
this.addAbility(new SplitSecondAbility());
@ -105,16 +105,17 @@ class ExtirpateEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
Card chosenCard = game.getCard(getTargetPointer().getFirst(game, source));
if (chosenCard != null && sourceObject != null && controller != null) {
if (chosenCard != null && sourceObject != null && controller != null) {
Player owner = game.getPlayer(chosenCard.getOwnerId());
if (owner == null) {
return false;
}
// Exile all cards with the same name
// Building a card filter with the name
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.
// Finding those cards in the hand and library is optional, because those zones are hidden (even if the hand is temporarily revealed).
@ -133,11 +134,11 @@ class ExtirpateEffect extends OneShotEffect {
for (UUID targetId : targets) {
Card targetCard = owner.getHand().get(targetId, game);
if (targetCard != null) {
controller.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.HAND, true);
controller.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.HAND, true);
}
}
}
// search cards in Library
filterNamedCard.setMessage("card named " + chosenCard.getName() + " in the library of " + owner.getName());
TargetCardInLibrary targetCardInLibrary = new TargetCardInLibrary(0, Integer.MAX_VALUE, filterNamedCard);
@ -146,7 +147,7 @@ class ExtirpateEffect extends OneShotEffect {
for (UUID targetId : targets) {
Card targetCard = owner.getLibrary().getCard(targetId, game);
if (targetCard != null) {
controller.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.LIBRARY, true);
controller.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.LIBRARY, true);
}
}
}
@ -155,5 +156,5 @@ class ExtirpateEffect extends OneShotEffect {
}
return false;
}
}

View file

@ -1,16 +1,16 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,32 +20,31 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.cards.h;
import mage.constants.CardType;
import mage.constants.Outcome;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.SplitCard;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.filter.FilterCard;
import mage.filter.common.FilterBasicLandCard;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer;
import mage.target.common.TargetCardInLibrary;
import java.util.List;
import java.util.UUID;
import mage.filter.predicate.mageobject.NamePredicate;
/**
*
* @author BetaSteward_at_googlemail.com
@ -53,7 +52,7 @@ import mage.filter.predicate.mageobject.NamePredicate;
public class HauntingEchoes extends CardImpl {
public HauntingEchoes(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{B}{B}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}{B}");
this.getSpellAbility().addTarget(new TargetPlayer());
this.getSpellAbility().addEffect(new HauntingEchoesEffect());
@ -87,18 +86,19 @@ class HauntingEchoesEffect extends OneShotEffect {
Player player = game.getPlayer(source.getControllerId());
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer != null) {
for (Card card: targetPlayer.getGraveyard().getCards(game)) {
for (Card card : targetPlayer.getGraveyard().getCards(game)) {
if (!filter.match(card, game)) {
card.moveToExile(null, "", source.getSourceId(), game);
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);
TargetCardInLibrary target = new TargetCardInLibrary(count, count, filterCard);
player.searchLibrary(target, game, targetPlayer.getId());
List<UUID> targets = target.getTargets();
for(UUID cardId : targets){
for (UUID cardId : targets) {
Card libraryCard = game.getCard(cardId);
if (libraryCard != null) {
libraryCard.moveToExile(null, "", source.getSourceId(), game);
@ -117,4 +117,4 @@ class HauntingEchoesEffect extends OneShotEffect {
return new HauntingEchoesEffect(this);
}
}
}

View file

@ -39,6 +39,7 @@ import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.CardsImpl;
import mage.cards.SplitCard;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.filter.FilterCard;
@ -56,8 +57,7 @@ import mage.target.common.TargetCardInLibrary;
public class InfernalTutor extends CardImpl {
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.
this.getSpellAbility().addEffect(new InfernalTutorEffect());
@ -67,7 +67,7 @@ public class InfernalTutor extends CardImpl {
HellbentCondition.instance,
"<br/><br/><i>Hellbent</i> - If you have no cards in hand, instead search your library for a card, put it into your hand, then shuffle your library");
this.getSpellAbility().addEffect(effect);
}
public InfernalTutor(final InfernalTutor card) {
@ -114,14 +114,15 @@ class InfernalTutorEffect extends OneShotEffect {
}
FilterCard filterCard;
if (cardToReveal != null) {
controller.revealCards("from hand :" + sourceObject.getName(), new CardsImpl(cardToReveal), game);
filterCard = new FilterCard("card named " + cardToReveal.getName());
filterCard.add(new NamePredicate(cardToReveal.getName()));
controller.revealCards("from hand :" + sourceObject.getName(), new CardsImpl(cardToReveal), game);
String nameToSearch = cardToReveal.isSplitCard() ? ((SplitCard) cardToReveal).getLeftHalfCard().getName() : cardToReveal.getName();
filterCard = new FilterCard("card named " + nameToSearch);
filterCard.add(new NamePredicate(nameToSearch));
} else {
filterCard = new FilterCard();
}
}
return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(filterCard), true, true).apply(game, source);
}
return true;
}

View file

@ -27,6 +27,7 @@
*/
package mage.cards.l;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
@ -46,8 +47,6 @@ import mage.target.TargetCard;
import mage.target.TargetPlayer;
import mage.target.common.TargetCardInLibrary;
import java.util.UUID;
/**
*
* @author jeffwadsworth
@ -55,7 +54,7 @@ import java.util.UUID;
public class Lobotomy extends CardImpl {
public Lobotomy(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{U}{B}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{U}{B}");
// Target player reveals his or her hand, then you choose a card other than a basic land card from it. Search that player's graveyard, hand, and library for all cards with the same name as the chosen card and exile them. Then that player shuffles his or her library.
this.getSpellAbility().addEffect(new LobotomyEffect());
@ -110,12 +109,12 @@ class LobotomyEffect extends OneShotEffect {
// Exile all cards with the same name
// Building a card filter with the name
FilterCard filterNamedCards = new FilterCard();
String nameToSearch = "---";// so no card matches
if (chosenCard != null) {
filterNamedCards.add(new NamePredicate(chosenCard.getName()));
nameToSearch = chosenCard.isSplitCard() ? ((SplitCard) chosenCard).getLeftHalfCard().getName() : 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();
// 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).

View file

@ -37,6 +37,7 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.cards.SplitCard;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
@ -58,8 +59,7 @@ import mage.target.common.TargetOpponent;
public class ReapIntellect extends CardImpl {
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.
this.getSpellAbility().addEffect(new ReapIntellectEffect());
@ -100,10 +100,10 @@ class ReapIntellectEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (targetPlayer != null && sourceObject != null && controller != null) {
// reveal hand of target player
// reveal hand of target player
targetPlayer.revealCards(sourceObject.getName(), targetPlayer.getHand(), game);
// Chose cards to exile from hand
Cards exiledCards = new CardsImpl();
int xCost = Math.min(source.getManaCostsToPay().getX(), targetPlayer.getHand().size());
@ -115,7 +115,7 @@ class ReapIntellectEffect extends OneShotEffect {
if (chosenCard != null) {
controller.moveCardToExileWithInfo(chosenCard, null, "", source.getSourceId(), game, Zone.HAND, true);
exiledCards.add(chosenCard);
}
}
}
// Exile other cards with the same name
// 4/15/2013 If you don't exile any cards from the player's hand, you don't search that player's library
@ -124,41 +124,41 @@ class ReapIntellectEffect extends OneShotEffect {
// Building a card filter with all names
ArrayList<NamePredicate> names = new ArrayList<>();
FilterCard filterNamedCards = new FilterCard();
for (Card card: exiledCards.getCards(game)) {
for (Card card : exiledCards.getCards(game)) {
if (exiledCards.size() == 1) {
filterNamedCards.add(new NamePredicate(card.getName()));
filterNamedCards.add(new NamePredicate(card.isSplitCard() ? ((SplitCard) card).getLeftHalfCard().getName() : card.getName()));
} else {
names.add(new NamePredicate(card.getName()));
names.add(new NamePredicate(card.isSplitCard() ? ((SplitCard) card).getLeftHalfCard().getName() : card.getName()));
}
}
if (exiledCards.size() > 1) {
filterNamedCards.add(Predicates.or(names));
}
// search cards in graveyard
TargetCardInGraveyard targetCardsGraveyard = new TargetCardInGraveyard(0, Integer.MAX_VALUE, filterNamedCards);
controller.chooseTarget(outcome, targetPlayer.getGraveyard(), targetCardsGraveyard, source, game);
for(UUID cardId: targetCardsGraveyard.getTargets()) {
for (UUID cardId : targetCardsGraveyard.getTargets()) {
Card card = game.getCard(cardId);
if (card != null) {
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.GRAVEYARD, true);
}
}
// search cards in hand
TargetCardInHand targetCardsHand = new TargetCardInHand(0, Integer.MAX_VALUE, filterNamedCards);
controller.chooseTarget(outcome, targetPlayer.getGraveyard(), targetCardsHand, source, game);
for(UUID cardId: targetCardsHand.getTargets()) {
for (UUID cardId : targetCardsHand.getTargets()) {
Card card = game.getCard(cardId);
if (card != null) {
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.HAND, true);
}
}
// search cards in Library
TargetCardInLibrary targetCardsLibrary = new TargetCardInLibrary(0, Integer.MAX_VALUE, filterNamedCards);
controller.searchLibrary(targetCardsLibrary, game, targetPlayer.getId());
for(UUID cardId: targetCardsLibrary.getTargets()) {
for (UUID cardId : targetCardsLibrary.getTargets()) {
Card card = game.getCard(cardId);
if (card != null) {
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY, true);

View file

@ -49,7 +49,6 @@ import mage.game.stack.Spell;
import mage.game.turn.TurnMod;
import mage.players.Player;
/**
*
* @author LevelX2
@ -57,15 +56,14 @@ import mage.players.Player;
public class SearchTheCity extends CardImpl {
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.
this.addAbility(new EntersBattlefieldTriggeredAbility(new SearchTheCityExileEffect()));
// Whenever you play a card with the same name as one of the exiled cards, 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.
this.addAbility(new SearchTheCityTriggeredAbility());
this.addAbility(new SearchTheCityTriggeredAbility());
}
public SearchTheCity(final SearchTheCity card) {
@ -78,7 +76,6 @@ public class SearchTheCity extends CardImpl {
}
}
class SearchTheCityExileEffect extends OneShotEffect {
public SearchTheCityExileEffect() {
@ -96,7 +93,7 @@ class SearchTheCityExileEffect extends OneShotEffect {
if (player != null) {
// move cards from library to exile
for (int i = 0; i < 5; i++) {
if (player != null && player.getLibrary().hasCards()) {
if (player.getLibrary().hasCards()) {
Card topCard = player.getLibrary().getFromTop(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 {
public SearchTheCityTriggeredAbility() {
@ -149,9 +145,9 @@ class SearchTheCityTriggeredAbility extends TriggeredAbilityImpl {
ExileZone searchTheCityExileZone = game.getExile().getExileZone(this.getSourceId());
FilterCard filter = new FilterCard();
filter.add(new NamePredicate(cardName));
if (searchTheCityExileZone.count(filter, game) > 0) {
this.getEffects().get(0).setValue("cardName",cardName);
this.getEffects().get(0).setValue("cardName", cardName);
return true;
}
}
@ -170,12 +166,11 @@ class SearchTheCityTriggeredAbility extends TriggeredAbilityImpl {
}
}
class SearchTheCityExiledCardToHandEffect extends OneShotEffect {
public SearchTheCityExiledCardToHandEffect() {
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) {
@ -187,7 +182,7 @@ class SearchTheCityExiledCardToHandEffect extends OneShotEffect {
String cardName = (String) this.getValue("cardName");
ExileZone searchTheCityExileZone = game.getExile().getExileZone(source.getSourceId());
if (cardName != null && searchTheCityExileZone != null) {
for (Card card :searchTheCityExileZone.getCards(game)) {
for (Card card : searchTheCityExileZone.getCards(game)) {
if (card.getName().equals(cardName)) {
if (card.moveToZone(Zone.HAND, source.getSourceId(), game, true)) {
game.informPlayers("Search the City: put " + card.getName() + " into owner's hand");
@ -212,4 +207,4 @@ class SearchTheCityExiledCardToHandEffect extends OneShotEffect {
public SearchTheCityExiledCardToHandEffect copy() {
return new SearchTheCityExiledCardToHandEffect(this);
}
}
}

View file

@ -36,6 +36,7 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.cards.SplitCard;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
@ -98,7 +99,8 @@ class SecretSalvageEffect extends OneShotEffect {
if (targetCard != null) {
controller.moveCards(targetCard, Zone.EXILED, source, game);
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);
if (controller.searchLibrary(target, game)) {
if (!target.getTargets().isEmpty()) {

View file

@ -37,6 +37,7 @@ import mage.abilities.keyword.FlyingAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.SplitCard;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
@ -57,7 +58,7 @@ import mage.target.common.TargetCardInLibrary;
public class ShimianSpecter extends CardImpl {
public ShimianSpecter(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{B}{B}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{B}{B}");
this.subtype.add("Specter");
this.power = new MageInt(2);
@ -65,7 +66,7 @@ public class ShimianSpecter extends CardImpl {
// Flying
this.addAbility(FlyingAbility.getInstance());
// Whenever Shimian Specter deals combat damage to a player, that player reveals his or her hand. You choose a nonland card from it. Search that player's graveyard, hand, and library for all cards with the same name as that card and exile them. Then that player shuffles his or her library.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new ShimianSpecterEffect(), false, true));
}
@ -103,26 +104,26 @@ class ShimianSpecterEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (targetPlayer != null && sourceObject != null && controller != null) {
// reveal hand of target player
// reveal hand of target player
targetPlayer.revealCards(sourceObject.getName(), targetPlayer.getHand(), game);
// You choose a nonland card from it
TargetCardInHand target = new TargetCardInHand(new FilterNonlandCard());
target.setNotTarget(true);
Card chosenCard = null;
if (controller.choose(Outcome.Benefit, targetPlayer.getHand(), target, game)) {
chosenCard = game.getCard(target.getFirstTarget());
}
}
// Exile all cards with the same name
// Building a card filter with the name
FilterCard filterNamedCards = new FilterCard();
String nameToSearch = "---";// so no card matches
if (chosenCard != null) {
filterNamedCards.add(new NamePredicate(chosenCard.getName()));
} else {
filterNamedCards.add(new NamePredicate("----")); // so no card matches
nameToSearch = chosenCard.isSplitCard() ? ((SplitCard) chosenCard).getLeftHalfCard().getName() : chosenCard.getName();
}
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.
// Finding those cards in the hand and library is optional, because those zones are hidden (even if the hand is temporarily revealed).
@ -137,20 +138,20 @@ class ShimianSpecterEffect extends OneShotEffect {
// search cards in hand
TargetCardInHand targetHandCards = new TargetCardInHand(0, Integer.MAX_VALUE, filterNamedCards);
controller.chooseTarget(outcome, targetPlayer.getHand(), targetHandCards, source, game);
for(UUID cardId: targetHandCards.getTargets()) {
for (UUID cardId : targetHandCards.getTargets()) {
Card card = game.getCard(cardId);
if (card != null) {
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.HAND, true);
}
}
}
}
// search cards in Library
// If the player has no nonland cards in his or her hand, you can still search that player's library and have him or her shuffle it.
if (chosenCard != null || controller.chooseUse(outcome, "Search library anyway?", source, game)) {
TargetCardInLibrary targetCardsLibrary = new TargetCardInLibrary(0, Integer.MAX_VALUE, filterNamedCards);
controller.searchLibrary(targetCardsLibrary, game, targetPlayer.getId());
for(UUID cardId: targetCardsLibrary.getTargets()) {
for (UUID cardId : targetCardsLibrary.getTargets()) {
Card card = game.getCard(cardId);
if (card != null) {
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY, true);

View file

@ -31,8 +31,6 @@ import java.util.HashSet;
import java.util.Map;
import java.util.Set;
import java.util.UUID;
import mage.constants.CardType;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
@ -44,6 +42,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.cards.SplitCard;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.common.FilterNonlandCard;
@ -59,7 +59,7 @@ import mage.target.common.TargetCardInHand;
public class SphinxOfTheChimes extends CardImpl {
public SphinxOfTheChimes(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{U}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{U}{U}");
this.subtype.add("Sphinx");
this.power = new MageInt(5);
@ -128,28 +128,25 @@ class TargetTwoNonLandCardsWithSameNameInHand extends TargetCardInHand {
Card chosenCard = cardsToCheck.get(entry.getKey(), game);
if (chosenCard != null) {
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);
}
}
}
}
}
else
{
} else {
for (UUID cardToCheck : cardsToCheck) {
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) {
newPossibleTargets.add(cardToCheck);
newPossibleTargets.add(cardToCheck);
}
}
}
return newPossibleTargets;
}
@Override
public boolean canChoose(UUID sourceControllerId, Game game) {
Cards cardsToCheck = new CardsImpl();
@ -158,11 +155,11 @@ class TargetTwoNonLandCardsWithSameNameInHand extends TargetCardInHand {
cardsToCheck.add(card.getId());
}
int possibleCards = 0;
for (UUID cardToCheck : cardsToCheck) {
for (Card card : cardsToCheck.getCards(game)) {
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) {
++possibleCards;
++possibleCards;
}
}
return possibleCards > 0;
@ -180,11 +177,11 @@ class TargetTwoNonLandCardsWithSameNameInHand extends TargetCardInHand {
}
} else {
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());
if (player.getHand().getCards(nameFilter, game).size() > 1) {
return true;
}
}
}
}
}

View file

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

View file

@ -27,6 +27,8 @@
*/
package mage.cards.s;
import java.util.List;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.*;
@ -45,9 +47,6 @@ import mage.target.common.TargetCardInGraveyard;
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCardInLibrary;
import java.util.List;
import java.util.UUID;
/**
*
* @author North
@ -61,7 +60,7 @@ public class SurgicalExtraction extends CardImpl {
}
public SurgicalExtraction(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.INSTANT},"{B/P}");
super(ownerId, setInfo, new CardType[]{CardType.INSTANT}, "{B/P}");
// 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.
@ -107,16 +106,14 @@ class SurgicalExtractionEffect extends OneShotEffect {
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();
cardsInLibrary.addAll(owner.getLibrary().getCards(game));
String nameToSearch = chosenCard.isSplitCard() ? ((SplitCard) chosenCard).getLeftHalfCard().getName() : chosenCard.getName();
FilterCard filterNamedCard = new FilterCard("card named " + nameToSearch);
filterNamedCard.add(new NamePredicate(nameToSearch));
// cards in Graveyard
int cardsCount = owner.getGraveyard().count(filterNamedCard, game);
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);
if (controller.chooseTarget(Outcome.Exile, owner.getGraveyard(), target, source, game)) {
List<UUID> targets = target.getTargets();
@ -130,27 +127,27 @@ class SurgicalExtractionEffect extends OneShotEffect {
}
// 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);
if (controller.chooseTarget(Outcome.Exile, owner.getHand(), targetCardInHand, source, game)) {
List<UUID> 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, true);
controller.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.HAND, true);
}
}
}
// 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);
if (controller.searchLibrary(targetCardInLibrary, game, owner.getId())) {
List<UUID> 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, true);
controller.moveCardToExileWithInfo(targetCard, null, "", source.getSourceId(), game, Zone.LIBRARY, true);
}
}
}

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);
}
}