From d4aaddcaa274399c15fcd0df6beca9f1bd6e8c68 Mon Sep 17 00:00:00 2001 From: Maxmtg Date: Tue, 20 Sep 2011 02:52:28 +0000 Subject: [PATCH] two useless functions in AllZoneUtil less. --- src/main/java/forge/AllZoneUtil.java | 56 ++++++-------------- src/main/java/forge/ComputerUtil.java | 2 +- src/main/java/forge/GuiDisplay4.java | 17 ++---- src/main/java/forge/card/cost/CostExile.java | 3 +- 4 files changed, 23 insertions(+), 55 deletions(-) diff --git a/src/main/java/forge/AllZoneUtil.java b/src/main/java/forge/AllZoneUtil.java index 4d25cbeaff5..9365ceafcc6 100644 --- a/src/main/java/forge/AllZoneUtil.java +++ b/src/main/java/forge/AllZoneUtil.java @@ -20,18 +20,6 @@ public final class AllZoneUtil { //////////// Creatures - /** - * use to get a list of creatures in play for a given player. - * - * @param player the player to get creatures for - * @return a CardList containing all creatures a given player has in play - */ - public static CardList getCreaturesInPlay(final Player player) { - CardList creats = player.getCardsIn(Zone.Battlefield); - return creats.filter(CardListFilter.creatures); - } - - /** * gets a list of all cards of a certain type that a given player has in given zone. * @@ -83,10 +71,11 @@ public final class AllZoneUtil { * @return a CardList with all cards currently in a graveyard */ public static CardList getCardsIn(final Constant.Zone zone, String cardName) { - CardList cards = getCardsIn(zone); - return cards.getName(cardName); + return getCardsIn(zone).getName(cardName); } + //////////// Creatures + /** * use to get a CardList of all creatures on the battlefield for both players * @@ -97,6 +86,19 @@ public final class AllZoneUtil { return creats.filter(CardListFilter.creatures); } + /** + * use to get a list of creatures in play for a given player. + * + * @param player the player to get creatures for + * @return a CardList containing all creatures a given player has in play + */ + public static CardList getCreaturesInPlay(final Player player) { + CardList creats = player.getCardsIn(Zone.Battlefield); + return creats.filter(CardListFilter.creatures); + } + + + ///////////////// Lands /** @@ -184,18 +186,6 @@ public final class AllZoneUtil { return player.getCardsIn(Zone.Battlefield, cardName).size() > 0; } - /** - * Answers the question: "Does have in play?". - * - * @param card the card to look for - * @param player the player whose battlefield we want to check - * @return true if that player has that card in play, false otherwise - * @since 1.0.15 - */ - public static boolean isCardInPlay(final Card card, final Player player) { - return player.getCardsIn(Zone.Battlefield).contains(card); - } - //////////////// getting all cards of a given color /** @@ -241,8 +231,7 @@ public final class AllZoneUtil { return null; } - CardList list = getCardsInZone(zone); - for (Card c : list) { + for (Card c : zone.getCards()) { if (card.equals(c)) { return c; } @@ -251,17 +240,6 @@ public final class AllZoneUtil { return card; } - /** - *

getCardsInZone.

- * - * @param zone a {@link forge.PlayerZone} object. - * @return a {@link forge.CardList} object. - */ - public static CardList getCardsInZone(final PlayerZone zone) { - return new CardList(zone.getCards()); - } - - /** *

compareTypeAmountInPlay.

* diff --git a/src/main/java/forge/ComputerUtil.java b/src/main/java/forge/ComputerUtil.java index 4a65adb1897..269d4a3b66a 100644 --- a/src/main/java/forge/ComputerUtil.java +++ b/src/main/java/forge/ComputerUtil.java @@ -1044,7 +1044,7 @@ public class ComputerUtil { * @return a {@link forge.CardList} object. */ static public CardList chooseExileFrom(Constant.Zone zone, String type, Card activate, Card target, int amount) { - CardList typeList = AllZoneUtil.getCardsInZone(AllZone.getComputerPlayer().getZone(zone)); + CardList typeList = new CardList(AllZone.getComputerPlayer().getZone(zone).getCards()); typeList = typeList.getValidCards(type.split(","), activate.getController(), activate); if (target != null && target.getController().isComputer() && typeList.contains(target)) typeList.remove(target); // don't exile the card we're pumping diff --git a/src/main/java/forge/GuiDisplay4.java b/src/main/java/forge/GuiDisplay4.java index 3d7aecb9293..b8cda93e601 100644 --- a/src/main/java/forge/GuiDisplay4.java +++ b/src/main/java/forge/GuiDisplay4.java @@ -780,7 +780,7 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo PlayerZone pZone = (PlayerZone) a; HandArea p = playerHandPanel; - Card[] c = AllZoneUtil.getCardsInZone(pZone).toArray(); + Card[] c = pZone.getCards(); List tmp, diff; tmp = new ArrayList(); @@ -837,7 +837,7 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo public void update(final Observable a, final Object b) { PlayerZone pZone = (PlayerZone) a; - Card[] c = AllZoneUtil.getCardsInZone(pZone).toArray(); + Card[] c = pZone.getCards(); GuiDisplayUtil.setupPlayZone(playerPlayPanel, c); } @@ -851,7 +851,7 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo public void update(final Observable a, final Object b) { PlayerZone pZone = (PlayerZone) a; - Card[] c = AllZoneUtil.getCardsInZone(pZone).toArray(); + Card[] c = pZone.getCards(); GuiDisplayUtil.setupPlayZone(oppPlayPanel, c); } @@ -1619,17 +1619,8 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo } } - /** - * @deprecated - * @see #getCardsAsIterable() - */ - @SuppressWarnings("unused") - protected Card[] getCards() { - return AllZoneUtil.getCardsInZone(zone).toArray(); - } - protected Iterable getCardsAsIterable() { - return new ImmutableIterableFrom(AllZoneUtil.getCardsInZone(zone)); + return new ImmutableIterableFrom(Arrays.asList(zone.getCards())); } protected void doAction(final Card c) { diff --git a/src/main/java/forge/card/cost/CostExile.java b/src/main/java/forge/card/cost/CostExile.java index f2194c90faf..6fb9a9099b4 100644 --- a/src/main/java/forge/card/cost/CostExile.java +++ b/src/main/java/forge/card/cost/CostExile.java @@ -88,8 +88,7 @@ public class CostExile extends CostPartWithList { public boolean canPay(SpellAbility ability, Card source, Player activator, Cost cost) { PlayerZone zone = activator.getZone(getFrom()); if (!getThis()) { - CardList typeList = AllZoneUtil.getCardsInZone(zone); - + CardList typeList = new CardList(zone.getCards()); typeList = typeList.getValidCards(getType().split(";"), activator, source); Integer amount = convertAmount();