Refactored RevealCardsFromLibraryUntil and some cards to use it

This commit is contained in:
Styxo 2016-12-13 09:21:11 +01:00
parent 78e730505e
commit f88d3f0bbf
15 changed files with 788 additions and 903 deletions

View file

@ -41,6 +41,7 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Zone;
import mage.counters.CounterType;
import mage.filter.common.FilterCreatureCard;
import mage.target.common.TargetCreaturePermanent;
@ -63,7 +64,7 @@ public class AjaniValiantProtector extends CardImpl {
this.addAbility(ability);
// +1: Reveal cards from the top of your library until you reveal a creature card. Put that card into your hand and the rest on the bottom of your library in a random order.
this.addAbility(new LoyaltyAbility(new RevealCardsFromLibraryUntilEffect(new FilterCreatureCard()), 1));
this.addAbility(new LoyaltyAbility(new RevealCardsFromLibraryUntilEffect(new FilterCreatureCard(), Zone.HAND, Zone.LIBRARY), 1));
// -11: Put X +1/+1 counters on target creature, where X is your life total. That creature gains trample until end of turn.
Effect effect = new AddCountersTargetEffect(CounterType.P1P1.createInstance(), new ControllerLifeCount());

View file

@ -0,0 +1,66 @@
/*
* 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.cards.a;
import java.util.UUID;
import mage.MageInt;
import mage.abilities.common.DealsDamageToOpponentTriggeredAbility;
import mage.abilities.effects.common.RevealCardsFromLibraryUntilEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.filter.common.FilterLandCard;
/**
*
* @author Styxo
*/
public class AvengingDruid extends CardImpl {
public AvengingDruid(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{2}{G}");
this.subtype.add("Human");
this.subtype.add("Druid");
this.power = new MageInt(1);
this.toughness = new MageInt(3);
// Whenever Avenging Druid deals damage to an opponent, you may reveal cards from the top of your library until you reveal a land card. If you do, put that card onto the battlefield and put all other cards revealed this way into your graveyard.
this.addAbility(new DealsDamageToOpponentTriggeredAbility(new RevealCardsFromLibraryUntilEffect(new FilterLandCard(), Zone.BATTLEFIELD, Zone.GRAVEYARD), true));
}
public AvengingDruid(final AvengingDruid card) {
super(card);
}
@Override
public AvengingDruid copy() {
return new AvengingDruid(this);
}
}

View file

@ -51,7 +51,7 @@ public class EvolutionaryLeap extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{1}{G}");
// {G}, Sacrifice a creature: Reveal cards from the top of your library until you reveal a creature card. Put that card into your hand and the rest on the bottom of your library in a random order.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RevealCardsFromLibraryUntilEffect(new FilterCreatureCard()), new ManaCostsImpl("{G}"));
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RevealCardsFromLibraryUntilEffect(new FilterCreatureCard(), Zone.HAND, Zone.LIBRARY), new ManaCostsImpl("{G}"));
ability.addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent(new FilterControlledCreaturePermanent("a creature"))));
this.addAbility(ability);
}

View file

@ -28,26 +28,19 @@
package mage.cards.f;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.DiesCreatureTriggeredAbility;
import mage.abilities.costs.mana.GenericManaCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DoIfCostPaid;
import mage.cards.Card;
import mage.abilities.effects.common.RevealCardsFromLibraryUntilEffect;
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.TargetController;
import mage.constants.Zone;
import mage.filter.common.FilterCreatureCard;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.permanent.ControllerPredicate;
import mage.game.Game;
import mage.players.Player;
/**
*
@ -66,7 +59,7 @@ public class Foster extends CardImpl {
// Whenever a creature you control dies, you may pay {1}. If you do, reveal cards from the top of your library until you reveal a creature card. Put that card into your hand and the rest into your graveyard.
Ability ability = new DiesCreatureTriggeredAbility(
new DoIfCostPaid(new FosterEffect(), new GenericManaCost(1)),
new DoIfCostPaid(new RevealCardsFromLibraryUntilEffect(new FilterCreatureCard(), Zone.HAND, Zone.GRAVEYARD), new GenericManaCost(1)),
false, filter);
this.addAbility(ability);
}
@ -80,53 +73,3 @@ public class Foster extends CardImpl {
return new Foster(this);
}
}
class FosterEffect extends OneShotEffect {
private static final FilterCreatureCard filter = new FilterCreatureCard();
public FosterEffect() {
super(Outcome.ReturnToHand);
this.staticText = "reveal cards from the top of your library until you reveal a creature card. Put that card into your hand and the rest into your graveyard";
}
public FosterEffect(final FosterEffect effect) {
super(effect);
}
@Override
public FosterEffect copy() {
return new FosterEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller == null || sourceObject == null) {
return false;
}
Cards cards = new CardsImpl();
Card cardFound = null;
while (controller.getLibrary().size() > 0) {
Card card = controller.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
if (filter.match(card, game)){
cardFound = card;
break;
}
}
}
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getName(), cards, game);
if (cardFound != null) {
controller.moveCards(cardFound, Zone.HAND, source, game);
cards.remove(cardFound);
}
controller.moveCards(cards, Zone.GRAVEYARD, source, game);
}
return true;
}
}

View file

@ -29,23 +29,16 @@ package mage.cards.g;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.DiesTriggeredAbility;
import mage.abilities.costs.common.ExileSourceFromGraveCost;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DoIfCostPaid;
import mage.abilities.effects.common.ExileSourceEffect;
import mage.cards.Card;
import mage.abilities.effects.common.RevealCardsFromLibraryUntilEffect;
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.FilterCreatureCard;
/**
*
@ -60,7 +53,7 @@ public class Gamekeeper extends CardImpl {
this.toughness = new MageInt(2);
// When Gamekeeper dies, you may exile it. If you do, reveal cards from the top of your library until you reveal a creature card. Put that card onto the battlefield and put all other cards revealed this way into your graveyard.
Ability ability = new DiesTriggeredAbility(new DoIfCostPaid(new GamekeeperEffect(), new ExileSourceFromGraveCost(), "Exile to reveal cards from the top of your library until you reveal a creature card?"), false);
Ability ability = new DiesTriggeredAbility(new DoIfCostPaid(new RevealCardsFromLibraryUntilEffect(new FilterCreatureCard(), Zone.BATTLEFIELD, Zone.GRAVEYARD), new ExileSourceFromGraveCost(), "Exile to reveal cards from the top of your library until you reveal a creature card?"), false);
this.addAbility(ability);
}
@ -73,42 +66,3 @@ public class Gamekeeper extends CardImpl {
return new Gamekeeper(this);
}
}
class GamekeeperEffect extends OneShotEffect {
public GamekeeperEffect() {
super(Outcome.Benefit);
staticText = "reveal cards from the top of your library until you reveal a creature card. Put that card onto the battlefield and put all other cards revealed this way into your graveyard";
}
public GamekeeperEffect(final GamekeeperEffect 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) {
new ExileSourceEffect().apply(game, source);
Cards revealedCards = new CardsImpl();
while (controller.getLibrary().size() > 0) {
Card card = controller.getLibrary().removeFromTop(game);
if (card.getCardType().contains(CardType.CREATURE)) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
break;
}
revealedCards.add(card);
}
controller.revealCards(sourceObject.getIdName(), revealedCards, game);
controller.moveCards(revealedCards, Zone.GRAVEYARD, source, game);
return true;
}
return false;
}
@Override
public GamekeeperEffect copy() {
return new GamekeeperEffect(this);
}
}

View file

@ -29,23 +29,16 @@ package mage.cards.h;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.abilities.effects.common.RevealCardsFromLibraryUntilEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.common.FilterBasicLandCard;
import mage.game.Game;
import mage.players.Library;
import mage.players.Player;
/**
*
@ -62,7 +55,7 @@ public class HermitDruid extends CardImpl {
this.toughness = new MageInt(1);
// {G}, {tap}: Reveal cards from the top of your library until you reveal a basic land card. Put that card into your hand and all other cards revealed this way into your graveyard.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new HermitDruidEffect(), new ManaCostsImpl("{G}"));
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RevealCardsFromLibraryUntilEffect(new FilterBasicLandCard(), Zone.HAND, Zone.GRAVEYARD), new ManaCostsImpl("{G}"));
ability.addCost(new TapSourceCost());
this.addAbility(ability);
}
@ -76,57 +69,3 @@ public class HermitDruid extends CardImpl {
return new HermitDruid(this);
}
}
class HermitDruidEffect extends OneShotEffect {
public HermitDruidEffect() {
super(Outcome.Benefit);
this.staticText = "Reveal cards from the top of your library until you reveal a basic land card. Put that card into your hand and all other cards revealed this way into your graveyard";
}
public HermitDruidEffect(final HermitDruidEffect effect) {
super(effect);
}
@Override
public HermitDruidEffect copy() {
return new HermitDruidEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player player = game.getPlayer(source.getControllerId());
MageObject sourceObject= game.getObject(source.getSourceId());
if (player != null) {
Library library = player.getLibrary();
if (library.size() < 1) {
return true;
}
CardsImpl cards = new CardsImpl();
Card card;
FilterBasicLandCard filter = new FilterBasicLandCard();
do {
card = library.removeFromTop(game);
if (card != null) {
if (filter.match(card, game)) {
player.moveCards(card, Zone.HAND, source, game);
} else {
cards.add(card);
}
}
} while (library.size() > 0 && card != null && !filter.match(card, game));
if (!cards.isEmpty()) {
player.moveCards(cards, Zone.GRAVEYARD, source, game);
if (card != null) {
cards.add(card);
}
player.revealCards(sourceObject.getName(), cards, game);
}
return true;
}
return false;
}
}

View file

@ -29,28 +29,21 @@ package mage.cards.j;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeTargetCost;
import mage.abilities.costs.common.TapSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.abilities.effects.common.RevealCardsFromLibraryUntilEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.common.FilterControlledCreaturePermanent;
import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.Predicates;
import mage.filter.predicate.mageobject.SupertypePredicate;
import mage.filter.predicate.permanent.AnotherPredicate;
import mage.game.Game;
import mage.players.Library;
import mage.players.Player;
import mage.target.common.TargetControlledCreaturePermanent;
/**
@ -59,10 +52,12 @@ import mage.target.common.TargetControlledCreaturePermanent;
*/
public class JaliraMasterPolymorphist extends CardImpl {
private static final FilterControlledCreaturePermanent filter = new FilterControlledCreaturePermanent("another creature");
private static final FilterCreatureCard filterCard = new FilterCreatureCard("nonlegendary creature card");
private static final FilterControlledCreaturePermanent filterPermanent = new FilterControlledCreaturePermanent("another creature");
static {
filter.add(new AnotherPredicate());
filterPermanent.add(new AnotherPredicate());
filterCard.add(Predicates.not(new SupertypePredicate("Legendary")));
}
public JaliraMasterPolymorphist(UUID ownerId, CardSetInfo setInfo) {
@ -76,9 +71,9 @@ public class JaliraMasterPolymorphist extends CardImpl {
// {2}{U}, {T}, Sacrifice another creature: Reveal cards from the top of your library until you reveal a nonlegendary creature card.
// Put that card onto the battlefield and the rest on the bottom of your library in a random order.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new JaliraMasterPolymorphistEffect(), new ManaCostsImpl("{2}{U}"));
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RevealCardsFromLibraryUntilEffect(filterCard, Zone.BATTLEFIELD, Zone.LIBRARY), new ManaCostsImpl("{2}{U}"));
ability.addCost(new TapSourceCost());
ability.addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent(1, 1, filter, true)));
ability.addCost(new SacrificeTargetCost(new TargetControlledCreaturePermanent(1, 1, filterPermanent, true)));
this.addAbility(ability);
}
@ -92,63 +87,3 @@ public class JaliraMasterPolymorphist extends CardImpl {
return new JaliraMasterPolymorphist(this);
}
}
class JaliraMasterPolymorphistEffect extends OneShotEffect {
private static final FilterCreatureCard filter = new FilterCreatureCard("nonlegendary creature card");
static {
filter.add(Predicates.not(new SupertypePredicate("Legendary")));
}
public JaliraMasterPolymorphistEffect() {
super(Outcome.PutCardInPlay);
this.staticText = "Reveal cards from the top of your library until you reveal a nonlegendary creature card. Put that card onto the battlefield and the rest on the bottom of your library in a random order";
}
public JaliraMasterPolymorphistEffect(final JaliraMasterPolymorphistEffect effect) {
super(effect);
}
@Override
public JaliraMasterPolymorphistEffect copy() {
return new JaliraMasterPolymorphistEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = game.getObject(source.getSourceId());
if (controller != null && controller.getLibrary().size() > 0) {
CardsImpl cards = new CardsImpl();
Library library = controller.getLibrary();
Card card = null;
do {
card = library.removeFromTop(game);
if (card != null) {
cards.add(card);
}
} while (library.size() > 0 && card != null && !filter.match(card, game));
// reveal cards
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cards, game);
}
if (card != null && filter.match(card, game)) {
// put nonlegendary creature card to battlefield
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
// remove it from revealed card list
cards.remove(card);
}
// Put the rest on the bottom of your library in a random order
while (cards.size() > 0) {
card = cards.getRandom(game);
if (card != null) {
cards.remove(card);
controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.HAND, false, false);
}
}
return true;
}
return false;
}
}

View file

@ -28,21 +28,13 @@
package mage.cards.r;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.ClashWinReturnToHandSpellEffect;
import mage.cards.Card;
import mage.abilities.effects.common.RevealCardsFromLibraryUntilEffect;
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.game.Game;
import mage.players.Player;
/**
*
@ -54,7 +46,7 @@ public class RecrossThePaths extends CardImpl {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{2}{G}");
// Reveal cards from the top of your library until you reveal a land card. Put that card onto the battlefield and the rest on the bottom of your library in any order.
this.getSpellAbility().addEffect(new RecrossThePathsEffect());
this.getSpellAbility().addEffect(new RevealCardsFromLibraryUntilEffect(new FilterLandCard(), Zone.BATTLEFIELD, Zone.LIBRARY, false, true));
// Clash with an opponent. If you win, return Recross the Paths to its owner's hand.
this.getSpellAbility().addEffect(ClashWinReturnToHandSpellEffect.getInstance());
@ -69,53 +61,3 @@ public class RecrossThePaths extends CardImpl {
return new RecrossThePaths(this);
}
}
class RecrossThePathsEffect extends OneShotEffect {
private static final FilterLandCard filter = new FilterLandCard();
public RecrossThePathsEffect() {
super(Outcome.ReturnToHand);
this.staticText = "reveal cards from the top of your library until you reveal a land card. Put that card onto the battlefield and the rest on the bottom of your library in any order";
}
public RecrossThePathsEffect(final RecrossThePathsEffect effect) {
super(effect);
}
@Override
public RecrossThePathsEffect copy() {
return new RecrossThePathsEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
if (controller == null || sourceObject == null) {
return false;
}
Cards cards = new CardsImpl();
Card cardFound = null;
while (controller.getLibrary().size() > 0) {
Card card = controller.getLibrary().removeFromTop(game);
if (card != null) {
cards.add(card);
if (filter.match(card, game)) {
cardFound = card;
break;
}
}
}
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cards, game);
if (cardFound != null) {
controller.moveCards(cardFound, Zone.BATTLEFIELD, source, game);
cards.remove(cardFound);
}
controller.putCardsOnBottomOfLibrary(cards, game, source, true);
}
return true;
}
}

View file

@ -0,0 +1,79 @@
/*
* 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.cards.s;
import java.util.UUID;
import mage.MageInt;
import mage.ObjectColor;
import mage.abilities.Ability;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.costs.mana.ManaCostsImpl;
import mage.abilities.effects.common.RevealCardsFromLibraryUntilEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ColorPredicate;
/**
*
* @author Styxo
*/
public class SacredGuide extends CardImpl {
private static final FilterCard filterCard = new FilterCard("white card");
static {
filterCard.add(new ColorPredicate(ObjectColor.WHITE));
}
public SacredGuide(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.CREATURE}, "{W}");
this.subtype.add("Human");
this.subtype.add("Cleric");
this.power = new MageInt(1);
this.toughness = new MageInt(1);
// {1}{W}, Sacrifice Sacred Guide: Reveal cards from the top of your library until you reveal a white card. Put that card into your hand and exile all other cards revealed this way.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RevealCardsFromLibraryUntilEffect(filterCard, Zone.HAND, Zone.EXILED), new ManaCostsImpl("{1}{W}"));
ability.addCost(new SacrificeSourceCost());
this.addAbility(ability);
}
public SacredGuide(final SacredGuide card) {
super(card);
}
@Override
public SacredGuide copy() {
return new SacredGuide(this);
}
}

View file

@ -45,6 +45,7 @@ import mage.constants.Duration;
import mage.constants.Layer;
import mage.constants.Outcome;
import mage.constants.SubLayer;
import mage.constants.Zone;
import mage.filter.FilterPermanent;
import mage.filter.common.FilterArtifactCard;
import mage.filter.common.FilterControlledArtifactPermanent;
@ -68,7 +69,7 @@ public class TezzeretMasterOfMetal extends CardImpl {
this.addAbility(new PlanswalkerEntersWithLoyalityCountersAbility(5));
// +1: Reveal cards from the top of your library until you reveal an artifact card. Put that card into your hand and the rest on the bottom of your library in a random order.
this.addAbility(new LoyaltyAbility(new RevealCardsFromLibraryUntilEffect(new FilterArtifactCard()), 1));
this.addAbility(new LoyaltyAbility(new RevealCardsFromLibraryUntilEffect(new FilterArtifactCard(), Zone.HAND, Zone.LIBRARY), 1));
// -3: Target opponent loses life equal to the number of artifacts you control.
Ability ability = new LoyaltyAbility(new LoseLifeTargetEffect(new PermanentsOnBattlefieldCount(new FilterControlledArtifactPermanent())), -3);

View file

@ -29,24 +29,17 @@ package mage.cards.t;
import java.util.UUID;
import mage.MageInt;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.TriggeredAbility;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.condition.common.KickedCondition;
import mage.abilities.decorator.ConditionalTriggeredAbility;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.RevealCardsFromLibraryUntilEffect;
import mage.abilities.keyword.KickerAbility;
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.common.FilterCreatureCard;
/**
*
@ -64,7 +57,7 @@ public class ThicketElemental extends CardImpl {
this.addAbility(new KickerAbility("{1}{G}"));
// When Thicket Elemental enters the battlefield, if it was kicked, you may reveal cards from the top of your library until you reveal a creature card. If you do, put that card onto the battlefield and shuffle all other cards revealed this way into your library.
TriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new ThicketElementalEffect());
TriggeredAbility ability = new EntersBattlefieldTriggeredAbility(new RevealCardsFromLibraryUntilEffect(new FilterCreatureCard(), Zone.BATTLEFIELD, Zone.LIBRARY, true));
this.addAbility(new ConditionalTriggeredAbility(ability, KickedCondition.getInstance(),
"When {this} enters the battlefield, if it was kicked, you may reveal cards from the top of your library until you reveal a creature card. If you do, put that card onto the battlefield and shuffle all other cards revealed this way into your library."));
}
@ -78,42 +71,3 @@ public class ThicketElemental extends CardImpl {
return new ThicketElemental(this);
}
}
class ThicketElementalEffect extends OneShotEffect {
public ThicketElementalEffect() {
super(Outcome.Benefit);
staticText = "if {this} was kicked, reveal cards from the top of your library until you reveal a creature card. Put that card onto the battlefield and shuffle all other cards revealed this way into your library";
}
public ThicketElementalEffect(final ThicketElementalEffect 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) {
Cards revealedCards = new CardsImpl();
while (controller.getLibrary().size() > 0) {
Card card = controller.getLibrary().removeFromTop(game);
if (card.getCardType().contains(CardType.CREATURE)) {
controller.moveCards(card, Zone.BATTLEFIELD, source, game);
break;
}
revealedCards.add(card);
}
controller.revealCards(sourceObject.getIdName(), revealedCards, game);
controller.moveCards(revealedCards, Zone.LIBRARY, source, game);
controller.shuffleLibrary(source, game);
return true;
}
return false;
}
@Override
public ThicketElementalEffect copy() {
return new ThicketElementalEffect(this);
}
}

View file

@ -68,8 +68,8 @@ public class AetherRevolt extends ExpansionSet {
cards.add(new SetCardInfo("Ajani, Valiant Protector", 185, Rarity.MYTHIC, mage.cards.a.AjaniValiantProtector.class));
cards.add(new SetCardInfo("Consulate Crackdown", 11, Rarity.RARE, mage.cards.c.ConsulateCrackdown.class));
cards.add(new SetCardInfo("Disallow", 31, Rarity.RARE, mage.cards.d.Disallow.class));
cards.add(new SetCardInfo("Tezzeret, Master of Metal", 190, Rarity.MYTHIC, mage.cards.t.TezzeretMasterOfMetal.class));
cards.add(new SetCardInfo("Pia's Revolution", 91, Rarity.RARE, mage.cards.p.PiasRevolution.class));
cards.add(new SetCardInfo("Tezzeret, Master of Metal", 190, Rarity.MYTHIC, mage.cards.t.TezzeretMasterOfMetal.class));
cards.add(new SetCardInfo("Trophy Mage", 48, Rarity.UNCOMMON, mage.cards.t.TrophyMage.class));
cards.add(new SetCardInfo("Yaheeni's Expertise", 75, Rarity.RARE, mage.cards.y.YaheenisExpertise.class));
}

View file

@ -57,6 +57,7 @@ public class Exodus extends ExpansionSet {
cards.add(new SetCardInfo("Allay", 1, Rarity.COMMON, mage.cards.a.Allay.class));
cards.add(new SetCardInfo("Anarchist", 79, Rarity.COMMON, mage.cards.a.Anarchist.class));
cards.add(new SetCardInfo("Angelic Blessing", 2, Rarity.COMMON, mage.cards.a.AngelicBlessing.class));
cards.add(new SetCardInfo("Avenging Druid", 105, Rarity.COMMON, mage.cards.a.AvengingDruid.class));
cards.add(new SetCardInfo("Bequeathal", 106, Rarity.COMMON, mage.cards.b.Bequeathal.class));
cards.add(new SetCardInfo("Carnophage", 53, Rarity.COMMON, mage.cards.c.Carnophage.class));
cards.add(new SetCardInfo("Cartographer", 107, Rarity.UNCOMMON, mage.cards.c.Cartographer.class));

View file

@ -258,6 +258,7 @@ public class Tempest extends ExpansionSet {
cards.add(new SetCardInfo("Rootwater Hunter", 82, Rarity.COMMON, mage.cards.r.RootwaterHunter.class));
cards.add(new SetCardInfo("Rootwater Matriarch", 83, Rarity.RARE, mage.cards.r.RootwaterMatriarch.class));
cards.add(new SetCardInfo("Ruby Medallion", 295, Rarity.RARE, mage.cards.r.RubyMedallion.class));
cards.add(new SetCardInfo("Sacred Guide", 250, Rarity.RARE, mage.cards.s.SacredGuide.class));
cards.add(new SetCardInfo("Sadistic Glee", 47, Rarity.COMMON, mage.cards.s.SadisticGlee.class));
cards.add(new SetCardInfo("Safeguard", 251, Rarity.RARE, mage.cards.s.Safeguard.class));
cards.add(new SetCardInfo("Salt Flats", 330, Rarity.RARE, mage.cards.s.SaltFlats.class));

View file

@ -47,16 +47,37 @@ import mage.players.Player;
public class RevealCardsFromLibraryUntilEffect extends OneShotEffect {
private FilterCard filter;
private Zone zoneToPutRest;
private Zone zoneToPutCard;
private boolean shuffleRestInto;
private boolean anyOrder;
public RevealCardsFromLibraryUntilEffect(FilterCard filter) {
super(Outcome.ReturnToHand);
public RevealCardsFromLibraryUntilEffect(FilterCard filter, Zone zoneToPutCard, Zone zoneToPutRest) {
this(filter, zoneToPutCard, zoneToPutRest, false, false);
}
public RevealCardsFromLibraryUntilEffect(FilterCard filter, Zone zoneToPutCard, Zone zoneToPutRest, boolean shuffleRestInto) {
this(filter, zoneToPutCard, zoneToPutRest, shuffleRestInto, false);
}
public RevealCardsFromLibraryUntilEffect(FilterCard filter, Zone zoneToPutCard, Zone zoneToPutRest, boolean shuffleRestInto, boolean anyOrder) {
super(Outcome.Benefit);
this.filter = filter;
this.staticText = "reveal cards from the top of your library until you reveal a " + filter.getMessage() + ". Put that card into your hand and the rest on the bottom of your library in a random order";
this.zoneToPutCard = zoneToPutCard;
this.zoneToPutRest = zoneToPutRest;
this.shuffleRestInto = shuffleRestInto;
this.anyOrder = anyOrder;
setText();
}
public RevealCardsFromLibraryUntilEffect(final RevealCardsFromLibraryUntilEffect effect) {
super(effect);
this.filter = effect.filter;
this.zoneToPutCard = effect.zoneToPutCard;
this.zoneToPutRest = effect.zoneToPutRest;
this.shuffleRestInto = effect.shuffleRestInto;
this.anyOrder = effect.anyOrder;
setText();
}
@Override
@ -82,25 +103,73 @@ public class RevealCardsFromLibraryUntilEffect extends OneShotEffect {
if (!cards.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cards, game);
if (filter.match(card, game)) {
// put creature card in hand
controller.moveCards(card, Zone.HAND, source, game);
// put card in correct zone
controller.moveCards(card, zoneToPutCard, source, game);
// remove it from revealed card list
cards.remove(card);
}
// Put the rest on the bottom of your library in a random order
Cards randomOrder = new CardsImpl();
while (cards.size() > 0) {
card = cards.getRandom(game);
if (card != null) {
cards.remove(card);
randomOrder.add(card);
controller.moveCardToLibraryWithInfo(card, source.getSourceId(), game, Zone.HAND, false, false);
// Put the rest in correct zone
switch (zoneToPutRest) {
case LIBRARY: {
if (cards.size() > 0) {
if (shuffleRestInto) {
library.addAll(cards.getCards(game), game);
} else {
controller.putCardsOnBottomOfLibrary(cards, game, source, anyOrder);
}
}
break;
}
default:
if (cards.size() > 0) {
controller.moveCards(cards, zoneToPutRest, source, game);
}
}
controller.putCardsOnBottomOfLibrary(randomOrder, game, source, false);
}
return true;
}
return false;
}
private void setText() {
StringBuilder sb = new StringBuilder("reveal cards from the top of your library until you reveal a " + filter.getMessage() + ". Put that card ");
switch (zoneToPutCard) {
case HAND: {
sb.append("into your hand ");
break;
}
case BATTLEFIELD: {
sb.append("onto the battlefield");
break;
}
}
switch (zoneToPutRest) {
case GRAVEYARD: {
sb.append(" and put all other cards revealed this way into your graveyard.");
break;
}
case LIBRARY: {
if (shuffleRestInto) {
sb.append(", then shuffles the rest into his or her library.");
} else {
sb.append(" and the rest on the bottom of your library in ");
if (anyOrder) {
sb.append("any");
} else {
sb.append("random");
}
sb.append(" order.");
}
break;
}
case EXILED: {
sb.append(" and exile all other cards revealed this way.");
break;
}
}
staticText = sb.toString();
}
}