* fixed the planeswalker search cards to work correctly with aven mindcensor like effects

This commit is contained in:
test 2017-01-12 13:51:22 +01:00
parent 8845319903
commit e18a429e92
5 changed files with 152 additions and 238 deletions

View file

@ -28,29 +28,20 @@
package mage.cards.a;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.common.EntersBattlefieldTriggeredAbility;
import mage.abilities.common.SimpleActivatedAbility;
import mage.abilities.costs.common.SacrificeSourceCost;
import mage.abilities.effects.Effect;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.PreventNextDamageFromChosenSourceToYouEffect;
import mage.cards.Card;
import mage.abilities.effects.common.search.SearchLibraryGraveyardPutInHandEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.constants.CardType;
import mage.constants.Duration;
import mage.constants.Outcome;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
/**
*
@ -58,12 +49,18 @@ import mage.target.TargetCard;
*/
public class AjanisAid extends CardImpl {
private final static FilterCard filter = new FilterCard("Ajani, Valiant Protector");
static {
filter.add(new NamePredicate("Ajani, Valiant Protector"));
}
public AjanisAid(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.ENCHANTMENT}, "{2}{G}{W}");
// When Ajani's Aid enters the battlefield, you may search your library and/or graveyard for a card named Ajani, Valiant Protector, reveal it,
// and put it into your hand. If you search your library this way, shuffle it.
this.addAbility(new EntersBattlefieldTriggeredAbility(new AjanisAidEffect()));
this.addAbility(new EntersBattlefieldTriggeredAbility(new SearchLibraryGraveyardPutInHandEffect(filter), true));
// Sacrifice Ajani's Aid: Prevent all combat damage a creature of your choice would deal this turn.
Effect effect = new PreventNextDamageFromChosenSourceToYouEffect(Duration.EndOfTurn, new FilterCreaturePermanent("creature of your choice"), true);
@ -80,52 +77,3 @@ public class AjanisAid extends CardImpl {
return new AjanisAid(this);
}
}
class AjanisAidEffect extends OneShotEffect {
public AjanisAidEffect() {
super(Outcome.Benefit);
staticText = "You may search your library and/or graveyard for a card named Ajani, Valiant Protector, reveal it, and put it into your hand. "
+ "If you search your library this way, shuffle it";
}
public AjanisAidEffect(final AjanisAidEffect effect) {
super(effect);
}
@Override
public AjanisAidEffect copy() {
return new AjanisAidEffect(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 && controller.chooseUse(outcome, "Search your library and/or graveyard for a card named Ajani, Valiant Protector?", source, game)) {
//Search your library and graveyard
Cards allCards = new CardsImpl();
boolean librarySearched = false;
if (controller.chooseUse(outcome, "Search also your library?", source, game)) {
librarySearched = true;
allCards.addAll(controller.getLibrary().getCardList());
}
allCards.addAll(controller.getGraveyard());
FilterCard filter = new FilterCard("a card named Ajani, Valiant Protector");
filter.add(new NamePredicate("Ajani, Valiant Protector"));
TargetCard target = new TargetCard(0, 1, Zone.ALL, new FilterCard());
if (controller.choose(outcome, allCards, target, game)) {
Card cardFound = game.getCard(target.getFirstTarget());
if (cardFound != null) {
controller.revealCards(sourceObject.getIdName(), new CardsImpl(cardFound), game);
controller.moveCards(cardFound, Zone.HAND, source, game);
}
}
if (librarySearched) {
controller.shuffleLibrary(source, game);
}
return true;
}
return false;
}
}

View file

@ -28,23 +28,13 @@
package mage.cards.l;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DamageTargetEffect;
import mage.cards.Card;
import mage.abilities.effects.common.search.SearchLibraryGraveyardPutInHandEffect;
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.predicate.mageobject.NamePredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCreaturePermanent;
/**
@ -53,14 +43,21 @@ import mage.target.common.TargetCreaturePermanent;
*/
public class LiberatingCombustion extends CardImpl {
private final static FilterCard filter = new FilterCard("Chandra, Pyrogenius");
static {
filter.add(new NamePredicate("Chandra, Pyrogenius"));
}
public LiberatingCombustion(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{4}{R}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{4}{R}");
// Liberating Combustion deals 6 damage to target creature.
this.getSpellAbility().addEffect(new DamageTargetEffect(6));
this.getSpellAbility().addTarget(new TargetCreaturePermanent());
// You may search your library and/or graveyard for a card named Chandra, Pyrogenius, reveal it, and put it into your hand. If you search your library this way, shuffle it.
this.getSpellAbility().addEffect(new LiberatingCombustionEffect());
this.getSpellAbility().addEffect(new SearchLibraryGraveyardPutInHandEffect(filter));
}
public LiberatingCombustion(final LiberatingCombustion card) {
@ -72,51 +69,3 @@ public class LiberatingCombustion extends CardImpl {
return new LiberatingCombustion(this);
}
}
class LiberatingCombustionEffect extends OneShotEffect {
public LiberatingCombustionEffect() {
super(Outcome.Benefit);
staticText = "You may search your library and/or graveyard for a card named Chandra, Pyrogenius, reveal it, and put it into your hand. If you search your library this way, shuffle it";
}
public LiberatingCombustionEffect(final LiberatingCombustionEffect effect) {
super(effect);
}
@Override
public LiberatingCombustionEffect copy() {
return new LiberatingCombustionEffect(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 && controller.chooseUse(outcome, "Search your library and/or graveyard for a card named Chandra, Pyrogenius?", source, game)) {
//Search your library and graveyard
Cards allCards = new CardsImpl();
boolean librarySearched = false;
if (controller.chooseUse(outcome, "Search also your library?", source, game)) {
librarySearched = true;
allCards.addAll(controller.getLibrary().getCardList());
}
allCards.addAll(controller.getGraveyard());
FilterCard filter = new FilterCard("a card named Chandra, Pyrogenius");
filter.add(new NamePredicate("Chandra, Pyrogenius"));
TargetCard target = new TargetCard(0, 1, Zone.ALL, new FilterCard());
if (controller.choose(outcome, allCards, target, game)) {
Card cardFound = game.getCard(target.getFirstTarget());
if (cardFound != null) {
controller.revealCards(sourceObject.getIdName(), new CardsImpl(cardFound), game);
controller.moveCards(cardFound, Zone.HAND, source, game);
}
}
if (librarySearched) {
controller.shuffleLibrary(source, game);
}
return true;
}
return false;
}
}

View file

@ -28,23 +28,13 @@
package mage.cards.t;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.Card;
import mage.abilities.effects.common.search.SearchLibraryGraveyardPutInHandEffect;
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.predicate.mageobject.NamePredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCreaturePermanent;
/**
@ -53,14 +43,22 @@ import mage.target.common.TargetCreaturePermanent;
*/
public class TezzeretsBetrayal extends CardImpl {
private final static FilterCard filter = new FilterCard("Tezzeret, Master of Metal");
static {
filter.add(new NamePredicate("Tezzeret, Master of Metal"));
}
public TezzeretsBetrayal(UUID ownerId, CardSetInfo setInfo) {
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{U}{B}");
// Destroy target creature. You may search your library and/or graveyard for a card named Tezzeret, Master of Metal, reveal it, and put it into your hand.
// If you search your library this way, shuffle it.
// Destroy target creature.
getSpellAbility().addEffect(new DestroyTargetEffect());
getSpellAbility().addTarget(new TargetCreaturePermanent());
getSpellAbility().addEffect(new TezzeretsBetrayalEffect());
// You may search your library and/or graveyard for a card named Tezzeret, Master of Metal, reveal it, and put it into your hand.
// If you search your library this way, shuffle it.
getSpellAbility().addEffect(new SearchLibraryGraveyardPutInHandEffect(filter));
}
public TezzeretsBetrayal(final TezzeretsBetrayal card) {
@ -72,52 +70,3 @@ public class TezzeretsBetrayal extends CardImpl {
return new TezzeretsBetrayal(this);
}
}
class TezzeretsBetrayalEffect extends OneShotEffect {
public TezzeretsBetrayalEffect() {
super(Outcome.Benefit);
staticText = "You may search your library and/or graveyard for a card named Tezzeret, Master of Metal, reveal it, and put it into your hand. "
+ "If you search your library this way, shuffle it";
}
public TezzeretsBetrayalEffect(final TezzeretsBetrayalEffect effect) {
super(effect);
}
@Override
public TezzeretsBetrayalEffect copy() {
return new TezzeretsBetrayalEffect(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 && controller.chooseUse(outcome, "Search your library and/or graveyard for a card named Tezzeret, Master of Metal?", source, game)) {
//Search your library and graveyard
Cards allCards = new CardsImpl();
boolean librarySearched = false;
if (controller.chooseUse(outcome, "Search also your library?", source, game)) {
librarySearched = true;
allCards.addAll(controller.getLibrary().getCardList());
}
allCards.addAll(controller.getGraveyard());
FilterCard filter = new FilterCard("a card named Tezzeret, Master of Metal");
filter.add(new NamePredicate("Tezzeret, Master of Metal"));
TargetCard target = new TargetCard(0, 1, Zone.ALL, new FilterCard());
if (controller.choose(outcome, allCards, target, game)) {
Card cardFound = game.getCard(target.getFirstTarget());
if (cardFound != null) {
controller.revealCards(sourceObject.getIdName(), new CardsImpl(cardFound), game);
controller.moveCards(cardFound, Zone.HAND, source, game);
}
}
if (librarySearched) {
controller.shuffleLibrary(source, game);
}
return true;
}
return false;
}
}

View file

@ -28,23 +28,14 @@
package mage.cards.v;
import java.util.UUID;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.abilities.effects.common.search.SearchLibraryGraveyardPutInHandEffect;
import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect;
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.FilterBasicLandCard;
import mage.filter.predicate.mageobject.NamePredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
import mage.target.common.TargetCardInLibrary;
/**
@ -53,14 +44,20 @@ import mage.target.common.TargetCardInLibrary;
*/
public class VerdantCrescendo extends CardImpl {
private final static FilterCard filter = new FilterCard("Nissa, Nature's Artisan");
static {
filter.add(new NamePredicate("Nissa, Nature's Artisan"));
}
public VerdantCrescendo(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{G}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{G}");
// Search your library for a basic land card and put it onto the battlefield tapped.
this.getSpellAbility().addEffect(new SearchLibraryPutInPlayEffect(new TargetCardInLibrary(new FilterBasicLandCard()), true, false));
// Search your library and graveyard for a card named Nissa, Nature's Artisan, reveal it, and put it into your hand. Then shuffle your library.
this.getSpellAbility().addEffect(new VerdantCrescendoEffect());
this.getSpellAbility().addEffect(new SearchLibraryGraveyardPutInHandEffect(filter, true));
}
public VerdantCrescendo(final VerdantCrescendo card) {
@ -72,45 +69,3 @@ public class VerdantCrescendo extends CardImpl {
return new VerdantCrescendo(this);
}
}
class VerdantCrescendoEffect extends OneShotEffect {
public VerdantCrescendoEffect() {
super(Outcome.Benefit);
staticText = "Search your library and graveyard for a card named Nissa, Nature's Artisan, reveal it, and put it into your hand. Then shuffle your library";
}
public VerdantCrescendoEffect(final VerdantCrescendoEffect effect) {
super(effect);
}
@Override
public VerdantCrescendoEffect copy() {
return new VerdantCrescendoEffect(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) {
//Search your library and graveyard
Cards allCards = new CardsImpl();
allCards.addAll(controller.getLibrary().getCardList());
allCards.addAll(controller.getGraveyard());
FilterCard filter = new FilterCard("a card named Nissa, Nature's Artisan");
filter.add(new NamePredicate("Nissa, Nature's Artisan"));
TargetCard target = new TargetCard(0, 1, Zone.ALL, filter);
if (controller.choose(outcome, allCards, target, game)) {
Cards cardFound = new CardsImpl(target.getTargets());
if (!cardFound.isEmpty()) {
controller.revealCards(sourceObject.getIdName(), cardFound, game);
controller.moveCards(cardFound, Zone.HAND, source, game);
}
}
controller.shuffleLibrary(source, game);
return true;
}
return false;
}
}

View file

@ -0,0 +1,113 @@
/*
* 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.search;
import mage.MageObject;
import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
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.target.TargetCard;
import mage.target.common.TargetCardInLibrary;
/**
*
* @author Styxo
*/
public class SearchLibraryGraveyardPutInHandEffect extends OneShotEffect {
private FilterCard filter;
private boolean forceToSearchBoth;
public SearchLibraryGraveyardPutInHandEffect(FilterCard filter) {
this(filter, false);
}
public SearchLibraryGraveyardPutInHandEffect(FilterCard filter, boolean forceToSearchBoth) {
super(Outcome.Benefit);
this.filter = filter;
this.forceToSearchBoth = forceToSearchBoth;
staticText = "Search your library and" + (forceToSearchBoth ? "" : "/or ") + " graveyard for a card named " + filter.getMessage() + ", reveal it, and put it into your hand. Then shuffle your library";
}
public SearchLibraryGraveyardPutInHandEffect(final SearchLibraryGraveyardPutInHandEffect effect) {
super(effect);
this.filter = effect.filter;
this.forceToSearchBoth = effect.forceToSearchBoth;
}
@Override
public SearchLibraryGraveyardPutInHandEffect copy() {
return new SearchLibraryGraveyardPutInHandEffect(this);
}
@Override
public boolean apply(Game game, Ability source) {
Player controller = game.getPlayer(source.getControllerId());
MageObject sourceObject = source.getSourceObject(game);
Card cardFound = null;
if (controller != null && sourceObject != null) {
if (forceToSearchBoth || controller.chooseUse(outcome, "Search your library for a card named " + filter.getMessage() + "?", source, game)) {
TargetCardInLibrary target = new TargetCardInLibrary(0, 1, filter);
target.clearChosen();
if (controller.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) {
cardFound = game.getCard(target.getFirstTarget());
}
}
controller.shuffleLibrary(source, game);
}
if (cardFound == null && controller.chooseUse(outcome, "Search your graveyard for a card named " + filter.getMessage() + "?", source, game)) {
TargetCard target = new TargetCard(0, 1, Zone.GRAVEYARD, filter);
target.clearChosen();
if (controller.choose(outcome, controller.getGraveyard(), target, game)) {
if (target.getTargets().size() > 0) {
cardFound = game.getCard(target.getFirstTarget());
}
}
}
if (cardFound != null) {
controller.revealCards(sourceObject.getIdName(), new CardsImpl(cardFound), game);
controller.moveCards(cardFound, Zone.HAND, source, game);
}
return true;
}
return false;
}
}