* Some rework of filter hanmdling.

This commit is contained in:
LevelX2 2018-04-28 00:30:28 +02:00
parent 1583c3af08
commit 59b9449fb9
9 changed files with 40 additions and 39 deletions

View file

@ -37,10 +37,8 @@ import mage.abilities.effects.common.PutOnLibraryTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.constants.TargetController;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.predicate.other.OwnerPredicate;
import mage.filter.StaticFilters;
import mage.target.common.TargetCardInYourGraveyard;
/**
@ -48,22 +46,16 @@ import mage.target.common.TargetCardInYourGraveyard;
* @author jeffwadsworth
*/
public class ConjurersBauble extends CardImpl {
private static final FilterCard filter = new FilterCard("card from your graveyard");
static {
filter.add(new OwnerPredicate(TargetController.YOU));
}
static final String rule = "Put up to one target card from your graveyard on the bottom of your library";
public ConjurersBauble(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{1}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}");
// {tap}, Sacrifice Conjurer's Bauble: Put up to one target card from your graveyard on the bottom of your library. Draw a card.
Ability ability = new SimpleActivatedAbility(Zone.BATTLEFIELD, new PutOnLibraryTargetEffect(false, rule), new TapSourceCost());
ability.addCost(new SacrificeSourceCost());
ability.addTarget(new TargetCardInYourGraveyard(0, 1, filter));
ability.addTarget(new TargetCardInYourGraveyard(0, 1, StaticFilters.FILTER_CARD_FROM_YOUR_GRAVEYARD));
ability.addEffect(new DrawCardSourceControllerEffect(1));
this.addAbility(ability);
}

View file

@ -29,6 +29,7 @@ package mage.cards.n;
import java.util.UUID;
import mage.abilities.Ability;
import mage.abilities.SpellAbility;
import mage.abilities.costs.common.DiscardXTargetCost;
import mage.abilities.dynamicvalue.common.GetXValue;
import mage.abilities.effects.Effect;
@ -38,6 +39,7 @@ import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.target.Target;
import mage.target.common.TargetCardInYourGraveyard;
@ -49,16 +51,15 @@ import mage.target.common.TargetCardInYourGraveyard;
public class NostalgicDreams extends CardImpl {
public NostalgicDreams(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{G}{G}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{G}{G}");
// As an additional cost to cast Nostalgic Dreams, discard X cards.
this.getSpellAbility().addCost(new DiscardXTargetCost(new FilterCard("cards"), true));
// Return X target cards from your graveyard to your hand. Exile Nostalgic Dreams.
// Return X target cards from your graveyard to your hand.
Effect effect = new ReturnFromGraveyardToHandTargetEffect();
effect.setText("Return X target cards from your graveyard to your hand");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addEffect(effect);
// Exile Nostalgic Dreams.
this.getSpellAbility().addEffect(ExileSpellEffect.getInstance());
}
@ -69,11 +70,12 @@ public class NostalgicDreams extends CardImpl {
@Override
public void adjustTargets(Ability ability, Game game) {
int xValue = new GetXValue().calculate(game, ability, null);
// if (xValue > 0) {
Target target = new TargetCardInYourGraveyard(xValue, new FilterCard("card from your graveyard"));
if (ability instanceof SpellAbility) {
int xValue = new GetXValue().calculate(game, ability, null);
Target target = new TargetCardInYourGraveyard(xValue, StaticFilters.FILTER_CARD_FROM_YOUR_GRAVEYARD);
ability.addTarget(target);
// }
}
}
@Override

View file

@ -51,19 +51,19 @@ import mage.target.common.TargetCardInGraveyard;
/**
*
* @author jonubuu
* @author jonubuu
*/
public class RelicOfProgenitus extends CardImpl {
public RelicOfProgenitus(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.ARTIFACT},"{1}");
super(ownerId, setInfo, new CardType[]{CardType.ARTIFACT}, "{1}");
// {tap}: Target player exiles a card from their graveyard.
Ability firstAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new RelicOfProgenitusEffect(), new TapSourceCost());
firstAbility.addTarget(new TargetPlayer());
this.addAbility(firstAbility);
// {1}, Exile Relic of Progenitus: Exile all cards from all graveyards. Draw a card.
Ability secondAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExileGraveyardAllPlayersEffect(),new GenericManaCost(1));
Ability secondAbility = new SimpleActivatedAbility(Zone.BATTLEFIELD, new ExileGraveyardAllPlayersEffect(), new GenericManaCost(1));
secondAbility.addCost(new ExileSourceCost());
secondAbility.addEffect(new DrawCardSourceControllerEffect(1));
this.addAbility(secondAbility);

View file

@ -34,7 +34,7 @@ import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
import mage.target.common.TargetCardInYourGraveyard;
/**
@ -44,14 +44,13 @@ import mage.target.common.TargetCardInYourGraveyard;
public class Restock extends CardImpl {
public Restock(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{3}{G}{G}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{3}{G}{G}");
// Return two target cards from your graveyard to your hand. Exile Restock.
Effect effect = new ReturnFromGraveyardToHandTargetEffect();
effect.setText("Return two target cards from your graveyard to your hand");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(2, new FilterCard("card from your graveyard")));
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(2, StaticFilters.FILTER_CARD_FROM_YOUR_GRAVEYARD));
this.getSpellAbility().addEffect(ExileSpellEffect.getInstance());
}

View file

@ -35,7 +35,7 @@ import mage.abilities.keyword.UndauntedAbility;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
import mage.target.common.TargetCardInYourGraveyard;
/**
@ -53,7 +53,7 @@ public class SeedsOfRenewal extends CardImpl {
Effect effect = new ReturnFromGraveyardToHandTargetEffect();
effect.setText("Return up to two target cards from your graveyard to your hand");
this.getSpellAbility().addEffect(effect);
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 2, new FilterCard("card from your graveyard")));
this.getSpellAbility().addTarget(new TargetCardInYourGraveyard(0, 2, StaticFilters.FILTER_CARD_FROM_YOUR_GRAVEYARD));
this.getSpellAbility().addEffect(ExileSpellEffect.getInstance());
}

View file

@ -36,7 +36,7 @@ import mage.abilities.effects.common.ReturnFromGraveyardToHandTargetEffect;
import mage.cards.CardImpl;
import mage.cards.CardSetInfo;
import mage.constants.CardType;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.target.common.TargetCardInYourGraveyard;
@ -47,7 +47,7 @@ import mage.target.common.TargetCardInYourGraveyard;
public class WildestDreams extends CardImpl {
public WildestDreams(UUID ownerId, CardSetInfo setInfo) {
super(ownerId,setInfo,new CardType[]{CardType.SORCERY},"{X}{X}{G}");
super(ownerId, setInfo, new CardType[]{CardType.SORCERY}, "{X}{X}{G}");
// Return X target cards from your graveyard to your hand.
// Exile Wildest Dreams.
@ -63,7 +63,7 @@ public class WildestDreams extends CardImpl {
if (ability instanceof SpellAbility) {
int xValue = ability.getManaCostsToPay().getX();
ability.getTargets().clear();
ability.addTarget(new TargetCardInYourGraveyard(xValue, new FilterCard("card from your graveyard")));
ability.addTarget(new TargetCardInYourGraveyard(xValue, StaticFilters.FILTER_CARD_FROM_YOUR_GRAVEYARD));
}
}

View file

@ -71,6 +71,7 @@ public class DoIfCostPaid extends OneShotEffect {
}
message = getCostText() + " and " + effectText + '?';
message = Character.toUpperCase(message.charAt(0)) + message.substring(1);
CardUtil.replaceSourceName(message, mageObject.getName());
} else {
message = chooseUseText;
}

View file

@ -75,6 +75,13 @@ public final class StaticFilters {
static {
FILTER_CARD_CREATURE_YOUR_GRAVEYARD.setLockedFilter(true);
}
public static final FilterCard FILTER_CARD_FROM_YOUR_GRAVEYARD = new FilterCard("card from your graveyard");
static {
FILTER_CARD_FROM_YOUR_GRAVEYARD.setLockedFilter(true);
}
public static final FilterLandCard FILTER_CARD_LAND = new FilterLandCard();
static {

View file

@ -27,20 +27,20 @@
*/
package mage.target.common;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
import mage.abilities.Ability;
import mage.cards.Card;
import mage.cards.Cards;
import mage.constants.Zone;
import mage.filter.FilterCard;
import mage.filter.StaticFilters;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.players.Player;
import mage.target.TargetCard;
import java.util.HashSet;
import java.util.Set;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
@ -48,7 +48,7 @@ import java.util.UUID;
public class TargetCardInYourGraveyard extends TargetCard {
public TargetCardInYourGraveyard() {
this(1, 1, new FilterCard("card from your graveyard"));
this(1, 1, StaticFilters.FILTER_CARD_FROM_YOUR_GRAVEYARD);
}
public TargetCardInYourGraveyard(FilterCard filter) {