mirror of
https://github.com/magefree/mage.git
synced 2026-01-25 20:59:14 -08:00
[filters] replaced Name condition with Predicate
This commit is contained in:
parent
3d1f23e03b
commit
98feeb9968
28 changed files with 120 additions and 83 deletions
|
|
@ -42,6 +42,7 @@ import mage.cards.CardsImpl;
|
|||
import mage.choices.Choice;
|
||||
import mage.choices.ChoiceImpl;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.sets.Sets;
|
||||
|
|
@ -119,7 +120,7 @@ class MindblazeEffect extends OneShotEffect<MindblazeEffect> {
|
|||
cards.addAll(player.getLibrary().getCards(game));
|
||||
playerControls.revealCards("Library", cards, game);
|
||||
FilterCard filter = new FilterCard();
|
||||
filter.getName().add(cardChoice.getChoice());
|
||||
filter.add(new NamePredicate(cardChoice.getChoice()));
|
||||
int count = Integer.parseInt(numberChoice.getChoice());
|
||||
if (player.getLibrary().count(filter, game) == count) {
|
||||
player.damage(8, source.getSourceId(), game.copy(), false, true);
|
||||
|
|
|
|||
|
|
@ -39,6 +39,8 @@ import mage.abilities.keyword.EnchantAbility;
|
|||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
|
@ -105,8 +107,7 @@ class CurseOfMisfortunesEffect extends OneShotEffect<CurseOfMisfortunesEffect> {
|
|||
for (UUID attachmentId: targetPlayer.getAttachments()) {
|
||||
Permanent attachment = game.getPermanent(attachmentId);
|
||||
if (attachment != null && attachment.getSubtype().contains("Curse")) {
|
||||
filter.getName().add(attachment.getName());
|
||||
filter.setNotName(true);
|
||||
filter.add(Predicates.not(new NamePredicate(attachment.getName())));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import mage.abilities.effects.OneShotEffect;
|
|||
import mage.abilities.keyword.FlashbackAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.target.common.TargetCreaturePermanent;
|
||||
|
|
@ -93,7 +94,7 @@ class SeverTheBloodlineEffect extends OneShotEffect<SeverTheBloodlineEffect> {
|
|||
Permanent targetPermanent = game.getPermanent(targetPointer.getFirst(game, source));
|
||||
if (targetPermanent != null) {
|
||||
FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
||||
filter.getName().add(targetPermanent.getName());
|
||||
filter.add(new NamePredicate(targetPermanent.getName()));
|
||||
List<Permanent> permanents = game.getBattlefield().getActivePermanents(filter, source.getControllerId(), source.getId(), game);
|
||||
for (Permanent permanent : permanents) {
|
||||
permanent.moveToExile(null, "", source.getId(), game);
|
||||
|
|
|
|||
|
|
@ -44,6 +44,7 @@ import mage.target.common.TargetCardInLibrary;
|
|||
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -92,7 +93,7 @@ class HauntingEchoesEffect extends OneShotEffect<HauntingEchoesEffect> {
|
|||
card.moveToExile(null, "", source.getId(), game);
|
||||
|
||||
FilterCard filterCard = new FilterCard("cards named " + card.getName());
|
||||
filterCard.getName().add(card.getName());
|
||||
filterCard.add(new NamePredicate(card.getName()));
|
||||
int count = targetPlayer.getLibrary().count(filterCard, game);
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(count, count, filterCard);
|
||||
target.setRequired(true);
|
||||
|
|
|
|||
|
|
@ -37,6 +37,7 @@ import mage.abilities.effects.common.search.SearchLibraryRevealPutInHandEffect;
|
|||
import mage.abilities.keyword.FlyingAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
/**
|
||||
|
|
@ -48,7 +49,7 @@ public class SquadronHawk extends CardImpl<SquadronHawk> {
|
|||
private static final FilterCard filter = new FilterCard("cards named Squadron Hawk");
|
||||
|
||||
static {
|
||||
filter.getName().add("Squadron Hawk");
|
||||
filter.add(new NamePredicate("Squadron Hawk"));
|
||||
}
|
||||
|
||||
public SquadronHawk(UUID ownerId) {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import mage.cards.Card;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
|
@ -115,7 +116,7 @@ class ArachnusSpinnerEffect extends OneShotEffect<ArachnusSpinnerEffect> {
|
|||
}
|
||||
|
||||
FilterCard filter = new FilterCard("card named Arachnus Web");
|
||||
filter.getName().add("Arachnus Web");
|
||||
filter.add(new NamePredicate("Arachnus Web"));
|
||||
|
||||
Card card = null;
|
||||
Zone zone = null;
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ import mage.target.common.TargetCardInLibrary;
|
|||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -105,7 +106,7 @@ class DoublingChantEffect extends OneShotEffect<DoublingChantEffect> {
|
|||
|
||||
if (player.chooseUse(Outcome.PutCreatureInPlay, sb.toString(), game)) {
|
||||
FilterCreatureCard filter = new FilterCreatureCard("creature card named" + creatureName);
|
||||
filter.getName().add(creatureName);
|
||||
filter.add(new NamePredicate(creatureName));
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(filter);
|
||||
|
||||
if (player.searchLibrary(target, game)) {
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import mage.cards.CardImpl;
|
|||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
|
@ -91,8 +92,10 @@ class MitoticManipulationEffect extends OneShotEffect<MitoticManipulationEffect>
|
|||
public boolean apply(Game game, Ability source) {
|
||||
List<Permanent> permanents = game.getBattlefield().getActivePermanents(source.getControllerId(), game);
|
||||
HashSet<String> permanentNames = new HashSet<String>();
|
||||
FilterCard filter = new FilterCard("card to put onto the battlefield");
|
||||
for (Permanent permanent : permanents) {
|
||||
permanentNames.add(permanent.getName());
|
||||
filter.add(new NamePredicate(permanent.getName()));
|
||||
}
|
||||
|
||||
Player player = game.getPlayer(source.getControllerId());
|
||||
|
|
@ -116,8 +119,6 @@ class MitoticManipulationEffect extends OneShotEffect<MitoticManipulationEffect>
|
|||
player.lookAtCards("Mitotic Manipulation", cards, game);
|
||||
|
||||
if (!cardsFound.isEmpty() && player.chooseUse(Outcome.PutCardInPlay, "Do you wish to put a card on the battlefield?", game)) {
|
||||
FilterCard filter = new FilterCard("card to put onto the battlefield");
|
||||
filter.getName().add(permanentNames);
|
||||
TargetCard target = new TargetCard(Zone.PICK, filter);
|
||||
|
||||
if (player.choose(Outcome.PutCardInPlay, cardsFound, target, game)) {
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.filter.Filter;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.target.common.TargetCardInYourGraveyard;
|
||||
|
||||
|
|
@ -54,7 +55,7 @@ public class EverbarkShaman extends CardImpl<EverbarkShaman> {
|
|||
private final static FilterCard filterTreefolk = new FilterCard("Treefolk from your graveyard");
|
||||
|
||||
static {
|
||||
filterForest.getName().add("Forest");
|
||||
filterForest.add(new NamePredicate("Forest"));
|
||||
filterTreefolk.getSubtype().add("Treefolk");
|
||||
filterTreefolk.setScopeSubtype(Filter.ComparisonScope.Any);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -40,6 +40,7 @@ import mage.cards.CardImpl;
|
|||
import mage.cards.Cards;
|
||||
import mage.cards.CardsImpl;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInGraveyard;
|
||||
|
|
@ -104,7 +105,7 @@ class SurgicalExtractionEffect extends OneShotEffect<SurgicalExtractionEffect> {
|
|||
Player targetPlayer = game.getPlayer(card.getOwnerId());
|
||||
if (targetPlayer != null) {
|
||||
FilterCard filter = new FilterCard("card named " + card.getName());
|
||||
filter.getName().add(card.getName());
|
||||
filter.add(new NamePredicate(card.getName()));
|
||||
|
||||
Cards cardsInLibrary = new CardsImpl(Zone.LIBRARY);
|
||||
cardsInLibrary.addAll(targetPlayer.getLibrary().getCards(game));
|
||||
|
|
|
|||
|
|
@ -36,6 +36,7 @@ import mage.abilities.costs.common.SacrificeTargetCost;
|
|||
import mage.abilities.keyword.AnnihilatorAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.common.FilterControlledPermanent;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.target.common.TargetControlledPermanent;
|
||||
|
||||
/**
|
||||
|
|
@ -48,7 +49,7 @@ public class HandOfEmrakul extends CardImpl<HandOfEmrakul> {
|
|||
private static final FilterControlledPermanent filter = new FilterControlledPermanent("Eldrazi Spawn");
|
||||
|
||||
static {
|
||||
filter.getName().add("Eldrazi Spawn");
|
||||
filter.add(new NamePredicate("Eldrazi Spawn"));
|
||||
}
|
||||
|
||||
public HandOfEmrakul(UUID ownerId) {
|
||||
|
|
|
|||
|
|
@ -36,13 +36,15 @@ import mage.MageInt;
|
|||
import mage.abilities.Ability;
|
||||
import mage.abilities.common.SimpleActivatedAbility;
|
||||
import mage.abilities.costs.mana.ManaCostsImpl;
|
||||
import mage.abilities.effects.common.RegenerateTargetEffect;
|
||||
import mage.abilities.effects.common.continious.BoostControlledEffect;
|
||||
import mage.abilities.effects.common.continious.GainAbilityControlledEffect;
|
||||
import mage.abilities.effects.common.RegenerateTargetEffect;
|
||||
import mage.abilities.keyword.TrampleAbility;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.Predicates;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
|
||||
/**
|
||||
|
|
@ -59,8 +61,7 @@ public class EzuriRenegadeLeader extends CardImpl<EzuriRenegadeLeader> {
|
|||
elfFilter.setMessage("Elf creatures");
|
||||
|
||||
notEzuri.getSubtype().add("Elf");
|
||||
notEzuri.getName().add("Ezuri, Renegade Leader");
|
||||
notEzuri.setNotName(true);
|
||||
notEzuri.add(Predicates.not(new NamePredicate("Ezuri, Renegade Leader")));
|
||||
}
|
||||
|
||||
public EzuriRenegadeLeader(UUID ownerId) {
|
||||
|
|
|
|||
|
|
@ -45,6 +45,7 @@ import mage.cards.Card;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.common.FilterLandCard;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
|
@ -132,7 +133,7 @@ class SameNameAsExiledCountValue implements DynamicValue {
|
|||
Permanent permanent = game.getPermanent(sourceAbility.getSourceId());
|
||||
if (permanent != null && permanent.getImprinted().size() > 0) {
|
||||
FilterPermanent filterPermanent = new FilterPermanent();
|
||||
filterPermanent.getName().add(game.getCard(permanent.getImprinted().get(0)).getName());
|
||||
filterPermanent.add(new NamePredicate(game.getCard(permanent.getImprinted().get(0)).getName()));
|
||||
value = game.getBattlefield().countAll(filterPermanent, game);
|
||||
}
|
||||
return value;
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import mage.abilities.effects.common.search.SearchLibraryPutInPlayEffect;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
import mage.target.common.TargetControlledCreaturePermanent;
|
||||
|
||||
|
|
@ -63,10 +64,8 @@ public class AngelsHerald extends CardImpl<AngelsHerald> {
|
|||
filterWhite.setUseColor(true);
|
||||
filterBlue.getColor().setBlue(true);
|
||||
filterBlue.setUseColor(true);
|
||||
}
|
||||
|
||||
static {
|
||||
filter.getName().add("Empyrial Archangel");
|
||||
filter.add(new NamePredicate("Empyrial Archangel"));
|
||||
}
|
||||
|
||||
public AngelsHerald(UUID ownerId) {
|
||||
|
|
|
|||
|
|
@ -39,6 +39,7 @@ import mage.abilities.effects.OneShotEffect;
|
|||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
import mage.players.Player;
|
||||
|
|
@ -113,8 +114,8 @@ class ClarionUltimatumEffect extends OneShotEffect<ClarionUltimatumEffect> {
|
|||
sb.append("Search for ").append(cardName).append(" in your library?");
|
||||
|
||||
if (player.chooseUse(Outcome.PutCardInPlay, sb.toString(), game)) {
|
||||
FilterCard filter = new FilterCard("card named" + cardName);
|
||||
filter.getName().add(cardName);
|
||||
FilterCard filter = new FilterCard("card named " + cardName);
|
||||
filter.add(new NamePredicate(cardName));
|
||||
TargetCardInLibrary target = new TargetCardInLibrary(filter);
|
||||
|
||||
if (player.searchLibrary(target, game)) {
|
||||
|
|
|
|||
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.sets.shardsofalara;
|
||||
|
||||
import java.util.UUID;
|
||||
import mage.Constants.CardType;
|
||||
import mage.Constants.Outcome;
|
||||
import mage.Constants.Rarity;
|
||||
|
|
@ -39,11 +40,10 @@ import mage.abilities.keyword.FirstStrikeAbility;
|
|||
import mage.cards.CardImpl;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.common.FilterLandPermanent;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
||||
import java.util.UUID;
|
||||
|
||||
/**
|
||||
*
|
||||
* @author BetaSteward_at_googlemail.com
|
||||
|
|
@ -80,7 +80,7 @@ class KnightOfTheWhiteOrchidAbility extends ZoneChangeTriggeredAbility<KnightOfT
|
|||
private static final FilterLandPermanent filter2 = new FilterLandPermanent();
|
||||
|
||||
static {
|
||||
filter1.getName().add("Plains");
|
||||
filter1.add(new NamePredicate("Plains"));
|
||||
}
|
||||
|
||||
public KnightOfTheWhiteOrchidAbility() {
|
||||
|
|
|
|||
|
|
@ -33,6 +33,7 @@ import mage.Constants.Rarity;
|
|||
import mage.abilities.effects.common.DestroyAllEffect;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.FilterPermanent;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
|
||||
/**
|
||||
*
|
||||
|
|
@ -43,7 +44,7 @@ public class Boil extends CardImpl<Boil> {
|
|||
private final static FilterPermanent filter = new FilterPermanent("islands");
|
||||
|
||||
static {
|
||||
filter.getName().add("Island");
|
||||
filter.add(new NamePredicate("Island"));
|
||||
}
|
||||
|
||||
public Boil(UUID ownerId) {
|
||||
|
|
|
|||
|
|
@ -42,6 +42,7 @@ import mage.abilities.common.SimpleStaticAbility;
|
|||
import mage.abilities.effects.ContinuousEffectImpl;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.common.FilterCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.permanent.Permanent;
|
||||
|
||||
|
|
@ -54,7 +55,7 @@ public class RelentlessRats extends CardImpl<RelentlessRats> {
|
|||
private final static FilterCreaturePermanent filter = new FilterCreaturePermanent();
|
||||
|
||||
static {
|
||||
filter.getName().add("Relentless Rats");
|
||||
filter.add(new NamePredicate("Relentless Rats"));
|
||||
}
|
||||
|
||||
public RelentlessRats(UUID ownerId) {
|
||||
|
|
|
|||
|
|
@ -50,6 +50,7 @@ import mage.abilities.keyword.TrampleAbility;
|
|||
import mage.cards.Card;
|
||||
import mage.cards.CardImpl;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.game.events.GameEvent;
|
||||
import mage.game.events.ZoneChangeEvent;
|
||||
|
|
@ -155,7 +156,7 @@ class GigantiformEffect extends OneShotEffect<GigantiformEffect> {
|
|||
private static final FilterCard filter = new FilterCard("card named Gigantiform");
|
||||
|
||||
static {
|
||||
filter.getName().add("Gigantiform");
|
||||
filter.add(new NamePredicate("Gigantiform"));
|
||||
}
|
||||
|
||||
public GigantiformEffect() {
|
||||
|
|
|
|||
|
|
@ -41,6 +41,7 @@ import mage.cards.CardImpl;
|
|||
import mage.counters.CounterType;
|
||||
import mage.filter.FilterCard;
|
||||
import mage.filter.common.FilterControlledCreaturePermanent;
|
||||
import mage.filter.predicate.mageobject.NamePredicate;
|
||||
import mage.game.Game;
|
||||
import mage.players.Player;
|
||||
import mage.target.common.TargetCardInLibrary;
|
||||
|
|
@ -51,14 +52,12 @@ import mage.target.common.TargetCardInLibrary;
|
|||
*/
|
||||
public class NissaRevane extends CardImpl<NissaRevane> {
|
||||
|
||||
private static final FilterCard nissasChosenFilter = new FilterCard();
|
||||
private static final FilterCard elfFilter = new FilterCard();
|
||||
private static final FilterCard nissasChosenFilter = new FilterCard("card named Nissa's Chosen");
|
||||
private static final FilterCard elfFilter = new FilterCard("Elf creature cards");
|
||||
|
||||
static {
|
||||
nissasChosenFilter.getName().add("Nissa's Chosen");
|
||||
nissasChosenFilter.setMessage("card named Nissa's Chosen");
|
||||
nissasChosenFilter.add(new NamePredicate("Nissa's Chosen"));
|
||||
elfFilter.getSubtype().add("Elf");
|
||||
elfFilter.setMessage("Elf creature cards");
|
||||
}
|
||||
|
||||
public NissaRevane(UUID ownerId) {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue