mirror of
https://github.com/correl/mage.git
synced 2025-04-08 17:00:07 -09:00
refactored a few more remove instances
This commit is contained in:
parent
d1b328a2da
commit
ddabfacbe7
7 changed files with 133 additions and 217 deletions
|
@ -78,7 +78,7 @@ class GrinningTotemSearchAndExileEffect extends OneShotEffect {
|
|||
}
|
||||
TargetCardInLibrary targetCard = new TargetCardInLibrary();
|
||||
you.searchLibrary(targetCard, source, game, targetOpponent.getId());
|
||||
Card card = targetOpponent.getLibrary().remove(targetCard.getFirstTarget(), game);
|
||||
Card card = targetOpponent.getLibrary().getCard(targetCard.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
UUID exileZoneId = CardUtil.getCardExileZoneId(game, source);
|
||||
you.moveCardsToExile(card, source, game, true, exileZoneId, CardUtil.getSourceName(game, source));
|
||||
|
|
|
@ -1,78 +1,75 @@
|
|||
package mage.cards.m;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.SearchEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.common.FilterLandCard;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author nick.myers
|
||||
*/
|
||||
public final class ManaSeverance extends CardImpl {
|
||||
|
||||
|
||||
public ManaSeverance(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{U}");
|
||||
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{U}");
|
||||
|
||||
// Search your library for any number of land cards and remove them from the game.
|
||||
// Shuffle your library afterwards.
|
||||
this.getSpellAbility().addEffect(new ManaSeveranceEffect());
|
||||
}
|
||||
|
||||
|
||||
private ManaSeverance(final ManaSeverance card) {
|
||||
super(card);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ManaSeverance copy() {
|
||||
return new ManaSeverance(this);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
class ManaSeveranceEffect extends SearchEffect {
|
||||
|
||||
class ManaSeveranceEffect extends OneShotEffect {
|
||||
|
||||
public ManaSeveranceEffect() {
|
||||
super(new TargetCardInLibrary(0, Integer.MAX_VALUE, new FilterLandCard()), Outcome.Exile);
|
||||
super(Outcome.Benefit);
|
||||
this.staticText = "search your library for any number of land cards, exile them, then shuffle";
|
||||
}
|
||||
|
||||
|
||||
public ManaSeveranceEffect(final ManaSeveranceEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
|
||||
@Override
|
||||
public ManaSeveranceEffect copy() {
|
||||
return new ManaSeveranceEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
if (controller != null) {
|
||||
if (controller.searchLibrary(target, source, game)) {
|
||||
if (!target.getTargets().isEmpty()) {
|
||||
for (UUID cardId : target.getTargets()) {
|
||||
Card card = controller.getLibrary().getCard(cardId, game);
|
||||
if (card != null) {
|
||||
controller.moveCardToExileWithInfo(card, null, "", source, game, Zone.LIBRARY, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
controller.shuffleLibrary(source, game);
|
||||
return true;
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(
|
||||
0, Integer.MAX_VALUE, StaticFilters.FILTER_CARD_LANDS
|
||||
);
|
||||
player.searchLibrary(target, source, game);
|
||||
Cards cards = new CardsImpl(target.getTargets());
|
||||
cards.retainZone(Zone.LIBRARY, game);
|
||||
player.moveCards(cards, Zone.EXILED, source, game);
|
||||
player.shuffleLibrary(source, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,9 +1,11 @@
|
|||
package mage.cards.s;
|
||||
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.*;
|
||||
import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
|
@ -23,13 +25,15 @@ import java.util.UUID;
|
|||
*/
|
||||
public final class SecretSalvage extends CardImpl {
|
||||
|
||||
private static final FilterCard filter = new FilterNonlandCard("nonland card from your graveyard");
|
||||
|
||||
public SecretSalvage(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{B}{B}");
|
||||
|
||||
// Exile target nonland card from your graveyard. Search your library for any number of cards with the same name as that card,
|
||||
// reveal them, and put them into your hand. Then shuffle your library.
|
||||
getSpellAbility().addEffect(new SecretSalvageEffect());
|
||||
getSpellAbility().addTarget(new TargetCardInYourGraveyard(new FilterNonlandCard("nonland card from your graveyard")));
|
||||
getSpellAbility().addTarget(new TargetCardInYourGraveyard(filter));
|
||||
}
|
||||
|
||||
private SecretSalvage(final SecretSalvage card) {
|
||||
|
@ -46,8 +50,9 @@ class SecretSalvageEffect extends OneShotEffect {
|
|||
|
||||
public SecretSalvageEffect() {
|
||||
super(Outcome.DrawCard);
|
||||
staticText = "Exile target nonland card from your graveyard. Search your library for any number of cards with the same name as that card, "
|
||||
+ "reveal them, put them into your hand, then shuffle";
|
||||
staticText = "Exile target nonland card from your graveyard. " +
|
||||
"Search your library for any number of cards with the same name as that card, " +
|
||||
"reveal them, put them into your hand, then shuffle";
|
||||
}
|
||||
|
||||
public SecretSalvageEffect(final SecretSalvageEffect effect) {
|
||||
|
@ -62,34 +67,16 @@ class SecretSalvageEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = source.getSourceObject(game);
|
||||
if (controller != null && sourceObject != null) {
|
||||
Card targetCard = game.getCard(getTargetPointer().getFirst(game, source));
|
||||
if (targetCard != null) {
|
||||
controller.moveCards(targetCard, Zone.EXILED, source, game);
|
||||
|
||||
String nameToSearch = CardUtil.getCardNameForSameNameSearch(targetCard);
|
||||
FilterCard nameFilter = new FilterCard();
|
||||
nameFilter.add(new NamePredicate(nameToSearch));
|
||||
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(0, Integer.MAX_VALUE, nameFilter);
|
||||
if (controller.searchLibrary(target, source, game)) {
|
||||
if (!target.getTargets().isEmpty()) {
|
||||
Cards cards = new CardsImpl();
|
||||
for (UUID cardId : target.getTargets()) {
|
||||
Card card = controller.getLibrary().remove(cardId, game);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
}
|
||||
}
|
||||
controller.revealCards(sourceObject.getIdName(), cards, game);
|
||||
controller.moveCards(cards, Zone.HAND, source, game);
|
||||
}
|
||||
controller.shuffleLibrary(source, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
Card targetCard = game.getCard(getTargetPointer().getFirst(game, source));
|
||||
if (controller == null || targetCard == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
controller.moveCards(targetCard, Zone.EXILED, source, game);
|
||||
String nameToSearch = CardUtil.getCardNameForSameNameSearch(targetCard);
|
||||
FilterCard nameFilter = new FilterCard("card named " + nameToSearch);
|
||||
nameFilter.add(new NamePredicate(nameToSearch));
|
||||
return new SearchLibraryPutInHandEffect(new TargetCardInLibrary(
|
||||
0, Integer.MAX_VALUE, nameFilter
|
||||
), true, true).apply(game, source);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,28 +1,28 @@
|
|||
|
||||
package mage.cards.s;
|
||||
|
||||
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.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.filter.common.FilterNonlandCard;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author North
|
||||
*/
|
||||
public final class SelectiveMemory extends CardImpl {
|
||||
|
||||
public SelectiveMemory(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{U}");
|
||||
|
||||
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}");
|
||||
|
||||
// Search your library for any number of nonland cards and exile them. Then shuffle your library.
|
||||
this.getSpellAbility().addEffect(new SelectiveMemoryEffect());
|
||||
|
@ -57,20 +57,17 @@ class SelectiveMemoryEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
if (player != null) {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(0, Integer.MAX_VALUE, new FilterNonlandCard());
|
||||
if (player.searchLibrary(target, source, game)) {
|
||||
for (UUID targetId : target.getTargets()) {
|
||||
Card card = player.getLibrary().remove(targetId, game);
|
||||
if (card != null) {
|
||||
card.moveToExile(null, "", source, game);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
player.shuffleLibrary(source, game);
|
||||
return true;
|
||||
if (player == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(
|
||||
0, Integer.MAX_VALUE, StaticFilters.FILTER_CARDS_NON_LAND
|
||||
);
|
||||
player.searchLibrary(target, source, game);
|
||||
Cards cards = new CardsImpl(target.getTargets());
|
||||
cards.retainZone(Zone.LIBRARY, game);
|
||||
player.moveCards(cards, Zone.EXILED, source, game);
|
||||
player.shuffleLibrary(source, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,33 +1,29 @@
|
|||
|
||||
package mage.cards.t;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageInt;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
|
||||
import mage.abilities.effects.AsThoughEffectImpl;
|
||||
import mage.abilities.effects.ContinuousEffect;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.abilities.effects.common.asthought.PlayFromNotOwnHandZoneTargetEffect;
|
||||
import mage.abilities.keyword.IslandwalkAbility;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.constants.*;
|
||||
import mage.filter.common.FilterArtifactCard;
|
||||
import mage.filter.StaticFilters;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.target.targetpointer.FixedTarget;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author jeffwadsworth
|
||||
*/
|
||||
public final class ThadaAdelAcquisitor extends CardImpl {
|
||||
|
||||
public ThadaAdelAcquisitor(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{U}{U}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{U}{U}");
|
||||
addSuperType(SuperType.LEGENDARY);
|
||||
this.subtype.add(SubType.MERFOLK);
|
||||
this.subtype.add(SubType.ROGUE);
|
||||
|
@ -39,7 +35,9 @@ public final class ThadaAdelAcquisitor extends CardImpl {
|
|||
this.addAbility(new IslandwalkAbility());
|
||||
|
||||
// Whenever Thada Adel, Acquisitor deals combat damage to a player, search that player's library for an artifact card and exile it. Then that player shuffles their library. Until end of turn, you may play that card.
|
||||
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new ThadaAdelAcquisitorEffect(), false, true));
|
||||
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(
|
||||
new ThadaAdelAcquisitorEffect(), false, true
|
||||
));
|
||||
}
|
||||
|
||||
private ThadaAdelAcquisitor(final ThadaAdelAcquisitor card) {
|
||||
|
@ -67,22 +65,16 @@ class ThadaAdelAcquisitorEffect extends OneShotEffect {
|
|||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
Player damagedPlayer = game.getPlayer(targetPointer.getFirst(game, source));
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller == null || damagedPlayer == null || sourceObject == null) {
|
||||
if (controller == null || damagedPlayer == null) {
|
||||
return false;
|
||||
}
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(new FilterArtifactCard());
|
||||
if (controller.searchLibrary(target, source, game, damagedPlayer.getId())) {
|
||||
if (!target.getTargets().isEmpty()) {
|
||||
Card card = damagedPlayer.getLibrary().remove(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
controller.moveCardToExileWithInfo(card, source.getSourceId(), sourceObject.getIdName(), source, game, Zone.LIBRARY, true);
|
||||
ContinuousEffect effect = new ThadaAdelPlayFromExileEffect();
|
||||
effect.setTargetPointer(new FixedTarget(card.getId()));
|
||||
game.addEffect(effect, source);
|
||||
}
|
||||
}
|
||||
}
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(StaticFilters.FILTER_CARD_ARTIFACT);
|
||||
controller.searchLibrary(target, source, game, damagedPlayer.getId());
|
||||
Card card = damagedPlayer.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
PlayFromNotOwnHandZoneTargetEffect.exileAndPlayFromExile(
|
||||
game, source, card, TargetController.YOU, Duration.EndOfTurn,
|
||||
false, false, false
|
||||
);
|
||||
damagedPlayer.shuffleLibrary(source, game);
|
||||
return true;
|
||||
}
|
||||
|
@ -92,31 +84,3 @@ class ThadaAdelAcquisitorEffect extends OneShotEffect {
|
|||
return new ThadaAdelAcquisitorEffect(this);
|
||||
}
|
||||
}
|
||||
|
||||
class ThadaAdelPlayFromExileEffect extends AsThoughEffectImpl {
|
||||
|
||||
public ThadaAdelPlayFromExileEffect() {
|
||||
super(AsThoughEffectType.PLAY_FROM_NOT_OWN_HAND_ZONE, Duration.EndOfTurn, Outcome.Benefit);
|
||||
staticText = "You may play this card from exile";
|
||||
}
|
||||
|
||||
public ThadaAdelPlayFromExileEffect(final ThadaAdelPlayFromExileEffect effect) {
|
||||
super(effect);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
return true;
|
||||
}
|
||||
|
||||
@Override
|
||||
public ThadaAdelPlayFromExileEffect copy() {
|
||||
return new ThadaAdelPlayFromExileEffect(this);
|
||||
}
|
||||
|
||||
@Override
|
||||
public boolean applies(UUID sourceId, Ability source, UUID affectedControllerId, Game game) {
|
||||
return source.isControlledBy(affectedControllerId)
|
||||
&& sourceId.equals(getTargetPointer().getFirst(game, source));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2,15 +2,18 @@ package mage.cards.u;
|
|||
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.effects.OneShotEffect;
|
||||
import mage.cards.*;
|
||||
import mage.abilities.effects.common.search.SearchLibraryPutInHandEffect;
|
||||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.Cards;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.common.FilterCreatureCard;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.util.CardUtil;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
|
@ -46,7 +49,8 @@ class UncageTheMenagerieEffect extends OneShotEffect {
|
|||
|
||||
public UncageTheMenagerieEffect() {
|
||||
super(Outcome.DrawCard);
|
||||
this.staticText = "Search your library for up to X creature cards with different names that each have mana value X, reveal them, put them into your hand, then shuffle.";
|
||||
this.staticText = "Search your library for up to X creature cards with different names " +
|
||||
"that each have mana value X, reveal them, put them into your hand, then shuffle.";
|
||||
}
|
||||
|
||||
public UncageTheMenagerieEffect(final UncageTheMenagerieEffect effect) {
|
||||
|
@ -60,38 +64,15 @@ class UncageTheMenagerieEffect extends OneShotEffect {
|
|||
|
||||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
Card sourceCard = game.getCard(source.getSourceId());
|
||||
if (player == null || sourceCard == null) {
|
||||
return false;
|
||||
}
|
||||
|
||||
int xValue = source.getManaCostsToPay().getX();
|
||||
|
||||
UncageTheMenagerieTarget target = new UncageTheMenagerieTarget(xValue);
|
||||
if (player.searchLibrary(target, source, game)) {
|
||||
if (!target.getTargets().isEmpty()) {
|
||||
Cards cards = new CardsImpl();
|
||||
for (UUID cardId : target.getTargets()) {
|
||||
Card card = player.getLibrary().remove(cardId, game);
|
||||
if (card != null) {
|
||||
cards.add(card);
|
||||
}
|
||||
}
|
||||
player.revealCards(sourceCard.getIdName(), cards, game);
|
||||
player.moveCards(cards, Zone.HAND, source, game);
|
||||
}
|
||||
player.shuffleLibrary(source, game);
|
||||
return true;
|
||||
}
|
||||
player.shuffleLibrary(source, game);
|
||||
return false;
|
||||
return new SearchLibraryPutInHandEffect(new UncageTheMenagerieTarget(
|
||||
source.getManaCostsToPay().getX()), true, true
|
||||
).apply(game, source);
|
||||
}
|
||||
}
|
||||
|
||||
class UncageTheMenagerieTarget extends TargetCardInLibrary {
|
||||
|
||||
private int xValue;
|
||||
private final int xValue;
|
||||
|
||||
public UncageTheMenagerieTarget(int xValue) {
|
||||
super(0, xValue, new FilterCreatureCard(xValue + " creature cards with different names with mana value " + xValue));
|
||||
|
@ -110,21 +91,15 @@ class UncageTheMenagerieTarget extends TargetCardInLibrary {
|
|||
|
||||
@Override
|
||||
public boolean canTarget(UUID playerId, UUID id, Ability source, Cards cards, Game game) {
|
||||
Card card = cards.get(id, game);
|
||||
if (card != null) {
|
||||
for (UUID targetId : this.getTargets()) {
|
||||
Card iCard = game.getCard(targetId);
|
||||
if (iCard != null && iCard.getName().equals(card.getName())) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
if (!(card.isCreature(game) && card.getManaValue() == xValue)) {
|
||||
return false;
|
||||
}
|
||||
|
||||
return filter.match(card, playerId, game);
|
||||
if (!super.canTarget(playerId, id, source, cards, game)) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
Card card = cards.get(id, game);
|
||||
return card.getManaValue() == xValue
|
||||
&& this
|
||||
.getTargets()
|
||||
.stream()
|
||||
.map(game::getCard)
|
||||
.noneMatch(c -> CardUtil.haveSameNames(c, card));
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1,8 +1,5 @@
|
|||
|
||||
package mage.cards.w;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.MageObject;
|
||||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
|
@ -10,39 +7,42 @@ import mage.abilities.effects.OneShotEffect;
|
|||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.cards.CardSetInfo;
|
||||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.constants.CardType;
|
||||
import mage.constants.Outcome;
|
||||
import mage.constants.Zone;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.common.FilterEnchantmentCard;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author emerald000
|
||||
*/
|
||||
public final class WildResearch extends CardImpl {
|
||||
|
||||
private static final FilterCard filterEnchantment = new FilterCard("enchantment card");
|
||||
private static final FilterCard filterEnchantment = new FilterEnchantmentCard();
|
||||
private static final FilterCard filterInstant = new FilterCard("instant card");
|
||||
|
||||
static {
|
||||
filterEnchantment.add(CardType.ENCHANTMENT.getPredicate());
|
||||
filterInstant.add(CardType.INSTANT.getPredicate());
|
||||
}
|
||||
|
||||
public WildResearch(UUID ownerId, CardSetInfo setInfo) {
|
||||
super(ownerId,setInfo,new CardType[]{CardType.ENCHANTMENT},"{2}{R}");
|
||||
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{R}");
|
||||
|
||||
// {1}{W}: Search your library for an enchantment card and reveal that card. Put it into your hand, then discard a card at random. Then shuffle your library.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new WildResearchEffect(filterEnchantment), new ManaCostsImpl<>("{1}{W}")));
|
||||
this.addAbility(new SimpleActivatedAbility(
|
||||
new WildResearchEffect(filterEnchantment), new ManaCostsImpl<>("{1}{W}")
|
||||
));
|
||||
|
||||
// {1}{U}: Search your library for an instant card and reveal that card. Put it into your hand, then discard a card at random. Then shuffle your library.
|
||||
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new WildResearchEffect(filterInstant), new ManaCostsImpl<>("{1}{U}")));
|
||||
|
||||
this.addAbility(new SimpleActivatedAbility(
|
||||
new WildResearchEffect(filterInstant), new ManaCostsImpl<>("{1}{U}")
|
||||
));
|
||||
}
|
||||
|
||||
private WildResearch(final WildResearch card) {
|
||||
|
@ -61,11 +61,12 @@ class WildResearchEffect extends OneShotEffect {
|
|||
|
||||
WildResearchEffect(FilterCard filter) {
|
||||
super(Outcome.DrawCard);
|
||||
this.staticText = "Search your library for an " + filter.getMessage() + " and reveal that card. Put it into your hand, then discard a card at random. Then shuffle.";
|
||||
this.staticText = "Search your library for an " + filter.getMessage() + " and reveal that card. " +
|
||||
"Put it into your hand, then discard a card at random. Then shuffle.";
|
||||
this.filter = filter;
|
||||
}
|
||||
|
||||
WildResearchEffect(final WildResearchEffect effect) {
|
||||
private WildResearchEffect(final WildResearchEffect effect) {
|
||||
super(effect);
|
||||
this.filter = effect.filter;
|
||||
}
|
||||
|
@ -78,23 +79,18 @@ class WildResearchEffect extends OneShotEffect {
|
|||
@Override
|
||||
public boolean apply(Game game, Ability source) {
|
||||
Player controller = game.getPlayer(source.getControllerId());
|
||||
MageObject sourceObject = game.getObject(source.getSourceId());
|
||||
if (controller != null && sourceObject != null) {
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(filter);
|
||||
if (controller.searchLibrary(target, source, game)) {
|
||||
if (!target.getTargets().isEmpty()) {
|
||||
Card card = controller.getLibrary().remove(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
controller.moveCards(card, Zone.HAND, source, game);
|
||||
Cards cards = new CardsImpl(card);
|
||||
controller.revealCards(sourceObject.getIdName(), cards, game, true);
|
||||
}
|
||||
}
|
||||
}
|
||||
controller.discardOne(true, false, source, game);
|
||||
controller.shuffleLibrary(source, game);
|
||||
return true;
|
||||
if (controller == null) {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(filter);
|
||||
controller.searchLibrary(target, source, game);
|
||||
Card card = controller.getLibrary().getCard(target.getFirstTarget(), game);
|
||||
if (card != null) {
|
||||
controller.revealCards(source, new CardsImpl(card), game);
|
||||
controller.moveCards(card, Zone.HAND, source, game);
|
||||
}
|
||||
controller.discardOne(true, false, source, game);
|
||||
controller.shuffleLibrary(source, game);
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue