Commonly used CardFilters moved to CardListFilter file

This commit is contained in:
Maxmtg
2011-09-20 01:26:28 +00:00
parent 9917121e0c
commit 035ab8cfb6
19 changed files with 252 additions and 249 deletions

View File

@@ -30,7 +30,7 @@ public final class AllZoneUtil {
*/
public static CardList getCreaturesInPlay(final Player player) {
CardList creats = player.getCardsIn(Zone.Battlefield);
return creats.filter(AllZoneUtil.creatures);
return creats.filter(CardListFilter.creatures);
}
/**
@@ -108,7 +108,7 @@ public final class AllZoneUtil {
*/
public static CardList getCreaturesInPlay() {
CardList creats = getCardsIn(Zone.Battlefield);
return creats.filter(AllZoneUtil.creatures);
return creats.filter(CardListFilter.creatures);
}
///////////////// Lands
@@ -121,7 +121,7 @@ public final class AllZoneUtil {
*/
public static CardList getPlayerLandsInPlay(final Player player) {
CardList cards = player.getCardsIn(Zone.Battlefield);
return cards.filter(lands);
return cards.filter(CardListFilter.lands);
}
/**
@@ -131,7 +131,7 @@ public final class AllZoneUtil {
*/
public static CardList getLandsInPlay() {
CardList cards = getCardsIn(Zone.Battlefield);
return cards.filter(lands);
return cards.filter(CardListFilter.lands);
}
//=============================================================================
@@ -345,141 +345,7 @@ public final class AllZoneUtil {
}
/**
* a CardListFilter to get all cards that are tapped.
*/
public static final CardListFilter tapped = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isTapped();
}
};
/**
* a CardListFilter to get all cards that are untapped.
*/
public static final CardListFilter untapped = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isUntapped();
}
};
/**
* a CardListFilter to get all creatures.
*/
public static final CardListFilter creatures = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isCreature();
}
};
/**
* a CardListFilter to get all enchantments.
*/
public static final CardListFilter enchantments = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isEnchantment();
}
};
/**
* a CardListFilter to get all equipment.
*/
public static final CardListFilter equipment = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isEquipment();
}
};
/**
* a CardListFilter to get all unenchanted cards in a list.
*/
public static final CardListFilter unenchanted = new CardListFilter() {
public boolean addCard(final Card c) {
return !c.isEnchanted();
}
};
/**
* a CardListFilter to get all enchanted cards in a list.
*/
public static final CardListFilter enchanted = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isEnchanted();
}
};
/**
* a CardListFilter to get all nontoken cards.
*/
public static final CardListFilter nonToken = new CardListFilter() {
public boolean addCard(final Card c) {
return !c.isToken();
}
};
/**
* a CardListFilter to get all token cards.
*/
public static final CardListFilter token = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isToken();
}
};
/**
* a CardListFilter to get all nonbasic lands.
*/
public static final CardListFilter nonBasicLand = new CardListFilter() {
public boolean addCard(final Card c) {
return !c.isBasicLand();
}
};
/**
* a CardListFilter to get all basicLands.
*/
public static final CardListFilter basicLands = new CardListFilter() {
public boolean addCard(final Card c) {
//the isBasicLand() check here may be sufficient...
return c.isLand() && c.isBasicLand();
}
};
/**
* a CardListFilter to get all artifacts.
*/
public static final CardListFilter artifacts = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isArtifact();
}
};
/**
* a CardListFilter to get all nonartifacts.
*/
public static final CardListFilter nonartifacts = new CardListFilter() {
public boolean addCard(final Card c) {
return !c.isArtifact();
}
};
/**
* a CardListFilter to get all lands.
*/
public static final CardListFilter lands = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isLand();
}
};
/**
* a CardListFilter to get all nonlands.
*/
public static final CardListFilter nonlands = new CardListFilter() {
public boolean addCard(final Card c) {
return !c.isLand();
}
};
/**
* get a CardListFilter to filter in only cards that can be targeted.
@@ -526,51 +392,6 @@ public final class AllZoneUtil {
return filter;
}
/**
* a CardListFilter to get all cards that are black.
*/
public static final CardListFilter black = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isBlack();
}
};
/**
* a CardListFilter to get all cards that are blue.
*/
public static final CardListFilter blue = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isBlue();
}
};
/**
* a CardListFilter to get all cards that are green.
*/
public static final CardListFilter green = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isGreen();
}
};
/**
* a CardListFilter to get all cards that are red.
*/
public static final CardListFilter red = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isRed();
}
};
/**
* a CardListFilter to get all cards that are white.
*/
public static final CardListFilter white = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isWhite();
}
};
/**
* a CardListFilter to get all cards that are a part of this game.
*

View File

@@ -14,7 +14,6 @@ import java.util.TreeMap;
import com.esotericsoftware.minlog.Log;
import forge.Constant.Zone;
import forge.card.abilityFactory.AbilityFactory;
import forge.card.cardFactory.CardFactoryUtil;
import forge.card.cost.Cost;
import forge.card.mana.ManaCost;

View File

@@ -14,4 +14,187 @@ public interface CardListFilter {
* @return a boolean.
*/
boolean addCard(Card c);
/**
* a CardListFilter to get all cards that are tapped.
*/
public static final CardListFilter tapped = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isTapped();
}
};
/**
* a CardListFilter to get all cards that are untapped.
*/
public static final CardListFilter untapped = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isUntapped();
}
};
/**
* a CardListFilter to get all creatures.
*/
public static final CardListFilter creatures = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isCreature();
}
};
/**
* a CardListFilter to get all enchantments.
*/
public static final CardListFilter enchantments = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isEnchantment();
}
};
/**
* a CardListFilter to get all equipment.
*/
public static final CardListFilter equipment = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isEquipment();
}
};
/**
* a CardListFilter to get all unenchanted cards in a list.
*/
public static final CardListFilter unenchanted = new CardListFilter() {
public boolean addCard(final Card c) {
return !c.isEnchanted();
}
};
/**
* a CardListFilter to get all enchanted cards in a list.
*/
public static final CardListFilter enchanted = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isEnchanted();
}
};
/**
* a CardListFilter to get all nontoken cards.
*/
public static final CardListFilter nonToken = new CardListFilter() {
public boolean addCard(final Card c) {
return !c.isToken();
}
};
/**
* a CardListFilter to get all token cards.
*/
public static final CardListFilter token = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isToken();
}
};
/**
* a CardListFilter to get all nonbasic lands.
*/
public static final CardListFilter nonBasicLand = new CardListFilter() {
public boolean addCard(final Card c) {
return !c.isBasicLand();
}
};
/**
* a CardListFilter to get all basicLands.
*/
public static final CardListFilter basicLands = new CardListFilter() {
public boolean addCard(final Card c) {
//the isBasicLand() check here may be sufficient...
return c.isLand() && c.isBasicLand();
}
};
/**
* a CardListFilter to get all artifacts.
*/
public static final CardListFilter artifacts = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isArtifact();
}
};
/**
* a CardListFilter to get all nonartifacts.
*/
public static final CardListFilter nonartifacts = new CardListFilter() {
public boolean addCard(final Card c) {
return !c.isArtifact();
}
};
/**
* a CardListFilter to get all lands.
*/
public static final CardListFilter lands = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isLand();
}
};
/**
* a CardListFilter to get all nonlands.
*/
public static final CardListFilter nonlands = new CardListFilter() {
public boolean addCard(final Card c) {
return !c.isLand();
}
};
/**
* a CardListFilter to get all cards that are black.
*/
public static final CardListFilter black = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isBlack();
}
};
/**
* a CardListFilter to get all cards that are blue.
*/
public static final CardListFilter blue = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isBlue();
}
};
/**
* a CardListFilter to get all cards that are green.
*/
public static final CardListFilter green = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isGreen();
}
};
/**
* a CardListFilter to get all cards that are red.
*/
public static final CardListFilter red = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isRed();
}
};
/**
* a CardListFilter to get all cards that are white.
*/
public static final CardListFilter white = new CardListFilter() {
public boolean addCard(final Card c) {
return c.isWhite();
}
};
}

View File

@@ -1751,7 +1751,7 @@ public class CombatUtil {
} else if (c.getName().equals("Spectral Force")) {
Player opp = c.getController().getOpponent();
CardList list = opp.getCardsIn(Zone.Battlefield);
list = list.filter(AllZoneUtil.black);
list = list.filter(CardListFilter.black);
if (list.size() == 0) {
c.addExtrinsicKeyword("This card doesn't untap during your next untap step.");
}

View File

@@ -775,7 +775,7 @@ public class ComputerUtil {
static public boolean chooseLandsToPlay() {
Player computer = AllZone.getComputerPlayer();
CardList landList = computer.getCardsIn(Zone.Hand);
landList = landList.filter(AllZoneUtil.lands);
landList = landList.filter(CardListFilter.lands);
CardList lands = AllZoneUtil.getPlayerTypeIn(computer, Zone.Graveyard, "Land");
@@ -1073,7 +1073,7 @@ public class ComputerUtil {
typeList = typeList.getValidCards(type.split(","), activate.getController(), activate);
//is this needed?
typeList = typeList.filter(AllZoneUtil.untapped);
typeList = typeList.filter(CardListFilter.untapped);
if (tap)
typeList.remove(activate);

View File

@@ -1449,9 +1449,9 @@ public class GameAction {
public final void seeWhoPlaysFirst() {
CardList HLibrary = AllZone.getHumanPlayer().getCardsIn(Zone.Library);
HLibrary = HLibrary.filter(AllZoneUtil.nonlands);
HLibrary = HLibrary.filter(CardListFilter.nonlands);
CardList CLibrary = AllZone.getComputerPlayer().getCardsIn(Zone.Library);
CLibrary = CLibrary.filter(AllZoneUtil.nonlands);
CLibrary = CLibrary.filter(CardListFilter.nonlands);
boolean Starter_Determined = false;
int Cut_Count = 0;
@@ -2058,7 +2058,7 @@ public class GameAction {
if (originalCard.getName().equals("Khalni Hydra") && spell.isSpell() == true) {
Player player = AllZone.getPhase().getPlayerTurn();
CardList playerCreature = AllZoneUtil.getCreaturesInPlay(player);
playerCreature = playerCreature.filter(AllZoneUtil.green);
playerCreature = playerCreature.filter(CardListFilter.green);
String manaC = manaCost + " ";
if (playerCreature.size() > 0) {
for (int i = 0; i < playerCreature.size(); i++) {

View File

@@ -936,7 +936,7 @@ public final class GameActionUtil {
public void execute() {
CardList list = src.getController().getCardsIn(Zone.Graveyard);
list = list.filter(AllZoneUtil.creatures);
list = list.filter(CardListFilter.creatures);
if (list.isEmpty()) {
AllZone.getStack().addSimultaneousStackEntry(ability);
@@ -1035,7 +1035,7 @@ public final class GameActionUtil {
public void resolve() {
for (int i = 0; i < damage; i++) {
CardList nonTokens = player.getCardsIn(Zone.Battlefield);
nonTokens = nonTokens.filter(AllZoneUtil.nonToken);
nonTokens = nonTokens.filter(CardListFilter.nonToken);
if (nonTokens.size() == 0) {
player.loseConditionMet(GameLossReason.SpellEffect, lich.getName());
} else {
@@ -1836,7 +1836,7 @@ public final class GameActionUtil {
produces.put("Swamp", "B");
CardList lands = AllZoneUtil.getCardsInGame();
lands = lands.filter(AllZoneUtil.lands);
lands = lands.filter(CardListFilter.lands);
//remove all abilities granted by this Command
for (Card land : lands) {

View File

@@ -682,7 +682,7 @@ public class MagicStack extends MyObservable {
if (sp.isSpell() && AllZoneUtil.isCardInPlay("Bazaar of Wonders")) {
boolean found = false;
CardList all = AllZoneUtil.getCardsIn(Zone.Battlefield);
all = all.filter(AllZoneUtil.nonToken);
all = all.filter(CardListFilter.nonToken);
CardList graves = AllZoneUtil.getCardsIn(Zone.Graveyard);
all.addAll(graves);

View File

@@ -57,7 +57,7 @@ public class PhaseUtil {
AllZone.getGameAction().resetActivationsPerTurn();
CardList lands = AllZoneUtil.getPlayerLandsInPlay(turn);
lands = lands.filter(AllZoneUtil.untapped);
lands = lands.filter(CardListFilter.untapped);
turn.setNumPowerSurgeLands(lands.size());
// anything before this point happens regardless of whether the Untap phase is skipped
@@ -156,7 +156,7 @@ public class PhaseUtil {
if (AllZone.getPhase().getPlayerTurn().isComputer()) {
//search for lands the computer has and only untap 1
CardList landList = AllZoneUtil.getPlayerLandsInPlay(AllZone.getComputerPlayer());
landList = landList.filter(AllZoneUtil.tapped);
landList = landList.filter(CardListFilter.tapped);
if (landList.size() > 0) {
landList.get(0).untap();
}
@@ -181,7 +181,7 @@ public class PhaseUtil {
}//selectCard()
};//Input
CardList landList = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer());
landList = landList.filter(AllZoneUtil.tapped);
landList = landList.filter(CardListFilter.tapped);
if (landList.size() > 0) {
AllZone.getInputControl().setInput(target);
}
@@ -190,8 +190,8 @@ public class PhaseUtil {
if (AllZoneUtil.isCardInPlay("Damping Field") || AllZoneUtil.isCardInPlay("Imi Statue")) {
if (AllZone.getPhase().getPlayerTurn().isComputer()) {
CardList artList = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
artList = artList.filter(AllZoneUtil.artifacts);
artList = artList.filter(AllZoneUtil.tapped);
artList = artList.filter(CardListFilter.artifacts);
artList = artList.filter(CardListFilter.tapped);
if (artList.size() > 0) {
CardFactoryUtil.AI_getBestArtifact(artList).untap();
}
@@ -217,8 +217,8 @@ public class PhaseUtil {
}//selectCard()
};//Input
CardList artList = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
artList = artList.filter(AllZoneUtil.artifacts);
artList = artList.filter(AllZoneUtil.tapped);
artList = artList.filter(CardListFilter.artifacts);
artList = artList.filter(CardListFilter.tapped);
if (artList.size() > 0) {
AllZone.getInputControl().setInput(target);
}
@@ -227,7 +227,7 @@ public class PhaseUtil {
if ((AllZoneUtil.isCardInPlay("Smoke") || AllZoneUtil.isCardInPlay("Stoic Angel"))) {
if (AllZone.getPhase().getPlayerTurn().isComputer()) {
CardList creatures = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer());
creatures = creatures.filter(AllZoneUtil.tapped);
creatures = creatures.filter(CardListFilter.tapped);
if (creatures.size() > 0) {
creatures.get(0).untap();
}
@@ -253,7 +253,7 @@ public class PhaseUtil {
}//selectCard()
};//Input
CardList creatures = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer());
creatures = creatures.filter(AllZoneUtil.tapped);
creatures = creatures.filter(CardListFilter.tapped);
if (creatures.size() > 0) {
AllZone.getInputControl().setInput(target);
}

View File

@@ -123,7 +123,7 @@ public class PlayerZone_ComesIntoPlay extends DefaultPlayerZone {
@Override
public void resolve() {
CardList lands = tisLand.getController().getCardsIn(Zone.Battlefield);
lands = lands.filter(AllZoneUtil.lands);
lands = lands.filter(CardListFilter.lands);
for (Card land : lands) {
land.tap();
}

View File

@@ -539,7 +539,7 @@ public class Upkeep implements java.io.Serializable {
*/
private static CardList abyss_getTargets(final Player player, final Card card) {
CardList creats = AllZoneUtil.getCreaturesInPlay(player);
creats = creats.filter(AllZoneUtil.nonartifacts);
creats = creats.filter(CardListFilter.nonartifacts);
creats = creats.getTargetableCards(card);
return creats;
}
@@ -562,7 +562,7 @@ public class Upkeep implements java.io.Serializable {
@Override
public void resolve() {
CardList artifacts = player.getCardsIn(Zone.Battlefield);
artifacts = artifacts.filter(AllZoneUtil.artifacts);
artifacts = artifacts.filter(CardListFilter.artifacts);
if (player.isHuman()) {
AllZone.getInputControl().setInput(new Input() {
@@ -2217,8 +2217,8 @@ public class Upkeep implements java.io.Serializable {
public void resolve() {
int gain = 0;
CardList play = player.getCardsIn(Zone.Battlefield);
CardList black = play.filter(AllZoneUtil.black);
CardList red = play.filter(AllZoneUtil.red);
CardList black = play.filter(CardListFilter.black);
CardList red = play.filter(CardListFilter.red);
if (black.size() > 0 && red.size() > 0) {
gain = 4;
}
@@ -2253,8 +2253,8 @@ public class Upkeep implements java.io.Serializable {
public void resolve() {
int draw = 0;
CardList play = player.getCardsIn(Zone.Battlefield);
CardList green = play.filter(AllZoneUtil.green);
CardList red = play.filter(AllZoneUtil.red);
CardList green = play.filter(CardListFilter.green);
CardList red = play.filter(CardListFilter.red);
if (green.size() > 0 && red.size() > 0) {
draw = 2;
@@ -2319,7 +2319,7 @@ public class Upkeep implements java.io.Serializable {
private static void upkeep_Shapeshifter() {
final Player player = AllZone.getPhase().getPlayerTurn();
CardList list = player.getCardsIn(Zone.Battlefield, "Shapeshifter");
list = list.filter(AllZoneUtil.nonToken);
list = list.filter(CardListFilter.nonToken);
for (final Card c : list) {
SpellAbility ability = new Ability(c, "0") {

View File

@@ -246,7 +246,7 @@ public final class AbilityFactory_Copy {
}
Card choice;
if (list.filter(AllZoneUtil.creatures).size() > 0) {
if (list.filter(CardListFilter.creatures).size() > 0) {
choice = CardFactoryUtil.AI_getBestCreature(list);
} else {
choice = CardFactoryUtil.AI_getMostExpensivePermanent(list, source, true);

View File

@@ -291,7 +291,7 @@ public class AbilityFactory_PermanentState {
untapList = untapList.getValidCards(tgt.getValidTgts(), source.getController(), source);
untapList = untapList.filter(AllZoneUtil.tapped);
untapList = untapList.filter(CardListFilter.tapped);
// filter out enchantments and planeswalkers, their tapped state doesn't matter.
String[] tappablePermanents = {"Creature", "Land", "Artifact"};
untapList = untapList.getValidCards(tappablePermanents, source.getController(), source);
@@ -358,7 +358,7 @@ public class AbilityFactory_PermanentState {
return true;
// try to just tap already tapped things
tapList = list.filter(AllZoneUtil.untapped);
tapList = list.filter(CardListFilter.untapped);
if (untapTargetList(source, tgt, af, sa, mandatory, tapList))
return true;
@@ -474,7 +474,7 @@ public class AbilityFactory_PermanentState {
else {
CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
list = list.getType(valid);
list = list.filter(AllZoneUtil.tapped);
list = list.filter(CardListFilter.tapped);
int count = 0;
while (list.size() != 0 && count < num)
@@ -747,7 +747,7 @@ public class AbilityFactory_PermanentState {
*/
private static boolean tapPrefTargeting(Card source, Target tgt, AbilityFactory af, SpellAbility sa, boolean mandatory) {
CardList tapList = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield);
tapList = tapList.filter(AllZoneUtil.untapped);
tapList = tapList.filter(CardListFilter.untapped);
tapList = tapList.getValidCards(tgt.getValidTgts(), source.getController(), source);
// filter out enchantments and planeswalkers, their tapped state doesn't matter.
String[] tappablePermanents = {"Creature", "Land", "Artifact"};
@@ -818,7 +818,7 @@ public class AbilityFactory_PermanentState {
return true;
// try to just tap already tapped things
tapList = list.filter(AllZoneUtil.tapped);
tapList = list.filter(CardListFilter.tapped);
if (tapTargetList(af, sa, tapList, mandatory))
return true;
@@ -1264,7 +1264,7 @@ public class AbilityFactory_PermanentState {
}
validTappables = validTappables.getValidCards(valid, source.getController(), source);
validTappables = validTappables.filter(AllZoneUtil.untapped);
validTappables = validTappables.filter(CardListFilter.untapped);
Random r = MyRandom.random;
boolean rr = false;
@@ -1299,7 +1299,7 @@ public class AbilityFactory_PermanentState {
private static CardList getTapAllTargets(String valid, Card source) {
CardList tmpList = AllZoneUtil.getCardsIn(Zone.Battlefield);
tmpList = tmpList.getValidCards(valid, source.getController(), source);
tmpList = tmpList.filter(AllZoneUtil.untapped);
tmpList = tmpList.filter(CardListFilter.untapped);
return tmpList;
}

View File

@@ -201,7 +201,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn
out.setOwner(in.getOwner());
CardList all = new CardList(getAllCards());
CardList tokens = AllZoneUtil.getCardsIn(Zone.Battlefield);
tokens = tokens.filter(AllZoneUtil.token);
tokens = tokens.filter(CardListFilter.token);
all.addAll(tokens);
out.setCopiedSpell(true);
for (Trigger t : out.getTriggers()) {
@@ -1092,7 +1092,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn
final Player player = getTargetPlayer();
CardList lands = player.getCardsIn(Zone.Graveyard);
lands = lands.filter(AllZoneUtil.basicLands);
lands = lands.filter(CardListFilter.basicLands);
if (card.getController().isHuman()) {
//now, select up to four lands
int end = -1;
@@ -1326,7 +1326,7 @@ public abstract class AbstractCardFactory implements NewConstants, CardFactoryIn
//may return null
public Card getCreature() {
CardList tappedCreatures = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer());
tappedCreatures = tappedCreatures.filter(AllZoneUtil.tapped);
tappedCreatures = tappedCreatures.filter(CardListFilter.tapped);
tappedCreatures = tappedCreatures.filter(AllZoneUtil.getCanTargetFilter(card));
if (tappedCreatures.isEmpty()) {
return null;

View File

@@ -558,7 +558,7 @@ public class CardFactory_Creatures {
@Override
public boolean canPlay() {
CardList possible = card.getController().getCardsIn(Zone.Hand);
possible = possible.filter(AllZoneUtil.nonlands);
possible = possible.filter(CardListFilter.nonlands);
return !possible.isEmpty() && super.canPlay();
}
@@ -1017,7 +1017,7 @@ public class CardFactory_Creatures {
@Override
public void resolve() {
CardList allTokens = AllZoneUtil.getCreaturesInPlay(card.getController());
allTokens = allTokens.filter(AllZoneUtil.token);
allTokens = allTokens.filter(CardListFilter.token);
int multiplier = AllZoneUtil.getDoublingSeasonMagnitude(card.getController());
@@ -1048,7 +1048,7 @@ public class CardFactory_Creatures {
@Override
public boolean canPlayAI() {
CardList allTokens = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer());
allTokens = allTokens.filter(AllZoneUtil.token);
allTokens = allTokens.filter(CardListFilter.token);
return allTokens.size() >= 2;
}
@@ -2271,7 +2271,7 @@ public class CardFactory_Creatures {
public boolean canPlayAI() {
//get all creatures
CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Graveyard);
list = list.filter(AllZoneUtil.creatures);
list = list.filter(CardListFilter.creatures);
return 0 < list.size();
}
});
@@ -2295,12 +2295,12 @@ public class CardFactory_Creatures {
Player opp = player.getOpponent();
int max = 0;
CardList play = opp.getCardsIn(Zone.Battlefield);
play = play.filter(AllZoneUtil.nonToken);
play = play.filter(AllZoneUtil.white);
play = play.filter(CardListFilter.nonToken);
play = play.filter(CardListFilter.white);
max += play.size();
CardList grave = opp.getCardsIn(Zone.Graveyard);
grave = grave.filter(AllZoneUtil.white);
grave = grave.filter(CardListFilter.white);
max += grave.size();
String[] life = new String[max + 1];
@@ -2499,7 +2499,7 @@ public class CardFactory_Creatures {
@Override
public boolean canPlay() {
CardList grave = card.getController().getCardsIn(Zone.Graveyard);
grave = grave.filter(AllZoneUtil.creatures);
grave = grave.filter(CardListFilter.creatures);
return super.canPlay() && grave.size() > 0;
}

View File

@@ -104,7 +104,7 @@ public class CardFactory_Instants {
final String kboost = getKeywordBoost();
CardList list = card.getController().getCardsIn(Zone.Battlefield);
list = list.filter(AllZoneUtil.white);
list = list.filter(CardListFilter.white);
for (int i = 0; i < list.size(); i++) {
final Card[] target = new Card[1];

View File

@@ -370,7 +370,7 @@ class CardFactory_Lands {
}
}//selectCard()
};//Input
if ((AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()).filter(AllZoneUtil.untapped).size() < 2)) {
if ((AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()).filter(CardListFilter.untapped).size() < 2)) {
AllZone.getGameAction().sacrifice(card);
return;
} else {
@@ -418,7 +418,7 @@ class CardFactory_Lands {
if (player.isComputer()) {
if (land.size() > 0) {
CardList tappedLand = new CardList(land.toArray());
tappedLand = tappedLand.filter(AllZoneUtil.tapped);
tappedLand = tappedLand.filter(CardListFilter.tapped);
//if any are tapped, sacrifice it
//else sacrifice random
if (tappedLand.size() > 0) {
@@ -490,7 +490,7 @@ class CardFactory_Lands {
public void execute() {
CardList plains = AllZoneUtil.getPlayerLandsInPlay(card.getController());
plains = plains.filter(AllZoneUtil.untapped);
plains = plains.filter(CardListFilter.untapped);
if (player.isComputer()) {
if (plains.size() > 1) {
@@ -509,7 +509,7 @@ class CardFactory_Lands {
}
} else { //this is the human resolution
final int[] paid = {0};
if ((AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()).filter(AllZoneUtil.untapped).size() < 2)) {
if ((AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()).filter(CardListFilter.untapped).size() < 2)) {
AllZone.getGameAction().sacrifice(card);
return;
}
@@ -871,7 +871,7 @@ class CardFactory_Lands {
if (player.isComputer()) {
if (land.size() > 0) {
CardList tappedLand = new CardList(land.toArray());
tappedLand = tappedLand.filter(AllZoneUtil.tapped);
tappedLand = tappedLand.filter(CardListFilter.tapped);
if (tappedLand.size() > 0) {
AllZone.getGameAction().moveToHand(CardFactoryUtil.getWorstLand(tappedLand));
} else {

View File

@@ -638,7 +638,7 @@ public class CardFactory_Sorceries {
@Override
public boolean canPlayAI() {
CardList c = AllZone.getHumanPlayer().getCardsIn(Zone.Library);
c = c.filter(AllZoneUtil.nonlands);
c = c.filter(CardListFilter.nonlands);
return c.size() > 0;
}
};//SpellAbility spell
@@ -805,7 +805,7 @@ public class CardFactory_Sorceries {
//randomly choose a nonland card
int getDamage() {
CardList notLand = card.getController().getCardsIn(Zone.Library);
notLand = notLand.filter(AllZoneUtil.nonlands);
notLand = notLand.filter(CardListFilter.nonlands);
notLand.shuffle();
if (notLand.isEmpty()) return 0;
@@ -1117,10 +1117,10 @@ public class CardFactory_Sorceries {
@Override
public boolean canPlayAI() {
CardList humTokenCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer());
humTokenCreats = humTokenCreats.filter(AllZoneUtil.token);
humTokenCreats = humTokenCreats.filter(CardListFilter.token);
CardList compTokenCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer());
compTokenCreats = compTokenCreats.filter(AllZoneUtil.token);
compTokenCreats = compTokenCreats.filter(CardListFilter.token);
return compTokenCreats.size() > humTokenCreats.size();
}//canPlayAI()
@@ -1128,7 +1128,7 @@ public class CardFactory_Sorceries {
@Override
public void resolve() {
CardList tokens = AllZoneUtil.getCreaturesInPlay();
tokens = tokens.filter(AllZoneUtil.token);
tokens = tokens.filter(CardListFilter.token);
CardFactoryUtil.copyTokens(tokens);
@@ -2561,7 +2561,7 @@ public class CardFactory_Sorceries {
@Override
public boolean canPlayAI() {
CardList c = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
c = c.filter(AllZoneUtil.nonlands);
c = c.filter(CardListFilter.nonlands);
return 2 >= c.size();
}
@@ -2617,7 +2617,7 @@ public class CardFactory_Sorceries {
@Override
public boolean canPlayAI() {
CardList c = AllZone.getComputerPlayer().getCardsIn(Zone.Hand);
c = c.filter(AllZoneUtil.nonlands);
c = c.filter(CardListFilter.nonlands);
return 2 >= c.size() ||
(AllZone.getComputerPlayer().hasMetalcraft() && AllZone.getHumanPlayer().getLife() <= 3);
}
@@ -2649,13 +2649,13 @@ public class CardFactory_Sorceries {
//"Destroy all artifacts",
if (userChoice.contains(cardChoices[0])) {
CardList cards = AllZoneUtil.getCardsIn(Zone.Battlefield).filter(AllZoneUtil.artifacts);
CardList cards = AllZoneUtil.getCardsIn(Zone.Battlefield).filter(CardListFilter.artifacts);
for (Card c : cards) AllZone.getGameAction().destroy(c);
}
//"Destroy all enchantments",
if (userChoice.contains(cardChoices[1])) {
CardList cards = AllZoneUtil.getCardsIn(Zone.Battlefield).filter(AllZoneUtil.enchantments);
CardList cards = AllZoneUtil.getCardsIn(Zone.Battlefield).filter(CardListFilter.enchantments);
for (Card c : cards) AllZone.getGameAction().destroy(c);
}
@@ -2988,7 +2988,7 @@ public class CardFactory_Sorceries {
@Override
public void showMessage() {
CardList grave = card.getController().getCardsIn(Constant.Zone.Graveyard);
grave = grave.filter(AllZoneUtil.creatures);
grave = grave.filter(CardListFilter.creatures);
grave = grave.filter(new CardListFilter() {
public boolean addCard(Card c) {
return c.getCMC() <= x[0];
@@ -3126,7 +3126,7 @@ public class CardFactory_Sorceries {
//get all
CardList creatures = AllZoneUtil.getCreaturesInPlay();
CardList grave = card.getController().getCardsIn(Zone.Graveyard);
grave = grave.filter(AllZoneUtil.creatures);
grave = grave.filter(CardListFilter.creatures);
if (AllZone.getHumanPlayer().canTarget(spell) || AllZone.getComputerPlayer().canTarget(spell))
display.add("Target player loses X life");

View File

@@ -1,10 +1,10 @@
package forge.card.cost;
import forge.AllZone;
import forge.AllZoneUtil;
import forge.ButtonUtil;
import forge.Card;
import forge.CardList;
import forge.CardListFilter;
import forge.ComputerUtil;
import forge.Constant;
import forge.Constant.Zone;
@@ -60,7 +60,7 @@ public class CostTapType extends CostPartWithList {
if (cost.getTap())
typeList.remove(source);
typeList = typeList.filter(AllZoneUtil.untapped);
typeList = typeList.filter(CardListFilter.untapped);
Integer amount = convertAmount();
if (typeList.size() == 0 || (amount != null && typeList.size() < amount))