From a3065b703a8e845d6d73abffa67799fed87accb2 Mon Sep 17 00:00:00 2001 From: LevelX2 Date: Wed, 20 May 2015 17:17:42 +0200 Subject: [PATCH] * Fixed that named searches (e.g. Surgical Extraction) work also if the selected card is a split card. --- .../mage/sets/dragonsmaze/BreakingEntering.java | 8 -------- .../sets/newphyrexia/SurgicalExtraction.java | 10 +++++----- .../sets/returntoravnica/EpicExperiment.java | 17 ++++++++--------- .../predicate/mageobject/NamePredicate.java | 8 +++++++- 4 files changed, 20 insertions(+), 23 deletions(-) diff --git a/Mage.Sets/src/mage/sets/dragonsmaze/BreakingEntering.java b/Mage.Sets/src/mage/sets/dragonsmaze/BreakingEntering.java index 967b50ce05..49ed215dd9 100644 --- a/Mage.Sets/src/mage/sets/dragonsmaze/BreakingEntering.java +++ b/Mage.Sets/src/mage/sets/dragonsmaze/BreakingEntering.java @@ -63,21 +63,13 @@ public class BreakingEntering extends SplitCard { super(ownerId, 124, "Breaking", "Entering", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{U}{B}", "{4}{B}{R}", true); this.expansionSetCode = "DGM"; - this.color.setBlue(true); - this.color.setBlack(true); - this.color.setRed(true); - // Breaking // Target player puts the top eight cards of his or her library into his or her graveyard. - getLeftHalfCard().getColor().setBlue(true); - getLeftHalfCard().getColor().setBlack(true); getLeftHalfCard().getSpellAbility().addEffect(new PutTopCardOfLibraryIntoGraveTargetEffect(8)); getLeftHalfCard().getSpellAbility().addTarget(new TargetPlayer()); // Entering // Put a creature card from a graveyard onto the battlefield under your control. It gains haste until end of turn. - getRightHalfCard().getColor().setRed(true); - getRightHalfCard().getColor().setBlack(true); getRightHalfCard().getSpellAbility().addEffect(new EnteringReturnFromGraveyardToBattlefieldEffect()); } diff --git a/Mage.Sets/src/mage/sets/newphyrexia/SurgicalExtraction.java b/Mage.Sets/src/mage/sets/newphyrexia/SurgicalExtraction.java index a4e5255fdb..014ab94a02 100644 --- a/Mage.Sets/src/mage/sets/newphyrexia/SurgicalExtraction.java +++ b/Mage.Sets/src/mage/sets/newphyrexia/SurgicalExtraction.java @@ -119,9 +119,9 @@ class SurgicalExtractionEffect extends OneShotEffect { // cards in Graveyard int cardsCount = owner.getGraveyard().count(filterNamedCard, game); if (cardsCount > 0) { - filterNamedCard.setMessage("card named " + chosenCard.getLogName() + " in the graveyard of " + owner.getLogName()); + 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)) { + if (controller.chooseTarget(Outcome.Exile, owner.getGraveyard(), target, source, game)) { List targets = target.getTargets(); for (UUID targetId : targets) { Card targetCard = owner.getGraveyard().get(targetId, game); @@ -133,9 +133,9 @@ class SurgicalExtractionEffect extends OneShotEffect { } // cards in Hand - filterNamedCard.setMessage("card named " + chosenCard.getLogName() + " in the hand of " + owner.getLogName()); + 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)) { + if (controller.chooseTarget(Outcome.Exile, owner.getHand(), targetCardInHand, source, game)) { List targets = targetCardInHand.getTargets(); for (UUID targetId : targets) { Card targetCard = owner.getHand().get(targetId, game); @@ -146,7 +146,7 @@ class SurgicalExtractionEffect extends OneShotEffect { } // cards in Library - filterNamedCard.setMessage("card named " + chosenCard.getLogName() + " in the library of " + owner.getLogName()); + 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(); diff --git a/Mage.Sets/src/mage/sets/returntoravnica/EpicExperiment.java b/Mage.Sets/src/mage/sets/returntoravnica/EpicExperiment.java index a630ab1c42..37e9c1443f 100644 --- a/Mage.Sets/src/mage/sets/returntoravnica/EpicExperiment.java +++ b/Mage.Sets/src/mage/sets/returntoravnica/EpicExperiment.java @@ -27,7 +27,9 @@ */ package mage.sets.returntoravnica; +import java.util.ArrayList; import java.util.UUID; +import mage.MageObject; import mage.abilities.Ability; import mage.abilities.effects.OneShotEffect; import mage.cards.Card; @@ -56,7 +58,6 @@ public class EpicExperiment extends CardImpl { super(ownerId, 159, "Epic Experiment", Rarity.MYTHIC, new CardType[]{CardType.SORCERY}, "{X}{U}{R}"); this.expansionSetCode = "RTR"; - // Exile the top X cards of your library. For each instant and sorcery card with // converted mana cost X or less among them, you may cast that card without paying // its mana cost. Then put all cards exiled this way that weren't cast into your graveyard. @@ -94,12 +95,13 @@ class EpicExperimentEffect extends OneShotEffect { @Override public boolean apply(Game game, Ability source) { Player controller = game.getPlayer(source.getControllerId()); - if (controller != null) { + MageObject sourceObject = source.getSourceObject(game); + if (controller != null && sourceObject != null) { // move cards from library to exile for (int i = 0; i < source.getManaCostsToPay().getX(); i++) { if (controller.getLibrary().size() > 0) { Card topCard = controller.getLibrary().getFromTop(game); - controller.moveCardToExileWithInfo(topCard, source.getSourceId(), "Cards exiled by Epic Experiment", source.getSourceId(), game, Zone.LIBRARY, true); + controller.moveCardToExileWithInfo(topCard, source.getSourceId(), "Cards exiled by " + sourceObject.getName(), source.getSourceId(), game, Zone.LIBRARY, true); } } // cast the possible cards without paying the mana @@ -108,13 +110,12 @@ class EpicExperimentEffect extends OneShotEffect { filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, source.getManaCostsToPay().getX() + 1)); filter.setMessage("instant and sorcery cards with converted mana cost "+ source.getManaCostsToPay().getX() +" or less"); while (epicExperimentExileZone != null && epicExperimentExileZone.count(filter, game) > 0 - && controller.chooseUse(Outcome.PlayForFree, "Cast cards exiled with Epic Experiment without paying its mana cost?", game)) { + && controller.chooseUse(Outcome.PlayForFree, "Cast cards exiled with " + sourceObject.getLogName() + " without paying its mana cost?", game)) { TargetCardInExile target = new TargetCardInExile(filter, source.getSourceId()); while (epicExperimentExileZone.count(filter, game) > 0 && controller.choose(Outcome.PlayForFree, epicExperimentExileZone, target, game)) { Card card = game.getCard(target.getFirstTarget()); if (card != null) { - if (controller.cast(card.getSpellAbility(), game, true)) - { + if (controller.cast(card.getSpellAbility(), game, true)) { game.getExile().removeCard(card, game); } } @@ -124,9 +125,7 @@ class EpicExperimentEffect extends OneShotEffect { // move cards not cast to graveyard ExileZone exile = game.getExile().getExileZone(source.getSourceId()); if (exile != null) { - for (Card card : exile.getCards(game)) { - controller.moveCardToGraveyardWithInfo(card, source.getSourceId(), game, Zone.EXILED); - } + controller.moveCardsToGraveyardWithInfo(exile, source, game, Zone.EXILED); } return true; } diff --git a/Mage/src/mage/filter/predicate/mageobject/NamePredicate.java b/Mage/src/mage/filter/predicate/mageobject/NamePredicate.java index 40e9e0adf4..c085564dd4 100644 --- a/Mage/src/mage/filter/predicate/mageobject/NamePredicate.java +++ b/Mage/src/mage/filter/predicate/mageobject/NamePredicate.java @@ -56,7 +56,13 @@ public class NamePredicate implements Predicate { SplitCard card = (SplitCard) ((Spell)input).getCard(); return name.equals(card.getLeftHalfCard().getName()) || name.equals(card.getRightHalfCard().getName()); } else { - return name.equals(input.getName()); + if (name.contains(" // ")) { + String leftName = name.substring(0, name.indexOf(" // ")); + String rightName = name.substring(name.indexOf(" // ") + 4, name.length()); + return leftName.equals(input.getName()) || rightName.equals(input.getName()); + } else { + return name.equals(input.getName()); + } } }