[filters] replaced ConvertedManaCost condition with Predicate

This commit is contained in:
North 2012-07-10 23:14:46 +03:00
parent 98feeb9968
commit 85b22de4b0
21 changed files with 44 additions and 62 deletions

View file

@ -38,6 +38,7 @@ import mage.cards.Card;
import mage.cards.CardImpl;
import mage.filter.Filter;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
@ -92,8 +93,7 @@ class AppetiteForBrainsEffect extends OneShotEffect<AppetiteForBrainsEffect> {
Player targetPlayer = game.getPlayer(source.getFirstTarget());
if (player != null && targetPlayer != null) {
FilterCard filter = new FilterCard("with converted mana cost 4 or greater");
filter.setConvertedManaCost(3);
filter.setConvertedManaCostComparison(Filter.ComparisonType.GreaterThan);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.GreaterThan, 3));
targetPlayer.revealCards("Appetite for Brains", targetPlayer.getHand(), game);
TargetCard target = new TargetCard(Zone.PICK, filter);

View file

@ -36,6 +36,7 @@ import mage.abilities.effects.common.ReturnFromGraveyardToBattlefieldTargetEffec
import mage.cards.CardImpl;
import mage.filter.Filter;
import mage.filter.common.FilterCreatureCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.target.Target;
import mage.target.common.TargetCardInYourGraveyard;
@ -49,8 +50,7 @@ public class DriverOfTheDead extends CardImpl<DriverOfTheDead> {
private static final FilterCreatureCard filter = new FilterCreatureCard("creature card with converted mana cost 2 or less from your graveyard to the battlefield");
static {
filter.setConvertedManaCost(3);
filter.setConvertedManaCostComparison(Filter.ComparisonType.LessThan);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, 3));
}
public DriverOfTheDead(UUID ownerId) {

View file

@ -36,6 +36,7 @@ import mage.abilities.effects.common.CounterTargetEffect;
import mage.cards.CardImpl;
import mage.filter.Filter;
import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.target.TargetSpell;
/**
@ -46,8 +47,7 @@ public class Thoughtbind extends CardImpl<Thoughtbind> {
private final static FilterSpell filter = new FilterSpell("spell with converted mana cost 4 or less");
static {
filter.setConvertedManaCost(5);
filter.setConvertedManaCostComparison(Filter.ComparisonType.LessThan);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, 5));
}
public Thoughtbind(UUID ownerId) {

View file

@ -34,6 +34,7 @@ import mage.abilities.effects.common.CounterTargetEffect;
import mage.cards.CardImpl;
import mage.filter.Filter;
import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.target.TargetSpell;
/**
@ -44,8 +45,7 @@ public class SpellSnare extends CardImpl<SpellSnare> {
private final static FilterSpell filter = new FilterSpell("spell with converted mana cost 2");
static {
filter.setConvertedManaCost(2);
filter.setConvertedManaCostComparison(Filter.ComparisonType.Equal);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, 2));
}
public SpellSnare(UUID ownerId) {

View file

@ -34,6 +34,7 @@ import mage.abilities.effects.common.DestroyAllEffect;
import mage.cards.CardImpl;
import mage.filter.Filter;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
/**
*
@ -43,8 +44,7 @@ public class CullingSun extends CardImpl<CullingSun> {
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with converted mana cost 3 or less");
static {
filter.setConvertedManaCost(4);
filter.setConvertedManaCostComparison(Filter.ComparisonType.LessThan);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, 4));
}
public CullingSun(UUID ownerId) {

View file

@ -40,6 +40,7 @@ import mage.cards.CardImpl;
import mage.filter.Filter.ComparisonScope;
import mage.filter.Filter.ComparisonType;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.game.events.GameEvent;
import mage.game.events.GameEvent.EventType;
@ -86,8 +87,7 @@ class SunTitanAbility extends TriggeredAbilityImpl<SunTitanAbility> {
filter.getCardType().add(CardType.LAND);
filter.getCardType().add(CardType.PLANESWALKER);
filter.setScopeCardType(ComparisonScope.Any);
filter.setConvertedManaCost(4);
filter.setConvertedManaCostComparison(ComparisonType.LessThan);
filter.add(new ConvertedManaCostPredicate(ComparisonType.LessThan, 4));
}
public SunTitanAbility() {

View file

@ -38,12 +38,12 @@ import mage.cards.Card;
import mage.cards.CardImpl;
import mage.filter.Filter;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
import java.util.UUID;
import mage.filter.Filter.ComparisonType;
/**
* @author Loki
@ -90,8 +90,7 @@ class GreenSunsZenithSearchEffect extends OneShotEffect<GreenSunsZenithSearchEff
filter.getCardType().add(CardType.CREATURE);
filter.setScopeCardType(Filter.ComparisonScope.Any);
//Set the mana cost one higher to 'emulate' a less than or equal to comparison.
filter.setConvertedManaCost(source.getManaCostsToPay().getX() + 1);
filter.setConvertedManaCostComparison(ComparisonType.LessThan);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, source.getManaCostsToPay().getX() + 1));
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (player.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) {

View file

@ -38,6 +38,7 @@ import mage.abilities.effects.common.search.SearchLibraryRevealPutInHandEffect;
import mage.cards.CardImpl;
import mage.filter.Filter;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.target.common.TargetCardInLibrary;
/**
@ -46,12 +47,11 @@ import mage.target.common.TargetCardInLibrary;
*/
public class TreasureMage extends CardImpl<TreasureMage> {
private static FilterCard filter = new FilterCard("an artifact card with converted mana cost 6 or more");
private static final FilterCard filter = new FilterCard("an artifact card with converted mana cost 6 or more");
static {
filter.getCardType().add(CardType.ARTIFACT);
filter.setConvertedManaCost(5);
filter.setConvertedManaCostComparison(Filter.ComparisonType.GreaterThan);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.GreaterThan, 5));
}
public TreasureMage (UUID ownerId) {

View file

@ -43,6 +43,7 @@ import mage.cards.Card;
import mage.cards.CardImpl;
import mage.filter.Filter;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -103,8 +104,7 @@ class BirthingPodEffect extends OneShotEffect<BirthingPodEffect> {
if (sacrificedPermanent != null && player != null) {
int newConvertedCost = sacrificedPermanent.getManaCost().convertedManaCost() + 1;
FilterCard filter = new FilterCard("creature card with converted mana cost " + newConvertedCost);
filter.setConvertedManaCost(newConvertedCost);
filter.setConvertedManaCostComparison(Filter.ComparisonType.Equal);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, newConvertedCost));
filter.getCardType().add(CardType.CREATURE);
filter.setScopeCardType(Filter.ComparisonScope.Any);
TargetCardInLibrary target = new TargetCardInLibrary(filter);

View file

@ -35,6 +35,7 @@ import mage.abilities.effects.common.CounterTargetEffect;
import mage.cards.CardImpl;
import mage.filter.Filter;
import mage.filter.FilterSpell;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.target.TargetSpell;
/**
@ -46,8 +47,7 @@ public class MentalMisstep extends CardImpl<MentalMisstep> {
private final static FilterSpell filter = new FilterSpell("spell with converted mana cost 1");
static {
filter.setConvertedManaCost(1);
filter.setConvertedManaCostComparison(Filter.ComparisonType.Equal);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, 1));
}
public MentalMisstep (UUID ownerId) {

View file

@ -30,10 +30,11 @@ package mage.sets.riseoftheeldrazi;
import java.util.UUID;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.abilities.effects.common.DestroyAllEffect;
import mage.cards.CardImpl;
import mage.filter.Filter;
import mage.filter.common.FilterCreaturePermanent;
import mage.abilities.effects.common.DestroyAllEffect;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
/**
*
@ -44,8 +45,7 @@ public class ConsumeTheMeek extends CardImpl<ConsumeTheMeek> {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creatures with converted mana cost 3 or less");
static {
filter.setConvertedManaCost(4);
filter.setConvertedManaCostComparison(Filter.ComparisonType.LessThan);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, 4));
}
public ConsumeTheMeek(UUID ownerId) {

View file

@ -37,8 +37,9 @@ import mage.abilities.Ability;
import mage.abilities.effects.OneShotEffect;
import mage.cards.Card;
import mage.cards.CardImpl;
import mage.filter.Filter.ComparisonType;
import mage.filter.Filter;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
@ -75,8 +76,7 @@ class InquisitionOfKozilekEffect extends OneShotEffect<InquisitionOfKozilekEffec
static {
filter.getNotCardType().add(CardType.LAND);
filter.setConvertedManaCost(4);
filter.setConvertedManaCostComparison(ComparisonType.LessThan);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, 4));
}
public InquisitionOfKozilekEffect() {

View file

@ -40,6 +40,7 @@ import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.filter.Filter.ComparisonType;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.TargetCard;
@ -91,8 +92,7 @@ class GenesisWaveEffect extends OneShotEffect<GenesisWaveEffect> {
game.setZone(card.getId(), Zone.PICK);
}
FilterCard filter = new FilterCard("card with converted mana cost " + count + " or less to put onto the battlefield");
filter.setConvertedManaCost(count + 1);
filter.setConvertedManaCostComparison(ComparisonType.LessThan);
filter.add(new ConvertedManaCostPredicate(ComparisonType.LessThan, count + 1));
TargetCard target1 = new TargetCard(Zone.PICK, filter);
while (cards.size() > 0 && player.choose(Outcome.PutCardInPlay, cards, target1, game)) {
Card card = cards.get(target1.getFirstTarget(), game);

View file

@ -37,6 +37,7 @@ import mage.abilities.effects.common.search.SearchLibraryRevealPutInHandEffect;
import mage.cards.CardImpl;
import mage.filter.Filter;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.target.common.TargetCardInLibrary;
import java.util.UUID;
@ -46,12 +47,11 @@ import java.util.UUID;
*/
public class TrinketMage extends CardImpl<TrinketMage> {
private static FilterCard filter = new FilterCard("an artifact card with converted mana cost 1 or less");
private static final FilterCard filter = new FilterCard("an artifact card with converted mana cost 1 or less");
static {
filter.getCardType().add(CardType.ARTIFACT);
filter.setConvertedManaCost(2);
filter.setConvertedManaCostComparison(Filter.ComparisonType.LessThan);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, 2));
}
public TrinketMage(UUID ownerId) {

View file

@ -36,6 +36,7 @@ import mage.abilities.keyword.ProtectionAbility;
import mage.cards.CardImpl;
import mage.filter.Filter.ComparisonType;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
/**
*
@ -46,8 +47,7 @@ public class MistmeadowSkulk extends CardImpl<MistmeadowSkulk> {
private static final FilterCard filter = new FilterCard("converted mana cost 3 or greater");
static {
filter.setConvertedManaCost(2);
filter.setConvertedManaCostComparison(ComparisonType.GreaterThan);
filter.add(new ConvertedManaCostPredicate(ComparisonType.GreaterThan, 2));
}
public MistmeadowSkulk(UUID ownerId) {

View file

@ -37,6 +37,7 @@ import mage.abilities.effects.common.search.SearchLibraryRevealPutInHandEffect;
import mage.cards.CardImpl;
import mage.filter.Filter.ComparisonType;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.target.common.TargetCardInLibrary;
/**
@ -49,8 +50,7 @@ public class RangerOfEos extends CardImpl<RangerOfEos> {
static {
filter.getCardType().add(CardType.CREATURE);
filter.setConvertedManaCost(2);
filter.setConvertedManaCostComparison(ComparisonType.LessThan);
filter.add(new ConvertedManaCostPredicate(ComparisonType.LessThan, 2));
}
public RangerOfEos(UUID ownerId) {

View file

@ -43,6 +43,7 @@ import mage.counters.CounterType;
import mage.filter.Filter.ComparisonType;
import mage.filter.common.FilterArtifactCard;
import mage.filter.common.FilterArtifactPermanent;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.game.permanent.Permanent;
import mage.players.Player;
@ -117,8 +118,7 @@ class TezzeretTheSeekerEffect2 extends OneShotEffect<TezzeretTheSeekerEffect2> {
}
FilterArtifactCard filter = new FilterArtifactCard("artifact card with converted mana cost " + cmc);
filter.setConvertedManaCost(cmc);
filter.setConvertedManaCostComparison(ComparisonType.Equal);
filter.add(new ConvertedManaCostPredicate(ComparisonType.Equal, cmc));
TargetCardInLibrary target = new TargetCardInLibrary(filter);
if (player.searchLibrary(target, game)) {

View file

@ -34,6 +34,7 @@ import mage.abilities.effects.common.DestroyTargetEffect;
import mage.cards.CardImpl;
import mage.filter.Filter.ComparisonType;
import mage.filter.common.FilterCreaturePermanent;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.target.common.TargetCreaturePermanent;
/**
@ -45,8 +46,7 @@ public class Smother extends CardImpl<Smother> {
private static final FilterCreaturePermanent filter = new FilterCreaturePermanent("creature with converted mana cost 3 or less");
static {
filter.setConvertedManaCost(4);
filter.setConvertedManaCostComparison(ComparisonType.LessThan);
filter.add(new ConvertedManaCostPredicate(ComparisonType.LessThan, 4));
}
public Smother(UUID ownerId) {

View file

@ -4,6 +4,7 @@ import mage.abilities.common.DiesTriggeredAbility;
import mage.abilities.effects.common.ReturnToHandTargetEffect;
import mage.filter.Filter;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.target.common.TargetCardInYourGraveyard;
public class SoulshiftAbility extends DiesTriggeredAbility {
@ -12,8 +13,7 @@ public class SoulshiftAbility extends DiesTriggeredAbility {
public SoulshiftAbility(int amount) {
super(new ReturnToHandTargetEffect());
FilterCard filter = new FilterCard("Spirit card with converted mana cost " + amount + " or less from your graveyard");
filter.setConvertedManaCost(amount + 1);
filter.setConvertedManaCostComparison(Filter.ComparisonType.LessThan);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.LessThan, amount + 1));
filter.getSubtype().add("Spirit");
filter.setScopeSubtype(Filter.ComparisonScope.Any);
this.addTarget(new TargetCardInYourGraveyard(filter));

View file

@ -11,6 +11,7 @@ import mage.cards.Cards;
import mage.cards.CardsImpl;
import mage.filter.Filter;
import mage.filter.FilterCard;
import mage.filter.predicate.mageobject.ConvertedManaCostPredicate;
import mage.game.Game;
import mage.players.Player;
import mage.target.common.TargetCardInLibrary;
@ -58,8 +59,7 @@ class TransmuteEffect extends OneShotEffect<TransmuteEffect> {
if (sourceCard != null && player != null) {
FilterCard filter = new FilterCard("card with converted mana cost " + sourceCard.getManaCost().convertedManaCost());
filter.setConvertedManaCost(sourceCard.getManaCost().convertedManaCost());
filter.setConvertedManaCostComparison(Filter.ComparisonType.Equal);
filter.add(new ConvertedManaCostPredicate(Filter.ComparisonType.Equal, sourceCard.getManaCost().convertedManaCost()));
TargetCardInLibrary target = new TargetCardInLibrary(1, filter);
if (player.searchLibrary(target, game)) {
if (target.getTargets().size() > 0) {

View file

@ -64,8 +64,6 @@ public class FilterObject<E extends MageObject, T extends FilterObject<E, T>> ex
protected List<String> supertype = new ArrayList<String>();
protected ComparisonScope scopeSupertype = ComparisonScope.Any;
protected boolean notSupertype;
protected int convertedManaCost;
protected ComparisonType convertedManaCostComparison;
protected int power;
protected ComparisonType powerComparison;
protected int toughness;
@ -107,8 +105,6 @@ public class FilterObject<E extends MageObject, T extends FilterObject<E, T>> ex
this.supertype.addAll(filter.supertype);
this.scopeSupertype = filter.scopeSupertype;
this.notSupertype = filter.notSupertype;
this.convertedManaCost = filter.convertedManaCost;
this.convertedManaCostComparison = filter.convertedManaCostComparison;
this.power = filter.power;
this.powerComparison = filter.powerComparison;
this.toughness = filter.toughness;
@ -179,11 +175,6 @@ public class FilterObject<E extends MageObject, T extends FilterObject<E, T>> ex
return notFilter;
}
if (convertedManaCostComparison != null) {
if (!compareInts(object.getManaCost().convertedManaCost(), convertedManaCost, convertedManaCostComparison))
return notFilter;
}
if (powerComparison != null) {
if (!compareInts(object.getPower().getValue(), power, powerComparison))
return notFilter;
@ -261,14 +252,6 @@ public class FilterObject<E extends MageObject, T extends FilterObject<E, T>> ex
this.notSupertype = notSupertype;
}
public void setConvertedManaCost(int convertedManaCost) {
this.convertedManaCost = convertedManaCost;
}
public void setConvertedManaCostComparison(ComparisonType convertedManaCostComparison) {
this.convertedManaCostComparison = convertedManaCostComparison;
}
public void setPower(int power) {
this.power = power;
}