From 013ddee250c0872e13367fe37e8661911b49a8d3 Mon Sep 17 00:00:00 2001 From: Maxmtg Date: Mon, 1 Oct 2012 23:32:48 +0000 Subject: [PATCH] CardList class replaced by java.util.(Array)List --- .gitattributes | 1 - src/main/java/forge/AllZoneUtil.java | 66 +++--- src/main/java/forge/Card.java | 62 +++--- src/main/java/forge/CardList.java | 39 ---- src/main/java/forge/CardListUtil.java | 68 ++++--- src/main/java/forge/CardUtil.java | 24 +-- src/main/java/forge/GameAction.java | 45 +++-- src/main/java/forge/GameActionUtil.java | 60 +++--- src/main/java/forge/NameChanger.java | 6 +- src/main/java/forge/StaticEffect.java | 7 +- src/main/java/forge/StaticEffects.java | 5 +- src/main/java/forge/card/DeckHints.java | 4 +- .../card/abilityfactory/AbilityFactory.java | 48 ++--- .../abilityfactory/AbilityFactoryAnimate.java | 4 +- .../abilityfactory/AbilityFactoryAttach.java | 41 ++-- .../abilityfactory/AbilityFactoryBond.java | 6 +- .../AbilityFactoryChangeZone.java | 66 +++--- .../abilityfactory/AbilityFactoryChoose.java | 16 +- .../abilityfactory/AbilityFactoryClash.java | 20 +- .../abilityfactory/AbilityFactoryClone.java | 2 +- .../abilityfactory/AbilityFactoryCombat.java | 5 +- .../abilityfactory/AbilityFactoryCopy.java | 5 +- .../AbilityFactoryCounters.java | 44 ++-- .../AbilityFactoryDealDamage.java | 31 +-- .../abilityfactory/AbilityFactoryDebuff.java | 21 +- .../abilityfactory/AbilityFactoryDestroy.java | 21 +- .../abilityfactory/AbilityFactoryEffect.java | 11 +- .../AbilityFactoryGainControl.java | 17 +- .../abilityfactory/AbilityFactoryMana.java | 11 +- .../AbilityFactoryPermanentState.java | 59 +++--- .../abilityfactory/AbilityFactoryPlay.java | 13 +- .../AbilityFactoryPreventDamage.java | 19 +- .../AbilityFactoryProtection.java | 21 +- .../abilityfactory/AbilityFactoryPump.java | 46 ++--- .../AbilityFactoryRegenerate.java | 21 +- .../abilityfactory/AbilityFactoryRepeat.java | 6 +- .../abilityfactory/AbilityFactoryReveal.java | 42 ++-- .../AbilityFactorySacrifice.java | 43 ++-- .../AbilityFactorySetState.java | 5 +- .../abilityfactory/AbilityFactoryToken.java | 5 +- .../AbilityFactoryZoneAffecting.java | 29 +-- .../cardfactory/CardFactoryArtifacts.java | 31 +-- .../card/cardfactory/CardFactoryAuras.java | 19 +- .../cardfactory/CardFactoryCreatures.java | 70 +++---- .../cardfactory/CardFactoryEnchantments.java | 20 +- .../card/cardfactory/CardFactoryInstants.java | 31 +-- .../card/cardfactory/CardFactoryLands.java | 25 ++- .../cardfactory/CardFactorySorceries.java | 96 ++++----- .../card/cardfactory/CardFactoryUtil.java | 190 +++++++++--------- .../java/forge/card/cost/CostDiscard.java | 14 +- src/main/java/forge/card/cost/CostExile.java | 13 +- src/main/java/forge/card/cost/CostMill.java | 5 +- .../forge/card/cost/CostPartWithList.java | 13 +- .../java/forge/card/cost/CostPutCounter.java | 10 +- .../forge/card/cost/CostRemoveCounter.java | 10 +- src/main/java/forge/card/cost/CostReturn.java | 10 +- src/main/java/forge/card/cost/CostReveal.java | 14 +- .../java/forge/card/cost/CostSacrifice.java | 14 +- .../java/forge/card/cost/CostTapType.java | 14 +- .../java/forge/card/cost/CostUntapType.java | 14 +- src/main/java/forge/card/cost/CostUtil.java | 12 +- .../card/replacement/ReplacementEffect.java | 12 +- .../card/spellability/AbilityActivated.java | 5 +- .../java/forge/card/spellability/Spell.java | 7 +- .../forge/card/spellability/SpellAbility.java | 37 ++-- .../spellability/SpellAbilityCondition.java | 7 +- .../spellability/SpellAbilityRestriction.java | 6 +- .../SpellAbilityStackInstance.java | 7 +- .../card/spellability/SpellPermanent.java | 23 ++- .../card/spellability/TargetSelection.java | 26 +-- .../card/staticability/StaticAbility.java | 2 +- .../StaticAbilityContinuous.java | 21 +- src/main/java/forge/card/trigger/Trigger.java | 11 +- .../trigger/TriggerAttackersDeclared.java | 6 +- .../forge/card/trigger/TriggerAttacks.java | 6 +- .../forge/card/trigger/TriggerHandler.java | 19 +- .../java/forge/control/input/InputAttack.java | 6 +- .../java/forge/control/input/InputBlock.java | 10 +- .../forge/control/input/InputMulligan.java | 13 +- .../control/input/InputPayDiscardCost.java | 6 +- .../control/input/InputPayReturnCost.java | 6 +- .../forge/control/input/InputPaySacCost.java | 6 +- src/main/java/forge/deck/DeckSection.java | 5 +- src/main/java/forge/game/GameNew.java | 11 +- .../java/forge/game/limited/BoosterDraft.java | 5 +- .../java/forge/game/limited/LimitedDeck.java | 2 +- src/main/java/forge/game/phase/Combat.java | 87 ++++---- .../java/forge/game/phase/CombatUtil.java | 128 ++++++------ src/main/java/forge/game/phase/EndOfTurn.java | 10 +- .../java/forge/game/phase/PhaseHandler.java | 13 +- src/main/java/forge/game/phase/PhaseUtil.java | 22 +- src/main/java/forge/game/phase/Untap.java | 23 ++- src/main/java/forge/game/phase/Upkeep.java | 117 +++++------ src/main/java/forge/game/player/AIPlayer.java | 21 +- .../forge/game/player/ComputerAIGeneral.java | 20 +- .../java/forge/game/player/ComputerUtil.java | 150 +++++++------- .../forge/game/player/ComputerUtilAttack.java | 65 +++--- .../forge/game/player/ComputerUtilBlock.java | 143 ++++++------- .../java/forge/game/player/HumanPlayer.java | 15 +- src/main/java/forge/game/player/Player.java | 130 ++++++------ .../java/forge/game/player/PlayerUtil.java | 14 +- .../forge/game/zone/DefaultPlayerZone.java | 8 +- src/main/java/forge/game/zone/MagicStack.java | 22 +- .../game/zone/PlayerZoneComesIntoPlay.java | 18 +- .../java/forge/gui/GuiAssignDamageFrame.java | 7 +- src/main/java/forge/gui/GuiDisplayUtil.java | 32 +-- src/main/java/forge/gui/match/CMatchUI.java | 4 +- .../java/forge/gui/match/ControlWinLose.java | 6 +- .../forge/gui/match/QuestWinLoseHandler.java | 11 +- .../forge/gui/match/nonsingleton/CField.java | 4 +- .../java/forge/gui/match/views/VPlayers.java | 5 +- src/main/java/forge/item/ItemPoolView.java | 7 +- src/main/java/forge/model/FMatchState.java | 10 +- src/main/java/forge/quest/QuestUtil.java | 19 +- src/test/java/forge/BoosterDraftTest.java | 6 +- src/test/java/forge/RunTest.java | 6 +- 116 files changed, 1583 insertions(+), 1495 deletions(-) delete mode 100644 src/main/java/forge/CardList.java diff --git a/.gitattributes b/.gitattributes index 94d1fc1b840..97621a0b445 100644 --- a/.gitattributes +++ b/.gitattributes @@ -12339,7 +12339,6 @@ src/main/java/forge/CardCharacteristicName.java -text src/main/java/forge/CardColor.java svneol=native#text/plain src/main/java/forge/CardDamageHistory.java -text src/main/java/forge/CardKeywords.java svneol=native#text/plain -src/main/java/forge/CardList.java svneol=native#text/plain src/main/java/forge/CardListUtil.java svneol=native#text/plain src/main/java/forge/CardPowerToughness.java svneol=native#text/plain src/main/java/forge/CardPredicates.java svneol=native#text/plain diff --git a/src/main/java/forge/AllZoneUtil.java b/src/main/java/forge/AllZoneUtil.java index 9e90328c26b..b7f0091a741 100644 --- a/src/main/java/forge/AllZoneUtil.java +++ b/src/main/java/forge/AllZoneUtil.java @@ -44,15 +44,15 @@ public abstract class AllZoneUtil { * * @param zone * Constant.Zone - * @return a CardList with all cards currently in a graveyard + * @return a List with all cards currently in a graveyard */ - public static CardList getCardsIn(final ZoneType zone) { - final CardList cards = new CardList(); + public static List getCardsIn(final ZoneType zone) { + final List cards = new ArrayList(); getCardsIn(zone, cards); return cards; } - private static void getCardsIn(final ZoneType zone, final CardList cards) { + private static void getCardsIn(final ZoneType zone, final List cards) { if (zone == ZoneType.Stack) { cards.addAll(AllZone.getStackZone().getCards()); } else { @@ -62,16 +62,16 @@ public abstract class AllZoneUtil { } } - public static CardList getCardsIn(final Iterable zones) { - final CardList cards = new CardList(); + public static List getCardsIn(final Iterable zones) { + final List cards = new ArrayList(); for (final ZoneType z : zones) { getCardsIn(z, cards); } return cards; } - public static CardList getCardsIn(final ZoneType[] zones) { - final CardList cards = new CardList(); + public static List getCardsIn(final ZoneType[] zones) { + final List cards = new ArrayList(); for (final ZoneType z : zones) { getCardsIn(z, cards); } @@ -86,22 +86,22 @@ public abstract class AllZoneUtil { * a Constant.Zone * @param cardName * a String - * @return a CardList with all cards currently in a graveyard + * @return a List with all cards currently in a graveyard */ - public static CardList getCardsIn(final ZoneType zone, final String cardName) { + public static List getCardsIn(final ZoneType zone, final String cardName) { return CardListUtil.filter(AllZoneUtil.getCardsIn(zone), CardPredicates.nameEquals(cardName)); } // ////////// Creatures /** - * use to get a CardList of all creatures on the battlefield for both. + * use to get a List of all creatures on the battlefield for both. * players * - * @return a CardList of all creatures on the battlefield on both sides + * @return a List of all creatures on the battlefield on both sides */ - public static CardList getCreaturesInPlay() { - final CardList creats = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + public static List getCreaturesInPlay() { + final List creats = AllZoneUtil.getCardsIn(ZoneType.Battlefield); return CardListUtil.filter(creats, Presets.CREATURES); } @@ -110,10 +110,10 @@ public abstract class AllZoneUtil { * * @param player * the player to get creatures for - * @return a CardList containing all creatures a given player has in play + * @return a List containing all creatures a given player has in play */ - public static CardList getCreaturesInPlay(final Player player) { - final CardList creats = player.getCardsIn(ZoneType.Battlefield); + public static List getCreaturesInPlay(final Player player) { + final List creats = player.getCardsIn(ZoneType.Battlefield); return CardListUtil.filter(creats, Presets.CREATURES); } @@ -124,18 +124,18 @@ public abstract class AllZoneUtil { * * @param player * the player whose lands we want to get - * @return a CardList containing all lands the given player has in play + * @return a List containing all lands the given player has in play */ - public static CardList getPlayerLandsInPlay(final Player player) { + public static List getPlayerLandsInPlay(final Player player) { return CardListUtil.filter(player.getCardsIn(ZoneType.Battlefield), Presets.LANDS); } /** * gets a list of all lands in play. * - * @return a CardList of all lands on the battlefield + * @return a List of all lands on the battlefield */ - public static CardList getLandsInPlay() { + public static List getLandsInPlay() { return CardListUtil.filter(AllZoneUtil.getCardsIn(ZoneType.Battlefield), Presets.LANDS); } @@ -215,10 +215,10 @@ public abstract class AllZoneUtil { * * @param color * the color of cards to get - * @return a CardList of all cards in play of a given color + * @return a List of all cards in play of a given color */ - public static CardList getColorInPlay(final String color) { - final CardList cards = AllZoneUtil.getPlayerColorInPlay(AllZone.getComputerPlayer(), color); + public static List getColorInPlay(final String color) { + final List cards = AllZoneUtil.getPlayerColorInPlay(AllZone.getComputerPlayer(), color); cards.addAll(AllZoneUtil.getPlayerColorInPlay(AllZone.getHumanPlayer(), color)); return cards; } @@ -231,10 +231,10 @@ public abstract class AllZoneUtil { * the player's 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 List of all cards in play of a given color */ - public static CardList getPlayerColorInPlay(final Player player, final String color) { - CardList cards = player.getCardsIn(ZoneType.Battlefield); + public static List getPlayerColorInPlay(final Player player, final String color) { + List cards = player.getCardsIn(ZoneType.Battlefield); cards = CardListUtil.filter(cards, new Predicate() { @Override public boolean apply(final Card c) { @@ -279,8 +279,8 @@ public abstract class AllZoneUtil { public static int compareTypeAmountInPlay(final Player player, final String type) { // returns the difference between player's final Player opponent = player.getOpponent(); - final CardList playerList = CardListUtil.getType(player.getCardsIn(ZoneType.Battlefield), type); - final CardList opponentList = CardListUtil.getType(opponent.getCardsIn(ZoneType.Battlefield), type); + final List playerList = CardListUtil.getType(player.getCardsIn(ZoneType.Battlefield), type); + final List opponentList = CardListUtil.getType(opponent.getCardsIn(ZoneType.Battlefield), type); return (playerList.size() - opponentList.size()); } @@ -298,8 +298,8 @@ public abstract class AllZoneUtil { public static int compareTypeAmountInGraveyard(final Player player, final String type) { // returns the difference between player's final Player opponent = player.getOpponent(); - final CardList playerList = CardListUtil.getType(player.getCardsIn(ZoneType.Graveyard), type); - final CardList opponentList = CardListUtil.getType(opponent.getCardsIn(ZoneType.Graveyard), type); + final List playerList = CardListUtil.getType(player.getCardsIn(ZoneType.Graveyard), type); + final List opponentList = CardListUtil.getType(opponent.getCardsIn(ZoneType.Graveyard), type); return (playerList.size() - opponentList.size()); } @@ -309,8 +309,8 @@ public abstract class AllZoneUtil { * @return a {@link forge.CardList} with all cards in all Battlefields, * Hands, Graveyards, Libraries, and Exiles. */ - public static CardList getCardsInGame() { - final CardList all = new CardList(); + public static List getCardsInGame() { + final List all = new ArrayList(); for (final Player player : AllZone.getPlayersInGame()) { all.addAll(player.getZone(ZoneType.Graveyard).getCards()); all.addAll(player.getZone(ZoneType.Hand).getCards()); diff --git a/src/main/java/forge/Card.java b/src/main/java/forge/Card.java index 4978a905c2e..9534e1f24f8 100644 --- a/src/main/java/forge/Card.java +++ b/src/main/java/forge/Card.java @@ -113,14 +113,14 @@ public class Card extends GameEntity implements Comparable { private final ArrayList rememberedObjects = new ArrayList(); private final ArrayList imprintedCards = new ArrayList(); private Card championedCard = null; - private final CardList devouredCards = new CardList(); + private final List devouredCards = new ArrayList(); private Map receivedDamageFromThisTurn = new TreeMap(); private Map dealtDamageToThisTurn = new TreeMap(); private Map dealtDamageToPlayerThisTurn = new TreeMap(); private final Map assignedDamageMap = new TreeMap(); - private CardList blockedThisTurn = null; - private CardList blockedByThisTurn = null; + private List blockedThisTurn = null; + private List blockedByThisTurn = null; private boolean startsGameInPlay = false; private boolean drawnThisTurn = false; @@ -575,9 +575,9 @@ public class Card extends GameEntity implements Comparable { * * TODO Write javadoc for this method. * - * @return a CardList object + * @return a List object */ - public final CardList getDevoured() { + public final List getDevoured() { return this.devouredCards; } @@ -941,7 +941,7 @@ public class Card extends GameEntity implements Comparable { /** * @return the blockedThisTurn */ - public CardList getBlockedThisTurn() { + public List getBlockedThisTurn() { return blockedThisTurn; } @@ -950,7 +950,7 @@ public class Card extends GameEntity implements Comparable { */ public void addBlockedThisTurn(Card attacker) { if (this.blockedThisTurn == null) { - this.blockedThisTurn = new CardList(); + this.blockedThisTurn = new ArrayList(); } this.blockedThisTurn.add(attacker); } @@ -967,7 +967,7 @@ public class Card extends GameEntity implements Comparable { /** * @return the blockedByThisTurn */ - public CardList getBlockedByThisTurn() { + public List getBlockedByThisTurn() { return blockedByThisTurn; } @@ -976,7 +976,7 @@ public class Card extends GameEntity implements Comparable { */ public void addBlockedByThisTurn(Card blocker) { if (this.blockedByThisTurn == null) { - this.blockedByThisTurn = new CardList(); + this.blockedByThisTurn = new ArrayList(); } this.blockedByThisTurn.add(blocker); } @@ -6546,7 +6546,7 @@ public class Card extends GameEntity implements Comparable { } } else if (property.startsWith("ControllerControls")) { final String type = property.substring(18); - final CardList list = this.getController().getCardsIn(ZoneType.Battlefield); + final List list = this.getController().getCardsIn(ZoneType.Battlefield); if (CardListUtil.getType(list, type).isEmpty()) { return false; } @@ -6639,13 +6639,13 @@ public class Card extends GameEntity implements Comparable { } } } else if (property.startsWith("Above")) { // "Are Above" Source - final CardList list = this.getOwner().getCardsIn(ZoneType.Graveyard); + final List list = this.getOwner().getCardsIn(ZoneType.Graveyard); if (list.indexOf(source) >= list.indexOf(this)) { return false; } } else if (property.startsWith("DirectlyAbove")) { // "Are Directly Above" // Source - final CardList list = this.getOwner().getCardsIn(ZoneType.Graveyard); + final List list = this.getOwner().getCardsIn(ZoneType.Graveyard); if (list.indexOf(this) - list.indexOf(source) != 1) { return false; } @@ -6656,18 +6656,18 @@ public class Card extends GameEntity implements Comparable { return false; } } else if (property.startsWith("TopGraveyard")) { - final CardList list = this.getOwner().getCardsIn(ZoneType.Graveyard); + final List list = this.getOwner().getCardsIn(ZoneType.Graveyard); Collections.reverse(list); if (list.isEmpty() || !this.equals(list.get(0))) { return false; } } else if (property.startsWith("BottomGraveyard")) { - final CardList list = this.getOwner().getCardsIn(ZoneType.Graveyard); + final List list = this.getOwner().getCardsIn(ZoneType.Graveyard); if (list.isEmpty() || !this.equals(list.get(0))) { return false; } } else if (property.startsWith("TopLibrary")) { - final CardList list = this.getOwner().getCardsIn(ZoneType.Library); + final List list = this.getOwner().getCardsIn(ZoneType.Library); if (list.isEmpty() || !this.equals(list.get(0))) { return false; } @@ -6691,7 +6691,7 @@ public class Card extends GameEntity implements Comparable { } else { final String restriction = property.split("SharesColorWith ")[1]; if (restriction.equals("TopCardOfLibrary")) { - final CardList list = sourceController.getCardsIn(ZoneType.Library); + final List list = sourceController.getCardsIn(ZoneType.Library); if (list.isEmpty() || !this.sharesColorWith(list.get(0))) { return false; } @@ -6721,7 +6721,7 @@ public class Card extends GameEntity implements Comparable { } else { final String restriction = property.split("sharesCreatureTypeWith ")[1]; if (restriction.equals("TopCardOfLibrary")) { - final CardList list = sourceController.getCardsIn(ZoneType.Library); + final List list = sourceController.getCardsIn(ZoneType.Library); if (list.isEmpty() || !this.sharesCreatureTypeWith(list.get(0))) { return false; } @@ -6771,7 +6771,7 @@ public class Card extends GameEntity implements Comparable { } else { final String restriction = property.split("sharesNameWith ")[1]; if (restriction.equals("YourGraveyard")) { - final CardList list = sourceController.getCardsIn(ZoneType.Graveyard); + final List list = sourceController.getCardsIn(ZoneType.Graveyard); if (list.isEmpty()) { return false; } @@ -6785,7 +6785,7 @@ public class Card extends GameEntity implements Comparable { return false; } } else if (restriction.equals(ZoneType.Battlefield.toString())) { - final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); if (list.isEmpty()) { return false; } @@ -6799,7 +6799,7 @@ public class Card extends GameEntity implements Comparable { return false; } } else if (restriction.equals("ThisTurnCast")) { - final CardList list = CardUtil.getThisTurnCast("Card", source); + final List list = CardUtil.getThisTurnCast("Card", source); if (list.isEmpty()) { return false; } @@ -6830,7 +6830,7 @@ public class Card extends GameEntity implements Comparable { } } else if (property.startsWith("SecondSpellCastThisTurn")) { - final CardList list = CardUtil.getThisTurnCast("Card", source); + final List list = CardUtil.getThisTurnCast("Card", source); if (list.size() < 2) { return false; } @@ -6969,28 +6969,28 @@ public class Card extends GameEntity implements Comparable { return false; } } else if (property.startsWith("greatestPower")) { - final CardList list = AllZoneUtil.getCreaturesInPlay(); + final List list = AllZoneUtil.getCreaturesInPlay(); for (final Card crd : list) { if (crd.getNetAttack() > this.getNetAttack()) { return false; } } } else if (property.startsWith("leastPower")) { - final CardList list = AllZoneUtil.getCreaturesInPlay(); + final List list = AllZoneUtil.getCreaturesInPlay(); for (final Card crd : list) { if (crd.getNetAttack() < this.getNetAttack()) { return false; } } } else if (property.startsWith("greatestCMC")) { - final CardList list = AllZoneUtil.getCreaturesInPlay(); + final List list = AllZoneUtil.getCreaturesInPlay(); for (final Card crd : list) { if (crd.getCMC() > this.getCMC()) { return false; } } } else if (property.startsWith("lowestCMC")) { - final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card crd : list) { if (!crd.isLand() && !crd.isImmutable() && (crd.getCMC() < this.getCMC())) { return false; @@ -7256,7 +7256,7 @@ public class Card extends GameEntity implements Comparable { return false; } } else if (property.startsWith("OnBattlefield")) { - final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); if (!list.contains(this)) { return false; } @@ -7523,7 +7523,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isBlocking() { - final CardList blockers = AllZone.getCombat().getAllBlockers(); + final List blockers = AllZone.getCombat().getAllBlockers(); return blockers.contains(this); } @@ -7922,7 +7922,7 @@ public class Card extends GameEntity implements Comparable { * a {@link java.util.Map} object. */ public final void addCombatDamage(final Map map) { - final CardList list = new CardList(); + final List list = new ArrayList(); for (final Entry entry : map.entrySet()) { final Card source = entry.getKey(); @@ -8081,7 +8081,7 @@ public class Card extends GameEntity implements Comparable { } // Prevent Damage static abilities - final CardList allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card ca : allp) { final ArrayList staticAbilities = ca.getStaticAbilities(); for (final StaticAbility stAb : staticAbilities) { @@ -8274,7 +8274,7 @@ public class Card extends GameEntity implements Comparable { return 0; } - final CardList auras = new CardList(this.getEnchantedBy()); + final List auras = new ArrayList(this.getEnchantedBy()); if (Iterables.any(auras, CardPredicates.nameEquals("Treacherous Link"))) { this.getController().addDamage(damageIn, source); @@ -8870,7 +8870,7 @@ public class Card extends GameEntity implements Comparable { } // CantTarget static abilities - final CardList allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card ca : allp) { final ArrayList staticAbilities = ca.getStaticAbilities(); for (final StaticAbility stAb : staticAbilities) { diff --git a/src/main/java/forge/CardList.java b/src/main/java/forge/CardList.java deleted file mode 100644 index fec234c53cd..00000000000 --- a/src/main/java/forge/CardList.java +++ /dev/null @@ -1,39 +0,0 @@ -/* - * Forge: Play Magic: the Gathering. - * Copyright (C) 2011 Forge Team - * - * This program is free software: you can redistribute it and/or modify - * it under the terms of the GNU General Public License as published by - * the Free Software Foundation, either version 3 of the License, or - * (at your option) any later version. - * - * This program is distributed in the hope that it will be useful, - * but WITHOUT ANY WARRANTY; without even the implied warranty of - * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the - * GNU General Public License for more details. - * - * You should have received a copy of the GNU General Public License - * along with this program. If not, see . - */ -package forge; - -import java.util.ArrayList; - - -/** - *

- * CardList class. - *

- * - * @author Forge - * @version $Id$ - */ -public class CardList extends ArrayList { - - private static final long serialVersionUID = 7912620750458976012L; - - public CardList() {} - public CardList(final Card c) { this.add(c); } - public CardList(final Iterable al) { for(Card c : al) this.add(c); } - -} // end class CardList diff --git a/src/main/java/forge/CardListUtil.java b/src/main/java/forge/CardListUtil.java index 9eded6b9fc7..89ce0b290d9 100644 --- a/src/main/java/forge/CardListUtil.java +++ b/src/main/java/forge/CardListUtil.java @@ -17,6 +17,7 @@ */ package forge; +import java.util.ArrayList; import java.util.Collections; import java.util.Comparator; import java.util.List; @@ -24,6 +25,7 @@ import java.util.List; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; import forge.card.cardfactory.CardFactoryUtil; import forge.card.spellability.SpellAbility; @@ -52,7 +54,7 @@ public class CardListUtil { * a int. * @return a {@link forge.CardList} object. */ - public static CardList filterToughness(final CardList in, final int atLeastToughness) { + public static List filterToughness(final List in, final int atLeastToughness) { return CardListUtil.filter(in, new Predicate() { @Override public boolean apply(Card c) { @@ -116,32 +118,32 @@ public class CardListUtil { * @param list * a {@link forge.CardList} object. */ - public static void sortAttack(final CardList list) { + public static void sortAttack(final List list) { Collections.sort(list, AttackComparator); } // sortAttack() /** *

- * Sorts a CardList by "best" using the EvaluateCreature function. + * Sorts a List by "best" using the EvaluateCreature function. * the best creatures will be first in the list. *

* * @param list * a {@link forge.CardList} object. */ - public static void sortByEvaluateCreature(final CardList list) { + public static void sortByEvaluateCreature(final List list) { Collections.sort(list, EvaluateCreatureComparator); } // sortByEvaluateCreature() /** *

- * Sorts a CardList by converted mana cost, putting highest first. + * Sorts a List by converted mana cost, putting highest first. *

* * @param list * a {@link forge.CardList} object. */ - public static void sortByMostExpensive(final CardList list) { + public static void sortByMostExpensive(final List list) { Collections.sort(list, CmcComparator); } // sortByMostExpensive() @@ -154,7 +156,7 @@ public class CardListUtil { * @param list * a {@link forge.CardList} object. */ - public static void sortAttackLowFirst(final CardList list) { + public static void sortAttackLowFirst(final List list) { Collections.sort(list, Collections.reverseOrder(AttackComparator)); } // sortAttackLowFirst() @@ -166,7 +168,7 @@ public class CardListUtil { * @param list * a {@link forge.CardList} object. */ - public static void sortNonFlyingFirst(final CardList list) { + public static void sortNonFlyingFirst(final List list) { CardListUtil.sortFlying(list); Collections.reverse(list); } // sortNonFlyingFirst @@ -179,19 +181,19 @@ public class CardListUtil { * @param list * a {@link forge.CardList} object. */ - public static void sortFlying(final CardList list) { + public static void sortFlying(final List list) { Collections.sort(list, getKeywordComparator("Flying")); } // sortFlying() /** *

- * Sorts a CardList from highest converted mana cost to lowest. + * Sorts a List from highest converted mana cost to lowest. *

* * @param list * a {@link forge.CardList} object. */ - public static void sortCMC(final CardList list) { + public static void sortCMC(final List list) { Collections.sort( list, CmcComparator ); } // sortCMC @@ -206,7 +208,7 @@ public class CardListUtil { * a {@link java.lang.String} object. * @return a {@link forge.CardList} object. */ - public static CardList getColor(final CardList list, final String color) { + public static List getColor(final List list, final String color) { return CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { @@ -224,7 +226,7 @@ public class CardListUtil { * a {@link forge.CardList} object. * @return a {@link forge.CardList} object. */ - public static CardList getGoldCards(final CardList list) { + public static List getGoldCards(final List list) { return CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { @@ -243,7 +245,7 @@ public class CardListUtil { * a {@link forge.CardList} object. * @return a int. */ - public static int sumCMC(final CardList c) { + public static int sumCMC(final List c) { return Aggregates.sum(c, CardPredicates.Accessors.fnGetCmc); } // sumCMC @@ -256,7 +258,7 @@ public class CardListUtil { * a {@link forge.CardList} object. * @return a float. */ - public static float getAverageCMC(final CardList c) { + public static float getAverageCMC(final List c) { return sumCMC(c) / c.size(); @@ -264,7 +266,7 @@ public class CardListUtil { /** * - * Given a CardList c, return a CardList that contains a random amount of cards from c. + * Given a List c, return a List that contains a random amount of cards from c. * * @param c * CardList @@ -272,12 +274,12 @@ public class CardListUtil { * int * @return CardList */ - public static CardList getRandomSubList(final CardList c, final int amount) { + public static List getRandomSubList(final List c, final int amount) { if (c.size() < amount) { return null; } - final CardList subList = new CardList(); + final List subList = new ArrayList(); while (subList.size() < amount) { CardListUtil.shuffle(c); subList.add(c.get(0)); @@ -298,38 +300,38 @@ public class CardListUtil { Collections.shuffle(list, MyRandom.getRandom()); } - public static CardList filterControlledBy(List cardList, Player player) { + public static List filterControlledBy(List cardList, Player player) { return CardListUtil.filter(cardList, CardPredicates.isController(player)); } - public static CardList getValidCards(List cardList, String[] restrictions, Player sourceController, Card source) { + public static List getValidCards(List cardList, String[] restrictions, Player sourceController, Card source) { return CardListUtil.filter(cardList, CardPredicates.restriction(restrictions, sourceController, source)); } - public static CardList getValidCards(List cardList, String restriction, Player sourceController, Card source) { + public static List getValidCards(List cardList, String restriction, Player sourceController, Card source) { return CardListUtil.filter(cardList, CardPredicates.restriction(restriction.split(","), sourceController, source)); } - public static CardList getTargetableCards(List cardList, SpellAbility source) { + public static List getTargetableCards(List cardList, SpellAbility source) { return CardListUtil.filter(cardList, CardPredicates.isTargetableBy(source)); } - public static CardList getKeyword(List cardList, String keyword) { + public static List getKeyword(List cardList, String keyword) { return CardListUtil.filter(cardList, CardPredicates.hasKeyword(keyword)); } - public static CardList getNotKeyword(List cardList, String keyword) { + public static List getNotKeyword(List cardList, String keyword) { return CardListUtil.filter(cardList, Predicates.not(CardPredicates.hasKeyword(keyword))); } - // cardType is like "Land" or "Goblin", returns a new CardList that is a + // cardType is like "Land" or "Goblin", returns a new ArrayList that is a // subset of current CardList - public static CardList getNotType(List cardList, String cardType) { + public static List getNotType(List cardList, String cardType) { return CardListUtil.filter(cardList, Predicates.not(CardPredicates.isType(cardType))); } - public static CardList getType(List cardList, String cardType) { + public static List getType(List cardList, String cardType) { return CardListUtil.filter(cardList, CardPredicates.isType(cardType)); } @@ -339,10 +341,16 @@ public class CardListUtil { * @param filt * determines which cards are present in the resulting list * - * @return a subset of this CardList whose items meet the filtering + * @return a subset of this List whose items meet the filtering * criteria; may be empty, but never null. */ - public static CardList filter(List cardList, Predicate filt) { - return new CardList(Iterables.filter(cardList, filt)); + public static List filter(List cardList, Predicate filt) { + return Lists.newArrayList(Iterables.filter(cardList, filt)); + } + + public static List createCardList(Card c) { + List res = new ArrayList(); + res.add(c); + return res; } } diff --git a/src/main/java/forge/CardUtil.java b/src/main/java/forge/CardUtil.java index 8e5d262e5ca..879ec632b85 100644 --- a/src/main/java/forge/CardUtil.java +++ b/src/main/java/forge/CardUtil.java @@ -108,7 +108,7 @@ public final class CardUtil { * a {@link forge.CardList} object. * @return a int. */ - public static int getRandomIndex(final CardList c) { + public static int getRandomIndex(final List c) { return CardUtil.RANDOM.nextInt(c.size()); } @@ -621,11 +621,11 @@ public final class CardUtil { * a isValid expression * @param src * a Card object - * @return a CardList that matches the given criteria + * @return a List that matches the given criteria */ - public static CardList getThisTurnEntered(final ZoneType to, final ZoneType from, final String valid, + public static List getThisTurnEntered(final ZoneType to, final ZoneType from, final String valid, final Card src) { - CardList res = new CardList(); + List res = new ArrayList(); if (to != ZoneType.Stack) { res.addAll(((DefaultPlayerZone) AllZone.getComputerPlayer().getZone(to)).getCardsAddedThisTurn(from)); res.addAll(((DefaultPlayerZone) AllZone.getHumanPlayer().getZone(to)).getCardsAddedThisTurn(from)); @@ -645,10 +645,10 @@ public final class CardUtil { * a String object * @param src * a Card object - * @return a CardList that matches the given criteria + * @return a List that matches the given criteria */ - public static CardList getThisTurnCast(final String valid, final Card src) { - CardList res = new CardList(); + public static List getThisTurnCast(final String valid, final Card src) { + List res = new ArrayList(); res.addAll(AllZone.getStack().getCardsCastThisTurn()); @@ -664,10 +664,10 @@ public final class CardUtil { * a String object * @param src * a Card object - * @return a CardList that matches the given criteria + * @return a List that matches the given criteria */ - public static CardList getLastTurnCast(final String valid, final Card src) { - CardList res = new CardList(); + public static List getLastTurnCast(final String valid, final Card src) { + List res = new ArrayList(); res.addAll(AllZone.getStack().getCardsCastLastTurn()); @@ -820,8 +820,8 @@ public final class CardUtil { * the valid * @return the radiance */ - public static CardList getRadiance(final Card source, final Card origin, final String[] valid) { - final CardList res = new CardList(); + public static List getRadiance(final Card source, final Card origin, final String[] valid) { + final List res = new ArrayList(); for (final CardColor col : origin.getColor()) { for (final String strCol : col.toStringList()) { diff --git a/src/main/java/forge/GameAction.java b/src/main/java/forge/GameAction.java index 178f69aedc7..7d4ba3bc809 100644 --- a/src/main/java/forge/GameAction.java +++ b/src/main/java/forge/GameAction.java @@ -22,6 +22,7 @@ import java.util.Collections; import java.util.Comparator; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import javax.swing.JFrame; @@ -75,7 +76,7 @@ public class GameAction { *

*/ public final void resetActivationsPerTurn() { - final CardList all = AllZoneUtil.getCardsInGame(); + final List all = AllZoneUtil.getCardsInGame(); // Reset Activations per Turn for (final Card card : all) { @@ -246,7 +247,7 @@ public class GameAction { } // Handle unequipping creatures if (copied.isEquipped()) { - final CardList equipments = new CardList(copied.getEquippedBy()); + final List equipments = new ArrayList(copied.getEquippedBy()); for (final Card equipment : equipments) { if (AllZoneUtil.isCardInPlay(equipment)) { equipment.unEquipCard(copied); @@ -255,7 +256,7 @@ public class GameAction { } // Handle unequipping creatures if (copied.isEquipped()) { - final CardList equipments = new CardList(copied.getEquippedBy()); + final List equipments = new ArrayList(copied.getEquippedBy()); for (final Card equipment : equipments) { if (AllZoneUtil.isCardInPlay(equipment)) { equipment.unEquipCard(copied); @@ -271,7 +272,7 @@ public class GameAction { } // remove enchantments from creatures if (copied.isEnchanted()) { - final CardList auras = new CardList(copied.getEnchantedBy()); + final List auras = new ArrayList(copied.getEnchantedBy()); for (final Card aura : auras) { aura.unEnchantEntity(copied); } @@ -455,8 +456,8 @@ public class GameAction { final Player owner = c.getOwner(); final PlayerZone grave = owner.getZone(ZoneType.Graveyard); final PlayerZone exile = owner.getZone(ZoneType.Exile); - final CardList ownerBoard = owner.getCardsIn(ZoneType.Battlefield); - final CardList opponentsBoard = owner.getOpponent().getCardsIn(ZoneType.Battlefield); + final List ownerBoard = owner.getCardsIn(ZoneType.Battlefield); + final List opponentsBoard = owner.getOpponent().getCardsIn(ZoneType.Battlefield); if (c.getName().equals("Nissa's Chosen") && origZone.is(ZoneType.Battlefield)) { return this.moveToLibrary(c, -1); @@ -949,7 +950,7 @@ public class GameAction { AllZone.getStaticEffects().clearStaticEffects(); // search for cards with static abilities - final CardList allCards = AllZoneUtil.getCardsInGame(); + final List allCards = AllZoneUtil.getCardsInGame(); final ArrayList staticAbilities = new ArrayList(); for (final Card card : allCards) { for (StaticAbility sa : card.getStaticAbilities()) { @@ -1036,7 +1037,7 @@ public class GameAction { final HashMap runParams = new HashMap(); AllZone.getTriggerHandler().runTrigger(TriggerType.Always, runParams); - final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); Card c; final Iterator it = list.iterator(); @@ -1045,7 +1046,7 @@ public class GameAction { c = it.next(); if (c.isEquipped()) { - final CardList equipments = new CardList(c.getEquippedBy()); + final List equipments = new ArrayList(c.getEquippedBy()); for (final Card equipment : equipments) { if (!AllZoneUtil.isCardInPlay(equipment)) { equipment.unEquipCard(c); @@ -1169,13 +1170,13 @@ public class GameAction { } // for q=0;q<2 /* //Experiment Kraj experiment - CardList krajs = AllZoneUtil.getCardsIn(ZoneType.Battlefield).filter(new Predicate() { + List krajs = AllZoneUtil.getCardsIn(ZoneType.Battlefield).filter(new Predicate() { @Override public boolean addCard(Card c) { return c.getName().equals("Experiment Kraj"); } }); - CardList P1P1s = AllZoneUtil.getCardsIn(ZoneType.Battlefield).filter(new Predicate() { + List P1P1s = AllZoneUtil.getCardsIn(ZoneType.Battlefield).filter(new Predicate() { @Override public boolean addCard(Card c) { return c.getCounters(Counters.P1P1) > 0; @@ -1217,7 +1218,7 @@ public class GameAction { */ private void destroyPlaneswalkers() { // get all Planeswalkers - final CardList list = CardListUtil.filter(AllZoneUtil.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.PLANEWALKERS); + final List list = CardListUtil.filter(AllZoneUtil.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.PLANEWALKERS); Card c; for (int i = 0; i < list.size(); i++) { @@ -1233,7 +1234,7 @@ public class GameAction { continue; } - final CardList cl = CardListUtil.getType(list, type); + final List cl = CardListUtil.getType(list, type); if (cl.size() > 1) { for (final Card crd : cl) { @@ -1250,13 +1251,13 @@ public class GameAction { *

*/ private void destroyLegendaryCreatures() { - final CardList a = CardListUtil.getType(AllZoneUtil.getCardsIn(ZoneType.Battlefield), "Legendary"); + final List a = CardListUtil.getType(AllZoneUtil.getCardsIn(ZoneType.Battlefield), "Legendary"); if (a.isEmpty() || AllZoneUtil.isCardInPlay("Mirror Gallery")) { return; } while (!a.isEmpty()) { - CardList b = AllZoneUtil.getCardsIn(ZoneType.Battlefield, a.get(0).getName()); + List b = AllZoneUtil.getCardsIn(ZoneType.Battlefield, a.get(0).getName()); b = CardListUtil.getType(b, "Legendary"); b = CardListUtil.filter(b, new Predicate() { @Override @@ -1319,7 +1320,7 @@ public class GameAction { } if (c.isEnchanted()) { - CardList list = new CardList(c.getEnchantedBy()); + List list = new ArrayList(c.getEnchantedBy()); list = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card crd) { @@ -1502,7 +1503,7 @@ public class GameAction { } if (c.isEnchanted()) { - CardList list = new CardList(c.getEnchantedBy()); + List list = new ArrayList(c.getEnchantedBy()); list = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card crd) { @@ -1710,8 +1711,8 @@ public class GameAction { final Integer chosenAmount = (Integer) GuiChoose.one("Exile how many cards?", cntChoice); System.out.println("Delve for " + chosenAmount); - final CardList choices = AllZone.getHumanPlayer().getCardsIn(ZoneType.Graveyard); - final CardList chosen = new CardList(); + final List choices = AllZone.getHumanPlayer().getCardsIn(ZoneType.Graveyard); + final List chosen = new ArrayList(); for (int i = 0; i < chosenAmount; i++) { final Card nowChosen = GuiChoose.oneOrNone("Exile which card?", choices); @@ -1743,7 +1744,7 @@ public class GameAction { } for (int i = 0; i < numToExile; i++) { - final CardList grave = new CardList(AllZone.getComputerPlayer().getZone(ZoneType.Graveyard) + final List grave = new ArrayList(AllZone.getComputerPlayer().getZone(ZoneType.Graveyard) .getCards()); Card chosen = null; for (final Card c : grave) { // Exile noncreatures first @@ -1772,7 +1773,7 @@ public class GameAction { manaCost.decreaseColorlessMana(numToExile); } } else if (spell.getSourceCard().hasKeyword("Convoke")) { - CardList untappedCreats = CardListUtil.filter(spell.getActivatingPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES); + List untappedCreats = CardListUtil.filter(spell.getActivatingPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES); untappedCreats = CardListUtil.filter(untappedCreats, CardPredicates.Presets.UNTAPPED); if (untappedCreats.size() != 0) { @@ -1859,7 +1860,7 @@ public class GameAction { } } // isSpell - CardList cardsOnBattlefield = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List cardsOnBattlefield = AllZoneUtil.getCardsIn(ZoneType.Battlefield); cardsOnBattlefield.add(originalCard); final ArrayList raiseAbilities = new ArrayList(); final ArrayList reduceAbilities = new ArrayList(); diff --git a/src/main/java/forge/GameActionUtil.java b/src/main/java/forge/GameActionUtil.java index 5afdb79a55f..58b18834103 100644 --- a/src/main/java/forge/GameActionUtil.java +++ b/src/main/java/forge/GameActionUtil.java @@ -104,12 +104,12 @@ public final class GameActionUtil { public void execute() { if (!c.isCopiedSpell()) { - final CardList humanNexus = AllZone.getHumanPlayer() + final List humanNexus = AllZone.getHumanPlayer() .getCardsIn(ZoneType.Battlefield, "Maelstrom Nexus"); - final CardList computerNexus = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield, + final List computerNexus = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield, "Maelstrom Nexus"); - final CardList maelstromNexii = new CardList(); + final List maelstromNexii = new ArrayList(); maelstromNexii.addAll(humanNexus); maelstromNexii.addAll(computerNexus); @@ -133,8 +133,8 @@ public final class GameActionUtil { final Ability ability = new Ability(c, "0") { @Override public void resolve() { - final CardList topOfLibrary = controller.getCardsIn(ZoneType.Library); - final CardList revealed = new CardList(); + final List topOfLibrary = controller.getCardsIn(ZoneType.Library); + final List revealed = new ArrayList(); if (topOfLibrary.size() == 0) { return; @@ -229,9 +229,9 @@ public final class GameActionUtil { @Override public void execute() { - final CardList humanThrummingStone = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield, + final List humanThrummingStone = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield, "Thrumming Stone"); - final CardList computerThrummingStone = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield, + final List computerThrummingStone = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield, "Thrumming Stone"); for (int i = 0; i < humanThrummingStone.size(); i++) { @@ -264,8 +264,8 @@ public final class GameActionUtil { final Ability ability = new Ability(c, "0") { @Override public void resolve() { - final CardList topOfLibrary = controller.getCardsIn(ZoneType.Library); - final CardList revealed = new CardList(); + final List topOfLibrary = controller.getCardsIn(ZoneType.Library); + final List revealed = new ArrayList(); int rippleNumber = rippleCount; if (topOfLibrary.size() == 0) { return; @@ -856,14 +856,14 @@ public final class GameActionUtil { return; } - final CardList playerLiches = player.getCardsIn(ZoneType.Battlefield, "Lich"); + final List playerLiches = player.getCardsIn(ZoneType.Battlefield, "Lich"); for (final Card lich : playerLiches) { final SpellAbility ability = new Ability(lich, "0") { @Override public void resolve() { for (int i = 0; i < damage; i++) { - CardList nonTokens = player.getCardsIn(ZoneType.Battlefield); + List nonTokens = player.getCardsIn(ZoneType.Battlefield); nonTokens = CardListUtil.filter(nonTokens, Presets.NON_TOKEN); if (nonTokens.size() == 0) { player.loseConditionMet(GameLossReason.SpellEffect, lich.getName()); @@ -916,7 +916,7 @@ public final class GameActionUtil { } if (c.isCreature() && AllZoneUtil.isCardInPlay("Contested War Zone", player)) { - final CardList zones = player.getCardsIn(ZoneType.Battlefield, "Contested War Zone"); + final List zones = player.getCardsIn(ZoneType.Battlefield, "Contested War Zone"); for (final Card zone : zones) { final Ability ability = new Ability(zone, "0") { @Override @@ -1069,7 +1069,7 @@ public final class GameActionUtil { @Override public void resolve() { - final CardList libList = opponent.getCardsIn(ZoneType.Library); + final List libList = opponent.getCardsIn(ZoneType.Library); int count = 0; int broken = 0; for (int i = 0; i < libList.size(); i = i + 4) { @@ -1158,7 +1158,7 @@ public final class GameActionUtil { produces.put("Plains", "W"); produces.put("Swamp", "B"); - CardList lands = AllZoneUtil.getCardsInGame(); + List lands = AllZoneUtil.getCardsInGame(); lands = CardListUtil.filter(lands, Presets.LANDS); // remove all abilities granted by this Command @@ -1217,11 +1217,11 @@ public final class GameActionUtil { private static Command coatOfArms = new Command() { private static final long serialVersionUID = 583505612126735693L; - private final CardList gloriousAnthemList = new CardList(); + private final List gloriousAnthemList = new ArrayList(); @Override public void execute() { - final CardList list = this.gloriousAnthemList; + final List list = this.gloriousAnthemList; // reset all cards in list - aka "old" cards for (int i2 = 0; i2 < list.size(); i2++) { list.get(i2).addSemiPermanentAttackBoost(-1); @@ -1249,14 +1249,14 @@ public final class GameActionUtil { private static Command alphaStatus = new Command() { private static final long serialVersionUID = -3213793711304934358L; - private final CardList previouslyPumped = new CardList(); + private final List previouslyPumped = new ArrayList(); private final ArrayList previouslyPumpedValue = new ArrayList(); @Override public void execute() { - final CardList alphaStatuses = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Alpha Status"); + final List alphaStatuses = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Alpha Status"); - final CardList allCreatures = AllZoneUtil.getCreaturesInPlay(); + final List allCreatures = AllZoneUtil.getCreaturesInPlay(); for (int i = 0; i < this.previouslyPumped.size(); i++) { this.previouslyPumped.get(i).addSemiPermanentAttackBoost(0 - this.previouslyPumpedValue.get(i)); @@ -1291,10 +1291,10 @@ public final class GameActionUtil { @Override public void execute() { // get all creatures - final CardList cards = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Umbra Stalker"); + final List cards = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Umbra Stalker"); for (final Card c : cards) { final Player player = c.getController(); - final CardList grave = player.getCardsIn(ZoneType.Graveyard); + final List grave = player.getCardsIn(ZoneType.Graveyard); final int pt = CardFactoryUtil.getNumberOfManaSymbolsByColor("B", grave); c.setBaseAttack(pt); c.setBaseDefense(pt); @@ -1308,7 +1308,7 @@ public final class GameActionUtil { @Override public void execute() { - CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = CardListUtil.filter(list, new Predicate() { @Override @@ -1331,7 +1331,7 @@ public final class GameActionUtil { @Override public void execute() { - final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Old Man of the Sea"); + final List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Old Man of the Sea"); for (final Card oldman : list) { if (!oldman.getGainControlTargets().isEmpty()) { if (oldman.getNetAttack() < oldman.getGainControlTargets().get(0).getNetAttack()) { @@ -1352,7 +1352,7 @@ public final class GameActionUtil { @Override public void execute() { - final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Liu Bei, Lord of Shu"); + final List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Liu Bei, Lord of Shu"); if (list.size() > 0) { for (int i = 0; i < list.size(); i++) { @@ -1371,7 +1371,7 @@ public final class GameActionUtil { } // execute() private boolean getsBonus(final Card c) { - CardList list = c.getController().getCardsIn(ZoneType.Battlefield); + List list = c.getController().getCardsIn(ZoneType.Battlefield); list = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { @@ -1391,7 +1391,7 @@ public final class GameActionUtil { @Override public void execute() { - CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { @@ -1409,7 +1409,7 @@ public final class GameActionUtil { } private int countSoundTheCalls() { - CardList list = AllZoneUtil.getCardsIn(ZoneType.Graveyard, "Sound the Call"); + List list = AllZoneUtil.getCardsIn(ZoneType.Graveyard, "Sound the Call"); return list.size(); } @@ -1422,7 +1422,7 @@ public final class GameActionUtil { @Override public void execute() { // get all creatures - final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Tarmogoyf"); + final List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Tarmogoyf"); for (int i = 0; i < list.size(); i++) { final Card c = list.get(i); @@ -1433,7 +1433,7 @@ public final class GameActionUtil { } // execute() private int countDiffTypes() { - final CardList list = AllZoneUtil.getCardsIn(ZoneType.Graveyard); + final List list = AllZoneUtil.getCardsIn(ZoneType.Graveyard); int count = 0; for (int q = 0; q < list.size(); q++) { @@ -1521,7 +1521,7 @@ public final class GameActionUtil { */ public static void doPowerSink(final Player p) { // get all lands with mana abilities - CardList lands = AllZoneUtil.getPlayerLandsInPlay(p); + List lands = AllZoneUtil.getPlayerLandsInPlay(p); lands = CardListUtil.filter(lands, new Predicate() { @Override public boolean apply(final Card c) { diff --git a/src/main/java/forge/NameChanger.java b/src/main/java/forge/NameChanger.java index e58fc68ac73..00040fb53dc 100644 --- a/src/main/java/forge/NameChanger.java +++ b/src/main/java/forge/NameChanger.java @@ -19,6 +19,8 @@ package forge; import java.io.BufferedReader; import java.io.FileReader; +import java.util.ArrayList; +import java.util.List; import java.util.Map; import java.util.Map.Entry; import java.util.StringTokenizer; @@ -154,9 +156,9 @@ public class NameChanger { * @return either list itself or a new list (possibly wasteful) containing * the side effected cards */ - public final CardList changeCardsIfNeeded(CardList list) { + public final List changeCardsIfNeeded(List list) { if (this.shouldChangeCardName()) { - list = new CardList( Lists.transform(list, fnTransformCard) ); + list = new ArrayList( Lists.transform(list, fnTransformCard) ); } return list; } diff --git a/src/main/java/forge/StaticEffect.java b/src/main/java/forge/StaticEffect.java index 2a6ffdd719f..4a18fe8e58c 100644 --- a/src/main/java/forge/StaticEffect.java +++ b/src/main/java/forge/StaticEffect.java @@ -19,6 +19,7 @@ package forge; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import forge.card.spellability.SpellAbility; import forge.game.player.Player; @@ -34,7 +35,7 @@ import forge.game.player.Player; public class StaticEffect { private Card source = new Card(); private int keywordNumber = 0; - private CardList affectedCards = new CardList(); + private List affectedCards = new ArrayList(); private ArrayList affectedPlayers = new ArrayList(); private int xValue = 0; private int yValue = 0; @@ -739,7 +740,7 @@ public class StaticEffect { * * @return a {@link forge.CardList} object. */ - public final CardList getAffectedCards() { + public final List getAffectedCards() { return this.affectedCards; } @@ -751,7 +752,7 @@ public class StaticEffect { * @param list * a {@link forge.CardList} object. */ - public final void setAffectedCards(final CardList list) { + public final void setAffectedCards(final List list) { this.affectedCards = list; } diff --git a/src/main/java/forge/StaticEffects.java b/src/main/java/forge/StaticEffects.java index dc932c99933..f60137383e8 100644 --- a/src/main/java/forge/StaticEffects.java +++ b/src/main/java/forge/StaticEffects.java @@ -20,6 +20,7 @@ package forge; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.List; import com.esotericsoftware.minlog.Log; @@ -75,7 +76,7 @@ public class StaticEffects { * a StaticEffect */ final void removeStaticEffect(final StaticEffect se) { - final CardList affectedCards = se.getAffectedCards(); + final List affectedCards = se.getAffectedCards(); final ArrayList affectedPlayers = se.getAffectedPlayers(); final HashMap params = se.getParams(); @@ -317,7 +318,7 @@ public class StaticEffects { public final void rePopulateStateBasedList() { this.reset(); - final CardList cards = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List cards = AllZoneUtil.getCardsIn(ZoneType.Battlefield); Log.debug("== Start add state effects =="); for (int i = 0; i < cards.size(); i++) { diff --git a/src/main/java/forge/card/DeckHints.java b/src/main/java/forge/card/DeckHints.java index 2e47372f1ee..206f5e157a4 100644 --- a/src/main/java/forge/card/DeckHints.java +++ b/src/main/java/forge/card/DeckHints.java @@ -63,12 +63,12 @@ public class DeckHints { } /** - * Returns a list of Cards from the given CardList that match this + * Returns a list of Cards from the given List that match this * DeckHints. I.e., other cards that this Card needs in its deck. * * @param cardList * list of cards to be filtered - * @return CardList of Cards that match this DeckHints. + * @return List of Cards that match this DeckHints. */ public List filter(Iterable cardList) { List ret; diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactory.java b/src/main/java/forge/card/abilityfactory/AbilityFactory.java index 64a6bb011eb..ed91d2def49 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactory.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactory.java @@ -19,11 +19,12 @@ package forge.card.abilityfactory; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardUtil; import forge.Command; @@ -1627,7 +1628,7 @@ public class AbilityFactory { * multiplier; } else if (calcX[0].startsWith("Remembered")) { // Add whole Remembered list to handlePaid - final CardList list = new CardList(); + final List list = new ArrayList(); if (card.getRemembered().isEmpty()) { final Card newCard = AllZoneUtil.getCardState(card); for (final Object o : newCard.getRemembered()) { @@ -1654,7 +1655,7 @@ public class AbilityFactory { return CardFactoryUtil.handlePaid(list, calcX[1], card) * multiplier; } else if (calcX[0].startsWith("Imprinted")) { // Add whole Imprinted list to handlePaid - final CardList list = new CardList(); + final List list = new ArrayList(); for (final Card c : card.getImprinted()) { list.add(AllZoneUtil.getCardState(c)); } @@ -1662,7 +1663,7 @@ public class AbilityFactory { return CardFactoryUtil.handlePaid(list, calcX[1], card) * multiplier; } else if (calcX[0].matches("Enchanted")) { // Add whole Enchanted list to handlePaid - final CardList list = new CardList(); + final List list = new ArrayList(); if (card.isEnchanting()) { Object o = card.getEnchanting(); if (o instanceof Card) { @@ -1722,7 +1723,7 @@ public class AbilityFactory { } */ - CardList list = new CardList(); + List list = new ArrayList(); if (calcX[0].startsWith("Sacrificed")) { list = AbilityFactory.findRootAbility(ability).getPaidList("Sacrificed"); } else if (calcX[0].startsWith("Discarded")) { @@ -1743,14 +1744,14 @@ public class AbilityFactory { final ArrayList all = t.getTargets(); if (!all.isEmpty() && (all.get(0) instanceof SpellAbility)) { final SpellAbility saTargeting = AbilityFactory.findParentsTargetedSpellAbility(ability); - list = new CardList(); + list = new ArrayList(); final ArrayList sas = saTargeting.getTarget().getTargetSAs(); for (final SpellAbility sa : sas) { list.add(sa.getSourceCard()); } } else { final SpellAbility saTargeting = AbilityFactory.findParentsTargetedCard(ability); - list = new CardList(saTargeting.getTarget().getTargetCards()); + list = new ArrayList(saTargeting.getTarget().getTargetCards()); } } else { final SpellAbility parent = AbilityFactory.findParentsTargetedCard(ability); @@ -1758,20 +1759,20 @@ public class AbilityFactory { if (parent != null) { final ArrayList all = parent.getTarget().getTargets(); if (!all.isEmpty() && (all.get(0) instanceof SpellAbility)) { - list = new CardList(); + list = new ArrayList(); final ArrayList sas = parent.getTarget().getTargetSAs(); for (final SpellAbility sa : sas) { list.add(sa.getSourceCard()); } } else { final SpellAbility saTargeting = AbilityFactory.findParentsTargetedCard(ability); - list = new CardList(saTargeting.getTarget().getTargetCards()); + list = new ArrayList(saTargeting.getTarget().getTargetCards()); } } } } else if (calcX[0].startsWith("Triggered")) { final SpellAbility root = ability.getRootSpellAbility(); - list = new CardList(); + list = new ArrayList(); list.add((Card) root.getTriggeringObject(calcX[0].substring(9))); } else if (calcX[0].startsWith("TriggerCount")) { // TriggerCount is similar to a regular Count, but just @@ -1784,7 +1785,7 @@ public class AbilityFactory { return CardFactoryUtil.doXMath(count, m, card) * multiplier; } else if (calcX[0].startsWith("Replaced")) { final SpellAbility root = ability.getRootSpellAbility(); - list = new CardList(); + list = new ArrayList(); list.add((Card) root.getReplacingObject(calcX[0].substring(8))); } else if (calcX[0].startsWith("ReplaceCount")) { // ReplaceCount is similar to a regular Count, but just @@ -1852,6 +1853,7 @@ public class AbilityFactory { * a {@link forge.card.spellability.SpellAbility} object. * @return a {@link java.util.ArrayList} object. */ + @SuppressWarnings("unchecked") public static ArrayList getDefinedCards(final Card hostCard, final String def, final SpellAbility sa) { final ArrayList cards = new ArrayList(); final String defined = (def == null) ? "Self" : def; // default to Self @@ -1886,7 +1888,7 @@ public class AbilityFactory { } else if (defined.equals("TopOfLibrary")) { - final CardList lib = hostCard.getController().getCardsIn(ZoneType.Library); + final List lib = hostCard.getController().getCardsIn(ZoneType.Library); if (lib.size() > 0) { c = lib.get(0); } else { @@ -1915,8 +1917,8 @@ public class AbilityFactory { if (crd instanceof Card) { c = AllZoneUtil.getCardState((Card) crd); c = (Card) crd; - } else if (crd instanceof CardList) { - for (final Card cardItem : (CardList) crd) { + } else if (crd instanceof List) { + for (final Card cardItem : (List) crd) { cards.add(cardItem); } } @@ -1926,8 +1928,8 @@ public class AbilityFactory { final Object crd = root.getReplacingObject(defined.substring(8)); if (crd instanceof Card) { c = AllZoneUtil.getCardState((Card) crd); - } else if (crd instanceof CardList) { - for (final Card cardItem : (CardList) crd) { + } else if (crd instanceof List) { + for (final Card cardItem : (List) crd) { cards.add(cardItem); } } @@ -1971,7 +1973,7 @@ public class AbilityFactory { cards.add(cl); } } else { - CardList list = null; + List list = null; if (defined.startsWith("Sacrificed")) { list = AbilityFactory.findRootAbility(sa).getPaidList("Sacrificed"); } @@ -2472,7 +2474,7 @@ public class AbilityFactory { if (threatParams.containsKey("Defined")) { objects = AbilityFactory.getDefinedObjects(source, threatParams.get("Defined"), topStack); } else if (threatParams.containsKey("ValidCards")) { - CardList cards = CardListUtil.getValidCards(AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield), threatParams.get("ValidCards").split(","), source.getController(), source); + List cards = CardListUtil.getValidCards(AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield), threatParams.get("ValidCards").split(","), source.getController(), source); for (Card card : cards) { objects.add(card); } @@ -2644,7 +2646,7 @@ public class AbilityFactory { if (params.containsKey("RememberCostCards")) { if (params.get("Cost").contains("Exile")) { - final CardList paidListExiled = sa.getPaidList("Exiled"); + final List paidListExiled = sa.getPaidList("Exiled"); for (final Card exiledAsCost : paidListExiled) { host.addRemembered(exiledAsCost); } @@ -2663,7 +2665,7 @@ public class AbilityFactory { * a SpellAbility * @return a {@link forge.CardList} object. */ - public static CardList filterListByType(final CardList list, String type, final SpellAbility sa) { + public static List filterListByType(final List list, String type, final SpellAbility sa) { if (type == null) { return list; } @@ -2685,7 +2687,7 @@ public class AbilityFactory { } if (!(o instanceof Card)) { - return new CardList(); + return new ArrayList(); } if (type.equals("Triggered") || (type.equals("TriggeredCard")) || (type.equals("TriggeredAttacker")) || (type.equals("TriggeredBlocker"))) { @@ -2716,7 +2718,7 @@ public class AbilityFactory { } } if (source == null) { - return new CardList(); + return new ArrayList(); } if (type.startsWith("TargetedCard")) { @@ -2737,7 +2739,7 @@ public class AbilityFactory { } if (!hasRememberedCard) { - return new CardList(); + return new ArrayList(); } } else if (type.equals("Card.AttachedBy")) { source = source.getEnchantingCard(); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryAnimate.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryAnimate.java index 30171c88c0e..eb6615a3f60 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryAnimate.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryAnimate.java @@ -28,7 +28,7 @@ import com.google.common.collect.Iterables; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.CardUtil; @@ -1282,7 +1282,7 @@ public final class AbilityFactoryAnimate { valid = params.get("ValidCards"); } - CardList list; + List list; ArrayList tgtPlayers = null; final Target tgt = sa.getTarget(); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java index 06297179f13..8f7369a52ed 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java @@ -20,6 +20,7 @@ package forge.card.abilityfactory; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; import java.util.Random; @@ -29,7 +30,7 @@ import com.google.common.base.Predicates; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.CardPredicates.Presets; @@ -347,7 +348,7 @@ public class AbilityFactoryAttach { return null; } - CardList list = AllZoneUtil.getCardsIn(tgt.getZone()); + List list = AllZoneUtil.getCardsIn(tgt.getZone()); list = CardListUtil.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), attachSource); if (params.containsKey("AITgts")) { list = CardListUtil.getValidCards(list, params.get("AITgts"), sa.getActivatingPlayer(), attachSource); @@ -392,7 +393,7 @@ public class AbilityFactoryAttach { * the logic * @return the card */ - public static Card attachGeneralAI(final SpellAbility sa, final CardList list, final boolean mandatory, + public static Card attachGeneralAI(final SpellAbility sa, final List list, final boolean mandatory, final Card attachSource, final String logic) { Player prefPlayer = AllZone.getHumanPlayer(); if ("Pump".equals(logic) || "Animate".equals(logic) ) { @@ -400,7 +401,7 @@ public class AbilityFactoryAttach { } // Some ChangeType cards are beneficial, and PrefPlayer should be // changed to represent that - final CardList prefList = CardListUtil.filterControlledBy(list, prefPlayer); + final List prefList = CardListUtil.filterControlledBy(list, prefPlayer); // If there are no preferred cards, and not mandatory bail out if (prefList.size() == 0) { @@ -436,7 +437,7 @@ public class AbilityFactoryAttach { * the list * @return the card */ - public static Card chooseUnpreferred(final boolean mandatory, final CardList list) { + public static Card chooseUnpreferred(final boolean mandatory, final List list) { if (!mandatory) { return null; } @@ -453,7 +454,7 @@ public class AbilityFactoryAttach { * the list * @return the card */ - public static Card chooseLessPreferred(final boolean mandatory, final CardList list) { + public static Card chooseLessPreferred(final boolean mandatory, final List list) { if (!mandatory) { return null; } @@ -499,10 +500,10 @@ public class AbilityFactoryAttach { * the attach source * @return the card */ - public static Card attachAIAnimatePreference(final SpellAbility sa, final CardList list, final boolean mandatory, + public static Card attachAIAnimatePreference(final SpellAbility sa, final List list, final boolean mandatory, final Card attachSource) { // AI For choosing a Card to Animate. - CardList betterList = CardListUtil.getNotType(list, "Creature"); + List betterList = CardListUtil.getNotType(list, "Creature"); if (sa.getSourceCard().getName().equals("Animate Artifact")) { betterList = CardListUtil.filter(betterList, new Predicate() { @Override @@ -537,7 +538,7 @@ public class AbilityFactoryAttach { * the attach source * @return the card */ - public static Card attachAIControlPreference(final SpellAbility sa, final CardList list, final boolean mandatory, + public static Card attachAIControlPreference(final SpellAbility sa, final List list, final boolean mandatory, final Card attachSource) { // AI For choosing a Card to Gain Control of. @@ -688,11 +689,11 @@ public class AbilityFactoryAttach { * the attach source * @return the card */ - public static Card attachAIPumpPreference(final SpellAbility sa, final CardList list, final boolean mandatory, + public static Card attachAIPumpPreference(final SpellAbility sa, final List list, final boolean mandatory, final Card attachSource) { // AI For choosing a Card to Pump Card c = null; - CardList magnetList = null; + List magnetList = null; String stCheck = null; if (attachSource.isAura()) { stCheck = "EnchantedBy"; @@ -769,7 +770,7 @@ public class AbilityFactoryAttach { } } - CardList prefList = new CardList(list); + List prefList = new ArrayList(list); if (totToughness < 0) { // Don't kill my own stuff with Negative toughness Auras final int tgh = totToughness; @@ -841,7 +842,7 @@ public class AbilityFactoryAttach { * the attach source * @return the card */ - public static Card attachAICursePreference(final SpellAbility sa, final CardList list, final boolean mandatory, + public static Card attachAICursePreference(final SpellAbility sa, final List list, final boolean mandatory, final Card attachSource) { // AI For choosing a Card to Curse of. @@ -887,7 +888,7 @@ public class AbilityFactoryAttach { } } - CardList prefList = null; + List prefList = null; if (totToughness < 0) { // Kill a creature if we can final int tgh = totToughness; @@ -904,7 +905,7 @@ public class AbilityFactoryAttach { } Card c = null; if ((prefList == null) || (prefList.size() == 0)) { - prefList = new CardList(list); + prefList = new ArrayList(list); } else { c = CardFactoryUtil.getBestAI(prefList); if (c != null) { @@ -948,7 +949,7 @@ public class AbilityFactoryAttach { * the attach source * @return the card */ - public static Card attachAIChangeTypePreference(final SpellAbility sa, CardList list, final boolean mandatory, + public static Card attachAIChangeTypePreference(final SpellAbility sa, List list, final boolean mandatory, final Card attachSource) { // AI For Cards like Evil Presence or Spreading Seas @@ -992,10 +993,10 @@ public class AbilityFactoryAttach { * the attach source * @return the card */ - public static Card attachAIKeepTappedPreference(final SpellAbility sa, final CardList list, + public static Card attachAIKeepTappedPreference(final SpellAbility sa, final List list, final boolean mandatory, final Card attachSource) { // AI For Cards like Paralyzing Grasp and Glimmerdust Nap - final CardList prefList = CardListUtil.filter(list, new Predicate() { + final List prefList = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { // Don't do Untapped Vigilance cards @@ -1417,7 +1418,7 @@ public class AbilityFactoryAttach { return true; } } else { - CardList list = AllZoneUtil.getCardsIn(tgt.getZone()); + List list = AllZoneUtil.getCardsIn(tgt.getZone()); list = CardListUtil.getValidCards(list, tgt.getValidTgts(), aura.getActivatingPlayer(), source); final Object o = GuiChoose.one(source + " - Select a card to attach to.", list); @@ -1710,7 +1711,7 @@ public class AbilityFactoryAttach { // If Cast Targets will be checked on the Stack for (final Object o : targets) { String valid = params.get("UnattachValid"); - CardList unattachList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List unattachList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); unattachList = CardListUtil.getValidCards(unattachList, valid.split(","), source.getController(), source); for (final Card c : unattachList) { AbilityFactoryAttach.handleUnattachment(o, c, af); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryBond.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryBond.java index 69f94bde258..86d3bcaa7b1 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryBond.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryBond.java @@ -19,9 +19,11 @@ package forge.card.abilityfactory; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; + import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.card.spellability.AbilityActivated; import forge.card.spellability.AbilitySub; import forge.card.spellability.SpellAbility; @@ -322,7 +324,7 @@ public final class AbilityFactoryBond { } // find list of valid cards to pair with - CardList cards = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List cards = AllZoneUtil.getCardsIn(ZoneType.Battlefield); cards = AbilityFactory.filterListByType(cards, params.get("ValidCards"), sa); if (cards.isEmpty()) { return; diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java index c0b8cd217fd..34d93b5c544 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java @@ -30,7 +30,7 @@ import forge.AllZone; import forge.AllZoneUtil; import forge.Card; import forge.CardCharacteristicName; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.CardPredicates.Presets; @@ -499,7 +499,7 @@ public final class AbilityFactoryChangeZone { //Ninjutsu if (params.containsKey("Ninjutsu")) { if (source.isType("Legendary") && !AllZoneUtil.isCardInPlay("Mirror Gallery")) { - final CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + final List list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); if (Iterables.any(list, CardPredicates.nameEquals(source.getName()))) { return false; } @@ -507,7 +507,7 @@ public final class AbilityFactoryChangeZone { if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isAfter(PhaseType.COMBAT_DAMAGE)) { return false; } - CardList attackers = new CardList(); + List attackers = new ArrayList(); attackers.addAll(AllZone.getCombat().getUnblockedAttackers()); boolean lowerCMC = false; for (Card attacker : attackers) { @@ -566,7 +566,7 @@ public final class AbilityFactoryChangeZone { } for (final Player p : pDefined) { - CardList list = p.getCardsIn(origin); + List list = p.getCardsIn(origin); if ((type != null) && p.isComputer()) { // AI only "knows" about his information @@ -696,7 +696,7 @@ public final class AbilityFactoryChangeZone { } for (final Player p : pDefined) { - CardList list = p.getCardsIn(origin); + List list = p.getCardsIn(origin); // Computer should "know" his deck if (p.isComputer()) { @@ -899,7 +899,7 @@ public final class AbilityFactoryChangeZone { private static void changeHiddenOriginResolveHuman(final AbilityFactory af, final SpellAbility sa, Player player) { final HashMap params = af.getMapParams(); final Card card = sa.getSourceCard(); - final CardList reveal = new CardList(); + final List reveal = new ArrayList(); final boolean defined = params.containsKey("Defined"); final Target tgt = sa.getTarget(); @@ -923,7 +923,7 @@ public final class AbilityFactoryChangeZone { // Currently only used for Mishra, but may be used by other things // Improve how this message reacts for other cards final List alt = ZoneType.listValueOf(params.get("OriginAlternative")); - CardList altFetchList = player.getCardsIn(alt); + List altFetchList = player.getCardsIn(alt); altFetchList = AbilityFactory.filterListByType(altFetchList, params.get("ChangeType"), sa); final StringBuilder sb = new StringBuilder(); @@ -950,9 +950,9 @@ public final class AbilityFactoryChangeZone { int changeNum = params.containsKey("ChangeNum") ? AbilityFactory.calculateAmount(card, params.get("ChangeNum"), sa) : 1; - CardList fetchList; + List fetchList; if (defined) { - fetchList = new CardList(AbilityFactory.getDefinedCards(card, params.get("Defined"), sa)); + fetchList = new ArrayList(AbilityFactory.getDefinedCards(card, params.get("Defined"), sa)); if (!params.containsKey("ChangeNum")) { changeNum = fetchList.size(); } @@ -1133,9 +1133,9 @@ public final class AbilityFactoryChangeZone { int changeNum = params.containsKey("ChangeNum") ? AbilityFactory.calculateAmount(card, params.get("ChangeNum"), sa) : 1; - CardList fetchList; + List fetchList; if (defined) { - fetchList = new CardList(AbilityFactory.getDefinedCards(card, params.get("Defined"), sa)); + fetchList = new ArrayList(AbilityFactory.getDefinedCards(card, params.get("Defined"), sa)); if (!params.containsKey("ChangeNum")) { changeNum = fetchList.size(); } @@ -1149,7 +1149,7 @@ public final class AbilityFactoryChangeZone { } final ZoneType destination = ZoneType.smartValueOf(params.get("Destination")); - final CardList fetched = new CardList(); + final List fetched = new ArrayList(); final String remember = params.get("RememberChanged"); final String forget = params.get("ForgetChanged"); final String imprint = params.get("Imprint"); @@ -1213,13 +1213,13 @@ public final class AbilityFactoryChangeZone { c = CardFactoryUtil.getBestAI(fetchList); } else { // Don't fetch another tutor with the same name - CardList sameNamed = CardListUtil.filter(fetchList, Predicates.not(CardPredicates.nameEquals(card.getName()))); + List sameNamed = CardListUtil.filter(fetchList, Predicates.not(CardPredicates.nameEquals(card.getName()))); if (origin.contains(ZoneType.Library) && !sameNamed.isEmpty()) { fetchList = sameNamed; } Player ai = AllZone.getComputerPlayer(); // Does AI need a land? - CardList hand = ai.getCardsIn(ZoneType.Hand); + List hand = ai.getCardsIn(ZoneType.Hand); System.out.println("Lands in hand = " + CardListUtil.filter(hand, Presets.LANDS).size() + ", on battlefield = " + CardListUtil.filter(ai.getCardsIn(ZoneType.Battlefield), Presets.LANDS).size()); if (CardListUtil.filter(hand, Presets.LANDS).size() == 0 && CardListUtil.filter(ai.getCardsIn(ZoneType.Battlefield), Presets.LANDS).size() < 4) { boolean canCastSomething = false; @@ -1355,10 +1355,10 @@ public final class AbilityFactoryChangeZone { * a {@link forge.CardList} object. * @return a {@link forge.Card} object. */ - private static Card basicManaFixing(final CardList list) { // Search for a + private static Card basicManaFixing(final List list) { // Search for a // Basic Land - final CardList combined = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + final List combined = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); combined.addAll(AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand)); final ArrayList basics = new ArrayList(); @@ -1426,11 +1426,11 @@ public final class AbilityFactoryChangeZone { * @param list * @return Card */ - private static Card chooseCreature(CardList list) { + private static Card chooseCreature(List list) { Card card = null; Combat combat = new Combat(); combat.initiatePossibleDefenders(AllZone.getComputerPlayer()); - CardList attackers = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + List attackers = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); for (Card att : attackers) { combat.addAttacker(att); } @@ -1510,7 +1510,7 @@ public final class AbilityFactoryChangeZone { } } else { // non-targeted retrieval - final CardList retrieval = AbilityFactoryChangeZone + final List retrieval = AbilityFactoryChangeZone .knownDetermineDefined(sa, params.get("Defined"), origin); if ((retrieval == null) || retrieval.isEmpty()) { @@ -1634,7 +1634,7 @@ public final class AbilityFactoryChangeZone { tgt.resetTargets(); } - CardList list = AllZoneUtil.getCardsIn(origin); + List list = AllZoneUtil.getCardsIn(origin); list = CardListUtil.getValidCards(list, tgt.getValidTgts(), AllZone.getComputerPlayer(), source); if (source.isInZone(ZoneType.Hand)) { list = CardListUtil.filter(list, Predicates.not(CardPredicates.nameEquals(source.getName()))); // Don't get the same card back. @@ -1648,7 +1648,7 @@ public final class AbilityFactoryChangeZone { if (origin.equals(ZoneType.Battlefield)) { // filter out untargetables list = CardListUtil.getTargetableCards(list, sa); - CardList aiPermanents = CardListUtil.filterControlledBy(list, AllZone.getComputerPlayer()); + List aiPermanents = CardListUtil.filterControlledBy(list, AllZone.getComputerPlayer()); // Don't blink cards that will die. aiPermanents = CardListUtil.filter(aiPermanents, new Predicate() { @@ -1668,7 +1668,7 @@ public final class AbilityFactoryChangeZone { if (AllZone.getStack().size() > 0) { final ArrayList objects = AbilityFactory.predictThreatenedObjects(af); - final CardList threatenedTargets = new CardList(); + final List threatenedTargets = new ArrayList(); for (final Card c : aiPermanents) { if (objects.contains(c)) { @@ -1684,7 +1684,7 @@ public final class AbilityFactoryChangeZone { } // Save combatants else if (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) { - final CardList combatants = CardListUtil.filter(aiPermanents, CardPredicates.Presets.CREATURES); + final List combatants = CardListUtil.filter(aiPermanents, CardPredicates.Presets.CREATURES); CardListUtil.sortByEvaluateCreature(combatants); for (final Card c : combatants) { @@ -1791,7 +1791,7 @@ public final class AbilityFactoryChangeZone { choice = mostExpensive; } } else if (destination.equals(ZoneType.Hand) || destination.equals(ZoneType.Library)) { - CardList nonLands = CardListUtil.getNotType(list, "Land"); + List nonLands = CardListUtil.getNotType(list, "Land"); // Prefer to pull a creature, generally more useful for AI. choice = chooseCreature(CardListUtil.filter(nonLands, CardPredicates.Presets.CREATURES)); if (choice == null) { // Could not find a creature. @@ -1866,7 +1866,7 @@ public final class AbilityFactoryChangeZone { final ZoneType destination = ZoneType.smartValueOf(params.get("Destination")); final Target tgt = sa.getTarget(); - CardList list = AllZoneUtil.getCardsIn(origin); + List list = AllZoneUtil.getCardsIn(origin); list = CardListUtil.getValidCards(list, tgt.getValidTgts(), AllZone.getComputerPlayer(), source); // Narrow down the list: @@ -1904,7 +1904,7 @@ public final class AbilityFactoryChangeZone { } else if (destination.equals(ZoneType.Battlefield) || origin.equals(ZoneType.Battlefield)) { choice = CardFactoryUtil.getMostExpensivePermanentAI(list, sa, false); } else if (destination.equals(ZoneType.Hand) || destination.equals(ZoneType.Library)) { - CardList nonLands = CardListUtil.getNotType(list, "Land"); + List nonLands = CardListUtil.getNotType(list, "Land"); // Prefer to pull a creature, generally more useful for AI. choice = chooseCreature(CardListUtil.filter(nonLands, CardPredicates.Presets.CREATURES)); if (choice == null) { // Could not find a creature. @@ -2312,8 +2312,8 @@ public final class AbilityFactoryChangeZone { * a {@link java.lang.String} object. * @return a {@link forge.CardList} object. */ - private static CardList knownDetermineDefined(final SpellAbility sa, final String defined, final ZoneType origin) { - final CardList ret = new CardList(); + private static List knownDetermineDefined(final SpellAbility sa, final String defined, final ZoneType origin) { + final List ret = new ArrayList(); final ArrayList list = AbilityFactory.getDefinedCards(sa.getSourceCard(), defined, sa); for (final Card c : list) { @@ -2574,9 +2574,9 @@ public final class AbilityFactoryChangeZone { // ex. "Return all Auras attached to target" // ex. "Return all blocking/blocked by target creature" - CardList humanType = AllZone.getHumanPlayer().getCardsIn(origin); + List humanType = AllZone.getHumanPlayer().getCardsIn(origin); humanType = AbilityFactory.filterListByType(humanType, params.get("ChangeType"), sa); - CardList computerType = AllZone.getComputerPlayer().getCardsIn(origin); + List computerType = AllZone.getComputerPlayer().getCardsIn(origin); computerType = AbilityFactory.filterListByType(computerType, params.get("ChangeType"), sa); final Target tgt = sa.getTarget(); @@ -2739,9 +2739,9 @@ public final class AbilityFactoryChangeZone { final ZoneType destination = ZoneType.smartValueOf(params.get("Destination")); final ZoneType origin = ZoneType.smartValueOf(params.get("Origin")); - CardList humanType = AllZone.getHumanPlayer().getCardsIn(origin); + List humanType = AllZone.getHumanPlayer().getCardsIn(origin); humanType = AbilityFactory.filterListByType(humanType, params.get("ChangeType"), sa); - CardList computerType = AllZone.getComputerPlayer().getCardsIn(origin); + List computerType = AllZone.getComputerPlayer().getCardsIn(origin); computerType = AbilityFactory.filterListByType(computerType, params.get("ChangeType"), sa); // TODO improve restrictions on when the AI would want to use this @@ -2885,7 +2885,7 @@ public final class AbilityFactoryChangeZone { final ZoneType destination = ZoneType.smartValueOf(params.get("Destination")); final List origin = ZoneType.listValueOf(params.get("Origin")); - CardList cards = null; + List cards = null; ArrayList tgtPlayers = null; diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java index d0ff1360590..0fc5310ec2d 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java @@ -33,7 +33,7 @@ import com.google.common.collect.HashBiMap; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.CardPredicates.Presets; @@ -733,7 +733,7 @@ public final class AbilityFactoryChoose { chosen = CardFactoryUtil.getMostProminentColor(AllZoneUtil.getCardsInGame()); } else if (logic.equals("MostProminentHumanCreatures")) { - CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + List list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); if (list.isEmpty()) { list = CardListUtil.filter(CardListUtil.filterControlledBy(AllZoneUtil.getCardsInGame(), AllZone.getHumanPlayer()), CardPredicates.Presets.CREATURES); } @@ -744,7 +744,7 @@ public final class AbilityFactoryChoose { ZoneType.Battlefield)); } else if (logic.equals("MostProminentPermanent")) { - final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); chosen = CardFactoryUtil.getMostProminentColor(list); } else if (logic.equals("MostProminentAttackers")) { @@ -1640,7 +1640,7 @@ public final class AbilityFactoryChoose { .getCardsIn(ZoneType.Library)); } } else { - CardList list = CardListUtil.filterControlledBy(AllZoneUtil.getCardsInGame(), AllZone.getHumanPlayer()); + List list = CardListUtil.filterControlledBy(AllZoneUtil.getCardsInGame(), AllZone.getHumanPlayer()); list = CardListUtil.filter(list, Predicates.not(Presets.LANDS)); if (!list.isEmpty()) { chosen = list.get(0).getName(); @@ -1866,7 +1866,7 @@ public final class AbilityFactoryChoose { if (params.containsKey("ChoiceZone")) { choiceZone = ZoneType.smartValueOf(params.get("ChoiceZone")); } - CardList choices = AllZoneUtil.getCardsIn(choiceZone); + List choices = AllZoneUtil.getCardsIn(choiceZone); if (params.containsKey("Choices")) { choices = CardListUtil.getValidCards(choices, params.get("Choices"), host.getController(), host); } @@ -1932,7 +1932,7 @@ public final class AbilityFactoryChoose { if (params.containsKey("ChoiceZone")) { choiceZone = ZoneType.smartValueOf(params.get("ChoiceZone")); } - CardList choices = AllZoneUtil.getCardsIn(choiceZone); + List choices = AllZoneUtil.getCardsIn(choiceZone); if (params.containsKey("Choices")) { choices = CardListUtil.getValidCards(choices, params.get("Choices"), host.getController(), host); } @@ -1942,11 +1942,11 @@ public final class AbilityFactoryChoose { ? CardFactoryUtil.xCount(host, host.getSVar(params.get("Amount"))) : Integer.parseInt(numericAmount); if (params.containsKey("SunderingTitan")) { - final CardList land = AllZoneUtil.getLandsInPlay(); + final List land = AllZoneUtil.getLandsInPlay(); final ArrayList basic = CardUtil.getBasicTypes(); for (final String type : basic) { - final CardList cl = CardListUtil.getType(land, type); + final List cl = CardListUtil.getType(land, type); if (cl.size() > 0) { final String prompt = "Choose a" + (type.equals("Island") ? "n " : " ") + type; final Object o = GuiChoose.one(prompt, cl); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryClash.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryClash.java index cd3df97ff50..331ad537f00 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryClash.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryClash.java @@ -25,7 +25,7 @@ import javax.swing.JOptionPane; import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.GameActionUtil; import forge.card.cardfactory.CardFactoryUtil; @@ -703,9 +703,9 @@ public final class AbilityFactoryClash { } final Player p = tgtPlayers.get(0); - CardList pool = new CardList(); + List pool = new ArrayList(); if (params.containsKey("DefinedCards")) { - pool = new CardList(AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("DefinedCards"), sa)); + pool = new ArrayList(AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("DefinedCards"), sa)); } else { pool = p.getCardsIn(zone); } @@ -756,9 +756,9 @@ public final class AbilityFactoryClash { if ((tgt == null) || p.canBeTargetedBy(sa)) { final ArrayList pile1 = new ArrayList(); final ArrayList pile2 = new ArrayList(); - CardList pool = new CardList(); + List pool = new ArrayList(); if (params.containsKey("DefinedCards")) { - pool = new CardList(AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("DefinedCards"), sa)); + pool = new ArrayList(AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("DefinedCards"), sa)); } else { pool = p.getCardsIn(zone); } @@ -845,7 +845,7 @@ public final class AbilityFactoryClash { } // end twoPiles resolve private static boolean selectPiles(final HashMap params, final SpellAbility sa, ArrayList pile1, ArrayList pile2, - Player chooser, Card card, CardList pool) { + Player chooser, Card card, List pool) { boolean pile1WasChosen = true; // then, the chooser picks a pile @@ -899,11 +899,11 @@ public final class AbilityFactoryClash { break; } } else { - int cmc1 = CardFactoryUtil.evaluatePermanentList(new CardList(pile1)); - int cmc2 = CardFactoryUtil.evaluatePermanentList(new CardList(pile2)); + int cmc1 = CardFactoryUtil.evaluatePermanentList(new ArrayList(pile1)); + int cmc2 = CardFactoryUtil.evaluatePermanentList(new ArrayList(pile2)); if (CardListUtil.getNotType(pool, "Creature").isEmpty()) { - cmc1 = CardFactoryUtil.evaluateCreatureList(new CardList(pile1)); - cmc2 = CardFactoryUtil.evaluateCreatureList(new CardList(pile2)); + cmc1 = CardFactoryUtil.evaluateCreatureList(new ArrayList(pile1)); + cmc2 = CardFactoryUtil.evaluateCreatureList(new ArrayList(pile2)); System.out.println("value:" + cmc1 + " " + cmc2); } diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryClone.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryClone.java index 21f0f508fd5..8e5fc50776c 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryClone.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryClone.java @@ -257,7 +257,7 @@ public final class AbilityFactoryClone { boolean useAbility = true; // if (card.getController().isComputer()) { -// final CardList creatures = AllZoneUtil.getCreaturesInPlay(); +// final List creatures = AllZoneUtil.getCreaturesInPlay(); // if (!creatures.isEmpty()) { // cardToCopy = CardFactoryUtil.getBestCreatureAI(creatures); // } diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryCombat.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryCombat.java index 1a43e421668..ff9b523466c 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryCombat.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryCombat.java @@ -19,12 +19,13 @@ package forge.card.abilityfactory; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import com.google.common.base.Predicate; import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.Singletons; @@ -1061,7 +1062,7 @@ public final class AbilityFactoryCombat { boolean chance = false; if (abTgt != null) { - CardList list = CardListUtil.filter(AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES); + List list = CardListUtil.filter(AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES); list = CardListUtil.getTargetableCards(list, sa); list = CardListUtil.getValidCards(list, abTgt.getValidTgts(), source.getController(), source); list = CardListUtil.filter(list, new Predicate() { diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryCopy.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryCopy.java index 912a6ddc178..623ba2eb40d 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryCopy.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryCopy.java @@ -21,13 +21,14 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Random; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; import forge.CardCharacteristicName; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates.Presets; import forge.Command; @@ -306,7 +307,7 @@ public final class AbilityFactoryCopy { final Target abTgt = sa.getTarget(); if (abTgt != null) { - CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = CardListUtil.getValidCards(list, abTgt.getValidTgts(), source.getController(), source); list = CardListUtil.getTargetableCards(list, sa); abTgt.resetTargets(); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryCounters.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryCounters.java index e9f15d466a9..0cafb54975e 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryCounters.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryCounters.java @@ -29,7 +29,7 @@ import com.google.common.base.Predicate; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.Counters; import forge.Singletons; @@ -305,7 +305,7 @@ public class AbilityFactoryCounters { final Cost abCost = sa.getPayCosts(); final Target abTgt = sa.getTarget(); final Card source = sa.getSourceCard(); - CardList list; + List list; Card choice = null; final String type = params.get("CounterType"); final String amountStr = params.get("CounterNum"); @@ -457,7 +457,7 @@ public class AbilityFactoryCounters { boolean chance = true; final Target abTgt = sa.getTarget(); final Card source = sa.getSourceCard(); - CardList list; + List list; Card choice = null; final String type = params.get("CounterType"); final String amountStr = params.get("CounterNum"); @@ -562,7 +562,7 @@ public class AbilityFactoryCounters { final Card source = sa.getSourceCard(); // boolean chance = true; boolean preferred = true; - CardList list; + List list; final Player player = af.isCurse() ? AllZone.getHumanPlayer() : AllZone.getComputerPlayer(); final String type = params.get("CounterType"); final String amountStr = params.get("CounterNum"); @@ -570,7 +570,7 @@ public class AbilityFactoryCounters { if (abTgt == null) { // No target. So must be defined - list = new CardList(AbilityFactory.getDefinedCards(source, params.get("Defined"), sa)); + list = new ArrayList(AbilityFactory.getDefinedCards(source, params.get("Defined"), sa)); if (!mandatory) { // TODO - If Trigger isn't mandatory, when wouldn't we want to @@ -655,11 +655,11 @@ public class AbilityFactoryCounters { * a int. * @return a {@link forge.Card} object. */ - private static Card chooseCursedTarget(final CardList list, final String type, final int amount) { + private static Card chooseCursedTarget(final List list, final String type, final int amount) { Card choice; if (type.equals("M1M1")) { // try to kill the best killable creature, or reduce the best one - final CardList killable = CardListUtil.filter(list, new Predicate() { + final List killable = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { return c.getNetDefense() <= amount; @@ -688,12 +688,12 @@ public class AbilityFactoryCounters { * a {@link java.lang.String} object. * @return a {@link forge.Card} object. */ - private static Card chooseBoonTarget(final CardList list, final String type) { + private static Card chooseBoonTarget(final List list, final String type) { Card choice; if (type.equals("P1P1")) { choice = CardFactoryUtil.getBestCreatureAI(list); } else if (type.equals("DIVINITY")) { - final CardList boon = CardListUtil.filter(list, new Predicate() { + final List boon = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { return c.getCounters(Counters.DIVINITY) == 0; @@ -995,7 +995,7 @@ public class AbilityFactoryCounters { final Cost abCost = sa.getPayCosts(); Target abTgt = sa.getTarget(); final Card source = sa.getSourceCard(); - // CardList list; + // List list; // Card choice = null; final HashMap params = af.getMapParams(); @@ -1075,7 +1075,7 @@ public class AbilityFactoryCounters { // the expected targets could be // Target abTgt = sa.getTarget(); // final Card source = sa.getSourceCard(); - // CardList list; + // List list; // Card choice = null; // HashMap params = af.getMapParams(); @@ -1446,8 +1446,8 @@ public class AbilityFactoryCounters { if (subAb != null && !subAb.chkAIDrawback()) { return false; } - CardList hperms = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); - CardList cperms = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List hperms = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + List cperms = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); cperms = CardListUtil.filter(cperms, new Predicate() { @Override public boolean apply(final Card crd) { @@ -1512,12 +1512,12 @@ public class AbilityFactoryCounters { * a {@link forge.card.spellability.SpellAbility} object. */ private static void proliferateResolve(final AbilityFactory af, final SpellAbility sa) { - CardList hperms = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); - CardList cperms = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List hperms = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + List cperms = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); if (sa.getSourceCard().getController().isHuman()) { cperms.addAll(hperms); - final CardList unchosen = cperms; + final List unchosen = cperms; AllZone.getInputControl().setInput(new Input() { private static final long serialVersionUID = -1779224307654698954L; @@ -1860,8 +1860,8 @@ public class AbilityFactoryCounters { final HashMap params = af.getMapParams(); final Cost abCost = sa.getPayCosts(); final Card source = sa.getSourceCard(); - CardList hList; - CardList cList; + List hList; + List cList; final String type = params.get("CounterType"); final String amountStr = params.get("CounterNum"); final String valid = params.get("ValidCards"); @@ -1919,7 +1919,7 @@ public class AbilityFactoryCounters { if (curse) { if (type.equals("M1M1")) { - final CardList killable = CardListUtil.filter(hList, new Predicate() { + final List killable = CardListUtil.filter(hList, new Predicate() { @Override public boolean apply(final Card c) { return c.getNetDefense() <= amount; @@ -2006,7 +2006,7 @@ public class AbilityFactoryCounters { final String valid = params.get("ValidCards"); final ZoneType zone = params.containsKey("ValidZone") ? ZoneType.smartValueOf(params.get("ValidZone")) : ZoneType.Battlefield; - CardList cards = AllZoneUtil.getCardsIn(zone); + List cards = AllZoneUtil.getCardsIn(zone); cards = CardListUtil.getValidCards(cards, valid, sa.getSourceCard().getController(), sa.getSourceCard()); final Target tgt = sa.getTarget(); @@ -2261,7 +2261,7 @@ public class AbilityFactoryCounters { final String valid = params.get("ValidCards"); final ZoneType zone = params.containsKey("ValidZone") ? ZoneType.smartValueOf(params.get("ValidZone")) : ZoneType.Battlefield; - CardList cards = AllZoneUtil.getCardsIn(zone); + List cards = AllZoneUtil.getCardsIn(zone); cards = CardListUtil.getValidCards(cards, valid, sa.getSourceCard().getController(), sa.getSourceCard()); final Target tgt = sa.getTarget(); @@ -2584,7 +2584,7 @@ public class AbilityFactoryCounters { } } else { // targeted final Player player = af.isCurse() ? AllZone.getHumanPlayer() : AllZone.getComputerPlayer(); - CardList list = player.getCardsIn(ZoneType.Battlefield); + List list = player.getCardsIn(ZoneType.Battlefield); list = CardListUtil.getTargetableCards(list, sa); list = CardListUtil.getValidCards(list, abTgt.getValidTgts(), host.getController(), host); if (list.isEmpty() && mandatory) { diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java index d45bb32eac6..7a453e01227 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java @@ -19,6 +19,7 @@ package forge.card.abilityfactory; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Random; import com.google.common.base.Predicate; @@ -27,7 +28,7 @@ import com.google.common.collect.Iterables; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.CardUtil; @@ -487,7 +488,7 @@ public class AbilityFactoryDealDamage { return false; } - final CardList hand = comp.getCardsIn(ZoneType.Hand); + final List hand = comp.getCardsIn(ZoneType.Hand); if (this.abilityFactory.isSpell()) { // If this is a spell, cast it instead of discarding @@ -526,7 +527,7 @@ public class AbilityFactoryDealDamage { final Target tgt = saMe.getTarget(); final Card source = saMe.getSourceCard(); final HashMap params = this.abilityFactory.getMapParams(); - CardList hPlay = pl.getCardsIn(ZoneType.Battlefield); + List hPlay = pl.getCardsIn(ZoneType.Battlefield); hPlay = CardListUtil.getValidCards(hPlay, tgt.getValidTgts(), AllZone.getComputerPlayer(), source); final ArrayList objects = tgt.getTargets(); @@ -543,7 +544,7 @@ public class AbilityFactoryDealDamage { } hPlay = CardListUtil.getTargetableCards(hPlay, saMe); - final CardList killables = CardListUtil.filter(hPlay, new Predicate() { + final List killables = CardListUtil.filter(hPlay, new Predicate() { @Override public boolean apply(final Card c) { return (c.getEnoughDamageToKill(d, source, false, noPrevention) <= d) && !ComputerUtil.canRegenerate(c) @@ -1164,14 +1165,14 @@ public class AbilityFactoryDealDamage { validP = params.get("ValidPlayers"); } - final CardList humanList = this.getKillableCreatures(af, sa, AllZone.getHumanPlayer(), dmg); - CardList computerList = this.getKillableCreatures(af, sa, AllZone.getComputerPlayer(), dmg); + final List humanList = this.getKillableCreatures(af, sa, AllZone.getHumanPlayer(), dmg); + List computerList = this.getKillableCreatures(af, sa, AllZone.getComputerPlayer(), dmg); final Target tgt = sa.getTarget(); if (tgt != null && sa.canTarget(AllZone.getHumanPlayer())) { tgt.resetTargets(); sa.getTarget().addTarget(AllZone.getHumanPlayer()); - computerList = new CardList(); + computerList = new ArrayList(); } // abCost stuff that should probably be centralized... @@ -1234,7 +1235,7 @@ public class AbilityFactoryDealDamage { * a int. * @return a {@link forge.CardList} object. */ - private CardList getKillableCreatures(final AbilityFactory af, final SpellAbility sa, final Player player, + private List getKillableCreatures(final AbilityFactory af, final SpellAbility sa, final Player player, final int dmg) { final HashMap params = af.getMapParams(); final Card source = af.getHostCard(); @@ -1245,7 +1246,7 @@ public class AbilityFactoryDealDamage { } // TODO: X may be something different than X paid - CardList list = player.getCardsIn(ZoneType.Battlefield); + List list = player.getCardsIn(ZoneType.Battlefield); list = CardListUtil.getValidCards(list, validC.split(","), source.getController(), source); final Predicate filterKillable = new Predicate() { @@ -1319,8 +1320,8 @@ public class AbilityFactoryDealDamage { } // Evaluate creatures getting killed - final CardList humanList = this.getKillableCreatures(af, sa, AllZone.getHumanPlayer(), dmg); - final CardList computerList = this.getKillableCreatures(af, sa, AllZone.getComputerPlayer(), dmg); + final List humanList = this.getKillableCreatures(af, sa, AllZone.getHumanPlayer(), dmg); + final List computerList = this.getKillableCreatures(af, sa, AllZone.getComputerPlayer(), dmg); if ((CardFactoryUtil.evaluateCreatureList(computerList) + 50) >= CardFactoryUtil .evaluateCreatureList(humanList)) { return false; @@ -1364,7 +1365,7 @@ public class AbilityFactoryDealDamage { } String players = ""; - CardList list = new CardList(); + List list = new ArrayList(); if (params.containsKey("ValidPlayers")) { players = params.get("ValidPlayers"); @@ -1635,7 +1636,7 @@ public class AbilityFactoryDealDamage { final HashMap params = af.getMapParams(); final Card card = sa.getSourceCard(); - CardList sources = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List sources = AllZoneUtil.getCardsIn(ZoneType.Battlefield); if (params.containsKey("ValidCards")) { sources = CardListUtil.getValidCards(sources, params.get("ValidCards"), card.getController(), card); } @@ -1878,7 +1879,7 @@ public class AbilityFactoryDealDamage { Target tgt = sa.getTarget(); tgt.resetTargets(); - CardList aiCreatures = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); + List aiCreatures = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); aiCreatures = CardListUtil.getTargetableCards(aiCreatures, sa); aiCreatures = CardListUtil.filter(aiCreatures, new Predicate() { @Override @@ -1887,7 +1888,7 @@ public class AbilityFactoryDealDamage { } }); - CardList humCreatures = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + List humCreatures = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); humCreatures = CardListUtil.getTargetableCards(humCreatures, sa); final Random r = MyRandom.getRandom(); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryDebuff.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryDebuff.java index 80990bf406d..38979cd51fd 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryDebuff.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryDebuff.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Random; import com.google.common.base.Predicate; @@ -28,7 +29,7 @@ import com.google.common.base.Predicate; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.Command; import forge.Singletons; @@ -392,7 +393,7 @@ public final class AbilityFactoryDebuff { final Target tgt = sa.getTarget(); tgt.resetTargets(); - CardList list = AbilityFactoryDebuff.getCurseCreatures(af, sa, kws); + List list = AbilityFactoryDebuff.getCurseCreatures(af, sa, kws); list = CardListUtil.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard()); // several uses here: @@ -445,9 +446,9 @@ public final class AbilityFactoryDebuff { * a {@link java.util.ArrayList} object. * @return a {@link forge.CardList} object. */ - private static CardList getCurseCreatures(final AbilityFactory af, final SpellAbility sa, + private static List getCurseCreatures(final AbilityFactory af, final SpellAbility sa, final ArrayList kws) { - CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + List list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); list = CardListUtil.getTargetableCards(list, sa); if (!list.isEmpty()) { @@ -477,7 +478,7 @@ public final class AbilityFactoryDebuff { * @return a boolean. */ private static boolean debuffMandatoryTarget(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) { - CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); final Target tgt = sa.getTarget(); list = CardListUtil.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard()); @@ -491,8 +492,8 @@ public final class AbilityFactoryDebuff { list.remove(c); } - final CardList pref = CardListUtil.filterControlledBy(list, AllZone.getHumanPlayer()); - final CardList forced = CardListUtil.filterControlledBy(list, AllZone.getComputerPlayer()); + final List pref = CardListUtil.filterControlledBy(list, AllZone.getHumanPlayer()); + final List forced = CardListUtil.filterControlledBy(list, AllZone.getComputerPlayer()); final Card source = sa.getSourceCard(); while (tgt.getNumTargeted() < tgt.getMaxTargets(source, sa)) { @@ -792,9 +793,9 @@ public final class AbilityFactoryDebuff { valid = params.get("ValidCards"); } - CardList comp = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List comp = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); comp = CardListUtil.getValidCards(comp, valid, hostCard.getController(), hostCard); - CardList human = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + List human = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); human = CardListUtil.getValidCards(human, valid, hostCard.getController(), hostCard); // TODO - add blocking situations here also @@ -839,7 +840,7 @@ public final class AbilityFactoryDebuff { valid = params.get("ValidCards"); } - CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = CardListUtil.getValidCards(list, valid.split(","), hostCard.getController(), hostCard); for (final Card tgtC : list) { diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java index c9e64edf5b9..48e2d426d31 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java @@ -20,6 +20,7 @@ package forge.card.abilityfactory; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Random; import com.google.common.base.Predicate; @@ -27,7 +28,7 @@ import com.google.common.base.Predicate; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardUtil; import forge.Counters; @@ -225,7 +226,7 @@ public class AbilityFactoryDestroy { final Card source = sa.getSourceCard(); final HashMap params = af.getMapParams(); final boolean noRegen = params.containsKey("NoRegen"); - CardList list; + List list; if (abCost != null) { if (!CostUtil.checkSacrificeCost(abCost, source)) { @@ -317,7 +318,7 @@ public class AbilityFactoryDestroy { } } else { if (params.containsKey("Defined")) { - list = new CardList(AbilityFactory.getDefinedCards(af.getHostCard(), params.get("Defined"), sa)); + list = new ArrayList(AbilityFactory.getDefinedCards(af.getHostCard(), params.get("Defined"), sa)); if (list.isEmpty() || !CardListUtil.filterControlledBy(list, AllZone.getComputerPlayer()).isEmpty() || CardListUtil.getNotKeyword(list, "Indestructible").isEmpty()) { @@ -376,7 +377,7 @@ public class AbilityFactoryDestroy { final boolean noRegen = params.containsKey("NoRegen"); if (tgt != null) { - CardList list; + List list; list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = CardListUtil.getTargetableCards(list, sa); list = CardListUtil.getValidCards(list, tgt.getValidTgts(), source.getController(), source); @@ -387,7 +388,7 @@ public class AbilityFactoryDestroy { tgt.resetTargets(); - CardList preferred = CardListUtil.getNotKeyword(list, "Indestructible"); + List preferred = CardListUtil.getNotKeyword(list, "Indestructible"); preferred = CardListUtil.filterControlledBy(preferred, AllZone.getHumanPlayer()); // If NoRegen is not set, filter out creatures that have a @@ -851,8 +852,8 @@ public class AbilityFactoryDestroy { if (params.containsKey("ValidCards")) { valid = params.get("ValidCards"); } - CardList humanlist = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); - CardList computerlist = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List humanlist = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + List computerlist = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); if (sa.getTarget() != null) { tgt.resetTargets(); sa.getTarget().addTarget(AllZone.getHumanPlayer()); @@ -932,8 +933,8 @@ public class AbilityFactoryDestroy { valid = valid.replace("X", Integer.toString(xPay)); } - CardList humanlist = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); - CardList computerlist = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List humanlist = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + List computerlist = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); final Target tgt = sa.getTarget(); @@ -1038,7 +1039,7 @@ public class AbilityFactoryDestroy { valid = valid.replace("X", Integer.toString(AbilityFactory.calculateAmount(card, "X", sa))); } - CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); if (targetPlayer != null) { list = CardListUtil.filterControlledBy(list, targetPlayer); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryEffect.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryEffect.java index 6bf9f971a4c..97732de365d 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryEffect.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryEffect.java @@ -19,6 +19,7 @@ package forge.card.abilityfactory; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Random; import com.google.common.base.Predicate; @@ -26,7 +27,7 @@ import com.google.common.base.Predicate; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.Command; @@ -286,7 +287,7 @@ public class AbilityFactoryEffect { final Target tgt = sa.getTarget(); if (tgt != null) { tgt.resetTargets(); - CardList list = AllZone.getCombat().getAttackerList(); + List list = AllZone.getCombat().getAttackerList(); list = CardListUtil.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard()); list = CardListUtil.getTargetableCards(list, sa); Card target = CardFactoryUtil.getBestCreatureAI(list); @@ -299,8 +300,8 @@ public class AbilityFactoryEffect { } else if (logic.equals("Always")) { randomReturn = true; } else if (logic.equals("Evasion")) { - CardList comp = CardListUtil.filter(AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES); - CardList human = CardListUtil.filter(AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES); + List comp = CardListUtil.filter(AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES); + List human = CardListUtil.filter(AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES); // only count creatures that can attack or block comp = CardListUtil.filter(comp, new Predicate() { @@ -330,7 +331,7 @@ public class AbilityFactoryEffect { if (name == null) { name = sa.getSourceCard().getName() + "'s Effect"; } - final CardList list = sa.getActivatingPlayer().getCardsIn(ZoneType.Battlefield, name); + final List list = sa.getActivatingPlayer().getCardsIn(ZoneType.Battlefield, name); if (list.size() != 0) { return false; } diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java index a24d5a04dd1..8c062c8735c 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java @@ -20,6 +20,7 @@ package forge.card.abilityfactory; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Map; import com.google.common.base.Predicate; @@ -27,7 +28,7 @@ import com.google.common.base.Predicate; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.Command; import forge.GameEntity; @@ -334,7 +335,7 @@ public class AbilityFactoryGainControl { } } - CardList list = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + List list = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); list = CardListUtil.getValidCards(list, tgt.getValidTgts(), sa.getSourceCard().getController(), sa.getSourceCard()); // AI won't try to grab cards that are filtered out of AI decks on // purpose @@ -418,7 +419,7 @@ public class AbilityFactoryGainControl { * a {@link forge.card.spellability.SpellAbility} object. */ private void gainControlResolve(final SpellAbility sa) { - CardList tgtCards = new CardList(); + List tgtCards = new ArrayList(); Card source = sa.getSourceCard(); final Target tgt = sa.getTarget(); @@ -472,7 +473,7 @@ public class AbilityFactoryGainControl { if (!tgtC.equals(newController)) { tgtC.addController(newController); } - // Singletons.getModel().getGameAction().changeController(new CardList(tgtC), + // Singletons.getModel().getGameAction().changeController(new ArrayList(tgtC), // tgtC.getController(), newController.get(0)); if (this.bUntap) { @@ -560,7 +561,7 @@ public class AbilityFactoryGainControl { private boolean gainControlDrawbackAI(final SpellAbility sa) { if ((sa.getTarget() == null) || !sa.getTarget().doesTarget()) { if (this.params.containsKey("AllValid")) { - CardList tgtCards = CardListUtil.filterControlledBy(AllZoneUtil.getCardsIn(ZoneType.Battlefield), AllZone.getHumanPlayer()); + List tgtCards = CardListUtil.filterControlledBy(AllZoneUtil.getCardsIn(ZoneType.Battlefield), AllZone.getHumanPlayer()); tgtCards = AbilityFactory.filterListByType(tgtCards, this.params.get("AllValid"), sa); if (tgtCards.isEmpty()) { return false; @@ -651,7 +652,7 @@ public class AbilityFactoryGainControl { } if (AllZoneUtil.isCardInPlay(c)) { c.removeController(newController); - // Singletons.getModel().getGameAction().changeController(new CardList(c), + // Singletons.getModel().getGameAction().changeController(new ArrayList(c), // c.getController(), originalController); if (tapOnLose) { @@ -854,7 +855,7 @@ public class AbilityFactoryGainControl { final Target tgt = sa.getTarget(); tgt.resetTargets(); - CardList list = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + List list = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); list = CardListUtil.getValidCards(list, tgt.getValidTgts(), AllZone.getComputerPlayer(), sa.getSourceCard()); // AI won't try to grab cards that are filtered out of AI decks on // purpose @@ -869,7 +870,7 @@ public class AbilityFactoryGainControl { if (params.containsKey("Defined")) { object2 = AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa).get(0); } else if (tgt.getMinTargets(sa.getSourceCard(), sa) > 1) { - CardList list2 = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List list2 = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); list2 = CardListUtil.getValidCards(list2, tgt.getValidTgts(), AllZone.getComputerPlayer(), sa.getSourceCard()); object2 = CardFactoryUtil.getWorstAI(list2); tgt.addTarget(object2); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryMana.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryMana.java index 15a9c988c1b..4089887bd68 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryMana.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryMana.java @@ -20,6 +20,7 @@ package forge.card.abilityfactory; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Random; import com.google.common.collect.Iterables; @@ -27,7 +28,7 @@ import com.google.common.collect.Iterables; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.Constant; @@ -762,11 +763,11 @@ public class AbilityFactoryMana { maxChoices++; } - CardList cards = null; + List cards = null; // Reuse AF_Defined in a slightly different way if (validCard.startsWith("Defined.")) { - cards = new CardList(); + cards = new ArrayList(); for (final Card c : AbilityFactory.getDefinedCards(card, validCard.replace("Defined.", ""), abMana)) { cards.add(c); } @@ -852,7 +853,7 @@ public class AbilityFactoryMana { * a {@link java.util.ArrayList} object. * @return a {@link java.util.ArrayList} object. */ - private static ArrayList hasProperty(final int maxChoices, final CardList cards, + private static ArrayList hasProperty(final int maxChoices, final List cards, final ArrayList colors) { for (final Card c : cards) { // For each card, go through all the colors and if the card is that @@ -997,7 +998,7 @@ public class AbilityFactoryMana { * @return a boolean. */ private static boolean hasUrzaLands(final Player p) { - final CardList landsControlled = p.getCardsIn(ZoneType.Battlefield); + final List landsControlled = p.getCardsIn(ZoneType.Battlefield); return Iterables.any(landsControlled, CardPredicates.nameEquals("Urza's Mine")) && Iterables.any(landsControlled, CardPredicates.nameEquals("Urza's Tower")) && Iterables.any(landsControlled, CardPredicates.nameEquals("Urza's Power Plant")); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryPermanentState.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryPermanentState.java index 67d0f04d1fe..ec50d0d9119 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryPermanentState.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryPermanentState.java @@ -20,6 +20,7 @@ package forge.card.abilityfactory; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Random; import com.google.common.base.Predicate; @@ -28,7 +29,7 @@ import com.google.common.collect.Iterables; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.CardPredicates.Presets; @@ -404,7 +405,7 @@ public class AbilityFactoryPermanentState { targetController = AllZone.getHumanPlayer(); } - CardList untapList = targetController.getCardsIn(ZoneType.Battlefield); + List untapList = targetController.getCardsIn(ZoneType.Battlefield); untapList = CardListUtil.getTargetableCards(untapList, sa); untapList = CardListUtil.getValidCards(untapList, tgt.getValidTgts(), source.getController(), source); @@ -476,7 +477,7 @@ public class AbilityFactoryPermanentState { final Card source = sa.getSourceCard(); final Target tgt = sa.getTarget(); - CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = CardListUtil.getValidCards(list, tgt.getValidTgts(), source.getController(), source); list = CardListUtil.getTargetableCards(list, sa); @@ -484,7 +485,7 @@ public class AbilityFactoryPermanentState { // filter by enchantments and planeswalkers, their tapped state doesn't // matter. final String[] tappablePermanents = { "Enchantment", "Planeswalker" }; - CardList tapList = CardListUtil.getValidCards(list, tappablePermanents, source.getController(), source); + List tapList = CardListUtil.getValidCards(list, tappablePermanents, source.getController(), source); if (AbilityFactoryPermanentState.untapTargetList(source, tgt, af, sa, mandatory, tapList)) { return true; @@ -527,7 +528,7 @@ public class AbilityFactoryPermanentState { * @return a boolean. */ private static boolean untapTargetList(final Card source, final Target tgt, final AbilityFactory af, - final SpellAbility sa, final boolean mandatory, final CardList tapList) { + final SpellAbility sa, final boolean mandatory, final List tapList) { for (final Card c : tgt.getTargetCards()) { tapList.remove(c); } @@ -637,7 +638,7 @@ public class AbilityFactoryPermanentState { if (p.isHuman()) { AllZone.getInputControl().setInput(CardFactoryUtil.inputUntapUpToNType(num, valid)); } else { - CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); list = CardListUtil.getType(list, valid); list = CardListUtil.filter(list, Presets.TAPPED); @@ -1000,7 +1001,7 @@ public class AbilityFactoryPermanentState { */ private static boolean tapPrefTargeting(final Card source, final Target tgt, final AbilityFactory af, final SpellAbility sa, final boolean mandatory) { - CardList tapList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + List tapList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); tapList = CardListUtil.filter(tapList, Presets.UNTAPPED); tapList = CardListUtil.getValidCards(tapList, tgt.getValidTgts(), source.getController(), source); // filter out enchantments and planeswalkers, their tapped state doesn't matter. @@ -1036,8 +1037,8 @@ public class AbilityFactoryPermanentState { if (phase.getPhase().isAfter(PhaseType.COMBAT_DECLARE_ATTACKERS)) { //Combat has already started - final CardList attackers = AllZone.getCombat().getAttackerList(); - CardList creatureList = CardListUtil.filter(tapList, new Predicate() { + final List attackers = AllZone.getCombat().getAttackerList(); + List creatureList = CardListUtil.filter(tapList, new Predicate() { @Override public boolean apply(final Card c) { if (c.isCreature()) { @@ -1050,9 +1051,9 @@ public class AbilityFactoryPermanentState { choice = CardFactoryUtil.getBestCreatureAI(creatureList); } } else { - final CardList attackers = ComputerUtil.getPossibleAttackers(); + final List attackers = ComputerUtil.getPossibleAttackers(); attackers.remove(sa.getSourceCard()); - CardList creatureList = CardListUtil.filter(tapList, new Predicate() { + List creatureList = CardListUtil.filter(tapList, new Predicate() { @Override public boolean apply(final Card c) { if (c.isCreature()) { @@ -1069,7 +1070,7 @@ public class AbilityFactoryPermanentState { && phase.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS)) { // Tap creatures possible blockers before combat during AI's turn. if (Iterables.any(tapList, CardPredicates.Presets.CREATURES)) { - CardList creatureList = CardListUtil.filter(tapList, CardPredicates.Presets.CREATURES_CAN_ATTACK); + List creatureList = CardListUtil.filter(tapList, CardPredicates.Presets.CREATURES_CAN_ATTACK); choice = CardFactoryUtil.getBestCreatureAI(creatureList); } else { // no creatures available choice = CardFactoryUtil.getMostExpensivePermanentAI(tapList, sa, false); @@ -1117,13 +1118,13 @@ public class AbilityFactoryPermanentState { final Card source = sa.getSourceCard(); final Target tgt = sa.getTarget(); - CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = CardListUtil.getValidCards(list, tgt.getValidTgts(), source.getController(), source); list = CardListUtil.getTargetableCards(list, sa); // filter by enchantments and planeswalkers, their tapped state doesn't matter. final String[] tappablePermanents = { "Enchantment", "Planeswalker" }; - CardList tapList = CardListUtil.getValidCards(list, tappablePermanents, source.getController(), source); + List tapList = CardListUtil.getValidCards(list, tappablePermanents, source.getController(), source); if (AbilityFactoryPermanentState.tapTargetList(af, sa, tapList, mandatory)) { return true; @@ -1161,7 +1162,7 @@ public class AbilityFactoryPermanentState { * a boolean. * @return a boolean. */ - private static boolean tapTargetList(final AbilityFactory af, final SpellAbility sa, final CardList tapList, + private static boolean tapTargetList(final AbilityFactory af, final SpellAbility sa, final List tapList, final boolean mandatory) { final Card source = sa.getSourceCard(); final Target tgt = sa.getTarget(); @@ -1420,7 +1421,7 @@ public class AbilityFactoryPermanentState { final Card card = sa.getSourceCard(); String valid = ""; - CardList list = null; + List list = null; ArrayList tgtPlayers = null; @@ -1682,7 +1683,7 @@ public class AbilityFactoryPermanentState { card.clearRemembered(); } - CardList cards = null; + List cards = null; ArrayList tgtPlayers = null; @@ -1738,7 +1739,7 @@ public class AbilityFactoryPermanentState { valid = params.get("ValidCards"); } - CardList validTappables = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List validTappables = AllZoneUtil.getCardsIn(ZoneType.Battlefield); final Target tgt = sa.getTarget(); @@ -1758,13 +1759,13 @@ public class AbilityFactoryPermanentState { } if (validTappables.size() > 0) { - final CardList human = CardListUtil.filter(validTappables, new Predicate() { + final List human = CardListUtil.filter(validTappables, new Predicate() { @Override public boolean apply(final Card c) { return c.getController().isHuman(); } }); - final CardList compy = CardListUtil.filter(validTappables, new Predicate() { + final List compy = CardListUtil.filter(validTappables, new Predicate() { @Override public boolean apply(final Card c) { return c.getController().isComputer(); @@ -1788,8 +1789,8 @@ public class AbilityFactoryPermanentState { * a {@link forge.Card} object. * @return a {@link forge.CardList} object. */ - private static CardList getTapAllTargets(final String valid, final Card source) { - CardList tmpList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + private static List getTapAllTargets(final String valid, final Card source) { + List tmpList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); tmpList = CardListUtil.getValidCards(tmpList, valid, source.getController(), source); tmpList = CardListUtil.filter(tmpList, Presets.UNTAPPED); return tmpList; @@ -1852,7 +1853,7 @@ public class AbilityFactoryPermanentState { valid = params.get("ValidCards"); } - CardList validTappables = AbilityFactoryPermanentState.getTapAllTargets(valid, source); + List validTappables = AbilityFactoryPermanentState.getTapAllTargets(valid, source); final Target tgt = sa.getTarget(); @@ -1873,13 +1874,13 @@ public class AbilityFactoryPermanentState { } if (validTappables.size() > 0) { - final CardList human = CardListUtil.filter(validTappables, new Predicate() { + final List human = CardListUtil.filter(validTappables, new Predicate() { @Override public boolean apply(final Card c) { return c.getController().isHuman(); } }); - final CardList compy = CardListUtil.filter(validTappables, new Predicate() { + final List compy = CardListUtil.filter(validTappables, new Predicate() { @Override public boolean apply(final Card c) { return c.getController().isComputer(); @@ -2581,17 +2582,17 @@ public class AbilityFactoryPermanentState { final boolean mandatory) { // Card source = sa.getSourceCard(); - // CardList phaseList = + // List phaseList = // AllZoneUtil.getCardsIn(Zone.Battlefield).getTargetableCards(source) // .getValidCards(tgt.getValidTgts(), source.getController(), source); - // CardList aiPhaseList = + // List aiPhaseList = // phaseList.getController(AllZone.getComputerPlayer()); // If Something in the Phase List might die from a bad combat, or a // spell on the stack save it - // CardList humanPhaseList = + // List humanPhaseList = // phaseList.getController(AllZone.getHumanPlayer()); // If something in the Human List is causing issues, phase it out @@ -2617,7 +2618,7 @@ public class AbilityFactoryPermanentState { final Card source = sa.getSourceCard(); final Target tgt = sa.getTarget(); - CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = CardListUtil.getTargetableCards(CardListUtil.getValidCards(list, tgt.getValidTgts(), source.getController(), source), sa); return false; diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryPlay.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryPlay.java index 4b0a22764c3..e7b9b41331a 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryPlay.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryPlay.java @@ -20,6 +20,7 @@ package forge.card.abilityfactory; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Random; import com.google.common.base.Predicate; @@ -28,7 +29,7 @@ import forge.AllZone; import forge.AllZoneUtil; import forge.Card; import forge.CardCharacteristicName; -import forge.CardList; + import forge.CardListUtil; import forge.GameActionUtil; import forge.Singletons; @@ -298,7 +299,7 @@ public final class AbilityFactoryPlay { // prevent run-away activations - first time will always return true boolean chance = r.nextFloat() <= Math.pow(.6667, sa.getRestrictions().getNumberTurnActivations()); - CardList cards; + List cards; final Target tgt = sa.getTarget(); if (tgt != null) { ZoneType zone = tgt.getZone().get(0); @@ -309,7 +310,7 @@ public final class AbilityFactoryPlay { } tgt.addTarget(CardFactoryUtil.getBestAI(cards)); } else if (!params.containsKey("Valid")) { - cards = new CardList(AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa)); + cards = new ArrayList(AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa)); if (cards.isEmpty()) { return false; } @@ -366,7 +367,7 @@ public final class AbilityFactoryPlay { } final Player controller = activator; - CardList tgtCards = new CardList(); + List tgtCards = new ArrayList(); final Target tgt = sa.getTarget(); if (params.containsKey("Valid")) { @@ -377,9 +378,9 @@ public final class AbilityFactoryPlay { tgtCards = AllZoneUtil.getCardsIn(zone); tgtCards = AbilityFactory.filterListByType(tgtCards, params.get("Valid"), sa); } else if (params.containsKey("Defined")) { - tgtCards = new CardList(AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa)); + tgtCards = new ArrayList(AbilityFactory.getDefinedCards(sa.getSourceCard(), params.get("Defined"), sa)); } else if (tgt != null) { - tgtCards = new CardList(tgt.getTargetCards()); + tgtCards = new ArrayList(tgt.getTargetCards()); } if (tgtCards.isEmpty()) { diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryPreventDamage.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryPreventDamage.java index ac19c3b28c8..1d3aa53b7bf 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryPreventDamage.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryPreventDamage.java @@ -19,11 +19,12 @@ package forge.card.abilityfactory; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.CardUtil; @@ -348,9 +349,9 @@ public class AbilityFactoryPreventDamage { tgt.addTarget(AllZone.getComputerPlayer()); } - final CardList threatenedTargets = new CardList(); + final List threatenedTargets = new ArrayList(); // filter AIs battlefield by what I can target - CardList targetables = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List targetables = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); targetables = CardListUtil.getValidCards(targetables, tgt.getValidTgts(), AllZone.getComputerPlayer(), hostCard); for (final Card c : targetables) { @@ -374,13 +375,13 @@ public class AbilityFactoryPreventDamage { chance = true; } else { // filter AIs battlefield by what I can target - CardList targetables = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List targetables = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); targetables = CardListUtil.getValidCards(targetables, tgt.getValidTgts(), AllZone.getComputerPlayer(), hostCard); if (targetables.size() == 0) { return false; } - final CardList combatants = CardListUtil.filter(targetables, CardPredicates.Presets.CREATURES); + final List combatants = CardListUtil.filter(targetables, CardPredicates.Presets.CREATURES); CardListUtil.sortByEvaluateCreature(combatants); for (final Card c : combatants) { @@ -457,9 +458,9 @@ public class AbilityFactoryPreventDamage { final Target tgt = sa.getTarget(); tgt.resetTargets(); // filter AIs battlefield by what I can target - CardList targetables = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List targetables = AllZoneUtil.getCardsIn(ZoneType.Battlefield); targetables = CardListUtil.getValidCards(targetables, tgt.getValidTgts(), AllZone.getComputerPlayer(), hostCard); - final CardList compTargetables = CardListUtil.filterControlledBy(targetables, AllZone.getComputerPlayer()); + final List compTargetables = CardListUtil.filterControlledBy(targetables, AllZone.getComputerPlayer()); if (targetables.size() == 0) { return false; @@ -470,7 +471,7 @@ public class AbilityFactoryPreventDamage { } if (compTargetables.size() > 0) { - final CardList combatants = CardListUtil.filter(compTargetables, CardPredicates.Presets.CREATURES); + final List combatants = CardListUtil.filter(compTargetables, CardPredicates.Presets.CREATURES); CardListUtil.sortByEvaluateCreature(combatants); if (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) { for (final Card c : combatants) { @@ -780,7 +781,7 @@ public class AbilityFactoryPreventDamage { final int numDam = AbilityFactory.calculateAmount(af.getHostCard(), params.get("Amount"), sa); String players = ""; - CardList list = new CardList(); + List list = new ArrayList(); if (params.containsKey("ValidPlayers")) { players = params.get("ValidPlayers"); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryProtection.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryProtection.java index 1606ab8bdd9..7de74ac099a 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryProtection.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryProtection.java @@ -21,6 +21,7 @@ import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import javax.swing.JOptionPane; @@ -29,7 +30,7 @@ import com.google.common.base.Predicate; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardUtil; import forge.Command; @@ -244,11 +245,11 @@ public final class AbilityFactoryProtection { * a {@link forge.card.abilityfactory.AbilityFactory} object. * @return a {@link forge.CardList} object. */ - private static CardList getProtectCreatures(final AbilityFactory af, final SpellAbility sa) { + private static List getProtectCreatures(final AbilityFactory af, final SpellAbility sa) { final Card hostCard = af.getHostCard(); final ArrayList gains = AbilityFactoryProtection.getProtectionList(hostCard, af.getMapParams()); - CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); + List list = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); list = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { @@ -382,7 +383,7 @@ public final class AbilityFactoryProtection { final Target tgt = sa.getTarget(); tgt.resetTargets(); - CardList list = AbilityFactoryProtection.getProtectCreatures(af, sa); + List list = AbilityFactoryProtection.getProtectCreatures(af, sa); list = CardListUtil.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard()); @@ -469,7 +470,7 @@ public final class AbilityFactoryProtection { final HashMap params = af.getMapParams(); final Card host = af.getHostCard(); - CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); final Target tgt = sa.getTarget(); list = CardListUtil.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard()); @@ -483,7 +484,7 @@ public final class AbilityFactoryProtection { list.remove(c); } - CardList pref = CardListUtil.filterControlledBy(list, AllZone.getComputerPlayer()); + List pref = CardListUtil.filterControlledBy(list, AllZone.getComputerPlayer()); pref = CardListUtil.filter(pref, new Predicate() { @Override public boolean apply(final Card c) { @@ -491,7 +492,7 @@ public final class AbilityFactoryProtection { AbilityFactoryProtection.getProtectionList(host, params)); } }); - final CardList pref2 = CardListUtil.filterControlledBy(list, AllZone.getComputerPlayer()); + final List pref2 = CardListUtil.filterControlledBy(list, AllZone.getComputerPlayer()); pref = CardListUtil.filter(pref, new Predicate() { @Override public boolean apply(final Card c) { @@ -499,7 +500,7 @@ public final class AbilityFactoryProtection { AbilityFactoryProtection.getProtectionList(host, params)); } }); - final CardList forced = CardListUtil.filterControlledBy(list, AllZone.getHumanPlayer()); + final List forced = CardListUtil.filterControlledBy(list, AllZone.getHumanPlayer()); final Card source = sa.getSourceCard(); while (tgt.getNumTargeted() < tgt.getMaxTargets(source, sa)) { @@ -742,7 +743,7 @@ public final class AbilityFactoryProtection { if (params.containsKey("AILogic")) { final String logic = params.get("AILogic"); if (logic.equals("MostProminentHumanCreatures")) { - CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + List list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); if (list.isEmpty()) { list = CardListUtil.filterControlledBy(AllZoneUtil.getCardsInGame(), AllZone.getHumanPlayer()); } @@ -1189,7 +1190,7 @@ public final class AbilityFactoryProtection { valid = params.get("ValidCards"); } if (!valid.equals("")) { - CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = CardListUtil.getValidCards(list, valid, sa.getActivatingPlayer(), host); for (final Card tgtC : list) { diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryPump.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryPump.java index 74dcf14a1c6..bd406c4e3eb 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryPump.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryPump.java @@ -29,7 +29,7 @@ import com.google.common.collect.Iterables; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.CardUtil; @@ -334,7 +334,7 @@ public class AbilityFactoryPump { return false; } - CardList attackers = CardListUtil.filter(AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.possibleAttackers); + List attackers = CardListUtil.filter(AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.possibleAttackers); if(!CombatUtil.canBlockAtLeastOne(card, attackers)) { return false; } @@ -390,7 +390,7 @@ public class AbilityFactoryPump { } Predicate opBlockers = CardPredicates.possibleBlockers(card); - CardList cardsCanBlock = CardListUtil.filter(AllZoneUtil.getCreaturesInPlay(human), opBlockers); + List cardsCanBlock = CardListUtil.filter(AllZoneUtil.getCreaturesInPlay(human), opBlockers); final boolean evasive = (keyword.endsWith("Unblockable") || keyword.endsWith("Fear") || keyword.endsWith("Intimidate") || keyword.endsWith("Shadow")); @@ -455,7 +455,7 @@ public class AbilityFactoryPump { } } else if (ph.isPlayerTurn(computer) && ph.getPhase().isBefore(PhaseType.COMBAT_DECLARE_ATTACKERS) && CombatUtil.canAttack(card)) { - CardList blockers = AllZoneUtil.getCreaturesInPlay(human); + List blockers = AllZoneUtil.getCreaturesInPlay(human); for (Card blocker : blockers) { if (CombatUtil.canBlock(card, blocker, combat) && !CombatUtil.canDestroyBlocker(blocker, card, combat, false)) { @@ -630,7 +630,7 @@ public class AbilityFactoryPump { if (defense > 0 && CombatUtil.blockerWouldBeDestroyed(c)) { return true; } - CardList blockedBy = AllZone.getCombat().getAttackersBlockedBy(c); + List blockedBy = AllZone.getCombat().getAttackersBlockedBy(c); // For now, Only care the first creature blocked by a card. // TODO Add in better BlockAdditional support if (!blockedBy.isEmpty() && attack > 0 && !CombatUtil.attackerWouldBeDestroyed(blockedBy.get(0))) { @@ -654,7 +654,7 @@ public class AbilityFactoryPump { } // if the life of the computer is in danger, try to pump blockers blocking Tramplers - CardList blockedBy = AllZone.getCombat().getAttackersBlockedBy(c); + List blockedBy = AllZone.getCombat().getAttackersBlockedBy(c); boolean attackerHasTrample = false; for (Card b : blockedBy) { attackerHasTrample |= b.hasKeyword("Trample"); @@ -679,9 +679,9 @@ public class AbilityFactoryPump { * * @return a {@link forge.CardList} object. */ - private CardList getPumpCreatures(final SpellAbility sa) { + private List getPumpCreatures(final SpellAbility sa) { - CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); + List list = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); list = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { @@ -704,8 +704,8 @@ public class AbilityFactoryPump { * a int. * @return a {@link forge.CardList} object. */ - private CardList getCurseCreatures(final SpellAbility sa, final int defense, final int attack) { - CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + private List getCurseCreatures(final SpellAbility sa, final int defense, final int attack) { + List list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); list = CardListUtil.getTargetableCards(list, sa); if ((defense < 0) && !list.isEmpty()) { // with spells that give -X/-X, // compi will try to destroy a @@ -727,9 +727,9 @@ public class AbilityFactoryPump { if (activePlayer.isComputer()) { if (Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_BEGIN)) { // TODO: Curse creatures that will block AI's creatures, if AI is going to attack. - list = new CardList(); + list = new ArrayList(); } else { - list = new CardList(); + list = new ArrayList(); } } else { // Human active, only curse attacking creatures @@ -751,7 +751,7 @@ public class AbilityFactoryPump { } }); } else { - list = new CardList(); + list = new ArrayList(); } } Singletons.getModel().getGameState().getPhaseHandler().getPhase().isBefore(PhaseType.COMBAT_BEGIN); @@ -768,7 +768,7 @@ public class AbilityFactoryPump { } }); } else { - list = new CardList(); + list = new ArrayList(); } } @@ -955,7 +955,7 @@ public class AbilityFactoryPump { final Target tgt = sa.getTarget(); tgt.resetTargets(); - CardList list = new CardList(); + List list = new ArrayList(); if (this.abilityFactory.getMapParams().containsKey("AILogic")) { if (this.abilityFactory.getMapParams().get("AILogic").equals("HighestPower")) { list = CardListUtil.getValidCards(AllZoneUtil.getCreaturesInPlay(), tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard()); @@ -1057,7 +1057,7 @@ public class AbilityFactoryPump { * @return a boolean. */ private boolean pumpMandatoryTarget(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) { - CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); final Target tgt = sa.getTarget(); list = CardListUtil.getValidCards(list, tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard()); list = CardListUtil.getTargetableCards(list, sa); @@ -1072,8 +1072,8 @@ public class AbilityFactoryPump { list.remove(c); } - CardList pref; - CardList forced; + List pref; + List forced; final Card source = sa.getSourceCard(); if (af.isCurse()) { @@ -1702,16 +1702,16 @@ public class AbilityFactoryPump { valid = this.params.get("ValidCards"); } - CardList comp = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List comp = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); comp = CardListUtil.getValidCards(comp, valid, source.getController(), source); - CardList human = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + List human = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); human = CardListUtil.getValidCards(human, valid, source.getController(), source); final Target tgt = sa.getTarget(); if (tgt != null && sa.canTarget(AllZone.getHumanPlayer()) && params.containsKey("IsCurse")) { tgt.resetTargets(); sa.getTarget().addTarget(AllZone.getHumanPlayer()); - comp = new CardList(); + comp = new ArrayList(); } if (this.abilityFactory.isCurse()) { @@ -1782,7 +1782,7 @@ public class AbilityFactoryPump { * a {@link forge.card.spellability.SpellAbility} object. */ private void pumpAllResolve(final SpellAbility sa) { - CardList list; + List list; ArrayList tgtPlayers = null; final ArrayList affectedZones = new ArrayList(); @@ -1802,7 +1802,7 @@ public class AbilityFactoryPump { affectedZones.add(ZoneType.Battlefield); } - list = new CardList(); + list = new ArrayList(); if ((tgtPlayers == null) || tgtPlayers.isEmpty()) { for (final ZoneType zone : affectedZones) { list.addAll(AllZoneUtil.getCardsIn(zone)); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryRegenerate.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryRegenerate.java index fb7175ff4f9..3488bcc2547 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryRegenerate.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryRegenerate.java @@ -20,11 +20,12 @@ package forge.card.abilityfactory; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.Command; @@ -314,7 +315,7 @@ public class AbilityFactoryRegenerate { } else { tgt.resetTargets(); // filter AIs battlefield by what I can target - CardList targetables = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List targetables = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); targetables = CardListUtil.getValidCards(targetables, tgt.getValidTgts(), AllZone.getComputerPlayer(), hostCard); if (targetables.size() == 0) { @@ -326,7 +327,7 @@ public class AbilityFactoryRegenerate { // control final ArrayList objects = AbilityFactory.predictThreatenedObjects(af); - final CardList threatenedTargets = new CardList(); + final List threatenedTargets = new ArrayList(); for (final Card c : targetables) { if (objects.contains(c) && (c.getShield() == 0)) { @@ -341,7 +342,7 @@ public class AbilityFactoryRegenerate { } } else { if (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) { - final CardList combatants = CardListUtil.filter(targetables, CardPredicates.Presets.CREATURES); + final List combatants = CardListUtil.filter(targetables, CardPredicates.Presets.CREATURES); CardListUtil.sortByEvaluateCreature(combatants); for (final Card c : combatants) { @@ -417,9 +418,9 @@ public class AbilityFactoryRegenerate { final Target tgt = sa.getTarget(); tgt.resetTargets(); // filter AIs battlefield by what I can target - CardList targetables = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List targetables = AllZoneUtil.getCardsIn(ZoneType.Battlefield); targetables = CardListUtil.getValidCards(targetables, tgt.getValidTgts(), AllZone.getComputerPlayer(), hostCard); - final CardList compTargetables = CardListUtil.filterControlledBy(targetables, AllZone.getComputerPlayer()); + final List compTargetables = CardListUtil.filterControlledBy(targetables, AllZone.getComputerPlayer()); if (targetables.size() == 0) { return false; @@ -430,7 +431,7 @@ public class AbilityFactoryRegenerate { } if (compTargetables.size() > 0) { - final CardList combatants = CardListUtil.filter(compTargetables, CardPredicates.Presets.CREATURES); + final List combatants = CardListUtil.filter(compTargetables, CardPredicates.Presets.CREATURES); CardListUtil.sortByEvaluateCreature(combatants); if (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) { for (final Card c : combatants) { @@ -726,7 +727,7 @@ public class AbilityFactoryRegenerate { valid = params.get("ValidCards"); } - CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = CardListUtil.getValidCards(list, valid.split(","), hostCard.getController(), hostCard); if (list.size() == 0) { @@ -740,7 +741,7 @@ public class AbilityFactoryRegenerate { } else { if (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS_INSTANT_ABILITY)) { - final CardList combatants = CardListUtil.filter(list, CardPredicates.Presets.CREATURES); + final List combatants = CardListUtil.filter(list, CardPredicates.Presets.CREATURES); for (final Card c : combatants) { if ((c.getShield() == 0) && CombatUtil.combatantWouldBeDestroyed(c)) { @@ -810,7 +811,7 @@ public class AbilityFactoryRegenerate { valid = params.get("ValidCards"); } - CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = CardListUtil.getValidCards(list, valid.split(","), hostCard.getController(), hostCard); for (final Card c : list) { diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryRepeat.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryRepeat.java index b79547f78d5..0d37cf882d0 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryRepeat.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryRepeat.java @@ -17,14 +17,16 @@ */ package forge.card.abilityfactory; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; import forge.CardListUtil; import forge.card.cost.Cost; -import forge.CardList; + import forge.GameActionUtil; import forge.card.cardfactory.CardFactoryUtil; import forge.card.spellability.AbilityActivated; @@ -265,7 +267,7 @@ public final class AbilityFactoryRepeat { if (params.containsKey("RepeatPresent")) { final String repeatPresent = params.get("RepeatPresent"); - CardList list = new CardList(); + List list = new ArrayList(); String repeatCompare = "GE1"; if (params.containsKey("RepeatCompare")) { diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java index 0048000e0f8..91ac4ffc914 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java @@ -31,7 +31,7 @@ import forge.AllZone; import forge.AllZoneUtil; import forge.Card; import forge.CardCharacteristicName; -import forge.CardList; + import forge.CardListUtil; import forge.CardUtil; import forge.GameActionUtil; @@ -423,9 +423,9 @@ public final class AbilityFactoryReveal { if (tgt != null && !p.canBeTargetedBy(sa)) { continue; } - final CardList top = new CardList(); - CardList valid = new CardList(); - final CardList rest = new CardList(); + final List top = new ArrayList(); + List valid = new ArrayList(); + final List rest = new ArrayList(); final PlayerZone library = p.getZone(ZoneType.Library); numToDig = Math.min(numToDig, library.size()); @@ -458,7 +458,7 @@ public final class AbilityFactoryReveal { } } else if (params.containsKey("RevealValid")) { final String revealValid = params.get("RevealValid"); - final CardList toReveal = CardListUtil.getValidCards(top, revealValid, host.getController(), host); + final List toReveal = CardListUtil.getValidCards(top, revealValid, host.getController(), host); if (!toReveal.isEmpty()) { GuiChoose.one("Revealing cards from library", toReveal); if (params.containsKey("RememberRevealed")) { @@ -482,8 +482,8 @@ public final class AbilityFactoryReveal { } if (!noMove) { - List movedCards = new CardList(); - CardList andOrCards = new CardList(); + List movedCards = new ArrayList(); + List andOrCards = new ArrayList(); for (final Card c : top) { rest.add(c); } @@ -540,7 +540,7 @@ public final class AbilityFactoryReveal { if (!andOrValid.equals("")) { andOrCards.remove(chosen); if (!chosen.isValid(andOrValid.split(","), host.getController(), host)) { - valid = new CardList(andOrCards); + valid = new ArrayList(andOrCards); } else if (!chosen.isValid(changeValid.split(","), host.getController(), host)) { valid.removeAll(andOrCards); } @@ -661,7 +661,7 @@ public final class AbilityFactoryReveal { } // end foreach player } // end resolve - // returns a CardList that is a subset of list with cards that share a name + // returns a List that is a subset of list with cards that share a name // with a permanent on the battlefield /** *

@@ -672,9 +672,9 @@ public final class AbilityFactoryReveal { * a {@link forge.CardList} object. * @return a {@link forge.CardList} object. */ - private static CardList sharesNameWithCardOnBattlefield(final CardList list) { - final CardList toReturn = new CardList(); - final CardList play = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + private static List sharesNameWithCardOnBattlefield(final List list) { + final List toReturn = new ArrayList(); + final List play = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card c : list) { for (final Card p : play) { if (p.getName().equals(c.getName()) && !toReturn.contains(c)) { @@ -1029,8 +1029,8 @@ public final class AbilityFactoryReveal { for (final Player p : tgtPlayers) { if ((tgt == null) || p.canBeTargetedBy(sa)) { - final CardList found = new CardList(); - final CardList revealed = new CardList(); + final List found = new ArrayList(); + final List revealed = new ArrayList(); final PlayerZone library = p.getZone(ZoneType.Library); @@ -1426,7 +1426,7 @@ public final class AbilityFactoryReveal { for (final Player p : tgtPlayers) { if ((tgt == null) || p.canBeTargetedBy(sa)) { - final CardList hand = p.getCardsIn(ZoneType.Hand); + final List hand = p.getCardsIn(ZoneType.Hand); if (sa.getActivatingPlayer().isHuman()) { if (hand.size() > 0) { GuiChoose.one(p + "'s hand", hand); @@ -2049,7 +2049,7 @@ public final class AbilityFactoryReveal { if (maxCards == 0) { return; } - final CardList topCards = new CardList(); + final List topCards = new ArrayList(); // show top n cards: for (int j = 0; j < maxCards; j++) { topCards.add(lib.get(j)); @@ -2373,14 +2373,14 @@ public final class AbilityFactoryReveal { for (final Player p : tgtPlayers) { if ((tgt == null) || p.canBeTargetedBy(sa)) { - final CardList handChoices = p.getCardsIn(ZoneType.Hand); + final List handChoices = p.getCardsIn(ZoneType.Hand); if (handChoices.size() > 0) { - final CardList revealed = new CardList(); + final List revealed = new ArrayList(); if (params.containsKey("Random")) { revealed.add(CardUtil.getRandom(handChoices)); GuiChoose.oneOrNone("Revealed card(s)", revealed); } else { - CardList valid = new CardList(handChoices); + List valid = new ArrayList(handChoices); int max = 1; if (params.containsKey("RevealValid")) { valid = CardListUtil.getValidCards(valid, params.get("RevealValid"), p, host); @@ -2414,8 +2414,8 @@ public final class AbilityFactoryReveal { * @param anyNumber a boolean * @return the revealed list */ - public static CardList getRevealedList(final Player player, final CardList valid, final int max, boolean anyNumber) { - final CardList chosen = new CardList(); + public static List getRevealedList(final Player player, final List valid, final int max, boolean anyNumber) { + final List chosen = new ArrayList(); final int validamount = Math.min(valid.size(), max); if (anyNumber && player.isHuman() && validamount > 0) { diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactorySacrifice.java b/src/main/java/forge/card/abilityfactory/AbilityFactorySacrifice.java index fc0b769d68d..faf2250ad0b 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactorySacrifice.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactorySacrifice.java @@ -19,12 +19,13 @@ package forge.card.abilityfactory; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Random; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardUtil; import forge.Singletons; @@ -285,7 +286,7 @@ public class AbilityFactorySacrifice { num = (num == null) ? "1" : num; final int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), num, sa); - CardList list = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + List list = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); list = CardListUtil.getValidCards(list, valid.split(","), sa.getActivatingPlayer(), sa.getSourceCard()); if (list.size() == 0) { @@ -425,11 +426,11 @@ public class AbilityFactorySacrifice { amount = Math.min(ComputerUtil.determineLeftoverMana(sa), amount); } - CardList humanList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + List humanList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); humanList = CardListUtil.getValidCards(humanList, valid.split(","), sa.getActivatingPlayer(), sa.getSourceCard()); - CardList computerList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List computerList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); if (defined.equals("Opponent")) { - computerList = new CardList(); + computerList = new ArrayList(); } computerList = CardListUtil.getValidCards(computerList, valid.split(","), sa.getActivatingPlayer(), sa.getSourceCard()); @@ -492,7 +493,7 @@ public class AbilityFactorySacrifice { } } else { - CardList sacList = null; + List sacList = null; for (final Player p : tgts) { if (params.containsKey("Random")) { sacList = AbilityFactorySacrifice.sacrificeRandom(p, amount, valid, sa, destroy); @@ -529,10 +530,10 @@ public class AbilityFactorySacrifice { * @param sa * a {@link forge.card.spellability.SpellAbility} object. */ - private static CardList sacrificeAI(final Player p, final int amount, final String valid, final SpellAbility sa, + private static List sacrificeAI(final Player p, final int amount, final String valid, final SpellAbility sa, final boolean destroy) { - CardList battlefield = p.getCardsIn(ZoneType.Battlefield); - CardList sacList = AbilityFactory.filterListByType(battlefield, valid, sa); + List battlefield = p.getCardsIn(ZoneType.Battlefield); + List sacList = AbilityFactory.filterListByType(battlefield, valid, sa); sacList = ComputerUtil.sacrificePermanents(amount, sacList, destroy, sa); return sacList; @@ -554,11 +555,11 @@ public class AbilityFactorySacrifice { * @param message * a {@link java.lang.String} object. */ - public static CardList sacrificeHuman(final Player p, final int amount, final String valid, final SpellAbility sa, + public static List sacrificeHuman(final Player p, final int amount, final String valid, final SpellAbility sa, final boolean destroy, final boolean optional) { - CardList battlefield = p.getCardsIn(ZoneType.Battlefield); - CardList list = AbilityFactory.filterListByType(battlefield, valid, sa); - CardList sacList = new CardList(); + List battlefield = p.getCardsIn(ZoneType.Battlefield); + List list = AbilityFactory.filterListByType(battlefield, valid, sa); + List sacList = new ArrayList(); for (int i = 0; i < amount; i++) { if (list.isEmpty()) { @@ -606,12 +607,12 @@ public class AbilityFactorySacrifice { * @param sa * a {@link forge.card.spellability.SpellAbility} object. */ - private static CardList sacrificeRandom(final Player p, final int amount, final String valid, final SpellAbility sa, + private static List sacrificeRandom(final Player p, final int amount, final String valid, final SpellAbility sa, final boolean destroy) { - CardList sacList = new CardList(); + List sacList = new ArrayList(); for (int i = 0; i < amount; i++) { - CardList battlefield = p.getCardsIn(ZoneType.Battlefield); - CardList list = AbilityFactory.filterListByType(battlefield, valid, sa); + List battlefield = p.getCardsIn(ZoneType.Battlefield); + List list = AbilityFactory.filterListByType(battlefield, valid, sa); if (list.size() != 0) { final Card sac = CardUtil.getRandom(list); if (destroy) { @@ -847,8 +848,8 @@ public class AbilityFactorySacrifice { valid = valid.replace("X", Integer.toString(xPay)); } - CardList humanlist = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); - CardList computerlist = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List humanlist = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + List computerlist = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); humanlist = CardListUtil.getValidCards(humanlist, valid.split(","), source.getController(), source); computerlist = CardListUtil.getValidCards(computerlist, valid.split(","), source.getController(), source); @@ -920,9 +921,9 @@ public class AbilityFactorySacrifice { valid = valid.replace("X", Integer.toString(AbilityFactory.calculateAmount(card, "X", sa))); } - CardList list; + List list; if (params.containsKey("Defined")) { - list = new CardList(AbilityFactory.getDefinedCards(af.getHostCard(), params.get("Defined"), sa)); + list = new ArrayList(AbilityFactory.getDefinedCards(af.getHostCard(), params.get("Defined"), sa)); } else { list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); } diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactorySetState.java b/src/main/java/forge/card/abilityfactory/AbilityFactorySetState.java index d475a172cee..cd421d875e2 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactorySetState.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactorySetState.java @@ -20,12 +20,13 @@ package forge.card.abilityfactory; import java.util.ArrayList; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Map; import forge.AllZoneUtil; import forge.Card; import forge.CardCharacteristicName; -import forge.CardList; + import forge.CardListUtil; import forge.card.spellability.AbilityActivated; import forge.card.spellability.AbilitySub; @@ -470,7 +471,7 @@ public class AbilityFactorySetState { valid = valid.replace("X", Integer.toString(AbilityFactory.calculateAmount(card, "X", sa))); } - CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); if (targetPlayer != null) { list = CardListUtil.filterControlledBy(list, targetPlayer); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryToken.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryToken.java index 71f1d392f2a..28a3b46ae46 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryToken.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryToken.java @@ -19,12 +19,13 @@ package forge.card.abilityfactory; import java.util.Arrays; import java.util.HashMap; +import java.util.List; import java.util.Random; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; import forge.card.cost.Cost; @@ -571,7 +572,7 @@ public class AbilityFactoryToken extends AbilityFactory { final String remember = this.abilityFactory.getMapParams().get("RememberTokens"); for (int i = 0; i < finalAmount; i++) { - final CardList tokens = CardFactoryUtil.makeToken(substitutedName, imageName, controller, cost, + final List tokens = CardFactoryUtil.makeToken(substitutedName, imageName, controller, cost, substitutedTypes, finalPower, finalToughness, this.tokenKeywords); // Grant abilities diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java index 58a19b96854..62b684e2fe1 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java @@ -22,11 +22,12 @@ import java.util.ArrayList; import java.util.Collections; import java.util.HashMap; import java.util.Iterator; +import java.util.List; import java.util.Random; import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardUtil; import forge.GameActionUtil; @@ -312,7 +313,7 @@ public class AbilityFactoryZoneAffecting { if (part instanceof CostDiscard) { CostDiscard cd = (CostDiscard) part; cd.decideAIPayment(sa, sa.getSourceCard(), null); - CardList discards = cd.getList(); + List discards = cd.getList(); for (Card discard : discards) { if (!ComputerUtil.isWorseThanDraw(discard)) { return false; @@ -621,7 +622,7 @@ public class AbilityFactoryZoneAffecting { p.addSlowtripList(source); } } else { - final CardList drawn = p.drawCards(numCards); + final List drawn = p.drawCards(numCards); if (params.containsKey("Reveal")) { GuiChoose.one("Revealing drawn cards", drawn); } @@ -965,7 +966,7 @@ public class AbilityFactoryZoneAffecting { final int numCards = AbilityFactory.calculateAmount(sa.getSourceCard(), params.get("NumCards"), sa); - final CardList pLibrary = AllZone.getHumanPlayer().getCardsIn(ZoneType.Library); + final List pLibrary = AllZone.getHumanPlayer().getCardsIn(ZoneType.Library); if (pLibrary.size() == 0) { // deck already empty, no need to mill if (!mandatory) { @@ -1085,7 +1086,7 @@ public class AbilityFactoryZoneAffecting { for (final Player p : tgtPlayers) { if ((tgt == null) || p.canBeTargetedBy(sa)) { - final CardList milled = p.mill(numCards, destination, bottom); + final List milled = p.mill(numCards, destination, bottom); if (params.containsKey("RememberMilled")) { for (final Card c : milled) { source.addRemembered(c); @@ -1295,7 +1296,7 @@ public class AbilityFactoryZoneAffecting { tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa); } - final CardList discarded = new CardList(); + final List discarded = new ArrayList(); for (final Player p : tgtPlayers) { if ((tgt == null) || p.canBeTargetedBy(sa)) { @@ -1314,7 +1315,7 @@ public class AbilityFactoryZoneAffecting { } if (mode.equals("Hand")) { - final CardList list = p.discardHand(sa); + final List list = p.discardHand(sa); if (params.containsKey("RememberDiscarded")) { for (final Card c : list) { source.addRemembered(c); @@ -1340,7 +1341,7 @@ public class AbilityFactoryZoneAffecting { p.discardUnless(numCards, params.get("UnlessType"), sa); } else if (mode.equals("RevealDiscardAll")) { // Reveal - final CardList dPHand = p.getCardsIn(ZoneType.Hand); + final List dPHand = p.getCardsIn(ZoneType.Hand); if (p.isHuman()) { // "reveal to computer" for information gathering @@ -1357,7 +1358,7 @@ public class AbilityFactoryZoneAffecting { valid = valid.replace("X", Integer.toString(AbilityFactory.calculateAmount(source, "X", sa))); } - final CardList dPChHand = CardListUtil.getValidCards(dPHand, valid.split(","), source.getController(), source); + final List dPChHand = CardListUtil.getValidCards(dPHand, valid.split(","), source.getController(), source); // Reveal cards that will be discarded? for (final Card c : dPChHand) { p.discard(c, sa); @@ -1366,7 +1367,7 @@ public class AbilityFactoryZoneAffecting { } else if (mode.equals("RevealYouChoose") || mode.equals("RevealOppChoose") || mode.equals("TgtChoose")) { // Is Reveal you choose right? I think the wrong player is // being used? - CardList dPHand = p.getCardsIn(ZoneType.Hand); + List dPHand = p.getCardsIn(ZoneType.Hand); if (dPHand.size() != 0) { if (params.containsKey("RevealNumber")) { String amountString = params.get("RevealNumber"); @@ -1374,7 +1375,7 @@ public class AbilityFactoryZoneAffecting { : CardFactoryUtil.xCount(source, source.getSVar(amountString)); dPHand = AbilityFactoryReveal.getRevealedList(p, dPHand, amount, false); } - CardList dPChHand = new CardList(dPHand); + List dPChHand = new ArrayList(dPHand); String[] dValid = null; if (params.containsKey("DiscardValid")) { // Restrict card choices dValid = params.get("DiscardValid").split(","); @@ -1392,7 +1393,7 @@ public class AbilityFactoryZoneAffecting { if (p.isComputer()) { // discard AI cards int max = chooser.getCardsIn(ZoneType.Hand).size(); max = Math.min(max, numCards); - CardList list = ComputerUtil.discardNumTypeAI(max, dValid, sa); + List list = ComputerUtil.discardNumTypeAI(max, dValid, sa); if (mode.startsWith("Reveal")) { GuiChoose.oneOrNone("Computer has chosen", list); } @@ -1405,7 +1406,7 @@ public class AbilityFactoryZoneAffecting { // discard human cards for (int i = 0; i < numCards; i++) { if (dPChHand.size() > 0) { - final CardList dChoices = new CardList(); + final List dChoices = new ArrayList(); if (params.containsKey("DiscardValid")) { final String validString = params.get("DiscardValid"); if (validString.contains("Creature") && !validString.contains("nonCreature")) { @@ -1425,7 +1426,7 @@ public class AbilityFactoryZoneAffecting { dPChHand.remove(dC); if (mode.startsWith("Reveal")) { - final CardList dCs = new CardList(); + final List dCs = new ArrayList(); dCs.add(dC); GuiChoose.oneOrNone("Computer has chosen", dCs); } diff --git a/src/main/java/forge/card/cardfactory/CardFactoryArtifacts.java b/src/main/java/forge/card/cardfactory/CardFactoryArtifacts.java index 723257cbf75..73e68134f6d 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryArtifacts.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryArtifacts.java @@ -1,11 +1,14 @@ package forge.card.cardfactory; +import java.util.ArrayList; +import java.util.List; + import javax.swing.JOptionPane; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.CardPredicates.Presets; @@ -184,7 +187,7 @@ class CardFactoryArtifacts { AllZone.getInputControl().setInput(discard); } } else { - CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); + List list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); list = CardListUtil.filter(list, CardPredicates.Presets.LANDS); AllZone.getComputerPlayer().discard(list.get(0), this); } // else @@ -216,7 +219,7 @@ class CardFactoryArtifacts { @Override public boolean canPlay() { - CardList list = card.getController().getCardsIn(ZoneType.Hand); + List list = card.getController().getCardsIn(ZoneType.Hand); list.remove(card); list = CardListUtil.filter(list, CardPredicates.Presets.LANDS); return (list.size() != 0) && super.canPlay(); @@ -247,8 +250,8 @@ class CardFactoryArtifacts { @Override public void resolve() { - final CardList topOfLibrary = card.getController().getCardsIn(ZoneType.Library); - final CardList revealed = new CardList(); + final List topOfLibrary = card.getController().getCardsIn(ZoneType.Library); + final List revealed = new ArrayList(); if (topOfLibrary.size() == 0) { return; @@ -343,7 +346,7 @@ class CardFactoryArtifacts { final int limit = 4; // at most, this can target 4 cards final Player player = this.getTargetPlayer(); - CardList lands = player.getCardsIn(ZoneType.Graveyard); + List lands = player.getCardsIn(ZoneType.Graveyard); lands = CardListUtil.filter(lands, Presets.BASIC_LANDS); if (card.getController().isHuman()) { // now, select up to four lands @@ -373,7 +376,7 @@ class CardFactoryArtifacts { } else { // Computer // based on current AI, computer should always target // himself. - final CardList list = this.getComputerLands(); + final List list = this.getComputerLands(); int max = list.size(); if (max > limit) { max = limit; @@ -387,8 +390,8 @@ class CardFactoryArtifacts { player.addSlowtripList(card); } - private CardList getComputerLands() { - final CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard); + private List getComputerLands() { + final List list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard); return CardListUtil.filter(list, CardPredicates.Presets.BASIC_LANDS); } } @@ -426,8 +429,8 @@ class CardFactoryArtifacts { @Override public boolean canPlayAI() { - final CardList libList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Library); - // CardList list = + final List libList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Library); + // List list = // AllZoneUtil.getCardsInPlay("Painter's Servant"); return libList.size() > 0; // && list.size() > 0; } @@ -435,10 +438,10 @@ class CardFactoryArtifacts { @Override public void resolve() { final Player target = this.getTargetPlayer(); - final CardList library = this.getTargetPlayer().getCardsIn(ZoneType.Library); + final List library = this.getTargetPlayer().getCardsIn(ZoneType.Library); boolean loop = true; - final CardList grinding = new CardList(); + final List grinding = new ArrayList(); do { grinding.clear(); @@ -544,7 +547,7 @@ class CardFactoryArtifacts { if (card.getController().isHuman()) { AllZone.getInputControl().setInput(new Input() { private static final long serialVersionUID = -2305549394512889450L; - private final CardList exiled = new CardList(); + private final List exiled = new ArrayList(); @Override public void showMessage() { diff --git a/src/main/java/forge/card/cardfactory/CardFactoryAuras.java b/src/main/java/forge/card/cardfactory/CardFactoryAuras.java index 3b1b2d2b2f1..5d43ecd3ce1 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryAuras.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryAuras.java @@ -19,6 +19,7 @@ package forge.card.cardfactory; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import com.esotericsoftware.minlog.Log; import com.google.common.base.Predicate; @@ -27,7 +28,7 @@ import com.google.common.collect.Iterables; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates.Presets; import forge.CardUtil; @@ -84,7 +85,7 @@ class CardFactoryAuras { } final String[] landTypes = new String[] { "Plains", "Island", "Swamp", "Mountain", "Forest" }; final HashMap humanLandCount = new HashMap(); - final CardList humanlands = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()); + final List humanlands = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()); for (final String landType : landTypes) { humanLandCount.put(landType, 0); @@ -112,7 +113,7 @@ class CardFactoryAuras { } newType[0] = landTypes[minAt]; - CardList list = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()); + List list = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()); list = CardListUtil.getNotType(list, newType[0]); // Don't enchant lands // that already have the // type @@ -247,7 +248,7 @@ class CardFactoryAuras { @Override public void showMessage() { - final CardList land = AllZoneUtil.getLandsInPlay(); + final List land = AllZoneUtil.getLandsInPlay(); this.stopSetNext(CardFactoryUtil .inputTargetSpecific(spell, land, "Select target land", true, false)); } @@ -265,7 +266,7 @@ class CardFactoryAuras { @Override public boolean canPlayAI() { - CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + List list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); list = CardListUtil.getKeyword(list, "Flying"); if (list.isEmpty()) { return false; @@ -369,13 +370,13 @@ class CardFactoryAuras { @Override public boolean canPlayAI() { - final CardList stuffy = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield, "Stuffy Doll"); + final List stuffy = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield, "Stuffy Doll"); if (stuffy.size() > 0) { this.setTargetCard(stuffy.get(0)); return true; } else { - final CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + final List list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); if (list.isEmpty()) { return false; @@ -420,7 +421,7 @@ class CardFactoryAuras { final SpellPermanent animate = new SpellPermanent(card) { private static final long serialVersionUID = 7126615291288065344L; - public CardList getCreturesInGrave() { + public List getCreturesInGrave() { // This includes creatures Animate Dead can't enchant once // in play. // The human may try to Animate them, the AI will not. @@ -434,7 +435,7 @@ class CardFactoryAuras { @Override public boolean canPlayAI() { - CardList cList = this.getCreturesInGrave(); + List cList = this.getCreturesInGrave(); // AI will only target something that will stick in play. cList = CardListUtil.getTargetableCards(cList, this); if (cList.size() == 0) { diff --git a/src/main/java/forge/card/cardfactory/CardFactoryCreatures.java b/src/main/java/forge/card/cardfactory/CardFactoryCreatures.java index 95d0a67d228..296bf140a50 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryCreatures.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryCreatures.java @@ -31,7 +31,7 @@ import forge.AllZone; import forge.AllZoneUtil; import forge.Card; import forge.CardCharacteristicName; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.CardPredicates.Presets; @@ -77,7 +77,7 @@ public class CardFactoryCreatures { @Override public boolean canPlayAI() { - final CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + final List list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); return Iterables.any(list, Predicates.or(CardPredicates.nameEquals("Glorious Anthem"), CardPredicates.nameEquals("Gaea's Anthem"))); } }; @@ -120,7 +120,7 @@ public class CardFactoryCreatures { @Override public void chooseTargetAI() { - CardList perms = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List perms = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); perms = CardListUtil.filter(CardListUtil.getTargetableCards(perms, this), new Predicate() { @Override public boolean apply(final Card c) { @@ -133,7 +133,7 @@ public class CardFactoryCreatures { @Override public boolean canPlayAI() { - CardList perms = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List perms = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); perms = CardListUtil.filter(CardListUtil.getTargetableCards(perms, this), new Predicate() { @Override public boolean apply(final Card c) { @@ -178,7 +178,7 @@ public class CardFactoryCreatures { final SpellAbility ability = new Ability(card, "0") { @Override public void resolve() { - final CardList hand = card.getController().getCardsIn(ZoneType.Hand); + final List hand = card.getController().getCardsIn(ZoneType.Hand); if (hand.size() == 0) { Singletons.getModel().getGameAction().sacrifice(card, null); } else { @@ -215,7 +215,7 @@ public class CardFactoryCreatures { public void execute() { if (card.getController().isHuman()) { - final CardList artifacts = CardListUtil.filter(AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.ARTIFACTS); + final List artifacts = CardListUtil.filter(AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.ARTIFACTS); if (artifacts.size() != 0) { final Card c = GuiChoose.one("Select an artifact put a phylactery counter on", artifacts); @@ -225,10 +225,10 @@ public class CardFactoryCreatures { } } else { // computer - CardList art = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List art = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); art = CardListUtil.filter(art, Presets.ARTIFACTS); - CardList list = new CardList(art); + List list = new ArrayList(art); list = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { @@ -272,7 +272,7 @@ public class CardFactoryCreatures { // TODO - this needs to be targeted final Player opp = card.getController().getOpponent(); - CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = list.getValidCards("Card.Other+YouCtrl".split(","), card.getController(), card); for (final Card c : list) { @@ -315,7 +315,7 @@ public class CardFactoryCreatures { } else { // AI chooses the color that appears in the keywords of // the most cards in its deck, hand and on battlefield - final CardList list = new CardList(); + final List list = new ArrayList(); list.addAll(AllZone.getComputerPlayer().getCardsIn(ZoneType.Library)); list.addAll(AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand)); list.addAll(AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield)); @@ -360,7 +360,7 @@ public class CardFactoryCreatures { final Ability ability = new Ability(card, "0") { @Override public void resolve() { - final CardList cl = CardFactoryUtil.makeToken("Stangg Twin", "RG 3 4 Stangg Twin", + final List cl = CardFactoryUtil.makeToken("Stangg Twin", "RG 3 4 Stangg Twin", card.getController(), "R G", new String[] { "Legendary", "Creature", "Human", "Warrior" }, 3, 4, new String[] { "" }); @@ -397,7 +397,7 @@ public class CardFactoryCreatures { @Override public void execute() { - final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Stangg Twin"); + final List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Stangg Twin"); if (list.size() == 1) { Singletons.getModel().getGameAction().exile(list.get(0)); @@ -423,7 +423,7 @@ public class CardFactoryCreatures { @Override public void resolve() { - CardList allTokens = AllZoneUtil.getCreaturesInPlay(card.getController()); + List allTokens = AllZoneUtil.getCreaturesInPlay(card.getController()); allTokens = CardListUtil.filter(allTokens, Presets.TOKEN); CardFactoryUtil.copyTokens(allTokens); @@ -431,7 +431,7 @@ public class CardFactoryCreatures { @Override public boolean canPlayAI() { - CardList allTokens = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); + List allTokens = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); allTokens = CardListUtil.filter(allTokens, Presets.TOKEN); return allTokens.size() >= 2; @@ -470,7 +470,7 @@ public class CardFactoryCreatures { lifeGain = CardFactoryUtil.getNumberOfPermanentsByColor((String) o); } else { - final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); final String color = CardFactoryUtil.getMostProminentColor(list); lifeGain = CardFactoryUtil.getNumberOfPermanentsByColor(color); } @@ -506,7 +506,7 @@ public class CardFactoryCreatures { return; } - final CardList cl = new CardList(); + final List cl = new ArrayList(); cl.add(lib.get(0)); GuiChoose.oneOrNone("Top card", cl); @@ -553,7 +553,7 @@ public class CardFactoryCreatures { return false; } - CardList targetables = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + List targetables = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); targetables = CardListUtil.filter(CardListUtil.getTargetableCards(targetables, this), new Predicate() { @Override @@ -574,7 +574,7 @@ public class CardFactoryCreatures { @Override public void resolve() { - CardList wolves = CardListUtil.getType(card.getController().getCardsIn(ZoneType.Battlefield), "Wolf"); + List wolves = CardListUtil.getType(card.getController().getCardsIn(ZoneType.Battlefield), "Wolf"); wolves = CardListUtil.filter(wolves, untappedCreature); final Card target = this.getTargetCard(); @@ -607,7 +607,7 @@ public class CardFactoryCreatures { })); } } else { // AI Choose spread Damage - final CardList damageableWolves = CardListUtil.filter(wolves, new Predicate() { + final List damageableWolves = CardListUtil.filter(wolves, new Predicate() { @Override public boolean apply(final Card c) { return (c.predictDamage(target.getNetAttack(), target, false) > 0); @@ -620,7 +620,7 @@ public class CardFactoryCreatures { return; } - CardList wolvesLeft = CardListUtil.filter(damageableWolves, new Predicate() { + List wolvesLeft = CardListUtil.filter(damageableWolves, new Predicate() { @Override public boolean apply(final Card c) { return !c.hasKeyword("Indestructible"); @@ -647,7 +647,7 @@ public class CardFactoryCreatures { } else { // Add -1/-1s to Random Indestructibles if (target.hasKeyword("Infect") || target.hasKeyword("Wither")) { - final CardList indestructibles = CardListUtil.filter(damageableWolves, new Predicate() { + final List indestructibles = CardListUtil.filter(damageableWolves, new Predicate() { @Override public boolean apply(final Card c) { return c.hasKeyword("Indestructible"); @@ -742,14 +742,14 @@ public class CardFactoryCreatures { if (AllZone.getHumanPlayer().getLife() < card.getCounters(Counters.P1P1)) { this.setTargetPlayer(AllZone.getHumanPlayer()); } else { - final CardList list = this.getCreature(); + final List list = this.getCreature(); CardListUtil.shuffle(list); this.setTargetCard(list.get(0)); } } // chooseTargetAI() - CardList getCreature() { - CardList list = CardFactoryUtil.getHumanCreatureAI(this, true); + List getCreature() { + List list = CardFactoryUtil.getHumanCreatureAI(this, true); list = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { @@ -804,7 +804,7 @@ public class CardFactoryCreatures { } // resolve() public int countKithkin() { - CardList kithkin = card.getController().getCardsIn(ZoneType.Battlefield); + List kithkin = card.getController().getCardsIn(ZoneType.Battlefield); kithkin = CardListUtil.filter(kithkin, new Predicate() { @Override @@ -915,7 +915,7 @@ public class CardFactoryCreatures { public boolean canPlayAI() { // Dark Depths: - CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield, "Dark Depths"); + List list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield, "Dark Depths"); list = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card crd) { @@ -973,7 +973,7 @@ public class CardFactoryCreatures { int intermSumPower = 0; int intermSumToughness = 0; // intermSumPower = intermSumToughness = 0; - CardList creats = card.getController().getCardsIn(ZoneType.Graveyard); + List creats = card.getController().getCardsIn(ZoneType.Graveyard); creats = CardListUtil.filter(creats, new Predicate() { @Override public boolean apply(final Card c) { @@ -1025,7 +1025,7 @@ public class CardFactoryCreatures { @Override public boolean canPlayAI() { // get all creatures - CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard); + List list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard); list = CardListUtil.filter(list, Presets.CREATURES); return 0 < list.size(); } @@ -1047,12 +1047,12 @@ public class CardFactoryCreatures { final Player player = card.getController(); final Player opp = player.getOpponent(); int max = 0; - CardList play = opp.getCardsIn(ZoneType.Battlefield); + List play = opp.getCardsIn(ZoneType.Battlefield); play = CardListUtil.filter(play, Presets.NON_TOKEN); play = CardListUtil.filter(play, Presets.WHITE); max += play.size(); - CardList grave = opp.getCardsIn(ZoneType.Graveyard); + List grave = opp.getCardsIn(ZoneType.Graveyard); grave = CardListUtil.filter(grave, Presets.WHITE); max += grave.size(); @@ -1099,7 +1099,7 @@ public class CardFactoryCreatures { } private static void getCard_YoseiTheMorningStar(final Card card, final String cardName) { - final CardList targetPerms = new CardList(); + final List targetPerms = new ArrayList(); final SpellAbility ability = new Ability(card, "0") { @Override public void resolve() { @@ -1193,7 +1193,7 @@ public class CardFactoryCreatures { @Override public void execute() { final Player player = card.getController(); - final CardList list = CardFactoryUtil.getHumanCreatureAI(ability, true); + final List list = CardFactoryUtil.getHumanCreatureAI(ability, true); if (player.isHuman()) { AllZone.getInputControl().setInput(playerInput); @@ -1210,7 +1210,7 @@ public class CardFactoryCreatures { private static void getCard_PhyrexianDreadnought(final Card card, final String cardName) { final Player player = card.getController(); - final CardList toSac = new CardList(); + final List toSac = new ArrayList(); final Ability sacOrSac = new Ability(card, "") { @Override @@ -1321,11 +1321,11 @@ public class CardFactoryCreatures { // name a card final String choice = JOptionPane.showInputDialog(null, "Name a card", cardName, JOptionPane.QUESTION_MESSAGE); - final CardList hand = this.getTargetPlayer().getCardsIn(ZoneType.Hand); + final List hand = this.getTargetPlayer().getCardsIn(ZoneType.Hand); int numCards = card.getXManaCostPaid(); numCards = Math.min(hand.size(), numCards); - final CardList revealed = new CardList(); + final List revealed = new ArrayList(); for (int i = 0; i < numCards; i++) { final Card random = CardUtil.getRandom(hand); revealed.add(random); diff --git a/src/main/java/forge/card/cardfactory/CardFactoryEnchantments.java b/src/main/java/forge/card/cardfactory/CardFactoryEnchantments.java index 22ed40deb53..05f8e67edf1 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryEnchantments.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryEnchantments.java @@ -1,9 +1,11 @@ package forge.card.cardfactory; +import java.util.List; + import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.Command; import forge.GameActionUtil; @@ -68,8 +70,8 @@ class CardFactoryEnchantments { @Override public boolean canPlay() { - final CardList grave = AllZone.getHumanPlayer().getCardsIn(ZoneType.Graveyard); - final CardList aiGrave = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard); + final List grave = AllZone.getHumanPlayer().getCardsIn(ZoneType.Graveyard); + final List aiGrave = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard); return ((CardListUtil.getType(grave, "Creature").size() > 1) || (CardListUtil.getType(aiGrave, "Creature").size() > 1)) && super.canPlay(); } @@ -81,8 +83,8 @@ class CardFactoryEnchantments { @Override public void showMessage() { - CardList grave = AllZone.getHumanPlayer().getCardsIn(ZoneType.Graveyard); - CardList aiGrave = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard); + List grave = AllZone.getHumanPlayer().getCardsIn(ZoneType.Graveyard); + List aiGrave = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard); grave = CardListUtil.filter(grave, CardPredicates.Presets.CREATURES); aiGrave = CardListUtil.filter(aiGrave, CardPredicates.Presets.CREATURES); @@ -90,7 +92,7 @@ class CardFactoryEnchantments { this.once = false; this.stop(); } else { - CardList chooseGrave; + List chooseGrave; if (grave.size() < 2) { chooseGrave = aiGrave; } else if (aiGrave.size() < 2) { @@ -102,7 +104,7 @@ class CardFactoryEnchantments { final Card c = GuiChoose.one("Choose first creature to exile", chooseGrave); if (c != null) { - CardList newGrave = CardListUtil.filter(c.getOwner().getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES); + List newGrave = CardListUtil.filter(c.getOwner().getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES); newGrave.remove(c); final Object o2 = GuiChoose.one("Choose second creature to exile", newGrave); @@ -148,8 +150,8 @@ class CardFactoryEnchantments { @Override public boolean canPlayAI() { - final CardList compCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); - final CardList humCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + final List compCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); + final List humCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); // only play standstill if comp controls more creatures than // human diff --git a/src/main/java/forge/card/cardfactory/CardFactoryInstants.java b/src/main/java/forge/card/cardfactory/CardFactoryInstants.java index 63cb5ad1868..c9bd0b964b5 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryInstants.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryInstants.java @@ -17,6 +17,7 @@ */ package forge.card.cardfactory; +import java.util.ArrayList; import java.util.List; import com.google.common.base.Predicate; @@ -25,7 +26,7 @@ import com.google.common.collect.Iterables; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.CardPredicates.Presets; @@ -94,7 +95,7 @@ public class CardFactoryInstants { @Override public void resolve() { Player player = getTargetPlayer(); - CardList artifacts = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List artifacts = AllZoneUtil.getCardsIn(ZoneType.Battlefield); artifacts = CardListUtil.filter(artifacts, CardPredicates.Presets.ARTIFACTS); for (int i = 0; i < artifacts.size(); i++) { @@ -128,8 +129,8 @@ public class CardFactoryInstants { } public void humanResolve() { - final CardList libraryList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Library); - final CardList selectedCards = new CardList(); + final List libraryList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Library); + final List selectedCards = new ArrayList(); Object o = GuiChoose.oneOrNone("Select first card", libraryList); if (o != null) { @@ -168,8 +169,8 @@ public class CardFactoryInstants { } public void computerResolve() { - final CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Library); - final CardList selectedCards = new CardList(); + final List list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Library); + final List selectedCards = new ArrayList(); // pick best creature Card c = CardFactoryUtil.getBestCreatureAI(list); @@ -207,7 +208,7 @@ public class CardFactoryInstants { @Override public boolean canPlay() { - final CardList library = card.getController().getCardsIn(ZoneType.Library); + final List library = card.getController().getCardsIn(ZoneType.Library); return library.size() >= 3 && super.canPlay(); } @@ -234,7 +235,7 @@ public class CardFactoryInstants { final Player player = card.getController(); final int max = card.getXManaCostPaid(); - final CardList graveList = tPlayer.getCardsIn(ZoneType.Graveyard); + final List graveList = tPlayer.getCardsIn(ZoneType.Graveyard); final int x = Math.min(max, graveList.size()); if (player.isHuman()) { @@ -268,7 +269,7 @@ public class CardFactoryInstants { @Override public boolean canPlayAI() { - final CardList graveList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Graveyard); + final List graveList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Graveyard); final int maxX = ComputerUtil.getAvailableMana(true).size() - 1; return (maxX >= 3) && (graveList.size() > 0); @@ -309,7 +310,7 @@ public class CardFactoryInstants { // the siren flag final Player player = card.getController(); final Player opponent = player.getOpponent(); - final CardList creatures = AllZoneUtil.getCreaturesInPlay(opponent); + final List creatures = AllZoneUtil.getCreaturesInPlay(opponent); for (final Card creature : creatures) { // skip walls, skip creatures with summoning sickness // also skip creatures with haste if they came onto the @@ -325,7 +326,7 @@ public class CardFactoryInstants { public void resolve() { final Player player = card.getController(); final Player opponent = player.getOpponent(); - final CardList creatures = AllZoneUtil.getCreaturesInPlay(opponent); + final List creatures = AllZoneUtil.getCreaturesInPlay(opponent); for (final Card creature : creatures) { // System.out.println("Siren's Call - EOT - "+creature.getName() @@ -385,7 +386,7 @@ public class CardFactoryInstants { @Override public void resolve() { final PlayerZone lib = card.getController().getZone(ZoneType.Library); - final CardList choices = new CardList(); + final List choices = new ArrayList(); for (int i = 0; (i < 3) && (lib.size() > 0); i++) { choices.add(lib.get(i)); } @@ -422,8 +423,8 @@ public class CardFactoryInstants { @Override public void resolve() { final Player you = card.getController(); - final CardList ens = CardListUtil.filter(AllZoneUtil.getCardsIn(ZoneType.Battlefield), Presets.ENCHANTMENTS); - final CardList toReturn = CardListUtil.filter(ens, new Predicate() { + final List ens = CardListUtil.filter(AllZoneUtil.getCardsIn(ZoneType.Battlefield), Presets.ENCHANTMENTS); + final List toReturn = CardListUtil.filter(ens, new Predicate() { @Override public boolean apply(final Card c) { final Card enchanting = c.getEnchantingCard(); @@ -480,7 +481,7 @@ public class CardFactoryInstants { final String[] choices = new String[] { "Artifact", "Creature", "Land" }; final Object o = GuiChoose.one("Select permanent type", choices); final String cardType = (String) o; - final CardList list = CardListUtil.getType(this.getTargetPlayer().getCardsIn(ZoneType.Battlefield), cardType); + final List list = CardListUtil.getType(this.getTargetPlayer().getCardsIn(ZoneType.Battlefield), cardType); final String[] tapOrUntap = new String[] { "Tap", "Untap" }; final Object z = GuiChoose.one("Tap or Untap?", tapOrUntap); diff --git a/src/main/java/forge/card/cardfactory/CardFactoryLands.java b/src/main/java/forge/card/cardfactory/CardFactoryLands.java index b454ce91315..7166e4f5937 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryLands.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryLands.java @@ -17,6 +17,9 @@ */ package forge.card.cardfactory; +import java.util.ArrayList; +import java.util.List; + import javax.swing.JOptionPane; import com.google.common.base.Predicate; @@ -24,7 +27,7 @@ import com.google.common.base.Predicate; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.CardPredicates.Presets; @@ -162,7 +165,7 @@ class CardFactoryLands { private static final long serialVersionUID = 1416258136308898492L; - private final CardList inPlay = new CardList(); + private final List inPlay = new ArrayList(); @Override public boolean canPlayAI() { @@ -292,11 +295,11 @@ class CardFactoryLands { @Override public void execute() { - final CardList land = CardListUtil.getValidCards(this.player.getCardsIn(ZoneType.Battlefield), type[0], this.player, card); + final List land = CardListUtil.getValidCards(this.player.getCardsIn(ZoneType.Battlefield), type[0], this.player, card); if (this.player.isComputer()) { if (land.size() > 0) { - CardList tappedLand = new CardList(land); + List tappedLand = new ArrayList(land); tappedLand = CardListUtil.filter(tappedLand, Presets.TAPPED); // if any are tapped, sacrifice it // else sacrifice random @@ -355,7 +358,7 @@ class CardFactoryLands { @Override public void execute() { final Player player = card.getController(); - final CardList land = player.getCardsIn(ZoneType.Battlefield, "Sheltered Valley"); + final List land = player.getCardsIn(ZoneType.Battlefield, "Sheltered Valley"); land.remove(card); if (land.size() > 0) { @@ -377,12 +380,12 @@ class CardFactoryLands { @Override public void execute() { - CardList plains = AllZoneUtil.getPlayerLandsInPlay(card.getController()); + List plains = AllZoneUtil.getPlayerLandsInPlay(card.getController()); plains = CardListUtil.filter(plains, Presets.UNTAPPED); if (this.player.isComputer()) { if (plains.size() > 1) { - CardList tappedPlains = CardListUtil.filter(plains, CardPredicates.Presets.BASIC_LANDS); + List tappedPlains = CardListUtil.filter(plains, CardPredicates.Presets.BASIC_LANDS); for (final Card c : tappedPlains) { Singletons.getModel().getGameAction().sacrifice(c, null); } @@ -487,7 +490,7 @@ class CardFactoryLands { } public void computerExecute() { - CardList hand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); + List hand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); hand = CardListUtil.getType(hand, type); if (hand.size() > 0) { this.revealCard(hand.get(0)); @@ -671,12 +674,12 @@ class CardFactoryLands { @Override public void execute() { final Player player = card.getController(); - CardList land = AllZoneUtil.getPlayerLandsInPlay(player); + List land = AllZoneUtil.getPlayerLandsInPlay(player); land = land.getNotType("Lair"); if (player.isComputer()) { if (land.size() > 0) { - CardList tappedLand = new CardList(land); + List tappedLand = new ArrayList(land); tappedLand = tappedLand.filter(CardListFilter.TAPPED); if (tappedLand.size() > 0) { Singletons.getModel().getGameAction().moveToHand(CardFactoryUtil.getWorstLand(tappedLand)); @@ -745,7 +748,7 @@ class CardFactoryLands { final Player player = card.getController(); final StringBuilder sb = new StringBuilder(); sb.append(type[0]).append(".untapped"); - final CardList land = player.getCardsIn(ZoneType.Battlefield) + final List land = player.getCardsIn(ZoneType.Battlefield) .getValidCards(sb.toString(), player, card); if (player.isComputer()) { diff --git a/src/main/java/forge/card/cardfactory/CardFactorySorceries.java b/src/main/java/forge/card/cardfactory/CardFactorySorceries.java index f0fa1b39253..94f30b0d650 100644 --- a/src/main/java/forge/card/cardfactory/CardFactorySorceries.java +++ b/src/main/java/forge/card/cardfactory/CardFactorySorceries.java @@ -33,7 +33,7 @@ import com.google.common.collect.Iterables; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.CardPredicates.Presets; @@ -80,9 +80,9 @@ public class CardFactorySorceries { Card choice = null; // check for no cards in hand on resolve - final CardList lib = card.getController().getCardsIn(ZoneType.Library); - final CardList cards = new CardList(); - final CardList exiled = new CardList(); + final List lib = card.getController().getCardsIn(ZoneType.Library); + final List cards = new ArrayList(); + final List exiled = new ArrayList(); if (lib.size() == 0) { JOptionPane.showMessageDialog(null, "No more cards in library.", "", JOptionPane.INFORMATION_MESSAGE); @@ -99,8 +99,8 @@ public class CardFactorySorceries { exiled.add(lib.get(i)); Singletons.getModel().getGameAction().exile(lib.get(i)); } - final CardList pile1 = new CardList(); - final CardList pile2 = new CardList(); + final List pile1 = new ArrayList(); + final List pile2 = new ArrayList(); boolean stop = false; int pile1CMC = 0; int pile2CMC = 0; @@ -212,7 +212,7 @@ public class CardFactorySorceries { JOptionPane.DEFAULT_OPTION, JOptionPane.INFORMATION_MESSAGE, null, possibleValues, possibleValues[0]); - CardList chosen; + List chosen; if (q.equals(0)) { chosen = pile1; } else { @@ -247,7 +247,7 @@ public class CardFactorySorceries { @Override public boolean canPlayAI() { - final CardList cards = AllZone.getComputerPlayer().getCardsIn(ZoneType.Library); + final List cards = AllZone.getComputerPlayer().getCardsIn(ZoneType.Library); return cards.size() >= 8; } }; // SpellAbility @@ -262,7 +262,7 @@ public class CardFactorySorceries { @Override public void resolve() { - final CardList all = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List all = AllZoneUtil.getCardsIn(ZoneType.Battlefield); final int soldiers = card.getXManaCostPaid(); for (int i = 0; i < soldiers; i++) { CardFactoryUtil.makeToken("Soldier", "W 1 1 Soldier", card.getController(), "W", new String[] { @@ -280,8 +280,8 @@ public class CardFactorySorceries { @Override public boolean canPlayAI() { - final CardList human = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); - final CardList computer = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); + final List human = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + final List computer = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); // the computer will at least destroy 2 more human creatures return ((computer.size() < (human.size() - 1)) || ((AllZone.getComputerPlayer().getLife() < 7) && !human @@ -297,15 +297,15 @@ public class CardFactorySorceries { @Override public boolean canPlayAI() { - CardList humTokenCreats = CardListUtil.filter(AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()), Presets.TOKEN); - CardList compTokenCreats = CardListUtil.filter(AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()), Presets.TOKEN); + List humTokenCreats = CardListUtil.filter(AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()), Presets.TOKEN); + List compTokenCreats = CardListUtil.filter(AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()), Presets.TOKEN); return compTokenCreats.size() > humTokenCreats.size(); } // canPlayAI() @Override public void resolve() { - CardList tokens = AllZoneUtil.getCreaturesInPlay(); + List tokens = AllZoneUtil.getCreaturesInPlay(); tokens = CardListUtil.filter(tokens, Presets.TOKEN); CardFactoryUtil.copyTokens(tokens); @@ -327,8 +327,8 @@ public class CardFactorySorceries { } private final static SpellAbility getGlobalRuin( final Card card ) { - final CardList target = new CardList(); - final CardList saveList = new CardList(); + final List target = new ArrayList(); + final List saveList = new ArrayList(); // need to use arrays so we can declare them final and still set the // values in the input and runtime classes. This is a hack. final int[] index = new int[1]; @@ -353,10 +353,10 @@ public class CardFactorySorceries { // Vector computerBasic = new Vector(); // figure out which basic land types the computer has - CardList land = AllZoneUtil.getPlayerLandsInPlay(AllZone.getComputerPlayer()); + List land = AllZoneUtil.getPlayerLandsInPlay(AllZone.getComputerPlayer()); for (final String element : Constant.Color.BASIC_LANDS) { - final CardList cl = CardListUtil.getType(land, element); + final List cl = CardListUtil.getType(land, element); if (!cl.isEmpty()) { // remove one land of this basic type from this list // the computer AI should really jump in here and @@ -437,8 +437,8 @@ public class CardFactorySorceries { /* && !saveList.contains(c) */) { // get all other basic[count] lands human player // controls and add them to target - CardList land = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()); - CardList cl = CardListUtil.getType(land, humanBasic.get(this.count)); + List land = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()); + List cl = CardListUtil.getType(land, humanBasic.get(this.count)); cl = CardListUtil.filter(cl, new Predicate() { @Override public boolean apply(final Card crd) { @@ -485,10 +485,10 @@ public class CardFactorySorceries { countBase[0] = 0; // figure out which basic land types the human has // put those in an set to use later - final CardList land = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + final List land = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); for (final String element : Constant.Color.BASIC_LANDS) { - final CardList c = CardListUtil.getType(land, element); + final List c = CardListUtil.getType(land, element); if (!c.isEmpty()) { humanBasic.add(element); countBase[0]++; @@ -531,7 +531,7 @@ public class CardFactorySorceries { @Override public void resolve() { final Player player = this.getTargetPlayer(); - final CardList lib = player.getCardsIn(ZoneType.Library); + final List lib = player.getCardsIn(ZoneType.Library); for (final Card c : Iterables.filter(player.getCardsIn(ZoneType.Graveyard), nonBasicLands)) { for (final Card rem : Iterables.filter(lib, CardPredicates.nameEquals(c.getName()))) { @@ -611,8 +611,8 @@ public class CardFactorySorceries { @Override public void resolve() { // Lands: - final CardList humLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()); - final CardList compLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.getComputerPlayer()); + final List humLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()); + final List compLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.getComputerPlayer()); if (compLand.size() > humLand.size()) { CardListUtil.shuffle(compLand); @@ -625,8 +625,8 @@ public class CardFactorySorceries { } // Hand - final CardList humHand = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand); - final CardList compHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); + final List humHand = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand); + final List compHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); final int handDiff = Math.abs(humHand.size() - compHand.size()); if (compHand.size() > humHand.size()) { @@ -636,8 +636,8 @@ public class CardFactorySorceries { } // Creatures: - final CardList humCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); - final CardList compCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); + final List humCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + final List compCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); if (compCreats.size() > humCreats.size()) { CardListUtil.sortAttackLowFirst(compCreats); @@ -655,17 +655,17 @@ public class CardFactorySorceries { @Override public boolean canPlayAI() { int diff = 0; - final CardList humLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()); - final CardList compLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.getComputerPlayer()); + final List humLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()); + final List compLand = AllZoneUtil.getPlayerLandsInPlay(AllZone.getComputerPlayer()); diff += humLand.size() - compLand.size(); - final CardList humCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); - CardList compCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); + final List humCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + List compCreats = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); compCreats = CardListUtil.filter(compCreats, CardPredicates.Presets.CREATURES); diff += 1.5 * (humCreats.size() - compCreats.size()); - final CardList humHand = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand); - final CardList compHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); + final List humHand = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand); + final List compHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); diff += 0.5 * (humHand.size() - compHand.size()); return diff > 2; @@ -752,15 +752,15 @@ public class CardFactorySorceries { /* * We want compy to have less cards in hand than the human */ - final CardList humanHand = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand); - final CardList computerHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); + final List humanHand = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand); + final List computerHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); return computerHand.size() < humanHand.size(); } @Override public void resolve() { - final CardList humanHand = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand); - final CardList computerHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); + final List humanHand = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand); + final List computerHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); final int num = Math.max(humanHand.size(), computerHand.size()); @@ -808,7 +808,7 @@ public class CardFactorySorceries { } final HashMap countInGraveyard = new HashMap(); - final CardList allGrave = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard); + final List allGrave = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard); for (final Card c : Iterables.filter(allGrave, CardPredicates.Presets.CREATURES)) { for (final String type : c.getType()) { if (CardUtil.isACreatureType(type)) { @@ -835,7 +835,7 @@ public class CardFactorySorceries { } // Actually put everything on the battlefield - CardList bidded = CardListUtil.filter(AllZoneUtil.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES); + List bidded = CardListUtil.filter(AllZoneUtil.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES); for (final Card c : bidded) { if (c.isType(input[1]) || (!input[0].equals("") && c.isType(input[0]))) { Singletons.getModel().getGameAction().moveToPlay(c); @@ -909,7 +909,7 @@ public class CardFactorySorceries { if (maxCards == 0) { return; } - final CardList topCards = new CardList(); + final List topCards = new ArrayList(); // show top n cards: for (int j = 0; j < maxCards; j++) { topCards.add(lib.get(j)); @@ -1158,7 +1158,7 @@ public class CardFactorySorceries { @Override public void showMessage() { - CardList grave = card.getController().getCardsIn(ZoneType.Graveyard); + List grave = card.getController().getCardsIn(ZoneType.Graveyard); grave = CardListUtil.filter(grave, Presets.CREATURES); grave = CardListUtil.filter(grave, new Predicate() { @Override @@ -1306,8 +1306,8 @@ public class CardFactorySorceries { final ArrayList display = new ArrayList(); // get all - final CardList creatures = AllZoneUtil.getCreaturesInPlay(); - CardList grave = card.getController().getCardsIn(ZoneType.Graveyard); + final List creatures = AllZoneUtil.getCreaturesInPlay(); + List grave = card.getController().getCardsIn(ZoneType.Graveyard); grave = CardListUtil.filter(grave, Presets.CREATURES); if (AllZone.getHumanPlayer().canBeTargetedBy(spell) @@ -1387,7 +1387,7 @@ public class CardFactorySorceries { final Card[] newArtifact = new Card[1]; // Sacrifice an artifact - CardList arts = p.getCardsIn(ZoneType.Battlefield); + List arts = p.getCardsIn(ZoneType.Battlefield); arts = CardListUtil.filter(arts, Presets.ARTIFACTS); final Object toSac = GuiChoose.oneOrNone("Sacrifice an artifact", arts); if (toSac != null) { @@ -1399,9 +1399,9 @@ public class CardFactorySorceries { } // Search your library for an artifact - final CardList lib = p.getCardsIn(ZoneType.Library); + final List lib = p.getCardsIn(ZoneType.Library); GuiChoose.oneOrNone("Looking at Library", lib); - final CardList libArts = CardListUtil.filter(lib, Presets.ARTIFACTS); + final List libArts = CardListUtil.filter(lib, Presets.ARTIFACTS); final Object o = GuiChoose.oneOrNone("Search for artifact", libArts); if (o != null) { newArtifact[0] = (Card) o; diff --git a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java index 0b4f5614907..e0b3c73e053 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java @@ -34,7 +34,7 @@ import forge.AllZone; import forge.AllZoneUtil; import forge.Card; import forge.CardCharacteristicName; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.CardPredicates.Presets; @@ -106,8 +106,8 @@ public class CardFactoryUtil { * a boolean. * @return a {@link forge.Card} object. */ - public static Card getMostExpensivePermanentAI(final CardList list, final SpellAbility spell, final boolean targeted) { - CardList all = list; + public static Card getMostExpensivePermanentAI(final List list, final SpellAbility spell, final boolean targeted) { + List all = list; if (targeted) { all = CardListUtil.filter(all, new Predicate() { @Override @@ -127,7 +127,7 @@ public class CardFactoryUtil { * the all * @return the card */ - public static Card getMostExpensivePermanentAI(final CardList all) { + public static Card getMostExpensivePermanentAI(final List all) { if (all.size() == 0) { return null; } @@ -140,7 +140,7 @@ public class CardFactoryUtil { int curCMC = card.getCMC(); // Add all cost of all auras with the same controller - final CardList auras = new CardList(card.getEnchantedBy()); + final List auras = new ArrayList(card.getEnchantedBy()); CardListUtil.filterControlledBy(auras, card.getController()); curCMC += CardListUtil.sumCMC(auras) + auras.size(); @@ -167,7 +167,7 @@ public class CardFactoryUtil { * a boolean. * @return a {@link forge.Card} object. */ - public static Card getCheapestCreatureAI(CardList list, final SpellAbility spell, final boolean targeted) { + public static Card getCheapestCreatureAI(List list, final SpellAbility spell, final boolean targeted) { list = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { @@ -190,8 +190,8 @@ public class CardFactoryUtil { * a boolean. * @return a {@link forge.Card} object. */ - public static Card getCheapestPermanentAI(final CardList list, final SpellAbility spell, final boolean targeted) { - CardList all = list; + public static Card getCheapestPermanentAI(final List list, final SpellAbility spell, final boolean targeted) { + List all = list; if (targeted) { all = CardListUtil.filter(all, new Predicate() { @Override @@ -227,14 +227,14 @@ public class CardFactoryUtil { * a {@link forge.CardList} object. * @return a {@link forge.Card} object. */ - public static Card getBestLandAI(final CardList list) { - final CardList land = CardListUtil.filter(list, CardPredicates.Presets.LANDS); + public static Card getBestLandAI(final List list) { + final List land = CardListUtil.filter(list, CardPredicates.Presets.LANDS); if (!(land.size() > 0)) { return null; } // prefer to target non basic lands - final CardList nbLand = CardListUtil.filter(land, Predicates.not(CardPredicates.Presets.BASIC_LANDS)); + final List nbLand = CardListUtil.filter(land, Predicates.not(CardPredicates.Presets.BASIC_LANDS)); if (nbLand.size() > 0) { // TODO - Rank non basics? @@ -260,7 +260,7 @@ public class CardFactoryUtil { return null; // no basic land was a minimum } - final CardList bLand = CardListUtil.getType(land, sminBL); + final List bLand = CardListUtil.getType(land, sminBL); for( Card ut : Iterables.filter(bLand, CardPredicates.Presets.UNTAPPED) ) { @@ -285,8 +285,8 @@ public class CardFactoryUtil { * a boolean. * @return a {@link forge.Card} object. */ - public static Card getBestEnchantmentAI(final CardList list, final SpellAbility spell, final boolean targeted) { - CardList all = CardListUtil.filter(list, CardPredicates.Presets.ENCHANTMENTS); + public static Card getBestEnchantmentAI(final List list, final SpellAbility spell, final boolean targeted) { + List all = CardListUtil.filter(list, CardPredicates.Presets.ENCHANTMENTS); if (targeted) { all = CardListUtil.filter(all, new Predicate() { @@ -311,8 +311,8 @@ public class CardFactoryUtil { * a {@link forge.CardList} object. * @return a {@link forge.Card} object. */ - public static Card getBestArtifactAI(final CardList list) { - CardList all = CardListUtil.filter(list, CardPredicates.Presets.ARTIFACTS); + public static Card getBestArtifactAI(final List list) { + List all = CardListUtil.filter(list, CardPredicates.Presets.ARTIFACTS); if (all.size() == 0) { return null; } @@ -344,7 +344,7 @@ public class CardFactoryUtil { * a {@link forge.CardList} object. * @return a int. */ - public static int evaluateCreatureList(final CardList list) { + public static int evaluateCreatureList(final List list) { int value = 0; for (int i = 0; i < list.size(); i++) { value += CardFactoryUtil.evaluateCreature(list.get(i)); @@ -362,7 +362,7 @@ public class CardFactoryUtil { * a {@link forge.CardList} object. * @return a int. */ - public static int evaluatePermanentList(final CardList list) { + public static int evaluatePermanentList(final List list) { int value = 0; for (int i = 0; i < list.size(); i++) { value += list.get(i).getCMC() + 1; @@ -587,7 +587,7 @@ public class CardFactoryUtil { * a {@link forge.CardList} object. * @return a {@link forge.Card} object. */ - public static Card getBestAI(final CardList list) { + public static Card getBestAI(final List list) { // Get Best will filter by appropriate getBest list if ALL of the list // is of that type if (CardListUtil.getNotType(list, "Creature").size() == 0) { @@ -610,8 +610,8 @@ public class CardFactoryUtil { * the list * @return the card */ - public static Card getBestCreatureAI(final CardList list) { - CardList all = CardListUtil.filter(list, CardPredicates.Presets.CREATURES); + public static Card getBestCreatureAI(final List list) { + List all = CardListUtil.filter(list, CardPredicates.Presets.CREATURES); return Aggregates.itemWithMax(all, CardPredicates.Accessors.fnEvaluateCreature); } @@ -625,9 +625,9 @@ public class CardFactoryUtil { * a {@link forge.CardList} object. * @return a {@link forge.Card} object. */ - public static Card getBestCreatureToBounceAI(final CardList list) { + public static Card getBestCreatureToBounceAI(final List list) { final int tokenBonus = 40; - CardList all = CardListUtil.filter(list, CardPredicates.Presets.CREATURES); + List all = CardListUtil.filter(list, CardPredicates.Presets.CREATURES); Card biggest = null; // returns null if list.size() == 0 int biggestvalue = 0; int newvalue = 0; @@ -661,7 +661,7 @@ public class CardFactoryUtil { * a {@link forge.CardList} object. * @return a {@link forge.Card} object. */ - public static Card getWorstAI(final CardList list) { + public static Card getWorstAI(final List list) { return CardFactoryUtil.getWorstPermanentAI(list, false, false, false, false); } @@ -675,8 +675,8 @@ public class CardFactoryUtil { * a {@link forge.CardList} object. * @return a {@link forge.Card} object. */ - public static Card getWorstCreatureAI(final CardList list) { - CardList all = CardListUtil.filter(list, CardPredicates.Presets.CREATURES); + public static Card getWorstCreatureAI(final List list) { + List all = CardListUtil.filter(list, CardPredicates.Presets.CREATURES); // get smallest creature return Aggregates.itemWithMin(all, CardPredicates.Accessors.fnEvaluateCreature); } @@ -698,7 +698,7 @@ public class CardFactoryUtil { * a boolean. * @return a {@link forge.Card} object. */ - public static Card getWorstPermanentAI(final CardList list, final boolean biasEnch, final boolean biasLand, + public static Card getWorstPermanentAI(final List list, final boolean biasEnch, final boolean biasLand, final boolean biasArt, final boolean biasCreature) { if (list.size() == 0) { return null; @@ -721,7 +721,7 @@ public class CardFactoryUtil { return CardFactoryUtil.getWorstCreatureAI(CardListUtil.filter(list, CardPredicates.Presets.CREATURES)); } - CardList lands = CardListUtil.filter(list, CardPredicates.Presets.LANDS); + List lands = CardListUtil.filter(list, CardPredicates.Presets.LANDS); if (lands.size() > 6) { return CardFactoryUtil.getWorstLand(lands); } @@ -756,7 +756,7 @@ public class CardFactoryUtil { * a {@link java.lang.String} object. * @return a {@link forge.control.input.Input} object. */ - public static Input inputDestroyNoRegeneration(final CardList choices, final String message) { + public static Input inputDestroyNoRegeneration(final List choices, final String message) { final Input target = new Input() { private static final long serialVersionUID = -6637588517573573232L; @@ -1046,8 +1046,8 @@ public class CardFactoryUtil { @Override public void resolve() { - final CardList cards = sourceCard.getController().getCardsIn(ZoneType.Library); - final CardList sameCost = new CardList(); + final List cards = sourceCard.getController().getCardsIn(ZoneType.Library); + final List sameCost = new ArrayList(); for (int i = 0; i < cards.size(); i++) { if (cards.get(i).getManaCost().getCMC() == sourceCard.getManaCost().getCMC()) { @@ -1248,8 +1248,8 @@ public class CardFactoryUtil { final SpellAbility desc = new Ability(sourceCard, "0") { @Override public void resolve() { - final CardList cards = sourceCard.getController().getCardsIn(ZoneType.Graveyard); - final CardList sameCost = new CardList(); + final List cards = sourceCard.getController().getCardsIn(ZoneType.Graveyard); + final List sameCost = new ArrayList(); final int cost = CardUtil.getConvertedManaCost(manacost); for (int i = 0; i < cards.size(); i++) { if (cards.get(i).getManaCost().getCMC() <= cost && cards.get(i).isType("Spirit")) { @@ -1301,7 +1301,7 @@ public class CardFactoryUtil { return desc; } // soulshiftTrigger() - // CardList choices are the only cards the user can successful select + // List choices are the only cards the user can successful select /** *

* inputTargetSpecific. @@ -1319,12 +1319,12 @@ public class CardFactoryUtil { * a boolean. * @return a {@link forge.control.input.Input} object. */ - public static Input inputTargetSpecific(final SpellAbility spell, final CardList choices, final String message, + public static Input inputTargetSpecific(final SpellAbility spell, final List choices, final String message, final boolean targeted, final boolean free) { return CardFactoryUtil.inputTargetSpecific(spell, choices, message, Command.BLANK, targeted, free); } - // CardList choices are the only cards the user can successful select + // List choices are the only cards the user can successful select /** *

* inputTargetSpecific. @@ -1344,7 +1344,7 @@ public class CardFactoryUtil { * a boolean. * @return a {@link forge.control.input.Input} object. */ - public static Input inputTargetSpecific(final SpellAbility spell, final CardList choices, final String message, + public static Input inputTargetSpecific(final SpellAbility spell, final List choices, final String message, final Command paid, final boolean targeted, final boolean free) { final Input target = new Input() { private static final long serialVersionUID = -1779224307654698954L; @@ -1382,7 +1382,7 @@ public class CardFactoryUtil { return target; } // inputTargetSpecific() - // CardList choices are the only cards the user can successful select + // List choices are the only cards the user can successful select /** *

* inputTargetChampionSac. @@ -1402,7 +1402,7 @@ public class CardFactoryUtil { * a boolean. * @return a {@link forge.control.input.Input} object. */ - public static Input inputTargetChampionSac(final Card crd, final SpellAbility spell, final CardList choices, + public static Input inputTargetChampionSac(final Card crd, final SpellAbility spell, final List choices, final String message, final boolean targeted, final boolean free) { final Input target = new Input() { private static final long serialVersionUID = -3320425330743678663L; @@ -1459,7 +1459,7 @@ public class CardFactoryUtil { @Override public void showMessage() { // get all creatures you control - final CardList list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + final List list = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); this.stopSetNext(CardFactoryUtil.inputTargetSpecific(equip, list, "Select target creature to equip", true, false)); @@ -1481,7 +1481,7 @@ public class CardFactoryUtil { * a {@link forge.Command} object. * @return a {@link forge.control.input.Input} object. */ - public static Input masterOfTheWildHuntInputTargetCreature(final SpellAbility spell, final CardList choices, + public static Input masterOfTheWildHuntInputTargetCreature(final SpellAbility spell, final List choices, final Command paid) { final Input target = new Input() { private static final long serialVersionUID = -1779224307654698954L; @@ -1570,8 +1570,8 @@ public class CardFactoryUtil { * a boolean. * @return a {@link forge.CardList} object. */ - public static CardList getHumanCreatureAI(final SpellAbility spell, final boolean targeted) { - CardList creature = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + public static List getHumanCreatureAI(final SpellAbility spell, final boolean targeted) { + List creature = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); if (targeted) { creature = CardListUtil.getTargetableCards(creature, spell); } @@ -1607,9 +1607,9 @@ public class CardFactoryUtil { * @return a int. */ public static int getNumberOfPermanentsByColor(final String color) { - final CardList cards = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List cards = AllZoneUtil.getCardsIn(ZoneType.Battlefield); - final CardList coloredPerms = new CardList(); + final List coloredPerms = new ArrayList(); for (int i = 0; i < cards.size(); i++) { if (CardUtil.getColors(cards.get(i)).contains(color)) { @@ -1631,7 +1631,7 @@ public class CardFactoryUtil { * @return a int. */ public static int getNumberOfManaSymbolsControlledByColor(final String colorAbb, final Player player) { - final CardList cards = player.getCardsIn(ZoneType.Battlefield); + final List cards = player.getCardsIn(ZoneType.Battlefield); return CardFactoryUtil.getNumberOfManaSymbolsByColor(colorAbb, cards); } @@ -1646,7 +1646,7 @@ public class CardFactoryUtil { * a {@link forge.CardList} object. * @return a int. */ - public static int getNumberOfManaSymbolsByColor(final String colorAbb, final CardList cards) { + public static int getNumberOfManaSymbolsByColor(final String colorAbb, final List cards) { int count = 0; for (int i = 0; i < cards.size(); i++) { final Card c = cards.get(i); @@ -1850,8 +1850,8 @@ public class CardFactoryUtil { * a {@link forge.game.player.Player} object. * @return a {@link forge.CardList} object. */ - public static CardList getExternalZoneActivationCards(final Player activator) { - final CardList cl = new CardList(); + public static List getExternalZoneActivationCards(final Player activator) { + final List cl = new ArrayList(); final Player opponent = activator.getOpponent(); cl.addAll(CardFactoryUtil.getActivateablesFromZone(activator.getZone(ZoneType.Graveyard), activator)); @@ -1875,13 +1875,13 @@ public class CardFactoryUtil { * a {@link forge.game.player.Player} object. * @return a boolean. */ - public static CardList getActivateablesFromZone(final PlayerZone zone, final Player activator) { + public static List getActivateablesFromZone(final PlayerZone zone, final Player activator) { - CardList cl = new CardList(zone.getCards()); + List cl = new ArrayList(zone.getCards()); // Only check the top card of the library if (zone.is(ZoneType.Library) && !cl.isEmpty()) { - cl = new CardList(cl.get(0)); + cl = CardListUtil.createCardList(cl.get(0)); } if (activator.isPlayer(zone.getPlayer())) { @@ -2002,7 +2002,7 @@ public class CardFactoryUtil { if (l[0].contains("Valid")) { final String restrictions = l[0].replace("Valid ", ""); final String[] rest = restrictions.split(","); - CardList cardsonbattlefield = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List cardsonbattlefield = AllZoneUtil.getCardsIn(ZoneType.Battlefield); cardsonbattlefield = CardListUtil.getValidCards(cardsonbattlefield, rest, players.get(0), source); n = cardsonbattlefield.size(); @@ -2020,7 +2020,7 @@ public class CardFactoryUtil { } if (sq[0].contains("DomainPlayer")) { - final CardList someCards = new CardList(); + final List someCards = new ArrayList(); someCards.addAll(players.get(0).getCardsIn(ZoneType.Battlefield)); final String[] basic = { "Forest", "Plains", "Mountain", "Island", "Swamp" }; @@ -2210,7 +2210,7 @@ public class CardFactoryUtil { String restrictions = l[0].replace("ValidGrave ", ""); restrictions = restrictions.replace("Count$", ""); final String[] rest = restrictions.split(","); - CardList cards = AllZoneUtil.getCardsIn(ZoneType.Graveyard); + List cards = AllZoneUtil.getCardsIn(ZoneType.Graveyard); cards = CardListUtil.getValidCards(cards, rest, cardController, c); n = cards.size(); @@ -2222,7 +2222,7 @@ public class CardFactoryUtil { String restrictions = l[0].replace("Valid ", ""); restrictions = restrictions.replace("Count$", ""); final String[] rest = restrictions.split(","); - CardList cardsonbattlefield = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List cardsonbattlefield = AllZoneUtil.getCardsIn(ZoneType.Battlefield); cardsonbattlefield = CardListUtil.getValidCards(cardsonbattlefield, rest, cardController, c); n = cardsonbattlefield.size(); @@ -2249,7 +2249,7 @@ public class CardFactoryUtil { } if (l[0].contains("GreatestPowerYouControl")) { - final CardList list = AllZoneUtil.getCreaturesInPlay(c.getController()); + final List list = AllZoneUtil.getCreaturesInPlay(c.getController()); int highest = 0; for (final Card crd : list) { if (crd.getNetAttack() > highest) { @@ -2260,7 +2260,7 @@ public class CardFactoryUtil { } if (l[0].contains("GreatestPowerYouDontControl")) { - final CardList list = AllZoneUtil.getCreaturesInPlay(c.getController().getOpponent()); + final List list = AllZoneUtil.getCreaturesInPlay(c.getController().getOpponent()); int highest = 0; for (final Card crd : list) { if (crd.getNetAttack() > highest) { @@ -2271,7 +2271,7 @@ public class CardFactoryUtil { } if (l[0].contains("HighestCMCRemembered")) { - final CardList list = new CardList(); + final List list = new ArrayList(); int highest = 0; for (final Object o : c.getRemembered()) { if (o instanceof Card) { @@ -2287,7 +2287,7 @@ public class CardFactoryUtil { } if (l[0].contains("RememberedSumPower")) { - final CardList list = new CardList(); + final List list = new ArrayList(); for (final Object o : c.getRemembered()) { if (o instanceof Card) { list.add(AllZoneUtil.getCardState((Card) o)); @@ -2340,7 +2340,7 @@ public class CardFactoryUtil { return CardFactoryUtil.doXMath(c.getRegeneratedThisTurn(), m, c); } - CardList someCards = new CardList(); + List someCards = new ArrayList(); // Complex counting methods @@ -2484,13 +2484,13 @@ public class CardFactoryUtil { // Count$TopOfLibraryCMC if (sq[0].contains("TopOfLibraryCMC")) { - final CardList topcard = cardController.getCardsIn(ZoneType.Library, 1); + final List topcard = cardController.getCardsIn(ZoneType.Library, 1); return CardFactoryUtil.doXMath(CardListUtil.sumCMC(topcard), m, c); } // Count$EnchantedControllerCreatures if (sq[0].contains("EnchantedControllerCreatures")) { - CardList enchantedControllerInPlay = new CardList(); + List enchantedControllerInPlay = new ArrayList(); if (c.getEnchantingCard() != null) { enchantedControllerInPlay = c.getEnchantingCard().getController().getCardsIn(ZoneType.Battlefield); enchantedControllerInPlay = CardListUtil.getType(enchantedControllerInPlay, "Creature"); @@ -2584,7 +2584,7 @@ public class CardFactoryUtil { if (sq[0].startsWith("Devoured")) { final String validDevoured = l[0].split(" ")[1]; final Card csource = c; - CardList cl = c.getDevoured(); + List cl = c.getDevoured(); cl = CardListUtil.getValidCards(cl, validDevoured.split(","), csource.getController(), csource); return CardFactoryUtil.doXMath(cl.size(), m, c); } @@ -2605,8 +2605,8 @@ public class CardFactoryUtil { if (sq[0].contains("SumPower")) { final String[] restrictions = l[0].split("_"); final String[] rest = restrictions[1].split(","); - CardList cardsonbattlefield = AllZoneUtil.getCardsIn(ZoneType.Battlefield); - CardList filteredCards = CardListUtil.getValidCards(cardsonbattlefield, rest, cardController, c); + List cardsonbattlefield = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List filteredCards = CardListUtil.getValidCards(cardsonbattlefield, rest, cardController, c); int sumPower = 0; for (int i = 0; i < filteredCards.size(); i++) { sumPower += filteredCards.get(i).getManaCost().getCMC(); @@ -2625,8 +2625,8 @@ public class CardFactoryUtil { if (sq[0].contains("SumCMC")) { final String[] restrictions = l[0].split("_"); final String[] rest = restrictions[1].split(","); - CardList cardsonbattlefield = AllZoneUtil.getCardsIn(ZoneType.Battlefield); - CardList filteredCards = CardListUtil.getValidCards(cardsonbattlefield, rest, cardController, c); + List cardsonbattlefield = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List filteredCards = CardListUtil.getValidCards(cardsonbattlefield, rest, cardController, c); return CardListUtil.sumCMC(filteredCards); } // Count$CardNumColors @@ -2646,7 +2646,7 @@ public class CardFactoryUtil { final String[] restrictions = l[0].split("_"); final Counters cType = Counters.getType(restrictions[1]); final String[] validFilter = restrictions[2].split(","); - CardList validCards = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List validCards = AllZoneUtil.getCardsIn(ZoneType.Battlefield); validCards = CardListUtil.getValidCards(validCards, validFilter, cardController, c); int cCount = 0; for (final Card card : validCards) { @@ -2702,7 +2702,7 @@ public class CardFactoryUtil { validFilter = workingCopy[2]; } - final CardList res = CardUtil.getThisTurnEntered(destination, origin, validFilter, c); + final List res = CardUtil.getThisTurnEntered(destination, origin, validFilter, c); return CardFactoryUtil.doXMath(res.size(), m, c); } @@ -2719,7 +2719,7 @@ public class CardFactoryUtil { final String[] workingCopy = l[0].split("_"); final String validFilter = workingCopy[1]; - CardList res; + List res; if (workingCopy[0].contains("This")) { res = CardUtil.getThisTurnCast(validFilter, c); @@ -2733,7 +2733,7 @@ public class CardFactoryUtil { // Count$Morbid.. if (sq[0].startsWith("Morbid")) { - final CardList res = CardUtil.getThisTurnEntered(ZoneType.Graveyard, ZoneType.Battlefield, "Creature", c); + final List res = CardUtil.getThisTurnEntered(ZoneType.Graveyard, ZoneType.Battlefield, "Creature", c); if (res.size() > 0) { return CardFactoryUtil.doXMath(Integer.parseInt(sq[1]), m, c); } else { @@ -3053,7 +3053,7 @@ public class CardFactoryUtil { * a {@link forge.Card} object. * @return a int. */ - public static int handlePaid(final CardList paidList, final String string, final Card source) { + public static int handlePaid(final List paidList, final String string, final Card source) { if (paidList == null) { if (string.contains(".")) { final String[] splitString = string.split("\\.", 2); @@ -3081,7 +3081,7 @@ public class CardFactoryUtil { if (l.length > 1) { m[0] = l[1]; } - final CardList list = CardListUtil.getValidCards(paidList, valid, source.getController(), source); + final List list = CardListUtil.getValidCards(paidList, valid, source.getController(), source); return CardFactoryUtil.doXMath(list.size(), m, source); } @@ -3148,7 +3148,7 @@ public class CardFactoryUtil { * a {@link forge.CardList} object. * @return a {@link java.lang.String} object. */ - public static String getMostProminentCardName(final CardList list) { + public static String getMostProminentCardName(final List list) { if (list.size() == 0) { return ""; @@ -3186,7 +3186,7 @@ public class CardFactoryUtil { * a {@link forge.CardList} object. * @return a {@link java.lang.String} object. */ - public static String getMostProminentCreatureType(final CardList list) { + public static String getMostProminentCreatureType(final List list) { if (list.size() == 0) { return ""; @@ -3233,7 +3233,7 @@ public class CardFactoryUtil { * a {@link forge.CardList} object. * @return a {@link java.lang.String} object. */ - public static String getMostProminentColor(final CardList list) { + public static String getMostProminentColor(final List list) { final Map map = new HashMap(); @@ -3275,7 +3275,7 @@ public class CardFactoryUtil { * @return a int. */ public static int getUsableManaSources(final Player player) { - CardList list = player.getCardsIn(ZoneType.Battlefield); + List list = player.getCardsIn(ZoneType.Battlefield); list = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { @@ -3300,7 +3300,7 @@ public class CardFactoryUtil { * a {@link forge.game.player.Player} object. * @return a {@link forge.CardList} object. */ - public static CardList makeTokenSaproling(final Player controller) { + public static List makeTokenSaproling(final Player controller) { return CardFactoryUtil.makeToken("Saproling", "G 1 1 Saproling", controller, "G", new String[] { "Creature", "Saproling" }, 1, 1, new String[] { "" }); } @@ -3328,10 +3328,10 @@ public class CardFactoryUtil { * an array of {@link java.lang.String} objects. * @return a {@link forge.CardList} object. */ - public static CardList makeToken(final String name, final String imageName, final Player controller, + public static List makeToken(final String name, final String imageName, final Player controller, final String manaCost, final String[] types, final int baseAttack, final int baseDefense, final String[] intrinsicKeywords) { - final CardList list = new CardList(); + final List list = new ArrayList(); final Card c = new Card(); c.setName(name); c.setImageName(imageName); @@ -3382,8 +3382,8 @@ public class CardFactoryUtil { * a {@link forge.CardList} object. * @return a {@link forge.CardList} object. */ - public static CardList copyTokens(final CardList tokenList) { - final CardList list = new CardList(); + public static List copyTokens(final List tokenList) { + final List list = new ArrayList(); for (int tokenAdd = 0; tokenAdd < tokenList.size(); tokenAdd++) { final Card thisToken = tokenList.get(tokenAdd); @@ -3395,7 +3395,7 @@ public class CardFactoryUtil { final List kal = thisToken.getIntrinsicKeyword(); final String[] tokenKeywords = new String[kal.size()]; kal.toArray(tokenKeywords); - final CardList tokens = CardFactoryUtil.makeToken(thisToken.getName(), thisToken.getImageName(), + final List tokens = CardFactoryUtil.makeToken(thisToken.getName(), thisToken.getImageName(), thisToken.getController(), thisToken.getManaCost().toString(), tokenTypes, thisToken.getBaseAttack(), thisToken.getBaseDefense(), tokenKeywords); @@ -3503,7 +3503,7 @@ public class CardFactoryUtil { * @return the worst land found based on the description above */ public static Card getWorstLand(final Player player) { - final CardList lands = AllZoneUtil.getPlayerLandsInPlay(player); + final List lands = AllZoneUtil.getPlayerLandsInPlay(player); return CardFactoryUtil.getWorstLand(lands); } // end getWorstLand @@ -3516,7 +3516,7 @@ public class CardFactoryUtil { * a {@link forge.CardList} object. * @return a {@link forge.Card} object. */ - public static Card getWorstLand(final CardList lands) { + public static Card getWorstLand(final List lands) { Card worstLand = null; int maxScore = 0; // first, check for tapped, basic lands @@ -3541,7 +3541,7 @@ public class CardFactoryUtil { * a {@link forge.CardList} object. * @return a {@link forge.Card} object. */ - public static Card getRandomCard(final CardList list) { + public static Card getRandomCard(final List list) { if (list.size() == 0) { return null; } @@ -3565,7 +3565,7 @@ public class CardFactoryUtil { final boolean extraLand = player.getNumLandsPlayed() > 0; if (extraLand) { - final CardList fastbonds = player.getCardsIn(ZoneType.Battlefield, "Fastbond"); + final List fastbonds = player.getCardsIn(ZoneType.Battlefield, "Fastbond"); for (final Card f : fastbonds) { final SpellAbility ability = new Ability(f, "0") { @Override @@ -4134,7 +4134,7 @@ public class CardFactoryUtil { final Ability haunterDiesSetup = new Ability(card, "0") { @Override public void resolve() { - final CardList creats = AllZoneUtil.getCreaturesInPlay(); + final List creats = AllZoneUtil.getCreaturesInPlay(); for (int i = 0; i < creats.size(); i++) { if (!creats.get(i).canBeTargetedBy(this)) { creats.remove(i); @@ -4151,7 +4151,7 @@ public class CardFactoryUtil { AllZone.getInputControl().setInput(target); } else { // AI choosing what to haunt - final CardList oppCreats = CardListUtil.filterControlledBy(creats, AllZone.getHumanPlayer()); + final List oppCreats = CardListUtil.filterControlledBy(creats, AllZone.getHumanPlayer()); if (oppCreats.size() != 0) { haunterDiesWork.setTargetCard(CardFactoryUtil.getWorstCreatureAI(oppCreats)); } else { @@ -4610,7 +4610,7 @@ public class CardFactoryUtil { @Override public void execute() { - final CardList lands = AllZoneUtil.getPlayerLandsInPlay(card.getController()); + final List lands = AllZoneUtil.getPlayerLandsInPlay(card.getController()); lands.remove(card); if (!(lands.size() <= 2)) { // it enters the battlefield this way, and should not @@ -4639,7 +4639,7 @@ public class CardFactoryUtil { @Override public void execute() { - final CardList clICtrl = card.getOwner().getCardsIn(ZoneType.Battlefield); + final List clICtrl = card.getOwner().getCardsIn(ZoneType.Battlefield); boolean fnd = false; @@ -4695,7 +4695,7 @@ public class CardFactoryUtil { @Override public void execute() { - final CardList cardsInPlay = CardListUtil.getType(AllZoneUtil.getCardsIn(ZoneType.Battlefield), "World"); + final List cardsInPlay = CardListUtil.getType(AllZoneUtil.getCardsIn(ZoneType.Battlefield), "World"); cardsInPlay.remove(card); for (int i = 0; i < cardsInPlay.size(); i++) { Singletons.getModel().getGameAction().sacrificeDestroy(cardsInPlay.get(i)); @@ -4782,7 +4782,7 @@ public class CardFactoryUtil { @Override public void execute() { - final CardList creats = AllZoneUtil.getCreaturesInPlay(card.getController()); + final List creats = AllZoneUtil.getCreaturesInPlay(card.getController()); creats.remove(card); // System.out.println("Creats size: " + creats.size()); @@ -4851,7 +4851,7 @@ public class CardFactoryUtil { public void execute() { // Target as Modular is Destroyed if (card.getController().isComputer()) { - CardList choices = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List choices = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); choices = CardListUtil.filter(choices, new Predicate() { @Override public boolean apply(final Card c) { diff --git a/src/main/java/forge/card/cost/CostDiscard.java b/src/main/java/forge/card/cost/CostDiscard.java index 27a69906f20..dc652459646 100644 --- a/src/main/java/forge/card/cost/CostDiscard.java +++ b/src/main/java/forge/card/cost/CostDiscard.java @@ -17,9 +17,11 @@ */ package forge.card.cost; +import java.util.List; + import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.card.abilityfactory.AbilityFactory; import forge.card.spellability.SpellAbility; @@ -109,7 +111,7 @@ public class CostDiscard extends CostPartWithList { */ @Override public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost) { - CardList handList = activator.getCardsIn(ZoneType.Hand); + List handList = activator.getCardsIn(ZoneType.Hand); final String type = this.getType(); final Integer amount = this.convertAmount(); @@ -162,7 +164,7 @@ public class CostDiscard extends CostPartWithList { @Override public final boolean payHuman(final SpellAbility ability, final Card source, final CostPayment payment) { final Player activator = ability.getActivatingPlayer(); - CardList handList = activator.getCardsIn(ZoneType.Hand); + List handList = activator.getCardsIn(ZoneType.Hand); final String discType = this.getType(); final String amount = this.getAmount(); this.resetList(); @@ -235,7 +237,7 @@ public class CostDiscard extends CostPartWithList { public final boolean decideAIPayment(final SpellAbility ability, final Card source, final CostPayment payment) { final String type = this.getType(); final Player activator = ability.getActivatingPlayer(); - final CardList hand = activator.getCardsIn(ZoneType.Hand); + final List hand = activator.getCardsIn(ZoneType.Hand); this.resetList(); if (type.equals("LastDrawn")) { if (!hand.contains(activator.getLastDrawnCard())) { @@ -297,7 +299,7 @@ public class CostDiscard extends CostPartWithList { * * @return a {@link forge.control.input.Input} object. */ - public static Input inputDiscardCost(final String discType, final CardList handList, final SpellAbility sa, + public static Input inputDiscardCost(final String discType, final List handList, final SpellAbility sa, final CostPayment payment, final CostDiscard part, final int nNeeded) { final SpellAbility sp = sa; final Input target = new Input() { @@ -341,7 +343,7 @@ public class CostDiscard extends CostPartWithList { @Override public void selectCard(final Card card, final PlayerZone zone) { if (zone.is(ZoneType.Hand) && handList.contains(card)) { - // send in CardList for Typing + // send in List for Typing card.getController().discard(card, sp); part.addToList(card); handList.remove(card); diff --git a/src/main/java/forge/card/cost/CostExile.java b/src/main/java/forge/card/cost/CostExile.java index 31ac8d8e505..873275428a9 100644 --- a/src/main/java/forge/card/cost/CostExile.java +++ b/src/main/java/forge/card/cost/CostExile.java @@ -19,12 +19,13 @@ package forge.card.cost; import java.util.ArrayList; import java.util.Iterator; +import java.util.List; import javax.swing.JOptionPane; import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.GameActionUtil; import forge.Singletons; @@ -145,7 +146,7 @@ public class CostExile extends CostPartWithList { */ @Override public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost) { - CardList typeList = new CardList(); + List typeList = new ArrayList(); if (this.getFrom().equals(ZoneType.Stack)) { for (int i = 0; i < AllZone.getStack().size(); i++) { typeList.add(AllZone.getStack().peekAbility(i).getSourceCard()); @@ -201,7 +202,7 @@ public class CostExile extends CostPartWithList { final String amount = this.getAmount(); Integer c = this.convertAmount(); final Player activator = ability.getActivatingPlayer(); - CardList list = activator.getCardsIn(this.getFrom()); + List list = activator.getCardsIn(this.getFrom()); list = CardListUtil.getValidCards(list, this.getType().split(";"), activator, source); if (c == null) { final String sVar = ability.getSVar(amount); @@ -287,7 +288,7 @@ public class CostExile extends CostPartWithList { final int nNeeded) { final StringBuilder sb = new StringBuilder(); sb.append("Exile ").append(nNeeded).append(" cards from the top of your library?"); - final CardList list = sa.getActivatingPlayer().getCardsIn(ZoneType.Library, nNeeded); + final List list = sa.getActivatingPlayer().getCardsIn(ZoneType.Library, nNeeded); if (list.size() > nNeeded) { // I don't believe this is possible @@ -329,7 +330,7 @@ public class CostExile extends CostPartWithList { final CostPayment payment, final int nNeeded) { final Input target = new Input() { private static final long serialVersionUID = 734256837615635021L; - private CardList typeList; + private List typeList; @Override public void showMessage() { @@ -495,7 +496,7 @@ public class CostExile extends CostPartWithList { final Input target = new Input() { private static final long serialVersionUID = 1403915758082824694L; - private CardList typeList; + private List typeList; private int nExiles = 0; @Override diff --git a/src/main/java/forge/card/cost/CostMill.java b/src/main/java/forge/card/cost/CostMill.java index 751a2b7be5e..ad292ed1937 100644 --- a/src/main/java/forge/card/cost/CostMill.java +++ b/src/main/java/forge/card/cost/CostMill.java @@ -18,10 +18,11 @@ package forge.card.cost; import java.util.Iterator; +import java.util.List; import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.GameActionUtil; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; @@ -138,7 +139,7 @@ public class CostMill extends CostPartWithList { c = AbilityFactory.calculateAmount(source, amount, ability); } } - final CardList list = activator.getCardsIn(ZoneType.Library, c); + final List list = activator.getCardsIn(ZoneType.Library, c); if ((list == null) || (list.size() > c)) { // I don't believe this is possible diff --git a/src/main/java/forge/card/cost/CostPartWithList.java b/src/main/java/forge/card/cost/CostPartWithList.java index 065d4b9968e..627770f09a6 100644 --- a/src/main/java/forge/card/cost/CostPartWithList.java +++ b/src/main/java/forge/card/cost/CostPartWithList.java @@ -17,8 +17,11 @@ */ package forge.card.cost; +import java.util.ArrayList; +import java.util.List; + import forge.Card; -import forge.CardList; + import forge.CardUtil; import forge.card.spellability.SpellAbility; @@ -28,14 +31,14 @@ import forge.card.spellability.SpellAbility; public abstract class CostPartWithList extends CostPart { /** The list. */ - private CardList list = null; + private List list = null; /** * Gets the list. * * @return the list */ - public final CardList getList() { + public final List getList() { return this.list; } @@ -45,7 +48,7 @@ public abstract class CostPartWithList extends CostPart { * @param setList * the new list */ - public final void setList(final CardList setList) { + public final void setList(final List setList) { this.list = setList; } @@ -53,7 +56,7 @@ public abstract class CostPartWithList extends CostPart { * Reset list. */ public final void resetList() { - this.setList(new CardList()); + this.setList(new ArrayList()); } /** diff --git a/src/main/java/forge/card/cost/CostPutCounter.java b/src/main/java/forge/card/cost/CostPutCounter.java index 2abed66d6ec..7789edd1c5d 100644 --- a/src/main/java/forge/card/cost/CostPutCounter.java +++ b/src/main/java/forge/card/cost/CostPutCounter.java @@ -17,8 +17,10 @@ */ package forge.card.cost; +import java.util.List; + import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.Counters; import forge.card.abilityfactory.AbilityFactory; @@ -136,7 +138,7 @@ public class CostPutCounter extends CostPartWithList { } } else { // 3 Cards have Put a -1/-1 Counter on a Creature you control. - final CardList typeList = CardListUtil.getValidCards(activator.getCardsIn(ZoneType.Battlefield), this.getType().split(";"), activator, source); + final List typeList = CardListUtil.getValidCards(activator.getCardsIn(ZoneType.Battlefield), this.getType().split(";"), activator, source); if (typeList.size() == 0) { return false; @@ -214,7 +216,7 @@ public class CostPutCounter extends CostPartWithList { c = AbilityFactory.calculateAmount(source, this.getAmount(), ability); } - final CardList typeList = CardListUtil.getValidCards(activator.getCardsIn(ZoneType.Battlefield), this.getType().split(";"), activator, source); + final List typeList = CardListUtil.getValidCards(activator.getCardsIn(ZoneType.Battlefield), this.getType().split(";"), activator, source); Card card = null; if (this.getType().equals("Creature.YouCtrl")) { @@ -248,7 +250,7 @@ public class CostPutCounter extends CostPartWithList { final CostPutCounter costPutCounter, final int nNeeded) { final Input target = new Input() { private static final long serialVersionUID = 2685832214519141903L; - private CardList typeList; + private List typeList; private int nPut = 0; @Override diff --git a/src/main/java/forge/card/cost/CostRemoveCounter.java b/src/main/java/forge/card/cost/CostRemoveCounter.java index 4b60e286c52..2d595c472e5 100644 --- a/src/main/java/forge/card/cost/CostRemoveCounter.java +++ b/src/main/java/forge/card/cost/CostRemoveCounter.java @@ -17,8 +17,10 @@ */ package forge.card.cost; +import java.util.List; + import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.Counters; import forge.card.abilityfactory.AbilityFactory; @@ -163,7 +165,7 @@ public class CostRemoveCounter extends CostPartWithList { } } else { - final CardList typeList = CardListUtil.getValidCards(activator.getCardsIn(this.getZone()), this.getType().split(";"), activator, source); + final List typeList = CardListUtil.getValidCards(activator.getCardsIn(this.getZone()), this.getType().split(";"), activator, source); if (amount != null) { boolean payable = false; for (Card c : typeList) { @@ -316,7 +318,7 @@ public class CostRemoveCounter extends CostPartWithList { final CostRemoveCounter costRemoveCounter, final int nNeeded) { final Input target = new Input() { private static final long serialVersionUID = 2685832214519141903L; - private CardList typeList; + private List typeList; private int nRemove = 0; @Override @@ -399,7 +401,7 @@ public class CostRemoveCounter extends CostPartWithList { final CostRemoveCounter costRemoveCounter, final int nNeeded) { final Input target = new Input() { private static final long serialVersionUID = 734256837615635021L; - private CardList typeList; + private List typeList; private int nRemove = 0; @Override diff --git a/src/main/java/forge/card/cost/CostReturn.java b/src/main/java/forge/card/cost/CostReturn.java index 4d8e1e34926..c47e3b90f8b 100644 --- a/src/main/java/forge/card/cost/CostReturn.java +++ b/src/main/java/forge/card/cost/CostReturn.java @@ -17,11 +17,13 @@ */ package forge.card.cost; +import java.util.List; + import javax.swing.JOptionPane; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; @@ -107,7 +109,7 @@ public class CostReturn extends CostPartWithList { @Override public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost) { if (!this.getThis()) { - CardList typeList = activator.getCardsIn(ZoneType.Battlefield); + List typeList = activator.getCardsIn(ZoneType.Battlefield); typeList = CardListUtil.getValidCards(typeList, this.getType().split(";"), activator, source); final Integer amount = this.convertAmount(); @@ -146,7 +148,7 @@ public class CostReturn extends CostPartWithList { final String amount = this.getAmount(); Integer c = this.convertAmount(); final Player activator = ability.getActivatingPlayer(); - final CardList list = activator.getCardsIn(ZoneType.Battlefield); + final List list = activator.getCardsIn(ZoneType.Battlefield); if (c == null) { final String sVar = ability.getSVar(amount); // Generalize this @@ -213,7 +215,7 @@ public class CostReturn extends CostPartWithList { final CostReturn part, final int nNeeded) { final Input target = new Input() { private static final long serialVersionUID = 2685832214519141903L; - private CardList typeList; + private List typeList; private int nReturns = 0; @Override diff --git a/src/main/java/forge/card/cost/CostReveal.java b/src/main/java/forge/card/cost/CostReveal.java index 3393abf0779..f53b3943df1 100644 --- a/src/main/java/forge/card/cost/CostReveal.java +++ b/src/main/java/forge/card/cost/CostReveal.java @@ -17,9 +17,11 @@ */ package forge.card.cost; +import java.util.List; + import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.card.abilityfactory.AbilityFactory; import forge.card.spellability.SpellAbility; @@ -61,7 +63,7 @@ public class CostReveal extends CostPartWithList { */ @Override public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost) { - CardList handList = activator.getCardsIn(ZoneType.Hand); + List handList = activator.getCardsIn(ZoneType.Hand); final String type = this.getType(); final Integer amount = this.convertAmount(); @@ -97,7 +99,7 @@ public class CostReveal extends CostPartWithList { public final boolean decideAIPayment(final SpellAbility ability, final Card source, final CostPayment payment) { final String type = this.getType(); final Player activator = ability.getActivatingPlayer(); - CardList hand = activator.getCardsIn(ZoneType.Hand); + List hand = activator.getCardsIn(ZoneType.Hand); this.resetList(); if (this.getThis()) { @@ -159,7 +161,7 @@ public class CostReveal extends CostPartWithList { } else { Integer num = this.convertAmount(); - CardList handList = activator.getCardsIn(ZoneType.Hand); + List handList = activator.getCardsIn(ZoneType.Hand); handList = CardListUtil.getValidCards(handList, this.getType().split(";"), activator, ability.getSourceCard()); if (num == null) { @@ -245,7 +247,7 @@ public class CostReveal extends CostPartWithList { * a int. * @return a {@link forge.control.input.Input} object. */ - public static Input inputRevealCost(final String discType, final CardList handList, final CostPayment payment, + public static Input inputRevealCost(final String discType, final List handList, final CostPayment payment, final CostReveal part, final SpellAbility sa, final int nNeeded) { final Input target = new Input() { private static final long serialVersionUID = -329993322080934435L; @@ -286,7 +288,7 @@ public class CostReveal extends CostPartWithList { @Override public void selectCard(final Card card, final PlayerZone zone) { if (zone.is(ZoneType.Hand) && handList.contains(card)) { - // send in CardList for Typing + // send in List for Typing handList.remove(card); part.addToList(card); this.nReveal++; diff --git a/src/main/java/forge/card/cost/CostSacrifice.java b/src/main/java/forge/card/cost/CostSacrifice.java index c9762269a42..37aeaa1056b 100644 --- a/src/main/java/forge/card/cost/CostSacrifice.java +++ b/src/main/java/forge/card/cost/CostSacrifice.java @@ -17,11 +17,13 @@ */ package forge.card.cost; +import java.util.List; + import javax.swing.JOptionPane; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; @@ -100,7 +102,7 @@ public class CostSacrifice extends CostPartWithList { public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost) { // You can always sac all if (!this.getThis()) { - CardList typeList = activator.getCardsIn(ZoneType.Battlefield); + List typeList = activator.getCardsIn(ZoneType.Battlefield); typeList = CardListUtil.getValidCards(typeList, this.getType().split(";"), activator, source); final Integer amount = this.convertAmount(); @@ -155,7 +157,7 @@ public class CostSacrifice extends CostPartWithList { final String amount = this.getAmount(); final String type = this.getType(); final Player activator = ability.getActivatingPlayer(); - CardList list = activator.getCardsIn(ZoneType.Battlefield); + List list = activator.getCardsIn(ZoneType.Battlefield); list = CardListUtil.getValidCards(list, type.split(";"), activator, source); if (activator.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) { list = CardListUtil.getNotType(list, "Creature"); @@ -203,7 +205,7 @@ public class CostSacrifice extends CostPartWithList { if (this.getThis()) { this.getList().add(source); } else if (this.getAmount().equals("All")) { - CardList typeList = activator.getCardsIn(ZoneType.Battlefield); + List typeList = activator.getCardsIn(ZoneType.Battlefield); typeList = CardListUtil.getValidCards(typeList, this.getType().split(";"), activator, source); if (activator.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) { typeList = CardListUtil.getNotType(typeList, "Creature"); @@ -244,7 +246,7 @@ public class CostSacrifice extends CostPartWithList { * TODO */ public static void sacrificeAll(final SpellAbility sa, final CostPayment payment, final CostPart part, - final CardList typeList) { + final List typeList) { // TODO Ask First for (final Card card : typeList) { payment.getAbility().addCostToHashList(card, "Sacrificed"); @@ -272,7 +274,7 @@ public class CostSacrifice extends CostPartWithList { * @return a {@link forge.control.input.Input} object. */ public static Input sacrificeFromList(final SpellAbility sa, final CostPayment payment, final CostSacrifice part, - final CardList typeList, final int nNeeded) { + final List typeList, final int nNeeded) { final Input target = new Input() { private static final long serialVersionUID = 2685832214519141903L; private int nSacrifices = 0; diff --git a/src/main/java/forge/card/cost/CostTapType.java b/src/main/java/forge/card/cost/CostTapType.java index 1e191331bb0..4a44000da24 100644 --- a/src/main/java/forge/card/cost/CostTapType.java +++ b/src/main/java/forge/card/cost/CostTapType.java @@ -17,8 +17,10 @@ */ package forge.card.cost; +import java.util.List; + import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates.Presets; import forge.card.abilityfactory.AbilityFactory; @@ -113,7 +115,7 @@ public class CostTapType extends CostPartWithList { */ @Override public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost) { - CardList typeList = activator.getCardsIn(ZoneType.Battlefield); + List typeList = activator.getCardsIn(ZoneType.Battlefield); typeList = CardListUtil.getValidCards(typeList, this.getType().split(";"), activator, source); @@ -152,7 +154,7 @@ public class CostTapType extends CostPartWithList { */ @Override public final boolean payHuman(final SpellAbility ability, final Card source, final CostPayment payment) { - CardList typeList = ability.getActivatingPlayer().getCardsIn(ZoneType.Battlefield); + List typeList = ability.getActivatingPlayer().getCardsIn(ZoneType.Battlefield); typeList = CardListUtil.getValidCards(typeList, this.getType().split(";"), ability.getActivatingPlayer(), ability.getSourceCard()); typeList = CardListUtil.filter(typeList, Presets.UNTAPPED); final String amount = this.getAmount(); @@ -186,7 +188,7 @@ public class CostTapType extends CostPartWithList { if (c == null) { final String sVar = ability.getSVar(amount); if (sVar.equals("XChoice")) { - CardList typeList = ability.getActivatingPlayer().getCardsIn(ZoneType.Battlefield); + List typeList = ability.getActivatingPlayer().getCardsIn(ZoneType.Battlefield); typeList = CardListUtil.getValidCards(typeList, this.getType().split(";"), ability.getActivatingPlayer(), ability.getSourceCard()); typeList = CardListUtil.filter(typeList, Presets.UNTAPPED); c = typeList.size(); @@ -225,7 +227,7 @@ public class CostTapType extends CostPartWithList { * a int. * @return a {@link forge.control.input.Input} object. */ - public static Input inputTapXCost(final CostTapType tapType, final CardList cardList, final SpellAbility sa, + public static Input inputTapXCost(final CostTapType tapType, final List cardList, final SpellAbility sa, final CostPayment payment, final int nCards) { final Input target = new Input() { @@ -256,7 +258,7 @@ public class CostTapType extends CostPartWithList { @Override public void selectCard(final Card card, final PlayerZone zone) { if (zone.is(ZoneType.Battlefield) && cardList.contains(card) && card.isUntapped()) { - // send in CardList for Typing + // send in List for Typing card.tap(); tapType.addToList(card); cardList.remove(card); diff --git a/src/main/java/forge/card/cost/CostUntapType.java b/src/main/java/forge/card/cost/CostUntapType.java index 611af67d498..8df88a9ad89 100644 --- a/src/main/java/forge/card/cost/CostUntapType.java +++ b/src/main/java/forge/card/cost/CostUntapType.java @@ -17,9 +17,11 @@ */ package forge.card.cost; +import java.util.List; + import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates.Presets; import forge.card.abilityfactory.AbilityFactory; @@ -118,7 +120,7 @@ public class CostUntapType extends CostPartWithList { */ @Override public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost) { - CardList typeList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List typeList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); typeList = CardListUtil.getValidCards(typeList, this.getType().split(";"), activator, source); @@ -158,7 +160,7 @@ public class CostUntapType extends CostPartWithList { @Override public final boolean payHuman(final SpellAbility ability, final Card source, final CostPayment payment) { final boolean untap = payment.getCost().getUntap(); - CardList typeList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List typeList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); typeList = CardListUtil.getValidCards(typeList, this.getType().split(";"), ability.getActivatingPlayer(), ability.getSourceCard()); typeList = CardListUtil.filter(typeList, Presets.TAPPED); if (untap) { @@ -195,7 +197,7 @@ public class CostUntapType extends CostPartWithList { if (c == null) { final String sVar = ability.getSVar(amount); if (sVar.equals("XChoice")) { - CardList typeList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List typeList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); typeList = CardListUtil.getValidCards(typeList, this.getType().split(";"), ability.getActivatingPlayer(), ability.getSourceCard()); if (untap) { typeList.remove(source); @@ -237,7 +239,7 @@ public class CostUntapType extends CostPartWithList { * a int. * @return a {@link forge.control.input.Input} object. */ - public static Input inputUntapYCost(final CostUntapType untapType, final CardList cardList, final SpellAbility sa, + public static Input inputUntapYCost(final CostUntapType untapType, final List cardList, final SpellAbility sa, final CostPayment payment, final int nCards) { final Input target = new Input() { @@ -268,7 +270,7 @@ public class CostUntapType extends CostPartWithList { @Override public void selectCard(final Card card, final PlayerZone zone) { if (zone.is(ZoneType.Battlefield) && cardList.contains(card) && card.isTapped()) { - // send in CardList for Typing + // send in List for Typing card.untap(); untapType.addToList(card); cardList.remove(card); diff --git a/src/main/java/forge/card/cost/CostUtil.java b/src/main/java/forge/card/cost/CostUtil.java index d7682b4dd82..ed52cbec9eb 100644 --- a/src/main/java/forge/card/cost/CostUtil.java +++ b/src/main/java/forge/card/cost/CostUtil.java @@ -17,11 +17,13 @@ */ package forge.card.cost; +import java.util.ArrayList; +import java.util.List; import java.util.Random; import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.Counters; import forge.card.abilityfactory.AbilityFactory; @@ -77,14 +79,14 @@ public class CostUtil { if (!important) { return false; } - CardList auras = new CardList(source.getEnchantedBy()); + List auras = new ArrayList(source.getEnchantedBy()); if (!CardListUtil.filterControlledBy(auras, source.getController()).isEmpty()) { return false; } continue; } - CardList typeList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List typeList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); typeList = CardListUtil.getValidCards(typeList, type.split(","), source.getController(), source); if (ComputerUtil.getCardPreference(source, "SacCost", typeList) == null) { return false; @@ -119,7 +121,7 @@ public class CostUtil { continue; } - CardList typeList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List typeList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); typeList = CardListUtil.getValidCards(typeList, type.split(","), source.getController(), source); if (ComputerUtil.getCardPreference(source, "SacCost", typeList) == null) { return false; @@ -214,7 +216,7 @@ public class CostUtil { final CostDiscard disc = (CostDiscard) part; final String type = disc.getType(); - CardList typeList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); + List typeList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); if (typeList.size() > AllZone.getComputerPlayer().getMaxHandSize()) { continue; } diff --git a/src/main/java/forge/card/replacement/ReplacementEffect.java b/src/main/java/forge/card/replacement/ReplacementEffect.java index 4b81ab81883..03d53ea7a41 100644 --- a/src/main/java/forge/card/replacement/ReplacementEffect.java +++ b/src/main/java/forge/card/replacement/ReplacementEffect.java @@ -17,11 +17,13 @@ */ package forge.card.replacement; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardUtil; import forge.card.TriggerReplacementBase; @@ -253,7 +255,7 @@ public abstract class ReplacementEffect extends TriggerReplacementBase { if (this.getMapParams().containsKey("PresentPlayer")) { presentPlayer = this.getMapParams().get("PresentPlayer"); } - CardList list = new CardList(); + List list = new ArrayList(); if (presentPlayer.equals("You") || presentPlayer.equals("Any")) { list.addAll(this.getHostCard().getController().getCardsIn(presentZone)); } @@ -292,7 +294,7 @@ public abstract class ReplacementEffect extends TriggerReplacementBase { if (this.getMapParams().containsKey("PresentPlayer2")) { presentPlayer = this.getMapParams().get("PresentPlayer2"); } - CardList list = new CardList(); + List list = new ArrayList(); if (presentPlayer.equals("You") || presentPlayer.equals("Any")) { list.addAll(this.getHostCard().getController().getCardsIn(presentZone)); } @@ -352,8 +354,8 @@ public abstract class ReplacementEffect extends TriggerReplacementBase { } if (this.getMapParams().containsKey("WerewolfUntransformCondition")) { - final CardList you = CardUtil.getLastTurnCast("Card.YouCtrl", this.getHostCard()); - final CardList opp = CardUtil.getLastTurnCast("Card.YouDontCtrl", this.getHostCard()); + final List you = CardUtil.getLastTurnCast("Card.YouCtrl", this.getHostCard()); + final List opp = CardUtil.getLastTurnCast("Card.YouDontCtrl", this.getHostCard()); if (!((you.size() > 1) || (opp.size() > 1))) { return false; } diff --git a/src/main/java/forge/card/spellability/AbilityActivated.java b/src/main/java/forge/card/spellability/AbilityActivated.java index 22c7857a963..fd5d5bccc4e 100644 --- a/src/main/java/forge/card/spellability/AbilityActivated.java +++ b/src/main/java/forge/card/spellability/AbilityActivated.java @@ -18,11 +18,12 @@ package forge.card.spellability; import java.util.ArrayList; +import java.util.List; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.card.cost.Cost; import forge.card.cost.CostPayment; import forge.card.staticability.StaticAbility; @@ -93,7 +94,7 @@ public abstract class AbilityActivated extends SpellAbility implements java.io.S } // CantBeActivated static abilities - final CardList allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card ca : allp) { final ArrayList staticAbilities = ca.getStaticAbilities(); for (final StaticAbility stAb : staticAbilities) { diff --git a/src/main/java/forge/card/spellability/Spell.java b/src/main/java/forge/card/spellability/Spell.java index 2c72ab07d87..5d868acc6b5 100644 --- a/src/main/java/forge/card/spellability/Spell.java +++ b/src/main/java/forge/card/spellability/Spell.java @@ -18,11 +18,12 @@ package forge.card.spellability; import java.util.ArrayList; +import java.util.List; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.card.cardfactory.CardFactoryUtil; import forge.card.cost.Cost; @@ -121,7 +122,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable } // CantBeCast static abilities - final CardList allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); allp.add(card); for (final Card ca : allp) { final ArrayList staticAbilities = ca.getStaticAbilities(); @@ -141,7 +142,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable final Card card = this.getSourceCard(); if (card.getSVar("NeedsToPlay").length() > 0) { final String needsToPlay = card.getSVar("NeedsToPlay"); - CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = CardListUtil.getValidCards(list, needsToPlay.split(","), card.getController(), card); if (list.isEmpty()) { diff --git a/src/main/java/forge/card/spellability/SpellAbility.java b/src/main/java/forge/card/spellability/SpellAbility.java index 70d9e683186..631590627ea 100644 --- a/src/main/java/forge/card/spellability/SpellAbility.java +++ b/src/main/java/forge/card/spellability/SpellAbility.java @@ -19,10 +19,11 @@ package forge.card.spellability; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import java.util.Set; import forge.Card; -import forge.CardList; + import forge.Command; import forge.CommandArgs; import forge.GameEntity; @@ -67,8 +68,8 @@ public abstract class SpellAbility { private Card sourceCard; private Card originalHost = null; - private CardList splicedCards = null; - private CardList targetList; + private List splicedCards = null; + private List targetList; // targetList doesn't appear to be used anymore private boolean spell; @@ -108,7 +109,7 @@ public abstract class SpellAbility { private final ArrayList paidAbilities = new ArrayList(); private ArrayList optionalAdditionalCosts = new ArrayList(); - private HashMap paidLists = new HashMap(); + private HashMap> paidLists = new HashMap>(); private HashMap triggeringObjects = new HashMap(); @@ -125,7 +126,7 @@ public abstract class SpellAbility { } }; - private CardList tappedForConvoke = new CardList(); + private List tappedForConvoke = new ArrayList(); private HashMap sVars = new HashMap(); @@ -823,7 +824,7 @@ public abstract class SpellAbility { * @param hash * a {@link java.util.HashMap} object. */ - public void setPaidHash(final HashMap hash) { + public void setPaidHash(final HashMap> hash) { this.paidLists = hash; } @@ -834,7 +835,7 @@ public abstract class SpellAbility { * * @return a {@link java.util.HashMap} object. */ - public HashMap getPaidHash() { + public HashMap> getPaidHash() { return this.paidLists; } @@ -849,7 +850,7 @@ public abstract class SpellAbility { * @param str * a {@link java.lang.String} object. */ - public void setPaidList(final CardList list, final String str) { + public void setPaidList(final List list, final String str) { this.paidLists.put(str, list); } @@ -862,7 +863,7 @@ public abstract class SpellAbility { * a {@link java.lang.String} object. * @return a {@link forge.CardList} object. */ - public CardList getPaidList(final String str) { + public List getPaidList(final String str) { return this.paidLists.get(str); } @@ -878,7 +879,7 @@ public abstract class SpellAbility { */ public void addCostToHashList(final Card c, final String str) { if (!this.paidLists.containsKey(str)) { - this.paidLists.put(str, new CardList()); + this.paidLists.put(str, new ArrayList()); } this.paidLists.get(str).add(c); @@ -890,7 +891,7 @@ public abstract class SpellAbility { *

*/ public void resetPaidHash() { - this.paidLists = new HashMap(); + this.paidLists = new HashMap>(); } /** @@ -1318,7 +1319,7 @@ public abstract class SpellAbility { * * @return a {@link forge.CardList} object. */ - public CardList getTargetList() { + public List getTargetList() { return this.targetList; } @@ -1330,7 +1331,7 @@ public abstract class SpellAbility { * @param list * a {@link forge.CardList} object. */ - public void setTargetList(final CardList list) { + public void setTargetList(final List list) { // The line below started to create a null error at // forge.CardFactoryUtil.canBeTargetedBy(CardFactoryUtil.java:3329) // after ForgeSVN r2699. I hope that commenting out the line below will @@ -1736,7 +1737,7 @@ public abstract class SpellAbility { */ public void addTappedForConvoke(final Card c) { if (this.tappedForConvoke == null) { - this.tappedForConvoke = new CardList(); + this.tappedForConvoke = new ArrayList(); } this.tappedForConvoke.add(c); @@ -1747,7 +1748,7 @@ public abstract class SpellAbility { * * @return the tapped for convoke */ - public CardList getTappedForConvoke() { + public List getTappedForConvoke() { return this.tappedForConvoke; } @@ -1763,14 +1764,14 @@ public abstract class SpellAbility { /** * @return the splicedCards */ - public CardList getSplicedCards() { + public List getSplicedCards() { return splicedCards; } /** * @param splicedCard the splicedCards to set */ - public void setSplicedCards(CardList splicedCards) { + public void setSplicedCards(List splicedCards) { this.splicedCards = splicedCards; } @@ -1779,7 +1780,7 @@ public abstract class SpellAbility { */ public void addSplicedCards(Card splicedCard) { if (this.splicedCards == null) { - this.splicedCards = new CardList(); + this.splicedCards = new ArrayList(); } this.splicedCards.add(splicedCard); } diff --git a/src/main/java/forge/card/spellability/SpellAbilityCondition.java b/src/main/java/forge/card/spellability/SpellAbilityCondition.java index 8b00266ac89..2719516d517 100644 --- a/src/main/java/forge/card/spellability/SpellAbilityCondition.java +++ b/src/main/java/forge/card/spellability/SpellAbilityCondition.java @@ -17,10 +17,13 @@ */ package forge.card.spellability; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import forge.AllZoneUtil; -import forge.CardList; +import forge.Card; + import forge.CardListUtil; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; @@ -249,7 +252,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables { } if (this.getIsPresent() != null) { - CardList list = new CardList(); + List list = new ArrayList(); if (this.getPresentDefined() != null) { list.addAll(AbilityFactory.getDefinedCards(sa.getSourceCard(), this.getPresentDefined(), sa)); } else { diff --git a/src/main/java/forge/card/spellability/SpellAbilityRestriction.java b/src/main/java/forge/card/spellability/SpellAbilityRestriction.java index 5d013d238bd..23d0bd0a458 100644 --- a/src/main/java/forge/card/spellability/SpellAbilityRestriction.java +++ b/src/main/java/forge/card/spellability/SpellAbilityRestriction.java @@ -19,10 +19,12 @@ package forge.card.spellability; import java.util.ArrayList; import java.util.HashMap; +import java.util.List; + import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; @@ -353,7 +355,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables { } } if (this.getIsPresent() != null) { - CardList list = AllZoneUtil.getCardsIn(this.getPresentZone()); + List list = AllZoneUtil.getCardsIn(this.getPresentZone()); list = CardListUtil.getValidCards(list, this.getIsPresent().split(","), activator, c); diff --git a/src/main/java/forge/card/spellability/SpellAbilityStackInstance.java b/src/main/java/forge/card/spellability/SpellAbilityStackInstance.java index 2678ad6e9bf..e57b7a2be4c 100644 --- a/src/main/java/forge/card/spellability/SpellAbilityStackInstance.java +++ b/src/main/java/forge/card/spellability/SpellAbilityStackInstance.java @@ -18,9 +18,10 @@ package forge.card.spellability; import java.util.HashMap; +import java.util.List; import forge.Card; -import forge.CardList; + import forge.game.player.Player; /** @@ -49,7 +50,7 @@ public class SpellAbilityStackInstance { // When going to a SubAbility that SA has a Instance Choice object /** The tc. */ private TargetChoices tc = null; - private CardList splicedCards = null; + private List splicedCards = null; /** The activating player. */ private Player activatingPlayer = null; @@ -67,7 +68,7 @@ public class SpellAbilityStackInstance { private int xManaPaid = 0; // Other Paid things - private HashMap paidHash = new HashMap(); + private HashMap> paidHash = new HashMap>(); // Additional info // is Kicked, is Buyback diff --git a/src/main/java/forge/card/spellability/SpellPermanent.java b/src/main/java/forge/card/spellability/SpellPermanent.java index 08ed67801f3..8bb00f7e340 100644 --- a/src/main/java/forge/card/spellability/SpellPermanent.java +++ b/src/main/java/forge/card/spellability/SpellPermanent.java @@ -25,7 +25,7 @@ import com.google.common.collect.Iterables; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.Command; @@ -70,7 +70,8 @@ public class SpellPermanent extends Spell { @Override public void showMessage() { - final CardList choice = (CardList) SpellPermanent.this.championGetCreature.execute(); + @SuppressWarnings("unchecked") + final List choice = (List) SpellPermanent.this.championGetCreature.execute(); this.stopSetNext(CardFactoryUtil.inputTargetChampionSac(SpellPermanent.this.getSourceCard(), SpellPermanent.this.championAbilityComes, choice, "Select another " @@ -83,7 +84,7 @@ public class SpellPermanent extends Spell { private final CommandReturn championGetCreature = new CommandReturn() { @Override public Object execute() { - final CardList cards = SpellPermanent.this.getSourceCard().getController().getCardsIn(ZoneType.Battlefield); + final List cards = SpellPermanent.this.getSourceCard().getController().getCardsIn(ZoneType.Battlefield); return CardListUtil.getValidCards(cards, SpellPermanent.this.championValid, SpellPermanent.this.getSourceCard() .getController(), SpellPermanent.this.getSourceCard()); } @@ -97,14 +98,15 @@ public class SpellPermanent extends Spell { final Card source = this.getSourceCard(); final Player controller = source.getController(); - final CardList creature = (CardList) SpellPermanent.this.championGetCreature.execute(); + @SuppressWarnings("unchecked") + final List creature = (List) SpellPermanent.this.championGetCreature.execute(); if (creature.size() == 0) { Singletons.getModel().getGameAction().sacrifice(source, null); return; } else if (controller.isHuman()) { AllZone.getInputControl().setInput(SpellPermanent.this.championInputComes); } else { // Computer - CardList computer = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List computer = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); computer = CardListUtil.getValidCards(computer, SpellPermanent.this.championValid, controller, source); computer.remove(source); @@ -350,19 +352,19 @@ public class SpellPermanent extends Spell { // check on legendary if (card.isType("Legendary") && !AllZoneUtil.isCardInPlay("Mirror Gallery")) { - final CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + final List list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); if (Iterables.any(list, CardPredicates.nameEquals(card.getName()))) { return false; } } if (card.isPlaneswalker()) { - CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); list = CardListUtil.filter(list, CardPredicates.Presets.PLANEWALKERS); for (int i = 0; i < list.size(); i++) { List type = card.getType(); final String subtype = type.get(type.size() - 1); - final CardList cl = CardListUtil.getType(list, subtype); + final List cl = CardListUtil.getType(list, subtype); if (cl.size() > 0) { return false; @@ -370,7 +372,7 @@ public class SpellPermanent extends Spell { } } if (card.isType("World")) { - CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); list = CardListUtil.getType(list, "World"); if (list.size() > 0) { return false; @@ -389,7 +391,8 @@ public class SpellPermanent extends Spell { return false; } - final CardList cl = (CardList) this.championGetCreature.execute(); + @SuppressWarnings("unchecked") + final List cl = (List) this.championGetCreature.execute(); if ((o == null) || !(cl.size() > 0) || !this.getSourceCard().isInZone(ZoneType.Hand)) { return false; } diff --git a/src/main/java/forge/card/spellability/TargetSelection.java b/src/main/java/forge/card/spellability/TargetSelection.java index 1ccfaabac56..40785e03f1a 100644 --- a/src/main/java/forge/card/spellability/TargetSelection.java +++ b/src/main/java/forge/card/spellability/TargetSelection.java @@ -26,7 +26,7 @@ import com.google.common.base.Predicate; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.card.abilityfactory.AbilityFactory; import forge.control.input.Input; @@ -269,7 +269,7 @@ public class TargetSelection { return; } - CardList choices = CardListUtil.getTargetableCards(CardListUtil.getValidCards(AllZoneUtil + List choices = CardListUtil.getTargetableCards(CardListUtil.getValidCards(AllZoneUtil .getCardsIn(zone), this.target.getValidTgts(), this.ability.getActivatingPlayer(), this.ability.getSourceCard()), this.ability); ArrayList objects = new ArrayList(); @@ -326,7 +326,7 @@ public class TargetSelection { } } // input_targetValid - // CardList choices are the only cards the user can successful select + // List choices are the only cards the user can successful select /** *

* input_targetSpecific. @@ -342,7 +342,7 @@ public class TargetSelection { * the already targeted * @return a {@link forge.control.input.Input} object. */ - public final Input inputTargetSpecific(final CardList choices, final boolean targeted, final boolean mandatory, + public final Input inputTargetSpecific(final List choices, final boolean targeted, final boolean mandatory, final ArrayList alreadyTargeted) { final SpellAbility sa = this.ability; final TargetSelection select = this; @@ -436,7 +436,7 @@ public class TargetSelection { * @param mandatory * a boolean. */ - public final void chooseCardFromList(final CardList choices, final boolean targeted, final boolean mandatory) { + public final void chooseCardFromList(final List choices, final boolean targeted, final boolean mandatory) { // Send in a list of valid cards, and popup a choice box to target final Card dummy = new Card(); dummy.setName("[FINISH TARGETING]"); @@ -454,12 +454,12 @@ public class TargetSelection { final Card divStack = new Card(); divStack.setName("--CARDS IN LIBRARY:--"); - CardList choicesZoneUnfiltered = choices; - final CardList crdsBattle = new CardList(); - final CardList crdsExile = new CardList(); - final CardList crdsGrave = new CardList(); - final CardList crdsLibrary = new CardList(); - final CardList crdsStack = new CardList(); + List choicesZoneUnfiltered = choices; + final List crdsBattle = new ArrayList(); + final List crdsExile = new ArrayList(); + final List crdsGrave = new ArrayList(); + final List crdsLibrary = new ArrayList(); + final List crdsStack = new ArrayList(); for (final Card inZone : choicesZoneUnfiltered) { if (AllZoneUtil.getCardsIn(ZoneType.Battlefield).contains(inZone)) { crdsBattle.add(inZone); @@ -473,7 +473,7 @@ public class TargetSelection { crdsStack.add(inZone); } } - CardList choicesFiltered = new CardList(); + List choicesFiltered = new ArrayList(); if (crdsBattle.size() >= 1) { choicesFiltered.add(divBattlefield); choicesFiltered.addAll(crdsBattle); @@ -502,7 +502,7 @@ public class TargetSelection { final Target tgt = this.getTgt(); - final CardList choicesWithDone = choicesFiltered; + final List choicesWithDone = choicesFiltered; if (tgt.isMinTargetsChosen(sa.getSourceCard(), sa)) { // is there a more elegant way of doing this? choicesWithDone.add(dummy); diff --git a/src/main/java/forge/card/staticability/StaticAbility.java b/src/main/java/forge/card/staticability/StaticAbility.java index c73a6cc43db..0e051ffd523 100644 --- a/src/main/java/forge/card/staticability/StaticAbility.java +++ b/src/main/java/forge/card/staticability/StaticAbility.java @@ -514,7 +514,7 @@ public class StaticAbility { /* * if(mapParams.containsKey("isPresent")) { String isPresent = - * mapParams.get("isPresent"); CardList list = + * mapParams.get("isPresent"); List list = * AllZoneUtil.getCardsInPlay(); * * list = list.getValidCards(isPresent.split(","), controller, diff --git a/src/main/java/forge/card/staticability/StaticAbilityContinuous.java b/src/main/java/forge/card/staticability/StaticAbilityContinuous.java index 4998ba1fc3a..0985c4bbbc6 100644 --- a/src/main/java/forge/card/staticability/StaticAbilityContinuous.java +++ b/src/main/java/forge/card/staticability/StaticAbilityContinuous.java @@ -20,11 +20,12 @@ package forge.card.staticability; import java.util.ArrayList; import java.util.Arrays; import java.util.HashMap; +import java.util.List; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardUtil; import forge.StaticEffect; @@ -56,7 +57,7 @@ public class StaticAbilityContinuous { final Card hostCard = stAb.getHostCard(); final StaticEffect se = new StaticEffect(); - final CardList affectedCards = StaticAbilityContinuous.getAffectedCards(stAb); + final List affectedCards = StaticAbilityContinuous.getAffectedCards(stAb); final ArrayList affectedPlayers = StaticAbilityContinuous.getAffectedPlayers(stAb); se.setAffectedCards(affectedCards); @@ -230,7 +231,7 @@ public class StaticAbilityContinuous { } } - CardList cardsIGainedAbilitiesFrom = AllZoneUtil.getCardsIn(validZones); + List cardsIGainedAbilitiesFrom = AllZoneUtil.getCardsIn(validZones); cardsIGainedAbilitiesFrom = CardListUtil.getValidCards(cardsIGainedAbilitiesFrom, valids, hostCard.getController(), hostCard); if (cardsIGainedAbilitiesFrom.size() > 0) { @@ -417,17 +418,17 @@ public class StaticAbilityContinuous { return players; } - private static CardList getAffectedCards(final StaticAbility stAb) { + private static List getAffectedCards(final StaticAbility stAb) { final HashMap params = stAb.getMapParams(); final Card hostCard = stAb.getHostCard(); final Player controller = hostCard.getController(); if (params.containsKey("CharacteristicDefining")) { - return new CardList(hostCard); // will always be the card itself + return CardListUtil.createCardList(hostCard); // will always be the card itself } // non - CharacteristicDefining - CardList affectedCards = new CardList(); + List affectedCards = new ArrayList(); if (params.containsKey("AffectedZone")) { affectedCards.addAll(AllZoneUtil.getCardsIn(ZoneType.listValueOf(params.get("AffectedZone")))); @@ -437,13 +438,13 @@ public class StaticAbilityContinuous { if (params.containsKey("Affected") && !params.get("Affected").contains(",")) { if (params.get("Affected").contains("Self")) { - affectedCards = new CardList(hostCard); + affectedCards = CardListUtil.createCardList(hostCard); } else if (params.get("Affected").contains("EnchantedBy")) { - affectedCards = new CardList(hostCard.getEnchantingCard()); + affectedCards = CardListUtil.createCardList(hostCard.getEnchantingCard()); } else if (params.get("Affected").contains("EquippedBy")) { - affectedCards = new CardList(hostCard.getEquippingCard()); + affectedCards = CardListUtil.createCardList(hostCard.getEquippingCard()); } else if (params.get("Affected").equals("EffectSource")) { - affectedCards = new CardList(AbilityFactory.getDefinedCards(hostCard, params.get("Affected"), null)); + affectedCards = new ArrayList(AbilityFactory.getDefinedCards(hostCard, params.get("Affected"), null)); return affectedCards; } } diff --git a/src/main/java/forge/card/trigger/Trigger.java b/src/main/java/forge/card/trigger/Trigger.java index 4571979312f..ce65bbbdb1b 100644 --- a/src/main/java/forge/card/trigger/Trigger.java +++ b/src/main/java/forge/card/trigger/Trigger.java @@ -17,13 +17,14 @@ */ package forge.card.trigger; +import java.util.ArrayList; import java.util.HashMap; import java.util.List; import java.util.Map; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardUtil; import forge.Singletons; @@ -344,7 +345,7 @@ public abstract class Trigger extends TriggerReplacementBase { if (this.getMapParams().containsKey("PresentPlayer")) { presentPlayer = this.getMapParams().get("PresentPlayer"); } - CardList list = new CardList(); + List list = new ArrayList(); if (presentPlayer.equals("You") || presentPlayer.equals("Any")) { list.addAll(this.getHostCard().getController().getCardsIn(presentZone)); } @@ -383,7 +384,7 @@ public abstract class Trigger extends TriggerReplacementBase { if (this.getMapParams().containsKey("PresentPlayer2")) { presentPlayer = this.getMapParams().get("PresentPlayer2"); } - CardList list = new CardList(); + List list = new ArrayList(); if (presentPlayer.equals("You") || presentPlayer.equals("Any")) { list.addAll(this.getHostCard().getController().getCardsIn(presentZone)); } @@ -443,8 +444,8 @@ public abstract class Trigger extends TriggerReplacementBase { } if (this.getMapParams().containsKey("WerewolfUntransformCondition")) { - final CardList you = CardUtil.getLastTurnCast("Card.YouCtrl", this.getHostCard()); - final CardList opp = CardUtil.getLastTurnCast("Card.YouDontCtrl", this.getHostCard()); + final List you = CardUtil.getLastTurnCast("Card.YouCtrl", this.getHostCard()); + final List opp = CardUtil.getLastTurnCast("Card.YouDontCtrl", this.getHostCard()); if (!((you.size() > 1) || (opp.size() > 1))) { return false; } diff --git a/src/main/java/forge/card/trigger/TriggerAttackersDeclared.java b/src/main/java/forge/card/trigger/TriggerAttackersDeclared.java index 53ac53e3a15..4e649d22e13 100644 --- a/src/main/java/forge/card/trigger/TriggerAttackersDeclared.java +++ b/src/main/java/forge/card/trigger/TriggerAttackersDeclared.java @@ -18,11 +18,12 @@ package forge.card.trigger; import java.util.HashMap; +import java.util.List; import java.util.Map; import forge.Card; -import forge.CardList; + import forge.card.spellability.SpellAbility; /** @@ -49,7 +50,8 @@ public class TriggerAttackersDeclared extends Trigger { @Override public final boolean performTest(final Map runParams2) { if (this.getMapParams().containsKey("SingleAttacker")) { - final CardList attackers = (CardList) runParams2.get("Attackers"); + @SuppressWarnings("unchecked") + final List attackers = (List) runParams2.get("Attackers"); if (attackers.size() != 1) { return false; } diff --git a/src/main/java/forge/card/trigger/TriggerAttacks.java b/src/main/java/forge/card/trigger/TriggerAttacks.java index 874917cc810..cafd3f03d95 100644 --- a/src/main/java/forge/card/trigger/TriggerAttacks.java +++ b/src/main/java/forge/card/trigger/TriggerAttacks.java @@ -18,10 +18,11 @@ package forge.card.trigger; import java.util.HashMap; +import java.util.List; import java.util.Map; import forge.Card; -import forge.CardList; + import forge.GameEntity; import forge.card.spellability.SpellAbility; @@ -69,7 +70,8 @@ public class TriggerAttacks extends Trigger { } if (this.getMapParams().containsKey("Alone")) { - final CardList otherAttackers = (CardList) runParams2.get("OtherAttackers"); + @SuppressWarnings("unchecked") + final List otherAttackers = (List) runParams2.get("OtherAttackers"); if (otherAttackers == null) { return false; } diff --git a/src/main/java/forge/card/trigger/TriggerHandler.java b/src/main/java/forge/card/trigger/TriggerHandler.java index 6d37b1bea5f..84181672439 100644 --- a/src/main/java/forge/card/trigger/TriggerHandler.java +++ b/src/main/java/forge/card/trigger/TriggerHandler.java @@ -20,11 +20,12 @@ package forge.card.trigger; import java.util.ArrayList; import java.util.EnumSet; import java.util.HashMap; +import java.util.List; import java.util.Map; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.Command; import forge.CommandArgs; @@ -64,7 +65,7 @@ public class TriggerHandler { * Clean up temporary triggers. */ public final void cleanUpTemporaryTriggers() { - final CardList absolutelyAllCards = new CardList(); + final List absolutelyAllCards = new ArrayList(); absolutelyAllCards.addAll(AllZone.getHumanPlayer().getAllCards()); absolutelyAllCards.addAll(AllZone.getComputerPlayer().getAllCards()); @@ -289,7 +290,7 @@ public class TriggerHandler { // This is done to allow the list of triggers to be modified while // triggers are running. final ArrayList delayedTriggersWorkingCopy = new ArrayList(this.delayedTriggers); - CardList allCards = AllZoneUtil.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES); + List allCards = AllZoneUtil.getCardsIn(ZoneType.STATIC_ABILITIES_SOURCE_ZONES); allCards.addAll(AllZoneUtil.getCardsIn(ZoneType.Stack)); boolean checkStatics = false; @@ -521,22 +522,22 @@ public class TriggerHandler { } @Override - public void setPaidHash(final HashMap hash) { + public void setPaidHash(final HashMap> hash) { sa[0].setPaidHash(hash); } @Override - public HashMap getPaidHash() { + public HashMap> getPaidHash() { return sa[0].getPaidHash(); } @Override - public void setPaidList(final CardList list, final String str) { + public void setPaidList(final List list, final String str) { sa[0].setPaidList(list, str); } @Override - public CardList getPaidList(final String str) { + public List getPaidList(final String str) { return sa[0].getPaidList(str); } @@ -701,7 +702,7 @@ public class TriggerHandler { } @Override - public CardList getTargetList() { + public List getTargetList() { return sa[0].getTargetList(); } @@ -897,7 +898,7 @@ public class TriggerHandler { } @Override - public void setTargetList(final CardList list) { + public void setTargetList(final List list) { sa[0].setTargetList(list); } diff --git a/src/main/java/forge/control/input/InputAttack.java b/src/main/java/forge/control/input/InputAttack.java index 450cb459968..d34540a9eb1 100644 --- a/src/main/java/forge/control/input/InputAttack.java +++ b/src/main/java/forge/control/input/InputAttack.java @@ -17,11 +17,13 @@ */ package forge.control.input; +import java.util.List; + import com.google.common.collect.Iterables; import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.CardPredicates; import forge.Singletons; import forge.game.phase.CombatUtil; @@ -64,7 +66,7 @@ public class InputAttack extends Input { if (AllZone.getCombat().getRemainingDefenders() == 0) { // Nothing left to attack, has to attack this defender - CardList possibleAttackers = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + List possibleAttackers = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); for (Card c : Iterables.filter(possibleAttackers, CardPredicates.Presets.CREATURES)) { if (c.hasKeyword("CARDNAME attacks each turn if able.") && CombatUtil.canAttack(c, AllZone.getCombat()) && !c.isAttacking()) { diff --git a/src/main/java/forge/control/input/InputBlock.java b/src/main/java/forge/control/input/InputBlock.java index 21f4e5a6c37..91fc5b00a05 100644 --- a/src/main/java/forge/control/input/InputBlock.java +++ b/src/main/java/forge/control/input/InputBlock.java @@ -17,11 +17,13 @@ */ package forge.control.input; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.Singletons; import forge.game.phase.CombatUtil; import forge.game.zone.PlayerZone; @@ -44,7 +46,7 @@ public class InputBlock extends Input { private static final long serialVersionUID = 6120743598368928128L; private Card currentAttacker = null; - private final HashMap allBlocking = new HashMap(); + private final HashMap> allBlocking = new HashMap>(); /** *

@@ -110,10 +112,10 @@ public class InputBlock extends Input { && zone.is(ZoneType.Battlefield, AllZone.getHumanPlayer())) { // Create a new blockedBy list if it doesn't exist if (!this.allBlocking.containsKey(card)) { - this.allBlocking.put(card, new CardList()); + this.allBlocking.put(card, new ArrayList()); } - CardList attackersBlocked = this.allBlocking.get(card); + List attackersBlocked = this.allBlocking.get(card); if (!attackersBlocked.contains(this.currentAttacker) && CombatUtil.canBlock(this.currentAttacker, card, AllZone.getCombat())) { attackersBlocked.add(this.currentAttacker); diff --git a/src/main/java/forge/control/input/InputMulligan.java b/src/main/java/forge/control/input/InputMulligan.java index 6dcfaa5fea9..dcd83a4a1de 100644 --- a/src/main/java/forge/control/input/InputMulligan.java +++ b/src/main/java/forge/control/input/InputMulligan.java @@ -18,11 +18,12 @@ package forge.control.input; import java.util.ArrayList; +import java.util.List; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.GameAction; import forge.GameActionUtil; @@ -88,7 +89,7 @@ public class InputMulligan extends Input { * @return an int */ public final int doMulligan(final Player player, final GamePlayerRating playerRating) { - final CardList hand = player.getCardsIn(ZoneType.Hand); + final List hand = player.getCardsIn(ZoneType.Hand); for (final Card c : hand) { Singletons.getModel().getGameAction().moveToLibrary(c); } @@ -140,7 +141,7 @@ public class InputMulligan extends Input { // 0 in its hand while (aiTakesMulligan) { - final CardList handList = aiPlayer.getCardsIn(ZoneType.Hand); + final List handList = aiPlayer.getCardsIn(ZoneType.Hand); final boolean hasLittleCmc0Cards = CardListUtil.getValidCards(handList, "Card.cmcEQ0", aiPlayer, null).size() < 2; aiTakesMulligan = (handList.size() > InputMulligan.AI_MULLIGAN_THRESHOLD) && hasLittleCmc0Cards; @@ -152,7 +153,7 @@ public class InputMulligan extends Input { // Human Leylines & Chancellors ButtonUtil.reset(); final AbilityFactory af = new AbilityFactory(); - final CardList humanOpeningHand = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand); + final List humanOpeningHand = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand); for (final Card c : humanOpeningHand) { final ArrayList kws = c.getKeyword(); @@ -178,7 +179,7 @@ public class InputMulligan extends Input { } // Computer Leylines & Chancellors - final CardList aiOpeningHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); + final List aiOpeningHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); for (final Card c : aiOpeningHand) { if (!c.getName().startsWith("Leyline")) { final ArrayList kws = c.getKeyword(); @@ -231,7 +232,7 @@ public class InputMulligan extends Input { if (c0.getName().equals("Serum Powder") && z0.is(ZoneType.Hand)) { if (GameActionUtil.showYesNoDialog(c0, "Use " + c0.getName() + "'s ability?")) { - CardList hand = c0.getController().getCardsIn(ZoneType.Hand); + List hand = c0.getController().getCardsIn(ZoneType.Hand); for (Card c : hand) { Singletons.getModel().getGameAction().exile(c); } diff --git a/src/main/java/forge/control/input/InputPayDiscardCost.java b/src/main/java/forge/control/input/InputPayDiscardCost.java index 1146d47519a..39510b956c4 100644 --- a/src/main/java/forge/control/input/InputPayDiscardCost.java +++ b/src/main/java/forge/control/input/InputPayDiscardCost.java @@ -17,9 +17,11 @@ */ package forge.control.input; +import java.util.List; + import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.Command; import forge.card.cardfactory.CardFactoryUtil; @@ -48,7 +50,7 @@ public class InputPayDiscardCost extends Input { private int numChosen = 0; private int numRequired = 0; - private CardList choiceList; + private List choiceList; private CostDiscard discardCost; private SpellAbility ability; private Command paid; diff --git a/src/main/java/forge/control/input/InputPayReturnCost.java b/src/main/java/forge/control/input/InputPayReturnCost.java index fa6b92b95bb..6f85b491470 100644 --- a/src/main/java/forge/control/input/InputPayReturnCost.java +++ b/src/main/java/forge/control/input/InputPayReturnCost.java @@ -17,9 +17,11 @@ */ package forge.control.input; +import java.util.List; + import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.Command; import forge.Singletons; @@ -49,7 +51,7 @@ public class InputPayReturnCost extends Input { private int numChosen = 0; private int numRequired = 0; - private CardList choiceList; + private List choiceList; private CostReturn returnCost; private SpellAbility ability; private Command paid; diff --git a/src/main/java/forge/control/input/InputPaySacCost.java b/src/main/java/forge/control/input/InputPaySacCost.java index 33cb6726c24..00ec8b2ec71 100644 --- a/src/main/java/forge/control/input/InputPaySacCost.java +++ b/src/main/java/forge/control/input/InputPaySacCost.java @@ -17,9 +17,11 @@ */ package forge.control.input; +import java.util.List; + import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.Command; import forge.Singletons; @@ -49,7 +51,7 @@ public class InputPaySacCost extends Input { private int numChosen = 0; private int numRequired = 0; - private CardList choiceList; + private List choiceList; private CostSacrifice sacCost; private SpellAbility ability; private Command paid; diff --git a/src/main/java/forge/deck/DeckSection.java b/src/main/java/forge/deck/DeckSection.java index ef239d9051a..6f5e259d4cf 100644 --- a/src/main/java/forge/deck/DeckSection.java +++ b/src/main/java/forge/deck/DeckSection.java @@ -17,10 +17,11 @@ */ package forge.deck; +import java.util.List; import java.util.Map.Entry; import forge.Card; -import forge.CardList; + import forge.item.CardDb; import forge.item.CardPrinted; import forge.item.ItemPool; @@ -98,7 +99,7 @@ public class DeckSection extends ItemPool { * @param cardList * the card list */ - public void add(final CardList cardList) { + public void add(final List cardList) { for (final Card c : cardList) { this.add(c); } diff --git a/src/main/java/forge/game/GameNew.java b/src/main/java/forge/game/GameNew.java index ff9a2fd9b51..c6d3c79cdbf 100644 --- a/src/main/java/forge/game/GameNew.java +++ b/src/main/java/forge/game/GameNew.java @@ -10,10 +10,11 @@ import javax.swing.JOptionPane; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import com.google.common.collect.Iterables; +import com.google.common.collect.Lists; import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates.Presets; import forge.CardPredicates; @@ -64,8 +65,8 @@ public class GameNew { * @param iconEnemy *   {@link java.lang.String} */ - public static void newGame(final Deck humanDeck, final Deck computerDeck, final CardList humanStart, - final CardList computerStart, final int humanLife, final int computerLife, String iconEnemy) { + public static void newGame(final Deck humanDeck, final Deck computerDeck, final List humanStart, + final List computerStart, final int humanLife, final int computerLife, String iconEnemy) { Singletons.getControl().changeState(FControl.MATCH_SCREEN); CMatchUI.SINGLETON_INSTANCE.initMatch(iconEnemy); @@ -375,11 +376,11 @@ public class GameNew { * @return an array of {@link forge.Card} objects. */ private static Iterable smoothComputerManaCurve(final Iterable in) { - final CardList library = new CardList(in); + final List library = Lists.newArrayList(in); CardListUtil.shuffle(library); // remove all land, keep non-basicland in there, shuffled - CardList land = CardListUtil.filter(library, CardPredicates.Presets.LANDS); + List land = CardListUtil.filter(library, CardPredicates.Presets.LANDS); for (Card c : land) { if (c.isLand()) { library.remove(c); diff --git a/src/main/java/forge/game/limited/BoosterDraft.java b/src/main/java/forge/game/limited/BoosterDraft.java index fa3f9117d06..476e33e4153 100644 --- a/src/main/java/forge/game/limited/BoosterDraft.java +++ b/src/main/java/forge/game/limited/BoosterDraft.java @@ -30,7 +30,8 @@ import javax.swing.JOptionPane; import com.google.common.base.Function; -import forge.CardList; + +import forge.Card; import forge.Constant; import forge.Singletons; import forge.card.BoosterGenerator; @@ -294,7 +295,7 @@ public final class BoosterDraft implements IBoosterDraft { int iPlayer = 0; for (int i = 1; i < this.pack.size(); i++) { - final CardList forAi = new CardList(); + final List forAi = new ArrayList(); final List booster = this.pack.get((iHumansBooster + i) % this.pack.size()); for (final CardPrinted cr : booster) { forAi.add(cr.toForgeCard()); diff --git a/src/main/java/forge/game/limited/LimitedDeck.java b/src/main/java/forge/game/limited/LimitedDeck.java index e13bec62722..9e1c5b86281 100644 --- a/src/main/java/forge/game/limited/LimitedDeck.java +++ b/src/main/java/forge/game/limited/LimitedDeck.java @@ -380,7 +380,7 @@ public class LimitedDeck { * Add non-basic lands to the deck. */ // private void addNonBasicLands() { - // CardList lands = getAiPlayables().getType("Land"); + // List lands = getAiPlayables().getType("Land"); // while (!getColors().getColor1().equals(getColors().getColor2()) && // landsNeeded > 0 && lands.size() > 0) { // final Card c = lands.get(0); diff --git a/src/main/java/forge/game/phase/Combat.java b/src/main/java/forge/game/phase/Combat.java index ce46b3e7f50..f9a3cdb3c4e 100644 --- a/src/main/java/forge/game/phase/Combat.java +++ b/src/main/java/forge/game/phase/Combat.java @@ -29,7 +29,7 @@ import java.util.TreeMap; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.GameActionUtil; @@ -50,17 +50,17 @@ import forge.gui.match.CMatchUI; */ public class Combat { // key is attacker Card - // value is CardList of blockers - private final Map attackerMap = new TreeMap(); - private final Map blockerMap = new TreeMap(); + // value is List of blockers + private final Map> attackerMap = new TreeMap>(); + private final Map> blockerMap = new TreeMap>(); private final Set blocked = new HashSet(); - private final HashMap unblockedMap = new HashMap(); + private final HashMap> unblockedMap = new HashMap>(); private final HashMap defendingDamageMap = new HashMap(); // Defenders are the Defending Player + Each controlled Planeswalker private List defenders = new ArrayList(); - private Map defenderMap = new HashMap(); + private Map> defenderMap = new HashMap>(); private int currentDefender = 0; private int nextDefender = 0; @@ -111,12 +111,12 @@ public class Combat { this.defenders.clear(); this.defenderMap.clear(); this.defenders.add((GameEntity) defender); - this.defenderMap.put((GameEntity) defender, new CardList()); - CardList planeswalkers = defender.getCardsIn(ZoneType.Battlefield); + this.defenderMap.put((GameEntity) defender, new ArrayList()); + List planeswalkers = defender.getCardsIn(ZoneType.Battlefield); planeswalkers = CardListUtil.filter(planeswalkers, CardPredicates.Presets.PLANEWALKERS); for (final Card pw : planeswalkers) { this.defenders.add((GameEntity) pw); - this.defenderMap.put((GameEntity) pw, new CardList()); + this.defenderMap.put((GameEntity) pw, new ArrayList()); } } @@ -205,7 +205,7 @@ public class Combat { public final void setDefenders(final List newDef) { this.defenders = newDef; for (GameEntity entity : this.defenders) { - this.defenderMap.put(entity, new CardList()); + this.defenderMap.put(entity, new ArrayList()); } } @@ -327,17 +327,16 @@ public class Combat { * * @return an array of {@link forge.CardList} objects. */ - public final CardList[] sortAttackerByDefender() { + public final List> sortAttackerByDefender() { int size = this.defenders.size(); - final CardList[] attackers = new CardList[size]; + final ArrayList> attackers = new ArrayList>(size); for (int i = 0; i < size; i++) { - attackers[i] = getAttackersByDefenderSlot(i); + attackers.add(getAttackersByDefenderSlot(i)); } - return attackers; } - public final CardList getAttackersByDefenderSlot(int slot) { + public final List getAttackersByDefenderSlot(int slot) { GameEntity entity = this.defenders.get(slot); return this.defenderMap.get(entity); } @@ -383,7 +382,7 @@ public class Combat { return; } - this.attackerMap.put(c, new CardList()); + this.attackerMap.put(c, new ArrayList()); this.attackerToDefender.put(c, defender); this.defenderMap.get(defender).add(c); } @@ -442,8 +441,8 @@ public class Combat { * * @return an array of {@link forge.Card} objects. */ - public final CardList getAttackerList() { - return new CardList(this.attackerMap.keySet()); + public final List getAttackerList() { + return new ArrayList(this.attackerMap.keySet()); } // getAttackers() /** @@ -473,7 +472,7 @@ public class Combat { this.blocked.add(attacker); this.attackerMap.get(attacker).add(blocker); if (!this.blockerMap.containsKey(blocker)) { - this.blockerMap.put(blocker, new CardList(attacker)); + this.blockerMap.put(blocker, CardListUtil.createCardList(attacker)); } else { this.blockerMap.get(blocker).add(attacker); @@ -487,8 +486,8 @@ public class Combat { * * @return a {@link forge.CardList} object. */ - public final CardList getAllBlockers() { - final CardList block = new CardList(); + public final List getAllBlockers() { + final List block = new ArrayList(); block.addAll(blockerMap.keySet()); return block; @@ -503,11 +502,11 @@ public class Combat { * a {@link forge.Card} object. * @return a {@link forge.CardList} object. */ - public final CardList getBlockers(final Card attacker) { + public final List getBlockers(final Card attacker) { if (this.getBlockingAttackerList(attacker) == null) { - return new CardList(); + return new ArrayList(); } else { - return new CardList(this.getBlockingAttackerList(attacker)); + return new ArrayList(this.getBlockingAttackerList(attacker)); } } @@ -520,11 +519,11 @@ public class Combat { * a {@link forge.Card} object. * @return a {@link forge.Card} object. */ - public final CardList getAttackersBlockedBy(final Card blocker) { + public final List getAttackersBlockedBy(final Card blocker) { if (blockerMap.containsKey(blocker)) { return blockerMap.get(blocker); } - return new CardList(); + return new ArrayList(); } /** @@ -536,7 +535,7 @@ public class Combat { * a {@link forge.Card} object. * @return a {@link forge.CardList} object. */ - private CardList getBlockingAttackerList(final Card attacker) { + private List getBlockingAttackerList(final Card attacker) { return this.attackerMap.get(attacker); } @@ -550,11 +549,11 @@ public class Combat { * @param blockers * a {@link forge.CardList} object. */ - public void setBlockerList(final Card attacker, final CardList blockers) { + public void setBlockerList(final Card attacker, final List blockers) { this.attackerMap.put(attacker, blockers); } - public void setAttackersBlockedByList(final Card blocker, final CardList attackers) { + public void setAttackersBlockedByList(final Card blocker, final List attackers) { this.blockerMap.put(blocker, attackers); } @@ -571,7 +570,7 @@ public class Combat { // is card an attacker? if (this.attackerMap.containsKey(c)) { // Keep track of all of the different maps - CardList blockers = this.attackerMap.get(c); + List blockers = this.attackerMap.get(c); this.attackerMap.remove(c); for (Card b : blockers) { this.blockerMap.get(b).remove(c); @@ -582,7 +581,7 @@ public class Combat { this.attackerToDefender.remove(c); this.defenderMap.get(entity).remove(c); } else if (this.blockerMap.containsKey(c)) { // card is a blocker - CardList attackers = this.blockerMap.get(c); + List attackers = this.blockerMap.get(c); boolean stillDeclaring = Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_BLOCKERS); this.blockerMap.remove(c); @@ -604,7 +603,7 @@ public class Combat { * a {@link forge.Card} object. */ public final void undoBlockingAssignment(final Card blocker) { - final CardList att = this.getAttackerList(); + final List att = this.getAttackerList(); for (final Card attacker : att) { if (this.getBlockers(attacker).contains(blocker)) { this.getBlockingAttackerList(attacker).remove(blocker); @@ -621,7 +620,7 @@ public class Combat { *

*/ public final void verifyCreaturesInPlay() { - final CardList all = new CardList(); + final List all = new ArrayList(); all.addAll(this.getAttackers()); all.addAll(this.getAllBlockers()); @@ -638,10 +637,10 @@ public class Combat { *

*/ public final void setUnblocked() { - final CardList attacking = this.getAttackerList(); + final List attacking = this.getAttackerList(); for (final Card attacker : attacking) { - final CardList block = this.getBlockers(attacker); + final List block = this.getBlockers(attacker); if (block.size() == 0) { // this damage is assigned to a player by setPlayerDamage() @@ -657,12 +656,12 @@ public class Combat { } private final boolean assignBlockersDamage(boolean firstStrikeDamage) { - final CardList blockers = this.getAllBlockers(); + final List blockers = this.getAllBlockers(); boolean assignedDamage = false; for (final Card blocker : blockers) { if (blocker.hasDoubleStrike() || blocker.hasFirstStrike() == firstStrikeDamage) { - CardList attackers = this.getAttackersBlockedBy(blocker); + List attackers = this.getAttackersBlockedBy(blocker); final int damage = blocker.getNetCombatDamage(); @@ -694,8 +693,8 @@ public class Combat { private final boolean assignAttackersDamage(boolean firstStrikeDamage) { this.defendingDamageMap.clear(); // this should really happen in deal damage - CardList blockers = null; - final CardList attackers = this.getAttackerList(); + List blockers = null; + final List attackers = this.getAttackerList(); boolean assignedDamage = false; for (final Card attacker : attackers) { // If attacker isn't in the right first/regular strike section, continue along @@ -755,7 +754,7 @@ public class Combat { * @param damage * a int. */ - private void distributeAIDamage(final Card attacker, final CardList block, int damage) { + private void distributeAIDamage(final Card attacker, final List block, int damage) { final Card c = attacker; if (attacker.hasKeyword("You may have CARDNAME assign its combat damage as though it weren't blocked.") @@ -808,7 +807,7 @@ public class Combat { final int enoughDamageToKill = b.getEnoughDamageToKill(damage, attacker, true); if (enoughDamageToKill <= damage) { damage -= enoughDamageToKill; - final CardList cl = new CardList(); + final List cl = new ArrayList(); cl.add(attacker); b.addAssignedDamage(enoughDamageToKill, c); @@ -847,7 +846,7 @@ public class Combat { player.addCombatDamage(entry.getValue(), entry.getKey()); } - final CardList unblocked = new CardList(bFirstStrike ? AllZone.getCombat().getUnblockedAttackers() : AllZone + final List unblocked = new ArrayList(bFirstStrike ? AllZone.getCombat().getUnblockedAttackers() : AllZone .getCombat().getUnblockedFirstStrikeAttackers()); for (int j = 0; j < unblocked.size(); j++) { @@ -862,7 +861,7 @@ public class Combat { // this can be much better below here... - final CardList combatants = new CardList(); + final List combatants = new ArrayList(); combatants.addAll(AllZone.getCombat().getAttackers()); combatants.addAll(AllZone.getCombat().getAllBlockers()); combatants.addAll(AllZone.getCombat().getDefendingPlaneswalkers()); @@ -950,7 +949,7 @@ public class Combat { * a {@link forge.Card} object. */ public final void addUnblockedAttacker(final Card c) { - this.unblockedMap.put(c, new CardList()); + this.unblockedMap.put(c, new ArrayList()); } } // Class Combat diff --git a/src/main/java/forge/game/phase/CombatUtil.java b/src/main/java/forge/game/phase/CombatUtil.java index ddb671ba772..c618a362dcb 100644 --- a/src/main/java/forge/game/phase/CombatUtil.java +++ b/src/main/java/forge/game/phase/CombatUtil.java @@ -31,7 +31,7 @@ import com.google.common.base.Predicate; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.Command; @@ -160,7 +160,7 @@ public class CombatUtil { return false; } - final CardList list = AllZoneUtil.getCreaturesInPlay(blocker.getController()); + final List list = AllZoneUtil.getCreaturesInPlay(blocker.getController()); if (list.size() < 2 && blocker.hasKeyword("CARDNAME can't attack or block alone.")) { return false; } @@ -168,7 +168,7 @@ public class CombatUtil { return true; } - public static boolean canBlockMoreCreatures(final Card blocker, final CardList blockedBy) { + public static boolean canBlockMoreCreatures(final Card blocker, final List blockedBy) { // TODO(sol) expand this for the additional blocking keyword if (blockedBy.isEmpty() || blocker.hasKeyword("CARDNAME can block any number of creatures.")) { return true; @@ -286,7 +286,7 @@ public class CombatUtil { String valid = StringUtils.join(walkTypes, ","); final Player defendingPlayer = attacker.getController().getOpponent(); - CardList defendingLands = defendingPlayer.getCardsIn(ZoneType.Battlefield); + List defendingLands = defendingPlayer.getCardsIn(ZoneType.Battlefield); for (Card c : defendingLands) { if (c.isValid(valid, defendingPlayer, attacker)) { return true; @@ -305,7 +305,7 @@ public class CombatUtil { * the attackers * @return true, if one can be blocked */ - public static boolean canBlockAtLeastOne(final Card blocker, final CardList attackers) { + public static boolean canBlockAtLeastOne(final Card blocker, final List attackers) { for (Card attacker : attackers) { if (CombatUtil.canBlock(attacker, blocker)) { return true; @@ -323,7 +323,7 @@ public class CombatUtil { * the blockers * @return true, if successful */ - public static boolean canBeBlocked(final Card attacker, final CardList blockers) { + public static boolean canBeBlocked(final Card attacker, final List blockers) { if (!CombatUtil.canBeBlocked(attacker)) { return false; } @@ -382,8 +382,8 @@ public class CombatUtil { */ public static boolean finishedMandatoryBlocks(final Combat combat) { - final CardList blockers = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); - final CardList attackers = combat.getAttackerList(); + final List blockers = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + final List attackers = combat.getAttackerList(); // if a creature does not block but should, return false for (final Card blocker : blockers) { @@ -398,7 +398,7 @@ public class CombatUtil { if (CombatUtil.canBlock(attacker, blocker, combat)) { boolean must = true; if (attacker.hasKeyword("CARDNAME can't be blocked except by two or more creatures.")) { - final CardList possibleBlockers = CardListUtil.filter(combat.getDefendingPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES); + final List possibleBlockers = CardListUtil.filter(combat.getDefendingPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES); possibleBlockers.remove(blocker); if (!CombatUtil.canBeBlocked(attacker, possibleBlockers)) { must = false; @@ -431,18 +431,18 @@ public class CombatUtil { private static void orderMultipleBlockers(final Combat combat) { // If there are multiple blockers, the Attacker declares the Assignment Order final Player player = combat.getAttackingPlayer(); - final CardList attackers = combat.getAttackerList(); + final List attackers = combat.getAttackerList(); for (final Card attacker : attackers) { - CardList blockers = combat.getBlockers(attacker); + List blockers = combat.getBlockers(attacker); if (blockers.size() <= 1) { continue; } - CardList orderedBlockers = null; + List orderedBlockers = null; if (player.isHuman()) { List ordered = GuiChoose.getOrderChoices("Choose Blocking Order", "Damaged First", 0, blockers.toArray(), null); - orderedBlockers = new CardList(); + orderedBlockers = new ArrayList(); for(Object o : ordered) { orderedBlockers.add((Card)o); } @@ -459,18 +459,18 @@ public class CombatUtil { private static void orderBlockingMultipleAttackers(final Combat combat) { // If there are multiple blockers, the Attacker declares the Assignment Order final Player player = combat.getDefendingPlayer(); - final CardList blockers = combat.getAllBlockers(); + final List blockers = combat.getAllBlockers(); for (final Card blocker : blockers) { - CardList attackers = combat.getAttackersBlockedBy(blocker); + List attackers = combat.getAttackersBlockedBy(blocker); if (attackers.size() <= 1) { continue; } - CardList orderedAttacker = null; + List orderedAttacker = null; if (player.isHuman()) { List ordered = GuiChoose.getOrderChoices("Choose Blocking Order", "Damaged First", 0, attackers.toArray(), null); - orderedAttacker = new CardList(); + orderedAttacker = new ArrayList(); for(Object o : ordered) { orderedAttacker.add((Card)o); } @@ -507,8 +507,8 @@ public class CombatUtil { return false; } - final CardList attackers = combat.getAttackerList(); - final CardList attackersWithLure = new CardList(); + final List attackers = combat.getAttackerList(); + final List attackersWithLure = new ArrayList(); for (final Card attacker : attackers) { if (attacker.hasStartOfKeyword("All creatures able to block CARDNAME do so.") || (attacker.hasStartOfKeyword("CARDNAME must be blocked if able.") && combat.getBlockers(attacker) @@ -521,7 +521,7 @@ public class CombatUtil { if (CombatUtil.canBeBlocked(attacker, combat) && CombatUtil.canBlock(attacker, blocker)) { boolean canBe = true; if (attacker.hasKeyword("CARDNAME can't be blocked except by two or more creatures.")) { - final CardList blockers = CardListUtil.filter(combat.getDefendingPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES); + final List blockers = CardListUtil.filter(combat.getDefendingPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES); blockers.remove(blocker); if (!CombatUtil.canBeBlocked(attacker, blockers)) { canBe = false; @@ -538,7 +538,7 @@ public class CombatUtil { if (CombatUtil.canBeBlocked(attacker, combat) && CombatUtil.canBlock(attacker, blocker)) { boolean canBe = true; if (attacker.hasKeyword("CARDNAME can't be blocked except by two or more creatures.")) { - final CardList blockers = CardListUtil.filter(combat.getDefendingPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES); + final List blockers = CardListUtil.filter(combat.getDefendingPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES); blockers.remove(blocker); if (!CombatUtil.canBeBlocked(attacker, blockers)) { canBe = false; @@ -803,7 +803,7 @@ public class CombatUtil { } } - final CardList list = AllZoneUtil.getCreaturesInPlay(c.getController()); + final List list = AllZoneUtil.getCreaturesInPlay(c.getController()); if (list.size() < 2 && c.hasKeyword("CARDNAME can't attack or block alone.")) { return false; } @@ -880,7 +880,7 @@ public class CombatUtil { if (asSeparateWords[12].matches("[0-9][0-9]?")) { powerLimit[0] = Integer.parseInt((asSeparateWords[12]).trim()); - CardList list = AllZoneUtil.getCreaturesInPlay(c.getController().getOpponent()); + List list = AllZoneUtil.getCreaturesInPlay(c.getController().getOpponent()); list = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card ct) { @@ -897,8 +897,8 @@ public class CombatUtil { } // hasKeyword = CARDNAME can't attack if defending player controls an // untapped creature with power ... - final CardList list = c.getController().getOpponent().getCardsIn(ZoneType.Battlefield); - CardList temp; + final List list = c.getController().getOpponent().getCardsIn(ZoneType.Battlefield); + List temp; for (String keyword : c.getKeyword()) { if (keyword.equals("CARDNAME can't attack.") || keyword.equals("CARDNAME can't attack or block.")) { return false; @@ -959,7 +959,7 @@ public class CombatUtil { public static int getTotalFirstStrikeBlockPower(final Card attacker, final Player player) { final Card att = attacker; - CardList list = AllZoneUtil.getCreaturesInPlay(player); + List list = AllZoneUtil.getCreaturesInPlay(player); list = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { @@ -1060,7 +1060,7 @@ public class CombatUtil { * a {@link forge.game.player.Player} object. * @return a int. */ - public static int sumDamageIfUnblocked(final CardList attackers, final Player attacked) { + public static int sumDamageIfUnblocked(final List attackers, final Player attacked) { int sum = 0; for (final Card attacker : attackers) { sum += CombatUtil.damageIfUnblocked(attacker, attacked, null); @@ -1080,7 +1080,7 @@ public class CombatUtil { * a {@link forge.game.player.Player} object. * @return a int. */ - public static int sumPoisonIfUnblocked(final CardList attackers, final Player attacked) { + public static int sumPoisonIfUnblocked(final List attackers, final Player attacked) { int sum = 0; for (final Card attacker : attackers) { sum += CombatUtil.poisonIfUnblocked(attacker, attacked, null); @@ -1102,12 +1102,12 @@ public class CombatUtil { int damage = 0; - final CardList attackers = combat.getAttackersByDefenderSlot(0); - final CardList unblocked = new CardList(); + final List attackers = combat.getAttackersByDefenderSlot(0); + final List unblocked = new ArrayList(); for (final Card attacker : attackers) { - final CardList blockers = combat.getBlockers(attacker); + final List blockers = combat.getBlockers(attacker); if ((blockers.size() == 0) || attacker.hasKeyword("You may have CARDNAME assign its combat damage " @@ -1144,12 +1144,12 @@ public class CombatUtil { int poison = 0; - final CardList attackers = combat.getAttackersByDefenderSlot(0); - final CardList unblocked = new CardList(); + final List attackers = combat.getAttackersByDefenderSlot(0); + final List unblocked = new ArrayList(); for (final Card attacker : attackers) { - final CardList blockers = combat.getBlockers(attacker); + final List blockers = combat.getBlockers(attacker); if ((blockers.size() == 0) || attacker.hasKeyword("You may have CARDNAME assign its combat damage" @@ -1189,11 +1189,11 @@ public class CombatUtil { } // check for creatures that must be blocked - final CardList attackers = combat.getAttackersByDefenderSlot(0); + final List attackers = combat.getAttackersByDefenderSlot(0); for (final Card attacker : attackers) { - final CardList blockers = combat.getBlockers(attacker); + final List blockers = combat.getBlockers(attacker); if (blockers.size() == 0) { if (!attacker.getSVar("MustBeBlocked").equals("")) { @@ -1243,11 +1243,11 @@ public class CombatUtil { } // check for creatures that must be blocked - final CardList attackers = combat.getAttackersByDefenderSlot(0); + final List attackers = combat.getAttackersByDefenderSlot(0); for (final Card attacker : attackers) { - final CardList blockers = combat.getBlockers(attacker); + final List blockers = combat.getBlockers(attacker); if (blockers.size() == 0) { if (!attacker.getSVar("MustBeBlocked").equals("")) { @@ -1276,7 +1276,7 @@ public class CombatUtil { * a {@link forge.CardList} object. * @return a int. */ - public static int totalDamageOfBlockers(final Card attacker, final CardList defenders) { + public static int totalDamageOfBlockers(final Card attacker, final List defenders) { int damage = 0; for (final Card defender : defenders) { @@ -1350,7 +1350,7 @@ public class CombatUtil { * a {@link forge.CardList} object. * @return a int. */ - public static int totalShieldDamage(final Card attacker, final CardList defenders) { + public static int totalShieldDamage(final Card attacker, final List defenders) { int defenderDefense = 0; @@ -1430,7 +1430,7 @@ public class CombatUtil { * @return a boolean. */ public static boolean attackerWouldBeDestroyed(final Card attacker) { - final CardList blockers = AllZone.getCombat().getBlockers(attacker); + final List blockers = AllZone.getCombat().getBlockers(attacker); for (final Card defender : blockers) { if (CombatUtil.canDestroyAttacker(attacker, defender, AllZone.getCombat(), true) @@ -1583,7 +1583,7 @@ public class CombatUtil { // look out for continuous static abilities that only care for blocking // creatures - final CardList cardList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List cardList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card card : cardList) { for (final StaticAbility stAb : card.getStaticAbilities()) { final HashMap params = stAb.getMapParams(); @@ -1848,7 +1848,7 @@ public class CombatUtil { // look out for continuous static abilities that only care for attacking // creatures - final CardList cardList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List cardList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card card : cardList) { for (final StaticAbility stAb : card.getStaticAbilities()) { final HashMap params = stAb.getMapParams(); @@ -1973,7 +1973,7 @@ public class CombatUtil { // look out for continuous static abilities that only care for attacking // creatures - final CardList cardList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List cardList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card card : cardList) { for (final StaticAbility stAb : card.getStaticAbilities()) { final HashMap params = stAb.getMapParams(); @@ -2331,7 +2331,7 @@ public class CombatUtil { public static boolean blockerWouldBeDestroyed(final Card blocker) { // TODO THis function only checks if a single attacker at a time would destroy a blocker // This needs to expand to tally up damage - final CardList attackers = AllZone.getCombat().getAttackersBlockedBy(blocker); + final List attackers = AllZone.getCombat().getAttackersBlockedBy(blocker); for(Card attacker : attackers) { if (CombatUtil.canDestroyBlocker(blocker, attacker, AllZone.getCombat(), true) @@ -2480,7 +2480,7 @@ public class CombatUtil { *

*/ public static void removeAllDamage() { - final CardList cl = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List cl = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card c : cl) { c.setDamage(0); } @@ -2498,17 +2498,18 @@ public class CombatUtil { // Append Defending Player/Planeswalker final Combat combat = AllZone.getCombat(); final List defenders = combat.getDefenders(); - final CardList[] attackers = combat.sortAttackerByDefender(); + final List> attackers = combat.sortAttackerByDefender(); // Not a big fan of the triple nested loop here for (int def = 0; def < defenders.size(); def++) { - if ((attackers[def] == null) || (attackers[def].size() == 0)) { + List attacker = attackers.get(def); + if ((attacker == null) || (attacker.size() == 0)) { continue; } sb.append(combat.getAttackingPlayer()).append(" declared "); - for (final Card attacker : attackers[def]) { - sb.append(attacker).append(" "); + for (final Card atk : attacker) { + sb.append(atk).append(" "); } sb.append("attacking ").append(defenders.get(def).toString()).append("."); @@ -2525,17 +2526,17 @@ public class CombatUtil { public static String getCombatBlockForLog() { final StringBuilder sb = new StringBuilder(); - CardList defend = null; + List defend = null; // Loop through Defenders // Append Defending Player/Planeswalker final Combat combat = AllZone.getCombat(); final List defenders = combat.getDefenders(); - final CardList[] attackers = combat.sortAttackerByDefender(); + final List> attackers = combat.sortAttackerByDefender(); // Not a big fan of the triple nested loop here for (int def = 0; def < defenders.size(); def++) { - final CardList list = attackers[def]; + final List list = attackers.get(def); for (final Card attacker : list) { sb.append(combat.getDefendingPlayer()).append(" assigned "); @@ -2575,11 +2576,12 @@ public class CombatUtil { // Loop through Defenders // Append Defending Player/Planeswalker final List defenders = AllZone.getCombat().getDefenders(); - final CardList[] attackers = AllZone.getCombat().sortAttackerByDefender(); + final List> attackers = AllZone.getCombat().sortAttackerByDefender(); // Not a big fan of the triple nested loop here for (int def = 0; def < defenders.size(); def++) { - if ((attackers[def] == null) || (attackers[def].size() == 0)) { + List atk = attackers.get(def); + if ((atk == null) || (atk.size() == 0)) { continue; } @@ -2591,14 +2593,12 @@ public class CombatUtil { display.append(defenders.get(def).toString()); display.append("\n"); - final CardList list = attackers[def]; - - for (final Card c : list) { + for (final Card c : atk) { // loop through attackers display.append("-> "); display.append(CombatUtil.combatantToString(c)).append("\n"); - CardList blockers = AllZone.getCombat().getBlockers(c); + List blockers = AllZone.getCombat().getBlockers(c); // loop through blockers for (final Card element : blockers) { @@ -2739,7 +2739,7 @@ public class CombatUtil { // Run triggers final HashMap runParams = new HashMap(); runParams.put("Attacker", c); - final CardList otherAttackers = AllZone.getCombat().getAttackerList(); + final List otherAttackers = AllZone.getCombat().getAttackerList(); otherAttackers.remove(c); runParams.put("OtherAttackers", otherAttackers); runParams.put("Attacked", AllZone.getCombat().getDefenderByAttacker(c)); @@ -2761,7 +2761,7 @@ public class CombatUtil { @Override public void resolve() { if (crd.getController().isHuman()) { - final CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + final List list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); ComputerUtil.sacrificePermanents(a, list, false, this); } else { AbilityFactorySacrifice.sacrificeHuman(AllZone.getHumanPlayer(), a, "Permanent", this, @@ -2829,7 +2829,7 @@ public class CombatUtil { final PlayerZone lib = player.getZone(ZoneType.Library); if (lib.size() > 0) { - final CardList cl = new CardList(); + final List cl = new ArrayList(); cl.add(lib.get(0)); GuiChoose.oneOrNone("Top card", cl); final Card top = lib.get(0); @@ -2871,7 +2871,7 @@ public class CombatUtil { * @param cl * a {@link forge.CardList} object. */ - public static void checkDeclareBlockers(final CardList cl) { + public static void checkDeclareBlockers(final List cl) { for (final Card c : cl) { if (!c.getDamageHistory().getCreatureBlockedThisCombat()) { for (final Ability ab : CardFactoryUtil.getBushidoEffects(c)) { @@ -3078,7 +3078,7 @@ public class CombatUtil { final Ability ability4 = new Ability(c, "0") { @Override public void resolve() { - CardList enchantments = attacker.getController().getCardsIn(ZoneType.Library); + List enchantments = attacker.getController().getCardsIn(ZoneType.Library); enchantments = CardListUtil.filter(enchantments, new Predicate() { @Override public boolean apply(final Card c) { diff --git a/src/main/java/forge/game/phase/EndOfTurn.java b/src/main/java/forge/game/phase/EndOfTurn.java index 17a34a14526..a6d1c72f745 100644 --- a/src/main/java/forge/game/phase/EndOfTurn.java +++ b/src/main/java/forge/game/phase/EndOfTurn.java @@ -17,12 +17,14 @@ */ package forge.game.phase; +import java.util.List; + import com.google.common.base.Predicate; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.Counters; import forge.Singletons; @@ -55,7 +57,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable { // TODO - should this freeze the Stack? - final CardList all = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List all = AllZoneUtil.getCardsIn(ZoneType.Battlefield); //EndOfTurn.endOfTurnWallOfReverence(); EndOfTurn.endOfTurnLighthouseChronologist(); @@ -152,7 +154,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable { if (AllZoneUtil.isCardInPlay(vale)) { vale.addController(vale.getController().getOpponent()); // Singletons.getModel().getGameAction().changeController( - // new CardList(vale), vale.getController(), + // new ArrayList(vale), vale.getController(), // vale.getController().getOpponent()); vale.removeAllExtrinsicKeyword("An opponent gains control of CARDNAME " @@ -231,7 +233,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable { private static void endOfTurnLighthouseChronologist() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); final Player opponent = player.getOpponent(); - CardList list = opponent.getCardsIn(ZoneType.Battlefield); + List list = opponent.getCardsIn(ZoneType.Battlefield); list = CardListUtil.filter(list, new Predicate() { @Override diff --git a/src/main/java/forge/game/phase/PhaseHandler.java b/src/main/java/forge/game/phase/PhaseHandler.java index f8028d0a65c..cbe819b8dab 100644 --- a/src/main/java/forge/game/phase/PhaseHandler.java +++ b/src/main/java/forge/game/phase/PhaseHandler.java @@ -18,6 +18,7 @@ package forge.game.phase; import java.util.HashMap; +import java.util.List; import java.util.Observer; import java.util.Stack; @@ -25,7 +26,7 @@ import com.esotericsoftware.minlog.Log; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.GameActionUtil; @@ -425,7 +426,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable { case CLEANUP: // Reset Damage received map - final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card c : list) { c.resetPreventNextDamage(); c.resetReceivedDamageFromThisTurn(); @@ -451,8 +452,8 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable { } AllZone.getEndOfTurn().executeUntil(); - final CardList cHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); - final CardList hHand = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand); + final List cHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); + final List hHand = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand); for (final Card c : cHand) { c.setDrawnThisTurn(false); } @@ -660,7 +661,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable { */ private boolean skipTurnTimeVault(Player turn) { // time vault: - CardList vaults = turn.getCardsIn(ZoneType.Battlefield, "Time Vault"); + List vaults = turn.getCardsIn(ZoneType.Battlefield, "Time Vault"); vaults = CardListUtil.filter(vaults, CardPredicates.Presets.TAPPED); if (vaults.size() > 0) { @@ -830,7 +831,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable { */ public final void resetAttackedThisCombat(final Player player) { // resets the status of attacked/blocked this phase - CardList list = player.getCardsIn(ZoneType.Battlefield); + List list = player.getCardsIn(ZoneType.Battlefield); list = CardListUtil.filter(list, CardPredicates.Presets.CREATURES); diff --git a/src/main/java/forge/game/phase/PhaseUtil.java b/src/main/java/forge/game/phase/PhaseUtil.java index 80753aa9f5b..590ca479842 100644 --- a/src/main/java/forge/game/phase/PhaseUtil.java +++ b/src/main/java/forge/game/phase/PhaseUtil.java @@ -17,14 +17,16 @@ */ package forge.game.phase; +import java.util.ArrayList; import java.util.HashMap; +import java.util.List; import com.google.common.base.Predicate; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates.Presets; import forge.Singletons; @@ -94,7 +96,7 @@ public class PhaseUtil { AllZone.getCombat().setDefendingPlayer(turn.getOpponent()); // Tokens starting game in play now actually suffer from Sum. Sickness again - final CardList list = turn.getCardsIncludePhasingIn(ZoneType.Battlefield); + final List list = turn.getCardsIncludePhasingIn(ZoneType.Battlefield); for (final Card c : list) { if (turn.getTurn() > 0 || !c.isStartsGameInPlay()) { c.setSickness(false); @@ -104,7 +106,7 @@ public class PhaseUtil { Singletons.getModel().getGameAction().resetActivationsPerTurn(); - final CardList lands = CardListUtil.filter(AllZoneUtil.getPlayerLandsInPlay(turn), Presets.UNTAPPED); + final List lands = CardListUtil.filter(AllZoneUtil.getPlayerLandsInPlay(turn), Presets.UNTAPPED); turn.setNumPowerSurgeLands(lands.size()); // anything before this point happens regardless of whether the Untap @@ -289,7 +291,7 @@ public class PhaseUtil { PhaseUtil.verifyCombat(); // Handles removing cards like Mogg Flunkies from combat if group attack didn't occur - final CardList filterList = AllZone.getCombat().getAttackerList(); + final List filterList = AllZone.getCombat().getAttackerList(); for (Card c : filterList) { if (c.hasKeyword("CARDNAME can't attack or block alone.") && c.isAttacking()) { if (AllZone.getCombat().getAttackers().size() < 2) { @@ -298,7 +300,7 @@ public class PhaseUtil { } } - final CardList list = AllZone.getCombat().getAttackerList(); + final List list = AllZone.getCombat().getAttackerList(); // TODO move propaganda to happen as the Attacker is Declared // Remove illegal Propaganda attacks first only for attacking the Player @@ -317,7 +319,7 @@ public class PhaseUtil { *

*/ public static void handleAttackingTriggers() { - final CardList list = AllZone.getCombat().getAttackerList(); + final List list = AllZone.getCombat().getAttackerList(); AllZone.getStack().freezeStack(); // Then run other Attacker bonuses // check for exalted: @@ -357,7 +359,7 @@ public class PhaseUtil { PhaseUtil.verifyCombat(); // Handles removing cards like Mogg Flunkies from combat if group block didn't occur - final CardList filterList = AllZone.getCombat().getAllBlockers(); + final List filterList = AllZone.getCombat().getAllBlockers(); for (Card c : filterList) { if (c.hasKeyword("CARDNAME can't attack or block alone.") && c.isBlocking()) { if (AllZone.getCombat().getAllBlockers().size() < 2) { @@ -370,7 +372,7 @@ public class PhaseUtil { AllZone.getCombat().setUnblocked(); - CardList list = new CardList(); + List list = new ArrayList(); list.addAll(AllZone.getCombat().getAllBlockers()); list = CardListUtil.filter(list, new Predicate() { @@ -380,12 +382,12 @@ public class PhaseUtil { } }); - final CardList attList = AllZone.getCombat().getAttackerList(); + final List attList = AllZone.getCombat().getAttackerList(); CombatUtil.checkDeclareBlockers(list); for (final Card a : attList) { - final CardList blockList = AllZone.getCombat().getBlockers(a); + final List blockList = AllZone.getCombat().getBlockers(a); for (final Card b : blockList) { CombatUtil.checkBlockedAttackers(a, b); } diff --git a/src/main/java/forge/game/phase/Untap.java b/src/main/java/forge/game/phase/Untap.java index f3faf7c3c5a..a846394e962 100644 --- a/src/main/java/forge/game/phase/Untap.java +++ b/src/main/java/forge/game/phase/Untap.java @@ -18,13 +18,14 @@ package forge.game.phase; import java.util.ArrayList; +import java.util.List; import com.google.common.base.Predicate; import com.google.common.base.Predicates; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates.Presets; import forge.Counters; @@ -86,7 +87,7 @@ public class Untap extends Phase implements java.io.Serializable { return false; } - final CardList allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card ca : allp) { if (ca.hasStartOfKeyword("Permanents don't untap during their controllers' untap steps")) { final int keywordPosition = ca @@ -113,7 +114,7 @@ public class Untap extends Phase implements java.io.Serializable { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); final Predicate tappedCanUntap = Predicates.and(Presets.TAPPED, Presets.CANUNTAP); - CardList list = player.getCardsIn(ZoneType.Battlefield); + List list = player.getCardsIn(ZoneType.Battlefield); for (final Card c : list) { if (c.getBounceAtUntap() && c.getName().contains("Undiscovered Paradise")) { @@ -188,7 +189,7 @@ public class Untap extends Phase implements java.io.Serializable { } // opponent untapping during your untap phase - final CardList opp = player.getOpponent().getCardsIn(ZoneType.Battlefield); + final List opp = player.getOpponent().getCardsIn(ZoneType.Battlefield); for (final Card oppCard : opp) { if (oppCard.hasKeyword("CARDNAME untaps during each other player's untap step.")) { oppCard.untap(); @@ -200,7 +201,7 @@ public class Untap extends Phase implements java.io.Serializable { if (Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn().isComputer()) { // search for lands the computer has and only untap 1 - CardList landList = AllZoneUtil.getPlayerLandsInPlay(AllZone.getComputerPlayer()); + List landList = AllZoneUtil.getPlayerLandsInPlay(AllZone.getComputerPlayer()); landList = CardListUtil.filter(landList, tappedCanUntap); if (landList.size() > 0) { @@ -229,7 +230,7 @@ public class Untap extends Phase implements java.io.Serializable { } } // selectCard() }; // Input - CardList landList = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()); + List landList = AllZoneUtil.getPlayerLandsInPlay(AllZone.getHumanPlayer()); landList = CardListUtil.filter(landList, tappedCanUntap); if (landList.size() > 0) { AllZone.getInputControl().setInput(target); @@ -238,7 +239,7 @@ public class Untap extends Phase implements java.io.Serializable { } if (AllZoneUtil.isCardInPlay("Damping Field") || AllZoneUtil.isCardInPlay("Imi Statue")) { if (Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn().isComputer()) { - CardList artList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List artList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); artList = CardListUtil.filter(artList, Presets.ARTIFACTS); artList = CardListUtil.filter(artList, tappedCanUntap); if (artList.size() > 0) { @@ -268,7 +269,7 @@ public class Untap extends Phase implements java.io.Serializable { } } // selectCard() }; // Input - CardList artList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + List artList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); artList = CardListUtil.filter(artList, Presets.ARTIFACTS); artList = CardListUtil.filter(artList, tappedCanUntap); if (artList.size() > 0) { @@ -278,7 +279,7 @@ public class Untap extends Phase implements java.io.Serializable { } if ((AllZoneUtil.isCardInPlay("Smoke") || AllZoneUtil.isCardInPlay("Stoic Angel"))) { if (Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn().isComputer()) { - CardList creatures = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); + List creatures = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); creatures = CardListUtil.filter(creatures, tappedCanUntap); if (creatures.size() > 0) { creatures.get(0).untap(); @@ -307,7 +308,7 @@ public class Untap extends Phase implements java.io.Serializable { } } // selectCard() }; // Input - CardList creatures = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + List creatures = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); creatures = CardListUtil.filter(creatures, tappedCanUntap); if (creatures.size() > 0) { AllZone.getInputControl().setInput(target); @@ -343,7 +344,7 @@ public class Untap extends Phase implements java.io.Serializable { private static void doPhasing(final Player turn) { // Needs to include phased out cards - final CardList list = CardListUtil.filter(turn.getCardsIncludePhasingIn(ZoneType.Battlefield), new Predicate() { + final List list = CardListUtil.filter(turn.getCardsIncludePhasingIn(ZoneType.Battlefield), new Predicate() { @Override public boolean apply(final Card c) { diff --git a/src/main/java/forge/game/phase/Upkeep.java b/src/main/java/forge/game/phase/Upkeep.java index 1992d0a4889..5fac856786f 100644 --- a/src/main/java/forge/game/phase/Upkeep.java +++ b/src/main/java/forge/game/phase/Upkeep.java @@ -18,6 +18,7 @@ package forge.game.phase; import java.util.ArrayList; +import java.util.List; import com.google.common.base.Predicate; import com.google.common.collect.Iterables; @@ -25,7 +26,7 @@ import com.google.common.collect.Iterables; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.CardPredicates.Presets; @@ -126,7 +127,7 @@ public class Upkeep extends Phase implements java.io.Serializable { private static void upkeepBraidOfFire() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList braids = player.getCardsIn(ZoneType.Battlefield, "Braid of Fire"); + final List braids = player.getCardsIn(ZoneType.Battlefield, "Braid of Fire"); for (int i = 0; i < braids.size(); i++) { final Card c = braids.get(i); @@ -164,7 +165,7 @@ public class Upkeep extends Phase implements java.io.Serializable { *

*/ private static void upkeepEcho() { - CardList list = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn().getCardsIn(ZoneType.Battlefield); + List list = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn().getCardsIn(ZoneType.Battlefield); list = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { @@ -225,7 +226,7 @@ public class Upkeep extends Phase implements java.io.Serializable { private static void upkeepSlowtrips() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - CardList list = player.getSlowtripList(); + List list = player.getSlowtripList(); for (int i = 0; i < list.size(); i++) { final Card card = list.get(i); @@ -279,7 +280,7 @@ public class Upkeep extends Phase implements java.io.Serializable { *

*/ private static void upkeepUpkeepCost() { - final CardList list = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn().getCardsIn(ZoneType.Battlefield); + final List list = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn().getCardsIn(ZoneType.Battlefield); for (int i = 0; i < list.size(); i++) { final Card c = list.get(i); @@ -474,22 +475,22 @@ public class Upkeep extends Phase implements java.io.Serializable { * regenerated. */ final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList the = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "The Abyss"); - final CardList magus = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Magus of the Abyss"); + final List the = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "The Abyss"); + final List magus = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Magus of the Abyss"); - final CardList cards = new CardList(); + final List cards = new ArrayList(); cards.addAll(the); cards.addAll(magus); for (final Card c : cards) { final Card abyss = c; - final CardList abyssGetTargets = CardListUtil.filter(AllZoneUtil.getCreaturesInPlay(player), Presets.NON_ARTIFACTS); + final List abyssGetTargets = CardListUtil.filter(AllZoneUtil.getCreaturesInPlay(player), Presets.NON_ARTIFACTS); final Ability sacrificeCreature = new Ability(abyss, "") { @Override public void resolve() { - final CardList targets = CardListUtil.getTargetableCards(abyssGetTargets, this); + final List targets = CardListUtil.getTargetableCards(abyssGetTargets, this); if (player.isHuman()) { if (targets.size() > 0) { AllZone.getInputControl().setInput(new Input() { @@ -516,7 +517,7 @@ public class Upkeep extends Phase implements java.io.Serializable { } } else { // computer - final CardList indestruct = CardListUtil.getKeyword(targets, "Indestructible"); + final List indestruct = CardListUtil.getKeyword(targets, "Indestructible"); if (indestruct.size() > 0) { Singletons.getModel().getGameAction().destroyNoRegeneration(indestruct.get(0)); } else if (targets.size() > 0) { @@ -550,9 +551,9 @@ public class Upkeep extends Phase implements java.io.Serializable { * least power, you choose one of them. */ final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList drops = player.getCardsIn(ZoneType.Battlefield, "Drop of Honey"); + final List drops = player.getCardsIn(ZoneType.Battlefield, "Drop of Honey"); drops.addAll(player.getCardsIn(ZoneType.Battlefield, "Porphyry Nodes")); - final CardList cards = drops; + final List cards = drops; for (int i = 0; i < cards.size(); i++) { final Card c = cards.get(i); @@ -560,7 +561,7 @@ public class Upkeep extends Phase implements java.io.Serializable { final Ability ability = new Ability(c, "") { @Override public void resolve() { - final CardList creatures = AllZoneUtil.getCreaturesInPlay(); + final List creatures = AllZoneUtil.getCreaturesInPlay(); if (creatures.size() > 0) { CardListUtil.sortAttackLowFirst(creatures); final int power = creatures.get(0).getNetAttack(); @@ -575,8 +576,8 @@ public class Upkeep extends Phase implements java.io.Serializable { } } // resolve - private CardList getLowestPowerList(final CardList original) { - final CardList lowestPower = new CardList(); + private List getLowestPowerList(final List original) { + final List lowestPower = new ArrayList(); final int power = original.get(0).getNetAttack(); int i = 0; while ((i < original.size()) && (original.get(i).getNetAttack() == power)) { @@ -586,9 +587,9 @@ public class Upkeep extends Phase implements java.io.Serializable { return lowestPower; } - private Card getCompyCardToDestroy(final CardList original) { - final CardList options = this.getLowestPowerList(original); - final CardList humanCreatures = CardListUtil.filter(options, new Predicate() { + private Card getCompyCardToDestroy(final List original) { + final List options = this.getLowestPowerList(original); + final List humanCreatures = CardListUtil.filter(options, new Predicate() { @Override public boolean apply(final Card c) { return c.getController().isHuman(); @@ -626,7 +627,7 @@ public class Upkeep extends Phase implements java.io.Serializable { */ final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList cards = player.getCardsIn(ZoneType.Battlefield, "Demonic Hordes"); + final List cards = player.getCardsIn(ZoneType.Battlefield, "Demonic Hordes"); for (int i = 0; i < cards.size(); i++) { @@ -635,7 +636,7 @@ public class Upkeep extends Phase implements java.io.Serializable { final Ability noPay = new Ability(c, "B B B") { @Override public void resolve() { - final CardList playerLand = AllZoneUtil.getPlayerLandsInPlay(player); + final List playerLand = AllZoneUtil.getPlayerLandsInPlay(player); c.tap(); if (c.getController().isComputer()) { @@ -714,7 +715,7 @@ public class Upkeep extends Phase implements java.io.Serializable { private static void upkeepInkDissolver() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); final Player opponent = player.getOpponent(); - final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Ink Dissolver"); + final List kinship = player.getCardsIn(ZoneType.Battlefield, "Ink Dissolver"); final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is @@ -800,7 +801,7 @@ public class Upkeep extends Phase implements java.io.Serializable { */ private static void upkeepKithkinZephyrnaut() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Kithkin Zephyrnaut"); + final List kinship = player.getCardsIn(ZoneType.Battlefield, "Kithkin Zephyrnaut"); final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is @@ -902,7 +903,7 @@ public class Upkeep extends Phase implements java.io.Serializable { */ private static void upkeepLeafCrownedElder() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Leaf-Crowned Elder"); + final List kinship = player.getCardsIn(ZoneType.Battlefield, "Leaf-Crowned Elder"); final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is @@ -1002,7 +1003,7 @@ public class Upkeep extends Phase implements java.io.Serializable { */ private static void upkeepMudbuttonClanger() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Mudbutton Clanger"); + final List kinship = player.getCardsIn(ZoneType.Battlefield, "Mudbutton Clanger"); final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is @@ -1099,7 +1100,7 @@ public class Upkeep extends Phase implements java.io.Serializable { */ private static void upkeepNightshadeSchemers() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Nightshade Schemers"); + final List kinship = player.getCardsIn(ZoneType.Battlefield, "Nightshade Schemers"); final Player opponent = player.getOpponent(); final PlayerZone library = player.getZone(ZoneType.Library); @@ -1184,7 +1185,7 @@ public class Upkeep extends Phase implements java.io.Serializable { */ private static void upkeepPyroclastConsul() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Pyroclast Consul"); + final List kinship = player.getCardsIn(ZoneType.Battlefield, "Pyroclast Consul"); final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is @@ -1213,11 +1214,11 @@ public class Upkeep extends Phase implements java.io.Serializable { boolean wantDamageCreatures = false; final String[] smallCreatures = { "Creature.toughnessLE2" }; - CardList humanCreatures = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + List humanCreatures = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); humanCreatures = CardListUtil.getValidCards(humanCreatures, smallCreatures, k.getController(), k); humanCreatures = CardListUtil.getNotKeyword(humanCreatures, "Indestructible"); - CardList computerCreatures = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); + List computerCreatures = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); computerCreatures = CardListUtil.getValidCards(computerCreatures, smallCreatures, k.getController(), k); computerCreatures = CardListUtil.getNotKeyword(computerCreatures, "Indestructible"); @@ -1251,7 +1252,7 @@ public class Upkeep extends Phase implements java.io.Serializable { } if (wantDamageCreatures) { - final CardList allCreatures = AllZoneUtil.getCreaturesInPlay(); + final List allCreatures = AllZoneUtil.getCreaturesInPlay(); for (final Card crd : allCreatures) { crd.addDamage(2, k); } @@ -1283,7 +1284,7 @@ public class Upkeep extends Phase implements java.io.Serializable { */ private static void upkeepSensationGorger() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Sensation Gorger"); + final List kinship = player.getCardsIn(ZoneType.Battlefield, "Sensation Gorger"); final Player opponent = player.getOpponent(); final PlayerZone library = player.getZone(ZoneType.Library); @@ -1375,7 +1376,7 @@ public class Upkeep extends Phase implements java.io.Serializable { */ private static void upkeepSqueakingPieGrubfellows() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Squeaking Pie Grubfellows"); + final List kinship = player.getCardsIn(ZoneType.Battlefield, "Squeaking Pie Grubfellows"); final Player opponent = player.getOpponent(); final PlayerZone library = player.getZone(ZoneType.Library); @@ -1461,7 +1462,7 @@ public class Upkeep extends Phase implements java.io.Serializable { */ private static void upkeepWanderingGraybeard() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Wandering Graybeard"); + final List kinship = player.getCardsIn(ZoneType.Battlefield, "Wandering Graybeard"); final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is @@ -1545,7 +1546,7 @@ public class Upkeep extends Phase implements java.io.Serializable { */ private static void upkeepWaterspoutWeavers() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Waterspout Weavers"); + final List kinship = player.getCardsIn(ZoneType.Battlefield, "Waterspout Weavers"); final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is @@ -1602,7 +1603,7 @@ public class Upkeep extends Phase implements java.io.Serializable { } if (wantMerfolkBuff) { - final CardList creatures = AllZoneUtil.getCreaturesInPlay(player); + final List creatures = AllZoneUtil.getCreaturesInPlay(player); for (int i = 0; i < creatures.size(); i++) { if (!creatures.get(i).hasKeyword("Flying")) { creatures.get(i).addExtrinsicKeyword("Flying"); @@ -1613,7 +1614,7 @@ public class Upkeep extends Phase implements java.io.Serializable { @Override public void execute() { - final CardList creatures = AllZoneUtil.getCreaturesInPlay(player); + final List creatures = AllZoneUtil.getCreaturesInPlay(player); for (int i = 0; i < creatures.size(); i++) { if (creatures.get(i).hasKeyword("Flying")) { creatures.get(i).removeExtrinsicKeyword("Flying"); @@ -1650,7 +1651,7 @@ public class Upkeep extends Phase implements java.io.Serializable { */ private static void upkeepWinnowerPatrol() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Winnower Patrol"); + final List kinship = player.getCardsIn(ZoneType.Battlefield, "Winnower Patrol"); final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is @@ -1734,7 +1735,7 @@ public class Upkeep extends Phase implements java.io.Serializable { */ private static void upkeepWolfSkullShaman() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Wolf-Skull Shaman"); + final List kinship = player.getCardsIn(ZoneType.Battlefield, "Wolf-Skull Shaman"); final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is @@ -1826,7 +1827,7 @@ public class Upkeep extends Phase implements java.io.Serializable { private static void upkeepSuspend() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - CardList list = player.getCardsIn(ZoneType.Exile); + List list = player.getCardsIn(ZoneType.Exile); list = CardListUtil.filter(list, new Predicate() { @Override @@ -1855,7 +1856,7 @@ public class Upkeep extends Phase implements java.io.Serializable { private static void upkeepVanishing() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - CardList list = player.getCardsIn(ZoneType.Battlefield); + List list = player.getCardsIn(ZoneType.Battlefield); list = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { @@ -1892,7 +1893,7 @@ public class Upkeep extends Phase implements java.io.Serializable { private static void upkeepFading() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - CardList list = player.getCardsIn(ZoneType.Battlefield); + List list = player.getCardsIn(ZoneType.Battlefield); list = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { @@ -1932,7 +1933,7 @@ public class Upkeep extends Phase implements java.io.Serializable { *

*/ private static void upkeepOathOfDruids() { - final CardList oathList = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Oath of Druids"); + final List oathList = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Oath of Druids"); if (oathList.isEmpty()) { return; } @@ -1945,7 +1946,7 @@ public class Upkeep extends Phase implements java.io.Serializable { final Ability ability = new Ability(oath, "0") { @Override public void resolve() { - final CardList libraryList = player.getCardsIn(ZoneType.Library); + final List libraryList = player.getCardsIn(ZoneType.Library); final PlayerZone battlefield = player.getZone(ZoneType.Battlefield); boolean oathFlag = true; @@ -1958,8 +1959,8 @@ public class Upkeep extends Phase implements java.io.Serializable { oathFlag = false; } } else { // if player == Computer - final CardList creaturesInLibrary = CardListUtil.filter(player.getCardsIn(ZoneType.Library), CardPredicates.Presets.CREATURES); - final CardList creaturesInBattlefield = CardListUtil.filter(player.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES); + final List creaturesInLibrary = CardListUtil.filter(player.getCardsIn(ZoneType.Library), CardPredicates.Presets.CREATURES); + final List creaturesInBattlefield = CardListUtil.filter(player.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.CREATURES); // if there are at least 3 creatures in library, // or none in play with one in library, oath @@ -1972,7 +1973,7 @@ public class Upkeep extends Phase implements java.io.Serializable { } if (oathFlag) { - final CardList cardsToReveal = new CardList(); + final List cardsToReveal = new ArrayList(); final int max = libraryList.size(); for (int i = 0; i < max; i++) { final Card c = libraryList.get(i); @@ -2013,7 +2014,7 @@ public class Upkeep extends Phase implements java.io.Serializable { *

*/ private static void upkeepOathOfGhouls() { - final CardList oathList = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Oath of Ghouls"); + final List oathList = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Oath of Ghouls"); if (oathList.isEmpty()) { return; } @@ -2025,7 +2026,7 @@ public class Upkeep extends Phase implements java.io.Serializable { final Ability ability = new Ability(oathList.get(0), "0") { @Override public void resolve() { - final CardList graveyardCreatures = CardListUtil.filter(player.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES); + final List graveyardCreatures = CardListUtil.filter(player.getCardsIn(ZoneType.Graveyard), CardPredicates.Presets.CREATURES); if (AllZoneUtil.compareTypeAmountInGraveyard(player, "Creature") > 0) { if (player.isHuman()) { @@ -2063,8 +2064,8 @@ public class Upkeep extends Phase implements java.io.Serializable { */ private static void upkeepKarma() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList karmas = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Karma"); - final CardList swamps = CardListUtil.getType(player.getCardsIn(ZoneType.Battlefield), "Swamp"); + final List karmas = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Karma"); + final List swamps = CardListUtil.getType(player.getCardsIn(ZoneType.Battlefield), "Swamp"); // determine how much damage to deal the current player final int damage = swamps.size(); @@ -2108,7 +2109,7 @@ public class Upkeep extends Phase implements java.io.Serializable { * controlled at the beginning of this turn. */ final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Power Surge"); + final List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Power Surge"); final int damage = player.getNumPowerSurgeLands(); for (final Card surge : list) { @@ -2138,14 +2139,14 @@ public class Upkeep extends Phase implements java.io.Serializable { */ private static void upkeepTangleWire() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList wires = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Tangle Wire"); + final List wires = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Tangle Wire"); for (final Card source : wires) { final SpellAbility ability = new Ability(source, "0") { @Override public void resolve() { final int num = source.getCounters(Counters.FADE); - final CardList list = CardListUtil.filter(player.getCardsIn(ZoneType.Battlefield), new Predicate() { + final List list = CardListUtil.filter(player.getCardsIn(ZoneType.Battlefield), new Predicate() { @Override public boolean apply(final Card c) { return (c.isArtifact() || c.isLand() || c.isCreature()) && c.isUntapped(); @@ -2156,7 +2157,7 @@ public class Upkeep extends Phase implements java.io.Serializable { if (player.isComputer()) { Card toTap = CardFactoryUtil.getWorstPermanentAI(list, false, false, false, false); // try to find non creature cards without tap abilities - CardList betterList = CardListUtil.filter(list, new Predicate() { + List betterList = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { if (c.isCreature()) { @@ -2230,7 +2231,7 @@ public class Upkeep extends Phase implements java.io.Serializable { private static void upkeepBlazeCounters() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - CardList blaze = player.getCardsIn(ZoneType.Battlefield); + List blaze = player.getCardsIn(ZoneType.Battlefield); blaze = CardListUtil.filter(blaze, new Predicate() { @Override public boolean apply(final Card c) { @@ -2265,7 +2266,7 @@ public class Upkeep extends Phase implements java.io.Serializable { private static void upkeepCurseOfMisfortunes() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList misfortunes = player.getCardsIn(ZoneType.Battlefield, "Curse of Misfortunes"); + final List misfortunes = player.getCardsIn(ZoneType.Battlefield, "Curse of Misfortunes"); for (int i = 0; i < misfortunes.size(); i++) { final Card source = misfortunes.get(i); @@ -2273,8 +2274,8 @@ public class Upkeep extends Phase implements java.io.Serializable { final Ability ability = new Ability(source, "0") { @Override public void resolve() { - CardList enchantmentsInLibrary = source.getController().getCardsIn(ZoneType.Library); - final CardList enchantmentsAttached = new CardList(source.getEnchantingPlayer().getEnchantedBy()); + List enchantmentsInLibrary = source.getController().getCardsIn(ZoneType.Library); + final List enchantmentsAttached = new ArrayList(source.getEnchantingPlayer().getEnchantedBy()); enchantmentsInLibrary = CardListUtil.filter(enchantmentsInLibrary, new Predicate() { @Override public boolean apply(final Card c) { diff --git a/src/main/java/forge/game/player/AIPlayer.java b/src/main/java/forge/game/player/AIPlayer.java index ee3225e051e..25b9cef2c8a 100644 --- a/src/main/java/forge/game/player/AIPlayer.java +++ b/src/main/java/forge/game/player/AIPlayer.java @@ -17,13 +17,14 @@ */ package forge.game.player; +import java.util.List; import java.util.Random; import com.google.common.collect.Iterables; import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.Singletons; @@ -134,7 +135,7 @@ public class AIPlayer extends Player { */ @Override public final boolean dredge() { - final CardList dredgers = this.getDredge(); + final List dredgers = this.getDredge(); final Random random = MyRandom.getRandom(); // use dredge if there are more than one of them in your graveyard @@ -164,10 +165,10 @@ public class AIPlayer extends Player { /** {@inheritDoc} */ @Override - public final CardList discard(final int num, final SpellAbility sa, final boolean duringResolution) { + public final List discard(final int num, final SpellAbility sa, final boolean duringResolution) { int max = this.getCardsIn(ZoneType.Hand).size(); max = Math.min(max, num); - final CardList discarded = ComputerUtil.discardNumTypeAI(max, null, sa); + final List discarded = ComputerUtil.discardNumTypeAI(max, null, sa); for (int i = 0; i < discarded.size(); i++) { this.doDiscard(discarded.get(i), sa); } @@ -178,8 +179,8 @@ public class AIPlayer extends Player { /** {@inheritDoc} */ @Override public final void discardUnless(final int num, final String uType, final SpellAbility sa) { - final CardList hand = this.getCardsIn(ZoneType.Hand); - final CardList tHand = CardListUtil.getType(hand, uType); + final List hand = this.getCardsIn(ZoneType.Hand); + final List tHand = CardListUtil.getType(hand, uType); if (tHand.size() > 0) { Card toDiscard = Aggregates.itemWithMin(tHand, CardPredicates.Accessors.fnGetCmc); @@ -194,18 +195,18 @@ public class AIPlayer extends Player { /** {@inheritDoc} */ @Override - protected final void doScry(final CardList topN, final int n) { + protected final void doScry(final List topN, final int n) { int num = n; for (int i = 0; i < num; i++) { boolean bottom = false; if (topN.get(i).isBasicLand()) { - CardList bl = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List bl = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); int nBasicLands = Iterables.size(Iterables.filter(bl, CardPredicates.Presets.BASIC_LANDS)); bottom = nBasicLands > 5; // if control more than 5 Basic land, // probably don't need more } else if (topN.get(i).isCreature()) { - CardList cl = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + List cl = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); cl = CardListUtil.filter(cl, CardPredicates.Presets.CREATURES); bottom = cl.size() > 5; // if control more than 5 Creatures, // probably don't need more @@ -229,7 +230,7 @@ public class AIPlayer extends Player { /** {@inheritDoc} */ @Override - public final void sacrificePermanent(final String prompt, final CardList choices) { + public final void sacrificePermanent(final String prompt, final List choices) { if (choices.size() > 0) { // TODO - this could probably use better AI final Card c = CardFactoryUtil.getWorstPermanentAI(choices, false, false, false, false); diff --git a/src/main/java/forge/game/player/ComputerAIGeneral.java b/src/main/java/forge/game/player/ComputerAIGeneral.java index 16c4eb30ff3..0bb72c0f787 100644 --- a/src/main/java/forge/game/player/ComputerAIGeneral.java +++ b/src/main/java/forge/game/player/ComputerAIGeneral.java @@ -26,7 +26,7 @@ import com.esotericsoftware.minlog.Log; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; import forge.card.cardfactory.CardFactoryUtil; @@ -79,7 +79,7 @@ public class ComputerAIGeneral implements Computer { * a {@link java.lang.String} object. */ private void playSpellAbilitiesStackEmpty() { - final CardList list = getAvailableCards(); + final List list = getAvailableCards(); final boolean nextPhase = ComputerUtil.playSpellAbilities(getSpellAbilities(list)); @@ -96,7 +96,7 @@ public class ComputerAIGeneral implements Computer { * @return a boolean. */ public static boolean hasACardGivingHaste() { - final CardList all = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + final List all = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); all.addAll(CardFactoryUtil.getExternalZoneActivationCards(AllZone.getComputerPlayer())); all.addAll(AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand)); @@ -129,10 +129,10 @@ public class ComputerAIGeneral implements Computer { * * @return a {@link forge.CardList} object. */ - private CardList getAvailableCards() { + private List getAvailableCards() { final Player computer = AllZone.getComputerPlayer(); final Player human = AllZone.getHumanPlayer(); - CardList all = computer.getCardsIn(ZoneType.Hand); + List all = computer.getCardsIn(ZoneType.Hand); all.addAll(computer.getCardsIn(ZoneType.Battlefield)); all.addAll(computer.getCardsIn(ZoneType.Exile)); all.addAll(computer.getCardsIn(ZoneType.Graveyard)); @@ -210,7 +210,7 @@ public class ComputerAIGeneral implements Computer { private ArrayList getPossibleETBCounters() { final Player computer = AllZone.getComputerPlayer(); final Player human = AllZone.getHumanPlayer(); - CardList all = computer.getCardsIn(ZoneType.Hand); + List all = computer.getCardsIn(ZoneType.Hand); all.addAll(computer.getCardsIn(ZoneType.Exile)); all.addAll(computer.getCardsIn(ZoneType.Graveyard)); if (!computer.getCardsIn(ZoneType.Library).isEmpty()) { @@ -238,7 +238,7 @@ public class ComputerAIGeneral implements Computer { * a {@link forge.CardList} object. * @return an array of {@link forge.card.spellability.SpellAbility} objects. */ - private ArrayList getSpellAbilities(final CardList l) { + private ArrayList getSpellAbilities(final List l) { final ArrayList spellAbilities = new ArrayList(); for (final Card c : l) { for (final SpellAbility sa : c.getNonManaSpellAbilities()) { @@ -257,7 +257,7 @@ public class ComputerAIGeneral implements Computer { * a {@link forge.CardList} object. * @return a {@link java.util.ArrayList} object. */ - private ArrayList getPlayableCounters(final CardList l) { + private ArrayList getPlayableCounters(final List l) { final ArrayList spellAbility = new ArrayList(); for (final Card c : l) { for (final SpellAbility sa : c.getNonManaSpellAbilities()) { @@ -307,7 +307,7 @@ public class ComputerAIGeneral implements Computer { */ @Override public final void declareBlockers() { - final CardList blockers = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); + final List blockers = AllZoneUtil.getCreaturesInPlay(AllZone.getComputerPlayer()); AllZone.setCombat(ComputerUtilBlock.getBlockers(AllZone.getCombat(), blockers)); @@ -347,7 +347,7 @@ public class ComputerAIGeneral implements Computer { Singletons.getModel().getGameState().getPhaseHandler().passPriority(); return; } - final CardList cards = getAvailableCards(); + final List cards = getAvailableCards(); // top of stack is owned by human, ArrayList possibleCounters = getPlayableCounters(cards); diff --git a/src/main/java/forge/game/player/ComputerUtil.java b/src/main/java/forge/game/player/ComputerUtil.java index 771ffd661df..e002087e745 100644 --- a/src/main/java/forge/game/player/ComputerUtil.java +++ b/src/main/java/forge/game/player/ComputerUtil.java @@ -31,7 +31,7 @@ import com.google.common.collect.Iterables; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.CardPredicates.Presets; @@ -991,7 +991,7 @@ public class ComputerUtil { * * @return a {@link forge.CardList} object. */ - public static CardList getAvailableMana(boolean checkPlayable) { + public static List getAvailableMana(boolean checkPlayable) { return ComputerUtil.getAvailableMana(AllZone.getComputerPlayer(), checkPlayable); } // getAvailableMana() @@ -1006,9 +1006,9 @@ public class ComputerUtil { * @param checkPlayable * @return a {@link forge.CardList} object. */ - public static CardList getAvailableMana(final Player player, final boolean checkPlayable) { - final CardList list = player.getCardsIn(ZoneType.Battlefield); - final CardList manaSources = CardListUtil.filter(list, new Predicate() { + public static List getAvailableMana(final Player player, final boolean checkPlayable) { + final List list = player.getCardsIn(ZoneType.Battlefield); + final List manaSources = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { if (checkPlayable) { @@ -1026,15 +1026,15 @@ public class ComputerUtil { } }); // CardListFilter - final CardList sortedManaSources = new CardList(); - final CardList otherManaSources = new CardList(); - final CardList colorlessManaSources = new CardList(); - final CardList oneManaSources = new CardList(); - final CardList twoManaSources = new CardList(); - final CardList threeManaSources = new CardList(); - final CardList fourManaSources = new CardList(); - final CardList fiveManaSources = new CardList(); - final CardList anyColorManaSources = new CardList(); + final List sortedManaSources = new ArrayList(); + final List otherManaSources = new ArrayList(); + final List colorlessManaSources = new ArrayList(); + final List oneManaSources = new ArrayList(); + final List twoManaSources = new ArrayList(); + final List threeManaSources = new ArrayList(); + final List fourManaSources = new ArrayList(); + final List fiveManaSources = new ArrayList(); + final List anyColorManaSources = new ArrayList(); // Sort mana sources // 1. Use lands that can only produce colorless mana without @@ -1129,7 +1129,7 @@ public class ComputerUtil { * @param player * a {@link forge.game.player.Player} object. * @param checkPlayable TODO - * @return HashMap + * @return HashMap> */ public static HashMap> mapManaSources(final Player player, boolean checkPlayable) { final HashMap> manaMap = new HashMap>(); @@ -1143,7 +1143,7 @@ public class ComputerUtil { final ArrayList snowSources = new ArrayList(); // Get list of current available mana sources - final CardList manaSources = ComputerUtil.getAvailableMana(checkPlayable); + final List manaSources = ComputerUtil.getAvailableMana(checkPlayable); // Loop over all mana sources for (int i = 0; i < manaSources.size(); i++) { @@ -1304,11 +1304,11 @@ public class ComputerUtil { if (!computer.canPlayLand()) { return false; } - final CardList hand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); - CardList landList = CardListUtil.filter(hand, Presets.LANDS); - CardList nonLandList = CardListUtil.filter(hand, Predicates.not(CardPredicates.Presets.LANDS)); + final List hand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); + List landList = CardListUtil.filter(hand, Presets.LANDS); + List nonLandList = CardListUtil.filter(hand, Predicates.not(CardPredicates.Presets.LANDS)); - final CardList lands = computer.getCardsIn(ZoneType.Graveyard); + final List lands = computer.getCardsIn(ZoneType.Graveyard); for (final Card crd : lands) { if (crd.isLand() && crd.hasKeyword("May be played")) { landList.add(crd); @@ -1318,9 +1318,9 @@ public class ComputerUtil { return false; } if (landList.size() == 1 && nonLandList.size() < 3) { - CardList cardsInPlay = computer.getCardsIn(ZoneType.Battlefield); - CardList landsInPlay = CardListUtil.filter(cardsInPlay, Presets.LANDS); - CardList allCards = computer.getCardsIn(ZoneType.Graveyard); + List cardsInPlay = computer.getCardsIn(ZoneType.Battlefield); + List landsInPlay = CardListUtil.filter(cardsInPlay, Presets.LANDS); + List allCards = computer.getCardsIn(ZoneType.Graveyard); allCards.addAll(cardsInPlay); int maxCmcInHand = Aggregates.max(hand, CardPredicates.Accessors.fnGetCmc); int max = Math.max(maxCmcInHand, 6); @@ -1345,7 +1345,7 @@ public class ComputerUtil { public boolean apply(final Card c) { if (c.getSVar("NeedsToPlay").length() > 0) { final String needsToPlay = c.getSVar("NeedsToPlay"); - CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = CardListUtil.getValidCards(list, needsToPlay.split(","), c.getController(), c); if (list.isEmpty()) { @@ -1353,7 +1353,7 @@ public class ComputerUtil { } } if (c.isType("Legendary") && !c.getName().equals("Flagstones of Trokair")) { - final CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + final List list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); if (Iterables.any(list, CardPredicates.nameEquals(c.getName()))) { return false; } @@ -1363,8 +1363,8 @@ public class ComputerUtil { // available final ArrayList spellAbilities = c.getSpellAbilities(); - final CardList hand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); - CardList lands = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + final List hand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); + List lands = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); lands.addAll(hand); lands = CardListUtil.filter(lands, CardPredicates.Presets.LANDS); int maxCmcInHand = Aggregates.max(hand, CardPredicates.Accessors.fnGetCmc); @@ -1391,7 +1391,7 @@ public class ComputerUtil { Card land = landList.get(ix); //play basic lands that are needed the most if (!Iterables.any(landList, CardPredicates.Presets.BASIC_LANDS)) { - final CardList combined = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + final List combined = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); final ArrayList basics = new ArrayList(); @@ -1445,12 +1445,12 @@ public class ComputerUtil { * a {@link forge.CardList} object. * @return a {@link forge.Card} object. */ - public static Card getCardPreference(final Card activate, final String pref, final CardList typeList) { + public static Card getCardPreference(final Card activate, final String pref, final List typeList) { if (activate != null) { final String[] prefValid = activate.getSVar("AIPreference").split("\\$"); if (prefValid[0].equals(pref)) { - final CardList prefList = CardListUtil.getValidCards(typeList, prefValid[1].split(","), activate.getController(), activate); + final List prefList = CardListUtil.getValidCards(typeList, prefValid[1].split(","), activate.getController(), activate); if (prefList.size() != 0) { CardListUtil.shuffle(prefList); return prefList.get(0); @@ -1461,7 +1461,7 @@ public class ComputerUtil { for (int ip = 0; ip < 6; ip++) { // priority 0 is the lowest, // priority 5 the highest final int priority = 6 - ip; - final CardList sacMeList = CardListUtil.filter(typeList, new Predicate() { + final List sacMeList = CardListUtil.filter(typeList, new Predicate() { @Override public boolean apply(final Card c) { return (!c.getSVar("SacMe").equals("") && (Integer.parseInt(c.getSVar("SacMe")) == priority)); @@ -1491,10 +1491,10 @@ public class ComputerUtil { } // Discard lands - final CardList landsInHand = CardListUtil.getType(typeList, "Land"); + final List landsInHand = CardListUtil.getType(typeList, "Land"); if (!landsInHand.isEmpty()) { - final CardList landsInPlay = CardListUtil.getType(AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield), "Land"); - final CardList nonLandsInHand = CardListUtil.getNotType(AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand), "Land"); + final List landsInPlay = CardListUtil.getType(AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield), "Land"); + final List nonLandsInHand = CardListUtil.getNotType(AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand), "Land"); final int highestCMC = Math.max(6, Aggregates.max(nonLandsInHand, CardPredicates.Accessors.fnGetCmc)); if (landsInPlay.size() >= highestCMC || (landsInPlay.size() + landsInHand.size() > 6 && landsInHand.size() > 1)) { @@ -1522,10 +1522,10 @@ public class ComputerUtil { * a int. * @return a {@link forge.CardList} object. */ - public static CardList chooseSacrificeType(final String type, final Card activate, final Card target, + public static List chooseSacrificeType(final String type, final Card activate, final Card target, final int amount) { Player activator = AllZone.getComputerPlayer(); - CardList typeList = activator.getCardsIn(ZoneType.Battlefield); + List typeList = activator.getCardsIn(ZoneType.Battlefield); typeList = CardListUtil.getValidCards(typeList, type.split(";"), activate.getController(), activate); if (activator.hasKeyword("You can't sacrifice creatures to cast spells or activate abilities.")) { typeList = CardListUtil.getNotType(typeList, "Creature"); @@ -1539,7 +1539,7 @@ public class ComputerUtil { return null; } - final CardList sacList = new CardList(); + final List sacList = new ArrayList(); int count = 0; while (count < amount) { @@ -1573,10 +1573,10 @@ public class ComputerUtil { * no restrictions. * @param sa * a {@link forge.card.spellability.SpellAbility} object. - * @return a CardList of discarded cards. + * @return a List of discarded cards. */ - public static CardList discardNumTypeAI(final int numDiscard, final String[] uTypes, final SpellAbility sa) { - CardList hand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); + public static List discardNumTypeAI(final int numDiscard, final String[] uTypes, final SpellAbility sa) { + List hand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); Card sourceCard = null; if ((uTypes != null) && (sa != null)) { @@ -1587,7 +1587,7 @@ public class ComputerUtil { return null; } - final CardList discardList = new CardList(); + final List discardList = new ArrayList(); int count = 0; if (sa != null) { sourceCard = sa.getSourceCard(); @@ -1626,7 +1626,7 @@ public class ComputerUtil { } List aiCards = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); final int numLandsInPlay = Iterables.size(Iterables.filter(aiCards, CardPredicates.Presets.LANDS)); - final CardList landsInHand = CardListUtil.filter(hand, CardPredicates.Presets.LANDS); + final List landsInHand = CardListUtil.filter(hand, CardPredicates.Presets.LANDS); final int numLandsInHand = landsInHand.size(); // Discard a land @@ -1671,7 +1671,7 @@ public class ComputerUtil { * a int. * @return a {@link forge.CardList} object. */ - public static CardList chooseExileType(final String type, final Card activate, final Card target, final int amount) { + public static List chooseExileType(final String type, final Card activate, final Card target, final int amount) { return ComputerUtil.chooseExileFrom(ZoneType.Battlefield, type, activate, target, amount); } @@ -1690,7 +1690,7 @@ public class ComputerUtil { * a int. * @return a {@link forge.CardList} object. */ - public static CardList chooseExileFromHandType(final String type, final Card activate, final Card target, + public static List chooseExileFromHandType(final String type, final Card activate, final Card target, final int amount) { return ComputerUtil.chooseExileFrom(ZoneType.Hand, type, activate, target, amount); } @@ -1710,7 +1710,7 @@ public class ComputerUtil { * a int. * @return a {@link forge.CardList} object. */ - public static CardList chooseExileFromGraveType(final String type, final Card activate, final Card target, + public static List chooseExileFromGraveType(final String type, final Card activate, final Card target, final int amount) { return ComputerUtil.chooseExileFrom(ZoneType.Graveyard, type, activate, target, amount); } @@ -1730,7 +1730,7 @@ public class ComputerUtil { * a int. * @return a {@link forge.CardList} object. */ - public static CardList chooseExileFromStackType(final String type, final Card activate, final Card target, + public static List chooseExileFromStackType(final String type, final Card activate, final Card target, final int amount) { return ComputerUtil.chooseExileFrom(ZoneType.Stack, type, activate, target, amount); } @@ -1752,9 +1752,9 @@ public class ComputerUtil { * a int. * @return a {@link forge.CardList} object. */ - public static CardList chooseExileFrom(final ZoneType zone, final String type, final Card activate, + public static List chooseExileFrom(final ZoneType zone, final String type, final Card activate, final Card target, final int amount) { - CardList typeList = new CardList(); + List typeList = new ArrayList(); if (zone.equals(ZoneType.Stack)) { for (int i = 0; i < AllZone.getStack().size(); i++) { typeList.add(AllZone.getStack().peekAbility(i).getSourceCard()); @@ -1773,7 +1773,7 @@ public class ComputerUtil { } CardListUtil.sortAttackLowFirst(typeList); - final CardList exileList = new CardList(); + final List exileList = new ArrayList(); for (int i = 0; i < amount; i++) { exileList.add(typeList.get(i)); @@ -1796,8 +1796,8 @@ public class ComputerUtil { * a int. * @return a {@link forge.CardList} object. */ - public static CardList chooseTapType(final String type, final Card activate, final boolean tap, final int amount) { - CardList typeList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + public static List chooseTapType(final String type, final Card activate, final boolean tap, final int amount) { + List typeList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); typeList = CardListUtil.getValidCards(typeList, type.split(","), activate.getController(), activate); // is this needed? @@ -1813,7 +1813,7 @@ public class ComputerUtil { CardListUtil.sortAttackLowFirst(typeList); - final CardList tapList = new CardList(); + final List tapList = new ArrayList(); for (int i = 0; i < amount; i++) { tapList.add(typeList.get(i)); @@ -1836,8 +1836,8 @@ public class ComputerUtil { * a int. * @return a {@link forge.CardList} object. */ - public static CardList chooseUntapType(final String type, final Card activate, final boolean untap, final int amount) { - CardList typeList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + public static List chooseUntapType(final String type, final Card activate, final boolean untap, final int amount) { + List typeList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); typeList = CardListUtil.getValidCards(typeList, type.split(","), activate.getController(), activate); // is this needed? @@ -1853,7 +1853,7 @@ public class ComputerUtil { CardListUtil.sortAttack(typeList); - final CardList untapList = new CardList(); + final List untapList = new ArrayList(); for (int i = 0; i < amount; i++) { untapList.add(typeList.get(i)); @@ -1876,8 +1876,8 @@ public class ComputerUtil { * a int. * @return a {@link forge.CardList} object. */ - public static CardList chooseReturnType(final String type, final Card activate, final Card target, final int amount) { - CardList typeList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + public static List chooseReturnType(final String type, final Card activate, final Card target, final int amount) { + List typeList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); typeList = CardListUtil.getValidCards(typeList, type.split(","), activate.getController(), activate); if ((target != null) && target.getController().isComputer() && typeList.contains(target)) { // bounce @@ -1893,7 +1893,7 @@ public class ComputerUtil { } CardListUtil.sortAttackLowFirst(typeList); - final CardList returnList = new CardList(); + final List returnList = new ArrayList(); for (int i = 0; i < amount; i++) { returnList.add(typeList.get(i)); @@ -1908,8 +1908,8 @@ public class ComputerUtil { * * @return a {@link forge.CardList} object. */ - public static CardList getPossibleAttackers() { - CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + public static List getPossibleAttackers() { + List list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); list = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { @@ -1941,7 +1941,7 @@ public class ComputerUtil { * @return a {@link forge.game.phase.Combat} object. */ public static Combat getBlockers() { - final CardList blockers = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + final List blockers = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); return ComputerUtilBlock.getBlockers(AllZone.getCombat(), blockers); } @@ -2020,9 +2020,9 @@ public class ComputerUtil { * the source SpellAbility * @return the card list */ - public static CardList sacrificePermanents(final int amount, final CardList list, final boolean destroy, + public static List sacrificePermanents(final int amount, final List list, final boolean destroy, SpellAbility source) { - final CardList sacList = new CardList(); + final List sacList = new ArrayList(); // used in Annihilator and AF_Sacrifice int max = list.size(); if (max > amount) { @@ -2036,7 +2036,7 @@ public class ComputerUtil { Card c = null; if (destroy) { - final CardList indestructibles = CardListUtil.getKeyword(list, "Indestructible"); + final List indestructibles = CardListUtil.getKeyword(list, "Indestructible"); if (!indestructibles.isEmpty()) { c = indestructibles.get(0); } @@ -2104,7 +2104,7 @@ public class ComputerUtil { } final Player controller = card.getController(); - final CardList l = controller.getCardsIn(ZoneType.Battlefield); + final List l = controller.getCardsIn(ZoneType.Battlefield); for (final Card c : l) { for (final SpellAbility sa : c.getSpellAbility()) { // This try/catch should fix the "computer is thinking" bug @@ -2155,7 +2155,7 @@ public class ComputerUtil { int prevented = 0; final Player controller = card.getController(); - final CardList l = controller.getCardsIn(ZoneType.Battlefield); + final List l = controller.getCardsIn(ZoneType.Battlefield); for (final Card c : l) { for (final SpellAbility sa : c.getSpellAbility()) { // if SA is from AF_Counter don't add to getPlayable @@ -2210,7 +2210,7 @@ public class ComputerUtil { } // get all cards the computer controls with BuffedBy - final CardList buffed = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + final List buffed = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); for (int j = 0; j < buffed.size(); j++) { final Card buffedcard = buffed.get(j); if (buffedcard.getSVar("BuffedBy").length() > 0) { @@ -2232,7 +2232,7 @@ public class ComputerUtil { } // BuffedBy // get all cards the human controls with AntiBuffedBy - final CardList antibuffed = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + final List antibuffed = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); for (int k = 0; k < antibuffed.size(); k++) { final Card buffedcard = antibuffed.get(k); if (buffedcard.getSVar("AntiBuffedBy").length() > 0) { @@ -2243,10 +2243,10 @@ public class ComputerUtil { } } } // AntiBuffedBy - final CardList vengevines = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard, "Vengevine"); + final List vengevines = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard, "Vengevine"); if (vengevines.size() > 0) { - final CardList creatures = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); - final CardList creatures2 = new CardList(); + final List creatures = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); + final List creatures2 = new ArrayList(); for (int i = 0; i < creatures.size(); i++) { if (creatures.get(i).isCreature() && creatures.get(i).getManaCost().getCMC() <= 3) { creatures2.add(creatures.get(i)); @@ -2273,7 +2273,7 @@ public class ComputerUtil { // Otherwise, if life is possibly in danger, then this is fine. Combat combat = new Combat(); combat.initiatePossibleDefenders(AllZone.getComputerPlayer()); - CardList attackers = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); + List attackers = AllZoneUtil.getCreaturesInPlay(AllZone.getHumanPlayer()); for (Card att : attackers) { if (CombatUtil.canAttackNextTurn(att)) { combat.addAttacker(att); @@ -2297,9 +2297,9 @@ public class ComputerUtil { if (!discard.getSVar("DiscardMe").equals("")) { return true; } - final CardList landsInPlay = CardListUtil.filter(AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.LANDS); - final CardList landsInHand = CardListUtil.filter(AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand), CardPredicates.Presets.LANDS); - final CardList nonLandsInHand = CardListUtil.getNotType(AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand), "Land"); + final List landsInPlay = CardListUtil.filter(AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.LANDS); + final List landsInHand = CardListUtil.filter(AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand), CardPredicates.Presets.LANDS); + final List nonLandsInHand = CardListUtil.getNotType(AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand), "Land"); final int highestCMC = Math.max(6, Aggregates.max(nonLandsInHand, CardPredicates.Accessors.fnGetCmc)); final int discardCMC = discard.getCMC(); if (discard.isLand()) { diff --git a/src/main/java/forge/game/player/ComputerUtilAttack.java b/src/main/java/forge/game/player/ComputerUtilAttack.java index d7563ab34a6..256c923c42b 100644 --- a/src/main/java/forge/game/player/ComputerUtilAttack.java +++ b/src/main/java/forge/game/player/ComputerUtilAttack.java @@ -17,6 +17,7 @@ */ package forge.game.player; +import java.util.ArrayList; import java.util.List; import java.util.Random; @@ -25,7 +26,7 @@ import com.google.common.base.Predicate; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.Counters; @@ -52,14 +53,14 @@ import forge.util.MyRandom; public class ComputerUtilAttack { // possible attackers and blockers - private final CardList attackers; - private final CardList blockers; + private final List attackers; + private final List blockers; private final Random random = MyRandom.getRandom(); private final int randomInt = this.random.nextInt(); - private CardList humanList; // holds human player creatures - private CardList computerList; // holds computer creatures + private List humanList; // holds human player creatures + private List computerList; // holds computer creatures private int aiAggression = 0; // added by Masher, how aggressive the ai // attack will be depending on circumstances @@ -74,11 +75,11 @@ public class ComputerUtilAttack { * @param possibleBlockers * a {@link forge.CardList} object. */ - public ComputerUtilAttack(final CardList possibleAttackers, final CardList possibleBlockers) { - this.humanList = new CardList(possibleBlockers); + public ComputerUtilAttack(final List possibleAttackers, final List possibleBlockers) { + this.humanList = new ArrayList(possibleBlockers); this.humanList = CardListUtil.filter(this.humanList, CardPredicates.Presets.CREATURES); - this.computerList = new CardList(possibleAttackers); + this.computerList = new ArrayList(possibleAttackers); this.computerList = CardListUtil.filter(this.computerList, CardPredicates.Presets.CREATURES); this.attackers = this.getPossibleAttackers(possibleAttackers); @@ -94,8 +95,8 @@ public class ComputerUtilAttack { * a {@link forge.CardList} object. * @return a {@link forge.CardList} object. */ - public final CardList sortAttackers(final CardList in) { - final CardList list = new CardList(); + public final List sortAttackers(final List in) { + final List list = new ArrayList(); // Cards with triggers should come first (for Battle Cry) for (final Card attacker : in) { @@ -144,7 +145,7 @@ public class ComputerUtilAttack { return true; } - final CardList controlledByCompy = AllZone.getComputerPlayer().getAllCards(); + final List controlledByCompy = AllZone.getComputerPlayer().getAllCards(); for (final Card c : controlledByCompy) { for (final Trigger trigger : c.getTriggers()) { if (CombatUtil.combatTriggerWillTrigger(attacker, null, trigger, combat)) { @@ -165,8 +166,8 @@ public class ComputerUtilAttack { * a {@link forge.CardList} object. * @return a {@link forge.CardList} object. */ - public final CardList getPossibleAttackers(final CardList in) { - CardList list = new CardList(in); + public final List getPossibleAttackers(final List in) { + List list = new ArrayList(in); list = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { @@ -187,8 +188,8 @@ public class ComputerUtilAttack { * a {@link forge.CardList} object. * @return a {@link forge.CardList} object. */ - public final CardList getPossibleBlockers(final CardList blockers, final CardList attackers) { - CardList possibleBlockers = new CardList(blockers); + public final List getPossibleBlockers(final List blockers, final List attackers) { + List possibleBlockers = new ArrayList(blockers); possibleBlockers = CardListUtil.filter(possibleBlockers, new Predicate() { @Override public boolean apply(final Card c) { @@ -209,8 +210,8 @@ public class ComputerUtilAttack { * a {@link forge.CardList} object. * @return a boolean. */ - public final boolean canBlockAnAttacker(final Card c, final CardList attackers) { - final CardList attackerList = new CardList(attackers); + public final boolean canBlockAnAttacker(final Card c, final List attackers) { + final List attackerList = new ArrayList(attackers); if (!c.isCreature()) { return false; } @@ -236,10 +237,10 @@ public class ComputerUtilAttack { * a {@link forge.game.phase.Combat} object. * @return a {@link forge.CardList} object. */ - public final CardList notNeededAsBlockers(final CardList attackers, final Combat combat) { - final CardList notNeededAsBlockers = new CardList(attackers); + public final List notNeededAsBlockers(final List attackers, final Combat combat) { + final List notNeededAsBlockers = new ArrayList(attackers); int fixedBlockers = 0; - final CardList vigilantes = new CardList(); + final List vigilantes = new ArrayList(); //check for time walks if (Singletons.getModel().getGameState().getPhaseHandler().isNextTurn(AllZone.getComputerPlayer())) { return attackers; @@ -267,7 +268,7 @@ public class ComputerUtilAttack { int blockersNeeded = this.humanList.size(); // don't hold back creatures that can't block any of the human creatures - final CardList list = this.getPossibleBlockers(attackers, this.humanList); + final List list = this.getPossibleBlockers(attackers, this.humanList); //Calculate the amount of creatures necessary for (int i = 0; i < list.size(); i++) { @@ -380,7 +381,7 @@ public class ComputerUtilAttack { // Beastmaster Ascension if (AllZoneUtil.isCardInPlay("Beastmaster Ascension", AllZone.getComputerPlayer()) && (this.attackers.size() > 1)) { - final CardList beastions = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield, "Beastmaster Ascension"); + final List beastions = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield, "Beastmaster Ascension"); int minCreatures = 7; for (final Card beastion : beastions) { final int counters = beastion.getCounters(Counters.QUEST); @@ -393,9 +394,9 @@ public class ComputerUtilAttack { CardListUtil.sortAttack(this.attackers); - final CardList unblockedAttackers = new CardList(); - final CardList remainingAttackers = new CardList(this.attackers); - final CardList remainingBlockers = new CardList(this.blockers); + final List unblockedAttackers = new ArrayList(); + final List remainingAttackers = new ArrayList(this.attackers); + final List remainingBlockers = new ArrayList(this.blockers); final Player human = AllZone.getHumanPlayer(); final Player computer = AllZone.getComputerPlayer(); @@ -513,7 +514,7 @@ public class ComputerUtilAttack { final boolean bAssault = this.doAssault(); // Determine who will be attacked this.chooseDefender(combat, bAssault); - CardList attackersLeft = new CardList(this.attackers); + List attackersLeft = new ArrayList(this.attackers); // Attackers that don't really have a choice for (final Card attacker : this.attackers) { if (!CombatUtil.canAttack(attacker, combat)) { @@ -594,7 +595,7 @@ public class ComputerUtilAttack { int humanForcesForAttritionalAttack = 0; // examine the potential forces - final CardList nextTurnAttackers = new CardList(); + final List nextTurnAttackers = new ArrayList(); int candidateCounterAttackDamage = 0; // int candidateTotalBlockDamage = 0; for (final Card pCard : this.humanList) { @@ -623,7 +624,7 @@ public class ComputerUtilAttack { } // get the potential damage and strength of the AI forces - final CardList candidateAttackers = new CardList(); + final List candidateAttackers = new ArrayList(); int candidateUnblockedDamage = 0; for (final Card pCard : this.computerList) { // if the creature can attack then it's a potential attacker this @@ -685,7 +686,7 @@ public class ComputerUtilAttack { // get player life total int humanLife = AllZone.getHumanPlayer().getLife(); // get the list of attackers up to the first blocked one - final CardList attritionalAttackers = new CardList(); + final List attritionalAttackers = new ArrayList(); for (int x = 0; x < (this.attackers.size() - humanForces); x++) { attritionalAttackers.add(this.attackers.get(x)); } @@ -816,7 +817,7 @@ public class ComputerUtilAttack { final int blockNum = this.blockers.size(); int attackNum = 0; int damage = 0; - CardList attacking = combat.getAttackersByDefenderSlot(combat.getCurrentDefenderNumber()); + List attacking = combat.getAttackersByDefenderSlot(combat.getCurrentDefenderNumber()); CardListUtil.sortAttackLowFirst(attacking); for (Card atta : attacking) { if (attackNum >= blockNum || !CombatUtil.canBeBlocked(attacker, this.blockers)) { @@ -846,7 +847,7 @@ public class ComputerUtilAttack { * @return a int. */ public final int countExaltedBonus(final Player player) { - CardList list = player.getCardsIn(ZoneType.Battlefield); + List list = player.getCardsIn(ZoneType.Battlefield); list = CardListUtil.filter(list, new Predicate() { @Override public boolean apply(final Card c) { @@ -889,7 +890,7 @@ public class ComputerUtilAttack { * a {@link forge.game.phase.Combat} object. * @return a boolean. */ - public final boolean shouldAttack(final Card attacker, final CardList defenders, final Combat combat) { + public final boolean shouldAttack(final Card attacker, final List defenders, final Combat combat) { boolean canBeKilledByOne = false; // indicates if the attacker can be // killed by a single blocker boolean canKillAll = true; // indicates if the attacker can kill all diff --git a/src/main/java/forge/game/player/ComputerUtilBlock.java b/src/main/java/forge/game/player/ComputerUtilBlock.java index 63c90ca154a..e6fd4392175 100644 --- a/src/main/java/forge/game/player/ComputerUtilBlock.java +++ b/src/main/java/forge/game/player/ComputerUtilBlock.java @@ -17,6 +17,7 @@ */ package forge.game.player; +import java.util.ArrayList; import java.util.List; import com.google.common.base.Predicate; @@ -24,7 +25,7 @@ import com.google.common.base.Predicates; import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.Counters; @@ -44,21 +45,21 @@ import forge.game.phase.CombatUtil; */ public class ComputerUtilBlock { /** Constant attackers. */ - private static CardList attackers = new CardList(); // all attackers + private static List attackers = new ArrayList(); // all attackers /** Constant attackersLeft. */ - private static CardList attackersLeft = new CardList(); // keeps track of + private static List attackersLeft = new ArrayList(); // keeps track of // all currently // unblocked // attackers /** Constant blockedButUnkilled. */ - private static CardList blockedButUnkilled = new CardList(); // blocked + private static List blockedButUnkilled = new ArrayList(); // blocked // attackers // that // currently // wouldn't be // destroyed /** Constant blockersLeft. */ - private static CardList blockersLeft = new CardList(); // keeps track of all + private static List blockersLeft = new ArrayList(); // keeps track of all // unassigned // blockers /** Constant diff=0. */ @@ -73,7 +74,7 @@ public class ComputerUtilBlock { * * @return a {@link forge.CardList} object. */ - private static CardList getAttackers() { + private static List getAttackers() { return ComputerUtilBlock.attackers; } @@ -85,7 +86,7 @@ public class ComputerUtilBlock { * @param cardList * a {@link forge.CardList} object. */ - private static void setAttackers(final CardList cardList) { + private static void setAttackers(final List cardList) { ComputerUtilBlock.attackers = (cardList); } @@ -96,7 +97,7 @@ public class ComputerUtilBlock { * * @return a {@link forge.CardList} object. */ - private static CardList getAttackersLeft() { + private static List getAttackersLeft() { return ComputerUtilBlock.attackersLeft; } @@ -108,7 +109,7 @@ public class ComputerUtilBlock { * @param cardList * a {@link forge.CardList} object. */ - private static void setAttackersLeft(final CardList cardList) { + private static void setAttackersLeft(final List cardList) { ComputerUtilBlock.attackersLeft = (cardList); } @@ -119,7 +120,7 @@ public class ComputerUtilBlock { * * @return a {@link forge.CardList} object. */ - private static CardList getBlockedButUnkilled() { + private static List getBlockedButUnkilled() { return ComputerUtilBlock.blockedButUnkilled; } @@ -132,7 +133,7 @@ public class ComputerUtilBlock { * @param cardList * a {@link forge.CardList} object. */ - private static void setBlockedButUnkilled(final CardList cardList) { + private static void setBlockedButUnkilled(final List cardList) { ComputerUtilBlock.blockedButUnkilled = (cardList); } @@ -143,7 +144,7 @@ public class ComputerUtilBlock { * * @return a {@link forge.CardList} object. */ - private static CardList getBlockersLeft() { + private static List getBlockersLeft() { return ComputerUtilBlock.blockersLeft; } @@ -155,7 +156,7 @@ public class ComputerUtilBlock { * @param cardList * a {@link forge.CardList} object. */ - private static void setBlockersLeft(final CardList cardList) { + private static void setBlockersLeft(final List cardList) { ComputerUtilBlock.blockersLeft = (cardList); } @@ -196,8 +197,8 @@ public class ComputerUtilBlock { * a {@link forge.game.phase.Combat} object. * @return a {@link forge.CardList} object. */ - private static CardList getPossibleBlockers(final Card attacker, final CardList blockersLeft, final Combat combat) { - final CardList blockers = new CardList(); + private static List getPossibleBlockers(final Card attacker, final List blockersLeft, final Combat combat) { + final List blockers = new ArrayList(); for (final Card blocker : blockersLeft) { // if the blocker can block a creature with lure it can't block a @@ -224,8 +225,8 @@ public class ComputerUtilBlock { * a {@link forge.game.phase.Combat} object. * @return a {@link forge.CardList} object. */ - private static CardList getSafeBlockers(final Card attacker, final CardList blockersLeft, final Combat combat) { - final CardList blockers = new CardList(); + private static List getSafeBlockers(final Card attacker, final List blockersLeft, final Combat combat) { + final List blockers = new ArrayList(); for (final Card b : blockersLeft) { if (!CombatUtil.canDestroyBlocker(b, attacker, combat, false)) { @@ -250,8 +251,8 @@ public class ComputerUtilBlock { * a {@link forge.game.phase.Combat} object. * @return a {@link forge.CardList} object. */ - private static CardList getKillingBlockers(final Card attacker, final CardList blockersLeft, final Combat combat) { - final CardList blockers = new CardList(); + private static List getKillingBlockers(final Card attacker, final List blockersLeft, final Combat combat) { + final List blockers = new ArrayList(); for (final Card b : blockersLeft) { if (CombatUtil.canDestroyAttacker(attacker, b, combat, false)) { @@ -271,19 +272,21 @@ public class ComputerUtilBlock { * a {@link forge.game.phase.Combat} object. * @return a {@link forge.CardList} object. */ - public static CardList sortPotentialAttackers(final Combat combat) { - final CardList[] attackerLists = combat.sortAttackerByDefender(); - final CardList sortedAttackers = new CardList(); - + public static List sortPotentialAttackers(final Combat combat) { + final List> attackerLists = combat.sortAttackerByDefender(); + final List sortedAttackers = new ArrayList(); + final List firstAttacker = attackerLists.get(0); + final List defenders = combat.getDefenders(); + // Begin with the attackers that pose the biggest threat - CardListUtil.sortByEvaluateCreature(attackerLists[0]); - CardListUtil.sortAttack(attackerLists[0]); + CardListUtil.sortByEvaluateCreature(firstAttacker); + CardListUtil.sortAttack(firstAttacker); // If I don't have any planeswalkers than sorting doesn't really matter if (defenders.size() == 1) { - return attackerLists[0]; + return firstAttacker; } final boolean bLifeInDanger = CombatUtil.lifeInDanger(combat); @@ -293,23 +296,23 @@ public class ComputerUtilBlock { // defend planeswalkers with more loyalty before planeswalkers with less // loyalty // if planeswalker will be too difficult to defend don't even bother - for (int i = 1; i < attackerLists.length; i++) { + for (List attacker : attackerLists) { // Begin with the attackers that pose the biggest threat - CardListUtil.sortAttack(attackerLists[i]); - for (final Card c : attackerLists[i]) { + CardListUtil.sortAttack(attacker); + for (final Card c : attacker) { sortedAttackers.add(c); } } if (bLifeInDanger) { // add creatures attacking the Player to the front of the list - for (final Card c : attackerLists[0]) { + for (final Card c : firstAttacker) { sortedAttackers.add(0, c); } } else { // add creatures attacking the Player to the back of the list - for (final Card c : attackerLists[0]) { + for (final Card c : firstAttacker) { sortedAttackers.add(c); } } @@ -332,7 +335,7 @@ public class ComputerUtilBlock { */ private static Combat makeGoodBlocks(final Combat combat) { - CardList currentAttackers = new CardList(ComputerUtilBlock.getAttackersLeft()); + List currentAttackers = new ArrayList(ComputerUtilBlock.getAttackersLeft()); for (final Card attacker : ComputerUtilBlock.getAttackersLeft()) { @@ -342,11 +345,11 @@ public class ComputerUtilBlock { Card blocker = null; - final CardList blockers = ComputerUtilBlock.getPossibleBlockers(attacker, + final List blockers = ComputerUtilBlock.getPossibleBlockers(attacker, ComputerUtilBlock.getBlockersLeft(), combat); - final CardList safeBlockers = ComputerUtilBlock.getSafeBlockers(attacker, blockers, combat); - CardList killingBlockers; + final List safeBlockers = ComputerUtilBlock.getSafeBlockers(attacker, blockers, combat); + List killingBlockers; if (safeBlockers.size() > 0) { // 1.Blockers that can destroy the attacker but won't get @@ -384,7 +387,7 @@ public class ComputerUtilBlock { combat.addBlocker(attacker, blocker); } } - ComputerUtilBlock.setAttackersLeft(new CardList(currentAttackers)); + ComputerUtilBlock.setAttackersLeft(new ArrayList(currentAttackers)); return combat; } @@ -401,15 +404,15 @@ public class ComputerUtilBlock { final static Predicate rampagesOrNeedsManyToBlock = Predicates.or( CardPredicates.containsKeyword("Rampage"), CardPredicates.containsKeyword("CARDNAME can't be blocked by more than one creature.")); private static Combat makeGangBlocks(final Combat combat) { - CardList currentAttackers = CardListUtil.filter(ComputerUtilBlock.getAttackersLeft(), Predicates.not(rampagesOrNeedsManyToBlock)); - CardList blockers; + List currentAttackers = CardListUtil.filter(ComputerUtilBlock.getAttackersLeft(), Predicates.not(rampagesOrNeedsManyToBlock)); + List blockers; // Try to block an attacker without first strike with a gang of first strikers for (final Card attacker : ComputerUtilBlock.getAttackersLeft()) { if (!attacker.hasKeyword("First Strike") && !attacker.hasKeyword("Double Strike")) { blockers = ComputerUtilBlock.getPossibleBlockers(attacker, ComputerUtilBlock.getBlockersLeft(), combat); - final CardList firstStrikeBlockers = new CardList(); - final CardList blockGang = new CardList(); + final List firstStrikeBlockers = new ArrayList(); + final List blockGang = new ArrayList(); for (int i = 0; i < blockers.size(); i++) { if (blockers.get(i).hasFirstStrike() || blockers.get(i).hasDoubleStrike()) { firstStrikeBlockers.add(blockers.get(i)); @@ -441,14 +444,14 @@ public class ComputerUtilBlock { } } - ComputerUtilBlock.setAttackersLeft(new CardList(currentAttackers)); - currentAttackers = new CardList(ComputerUtilBlock.getAttackersLeft()); + ComputerUtilBlock.setAttackersLeft(new ArrayList(currentAttackers)); + currentAttackers = new ArrayList(ComputerUtilBlock.getAttackersLeft()); // Try to block an attacker with two blockers of which only one will die for (final Card attacker : ComputerUtilBlock.getAttackersLeft()) { blockers = ComputerUtilBlock.getPossibleBlockers(attacker, ComputerUtilBlock.getBlockersLeft(), combat); - CardList usableBlockers; - final CardList blockGang = new CardList(); + List usableBlockers; + final List blockGang = new ArrayList(); int absorbedDamage = 0; // The amount of damage needed to kill the // first blocker int currentValue = 0; // The value of the creatures in the blockgang @@ -509,7 +512,7 @@ public class ComputerUtilBlock { } } - ComputerUtilBlock.setAttackersLeft(new CardList(currentAttackers)); + ComputerUtilBlock.setAttackersLeft(new ArrayList(currentAttackers)); return combat; } @@ -525,8 +528,8 @@ public class ComputerUtilBlock { */ private static Combat makeTradeBlocks(final Combat combat) { - CardList currentAttackers = new CardList(ComputerUtilBlock.getAttackersLeft()); - CardList killingBlockers; + List currentAttackers = new ArrayList(ComputerUtilBlock.getAttackersLeft()); + List killingBlockers; for (final Card attacker : ComputerUtilBlock.getAttackersLeft()) { @@ -543,7 +546,7 @@ public class ComputerUtilBlock { currentAttackers.remove(attacker); } } - ComputerUtilBlock.setAttackersLeft(new CardList(currentAttackers)); + ComputerUtilBlock.setAttackersLeft(new ArrayList(currentAttackers)); return combat; } @@ -559,8 +562,8 @@ public class ComputerUtilBlock { */ private static Combat makeChumpBlocks(final Combat combat) { - CardList currentAttackers = new CardList(ComputerUtilBlock.getAttackersLeft()); - CardList chumpBlockers; + List currentAttackers = new ArrayList(ComputerUtilBlock.getAttackersLeft()); + List chumpBlockers; for (final Card attacker : ComputerUtilBlock.getAttackersLeft()) { @@ -578,7 +581,7 @@ public class ComputerUtilBlock { ComputerUtilBlock.getBlockedButUnkilled().add(attacker); } } - ComputerUtilBlock.setAttackersLeft(new CardList(currentAttackers)); + ComputerUtilBlock.setAttackersLeft(new ArrayList(currentAttackers)); return combat; } @@ -595,9 +598,9 @@ public class ComputerUtilBlock { */ private static Combat reinforceBlockersAgainstTrample(final Combat combat) { - CardList chumpBlockers; + List chumpBlockers; - CardList tramplingAttackers = CardListUtil.getKeyword(ComputerUtilBlock.getAttackers(), "Trample"); + List tramplingAttackers = CardListUtil.getKeyword(ComputerUtilBlock.getAttackers(), "Trample"); tramplingAttackers = CardListUtil.filter(tramplingAttackers, Predicates.not(rampagesOrNeedsManyToBlock)); // TODO - should check here for a "rampage-like" trigger that replaced @@ -642,10 +645,10 @@ public class ComputerUtilBlock { */ private static Combat reinforceBlockersToKill(final Combat combat) { - CardList safeBlockers; - CardList blockers; + List safeBlockers; + List blockers; - CardList targetAttackers = CardListUtil.filter(ComputerUtilBlock.getBlockedButUnkilled(), Predicates.not(rampagesOrNeedsManyToBlock)); + List targetAttackers = CardListUtil.filter(ComputerUtilBlock.getBlockedButUnkilled(), Predicates.not(rampagesOrNeedsManyToBlock)); // TODO - should check here for a "rampage-like" trigger that replaced // the keyword: @@ -678,7 +681,7 @@ public class ComputerUtilBlock { safeBlockers = CardListUtil.getKeyword(blockers, "First Strike"); safeBlockers.addAll(CardListUtil.getKeyword(blockers, "Double Strike")); } else { - safeBlockers = new CardList(blockers); + safeBlockers = new ArrayList(blockers); } for (final Card blocker : safeBlockers) { @@ -712,25 +715,25 @@ public class ComputerUtilBlock { * a {@link forge.CardList} object. * @return a {@link forge.game.phase.Combat} object. */ - private static Combat resetBlockers(final Combat combat, final CardList possibleBlockers) { + private static Combat resetBlockers(final Combat combat, final List possibleBlockers) { - final CardList oldBlockers = combat.getAllBlockers(); + final List oldBlockers = combat.getAllBlockers(); for (final Card blocker : oldBlockers) { combat.removeFromCombat(blocker); } - ComputerUtilBlock.setAttackersLeft(new CardList(ComputerUtilBlock.getAttackers())); // keeps + ComputerUtilBlock.setAttackersLeft(new ArrayList(ComputerUtilBlock.getAttackers())); // keeps // track // of all // currently // unblocked // attackers - ComputerUtilBlock.setBlockersLeft(new CardList(possibleBlockers)); // keeps + ComputerUtilBlock.setBlockersLeft(new ArrayList(possibleBlockers)); // keeps // track of // all // unassigned // blockers - ComputerUtilBlock.setBlockedButUnkilled(new CardList()); // keeps track + ComputerUtilBlock.setBlockedButUnkilled(new ArrayList()); // keeps track // of all // blocked // attackers that currently @@ -751,7 +754,7 @@ public class ComputerUtilBlock { * a {@link forge.CardList} object. * @return a {@link forge.game.phase.Combat} object. */ - public static Combat getBlockers(final Combat originalCombat, final CardList possibleBlockers) { + public static Combat getBlockers(final Combat originalCombat, final List possibleBlockers) { Combat combat = originalCombat; @@ -762,13 +765,13 @@ public class ComputerUtilBlock { } // keeps track of all currently unblocked attackers - ComputerUtilBlock.setAttackersLeft(new CardList(ComputerUtilBlock.getAttackers())); + ComputerUtilBlock.setAttackersLeft(new ArrayList(ComputerUtilBlock.getAttackers())); // keeps track of all unassigned blockers - ComputerUtilBlock.setBlockersLeft(new CardList(possibleBlockers)); + ComputerUtilBlock.setBlockersLeft(new ArrayList(possibleBlockers)); // keeps track of all blocked attackers that currently wouldn't be destroyed - ComputerUtilBlock.setBlockedButUnkilled(new CardList()); - CardList blockers; - CardList chumpBlockers; + ComputerUtilBlock.setBlockedButUnkilled(new ArrayList()); + List blockers; + List chumpBlockers; ComputerUtilBlock.setDiff((AllZone.getComputerPlayer().getLife() * 2) - 5); // This // is @@ -909,7 +912,7 @@ public class ComputerUtilBlock { return combat; } - public static CardList orderBlockers(Card attacker, CardList blockers) { + public static List orderBlockers(Card attacker, List blockers) { // very very simple ordering of blockers, sort by evaluate, then sort by attack //final int damage = attacker.getNetCombatDamage(); CardListUtil.sortByEvaluateCreature(blockers); @@ -921,7 +924,7 @@ public class ComputerUtilBlock { return blockers; } - public static CardList orderAttackers(Card attacker, CardList blockers) { + public static List orderAttackers(Card attacker, List blockers) { // This shouldn't really take trample into account, but otherwise should be pretty similar to orderBlockers // very very simple ordering of attackers, sort by evaluate, then sort by attack //final int damage = attacker.getNetCombatDamage(); diff --git a/src/main/java/forge/game/player/HumanPlayer.java b/src/main/java/forge/game/player/HumanPlayer.java index a2b4195f61d..180e9c1469d 100644 --- a/src/main/java/forge/game/player/HumanPlayer.java +++ b/src/main/java/forge/game/player/HumanPlayer.java @@ -17,9 +17,12 @@ */ package forge.game.player; +import java.util.ArrayList; +import java.util.List; + import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.Singletons; import forge.card.spellability.SpellAbility; import forge.control.input.Input; @@ -148,11 +151,11 @@ public class HumanPlayer extends Player { /** {@inheritDoc} */ @Override - public final CardList discard(final int num, final SpellAbility sa, final boolean duringResolution) { + public final List discard(final int num, final SpellAbility sa, final boolean duringResolution) { AllZone.getInputControl().setInput(PlayerUtil.inputDiscard(num, sa), duringResolution); - // why is CardList returned? - return new CardList(); + // why is List returned? + return new ArrayList(); } /** {@inheritDoc} */ @@ -178,7 +181,7 @@ public class HumanPlayer extends Player { /** {@inheritDoc} */ @Override - protected final void doScry(final CardList topN, final int n) { + protected final void doScry(final List topN, final int n) { int num = n; for (int i = 0; i < num; i++) { final Card c = GuiChoose.oneOrNone("Put on bottom of library.", topN); @@ -203,7 +206,7 @@ public class HumanPlayer extends Player { /** {@inheritDoc} */ @Override - public final void sacrificePermanent(final String prompt, final CardList choices) { + public final void sacrificePermanent(final String prompt, final List choices) { final Input in = PlayerUtil.inputSacrificePermanent(choices, prompt); AllZone.getInputControl().setInput(in); } diff --git a/src/main/java/forge/game/player/Player.java b/src/main/java/forge/game/player/Player.java index f25e19ba68e..9f549ff87c0 100644 --- a/src/main/java/forge/game/player/Player.java +++ b/src/main/java/forge/game/player/Player.java @@ -33,7 +33,7 @@ import com.google.common.collect.Iterables; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates; import forge.CardUtil; @@ -124,7 +124,7 @@ public abstract class Player extends GameEntity implements Comparable { private int numDrawnThisTurn = 0; /** The slowtrip list. */ - private CardList slowtripList = new CardList(); + private List slowtripList = new ArrayList(); /** The keywords. */ private ArrayList keywords = new ArrayList(); @@ -199,7 +199,7 @@ public abstract class Player extends GameEntity implements Comparable { this.setPreventNextDamage(0); this.lastDrawnCard = null; this.numDrawnThisTurn = 0; - this.slowtripList = new CardList(); + this.slowtripList = new ArrayList(); this.nTurns = 0; this.altWin = false; this.altWinSourceName = null; @@ -647,7 +647,7 @@ public abstract class Player extends GameEntity implements Comparable { } // Prevent Damage static abilities - final CardList allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card ca : allp) { final ArrayList staticAbilities = ca.getStaticAbilities(); for (final StaticAbility stAb : staticAbilities) { @@ -784,7 +784,7 @@ public abstract class Player extends GameEntity implements Comparable { if (AllZoneUtil.isCardInPlay("Crumbling Sanctuary")) { for (int i = 0; i < damage; i++) { - final CardList lib = this.getCardsIn(ZoneType.Library); + final List lib = this.getCardsIn(ZoneType.Library); if (lib.size() > 0) { Singletons.getModel().getGameAction().exile(lib.get(0)); } @@ -1159,9 +1159,9 @@ public abstract class Player extends GameEntity implements Comparable { * drawCard. *

* - * @return a CardList of cards actually drawn + * @return a List of cards actually drawn */ - public final CardList drawCard() { + public final List drawCard() { return this.drawCards(1); } @@ -1170,9 +1170,9 @@ public abstract class Player extends GameEntity implements Comparable { * drawCards. *

* - * @return a CardList of cards actually drawn + * @return a List of cards actually drawn */ - public final CardList drawCards() { + public final List drawCards() { return this.drawCards(1); } @@ -1192,9 +1192,9 @@ public abstract class Player extends GameEntity implements Comparable { * * @param n * a int. - * @return a CardList of cards actually drawn + * @return a List of cards actually drawn */ - public final CardList drawCards(final int n) { + public final List drawCards(final int n) { return this.drawCards(n, false); } @@ -1208,10 +1208,10 @@ public abstract class Player extends GameEntity implements Comparable { * @param firstFromDraw * true if this is the card drawn from that player's draw step * each turn - * @return a CardList of cards actually drawn + * @return a List of cards actually drawn */ - public final CardList drawCards(final int n, final boolean firstFromDraw) { - final CardList drawn = new CardList(); + public final List drawCards(final int n, final boolean firstFromDraw) { + final List drawn = new ArrayList(); if (!this.canDraw()) { return drawn; @@ -1250,10 +1250,10 @@ public abstract class Player extends GameEntity implements Comparable { * doDraw. *

* - * @return a CardList of cards actually drawn + * @return a List of cards actually drawn */ - private CardList doDraw() { - final CardList drawn = new CardList(); + private List doDraw() { + final List drawn = new ArrayList(); final PlayerZone library = this.getZone(ZoneType.Library); // Replacement effects @@ -1273,7 +1273,7 @@ public abstract class Player extends GameEntity implements Comparable { if ((this.numDrawnThisTurn == 0) && this.isComputer()) { boolean reveal = false; - final CardList cards = this.getCardsIn(ZoneType.Battlefield); + final List cards = this.getCardsIn(ZoneType.Battlefield); for (final Card card : cards) { if (card.hasKeyword("Reveal the first card you draw each turn")) { reveal = true; @@ -1327,15 +1327,15 @@ public abstract class Player extends GameEntity implements Comparable { /** * gets a list of all cards in the requested zone. This function makes a - * CardList from Card[]. + * List from Card[]. * * @param zone * the zone - * @return a CardList with all the cards currently in requested zone + * @return a List with all the cards currently in requested zone */ - public final CardList getCardsIn(final ZoneType zone) { + public final List getCardsIn(final ZoneType zone) { final List cards = zone == ZoneType.Stack ? AllZone.getStackZone().getCards() : this.getZone(zone).getCards(); - return new CardList(cards); + return new ArrayList(cards); } /** @@ -1343,7 +1343,7 @@ public abstract class Player extends GameEntity implements Comparable { * * @return the all cards */ - public final CardList getAllCards() { + public final List getAllCards() { return this.getCardsIn(Player.ALL_ZONES); } @@ -1354,24 +1354,24 @@ public abstract class Player extends GameEntity implements Comparable { * the zone * @return the cards include phasing in */ - public final CardList getCardsIncludePhasingIn(final ZoneType zone) { + public final List getCardsIncludePhasingIn(final ZoneType zone) { final List cards = zone == ZoneType.Stack ? AllZone.getStackZone().getCards() : this.getZone(zone) .getCards(false); - return new CardList(cards); + return new ArrayList(cards); } /** * gets a list of first N cards in the requested zone. This function makes a - * CardList from Card[]. + * List from Card[]. * * @param zone * the zone * @param n * the n - * @return a CardList with all the cards currently in requested zone + * @return a List with all the cards currently in requested zone */ - public final CardList getCardsIn(final ZoneType zone, final int n) { - return new CardList(this.getZone(zone).getCards(n)); + public final List getCardsIn(final ZoneType zone, final int n) { + return new ArrayList(this.getZone(zone).getCards(n)); } /** @@ -1379,10 +1379,10 @@ public abstract class Player extends GameEntity implements Comparable { * * @param zones * the zones - * @return a CardList with all the cards currently in requested zones + * @return a List with all the cards currently in requested zones */ - public final CardList getCardsIn(final List zones) { - final CardList result = new CardList(); + public final List getCardsIn(final List zones) { + final List result = new ArrayList(); for (final ZoneType z : zones) { if (z == ZoneType.Stack) { for (Card c : AllZone.getStackZone().getCards()) { @@ -1399,8 +1399,8 @@ public abstract class Player extends GameEntity implements Comparable { return result; } - public final CardList getCardsIn(final ZoneType... zones) { - final CardList result = new CardList(); + public final List getCardsIn(final ZoneType... zones) { + final List result = new ArrayList(); for (final ZoneType z : zones) { if (this.getZone(z) != null) { result.addAll(this.getZone(z).getCards()); @@ -1410,15 +1410,15 @@ public abstract class Player extends GameEntity implements Comparable { } /** * gets a list of all cards with requested cardName in a given player's - * requested zone. This function makes a CardList from Card[]. + * requested zone. This function makes a List from Card[]. * * @param zone * the zone * @param cardName * the card name - * @return a CardList with all the cards currently in that player's library + * @return a List with all the cards currently in that player's library */ - public final CardList getCardsIn(final ZoneType zone, final String cardName) { + public final List getCardsIn(final ZoneType zone, final String cardName) { return CardListUtil.filter(this.getCardsIn(zone), CardPredicates.nameEquals(cardName)); } @@ -1429,9 +1429,9 @@ public abstract class Player extends GameEntity implements Comparable { * * @return a {@link forge.CardList} object. */ - protected final CardList getDredge() { - final CardList dredge = new CardList(); - final CardList cl = this.getCardsIn(ZoneType.Graveyard); + protected final List getDredge() { + final List dredge = new ArrayList(); + final List cl = this.getCardsIn(ZoneType.Graveyard); for (final Card c : cl) { final ArrayList kw = c.getKeyword(); @@ -1514,7 +1514,7 @@ public abstract class Player extends GameEntity implements Comparable { * a boolean. * @return a {@link forge.CardList} object. */ - public abstract CardList discard(final int num, final SpellAbility sa, boolean duringResolution); + public abstract List discard(final int num, final SpellAbility sa, boolean duringResolution); /** *

@@ -1525,7 +1525,7 @@ public abstract class Player extends GameEntity implements Comparable { * a {@link forge.card.spellability.SpellAbility} object. * @return a {@link forge.CardList} object. */ - public final CardList discard(final SpellAbility sa) { + public final List discard(final SpellAbility sa) { return this.discard(1, sa, false); } @@ -1540,9 +1540,9 @@ public abstract class Player extends GameEntity implements Comparable { * a {@link forge.card.spellability.SpellAbility} object. * @return a {@link forge.CardList} object. */ - public final CardList discard(final Card c, final SpellAbility sa) { + public final List discard(final Card c, final SpellAbility sa) { this.doDiscard(c, sa); - return new CardList(c); + return CardListUtil.createCardList(c); } /** @@ -1596,8 +1596,8 @@ public abstract class Player extends GameEntity implements Comparable { * a {@link forge.card.spellability.SpellAbility} object. * @return the card list */ - public final CardList discardHand(final SpellAbility sa) { - final CardList list = this.getCardsIn(ZoneType.Hand); + public final List discardHand(final SpellAbility sa) { + final List list = this.getCardsIn(ZoneType.Hand); this.discardRandom(list.size(), sa); return list; } @@ -1609,9 +1609,9 @@ public abstract class Player extends GameEntity implements Comparable { * * @param sa * a {@link forge.card.spellability.SpellAbility} object. - * @return a CardList of cards discarded + * @return a List of cards discarded */ - public final CardList discardRandom(final SpellAbility sa) { + public final List discardRandom(final SpellAbility sa) { return this.discardRandom(1, sa); } @@ -1624,9 +1624,9 @@ public abstract class Player extends GameEntity implements Comparable { * a int. * @param sa * a {@link forge.card.spellability.SpellAbility} object. - * @return a CardList of cards discarded + * @return a List of cards discarded */ - public final CardList discardRandom(final int num, final SpellAbility sa) { + public final List discardRandom(final int num, final SpellAbility sa) { return this.discardRandom(num, sa, "Card"); } @@ -1641,12 +1641,12 @@ public abstract class Player extends GameEntity implements Comparable { * a {@link forge.card.spellability.SpellAbility} object. * @param valid * a valid expression - * @return a CardList of cards discarded + * @return a List of cards discarded */ - public final CardList discardRandom(final int num, final SpellAbility sa, final String valid) { - final CardList discarded = new CardList(); + public final List discardRandom(final int num, final SpellAbility sa, final String valid) { + final List discarded = new ArrayList(); for (int i = 0; i < num; i++) { - CardList list = this.getCardsIn(ZoneType.Hand); + List list = this.getCardsIn(ZoneType.Hand); list = CardListUtil.getValidCards(list, valid, sa.getSourceCard().getController(), sa.getSourceCard()); if (list.size() != 0) { final Card disc = CardUtil.getRandom(list); @@ -1680,7 +1680,7 @@ public abstract class Player extends GameEntity implements Comparable { * a int. * @return the card list */ - public final CardList mill(final int n) { + public final List mill(final int n) { return this.mill(n, ZoneType.Graveyard, false); } @@ -1697,9 +1697,9 @@ public abstract class Player extends GameEntity implements Comparable { * a boolean. * @return the card list */ - public final CardList mill(final int n, final ZoneType zone, final boolean bottom) { - final CardList lib = this.getCardsIn(ZoneType.Library); - final CardList milled = new CardList(); + public final List mill(final int n, final ZoneType zone, final boolean bottom) { + final List lib = this.getCardsIn(ZoneType.Library); + final List milled = new ArrayList(); final int max = Math.min(n, lib.size()); @@ -1773,7 +1773,7 @@ public abstract class Player extends GameEntity implements Comparable { * @param n * a int. */ - protected abstract void doScry(CardList topN, int n); + protected abstract void doScry(List topN, int n); /** *

@@ -1784,7 +1784,7 @@ public abstract class Player extends GameEntity implements Comparable { * a int. */ public final void scry(int numScry) { - final CardList topN = new CardList(); + final List topN = new ArrayList(); final PlayerZone library = this.getZone(ZoneType.Library); numScry = Math.min(numScry, library.size()); for (int i = 0; i < numScry; i++) { @@ -1841,7 +1841,7 @@ public abstract class Player extends GameEntity implements Comparable { } // CantBeCast static abilities - final CardList allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card ca : allp) { final ArrayList staticAbilities = ca.getStaticAbilities(); for (final StaticAbility stAb : staticAbilities) { @@ -1889,7 +1889,7 @@ public abstract class Player extends GameEntity implements Comparable { * @return a {@link forge.Card} object. */ public final Card getPlaneswalker() { - final CardList c = CardListUtil.filter(this.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.PLANEWALKERS); + final List c = CardListUtil.filter(this.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.PLANEWALKERS); if ((null != c) && (c.size() > 0)) { return c.get(0); } else { @@ -1990,7 +1990,7 @@ public abstract class Player extends GameEntity implements Comparable { * * @return a {@link forge.CardList} object. */ - public final CardList getSlowtripList() { + public final List getSlowtripList() { return this.slowtripList; } @@ -2100,7 +2100,7 @@ public abstract class Player extends GameEntity implements Comparable { * @param choices * a {@link forge.CardList} object. */ - public abstract void sacrificePermanent(String prompt, CardList choices); + public abstract void sacrificePermanent(String prompt, List choices); // Game win/loss @@ -2287,7 +2287,7 @@ public abstract class Player extends GameEntity implements Comparable { * @return a boolean. */ public final boolean hasMetalcraft() { - final CardList list = CardListUtil.filter(this.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.ARTIFACTS); + final List list = CardListUtil.filter(this.getCardsIn(ZoneType.Battlefield), CardPredicates.Presets.ARTIFACTS); return list.size() >= 3; } diff --git a/src/main/java/forge/game/player/PlayerUtil.java b/src/main/java/forge/game/player/PlayerUtil.java index f34d808ddc8..43fc1b781c3 100644 --- a/src/main/java/forge/game/player/PlayerUtil.java +++ b/src/main/java/forge/game/player/PlayerUtil.java @@ -17,11 +17,13 @@ */ package forge.game.player; +import java.util.List; + import com.google.common.base.Predicate; import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.Singletons; import forge.card.spellability.SpellAbility; @@ -57,7 +59,7 @@ public final class PlayerUtil { */ public static boolean worshipFlag(final Player player) { // Instead of hardcoded Ali from Cairo like cards, it is now a Keyword - CardList list = player.getCardsIn(ZoneType.Battlefield); + List list = player.getCardsIn(ZoneType.Battlefield); list = CardListUtil.getKeyword(list, "Damage that would reduce your life total to less than 1 reduces it to 1 instead."); list = CardListUtil.filter(list, new Predicate() { @Override @@ -227,7 +229,7 @@ public final class PlayerUtil { * @return a {@link forge.control.input.Input} object. * @since 1.0.15 */ - public static Input inputSacrificePermanent(final CardList choices, final String message) { + public static Input inputSacrificePermanent(final List choices, final String message) { return PlayerUtil.inputSacrificePermanentsFromList(1, choices, message); } // input_sacrifice() @@ -242,7 +244,7 @@ public final class PlayerUtil { * @since 1.0.15 */ public static Input inputSacrificePermanents(final int nCards) { - final CardList list = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + final List list = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); return PlayerUtil.inputSacrificePermanentsFromList(nCards, list, "Select a permanent to sacrifice"); } // input_sacrificePermanents() @@ -259,7 +261,7 @@ public final class PlayerUtil { * @since 1.0.15 */ public static Input inputSacrificePermanents(final int nCards, final String type) { - CardList list = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + List list = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); list = CardListUtil.getType(list, type); return PlayerUtil.inputSacrificePermanentsFromList(nCards, list, "Select a " + type + " to sacrifice"); @@ -279,7 +281,7 @@ public final class PlayerUtil { * @return a {@link forge.control.input.Input} object. * @since 1.0.15 */ - public static Input inputSacrificePermanentsFromList(final int nCards, final CardList list, final String message) { + public static Input inputSacrificePermanentsFromList(final int nCards, final List list, final String message) { final Input target = new Input() { private static final long serialVersionUID = 1981791992623774490L; private int n = 0; diff --git a/src/main/java/forge/game/zone/DefaultPlayerZone.java b/src/main/java/forge/game/zone/DefaultPlayerZone.java index 3c305d9b8e6..156562c2489 100644 --- a/src/main/java/forge/game/zone/DefaultPlayerZone.java +++ b/src/main/java/forge/game/zone/DefaultPlayerZone.java @@ -23,7 +23,7 @@ import java.util.Observable; import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.Singletons; import forge.card.trigger.TriggerType; import forge.game.player.Player; @@ -46,7 +46,7 @@ public class DefaultPlayerZone extends PlayerZone implements java.io.Serializabl private final Player player; private boolean update = true; - private final CardList cardsAddedThisTurn = new CardList(); + private final List cardsAddedThisTurn = new ArrayList(); private final ArrayList cardsAddedThisTurnSource = new ArrayList(); /** @@ -431,9 +431,9 @@ public class DefaultPlayerZone extends PlayerZone implements java.io.Serializabl * a {@link java.lang.String} object. * @return a {@link forge.CardList} object. */ - public final CardList getCardsAddedThisTurn(final ZoneType origin) { + public final List getCardsAddedThisTurn(final ZoneType origin) { //System.out.print("Request cards put into " + this.getZoneType() + " from " + origin + ".Amount: "); - final CardList ret = new CardList(); + final List ret = new ArrayList(); for (int i = 0; i < this.cardsAddedThisTurn.size(); i++) { if ((this.cardsAddedThisTurnSource.get(i) == origin) || (origin == null)) { ret.add(this.cardsAddedThisTurn.get(i)); diff --git a/src/main/java/forge/game/zone/MagicStack.java b/src/main/java/forge/game/zone/MagicStack.java index 01c24f098ed..f8f9ee59c30 100644 --- a/src/main/java/forge/game/zone/MagicStack.java +++ b/src/main/java/forge/game/zone/MagicStack.java @@ -27,7 +27,7 @@ import com.esotericsoftware.minlog.Log; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates.Presets; import forge.Command; @@ -77,8 +77,8 @@ public class MagicStack extends MyObservable { private boolean bResolving = false; private int splitSecondOnStack = 0; - private final CardList thisTurnCast = new CardList(); - private CardList lastTurnCast = new CardList(); + private final List thisTurnCast = new ArrayList(); + private List lastTurnCast = new ArrayList(); private Card curResolvingCard = null; /** @@ -762,9 +762,9 @@ public class MagicStack extends MyObservable { */ if (sp.isSpell() && AllZoneUtil.isCardInPlay("Bazaar of Wonders")) { boolean found = false; - CardList all = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + List all = AllZoneUtil.getCardsIn(ZoneType.Battlefield); all = CardListUtil.filter(all, Presets.NON_TOKEN); - final CardList graves = AllZoneUtil.getCardsIn(ZoneType.Graveyard); + final List graves = AllZoneUtil.getCardsIn(ZoneType.Graveyard); all.addAll(graves); for (final Card c : all) { @@ -774,7 +774,7 @@ public class MagicStack extends MyObservable { } if (found) { - final CardList bazaars = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Bazaar of Wonders"); // should + final List bazaars = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Bazaar of Wonders"); // should // only // be // 1... @@ -897,7 +897,7 @@ public class MagicStack extends MyObservable { if (source.hasStartOfKeyword("Haunt") && !source.isCreature() && AllZone.getZoneOf(source).is(ZoneType.Graveyard)) { - final CardList creats = AllZoneUtil.getCreaturesInPlay(); + final List creats = AllZoneUtil.getCreaturesInPlay(); final Ability haunterDiesWork = new Ability(source, "0") { @Override public void resolve() { @@ -942,7 +942,7 @@ public class MagicStack extends MyObservable { AllZone.getInputControl().setInput(target); } else { // AI choosing what to haunt - final CardList oppCreats = CardListUtil.filterControlledBy(creats, AllZone.getHumanPlayer()); + final List oppCreats = CardListUtil.filterControlledBy(creats, AllZone.getHumanPlayer()); if (oppCreats.size() != 0) { haunterDiesWork.setTargetCard(CardFactoryUtil.getWorstCreatureAI(oppCreats)); } else { @@ -1421,7 +1421,7 @@ public class MagicStack extends MyObservable { * * @return a CardList. */ - public final CardList getCardsCastThisTurn() { + public final List getCardsCastThisTurn() { return this.thisTurnCast; } @@ -1437,7 +1437,7 @@ public class MagicStack extends MyObservable { * setCardsCastLastTurn. */ public final void setCardsCastLastTurn() { - this.lastTurnCast = new CardList(this.thisTurnCast); + this.lastTurnCast = new ArrayList(this.thisTurnCast); } /** @@ -1445,7 +1445,7 @@ public class MagicStack extends MyObservable { * * @return a CardList. */ - public final CardList getCardsCastLastTurn() { + public final List getCardsCastLastTurn() { return this.lastTurnCast; } diff --git a/src/main/java/forge/game/zone/PlayerZoneComesIntoPlay.java b/src/main/java/forge/game/zone/PlayerZoneComesIntoPlay.java index 55621e0b84b..4a7858b54a5 100644 --- a/src/main/java/forge/game/zone/PlayerZoneComesIntoPlay.java +++ b/src/main/java/forge/game/zone/PlayerZoneComesIntoPlay.java @@ -23,7 +23,7 @@ import java.util.List; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.CardList; + import forge.CardListUtil; import forge.CardPredicates.Presets; import forge.Command; @@ -81,7 +81,7 @@ public class PlayerZoneComesIntoPlay extends DefaultPlayerZone { c.setTapped(true); } else { // ETBTapped static abilities - final CardList allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card ca : allp) { final ArrayList staticAbilities = ca.getStaticAbilities(); for (final StaticAbility stAb : staticAbilities) { @@ -141,7 +141,7 @@ public class PlayerZoneComesIntoPlay extends DefaultPlayerZone { c.comesIntoPlay(); if (c.isLand()) { - /*CardList list = player.getCardsIn(ZoneType.Battlefield); + /*List list = player.getCardsIn(ZoneType.Battlefield); list = list.filter(new Predicate() { @Override @@ -155,14 +155,14 @@ public class PlayerZoneComesIntoPlay extends DefaultPlayerZone { }*/ // Tectonic Instability - final CardList tis = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Tectonic Instability"); + final List tis = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Tectonic Instability"); final Card tisLand = c; for (final Card ti : tis) { final Card source = ti; final SpellAbility ability = new Ability(source, "") { @Override public void resolve() { - CardList lands = tisLand.getController().getCardsIn(ZoneType.Battlefield); + List lands = tisLand.getController().getCardsIn(ZoneType.Battlefield); lands = CardListUtil.filter(lands, Presets.LANDS); for (final Card land : lands) { land.tap(); @@ -177,14 +177,14 @@ public class PlayerZoneComesIntoPlay extends DefaultPlayerZone { } - final CardList les = c.getOwner().getOpponent().getCardsIn(ZoneType.Battlefield, "Land Equilibrium"); + final List les = c.getOwner().getOpponent().getCardsIn(ZoneType.Battlefield, "Land Equilibrium"); final Card lesLand = c; if (les.size() > 0) { final Card source = les.get(0); final SpellAbility ability = new Ability(source, "") { @Override public void resolve() { - final CardList lands = AllZoneUtil.getPlayerLandsInPlay(lesLand.getOwner()); + final List lands = AllZoneUtil.getPlayerLandsInPlay(lesLand.getOwner()); lesLand.getOwner().sacrificePermanent(source.getName() + " - Select a land to sacrifice", lands); } @@ -193,8 +193,8 @@ public class PlayerZoneComesIntoPlay extends DefaultPlayerZone { sb.append(source).append(" - "); sb.append(tisLand.getController()).append(" sacrifices a land."); ability.setStackDescription(sb.toString()); - final CardList pLands = AllZoneUtil.getPlayerLandsInPlay(lesLand.getOwner()); - final CardList oLands = AllZoneUtil.getPlayerLandsInPlay(lesLand.getOwner().getOpponent()); + final List pLands = AllZoneUtil.getPlayerLandsInPlay(lesLand.getOwner()); + final List oLands = AllZoneUtil.getPlayerLandsInPlay(lesLand.getOwner().getOpponent()); // (pLands - 1) because this land is in play, and the // ability is before it is in play if (oLands.size() <= (pLands.size() - 1)) { diff --git a/src/main/java/forge/gui/GuiAssignDamageFrame.java b/src/main/java/forge/gui/GuiAssignDamageFrame.java index 8daa0917605..c1c11e54a26 100644 --- a/src/main/java/forge/gui/GuiAssignDamageFrame.java +++ b/src/main/java/forge/gui/GuiAssignDamageFrame.java @@ -22,6 +22,7 @@ import java.awt.Rectangle; import java.awt.event.ActionEvent; import java.awt.event.ActionListener; import java.awt.event.MouseEvent; +import java.util.List; import javax.swing.BoxLayout; import javax.swing.JButton; @@ -36,7 +37,7 @@ import javax.swing.WindowConstants; import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.GameEntity; import forge.error.ErrorViewer; import forge.gui.match.CMatchUI; @@ -62,7 +63,7 @@ public class GuiAssignDamageFrame extends JFrame { private int assignedToActive = 0; private Card damageAssigner; private Card activeRecipient; - private CardList recipients; + private List recipients; private boolean deathtouch = false; private final BorderLayout borderLayout1 = new BorderLayout(); @@ -94,7 +95,7 @@ public class GuiAssignDamageFrame extends JFrame { * @param damage * a int. */ - public GuiAssignDamageFrame(final Card attacker, final CardList creatureList, final int damage) { + public GuiAssignDamageFrame(final Card attacker, final List creatureList, final int damage) { this(); this.assignDamage = damage; this.damageAssigner = attacker; diff --git a/src/main/java/forge/gui/GuiDisplayUtil.java b/src/main/java/forge/gui/GuiDisplayUtil.java index c2c8a250e4d..146e4a2a9ef 100644 --- a/src/main/java/forge/gui/GuiDisplayUtil.java +++ b/src/main/java/forge/gui/GuiDisplayUtil.java @@ -36,7 +36,7 @@ import forge.AllZone; import forge.AllZoneUtil; import forge.Card; import forge.CardCharacteristicName; -import forge.CardList; + import forge.CardUtil; import forge.Constant; import forge.Counters; @@ -434,16 +434,16 @@ public final class GuiDisplayUtil { final String[] humanSetupExile = tHumanSetupExile.split(";"); final String[] computerSetupExile = tComputerSetupExile.split(";"); - CardList humanDevSetup = new CardList(); - CardList computerDevSetup = new CardList(); - CardList humanDevHandSetup = new CardList(); - CardList computerDevHandSetup = new CardList(); - CardList humanDevGraveyardSetup = new CardList(); - CardList computerDevGraveyardSetup = new CardList(); - CardList humanDevLibrarySetup = new CardList(); - CardList computerDevLibrarySetup = new CardList(); - CardList humanDevExileSetup = new CardList(); - CardList computerDevExileSetup = new CardList(); + List humanDevSetup = new ArrayList(); + List computerDevSetup = new ArrayList(); + List humanDevHandSetup = new ArrayList(); + List computerDevHandSetup = new ArrayList(); + List humanDevGraveyardSetup = new ArrayList(); + List computerDevGraveyardSetup = new ArrayList(); + List humanDevLibrarySetup = new ArrayList(); + List computerDevLibrarySetup = new ArrayList(); + List humanDevExileSetup = new ArrayList(); + List computerDevExileSetup = new ArrayList(); if (!tChangePlayer.trim().toLowerCase().equals("none")) { if (tChangePlayer.trim().toLowerCase().equals("human")) { @@ -575,8 +575,8 @@ public final class GuiDisplayUtil { * a {@link forge.game.player.Player} object. * @return a {@link forge.CardList} object. */ - public static CardList devProcessCardsForZone(final String[] data, final Player player) { - final CardList cl = new CardList(); + public static List devProcessCardsForZone(final String[] data, final Player player) { + final List cl = new ArrayList(); for (final String element : data) { final String[] cardinfo = element.trim().split("\\|"); @@ -619,7 +619,7 @@ public final class GuiDisplayUtil { * @since 1.0.15 */ public static void devModeTutor() { - final CardList lib = AllZone.getHumanPlayer().getCardsIn(ZoneType.Library); + final List lib = AllZone.getHumanPlayer().getCardsIn(ZoneType.Library); final Object o = GuiChoose.oneOrNone("Choose a card", lib); if (null == o) { return; @@ -716,7 +716,7 @@ public final class GuiDisplayUtil { * @since 1.0.15 */ public static void devModeTapPerm() { - final CardList play = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List play = AllZoneUtil.getCardsIn(ZoneType.Battlefield); final Object o = GuiChoose.oneOrNone("Choose a permanent", play); if (null == o) { return; @@ -734,7 +734,7 @@ public final class GuiDisplayUtil { * @since 1.0.15 */ public static void devModeUntapPerm() { - final CardList play = AllZoneUtil.getCardsIn(ZoneType.Battlefield); + final List play = AllZoneUtil.getCardsIn(ZoneType.Battlefield); final Object o = GuiChoose.oneOrNone("Choose a permanent", play); if (null == o) { return; diff --git a/src/main/java/forge/gui/match/CMatchUI.java b/src/main/java/forge/gui/match/CMatchUI.java index b26e15516f2..c6784b50184 100644 --- a/src/main/java/forge/gui/match/CMatchUI.java +++ b/src/main/java/forge/gui/match/CMatchUI.java @@ -26,7 +26,7 @@ import javax.swing.ImageIcon; import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.Constant; import forge.Singletons; import forge.game.GameType; @@ -152,7 +152,7 @@ public enum CMatchUI implements CardContainer { * @param blockers   {@link forge.CardList} * @param damage   int */ - public void assignDamage(final Card attacker, final CardList blockers, final int damage) { + public void assignDamage(final Card attacker, final List blockers, final int damage) { if (damage <= 0) { return; } diff --git a/src/main/java/forge/gui/match/ControlWinLose.java b/src/main/java/forge/gui/match/ControlWinLose.java index bd16bc65680..01336bc1a14 100644 --- a/src/main/java/forge/gui/match/ControlWinLose.java +++ b/src/main/java/forge/gui/match/ControlWinLose.java @@ -8,7 +8,7 @@ import javax.swing.JButton; import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.Constant; import forge.Singletons; import forge.control.FControl; @@ -96,7 +96,7 @@ public class ControlWinLose { Deck hDeck = Constant.Runtime.HUMAN_DECK[0]; Deck cDeck = Constant.Runtime.COMPUTER_DECK[0]; if (Singletons.getModel().getMatchState().hasWonLastGame(AllZone.getHumanPlayer().getName())) { - CardList compAntes = AllZone.getComputerPlayer().getCardsIn(ZoneType.Ante); + List compAntes = AllZone.getComputerPlayer().getCardsIn(ZoneType.Ante); //remove compy's ante cards form his deck for (Card c : compAntes) { @@ -114,7 +114,7 @@ public class ControlWinLose { } } else { //compy won - CardList humanAntes = AllZone.getHumanPlayer().getCardsIn(ZoneType.Ante); + List humanAntes = AllZone.getHumanPlayer().getCardsIn(ZoneType.Ante); //remove humans ante cards form his deck for (Card c : humanAntes) { diff --git a/src/main/java/forge/gui/match/QuestWinLoseHandler.java b/src/main/java/forge/gui/match/QuestWinLoseHandler.java index 5db3d4e9a66..30303938a81 100644 --- a/src/main/java/forge/gui/match/QuestWinLoseHandler.java +++ b/src/main/java/forge/gui/match/QuestWinLoseHandler.java @@ -17,7 +17,8 @@ package forge.gui.match; import forge.AllZone; -import forge.CardList; + +import forge.Card; import forge.Constant; import forge.Singletons; import forge.control.FControl; @@ -123,8 +124,8 @@ public class QuestWinLoseHandler extends ControlWinLose { } } - final CardList humanList = QuestUtil.getHumanStartingCards(qData, qEvent); - final CardList computerList = QuestUtil.getComputerStartingCards(qEvent); + final List humanList = QuestUtil.getHumanStartingCards(qData, qEvent); + final List computerList = QuestUtil.getComputerStartingCards(qEvent); final int humanLife = qa.getLife(qData.getMode()) + extraLife; int computerLife = 20; @@ -156,14 +157,14 @@ public class QuestWinLoseHandler extends ControlWinLose { //do per-game actions if (matchState.hasWonLastGame(AllZone.getHumanPlayer().getName())) { if (isAnte) { - final CardList antes = AllZone.getComputerPlayer().getCardsIn(ZoneType.Ante); + final List antes = AllZone.getComputerPlayer().getCardsIn(ZoneType.Ante); final List antesPrinted = Singletons.getModel().getMatchState().addAnteWon(antes); this.anteWon(antesPrinted); } } else { if (isAnte) { - final CardList antes = AllZone.getHumanPlayer().getCardsIn(ZoneType.Ante); + final List antes = AllZone.getHumanPlayer().getCardsIn(ZoneType.Ante); final List antesPrinted = Singletons.getModel().getMatchState().addAnteLost(antes); for (final CardPrinted ante : antesPrinted) { //the last param here (should) determine if this is added to the Card Shop diff --git a/src/main/java/forge/gui/match/nonsingleton/CField.java b/src/main/java/forge/gui/match/nonsingleton/CField.java index 0f9c32372ee..8b5df92ccc9 100644 --- a/src/main/java/forge/gui/match/nonsingleton/CField.java +++ b/src/main/java/forge/gui/match/nonsingleton/CField.java @@ -32,7 +32,7 @@ import com.google.common.collect.Lists; import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.Command; import forge.Constant; import forge.Singletons; @@ -444,7 +444,7 @@ public class CField implements ICDoc { } } - final CardList att = AllZone.getCombat().getAttackerList(); + final List att = AllZone.getCombat().getAttackerList(); if ((c.isTapped() || c.hasSickness() || ((c.hasKeyword("Vigilance")) && att.contains(c))) && (input instanceof InputAttack)) { final forge.view.arcane.CardPanel cardPanel = CField.this.view.getTabletop().getCardPanel( diff --git a/src/main/java/forge/gui/match/views/VPlayers.java b/src/main/java/forge/gui/match/views/VPlayers.java index 18611ceb217..389ceb37da6 100644 --- a/src/main/java/forge/gui/match/views/VPlayers.java +++ b/src/main/java/forge/gui/match/views/VPlayers.java @@ -27,7 +27,8 @@ import javax.swing.border.MatteBorder; import net.miginfocom.swing.MigLayout; import forge.AllZone; -import forge.CardList; +import forge.Card; + import forge.Singletons; import forge.game.player.Player; import forge.game.zone.ZoneType; @@ -161,7 +162,7 @@ public enum VPlayers implements IVDoc { temp[5].setText(""); } if (Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE)) { - CardList list = p0.getCardsIn(ZoneType.Ante); + List list = p0.getCardsIn(ZoneType.Ante); StringBuilder sb = new StringBuilder(); sb.append("Ante'd: "); for (int i = 0; i < list.size(); i++) { diff --git a/src/main/java/forge/item/ItemPoolView.java b/src/main/java/forge/item/ItemPoolView.java index 1cfde767428..0c5e869ac36 100644 --- a/src/main/java/forge/item/ItemPoolView.java +++ b/src/main/java/forge/item/ItemPoolView.java @@ -26,7 +26,8 @@ import java.util.Map.Entry; import com.google.common.base.Function; -import forge.CardList; + +import forge.Card; import forge.card.CardRules; /** @@ -241,8 +242,8 @@ public class ItemPoolView implements Iterable toForgeCardList() { + final List result = new ArrayList(); for (final Entry e : this) { if (e.getKey() instanceof CardPrinted) { for (int i = 0; i < e.getValue(); i++) { diff --git a/src/main/java/forge/model/FMatchState.java b/src/main/java/forge/model/FMatchState.java index 9935a182efe..a2989318daf 100644 --- a/src/main/java/forge/model/FMatchState.java +++ b/src/main/java/forge/model/FMatchState.java @@ -24,7 +24,7 @@ import java.util.Map; import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.game.GameSummary; import forge.item.CardDb; import forge.item.CardPrinted; @@ -154,13 +154,13 @@ public class FMatchState { } /** - * Adds a CardList to the antes that have already been won this match. + * Adds a List to the antes that have already been won this match. * * @param antes cards won in ante * @return the list * @since 1.2.3 */ - public final List addAnteWon(final CardList antes) { + public final List addAnteWon(final List antes) { List antesPrinted = new ArrayList(); for (Card ante : antes) { CardPrinted cp = CardDb.instance().getCard(ante.getName(), ante.getCurSetCode()); @@ -189,13 +189,13 @@ public class FMatchState { } /** - * Adds a CardList to the antes that have already been lost this match. + * Adds a List to the antes that have already been lost this match. * * @param antes cards lost in ante * @return the list * @since 1.2.3 */ - public final List addAnteLost(final CardList antes) { + public final List addAnteLost(final List antes) { List antesPrinted = new ArrayList(); for (Card ante : antes) { CardPrinted cp = CardDb.instance().getCard(ante.getName(), ante.getCurSetCode()); diff --git a/src/main/java/forge/quest/QuestUtil.java b/src/main/java/forge/quest/QuestUtil.java index 9ca6b16d993..4417229481a 100644 --- a/src/main/java/forge/quest/QuestUtil.java +++ b/src/main/java/forge/quest/QuestUtil.java @@ -19,12 +19,13 @@ package forge.quest; import forge.AllZone; import forge.Card; -import forge.CardList; + import forge.card.cardfactory.CardFactory; import forge.game.player.Player; import forge.item.CardDb; import forge.quest.bazaar.QuestPetController; +import java.util.ArrayList; import java.util.List; /** @@ -46,8 +47,8 @@ public class QuestUtil { * a {@link forge.quest.data.QuestData} object. * @return a {@link forge.CardList} object. */ - public static CardList getComputerStartingCards() { - return new CardList(); + public static List getComputerStartingCards() { + return new ArrayList(); } /** @@ -62,8 +63,8 @@ public class QuestUtil { * a {@link forge.quest.QuestEvent} object. * @return a {@link forge.CardList} object. */ - public static CardList getComputerStartingCards(final QuestEvent qe) { - final CardList list = new CardList(); + public static List getComputerStartingCards(final QuestEvent qe) { + final List list = new ArrayList(); if (qe instanceof QuestEventChallenge) { final List extras = ((QuestEventChallenge) qe).getAIExtraCards(); @@ -86,8 +87,8 @@ public class QuestUtil { * a {@link forge.quest.data.QuestData} object. * @return a {@link forge.CardList} object. */ - public static CardList getHumanStartingCards(final QuestController qc) { - final CardList list = new CardList(); + public static List getHumanStartingCards(final QuestController qc) { + final List list = new ArrayList(); for (int iSlot = 0; iSlot < QuestController.MAX_PET_SLOTS; iSlot++) { @@ -122,8 +123,8 @@ public class QuestUtil { * a {@link forge.quest.QuestEvent} object. * @return a {@link forge.CardList} object. */ - public static CardList getHumanStartingCards(final QuestController qc, final QuestEvent qe) { - final CardList list = QuestUtil.getHumanStartingCards(qc); + public static List getHumanStartingCards(final QuestController qc, final QuestEvent qe) { + final List list = QuestUtil.getHumanStartingCards(qc); if (qe instanceof QuestEventChallenge) { final List extras = ((QuestEventChallenge) qe).getHumanExtraCards(); diff --git a/src/test/java/forge/BoosterDraftTest.java b/src/test/java/forge/BoosterDraftTest.java index 722f79b006a..a9edfb28347 100644 --- a/src/test/java/forge/BoosterDraftTest.java +++ b/src/test/java/forge/BoosterDraftTest.java @@ -1,5 +1,7 @@ package forge; +import java.util.List; + import org.testng.annotations.Test; import forge.card.BoosterData; @@ -77,7 +79,7 @@ public class BoosterDraftTest implements IBoosterDraft { * * @return a {@link forge.CardList} object. */ - public CardList getChosenCards() { + public List getChosenCards() { return null; } @@ -88,7 +90,7 @@ public class BoosterDraftTest implements IBoosterDraft { * * @return a {@link forge.CardList} object. */ - public CardList getUnchosenCards() { + public List getUnchosenCards() { return null; } diff --git a/src/test/java/forge/RunTest.java b/src/test/java/forge/RunTest.java index c3a903f16a1..5933d1d0bf8 100644 --- a/src/test/java/forge/RunTest.java +++ b/src/test/java/forge/RunTest.java @@ -261,7 +261,7 @@ public class RunTest { c2.setUniqueNumber(2); // test CardList - final CardList cardList = new CardList(Arrays.asList(new Card[] { c, c2 })); + final List cardList = new ArrayList(Arrays.asList(new Card[] { c, c2 })); this.check("111", cardList.contains(c)); this.check("112", cardList.contains(c2)); this.check("113", cardList.containsName(c)); @@ -275,12 +275,12 @@ public class RunTest { this.check("118", !c.hasSickness()); final CardFactoryInterface cf1 = AllZone.getCardFactory(); - final CardList c1 = new CardList(); + final List c1 = new ArrayList(); c1.add(cf1.getCard("Shock", null)); c1.add(cf1.getCard("Royal Assassin", null)); c1.add(cf1.getCard("Hymn to Tourach", null)); - CardList c3 = c1.filter(new Predicate() { + List c3 = c1.filter(new Predicate() { @Override public boolean isTrue(final Card c) { return c.isCreature();