AllZoneUtil Checkstyle fixes.

This commit is contained in:
slapshot5
2011-08-31 07:40:50 +00:00
parent cf623391fb
commit 388e903300

View File

@@ -12,23 +12,27 @@ import java.util.ArrayList;
* @author dennis.r.friedrichsen (slapshot5 on slightlymagic.net) * @author dennis.r.friedrichsen (slapshot5 on slightlymagic.net)
* @version $Id$ * @version $Id$
*/ */
public class AllZoneUtil { public final class AllZoneUtil {
private AllZoneUtil() {
throw new AssertionError();
}
//////////// Creatures //////////// Creatures
/** /**
* use to get a list of creatures in play for a given player * use to get a list of creatures in play for a given player.
* *
* @param player the player to get creatures for * @param player the player to get creatures for
* @return a CardList containing all creatures a given player has in play * @return a CardList containing all creatures a given player has in play
*/ */
public static CardList getCreaturesInPlay(final Player player) { public static CardList getCreaturesInPlay(final Player player) {
CardList creatures = AllZoneUtil.getPlayerCardsInPlay(player); CardList creats = AllZoneUtil.getPlayerCardsInPlay(player);
return creatures.filter(AllZoneUtil.creatures); return creats.filter(AllZoneUtil.creatures);
} }
/** /**
* use to get a list of creatures in play with a given keyword * use to get a list of creatures in play with a given keyword.
* *
* @param keyword the keyword to get creatures for * @param keyword the keyword to get creatures for
* @return a CardList containing all creatures in play with a given keyword * @return a CardList containing all creatures in play with a given keyword
@@ -36,7 +40,7 @@ public class AllZoneUtil {
public static CardList getCreaturesInPlayWithKeyword(final String keyword) { public static CardList getCreaturesInPlayWithKeyword(final String keyword) {
CardList list = getCreaturesInPlay(); CardList list = getCreaturesInPlay();
list = list.filter(new CardListFilter() { list = list.filter(new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return c.hasKeyword(keyword); return c.hasKeyword(keyword);
} }
}); });
@@ -49,14 +53,14 @@ public class AllZoneUtil {
* @return a CardList of all creatures on the battlefield on both sides * @return a CardList of all creatures on the battlefield on both sides
*/ */
public static CardList getCreaturesInPlay() { public static CardList getCreaturesInPlay() {
CardList creatures = getCardsInPlay(); CardList creats = getCardsInPlay();
return creatures.filter(AllZoneUtil.creatures); return creats.filter(AllZoneUtil.creatures);
} }
///////////////// Lands ///////////////// Lands
/** /**
* use to get a list of all lands a given player has on the battlefield * use to get a list of all lands a given player has on the battlefield.
* *
* @param player the player whose lands we want to get * @param player the player whose lands we want to get
* @return a CardList containing all lands the given player has in play * @return a CardList containing all lands the given player has in play
@@ -67,7 +71,7 @@ public class AllZoneUtil {
} }
/** /**
* gets a list of all lands in play * gets a list of all lands in play.
* *
* @return a CardList of all lands on the battlefield * @return a CardList of all lands on the battlefield
*/ */
@@ -86,7 +90,7 @@ public class AllZoneUtil {
//============================================================================= //=============================================================================
/** /**
* gets a list of all cards in play on both sides * gets a list of all cards in play on both sides.
* *
* @return a CardList of all cards in play on both sides * @return a CardList of all cards in play on both sides
*/ */
@@ -97,7 +101,7 @@ public class AllZoneUtil {
} }
/** /**
* gets a list of all cards in play with a given card name * gets a list of all cards in play with a given card name.
* *
* @param cardName the name of the card to search for * @param cardName the name of the card to search for
* @return a CardList with all cards in play of the given name * @return a CardList with all cards in play of the given name
@@ -113,7 +117,7 @@ public class AllZoneUtil {
} }
/** /**
* gets a list of all cards that a given Player has in play * gets a list of all cards that a given Player has in play.
* *
* @param player the player's cards to get * @param player the player's cards to get
* @return a CardList with all cards in the Play zone for the given player * @return a CardList with all cards in the Play zone for the given player
@@ -128,7 +132,7 @@ public class AllZoneUtil {
} }
/** /**
* gets a list of all cards with a given name a given player has in play * gets a list of all cards with a given name a given player has in play.
* *
* @param player the player whose cards in play you want to get * @param player the player whose cards in play you want to get
* @param cardName the card name to look for in that zone * @param cardName the card name to look for in that zone
@@ -150,7 +154,7 @@ public class AllZoneUtil {
/** /**
* gets a list of all cards owned by both players that have are currently in the graveyard * gets a list of all cards owned by both players that have are currently in the graveyard.
* *
* @return a CardList with all cards currently in a graveyard * @return a CardList with all cards currently in a graveyard
*/ */
@@ -163,7 +167,7 @@ public class AllZoneUtil {
/** /**
* gets all cards in given player's graveyard * gets all cards in given player's graveyard.
* *
* @param player the player whose graveyard we want to get * @param player the player whose graveyard we want to get
* @return a CardList containing all cards in that player's graveyard * @return a CardList containing all cards in that player's graveyard
@@ -178,7 +182,7 @@ public class AllZoneUtil {
} }
/** /**
* gets a list of all cards with a given name in a certain player's graveyard * gets a list of all cards with a given name in a certain player's graveyard.
* *
* @param player the player whose graveyard we want to get * @param player the player whose graveyard we want to get
* @param cardName the card name to find in the graveyard * @param cardName the card name to find in the graveyard
@@ -193,7 +197,7 @@ public class AllZoneUtil {
// Get a Cards in All Graveyards with a certain name // Get a Cards in All Graveyards with a certain name
/** /**
* gets a CardList of all cards with a given name in all graveyards * gets a CardList of all cards with a given name in all graveyards.
* *
* @param cardName the card name to look for * @param cardName the card name to look for
* @return a CardList of all cards with the given name in all graveyards * @return a CardList of all cards with the given name in all graveyards
@@ -207,20 +211,20 @@ public class AllZoneUtil {
} }
/** /**
* answers the question "is a certain, specific card in this player's graveyard?" * answers the question "is a certain, specific card in this player's graveyard?".
* *
* @param player the player's hand to check * @param player the player's hand to check
* @param card the specific card to look for * @param card the specific card to look for
* @return true if the card is present in this player's hand; false otherwise * @return true if the card is present in this player's hand; false otherwise
*/ */
public static boolean isCardInPlayerGraveyard(Player player, Card card) { public static boolean isCardInPlayerGraveyard(final Player player, final Card card) {
return isCardInZone(AllZone.getZone(Constant.Zone.Graveyard, player), card); return isCardInZone(AllZone.getZone(Constant.Zone.Graveyard, player), card);
} }
//////// HAND //////// HAND
/** /**
* gets a list of all cards in a given player's hand * gets a list of all cards in a given player's hand.
* *
* @param player the player's hand to target * @param player the player's hand to target
* @return a CardList containing all cards in target player's hand * @return a CardList containing all cards in target player's hand
@@ -235,43 +239,46 @@ public class AllZoneUtil {
} }
/** /**
* answers the question "is a certain, specific card in this player's hand?" * answers the question "is a certain, specific card in this player's hand?".
* *
* @param player the player's hand to check * @param player the player's hand to check
* @param card the specific card to look for * @param card the specific card to look for
* @return true if the card is present in this player's hand; false otherwise * @return true if the card is present in this player's hand; false otherwise
*/ */
public static boolean isCardInPlayerHand(Player player, Card card) { public static boolean isCardInPlayerHand(final Player player, final Card card) {
return isCardInZone(AllZone.getZone(Constant.Zone.Hand, player), card); return isCardInZone(AllZone.getZone(Constant.Zone.Hand, player), card);
} }
/** /**
* answers the question "is a specific card in this player's library?" * answers the question "is a specific card in this player's library?".
* *
* @param player the player's library to check * @param player the player's library to check
* @param card the specific card to look for * @param card the specific card to look for
* @return true if the card is present in this player's library; false otherwise * @return true if the card is present in this player's library; false otherwise
*/ */
public static boolean isCardInPlayerLibrary(Player player, Card card) { public static boolean isCardInPlayerLibrary(final Player player, final Card card) {
return isCardInZone(AllZone.getZone(Constant.Zone.Library, player), card); return isCardInZone(AllZone.getZone(Constant.Zone.Library, player), card);
} }
/** /**
* answers the question "is a specific card in the specified zone?" * answers the question "is a specific card in the specified zone?".
* *
* @param pz the PlayerZone to check * @param pz the PlayerZone to check
* @param card the specific card to look for * @param card the specific card to look for
* @return true if the card is present in this zone; false otherwise * @return true if the card is present in this zone; false otherwise
*/ */
public static boolean isCardInZone(PlayerZone pz, Card card) { public static boolean isCardInZone(final PlayerZone pz, final Card card) {
if (card == null) if (card == null) {
return false; return false;
}
CardList cl = getCardsInZone(pz); CardList cl = getCardsInZone(pz);
for (int i = 0; i < cl.size(); i++) for (int i = 0; i < cl.size(); i++) {
if (cl.get(i).equals(card)) if (cl.get(i).equals(card)) {
return true; return true;
}
}
return false; return false;
} }
@@ -279,7 +286,7 @@ public class AllZoneUtil {
////////////// EXILE ////////////// EXILE
/** /**
* gets a list of all cards owned by both players that are in Exile * gets a list of all cards owned by both players that are in Exile.
* *
* @return a CardList with all cards in Exile * @return a CardList with all cards in Exile
*/ */
@@ -291,7 +298,7 @@ public class AllZoneUtil {
} }
/** /**
* gets a list of all cards in Exile for a given player * gets a list of all cards in Exile for a given player.
* *
* @param player the player whose cards we want that are in Exile * @param player the player whose cards we want that are in Exile
* @return a CardList with all cards in Exile for a given player * @return a CardList with all cards in Exile for a given player
@@ -306,7 +313,7 @@ public class AllZoneUtil {
} }
/** /**
* gets a list of all cards with a given name in a certain player's exile * gets a list of all cards with a given name in a certain player's exile.
* *
* @param player the player whose exile we want to get * @param player the player whose exile we want to get
* @param cardName the card name to find in the exile * @param cardName the card name to find in the exile
@@ -321,7 +328,7 @@ public class AllZoneUtil {
//////////////////////// LIBRARY //////////////////////// LIBRARY
/** /**
* gets a list of all cards in a given player's library * gets a list of all cards in a given player's library.
* *
* @return a CardList with all the cards currently in that player's library * @return a CardList with all the cards currently in that player's library
* @param player a {@link forge.Player} object. * @param player a {@link forge.Player} object.
@@ -336,7 +343,7 @@ public class AllZoneUtil {
} }
/** /**
* gets a list of all cards with a certain name in a given player's library * gets a list of all cards with a certain name in a given player's library.
* *
* @param player the player's library one is interested in * @param player the player's library one is interested in
* @param cardName the card's name that one is interested in * @param cardName the card's name that one is interested in
@@ -348,34 +355,35 @@ public class AllZoneUtil {
} }
/** /**
* gets a list of a given number of cards from the top of given player's library * gets a list of a given number of cards from the top of given player's library.
* *
* @param player the player's library one is interested in * @param player the player's library one is interested in
* @param numCards the number of cards to get from the top * @param numCards the number of cards to get from the top
* @return a CardList of the top number of cards in the given player's library * @return a CardList of the top number of cards in the given player's library
*/ */
public static CardList getPlayerCardsInLibrary(final Player player, int numCards) { public static CardList getPlayerCardsInLibrary(final Player player, final int numCards) {
CardList cards = new CardList(); CardList cards = new CardList();
if (player.isHuman() || player.isComputer()) { if (player.isHuman() || player.isComputer()) {
PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player); PlayerZone lib = AllZone.getZone(Constant.Zone.Library, player);
if (lib.size() <= numCards) if (lib.size() <= numCards) {
cards.addAll(lib.getCards()); cards.addAll(lib.getCards());
else { } else {
for (int i = 0; i < numCards; i++) for (int i = 0; i < numCards; i++) {
cards.add(lib.get(i)); cards.add(lib.get(i));
}
} }
} }
return cards; return cards;
} }
/** /**
* answers the question "is the given card in any exile zone?" * answers the question "is the given card in any exile zone?".
* *
* @param c the card to look for in Exile * @param c the card to look for in Exile
* @return true is the card is in Human or Computer's Exile zone * @return true is the card is in Human or Computer's Exile zone
*/ */
public static boolean isCardExiled(Card c) { public static boolean isCardExiled(final Card c) {
return getCardsInExile().contains(c); return getCardsInExile().contains(c);
} }
@@ -385,7 +393,7 @@ public class AllZoneUtil {
* @param c a {@link forge.Card} object. * @param c a {@link forge.Card} object.
* @return a boolean. * @return a boolean.
*/ */
public static boolean isCardInGrave(Card c) { public static boolean isCardInGrave(final Card c) {
return getCardsInGraveyard().contains(c); return getCardsInGraveyard().contains(c);
} }
@@ -397,12 +405,12 @@ public class AllZoneUtil {
* @param card a {@link forge.Card} object. * @param card a {@link forge.Card} object.
* @return a boolean. * @return a boolean.
*/ */
public static boolean isCardInPlay(Card card) { public static boolean isCardInPlay(final Card card) {
return getCardsInPlay().contains(card); return getCardsInPlay().contains(card);
} }
/** /**
* Answers the question: "Is <card name> in play?" * Answers the question: "Is <card name> in play?".
* *
* @param cardName the name of the card to look for * @param cardName the name of the card to look for
* @return true is the card is in play, false otherwise * @return true is the card is in play, false otherwise
@@ -412,7 +420,7 @@ public class AllZoneUtil {
} }
/** /**
* Answers the question: "Does <player> have <card name> in play?" * Answers the question: "Does <player> have <card name> in play?".
* *
* @param cardName the name of the card to look for * @param cardName the name of the card to look for
* @param player the player whose battlefield we want to check * @param player the player whose battlefield we want to check
@@ -423,7 +431,7 @@ public class AllZoneUtil {
} }
/** /**
* Answers the question: "Does <player> have <given card> in play?" * Answers the question: "Does <player> have <given card> in play?".
* *
* @param card the card to look for * @param card the card to look for
* @param player the player whose battlefield we want to check * @param player the player whose battlefield we want to check
@@ -437,7 +445,7 @@ public class AllZoneUtil {
///get a list of certain types are in play (like Mountain, Elf, etc...) ///get a list of certain types are in play (like Mountain, Elf, etc...)
/** /**
* gets a list of all cards with a certain type (Mountain, Elf, etc...) in play * gets a list of all cards with a certain type (Mountain, Elf, etc...) in play.
* *
* @param cardType the type to find in play * @param cardType the type to find in play
* @return a CardList with all cards of the given type in play * @return a CardList with all cards of the given type in play
@@ -449,7 +457,7 @@ public class AllZoneUtil {
} }
/** /**
* gets a list of all cards of a certain type that a given player has in play * gets a list of all cards of a certain type that a given player has in play.
* *
* @param player the player to check for cards in play * @param player the player to check for cards in play
* @param cardType the card type to check for * @param cardType the card type to check for
@@ -462,7 +470,7 @@ public class AllZoneUtil {
} }
/** /**
* gets a list of all cards of a certain type that a given player has in his library * gets a list of all cards of a certain type that a given player has in his library.
* *
* @param player the player to check for cards in play * @param player the player to check for cards in play
* @param cardType the card type to check for * @param cardType the card type to check for
@@ -475,7 +483,7 @@ public class AllZoneUtil {
} }
/** /**
* gets a list of all cards of a certain type that a given player has in graveyard * gets a list of all cards of a certain type that a given player has in graveyard.
* *
* @param player the player to check for cards in play * @param player the player to check for cards in play
* @param cardType the card type to check for * @param cardType the card type to check for
@@ -490,7 +498,7 @@ public class AllZoneUtil {
//////////////// getting all cards of a given color //////////////// getting all cards of a given color
/** /**
* gets a list of all Cards of a given color on the battlefield * gets a list of all Cards of a given color on the battlefield.
* *
* @param color the color of cards to get * @param color the color of cards to get
* @return a CardList of all cards in play of a given color * @return a CardList of all cards in play of a given color
@@ -502,7 +510,7 @@ public class AllZoneUtil {
} }
/** /**
* gets a list of all Cards of a given color a given player has on the battlefield * gets a list of all Cards of a given color a given player has on the battlefield.
* *
* @param player the player's cards to get * @param player the player's cards to get
* @param color the color of cards to get * @param color the color of cards to get
@@ -511,7 +519,7 @@ public class AllZoneUtil {
public static CardList getPlayerColorInPlay(final Player player, final String color) { public static CardList getPlayerColorInPlay(final Player player, final String color) {
CardList cards = getPlayerCardsInPlay(player); CardList cards = getPlayerCardsInPlay(player);
cards = cards.filter(new CardListFilter() { cards = cards.filter(new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
ArrayList<String> colorList = CardUtil.getColors(c); ArrayList<String> colorList = CardUtil.getColors(c);
return colorList.contains(color); return colorList.contains(color);
} }
@@ -525,15 +533,18 @@ public class AllZoneUtil {
* @param card a {@link forge.Card} object. * @param card a {@link forge.Card} object.
* @return a {@link forge.Card} object. * @return a {@link forge.Card} object.
*/ */
public static Card getCardState(Card card) { public static Card getCardState(final Card card) {
PlayerZone zone = AllZone.getZone(card); PlayerZone zone = AllZone.getZone(card);
if (zone == null) // for tokens //for tokens
if (zone == null) {
return null; return null;
}
CardList list = getCardsInZone(zone.getZoneName()); CardList list = getCardsInZone(zone.getZoneName());
for (Card c : list) { for (Card c : list) {
if (card.equals(c)) if (card.equals(c)) {
return c; return c;
}
} }
return card; return card;
@@ -545,7 +556,7 @@ public class AllZoneUtil {
* @param zone a {@link java.lang.String} object. * @param zone a {@link java.lang.String} object.
* @return a {@link forge.CardList} object. * @return a {@link forge.CardList} object.
*/ */
public static CardList getCardsInZone(String zone) { public static CardList getCardsInZone(final String zone) {
return getCardsInZone(zone, null); return getCardsInZone(zone, null);
} }
@@ -555,7 +566,7 @@ public class AllZoneUtil {
* @param zone a {@link forge.PlayerZone} object. * @param zone a {@link forge.PlayerZone} object.
* @return a {@link forge.CardList} object. * @return a {@link forge.CardList} object.
*/ */
public static CardList getCardsInZone(PlayerZone zone) { public static CardList getCardsInZone(final PlayerZone zone) {
return new CardList(zone.getCards()); return new CardList(zone.getCards());
} }
@@ -566,38 +577,48 @@ public class AllZoneUtil {
* @param player a {@link forge.Player} object. * @param player a {@link forge.Player} object.
* @return a {@link forge.CardList} object. * @return a {@link forge.CardList} object.
*/ */
public static CardList getCardsInZone(String zone, Player player) { public static CardList getCardsInZone(final String zone, final Player player) {
CardList all = new CardList(); CardList all = new CardList();
if (zone.contains(Constant.Zone.Graveyard)) { if (zone.contains(Constant.Zone.Graveyard)) {
if (player == null || player.isHuman()) if (player == null || player.isHuman()) {
all.addAll(AllZone.getHumanGraveyard().getCards()); all.addAll(AllZone.getHumanGraveyard().getCards());
if (player == null || player.isComputer()) }
if (player == null || player.isComputer()) {
all.addAll(AllZone.getComputerGraveyard().getCards()); all.addAll(AllZone.getComputerGraveyard().getCards());
}
} }
if (zone.contains(Constant.Zone.Hand)) { if (zone.contains(Constant.Zone.Hand)) {
if (player == null || player.isHuman()) if (player == null || player.isHuman()) {
all.addAll(AllZone.getHumanHand().getCards()); all.addAll(AllZone.getHumanHand().getCards());
if (player == null || player.isComputer()) }
if (player == null || player.isComputer()) {
all.addAll(AllZone.getComputerHand().getCards()); all.addAll(AllZone.getComputerHand().getCards());
}
} }
if (zone.contains(Constant.Zone.Battlefield)) { if (zone.contains(Constant.Zone.Battlefield)) {
if (player == null || player.isHuman()) if (player == null || player.isHuman()) {
all.addAll(AllZone.getHumanBattlefield().getCards()); all.addAll(AllZone.getHumanBattlefield().getCards());
if (player == null || player.isComputer()) }
if (player == null || player.isComputer()) {
all.addAll(AllZone.getComputerBattlefield().getCards()); all.addAll(AllZone.getComputerBattlefield().getCards());
}
} }
if (zone.contains(Constant.Zone.Exile)) { if (zone.contains(Constant.Zone.Exile)) {
if (player == null || player.isHuman()) if (player == null || player.isHuman()) {
all.addAll(AllZone.getHumanExile().getCards()); all.addAll(AllZone.getHumanExile().getCards());
if (player == null || player.isComputer()) }
if (player == null || player.isComputer()) {
all.addAll(AllZone.getComputerExile().getCards()); all.addAll(AllZone.getComputerExile().getCards());
}
} }
if (zone.contains(Constant.Zone.Library)) { if (zone.contains(Constant.Zone.Library)) {
if (player == null || player.isHuman()) if (player == null || player.isHuman()) {
all.addAll(AllZone.getHumanLibrary().getCards()); all.addAll(AllZone.getHumanLibrary().getCards());
if (player == null || player.isComputer()) }
if (player == null || player.isComputer()) {
all.addAll(AllZone.getComputerLibrary().getCards()); all.addAll(AllZone.getComputerLibrary().getCards());
}
} }
return all; return all;
@@ -610,7 +631,7 @@ public class AllZoneUtil {
* @param type a {@link java.lang.String} object. * @param type a {@link java.lang.String} object.
* @return a int. * @return a int.
*/ */
public static int compareTypeAmountInPlay(final Player player, String type) { public static int compareTypeAmountInPlay(final Player player, final String type) {
// returns the difference between player's // returns the difference between player's
Player opponent = player.getOpponent(); Player opponent = player.getOpponent();
CardList playerList = getPlayerTypeInPlay(player, type); CardList playerList = getPlayerTypeInPlay(player, type);
@@ -625,7 +646,7 @@ public class AllZoneUtil {
* @param type a {@link java.lang.String} object. * @param type a {@link java.lang.String} object.
* @return a int. * @return a int.
*/ */
public static int compareTypeAmountInGraveyard(final Player player, String type) { public static int compareTypeAmountInGraveyard(final Player player, final String type) {
// returns the difference between player's // returns the difference between player's
Player opponent = player.getOpponent(); Player opponent = player.getOpponent();
CardList playerList = getPlayerTypeInGraveyard(player, type); CardList playerList = getPlayerTypeInGraveyard(player, type);
@@ -635,150 +656,150 @@ public class AllZoneUtil {
/** /**
* a CardListFilter to get all cards that are tapped * a CardListFilter to get all cards that are tapped.
*/ */
public static final CardListFilter tapped = new CardListFilter() { public static final CardListFilter tapped = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return c.isTapped(); return c.isTapped();
} }
}; };
/** /**
* a CardListFilter to get all cards that are untapped * a CardListFilter to get all cards that are untapped.
*/ */
public static final CardListFilter untapped = new CardListFilter() { public static final CardListFilter untapped = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return c.isUntapped(); return c.isUntapped();
} }
}; };
/** /**
* a CardListFilter to get all creatures * a CardListFilter to get all creatures.
*/ */
public static final CardListFilter creatures = new CardListFilter() { public static final CardListFilter creatures = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return c.isCreature(); return c.isCreature();
} }
}; };
/** /**
* a CardListFilter to get all enchantments * a CardListFilter to get all enchantments.
*/ */
public static final CardListFilter enchantments = new CardListFilter() { public static final CardListFilter enchantments = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return c.isEnchantment(); return c.isEnchantment();
} }
}; };
/** /**
* a CardListFilter to get all equipment * a CardListFilter to get all equipment.
*/ */
public static final CardListFilter equipment = new CardListFilter() { public static final CardListFilter equipment = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return c.isEquipment(); return c.isEquipment();
} }
}; };
/** /**
* a CardListFilter to get all unenchanted cards in a list * a CardListFilter to get all unenchanted cards in a list.
*/ */
public static final CardListFilter unenchanted = new CardListFilter() { public static final CardListFilter unenchanted = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return !c.isEnchanted(); return !c.isEnchanted();
} }
}; };
/** /**
* a CardListFilter to get all enchanted cards in a list * a CardListFilter to get all enchanted cards in a list.
*/ */
public static final CardListFilter enchanted = new CardListFilter() { public static final CardListFilter enchanted = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return c.isEnchanted(); return c.isEnchanted();
} }
}; };
/** /**
* a CardListFilter to get all nontoken cards * a CardListFilter to get all nontoken cards.
*/ */
public static final CardListFilter nonToken = new CardListFilter() { public static final CardListFilter nonToken = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return !c.isToken(); return !c.isToken();
} }
}; };
/** /**
* a CardListFilter to get all token cards * a CardListFilter to get all token cards.
*/ */
public static final CardListFilter token = new CardListFilter() { public static final CardListFilter token = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return c.isToken(); return c.isToken();
} }
}; };
/** /**
* a CardListFilter to get all nonbasic lands * a CardListFilter to get all nonbasic lands.
*/ */
public static final CardListFilter nonBasicLand = new CardListFilter() { public static final CardListFilter nonBasicLand = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return !c.isBasicLand(); return !c.isBasicLand();
} }
}; };
/** /**
* a CardListFilter to get all basicLands * a CardListFilter to get all basicLands.
*/ */
public static final CardListFilter basicLands = new CardListFilter() { public static final CardListFilter basicLands = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
//the isBasicLand() check here may be sufficient... //the isBasicLand() check here may be sufficient...
return c.isLand() && c.isBasicLand(); return c.isLand() && c.isBasicLand();
} }
}; };
/** /**
* a CardListFilter to get all artifacts * a CardListFilter to get all artifacts.
*/ */
public static final CardListFilter artifacts = new CardListFilter() { public static final CardListFilter artifacts = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return c.isArtifact(); return c.isArtifact();
} }
}; };
/** /**
* a CardListFilter to get all nonartifacts * a CardListFilter to get all nonartifacts.
*/ */
public static final CardListFilter nonartifacts = new CardListFilter() { public static final CardListFilter nonartifacts = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return !c.isArtifact(); return !c.isArtifact();
} }
}; };
/** /**
* a CardListFilter to get all lands * a CardListFilter to get all lands.
*/ */
public static final CardListFilter lands = new CardListFilter() { public static final CardListFilter lands = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return c.isLand(); return c.isLand();
} }
}; };
/** /**
* a CardListFilter to get all nonlands * a CardListFilter to get all nonlands.
*/ */
public static final CardListFilter nonlands = new CardListFilter() { public static final CardListFilter nonlands = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return !c.isLand(); return !c.isLand();
} }
}; };
/** /**
* get a CardListFilter to filter in only cards that can be targeted * get a CardListFilter to filter in only cards that can be targeted.
* *
* @param source - the card to be the source for the target * @param source - the card to be the source for the target
* @return a CardListFilter to only add cards that can be targeted * @return a CardListFilter to only add cards that can be targeted
*/ */
public static CardListFilter getCanTargetFilter(final Card source) { public static CardListFilter getCanTargetFilter(final Card source) {
CardListFilter canTarget = new CardListFilter() { CardListFilter canTarget = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return CardFactoryUtil.canTarget(source, c); return CardFactoryUtil.canTarget(source, c);
} }
}; };
@@ -786,14 +807,14 @@ public class AllZoneUtil {
} }
/** /**
* get a CardListFilter to filter a CardList for a given keyword * get a CardListFilter to filter a CardList for a given keyword.
* *
* @param keyword - the keyword to look for * @param keyword - the keyword to look for
* @return a CardListFilter to only add cards with the given keyword * @return a CardListFilter to only add cards with the given keyword
*/ */
public static CardListFilter getKeywordFilter(final String keyword) { public static CardListFilter getKeywordFilter(final String keyword) {
CardListFilter filter = new CardListFilter() { CardListFilter filter = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return c.hasKeyword(keyword); return c.hasKeyword(keyword);
} }
}; };
@@ -801,14 +822,14 @@ public class AllZoneUtil {
} }
/** /**
* get a CardListFilter to filter a CardList for a given type * get a CardListFilter to filter a CardList for a given type.
* *
* @param type - the type to check for * @param type - the type to check for
* @return a CardListFilter to only add cards of the given type * @return a CardListFilter to only add cards of the given type
*/ */
public static CardListFilter getTypeFilter(final String type) { public static CardListFilter getTypeFilter(final String type) {
CardListFilter filter = new CardListFilter() { CardListFilter filter = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return c.isType(type); return c.isType(type);
} }
}; };
@@ -816,52 +837,52 @@ public class AllZoneUtil {
} }
/** /**
* a CardListFilter to get all cards that are black * a CardListFilter to get all cards that are black.
*/ */
public static final CardListFilter black = new CardListFilter() { public static final CardListFilter black = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return c.isBlack(); return c.isBlack();
} }
}; };
/** /**
* a CardListFilter to get all cards that are blue * a CardListFilter to get all cards that are blue.
*/ */
public static final CardListFilter blue = new CardListFilter() { public static final CardListFilter blue = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return c.isBlue(); return c.isBlue();
} }
}; };
/** /**
* a CardListFilter to get all cards that are green * a CardListFilter to get all cards that are green.
*/ */
public static final CardListFilter green = new CardListFilter() { public static final CardListFilter green = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return c.isGreen(); return c.isGreen();
} }
}; };
/** /**
* a CardListFilter to get all cards that are red * a CardListFilter to get all cards that are red.
*/ */
public static final CardListFilter red = new CardListFilter() { public static final CardListFilter red = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return c.isRed(); return c.isRed();
} }
}; };
/** /**
* a CardListFilter to get all cards that are white * a CardListFilter to get all cards that are white.
*/ */
public static final CardListFilter white = new CardListFilter() { public static final CardListFilter white = new CardListFilter() {
public boolean addCard(Card c) { public boolean addCard(final Card c) {
return c.isWhite(); return c.isWhite();
} }
}; };
/** /**
* a CardListFilter to get all cards that are a part of this game * a CardListFilter to get all cards that are a part of this game.
* *
* @return a {@link forge.CardList} with all cards in all Battlefields, Hands, Graveyards, Libraries, and Exiles. * @return a {@link forge.CardList} with all cards in all Battlefields, Hands, Graveyards, Libraries, and Exiles.
*/ */
@@ -892,15 +913,17 @@ public class AllZoneUtil {
* @param player the {@link forge.Player} player to determine if is affected by Doubling Season * @param player the {@link forge.Player} player to determine if is affected by Doubling Season
* @return a int. * @return a int.
*/ */
public static int getDoublingSeasonMagnitude(Player player) { public static int getDoublingSeasonMagnitude(final Player player) {
int multiplier = 1; int multiplier = 1;
int doublingSeasons = getPlayerCardsInPlay(player, "Doubling Season").size(); int doublingSeasons = getPlayerCardsInPlay(player, "Doubling Season").size();
if (doublingSeasons > 0) multiplier = (int) Math.pow(2, doublingSeasons); if (doublingSeasons > 0) {
multiplier = (int) Math.pow(2, doublingSeasons);
}
return multiplier; return multiplier;
} }
/** /**
* get a list of all players participating in this game * get a list of all players participating in this game.
* *
* @return a list of all player participating in this game * @return a list of all player participating in this game
*/ */
@@ -912,12 +935,12 @@ public class AllZoneUtil {
} }
/** /**
* gets a list of all opponents of a given player * gets a list of all opponents of a given player.
* *
* @param p the player whose opponents to get * @param p the player whose opponents to get
* @return a list of all opponents * @return a list of all opponents
*/ */
public static ArrayList<Player> getOpponents(Player p) { public static ArrayList<Player> getOpponents(final Player p) {
ArrayList<Player> list = new ArrayList<Player>(); ArrayList<Player> list = new ArrayList<Player>();
list.add(p.getOpponent()); list.add(p.getOpponent());
return list; return list;
@@ -932,20 +955,22 @@ public class AllZoneUtil {
* @return a boolean. * @return a boolean.
* @since 1.0.15 * @since 1.0.15
*/ */
public static boolean compare(int leftSide, String comp, int rightSide) { public static boolean compare(final int leftSide, final String comp, final int rightSide) {
// should this function be somewhere else? // should this function be somewhere else?
// leftSide COMPARED to rightSide: // leftSide COMPARED to rightSide:
if (comp.contains("LT")) return leftSide < rightSide; if (comp.contains("LT")) {
return leftSide < rightSide;
else if (comp.contains("LE")) return leftSide <= rightSide; } else if (comp.contains("LE")) {
return leftSide <= rightSide;
else if (comp.contains("EQ")) return leftSide == rightSide; } else if (comp.contains("EQ")) {
return leftSide == rightSide;
else if (comp.contains("GE")) return leftSide >= rightSide; } else if (comp.contains("GE")) {
return leftSide >= rightSide;
else if (comp.contains("GT")) return leftSide > rightSide; } else if (comp.contains("GT")) {
return leftSide > rightSide;
else if (comp.contains("NE")) return leftSide != rightSide; // not equals } else if (comp.contains("NE")) {
return leftSide != rightSide; // not equals
}
return false; return false;
} }