Some rework for "Name a nonland card" effects.

This commit is contained in:
LevelX2 2016-06-19 16:05:17 +02:00
parent 3edca4234a
commit 7563b0c30f
8 changed files with 40 additions and 212 deletions

View file

@ -56,9 +56,6 @@ public class ThoughtHemorrhage extends CardImpl {
super(ownerId, 47, "Thought Hemorrhage", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{B}{R}"); super(ownerId, 47, "Thought Hemorrhage", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{2}{B}{R}");
this.expansionSetCode = "ARB"; this.expansionSetCode = "ARB";
// Name a nonland card. Target player reveals his or her hand. Thought Hemorrhage deals 3 damage to that player for each card with that name revealed this way. Search that player's graveyard, hand, and library for all cards with that name and exile them. Then that player shuffles his or her library. // Name a nonland card. Target player reveals his or her hand. Thought Hemorrhage deals 3 damage to that player for each card with that name revealed this way. Search that player's graveyard, hand, and library for all cards with that name and exile them. Then that player shuffles his or her library.
this.getSpellAbility().addTarget(new TargetPlayer()); this.getSpellAbility().addTarget(new TargetPlayer());
this.getSpellAbility().addEffect(new NameACardEffect(NameACardEffect.TypeOfName.NON_LAND_NAME)); this.getSpellAbility().addEffect(new NameACardEffect(NameACardEffect.TypeOfName.NON_LAND_NAME));
@ -93,7 +90,7 @@ class ThoughtHemorrhageEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
String cardName = (String) game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY); String cardName = (String) game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY);
if (sourceObject != null && controller != null && cardName != null && !cardName.isEmpty()) { if (sourceObject != null && controller != null && cardName != null && !cardName.isEmpty()) {
Player targetPlayer = game.getPlayer(source.getFirstTarget()); Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (targetPlayer != null) { if (targetPlayer != null) {
targetPlayer.revealCards("hand of " + targetPlayer.getName(), targetPlayer.getHand(), game); targetPlayer.revealCards("hand of " + targetPlayer.getName(), targetPlayer.getHand(), game);
@ -123,7 +120,7 @@ class ThoughtHemorrhageEffect extends OneShotEffect {
// search cards in hand // search cards in hand
TargetCardInHand targetCardsHand = new TargetCardInHand(0, Integer.MAX_VALUE, filterNamedCards); TargetCardInHand targetCardsHand = new TargetCardInHand(0, Integer.MAX_VALUE, filterNamedCards);
controller.chooseTarget(outcome, targetPlayer.getGraveyard(), targetCardsHand, source, game); controller.chooseTarget(outcome, targetPlayer.getGraveyard(), targetCardsHand, source, game);
for(UUID cardId: targetCardsHand.getTargets()) { for (UUID cardId : targetCardsHand.getTargets()) {
Card card = game.getCard(cardId); Card card = game.getCard(cardId);
if (card != null) { if (card != null) {
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.HAND, true); controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.HAND, true);
@ -134,14 +131,14 @@ class ThoughtHemorrhageEffect extends OneShotEffect {
// 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 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.
TargetCardInLibrary targetCardsLibrary = new TargetCardInLibrary(0, Integer.MAX_VALUE, filterNamedCards); TargetCardInLibrary targetCardsLibrary = new TargetCardInLibrary(0, Integer.MAX_VALUE, filterNamedCards);
controller.searchLibrary(targetCardsLibrary, game, targetPlayer.getId()); controller.searchLibrary(targetCardsLibrary, game, targetPlayer.getId());
for(UUID cardId: targetCardsLibrary.getTargets()) { for (UUID cardId : targetCardsLibrary.getTargets()) {
Card card = game.getCard(cardId); Card card = game.getCard(cardId);
if (card != null) { if (card != null) {
controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY, true); controller.moveCardToExileWithInfo(card, null, "", source.getSourceId(), game, Zone.LIBRARY, true);
} }
} }
targetPlayer.shuffleLibrary(source, game); targetPlayer.shuffleLibrary(source, game);
return true; return true;
} }
} }
return false; return false;

View file

@ -1,16 +1,16 @@
/* /*
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met: * permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 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 * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution. * provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * 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 * 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 * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
@ -20,7 +20,7 @@
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * 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 * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* The views and conclusions contained in the software and documentation are those of the * 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 * 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.
@ -52,11 +52,10 @@ public class CranialExtraction extends CardImpl {
public CranialExtraction(UUID ownerId) { public CranialExtraction(UUID ownerId) {
super(ownerId, 105, "Cranial Extraction", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{3}{B}"); super(ownerId, 105, "Cranial Extraction", Rarity.RARE, new CardType[]{CardType.SORCERY}, "{3}{B}");
this.expansionSetCode = "CHK"; this.expansionSetCode = "CHK";
this.subtype.add("Arcane"); this.subtype.add("Arcane");
/* Name a nonland card. Search target player's graveyard, hand, and library for
/* Name a nonland card. Search target player's graveyard, hand, and library for * all cards with that name and exile them. Then that player shuffles his or her library. */
* all cards with that name and exile them. Then that player shuffles his or her library. */
this.getSpellAbility().addTarget(new TargetPlayer()); this.getSpellAbility().addTarget(new TargetPlayer());
this.getSpellAbility().addEffect(new CranialExtractionEffect()); this.getSpellAbility().addEffect(new CranialExtractionEffect());
} }

View file

@ -31,11 +31,9 @@ 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;
import mage.abilities.effects.common.NameACardEffect;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.repository.CardRepository;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
@ -54,6 +52,7 @@ public class BrainPry extends CardImpl {
this.expansionSetCode = "DIS"; this.expansionSetCode = "DIS";
//Name a nonland card. Target player reveals his or her hand. That player discards a card with that name. If he or she can't, you draw a card. //Name a nonland card. Target player reveals his or her hand. That player discards a card with that name. If he or she can't, you draw a card.
this.getSpellAbility().addEffect((new NameACardEffect(NameACardEffect.TypeOfName.NON_LAND_NAME)));
this.getSpellAbility().addTarget(new TargetPlayer()); this.getSpellAbility().addTarget(new TargetPlayer());
this.getSpellAbility().addEffect(new BrainPryEffect()); this.getSpellAbility().addEffect(new BrainPryEffect());
} }
@ -72,7 +71,7 @@ class BrainPryEffect extends OneShotEffect {
public BrainPryEffect() { public BrainPryEffect() {
super(Outcome.Discard); super(Outcome.Discard);
staticText = "Name a nonland card. Target player reveals his or her hand. That player discards a card with that name. If he or she can't, you draw a card"; staticText = "Target player reveals his or her hand. That player discards a card with that name. If he or she can't, you draw a card";
} }
public BrainPryEffect(final BrainPryEffect effect) { public BrainPryEffect(final BrainPryEffect effect) {
@ -84,21 +83,9 @@ class BrainPryEffect extends OneShotEffect {
Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source)); Player targetPlayer = game.getPlayer(targetPointer.getFirst(game, source));
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (targetPlayer != null && controller != null && sourceObject != null) { String cardName = (String) game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY);
Choice cardChoice = new ChoiceImpl(true); if (targetPlayer != null && controller != null && sourceObject != null && cardName != null) {
cardChoice.setMessage("Name a nonland card.");
cardChoice.setChoices(CardRepository.instance.getNonLandNames());
cardChoice.clearChoice();
while (!controller.choose(Outcome.Discard, cardChoice, game)) {
if (!controller.canRespond()) {
return false;
}
}
String cardName = cardChoice.getChoice();
Boolean hasDiscarded = false; Boolean hasDiscarded = false;
game.informPlayers(sourceObject.getLogName() + ", named card: [" + cardName + "]");
for (Card card : targetPlayer.getHand().getCards(game)) { for (Card card : targetPlayer.getHand().getCards(game)) {
if (card.getName().equals(cardName)) { if (card.getName().equals(cardName)) {
targetPlayer.discard(card, source, game); targetPlayer.discard(card, source, game);
@ -106,11 +93,9 @@ class BrainPryEffect extends OneShotEffect {
break; break;
} }
} }
if (!hasDiscarded) { if (!hasDiscarded) {
controller.drawCards(1, game); controller.drawCards(1, game);
} }
controller.lookAtCards(sourceObject.getName() + " Hand", targetPlayer.getHand(), game); controller.lookAtCards(sourceObject.getName() + " Hand", targetPlayer.getHand(), game);
} }
return true; return true;

View file

@ -29,19 +29,17 @@ package mage.sets.judgment;
import java.util.UUID; import java.util.UUID;
import mage.MageObject; import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.NameACardEffect;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome; import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.TimingRule; import mage.constants.TimingRule;
import mage.abilities.Ability;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.keyword.FlashbackAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.repository.CardRepository;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.filter.common.FilterControlledCreaturePermanent; import mage.filter.common.FilterControlledCreaturePermanent;
import mage.game.Game; import mage.game.Game;
import mage.players.Player; import mage.players.Player;
@ -59,12 +57,13 @@ public class CabalTherapy extends CardImpl {
this.expansionSetCode = "JUD"; this.expansionSetCode = "JUD";
// Name a nonland card. Target player reveals his or her hand and discards all cards with that name. // Name a nonland card. Target player reveals his or her hand and discards all cards with that name.
this.getSpellAbility().addEffect((new NameACardEffect(NameACardEffect.TypeOfName.NON_LAND_NAME)));
this.getSpellAbility().addTarget(new TargetPlayer()); this.getSpellAbility().addTarget(new TargetPlayer());
this.getSpellAbility().addEffect(new CabalTherapyEffect()); this.getSpellAbility().addEffect(new CabalTherapyEffect());
// Flashback-Sacrifice a creature. // Flashback-Sacrifice a creature.
this.addAbility(new FlashbackAbility( this.addAbility(new FlashbackAbility(
new SacrificeTargetCost(new TargetControlledCreaturePermanent(1,1,new FilterControlledCreaturePermanent("a creature"), true)), new SacrificeTargetCost(new TargetControlledCreaturePermanent(1, 1, new FilterControlledCreaturePermanent("a creature"), true)),
TimingRule.SORCERY)); TimingRule.SORCERY));
} }
@ -95,25 +94,12 @@ class CabalTherapyEffect extends OneShotEffect {
Player controller = game.getPlayer(source.getControllerId()); Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId()); MageObject sourceObject = game.getObject(source.getSourceId());
if (targetPlayer != null && controller != null && sourceObject != null) { if (targetPlayer != null && controller != null && sourceObject != null) {
Choice cardChoice = new ChoiceImpl(true); String cardName = (String) game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY);
cardChoice.setMessage("Name a nonland card.");
cardChoice.setChoices(CardRepository.instance.getNonLandNames());
cardChoice.clearChoice();
while (!controller.choose(Outcome.Discard, cardChoice, game)) {
if (!controller.canRespond()) {
return false;
}
}
String cardName = cardChoice.getChoice();
game.informPlayers(sourceObject.getLogName() + ", named card: [" + cardName + "]");
for (Card card : targetPlayer.getHand().getCards(game)) { for (Card card : targetPlayer.getHand().getCards(game)) {
if (card.getName().equals(cardName)) { if (card.getName().equals(cardName)) {
targetPlayer.discard(card, source, game); targetPlayer.discard(card, source, game);
} }
} }
controller.lookAtCards(sourceObject.getName() + " Hand", targetPlayer.getHand(), game); controller.lookAtCards(sourceObject.getName() + " Hand", targetPlayer.getHand(), game);
} }
return true; return true;

View file

@ -28,20 +28,14 @@
package mage.sets.magic2015; package mage.sets.magic2015;
import java.util.UUID; import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode; import mage.abilities.effects.common.NameACardEffect;
import mage.abilities.effects.common.search.SearchTargetGraveyardHandLibraryForCardNameAndExileEffect; import mage.abilities.effects.common.search.SearchTargetGraveyardHandLibraryForCardNameAndExileEffect;
import mage.abilities.keyword.ConvokeAbility; import mage.abilities.keyword.ConvokeAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.repository.CardRepository;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.game.Game; import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
/** /**
@ -57,6 +51,7 @@ public class StainTheMind extends CardImpl {
// Convoke // Convoke
this.addAbility(new ConvokeAbility()); this.addAbility(new ConvokeAbility());
// Name a nonland card. Search target player's graveyard, hand, and library for any number of card's with that name and exile them. Then that player shuffles his or her library. // Name a nonland card. Search target player's graveyard, hand, and library for any number of card's with that name and exile them. Then that player shuffles his or her library.
this.getSpellAbility().addEffect((new NameACardEffect(NameACardEffect.TypeOfName.NON_LAND_NAME)));
this.getSpellAbility().addEffect(new StainTheMindEffect()); this.getSpellAbility().addEffect(new StainTheMindEffect());
this.getSpellAbility().addTarget(new TargetPlayer()); this.getSpellAbility().addTarget(new TargetPlayer());
} }
@ -83,29 +78,8 @@ class StainTheMindEffect extends SearchTargetGraveyardHandLibraryForCardNameAndE
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source)); String cardName = (String) game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY);
Player controller = game.getPlayer(source.getControllerId()); return super.applySearchAndExile(game, source, cardName, targetPointer.getFirst(game, source));
if (player != null && controller != null) {
Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(CardRepository.instance.getNonLandNames());
cardChoice.clearChoice();
cardChoice.setMessage("Name a nonland card");
while (!controller.choose(Outcome.Exile, cardChoice, game)) {
if (!controller.canRespond()) {
return false;
}
}
String cardName;
cardName = cardChoice.getChoice();
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null) {
game.informPlayers(sourceObject.getName() + " named card: [" + cardName + "]");
}
super.applySearchAndExile(game, source, cardName, player.getId());
}
return true;
} }
@Override @Override
@ -113,12 +87,4 @@ class StainTheMindEffect extends SearchTargetGraveyardHandLibraryForCardNameAndE
return new StainTheMindEffect(this); return new StainTheMindEffect(this);
} }
@Override
public String getText(Mode mode) {
StringBuilder sb = new StringBuilder();
sb.append("Name a nonland card. ");
sb.append(super.getText(mode));
return sb.toString();
}
} }

View file

@ -34,13 +34,9 @@ import mage.abilities.Ability;
import mage.abilities.common.AsEntersBattlefieldAbility; import mage.abilities.common.AsEntersBattlefieldAbility;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.ContinuousRuleModifyingEffectImpl; import mage.abilities.effects.ContinuousRuleModifyingEffectImpl;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.NameACardEffect; import mage.abilities.effects.common.NameACardEffect;
import mage.abilities.keyword.FlyingAbility; import mage.abilities.keyword.FlyingAbility;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.repository.CardRepository;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Duration; import mage.constants.Duration;
import mage.constants.Outcome; import mage.constants.Outcome;
@ -49,9 +45,6 @@ import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.game.events.GameEvent; import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType; import mage.game.events.GameEvent.EventType;
import mage.game.permanent.Permanent;
import mage.players.Player;
import mage.util.CardUtil;
/** /**
* *
@ -87,46 +80,6 @@ public class VoidstoneGargoyle extends CardImpl {
} }
} }
class VoidstoneGargoyleChooseCardEffect extends OneShotEffect {
public VoidstoneGargoyleChooseCardEffect() {
super(Outcome.Detriment);
staticText = "name a nonland card";
}
public VoidstoneGargoyleChooseCardEffect(final VoidstoneGargoyleChooseCardEffect effect) {
super(effect);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
Permanent permanent = game.getPermanentEntering(source.getSourceId());
if (controller != null && permanent != null) {
Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(CardRepository.instance.getNonLandNames());
cardChoice.clearChoice();
while (!controller.choose(Outcome.Detriment, cardChoice, game)) {
if (!controller.canRespond()) {
return false;
}
}
String cardName = cardChoice.getChoice();
game.informPlayers(permanent.getLogName() + ", named card: [" + cardName + "]");
game.getState().setValue(source.getSourceId().toString(), cardName);
permanent.addInfo("named card", CardUtil.addToolTipMarkTags("Named card: [" + cardName + "]"), game);
return true;
}
return false;
}
@Override
public VoidstoneGargoyleChooseCardEffect copy() {
return new VoidstoneGargoyleChooseCardEffect(this);
}
}
class VoidstoneGargoyleReplacementEffect1 extends ContinuousRuleModifyingEffectImpl { class VoidstoneGargoyleReplacementEffect1 extends ContinuousRuleModifyingEffectImpl {
public VoidstoneGargoyleReplacementEffect1() { public VoidstoneGargoyleReplacementEffect1() {

View file

@ -28,23 +28,17 @@
package mage.sets.returntoravnica; package mage.sets.returntoravnica;
import java.util.UUID; import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.common.SimpleStaticAbility; import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.Effect; import mage.abilities.effects.Effect;
import mage.abilities.effects.common.CantBeCounteredSourceEffect; import mage.abilities.effects.common.CantBeCounteredSourceEffect;
import mage.abilities.effects.common.NameACardEffect;
import mage.abilities.effects.common.search.SearchTargetGraveyardHandLibraryForCardNameAndExileEffect; import mage.abilities.effects.common.search.SearchTargetGraveyardHandLibraryForCardNameAndExileEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.repository.CardRepository;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.constants.Zone; import mage.constants.Zone;
import mage.game.Game; import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetOpponent; import mage.target.common.TargetOpponent;
/** /**
@ -65,9 +59,9 @@ public class SlaughterGames extends CardImpl {
this.addAbility(ability); this.addAbility(ability);
// Name a nonland card. Search target opponent's graveyard, hand, and library for any number of cards with that name and exile them. Then that player shuffles his or her library. // Name a nonland card. Search target opponent's graveyard, hand, and library for any number of cards with that name and exile them. Then that player shuffles his or her library.
this.getSpellAbility().addEffect(new NameACardEffect(NameACardEffect.TypeOfName.NON_LAND_NAME));
this.getSpellAbility().addEffect(new SlaughterGamesEffect()); this.getSpellAbility().addEffect(new SlaughterGamesEffect());
this.getSpellAbility().addTarget(new TargetOpponent()); this.getSpellAbility().addTarget(new TargetOpponent());
} }
public SlaughterGames(final SlaughterGames card) { public SlaughterGames(final SlaughterGames card) {
@ -92,29 +86,8 @@ class SlaughterGamesEffect extends SearchTargetGraveyardHandLibraryForCardNameAn
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(targetPointer.getFirst(game, source)); String cardName = (String) game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY);
Player controller = game.getPlayer(source.getControllerId()); return super.applySearchAndExile(game, source, cardName, targetPointer.getFirst(game, source));
if (player != null && controller != null) {
Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(CardRepository.instance.getNonLandNames());
cardChoice.clearChoice();
cardChoice.setMessage("Name a nonland card");
while (!controller.choose(Outcome.Exile, cardChoice, game)) {
if (!controller.canRespond()) {
return false;
}
}
String cardName;
cardName = cardChoice.getChoice();
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null) {
game.informPlayers(sourceObject.getName() + " named card: [" + cardName + "]");
}
super.applySearchAndExile(game, source, cardName, player.getId());
}
return true;
} }
@Override @Override
@ -122,12 +95,4 @@ class SlaughterGamesEffect extends SearchTargetGraveyardHandLibraryForCardNameAn
return new SlaughterGamesEffect(this); return new SlaughterGamesEffect(this);
} }
@Override
public String getText(Mode mode) {
StringBuilder sb = new StringBuilder();
sb.append("Name a nonland card. ");
sb.append(super.getText(mode));
return sb.toString();
}
} }

View file

@ -28,19 +28,14 @@
package mage.sets.scarsofmirrodin; package mage.sets.scarsofmirrodin;
import java.util.UUID; import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability; import mage.abilities.Ability;
import mage.abilities.Mode; import mage.abilities.Mode;
import mage.abilities.effects.common.NameACardEffect;
import mage.abilities.effects.common.search.SearchTargetGraveyardHandLibraryForCardNameAndExileEffect; import mage.abilities.effects.common.search.SearchTargetGraveyardHandLibraryForCardNameAndExileEffect;
import mage.cards.CardImpl; import mage.cards.CardImpl;
import mage.cards.repository.CardRepository;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.constants.CardType; import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Rarity; import mage.constants.Rarity;
import mage.game.Game; import mage.game.Game;
import mage.players.Player;
import mage.target.TargetPlayer; import mage.target.TargetPlayer;
/** /**
@ -55,6 +50,7 @@ public class Memoricide extends CardImpl {
// Name a nonland card. Search target player's graveyard, hand, and library for any number of cards with // Name a nonland card. Search target player's graveyard, hand, and library for any number of cards with
// that name and exile them. Then that player shuffles his or her library // that name and exile them. Then that player shuffles his or her library
this.getSpellAbility().addEffect((new NameACardEffect(NameACardEffect.TypeOfName.NON_LAND_NAME)));
this.getSpellAbility().addTarget(new TargetPlayer()); this.getSpellAbility().addTarget(new TargetPlayer());
this.getSpellAbility().addEffect(new MemoricideEffect()); this.getSpellAbility().addEffect(new MemoricideEffect());
} }
@ -82,27 +78,8 @@ class MemoricideEffect extends SearchTargetGraveyardHandLibraryForCardNameAndExi
@Override @Override
public boolean apply(Game game, Ability source) { public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(this.getTargetPointer().getFirst(game, source)); String cardName = (String) game.getState().getValue(source.getSourceId().toString() + NameACardEffect.INFO_KEY);
Player controller = game.getPlayer(source.getControllerId()); return super.applySearchAndExile(game, source, cardName, targetPointer.getFirst(game, source));
if (player != null && controller != null) {
Choice cardChoice = new ChoiceImpl();
cardChoice.setChoices(CardRepository.instance.getNonLandNames());
cardChoice.clearChoice();
cardChoice.setMessage("Name a nonland card");
while (!controller.choose(Outcome.Exile, cardChoice, game)) {
if (!controller.canRespond()) {
return false;
}
}
String cardName = cardChoice.getChoice();
MageObject sourceObject = game.getObject(source.getSourceId());
if (sourceObject != null) {
game.informPlayers(sourceObject.getName() + " named card: [" + cardName + "]");
}
super.applySearchAndExile(game, source, cardName, player.getId());
}
return true;
} }
@Override @Override