* Fixed that named searches (e.g. Surgical Extraction) work also if the selected card is a split card.

This commit is contained in:
LevelX2 2015-05-20 17:17:42 +02:00
parent be81d93e2b
commit a3065b703a
4 changed files with 20 additions and 23 deletions

View file

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

View file

@ -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<UUID> 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<UUID> 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<UUID> targets = targetCardInLibrary.getTargets();

View file

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

View file

@ -55,10 +55,16 @@ public class NamePredicate implements Predicate<MageObject> {
} else if (input instanceof Spell && ((Spell)input).getSpellAbility().getSpellAbilityType().equals(SpellAbilityType.SPLIT_FUSED)){
SplitCard card = (SplitCard) ((Spell)input).getCard();
return name.equals(card.getLeftHalfCard().getName()) || name.equals(card.getRightHalfCard().getName());
} else {
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());
}
}
}
@Override
public String toString() {