[Refactor] Edited RevealLibraryPutIntoHandEffect, deleted the same effect class (EnvoyEffect) and changed some cards

This commit is contained in:
Styxo 2017-01-03 10:05:58 +01:00
parent 656e658fb4
commit a4a9e41464
19 changed files with 123 additions and 473 deletions

View file

@ -48,13 +48,14 @@ import mage.filter.predicate.permanent.ControllerPredicate;
import mage.target.common.TargetCreaturePermanent;
import java.util.UUID;
import mage.constants.Zone;
/**
* @author JRHerlehy
*/
public class AjaniUnyielding extends CardImpl {
private static final FilterPermanentCard nonlandPermanentFilter = new FilterPermanentCard("nonland permanent card");
private static final FilterPermanentCard nonlandPermanentFilter = new FilterPermanentCard("nonland permanent cards");
private static final FilterCreaturePermanent creatureFilter = new FilterCreaturePermanent("creature you control");
private static final FilterPlaneswalkerPermanent planeswalkerFilter = new FilterPlaneswalkerPermanent("other planeswalker you control");
@ -72,7 +73,7 @@ public class AjaniUnyielding extends CardImpl {
this.addAbility(new PlanswalkerEntersWithLoyalityCountersAbility(4));
// +2: Reveal the top three cards of your library. Put all nonland permanent cards revealed this way into your hand and the rest on the bottom of your library in any order.
this.addAbility(new LoyaltyAbility(new RevealLibraryPutIntoHandEffect(3, nonlandPermanentFilter, true), 2));
this.addAbility(new LoyaltyAbility(new RevealLibraryPutIntoHandEffect(3, nonlandPermanentFilter, Zone.LIBRARY), 2));
// -2: Exile target creature. Its controller gains life equal to its power.
LoyaltyAbility ajaniAbility2 = new LoyaltyAbility(new SwordsToPlowsharesEffect(), -2);

View file

@ -28,19 +28,12 @@
package mage.cards.b;
import java.util.UUID;
import mage.MageObject;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.abilities.effects.common.RevealLibraryPutIntoHandEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.game.Game;
import mage.players.Player;
import mage.filter.common.FilterCreatureCard;
/**
*
@ -49,10 +42,9 @@ import mage.players.Player;
public class BeastHunt extends CardImpl {
public BeastHunt(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{G}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{G}");
this.getSpellAbility().addEffect(new BeastHuntEffect());
this.getSpellAbility().addEffect(new RevealLibraryPutIntoHandEffect(3, new FilterCreatureCard(), Zone.GRAVEYARD));
}
public BeastHunt(final BeastHunt card) {
@ -64,45 +56,3 @@ public class BeastHunt extends CardImpl {
return new BeastHunt(this);
}
}
class BeastHuntEffect extends OneShotEffect {
public BeastHuntEffect() {
super(Outcome.Benefit);
staticText = "Reveal the top three cards of your library. Put all creature cards revealed this way into your hand and the rest into your graveyard";
}
public BeastHuntEffect(final BeastHuntEffect effect) {
super(effect);
}
@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) {
return false;
}
Cards cards = new CardsImpl();
Cards cardsToHand = new CardsImpl();
cards.addAll(controller.getLibrary().getTopCards(game, 3));
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getName(), cards, game);
for (Card card: cards.getCards(game)) {
if (card.getCardType().contains(CardType.CREATURE)) {
cardsToHand.add(card);
cards.remove(card);
}
}
controller.moveCards(cardsToHand, Zone.HAND, source, game);
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
}
return true;
}
@Override
public BeastHuntEffect copy() {
return new BeastHuntEffect(this);
}
}

View file

@ -35,19 +35,13 @@ import mage.abilities.Ability;
import mage.abilities.common.DealsCombatDamageToAPlayerTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.DiscardTargetCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.abilities.effects.common.RevealLibraryPutIntoHandEffect;
import mage.abilities.keyword.TrampleAbility;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.common.FilterLandCard;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInHand;
import mage.target.common.TargetCreatureOrPlayer;
@ -58,12 +52,11 @@ import mage.target.common.TargetCreatureOrPlayer;
public class BorborygmosEnraged extends CardImpl {
public BorborygmosEnraged(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{R}{R}{G}{G}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{R}{R}{G}{G}");
this.subtype.add("Cyclops");
this.supertype.add("Legendary");
this.power = new MageInt(7);
this.toughness = new MageInt(6);
@ -71,7 +64,7 @@ public class BorborygmosEnraged extends CardImpl {
this.addAbility(TrampleAbility.getInstance());
//Whenever Borborygmous Enraged deals combat damage to a player, reveal the top three cards of your library. Put all land cards revealed this way into your hand and the rest into your graveyard.
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new BorborygmosEnragedEffect(), false, false));
this.addAbility(new DealsCombatDamageToAPlayerTriggeredAbility(new RevealLibraryPutIntoHandEffect(3, new FilterLandCard(), Zone.GRAVEYARD), false, false));
//Discard a land card: Borborygmos Enraged deals 3 damage to target creature or player
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new DamageTargetEffect(3), new DiscardTargetCost(new TargetCardInHand(new FilterLandCard())));
@ -88,43 +81,3 @@ public class BorborygmosEnraged extends CardImpl {
return new BorborygmosEnraged(this);
}
}
class BorborygmosEnragedEffect extends OneShotEffect {
public BorborygmosEnragedEffect() {
super(Outcome.DrawCard);
this.staticText = "reveal the top three cards of your library. Put all land cards revealed this way into your hand and the rest into your graveyard";
}
public BorborygmosEnragedEffect(final BorborygmosEnragedEffect effect) {
super(effect);
}
@Override
public BorborygmosEnragedEffect copy() {
return new BorborygmosEnragedEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
if (controller != null) {
Cards cards = new CardsImpl();
cards.addAll(controller.getLibrary().getTopCards(game, 3));
if (!cards.isEmpty()) {
controller.revealCards("Borborygmous Enraged", cards, game);
Cards landCards = new CardsImpl();
for(Card card: cards.getCards(game) ) {
if (card.getCardType().contains(CardType.LAND)) {
landCards.add(card);
cards.remove(card);
}
}
controller.moveCards(landCards, Zone.HAND, source, game);
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
}
return true;
}
return false;
}
}

View file

@ -35,7 +35,7 @@ import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleStaticAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ChooseCreatureTypeEffect;
import mage.abilities.effects.common.EnvoyEffect;
import mage.abilities.effects.common.RevealLibraryPutIntoHandEffect;
import mage.abilities.effects.common.continuous.BoostAllOfChosenSubtypeEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
@ -54,7 +54,7 @@ import mage.game.Game;
public class BrassHerald extends CardImpl {
public BrassHerald(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT,CardType.CREATURE},"{6}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT, CardType.CREATURE}, "{6}");
this.subtype.add("Golem");
this.power = new MageInt(2);
this.toughness = new MageInt(2);
@ -99,6 +99,6 @@ class BrassHeraldEntersEffect extends OneShotEffect {
public boolean apply(Game game, Ability source) {
FilterCard filter = new FilterCard("creature cards of the chosen type");
filter.add(new ChosenSubtypePredicate(source.getSourceId()));
return new EnvoyEffect(filter, 4).apply(game, source);
return new RevealLibraryPutIntoHandEffect(4, filter, Zone.LIBRARY).apply(game, source);
}
}

View file

@ -60,7 +60,7 @@ import mage.players.Player;
public class DepalaPilotExemplar extends CardImpl {
public DepalaPilotExemplar(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{1}{R}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{1}{R}{W}");
this.supertype.add("Legendary");
this.subtype.add("Dwarf");
this.subtype.add("Pilot");
@ -92,6 +92,7 @@ public class DepalaPilotExemplar extends CardImpl {
class DepalaPilotExemplarEffect extends OneShotEffect {
private static final FilterCard filter = new FilterCard("Dwarf and Vehicle cards");
static {
filter.add(Predicates.or(new SubtypePredicate("Dwarf"), new SubtypePredicate("Vehicle")));
}
@ -118,7 +119,7 @@ class DepalaPilotExemplarEffect extends OneShotEffect {
int xValue = controller.announceXMana(0, Integer.MAX_VALUE, "Choose the amount of mana to pay", game, source);
cost.add(new GenericManaCost(xValue));
if (cost.pay(source, game, source.getSourceId(), source.getControllerId(), false) && xValue > 0) {
new RevealLibraryPutIntoHandEffect(xValue, filter, false).apply(game, source);
new RevealLibraryPutIntoHandEffect(xValue, filter, Zone.LIBRARY, false).apply(game, source);
}
return true;
}

View file

@ -29,22 +29,15 @@ package mage.cards.e;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SpellCastControllerTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.RevealLibraryPutIntoHandEffect;
import mage.abilities.keyword.SoulshiftAbility;
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.common.FilterLandCard;
import mage.filter.common.FilterSpiritOrArcaneCard;
import mage.game.Game;
import mage.players.Player;
/**
*
@ -53,14 +46,14 @@ import mage.players.Player;
public class ElderPineOfJukai extends CardImpl {
public ElderPineOfJukai(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{G}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}");
this.subtype.add("Spirit");
this.power = new MageInt(2);
this.toughness = new MageInt(1);
// Whenever you cast a Spirit or Arcane spell, reveal the top three cards of your library. Put all land cards revealed this way into your hand and the rest on the bottom of your library in any order.
this.addAbility(new SpellCastControllerTriggeredAbility(new ElderPineOfJukaiEffect(), new FilterSpiritOrArcaneCard(), false));
this.addAbility(new SpellCastControllerTriggeredAbility(new RevealLibraryPutIntoHandEffect(3, new FilterLandCard(), Zone.LIBRARY), new FilterSpiritOrArcaneCard(), false));
// Soulshift 2
this.addAbility(new SoulshiftAbility(2));
@ -75,40 +68,3 @@ public class ElderPineOfJukai extends CardImpl {
return new ElderPineOfJukai(this);
}
}
class ElderPineOfJukaiEffect extends OneShotEffect {
public ElderPineOfJukaiEffect() {
super(Outcome.DrawCard);
this.staticText = "reveal the top three cards of your library. Put all land cards revealed this way into your hand and the rest on the bottom of your library in any order";
}
public ElderPineOfJukaiEffect(final ElderPineOfJukaiEffect effect) {
super(effect);
}
@Override
public ElderPineOfJukaiEffect copy() {
return new ElderPineOfJukaiEffect(this);
}
@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) {
return false;
}
Cards cards = new CardsImpl();
cards.addAll(controller.getLibrary().getTopCards(game, 3));
controller.revealCards(sourceObject.getName(), cards, game);
for (Card card : cards.getCards(game)) {
if (card.getCardType().contains(CardType.LAND)) {
controller.moveCards(card, Zone.HAND, source, game);
cards.remove(card);
}
}
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;
}
}

View file

@ -34,7 +34,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.EnvoyEffect;
import mage.abilities.effects.common.RevealLibraryPutIntoHandEffect;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -51,7 +52,7 @@ public class EnlistmentOfficer extends CardImpl {
}
public EnlistmentOfficer(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{W}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{W}");
this.subtype.add("Human");
this.subtype.add("Soldier");
@ -60,8 +61,9 @@ public class EnlistmentOfficer extends CardImpl {
// First strike
this.addAbility(FirstStrikeAbility.getInstance());
// When Enlistment Officer enters the battlefield, reveal the top four cards of your library. Put all Soldier cards revealed this way into your hand and the rest on the bottom of your library in any order.
this.addAbility(new EntersBattlefieldTriggeredAbility(new EnvoyEffect(filter, 4)));
this.addAbility(new EntersBattlefieldTriggeredAbility(new RevealLibraryPutIntoHandEffect(4, filter, Zone.LIBRARY)));
}
public EnlistmentOfficer(final EnlistmentOfficer card) {

View file

@ -33,6 +33,7 @@ import mage.abilities.effects.common.RevealLibraryPutIntoHandEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
/**
@ -42,11 +43,10 @@ import mage.filter.common.FilterCreatureCard;
public class EnshrinedMemories extends CardImpl {
public EnshrinedMemories(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{X}{G}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{G}");
// Reveal the top X cards of your library. Put all creature cards revealed this way into your hand and the rest on the bottom of your library in any order.
this.getSpellAbility().addEffect(new RevealLibraryPutIntoHandEffect(new ManacostVariableValue(), new FilterCreatureCard("all creature cards"),true));
this.getSpellAbility().addEffect(new RevealLibraryPutIntoHandEffect(new ManacostVariableValue(), new FilterCreatureCard(), Zone.LIBRARY, true));
}
public EnshrinedMemories(final EnshrinedMemories card) {

View file

@ -69,7 +69,7 @@ public class GarrukCallerOfBeasts extends CardImpl {
this.addAbility(new PlanswalkerEntersWithLoyalityCountersAbility(4));
// +1: Reveal the top 5 cards of your library. Put all creature cards revealed this way into your hand and the rest on the bottom of your library in any order.
this.addAbility(new LoyaltyAbility(new RevealLibraryPutIntoHandEffect(5, new FilterCreatureCard("all creature cards"), true), 1));
this.addAbility(new LoyaltyAbility(new RevealLibraryPutIntoHandEffect(5, new FilterCreatureCard(), Zone.LIBRARY), 1));
// -3: You may put a green creature card from your hand onto the battlefield.
this.addAbility(new LoyaltyAbility(new PutPermanentOnBattlefieldEffect(filterGreenCreature), -3));

View file

@ -34,7 +34,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.EnvoyEffect;
import mage.abilities.effects.common.RevealLibraryPutIntoHandEffect;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -51,7 +52,7 @@ public class GoblinRingleader extends CardImpl {
}
public GoblinRingleader(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{R}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{R}");
this.subtype.add("Goblin");
this.power = new MageInt(2);
@ -59,8 +60,9 @@ public class GoblinRingleader extends CardImpl {
// Haste
this.addAbility(HasteAbility.getInstance());
// When Goblin Ringleader enters the battlefield, reveal the top four cards of your library. Put all Goblin cards revealed this way into your hand and the rest on the bottom of your library in any order.
this.addAbility(new EntersBattlefieldTriggeredAbility(new EnvoyEffect(filter, 4)));
this.addAbility(new EntersBattlefieldTriggeredAbility(new RevealLibraryPutIntoHandEffect(4, filter, Zone.LIBRARY)));
}
public GoblinRingleader(final GoblinRingleader card) {

View file

@ -37,7 +37,7 @@ import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.EnvoyEffect;
import mage.abilities.effects.common.RevealLibraryPutIntoHandEffect;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -54,15 +54,17 @@ public class GraveDefiler extends CardImpl {
}
public GraveDefiler(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{B}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{B}");
this.subtype.add("Zombie");
this.power = new MageInt(2);
this.toughness = new MageInt(1);
// When Grave Defiler enters the battlefield, reveal the top four cards of your library. Put all Zombie cards revealed this way into your hand and the rest on the bottom of your library in any order.
this.addAbility(new EntersBattlefieldTriggeredAbility(new EnvoyEffect(filter, 4)));
this.addAbility(new EntersBattlefieldTriggeredAbility(new RevealLibraryPutIntoHandEffect(4, filter, Zone.LIBRARY)));
// {1}{B}: Regenerate Grave Defiler.
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new RegenerateSourceEffect(), new ManaCostsImpl("{1}{B}"))); }
this.addAbility(new SimpleActivatedAbility(Zone.BATTLEFIELD, new RegenerateSourceEffect(), new ManaCostsImpl("{1}{B}")));
}
public GraveDefiler(final GraveDefiler card) {
super(card);

View file

@ -33,7 +33,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.EnvoyEffect;
import mage.abilities.effects.common.RevealLibraryPutIntoHandEffect;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -50,14 +51,14 @@ public class KavuHowler extends CardImpl {
}
public KavuHowler(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{4}{G}{G}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{4}{G}{G}");
this.subtype.add("Kavu");
this.power = new MageInt(4);
this.toughness = new MageInt(5);
// When Kavu Howler enters the battlefield, reveal the top four cards of your library. Put all Kavu cards revealed this way into your hand and the rest on the bottom of your library in any order.
this.addAbility(new EntersBattlefieldTriggeredAbility(new EnvoyEffect(filter, 4)));
this.addAbility(new EntersBattlefieldTriggeredAbility(new RevealLibraryPutIntoHandEffect(4, filter, Zone.LIBRARY)));
}
public KavuHowler(final KavuHowler card) {

View file

@ -27,19 +27,15 @@
*/
package mage.cards.l;
import java.util.Set;
import java.util.UUID;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.abilities.effects.common.RevealLibraryPutIntoHandEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.CardsImpl;
import mage.game.Game;
import mage.players.Player;
import mage.filter.FilterCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.CardTypePredicate;
/**
*
@ -47,12 +43,18 @@ import mage.players.Player;
*/
public class LairDelve extends CardImpl {
public LairDelve(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{2}{G}");
private static final FilterCard filter = new FilterCard("all creature and land cards");
static {
filter.add(Predicates.or(new CardTypePredicate(CardType.LAND), new CardTypePredicate(CardType.CREATURE)));
}
public LairDelve(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{G}");
// Reveal the top two cards of your library. Put all creature and land cards revealed this way into your hand and the rest on the bottom of your library in any order.
this.getSpellAbility().addEffect(new LairDelveEffect());
this.getSpellAbility().addEffect(new RevealLibraryPutIntoHandEffect(2, filter, Zone.LIBRARY));
}
public LairDelve(final LairDelve card) {
@ -64,47 +66,3 @@ public class LairDelve extends CardImpl {
return new LairDelve(this);
}
}
class LairDelveEffect extends OneShotEffect {
public LairDelveEffect() {
super(Outcome.DrawCard);
this.staticText = "Reveal the top two cards of your library. Put all creature and land cards revealed this way into your hand and the rest on the bottom of your library in any order";
}
public LairDelveEffect(final LairDelveEffect effect) {
super(effect);
}
@Override
public LairDelveEffect copy() {
return new LairDelveEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
CardsImpl cards = new CardsImpl();
int amount = Math.min(2, player.getLibrary().size());
for (int i = 0; i < amount; i++) {
cards.add(player.getLibrary().removeFromTop(game));
}
player.revealCards("Lair Delve", cards, game);
Set<Card> cardsList = cards.getCards(game);
for (Card card : cardsList) {
if (card.getCardType().contains(CardType.CREATURE) || card.getCardType().contains(CardType.LAND)) {
card.moveToZone(Zone.HAND, source.getSourceId(), game, true);
cards.remove(card);
}
}
player.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;
}
}

View file

@ -29,20 +29,15 @@ package mage.cards.m;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.RevealLibraryPutIntoHandEffect;
import mage.abilities.keyword.FlyingAbility;
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.game.Game;
import mage.players.Player;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.SubtypePredicate;
/**
*
@ -50,16 +45,26 @@ import mage.players.Player;
*/
public class MerfolkWayfinder extends CardImpl {
private static final FilterCard filter = new FilterCard("all Island cards");
static {
filter.add(new SubtypePredicate("Island"));
}
public MerfolkWayfinder(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{2}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{U}");
this.subtype.add("Merfolk");
this.subtype.add("Scout");
this.power = new MageInt(1);
this.toughness = new MageInt(2);
// Flying
this.addAbility(FlyingAbility.getInstance());
this.addAbility(new EntersBattlefieldTriggeredAbility(new MerfolkWayfinderEffect()));
// When Merfolk Wayfinder enters the battlefield, reveal the top three cards of your library. Put all Island cards revealed this way into your hand and the rest on the bottom of your library in any order
this.addAbility(new EntersBattlefieldTriggeredAbility(new RevealLibraryPutIntoHandEffect(3, filter, Zone.LIBRARY)));
}
public MerfolkWayfinder(final MerfolkWayfinder card) {
@ -71,46 +76,3 @@ public class MerfolkWayfinder extends CardImpl {
return new MerfolkWayfinder(this);
}
}
class MerfolkWayfinderEffect extends OneShotEffect {
public MerfolkWayfinderEffect() {
super(Outcome.DrawCard);
this.staticText = "reveal the top three cards of your library. Put all Island cards revealed this way into your hand and the rest on the bottom of your library in any order";
}
public MerfolkWayfinderEffect(final MerfolkWayfinderEffect effect) {
super(effect);
}
@Override
public MerfolkWayfinderEffect copy() {
return new MerfolkWayfinderEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
if (player == null) {
return false;
}
Cards cards = new CardsImpl();
Cards cardsToReveal = new CardsImpl();
int count = Math.min(player.getLibrary().size(), 3);
for (int i = 0; i < count; i++) {
Card card = player.getLibrary().removeFromTop(game);
if (card != null) {
cardsToReveal.add(card);
if (card.hasSubtype("Island", game)) {
card.moveToZone(Zone.HAND, source.getSourceId(), game, false);
} else {
cards.add(card);
}
}
}
player.revealCards("Merfolk Wayfinder", cardsToReveal, game);
player.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;
}
}

View file

@ -28,19 +28,12 @@
package mage.cards.m;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.abilities.effects.common.RevealLibraryPutIntoHandEffect;
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.game.Game;
import mage.players.Player;
import mage.filter.common.FilterLandCard;
/**
*
@ -49,11 +42,10 @@ import mage.players.Player;
public class Mulch extends CardImpl {
public Mulch(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{1}{G}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{1}{G}");
// Reveal the top four cards of your library. Put all land cards revealed this way into your hand and the rest into your graveyard.
this.getSpellAbility().addEffect(new MulchEffect());
this.getSpellAbility().addEffect(new RevealLibraryPutIntoHandEffect(4, new FilterLandCard(), Zone.GRAVEYARD));
}
public Mulch(final Mulch card) {
@ -65,47 +57,3 @@ public class Mulch extends CardImpl {
return new Mulch(this);
}
}
class MulchEffect extends OneShotEffect {
public MulchEffect() {
super(Outcome.DrawCard);
this.staticText = "Reveal the top four cards of your library. Put all land cards revealed this way into your hand and the rest into your graveyard";
}
public MulchEffect(final MulchEffect effect) {
super(effect);
}
@Override
public MulchEffect copy() {
return new MulchEffect(this);
}
@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) {
Cards cards = new CardsImpl();
cards.addAll(controller.getLibrary().getTopCards(game, 4));
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getName(), cards, game);
Cards landCards = new CardsImpl();
Cards otherCards = new CardsImpl();
for (Card card: cards.getCards(game)) {
if (card.getCardType().contains(CardType.LAND)) {
landCards.add(card);
} else {
otherCards.add(card);
}
}
controller.moveCards(landCards, Zone.HAND, source, game);
controller.moveCards(otherCards, Zone.GRAVEYARD, source, game);
}
return true;
}
return false;
}
}

View file

@ -34,7 +34,8 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.effects.common.EnvoyEffect;
import mage.abilities.effects.common.RevealLibraryPutIntoHandEffect;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.SubtypePredicate;
@ -51,7 +52,7 @@ public class SylvanMessenger extends CardImpl {
}
public SylvanMessenger(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{3}{G}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{3}{G}");
this.subtype.add("Elf");
this.power = new MageInt(2);
@ -60,7 +61,7 @@ public class SylvanMessenger extends CardImpl {
// Trample
this.addAbility(TrampleAbility.getInstance());
// When Sylvan Messenger enters the battlefield, reveal the top four cards of your library. Put all Elf cards revealed this way into your hand and the rest on the bottom of your library in any order.
this.addAbility(new EntersBattlefieldTriggeredAbility(new EnvoyEffect(filter, 4)));
this.addAbility(new EntersBattlefieldTriggeredAbility(new RevealLibraryPutIntoHandEffect(4, filter, Zone.LIBRARY)));
}
public SylvanMessenger(final SylvanMessenger card) {

View file

@ -34,17 +34,17 @@ import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.abilities.effects.common.RevealLibraryPutIntoHandEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.cards.repository.CardRepository;
import mage.choices.Choice;
import mage.choices.ChoiceImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.game.Game;
import mage.players.Player;
@ -55,7 +55,7 @@ import mage.players.Player;
public class WoodSage extends CardImpl {
public WoodSage(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.CREATURE},"{G}{U}");
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{G}{U}");
this.subtype.add("Human");
this.subtype.add("Druid");
this.power = new MageInt(1);
@ -76,7 +76,6 @@ public class WoodSage extends CardImpl {
}
}
class WoodSageEffect extends OneShotEffect {
public WoodSageEffect() {
@ -111,20 +110,10 @@ class WoodSageEffect extends OneShotEffect {
game.informPlayers(sourceObject.getLogName() + ", named card: [" + cardName + "]");
}
Cards cards = new CardsImpl();
cards.addAll(controller.getLibrary().getTopCards(game, 4));
if (!cards.isEmpty()) {
Cards cardsToHand = new CardsImpl();
controller.revealCards(sourceObject.getName(), cards, game);
for (Card card: cards.getCards(game)) {
if (card.getName().equals(cardName)) {
cardsToHand.add(card);
cards.remove(card);
}
}
controller.moveCards(cardsToHand, Zone.HAND, source, game);
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
}
FilterCreatureCard filter = new FilterCreatureCard("all of them with that name");
filter.add(new NamePredicate(cardName));
new RevealLibraryPutIntoHandEffect(4, filter, Zone.GRAVEYARD).apply(game, source);
return true;
}

View file

@ -1,101 +0,0 @@
/*
* 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
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* 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.abilities.effects.common;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.Mode;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.game.Game;
import mage.players.Player;
import mage.util.CardUtil;
/**
*
* @author LoneFox
*/
public class EnvoyEffect extends OneShotEffect {
private final FilterCard filter;
private final int numCards;
public EnvoyEffect(FilterCard filter, int numCards) {
super(Outcome.DrawCard);
this.filter = filter;
this.numCards = numCards;
}
public EnvoyEffect(final EnvoyEffect effect) {
super(effect);
this.filter = effect.filter.copy();
this.numCards = effect.numCards;
}
@Override
public EnvoyEffect copy() {
return new EnvoyEffect(this);
}
@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) {
return false;
}
Cards cards = new CardsImpl();
cards.addAll(controller.getLibrary().getTopCards(game, numCards));
controller.revealCards(sourceObject.getIdName(), cards, game);
Cards cardsToHand = new CardsImpl();
for (Card card : cards.getCards(game)) {
if (filter.match(card, game)) {
cardsToHand.add(card);
}
}
cards.removeAll(cardsToHand);
controller.moveCards(cardsToHand, Zone.HAND, source, game);
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
return true;
}
@Override
public String getText(Mode mode) {
if (staticText != null && !staticText.isEmpty()) {
return staticText;
}
return "Reveal the top " + CardUtil.numberToText(numCards) + " cards of your library. Put all "
+ filter.getMessage() + " revealed this way into your hand and the rest on the bottom of your library in any order.";
}
}

View file

@ -51,16 +51,22 @@ public class RevealLibraryPutIntoHandEffect extends OneShotEffect {
private DynamicValue amountCards;
private FilterCard filter;
private Zone zoneToPutRest;
private boolean anyOrder;
public RevealLibraryPutIntoHandEffect(int amountCards, FilterCard filter, boolean anyOrder) {
this(new StaticValue(amountCards), filter, anyOrder);
public RevealLibraryPutIntoHandEffect(int amountCards, FilterCard filter, Zone zoneToPutRest) {
this(amountCards, filter, zoneToPutRest, true);
}
public RevealLibraryPutIntoHandEffect(DynamicValue amountCards, FilterCard filter, boolean anyOrder) {
public RevealLibraryPutIntoHandEffect(int amountCards, FilterCard filter, Zone zoneToPutRest, boolean anyOrder) {
this(new StaticValue(amountCards), filter, zoneToPutRest, anyOrder);
}
public RevealLibraryPutIntoHandEffect(DynamicValue amountCards, FilterCard filter, Zone zoneToPutRest, boolean anyOrder) {
super(Outcome.DrawCard);
this.amountCards = amountCards;
this.filter = filter;
this.zoneToPutRest = zoneToPutRest;
this.anyOrder = anyOrder;
this.staticText = setText();
}
@ -69,6 +75,7 @@ public class RevealLibraryPutIntoHandEffect extends OneShotEffect {
super(effect);
this.amountCards = effect.amountCards;
this.filter = effect.filter;
this.zoneToPutRest = effect.zoneToPutRest;
this.anyOrder = effect.anyOrder;
}
@ -98,7 +105,14 @@ public class RevealLibraryPutIntoHandEffect extends OneShotEffect {
}
}
controller.moveCards(cardsToHand, Zone.HAND, source, game);
controller.putCardsOnBottomOfLibrary(cards, game, source, anyOrder);
switch (zoneToPutRest) {
case LIBRARY: {
controller.putCardsOnBottomOfLibrary(cards, game, source, anyOrder);
break;
}
default:
controller.moveCards(cards, zoneToPutRest, source, game);
}
return true;
}
@ -106,10 +120,21 @@ public class RevealLibraryPutIntoHandEffect extends OneShotEffect {
StringBuilder sb = new StringBuilder("Reveal the top ");
sb.append(CardUtil.numberToText(amountCards.toString())).append(" cards of your library. Put all ");
sb.append(filter.getMessage());
sb.append(" revealed this way into your hand and the rest on the bottom of your library");
if (anyOrder) {
sb.append(" in any order");
sb.append(" revealed this way into your hand and the rest ");
switch (zoneToPutRest) {
case LIBRARY: {
sb.append("on the bottom of your library");
if (anyOrder) {
sb.append(" in any order");
} else {
sb.append(" in a random order");
}
break;
}
case GRAVEYARD:
sb.append("into your graveyard");
}
return sb.toString();
}
}