From 08888616f7044b9e0c7ccb37481ab3c94ebd9eb2 Mon Sep 17 00:00:00 2001 From: Maxmtg Date: Sat, 7 Apr 2012 12:50:31 +0000 Subject: [PATCH] Zone moved to a personal package --- .gitattributes | 22 +- src/main/java/forge/AllZone.java | 19 +- src/main/java/forge/AllZoneUtil.java | 60 +++--- src/main/java/forge/Card.java | 68 +++---- src/main/java/forge/CardReader.java | 4 +- src/main/java/forge/CardUtil.java | 7 +- src/main/java/forge/Constant.java | 71 ------- src/main/java/forge/GameAction.java | 142 ++++++------- src/main/java/forge/GameActionUtil.java | 94 ++++----- src/main/java/forge/NameChanger.java | 2 +- src/main/java/forge/StaticEffects.java | 4 +- .../card/abilityfactory/AbilityFactory.java | 19 +- .../abilityfactory/AbilityFactoryAnimate.java | 6 +- .../abilityfactory/AbilityFactoryAttach.java | 6 +- .../AbilityFactoryChangeZone.java | 191 +++++++++--------- .../abilityfactory/AbilityFactoryChoose.java | 20 +- .../abilityfactory/AbilityFactoryClash.java | 10 +- .../abilityfactory/AbilityFactoryCombat.java | 4 +- .../abilityfactory/AbilityFactoryCopy.java | 4 +- .../AbilityFactoryCounters.java | 39 ++-- .../AbilityFactoryDealDamage.java | 12 +- .../abilityfactory/AbilityFactoryDebuff.java | 10 +- .../abilityfactory/AbilityFactoryDestroy.java | 16 +- .../abilityfactory/AbilityFactoryEffect.java | 8 +- .../AbilityFactoryGainControl.java | 9 +- .../abilityfactory/AbilityFactoryMana.java | 8 +- .../AbilityFactoryPermanentState.java | 30 +-- .../abilityfactory/AbilityFactoryPlay.java | 8 +- .../AbilityFactoryPreventDamage.java | 10 +- .../AbilityFactoryProtection.java | 6 +- .../abilityfactory/AbilityFactoryPump.java | 26 +-- .../AbilityFactoryRegenerate.java | 10 +- .../abilityfactory/AbilityFactoryReveal.java | 65 +++--- .../AbilityFactorySacrifice.java | 21 +- .../AbilityFactorySetState.java | 4 +- .../abilityfactory/AbilityFactoryToken.java | 4 +- .../AbilityFactoryZoneAffecting.java | 41 ++-- .../card/cardfactory/AbstractCardFactory.java | 51 +++-- .../card/cardfactory/CardFactoryAuras.java | 21 +- .../cardfactory/CardFactoryCreatures.java | 82 ++++---- .../card/cardfactory/CardFactoryInstants.java | 27 ++- .../card/cardfactory/CardFactoryLands.java | 29 ++- .../cardfactory/CardFactorySorceries.java | 75 ++++--- .../card/cardfactory/CardFactoryUtil.java | 157 +++++++------- src/main/java/forge/card/cost/Cost.java | 10 +- .../java/forge/card/cost/CostDiscard.java | 19 +- src/main/java/forge/card/cost/CostExile.java | 27 ++- src/main/java/forge/card/cost/CostMana.java | 8 +- src/main/java/forge/card/cost/CostMill.java | 11 +- .../java/forge/card/cost/CostPutCounter.java | 10 +- src/main/java/forge/card/cost/CostReturn.java | 10 +- src/main/java/forge/card/cost/CostReveal.java | 19 +- .../java/forge/card/cost/CostSacrifice.java | 10 +- .../java/forge/card/cost/CostTapType.java | 13 +- src/main/java/forge/card/cost/CostUtil.java | 8 +- .../forge/card/replacement/ReplaceMoved.java | 10 +- .../card/replacement/ReplacementEffect.java | 10 +- .../card/replacement/ReplacementHandler.java | 4 +- .../card/spellability/AbilityActivated.java | 4 +- .../java/forge/card/spellability/Spell.java | 11 +- .../spellability/SpellAbilityCondition.java | 8 +- .../SpellAbilityRequirements.java | 2 +- .../spellability/SpellAbilityRestriction.java | 14 +- .../spellability/SpellAbilityVariables.java | 14 +- .../card/spellability/SpellPermanent.java | 27 ++- .../java/forge/card/spellability/Target.java | 10 +- .../card/spellability/TargetSelection.java | 11 +- .../card/staticability/StaticAbility.java | 10 +- .../StaticAbilityCantBeCast.java | 4 +- .../StaticAbilityCantTarget.java | 7 +- .../StaticAbilityContinuous.java | 6 +- src/main/java/forge/card/trigger/Trigger.java | 16 +- .../forge/card/trigger/TriggerHandler.java | 15 +- .../java/forge/control/ControlMatchUI.java | 10 +- src/main/java/forge/control/input/Input.java | 4 +- .../java/forge/control/input/InputAttack.java | 13 +- .../java/forge/control/input/InputBlock.java | 6 +- .../forge/control/input/InputCleanup.java | 11 +- .../forge/control/input/InputMulligan.java | 23 +-- .../control/input/InputPassPriority.java | 2 +- .../forge/control/input/InputPayManaCost.java | 6 +- .../input/InputPayManaCostAbility.java | 6 +- .../control/input/InputPayManaCostUtil.java | 4 +- .../forge/control/match/ControlField.java | 34 ++-- .../java/forge/control/match/ControlHand.java | 10 +- .../forge/control/match/ControlWinLose.java | 6 +- src/main/java/forge/game/GameNew.java | 34 ++-- src/main/java/forge/game/GameState.java | 10 +- src/main/java/forge/game/phase/Combat.java | 4 +- .../java/forge/game/phase/CombatUtil.java | 64 +++--- src/main/java/forge/game/phase/EndOfTurn.java | 8 +- .../java/forge/game/phase/PhaseHandler.java | 12 +- src/main/java/forge/game/phase/PhaseUtil.java | 10 +- src/main/java/forge/game/phase/Untap.java | 29 ++- src/main/java/forge/game/phase/Upkeep.java | 147 +++++++------- src/main/java/forge/game/player/AIPlayer.java | 20 +- .../forge/game/player/ComputerAIGeneral.java | 38 ++-- .../java/forge/game/player/ComputerUtil.java | 53 +++-- .../forge/game/player/ComputerUtilAttack.java | 13 +- .../java/forge/game/player/HumanPlayer.java | 8 +- src/main/java/forge/game/player/Player.java | 113 ++++++----- .../java/forge/game/player/PlayerUtil.java | 32 +-- .../{player => zone}/DefaultPlayerZone.java | 33 ++- .../game/{player => zone}/IPlayerZone.java | 12 +- .../forge/{ => game/zone}/MagicStack.java | 35 ++-- .../game/{player => zone}/PlayerZone.java | 2 +- .../PlayerZoneComesIntoPlay.java | 17 +- src/main/java/forge/game/zone/ZoneType.java | 75 +++++++ src/main/java/forge/gui/CardDetailPanel.java | 15 +- src/main/java/forge/gui/GuiDisplayUtil.java | 54 ++--- src/main/java/forge/gui/GuiInput.java | 4 +- .../gui/MultiPhaseProgressMonitorWithETA.java | 6 +- .../forge/view/match/QuestWinLoseHandler.java | 6 +- src/main/java/forge/view/match/ViewField.java | 10 +- .../java/forge/view/match/ViewTabber.java | 6 +- .../BaseProgressMonitor.java | 44 ++-- .../BraidsProgressMonitor.java | 2 +- ...irectoriesSkipDotDirectoriesGenerator.java | 2 +- .../generator => }/GeneratorFunctions.java | 2 +- .../braids/util/generator/package-info.java | 11 - .../StderrProgressMonitor.java | 132 ------------ .../util/progress_monitor/package-info.java | 2 - 122 files changed, 1443 insertions(+), 1607 deletions(-) rename src/main/java/forge/game/{player => zone}/DefaultPlayerZone.java (90%) rename src/main/java/forge/game/{player => zone}/IPlayerZone.java (94%) rename src/main/java/forge/{ => game/zone}/MagicStack.java (98%) rename src/main/java/forge/game/{player => zone}/PlayerZone.java (97%) rename src/main/java/forge/game/{player => zone}/PlayerZoneComesIntoPlay.java (96%) create mode 100644 src/main/java/forge/game/zone/ZoneType.java rename src/main/java/net/slightlymagic/braids/{util/progress_monitor => }/BaseProgressMonitor.java (89%) rename src/main/java/net/slightlymagic/braids/{util/progress_monitor => }/BraidsProgressMonitor.java (99%) rename src/main/java/net/slightlymagic/braids/{util/generator => }/FindNonDirectoriesSkipDotDirectoriesGenerator.java (98%) rename src/main/java/net/slightlymagic/braids/{util/generator => }/GeneratorFunctions.java (99%) delete mode 100644 src/main/java/net/slightlymagic/braids/util/generator/package-info.java delete mode 100644 src/main/java/net/slightlymagic/braids/util/progress_monitor/StderrProgressMonitor.java delete mode 100644 src/main/java/net/slightlymagic/braids/util/progress_monitor/package-info.java diff --git a/.gitattributes b/.gitattributes index 8a0eed00185..219b163eba5 100644 --- a/.gitattributes +++ b/.gitattributes @@ -11357,7 +11357,6 @@ src/main/java/forge/GameEntity.java -text src/main/java/forge/GameLog.java -text src/main/java/forge/HandSizeOp.java svneol=native#text/plain src/main/java/forge/ImageCache.java svneol=native#text/plain -src/main/java/forge/MagicStack.java svneol=native#text/plain src/main/java/forge/MyObservable.java svneol=native#text/plain src/main/java/forge/NameChanger.java svneol=native#text/plain src/main/java/forge/Singletons.java svneol=native#text/plain @@ -11623,14 +11622,16 @@ src/main/java/forge/game/player/ComputerAIInput.java svneol=native#text/plain src/main/java/forge/game/player/ComputerUtil.java svneol=native#text/plain src/main/java/forge/game/player/ComputerUtilAttack.java svneol=native#text/plain src/main/java/forge/game/player/ComputerUtilBlock.java svneol=native#text/plain -src/main/java/forge/game/player/DefaultPlayerZone.java svneol=native#text/plain src/main/java/forge/game/player/HumanPlayer.java svneol=native#text/plain -src/main/java/forge/game/player/IPlayerZone.java svneol=native#text/plain src/main/java/forge/game/player/Player.java svneol=native#text/plain src/main/java/forge/game/player/PlayerType.java svneol=native#text/plain src/main/java/forge/game/player/PlayerUtil.java svneol=native#text/plain -src/main/java/forge/game/player/PlayerZone.java svneol=native#text/plain -src/main/java/forge/game/player/PlayerZoneComesIntoPlay.java svneol=native#text/plain +src/main/java/forge/game/zone/DefaultPlayerZone.java svneol=native#text/plain +src/main/java/forge/game/zone/IPlayerZone.java svneol=native#text/plain +src/main/java/forge/game/zone/MagicStack.java svneol=native#text/plain +src/main/java/forge/game/zone/PlayerZone.java svneol=native#text/plain +src/main/java/forge/game/zone/PlayerZoneComesIntoPlay.java svneol=native#text/plain +src/main/java/forge/game/zone/ZoneType.java -text src/main/java/forge/gui/CardContainer.java svneol=native#text/plain src/main/java/forge/gui/CardDetailPanel.java svneol=native#text/plain src/main/java/forge/gui/CardListViewer.java -text @@ -11893,14 +11894,11 @@ src/main/java/forge/view/match/ViewTabber.java -text src/main/java/forge/view/match/ViewWinLose.java -text src/main/java/forge/view/match/package-info.java svneol=native#text/plain src/main/java/forge/view/package-info.java svneol=native#text/plain +src/main/java/net/slightlymagic/braids/BaseProgressMonitor.java svneol=native#text/plain +src/main/java/net/slightlymagic/braids/BraidsProgressMonitor.java svneol=native#text/plain +src/main/java/net/slightlymagic/braids/FindNonDirectoriesSkipDotDirectoriesGenerator.java svneol=native#text/plain +src/main/java/net/slightlymagic/braids/GeneratorFunctions.java svneol=native#text/plain src/main/java/net/slightlymagic/braids/LICENSE.txt svneol=native#text/plain -src/main/java/net/slightlymagic/braids/util/generator/FindNonDirectoriesSkipDotDirectoriesGenerator.java svneol=native#text/plain -src/main/java/net/slightlymagic/braids/util/generator/GeneratorFunctions.java svneol=native#text/plain -src/main/java/net/slightlymagic/braids/util/generator/package-info.java svneol=native#text/plain -src/main/java/net/slightlymagic/braids/util/progress_monitor/BaseProgressMonitor.java svneol=native#text/plain -src/main/java/net/slightlymagic/braids/util/progress_monitor/BraidsProgressMonitor.java svneol=native#text/plain -src/main/java/net/slightlymagic/braids/util/progress_monitor/StderrProgressMonitor.java svneol=native#text/plain -src/main/java/net/slightlymagic/braids/util/progress_monitor/package-info.java svneol=native#text/plain src/main/java/tree/properties/PropertyElement.java svneol=native#text/plain src/main/java/tree/properties/PropertyType.java svneol=native#text/plain src/main/java/tree/properties/TreeProperties.java svneol=native#text/plain diff --git a/src/main/java/forge/AllZone.java b/src/main/java/forge/AllZone.java index fea739155d3..b4255b59a98 100644 --- a/src/main/java/forge/AllZone.java +++ b/src/main/java/forge/AllZone.java @@ -20,7 +20,6 @@ package forge; import java.util.Arrays; import java.util.List; -import forge.Constant.Zone; import forge.card.cardfactory.CardFactoryInterface; import forge.card.cardfactory.PreloadingCardFactory; import forge.card.replacement.ReplacementHandler; @@ -30,7 +29,9 @@ import forge.game.GameState; import forge.game.phase.Combat; import forge.game.phase.EndOfTurn; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.MagicStack; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.properties.ForgeProps; import forge.properties.NewConstants; import forge.quest.QuestController; @@ -226,7 +227,7 @@ public final class AllZone { * * Will eventually be marked deprecated. * - * @return a {@link forge.MagicStack} object. + * @return a {@link forge.game.zone.MagicStack} object. * @since 1.0.15 */ public static MagicStack getStack() { @@ -333,7 +334,7 @@ public final class AllZone { * * Will eventually be marked deprecated. * - * @return a {@link forge.game.player.PlayerZone} object. + * @return a {@link forge.game.zone.PlayerZone} object. * @since 1.0.15 */ public static PlayerZone getStackZone() { @@ -347,7 +348,7 @@ public final class AllZone { * * @param c * a {@link forge.Card} object. - * @return a {@link forge.game.player.PlayerZone} object. + * @return a {@link forge.game.zone.PlayerZone} object. */ public static PlayerZone getZoneOf(final Card c) { final GameState gameState = Singletons.getModel().getGameState(); @@ -360,7 +361,7 @@ public final class AllZone { } for (final Player p : gameState.getPlayers()) { - for (final Zone z : Player.ALL_ZONES) { + for (final ZoneType z : Player.ALL_ZONES) { final PlayerZone pz = p.getZone(z); if (pz.contains(c)) { return pz; @@ -381,13 +382,13 @@ public final class AllZone { * Constant.Zone * @return boolean */ - public static boolean isCardInZone(final Card c, final Constant.Zone zone) { + public static boolean isCardInZone(final Card c, final ZoneType zone) { final GameState gameState = Singletons.getModel().getGameState(); if (gameState == null) { return false; } - if (zone.equals(Constant.Zone.Stack)) { + if (zone.equals(ZoneType.Stack)) { if (gameState.getStackZone().contains(c)) { return true; } @@ -413,7 +414,7 @@ public final class AllZone { return; } for (final Player p : gameState.getPlayers()) { - for (final Zone z : Player.ALL_ZONES) { + for (final ZoneType z : Player.ALL_ZONES) { p.getZone(z).resetCardsAddedThisTurn(); } } diff --git a/src/main/java/forge/AllZoneUtil.java b/src/main/java/forge/AllZoneUtil.java index 3a52970de27..27c06030518 100644 --- a/src/main/java/forge/AllZoneUtil.java +++ b/src/main/java/forge/AllZoneUtil.java @@ -18,8 +18,8 @@ package forge; import java.util.ArrayList; -import forge.Constant.Zone; import forge.game.player.Player; +import forge.game.zone.ZoneType; /** * AllZoneUtil contains static functions used to get CardLists of various cards @@ -40,14 +40,14 @@ public abstract class AllZoneUtil { * Constant.Zone * @return a CardList with all cards currently in a graveyard */ - public static CardList getCardsIn(final Constant.Zone zone) { + public static CardList getCardsIn(final ZoneType zone) { final CardList cards = new CardList(); getCardsIn(zone, cards); return cards; } - private static void getCardsIn(final Constant.Zone zone, final CardList cards) { - if (zone == Zone.Stack) { + private static void getCardsIn(final ZoneType zone, final CardList cards) { + if (zone == ZoneType.Stack) { cards.addAll(AllZone.getStackZone().getCards()); } else { for (final Player p : AllZone.getPlayersInGame()) { @@ -56,17 +56,17 @@ public abstract class AllZoneUtil { } } - public static CardList getCardsIn(final Iterable zones) { + public static CardList getCardsIn(final Iterable zones) { final CardList cards = new CardList(); - for (final Zone z : zones) { + for (final ZoneType z : zones) { getCardsIn(z, cards); } return cards; } - public static CardList getCardsIn(final Constant.Zone[] zones) { + public static CardList getCardsIn(final ZoneType[] zones) { final CardList cards = new CardList(); - for (final Zone z : zones) { + for (final ZoneType z : zones) { getCardsIn(z, cards); } return cards; @@ -82,7 +82,7 @@ public abstract class AllZoneUtil { * a String * @return a CardList with all cards currently in a graveyard */ - public static CardList getCardsIn(final Constant.Zone zone, final String cardName) { + public static CardList getCardsIn(final ZoneType zone, final String cardName) { return AllZoneUtil.getCardsIn(zone).getName(cardName); } @@ -95,7 +95,7 @@ public abstract class AllZoneUtil { * @return a CardList of all creatures on the battlefield on both sides */ public static CardList getCreaturesInPlay() { - final CardList creats = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList creats = AllZoneUtil.getCardsIn(ZoneType.Battlefield); return creats.filter(CardListFilter.CREATURES); } @@ -107,7 +107,7 @@ public abstract class AllZoneUtil { * @return a CardList containing all creatures a given player has in play */ public static CardList getCreaturesInPlay(final Player player) { - final CardList creats = player.getCardsIn(Zone.Battlefield); + final CardList creats = player.getCardsIn(ZoneType.Battlefield); return creats.filter(CardListFilter.CREATURES); } @@ -121,7 +121,7 @@ public abstract class AllZoneUtil { * @return a CardList containing all lands the given player has in play */ public static CardList getPlayerLandsInPlay(final Player player) { - return player.getCardsIn(Zone.Battlefield).filter(CardListFilter.LANDS); + return player.getCardsIn(ZoneType.Battlefield).filter(CardListFilter.LANDS); } /** @@ -130,7 +130,7 @@ public abstract class AllZoneUtil { * @return a CardList of all lands on the battlefield */ public static CardList getLandsInPlay() { - return AllZoneUtil.getCardsIn(Zone.Battlefield).filter(CardListFilter.LANDS); + return AllZoneUtil.getCardsIn(ZoneType.Battlefield).filter(CardListFilter.LANDS); } // ============================================================================= @@ -148,7 +148,7 @@ public abstract class AllZoneUtil { * @return true is the card is in Human or Computer's Exile zone */ public static boolean isCardExiled(final Card c) { - return AllZoneUtil.getCardsIn(Zone.Exile).contains(c); + return AllZoneUtil.getCardsIn(ZoneType.Exile).contains(c); } // /Check if a certain card is in play @@ -163,7 +163,7 @@ public abstract class AllZoneUtil { * @return a boolean. */ public static boolean isCardInPlay(final Card card) { - return AllZoneUtil.getCardsIn(Zone.Battlefield).contains(card); + return AllZoneUtil.getCardsIn(ZoneType.Battlefield).contains(card); } /** @@ -174,7 +174,7 @@ public abstract class AllZoneUtil { * @return true is the card is in play, false otherwise */ public static boolean isCardInPlay(final String cardName) { - for (Card card : AllZoneUtil.getCardsIn(Zone.Battlefield)) { + for (Card card : AllZoneUtil.getCardsIn(ZoneType.Battlefield)) { if (card.getName().equals(cardName)) { return true; } @@ -192,7 +192,7 @@ public abstract class AllZoneUtil { * @return true if that player has that card in play, false otherwise */ public static boolean isCardInPlay(final String cardName, final Player player) { - for (Card card : player.getCardsIn(Zone.Battlefield)) { + for (Card card : player.getCardsIn(ZoneType.Battlefield)) { if (card.getName().equals(cardName)) { return true; } @@ -226,7 +226,7 @@ public abstract class AllZoneUtil { * @return a CardList of all cards in play of a given color */ public static CardList getPlayerColorInPlay(final Player player, final String color) { - CardList cards = player.getCardsIn(Zone.Battlefield); + CardList cards = player.getCardsIn(ZoneType.Battlefield); cards = cards.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -271,8 +271,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 = player.getCardsIn(Zone.Battlefield).getType(type); - final CardList opponentList = opponent.getCardsIn(Zone.Battlefield).getType(type); + final CardList playerList = player.getCardsIn(ZoneType.Battlefield).getType(type); + final CardList opponentList = opponent.getCardsIn(ZoneType.Battlefield).getType(type); return (playerList.size() - opponentList.size()); } @@ -290,8 +290,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 = player.getCardsIn(Zone.Graveyard).getType(type); - final CardList opponentList = opponent.getCardsIn(Zone.Graveyard).getType(type); + final CardList playerList = player.getCardsIn(ZoneType.Graveyard).getType(type); + final CardList opponentList = opponent.getCardsIn(ZoneType.Graveyard).getType(type); return (playerList.size() - opponentList.size()); } @@ -304,11 +304,11 @@ public abstract class AllZoneUtil { public static CardList getCardsInGame() { final CardList all = new CardList(); for (final Player player : AllZone.getPlayersInGame()) { - all.addAll(player.getZone(Zone.Graveyard).getCards()); - all.addAll(player.getZone(Zone.Hand).getCards()); - all.addAll(player.getZone(Zone.Library).getCards()); - all.addAll(player.getZone(Zone.Battlefield).getCards(false)); - all.addAll(player.getZone(Zone.Exile).getCards()); + all.addAll(player.getZone(ZoneType.Graveyard).getCards()); + all.addAll(player.getZone(ZoneType.Hand).getCards()); + all.addAll(player.getZone(ZoneType.Library).getCards()); + all.addAll(player.getZone(ZoneType.Battlefield).getCards(false)); + all.addAll(player.getZone(ZoneType.Exile).getCards()); } all.addAll(AllZone.getStackZone().getCards()); return all; @@ -325,7 +325,7 @@ public abstract class AllZoneUtil { * @return a int. */ public static int getDoublingSeasonMagnitude(final Player player) { - final int doublingSeasons = player.getCardsIn(Zone.Battlefield, "Doubling Season").size(); + final int doublingSeasons = player.getCardsIn(ZoneType.Battlefield, "Doubling Season").size(); return (int) Math.pow(2, doublingSeasons); // pow(a,0) = 1; pow(a,1) = a // ... no worries about size // = 0 @@ -342,8 +342,8 @@ public abstract class AllZoneUtil { * @return a int. */ public static int getTokenDoublersMagnitude(final Player player) { - final int tokenDoublers = player.getCardsIn(Zone.Battlefield, "Parallel Lives").size() - + player.getCardsIn(Zone.Battlefield, "Doubling Season").size(); + final int tokenDoublers = player.getCardsIn(ZoneType.Battlefield, "Parallel Lives").size() + + player.getCardsIn(ZoneType.Battlefield, "Doubling Season").size(); return (int) Math.pow(2, tokenDoublers); // pow(a,0) = 1; pow(a,1) = a // ... no worries about size = // 0 diff --git a/src/main/java/forge/Card.java b/src/main/java/forge/Card.java index 0e7a28063e0..07718777225 100644 --- a/src/main/java/forge/Card.java +++ b/src/main/java/forge/Card.java @@ -33,7 +33,6 @@ import java.util.TreeMap; import com.esotericsoftware.minlog.Log; -import forge.Constant.Zone; import forge.card.CardCharacteristics; import forge.card.EditionInfo; import forge.card.abilityfactory.AbilityFactory; @@ -53,6 +52,7 @@ import forge.card.trigger.TriggerType; import forge.card.trigger.ZCTrigger; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.item.CardDb; import forge.util.MyRandom; @@ -82,7 +82,7 @@ public class Card extends GameEntity implements Comparable { private boolean isFlip = false; private CardCharactersticName otherTransformable = null; - private Zone castFrom = null; + private ZoneType castFrom = null; private final CardDamageHistory damageHistory = new CardDamageHistory(); private Map counters = new TreeMap(); @@ -5497,7 +5497,7 @@ public class Card extends GameEntity implements Comparable { * @return a boolean. */ public final boolean isSpell() { - return (this.isInstant() || this.isSorcery() || (this.isAura() && !AllZoneUtil.getCardsIn(Zone.Battlefield) + return (this.isInstant() || this.isSorcery() || (this.isAura() && !AllZoneUtil.getCardsIn(ZoneType.Battlefield) .contains(this))); } @@ -6470,7 +6470,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(Zone.Battlefield); + final CardList list = this.getController().getCardsIn(ZoneType.Battlefield); if (list.getType(type).isEmpty()) { return false; } @@ -6526,31 +6526,31 @@ public class Card extends GameEntity implements Comparable { return false; } } else if (property.startsWith("Above")) { // "Are Above" Source - final CardList list = this.getOwner().getCardsIn(Zone.Graveyard); + final CardList list = this.getOwner().getCardsIn(ZoneType.Graveyard); if (!list.getAbove(source, this)) { return false; } } else if (property.startsWith("DirectlyAbove")) { // "Are Directly Above" // Source - final CardList list = this.getOwner().getCardsIn(Zone.Graveyard); + final CardList list = this.getOwner().getCardsIn(ZoneType.Graveyard); if (!list.getDirectlyAbove(source, this)) { return false; } } else if (property.startsWith("TopGraveyardCreature")) { - CardList list = this.getOwner().getCardsIn(Zone.Graveyard); + CardList list = this.getOwner().getCardsIn(ZoneType.Graveyard); list = list.getType("Creature"); list.reverse(); if (list.isEmpty() || !this.equals(list.get(0))) { return false; } } else if (property.startsWith("TopGraveyard")) { - final CardList list = this.getOwner().getCardsIn(Zone.Graveyard); + final CardList list = this.getOwner().getCardsIn(ZoneType.Graveyard); list.reverse(); if (list.isEmpty() || !this.equals(list.get(0))) { return false; } } else if (property.startsWith("TopLibrary")) { - final CardList list = this.getOwner().getCardsIn(Zone.Library); + final CardList list = this.getOwner().getCardsIn(ZoneType.Library); if (list.isEmpty() || !this.equals(list.get(0))) { return false; } @@ -6574,7 +6574,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(Zone.Library); + final CardList list = sourceController.getCardsIn(ZoneType.Library); if (list.isEmpty() || !this.sharesColorWith(list.get(0))) { return false; } @@ -6586,7 +6586,7 @@ public class Card extends GameEntity implements Comparable { } } else { boolean shares = false; - for (final Card card : sourceController.getCardsIn(Constant.Zone.Battlefield)) { + for (final Card card : sourceController.getCardsIn(ZoneType.Battlefield)) { if (card.isValid(restriction, sourceController, source) && this.sharesColorWith(card)) { shares = true; } @@ -6604,7 +6604,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(Zone.Library); + final CardList list = sourceController.getCardsIn(ZoneType.Library); if (list.isEmpty() || !this.sharesCreatureTypeWith(list.get(0))) { return false; } @@ -6623,7 +6623,7 @@ public class Card extends GameEntity implements Comparable { } } else { boolean shares = false; - for (final Card card : sourceController.getCardsIn(Constant.Zone.Battlefield)) { + for (final Card card : sourceController.getCardsIn(ZoneType.Battlefield)) { if (card.isValid(restriction, sourceController, source) && this.sharesCreatureTypeWith(card)) { shares = true; } @@ -6636,12 +6636,12 @@ public class Card extends GameEntity implements Comparable { } else if (property.startsWith("sharesNameWith")) { final String restriction = property.split("sharesNameWith ")[1]; if (restriction.equals("YourGraveyard")) { - final CardList list = sourceController.getCardsIn(Zone.Graveyard); + final CardList list = sourceController.getCardsIn(ZoneType.Graveyard); if (list.isEmpty()) { return false; } boolean shares = false; - for (final Card card : sourceController.getCardsIn(Constant.Zone.Graveyard)) { + for (final Card card : sourceController.getCardsIn(ZoneType.Graveyard)) { if (this.getName().equals(card.getName())) { shares = true; } @@ -6649,13 +6649,13 @@ public class Card extends GameEntity implements Comparable { if (!shares) { return false; } - } else if (restriction.equals(Constant.Zone.Battlefield.toString())) { - final CardList list = AllZoneUtil.getCardsIn(Constant.Zone.Battlefield); + } else if (restriction.equals(ZoneType.Battlefield.toString())) { + final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); if (list.isEmpty()) { return false; } boolean shares = false; - for (final Card card : AllZoneUtil.getCardsIn(Constant.Zone.Battlefield)) { + for (final Card card : AllZoneUtil.getCardsIn(ZoneType.Battlefield)) { if (this.getName().equals(card.getName())) { shares = true; } @@ -6822,7 +6822,7 @@ public class Card extends GameEntity implements Comparable { } } } else if (property.startsWith("lowestCMC")) { - final CardList list = AllZoneUtil.getCardsIn(Constant.Zone.Battlefield); + final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card crd : list) { if (!crd.isLand() && !crd.isImmutable() && (crd.getCMC() < this.getCMC())) { return false; @@ -7048,13 +7048,13 @@ public class Card extends GameEntity implements Comparable { } } else if (property.startsWith("wasCastFrom")) { final String strZone = property.substring(11); - final Zone realZone = Constant.Zone.smartValueOf(strZone); + final ZoneType realZone = ZoneType.smartValueOf(strZone); if (realZone != this.getCastFrom()) { return false; } } else if (property.startsWith("wasNotCastFrom")) { final String strZone = property.substring(14); - final Zone realZone = Constant.Zone.smartValueOf(strZone); + final ZoneType realZone = ZoneType.smartValueOf(strZone); if (realZone == this.getCastFrom()) { return false; } @@ -7814,7 +7814,7 @@ public class Card extends GameEntity implements Comparable { } // Prevent Damage static abilities - final CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card ca : allp) { final ArrayList staticAbilities = ca.getStaticAbilities(); for (final StaticAbility stAb : staticAbilities) { @@ -7923,7 +7923,7 @@ public class Card extends GameEntity implements Comparable { int restDamage = damage; if (AllZoneUtil.isCardInPlay("Sulfuric Vapors") && source.isSpell() && source.isRed()) { - final int amount = AllZoneUtil.getCardsIn(Zone.Battlefield, "Sulfuric Vapors").size(); + final int amount = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Sulfuric Vapors").size(); for (int i = 0; i < amount; i++) { restDamage += 1; } @@ -7931,14 +7931,14 @@ public class Card extends GameEntity implements Comparable { if (AllZoneUtil.isCardInPlay("Pyromancer's Swath", source.getController()) && (source.isInstant() || source.isSorcery()) && this.isCreature()) { - final int amount = source.getController().getCardsIn(Zone.Battlefield, "Pyromancer's Swath").size(); + final int amount = source.getController().getCardsIn(ZoneType.Battlefield, "Pyromancer's Swath").size(); for (int i = 0; i < amount; i++) { restDamage += 2; } } if (AllZoneUtil.isCardInPlay("Furnace of Rath") && this.isCreature()) { - final int amount = AllZoneUtil.getCardsIn(Zone.Battlefield, "Furnace of Rath").size(); + final int amount = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Furnace of Rath").size(); for (int i = 0; i < amount; i++) { restDamage += restDamage; } @@ -7946,7 +7946,7 @@ public class Card extends GameEntity implements Comparable { if (AllZoneUtil.isCardInPlay("Gratuitous Violence", source.getController()) && source.isCreature() && this.isCreature()) { - final int amount = source.getController().getCardsIn(Zone.Battlefield, "Gratuitous Violence").size(); + final int amount = source.getController().getCardsIn(ZoneType.Battlefield, "Gratuitous Violence").size(); for (int i = 0; i < amount; i++) { restDamage += restDamage; } @@ -7954,14 +7954,14 @@ public class Card extends GameEntity implements Comparable { if (AllZoneUtil.isCardInPlay("Fire Servant", source.getController()) && source.isRed() && (source.isInstant() || source.isSorcery())) { - final int amount = source.getController().getCardsIn(Zone.Battlefield, "Fire Servant").size(); + final int amount = source.getController().getCardsIn(ZoneType.Battlefield, "Fire Servant").size(); for (int i = 0; i < amount; i++) { restDamage += restDamage; } } if (AllZoneUtil.isCardInPlay("Benevolent Unicorn") && source.isSpell() && this.isCreature()) { - final int amount = AllZoneUtil.getCardsIn(Zone.Battlefield, "Benevolent Unicorn").size(); + final int amount = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Benevolent Unicorn").size(); for (int i = 0; i < amount; i++) { if (restDamage > 0) { restDamage -= 1; @@ -7970,7 +7970,7 @@ public class Card extends GameEntity implements Comparable { } if (AllZoneUtil.isCardInPlay("Lashknife Barrier", this.getController()) && this.isCreature()) { - final int amount = this.getController().getCardsIn(Zone.Battlefield, "Lashknife Barrier").size(); + final int amount = this.getController().getCardsIn(ZoneType.Battlefield, "Lashknife Barrier").size(); for (int i = 0; i < amount; i++) { if (restDamage > 0) { restDamage -= 1; @@ -8523,7 +8523,7 @@ public class Card extends GameEntity implements Comparable { * Constant.Zone * @return boolean */ - public boolean isInZone(final Constant.Zone zone) { + public boolean isInZone(final ZoneType zone) { return AllZone.isCardInZone(this, zone); } @@ -8542,7 +8542,7 @@ public class Card extends GameEntity implements Comparable { } // CantTarget static abilities - final CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card ca : allp) { final ArrayList staticAbilities = ca.getStaticAbilities(); for (final StaticAbility stAb : staticAbilities) { @@ -8553,7 +8553,7 @@ public class Card extends GameEntity implements Comparable { } // keywords don't work outside battlefield - if (!this.isInZone(Constant.Zone.Battlefield)) { + if (!this.isInZone(ZoneType.Battlefield)) { return true; } @@ -8685,7 +8685,7 @@ public class Card extends GameEntity implements Comparable { * * @return the castFrom */ - public Zone getCastFrom() { + public ZoneType getCastFrom() { return this.castFrom; } @@ -8693,7 +8693,7 @@ public class Card extends GameEntity implements Comparable { * @param castFrom0 * the castFrom to set */ - public void setCastFrom(final Zone castFrom0) { + public void setCastFrom(final ZoneType castFrom0) { this.castFrom = castFrom0; } diff --git a/src/main/java/forge/CardReader.java b/src/main/java/forge/CardReader.java index c019318bedd..413e3888314 100644 --- a/src/main/java/forge/CardReader.java +++ b/src/main/java/forge/CardReader.java @@ -35,8 +35,8 @@ import java.util.zip.ZipFile; import javax.swing.SwingUtilities; -import net.slightlymagic.braids.util.generator.FindNonDirectoriesSkipDotDirectoriesGenerator; -import net.slightlymagic.braids.util.generator.GeneratorFunctions; +import net.slightlymagic.braids.FindNonDirectoriesSkipDotDirectoriesGenerator; +import net.slightlymagic.braids.GeneratorFunctions; import com.google.code.jyield.Generator; import com.google.code.jyield.YieldUtils; diff --git a/src/main/java/forge/CardUtil.java b/src/main/java/forge/CardUtil.java index 5953de9d2c1..111f76eaa22 100644 --- a/src/main/java/forge/CardUtil.java +++ b/src/main/java/forge/CardUtil.java @@ -37,7 +37,8 @@ import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbilityList; import forge.card.trigger.TriggerType; import forge.control.input.InputPayManaCostUtil; -import forge.game.player.DefaultPlayerZone; +import forge.game.zone.DefaultPlayerZone; +import forge.game.zone.ZoneType; import forge.gui.GuiDisplayUtil; import forge.item.CardPrinted; import forge.properties.ForgeProps; @@ -850,10 +851,10 @@ public final class CardUtil { * a Card object * @return a CardList that matches the given criteria */ - public static CardList getThisTurnEntered(final Constant.Zone to, final Constant.Zone from, final String valid, + public static CardList getThisTurnEntered(final ZoneType to, final ZoneType from, final String valid, final Card src) { CardList res = new CardList(); - if (to != Constant.Zone.Stack) { + if (to != ZoneType.Stack) { res.addAll(((DefaultPlayerZone) AllZone.getComputerPlayer().getZone(to)).getCardsAddedThisTurn(from)); res.addAll(((DefaultPlayerZone) AllZone.getHumanPlayer().getZone(to)).getCardsAddedThisTurn(from)); } else { diff --git a/src/main/java/forge/Constant.java b/src/main/java/forge/Constant.java index 8562cd9c678..c9f68a557f6 100644 --- a/src/main/java/forge/Constant.java +++ b/src/main/java/forge/Constant.java @@ -124,77 +124,6 @@ public final class Constant { } } - /** - * The Enum Zone. - */ - public enum Zone { - - /** The Hand. */ - Hand(true), - - /** The Library. */ - Library(true), - - /** The Graveyard. */ - Graveyard(false), - - /** The Battlefield. */ - Battlefield(false), - - /** The Exile. */ - Exile(false), - - /** The Command. */ - Command(false), - - /** The Stack. */ - Stack(false), - - Sideboard(true), - /** Ante. */ - Ante(false); - - public static final Zone[] StaticAbilitiesSourceZones = new Zone[]{Battlefield, Graveyard, Exile/*, Hand*/}; - - private final boolean holdsHiddenInfo; - private Zone(boolean holdsHidden) { - holdsHiddenInfo = holdsHidden; - } - - - public static Zone smartValueOf(final String value) { - if (value == null) { - return null; - } - if ("All".equals(value)) { - return null; - } - final String valToCompate = value.trim(); - for (final Zone v : Zone.values()) { - if (v.name().compareToIgnoreCase(valToCompate) == 0) { - return v; - } - } - throw new IllegalArgumentException("No element named " + value + " in enum Zone"); - } - - public static List listValueOf(final String values) { - final List result = new ArrayList(); - for (final String s : values.split("[, ]+")) { - result.add(Zone.smartValueOf(s)); - } - return result; - } - - public boolean isHidden() { - return holdsHiddenInfo; - } - - public boolean isKnown() { - return !holdsHiddenInfo; - } - } - /** * The Interface Color. */ diff --git a/src/main/java/forge/GameAction.java b/src/main/java/forge/GameAction.java index c6539585104..90aa870ae2b 100644 --- a/src/main/java/forge/GameAction.java +++ b/src/main/java/forge/GameAction.java @@ -23,7 +23,6 @@ import java.util.Iterator; import javax.swing.JFrame; -import forge.Constant.Zone; import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactoryAttach; import forge.card.abilityfactory.AbilityFactoryCharm; @@ -52,8 +51,9 @@ import forge.game.GameSummary; import forge.game.phase.PhaseHandler; import forge.game.player.ComputerUtil; import forge.game.player.Player; -import forge.game.player.PlayerZone; -import forge.game.player.PlayerZoneComesIntoPlay; +import forge.game.zone.PlayerZone; +import forge.game.zone.PlayerZoneComesIntoPlay; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.view.match.ViewWinLose; @@ -86,9 +86,9 @@ public class GameAction { *

* * @param zoneFrom - * a {@link forge.game.player.PlayerZone} object. + * a {@link forge.game.zone.PlayerZone} object. * @param zoneTo - * a {@link forge.game.player.PlayerZone} object. + * a {@link forge.game.zone.PlayerZone} object. * @param c * a {@link forge.Card} object. * @return a {@link forge.Card} object. @@ -120,7 +120,7 @@ public class GameAction { repParams.put("Destination", zoneTo.getZoneType()); if (AllZone.getReplacementHandler().run(repParams)) { - if (AllZone.getStack().isResolving(c) && !zoneTo.is(Constant.Zone.Graveyard)) { + if (AllZone.getStack().isResolving(c) && !zoneTo.is(ZoneType.Graveyard)) { return Singletons.getModel().getGameAction().moveToGraveyard(c); } return c; @@ -133,8 +133,8 @@ public class GameAction { // Don't copy Tokens, Cards staying in same zone, or cards entering // Battlefield - if (c.isToken() || suppress || zoneTo.is(Constant.Zone.Battlefield) || zoneTo.is(Constant.Zone.Stack) - || (zoneFrom.is(Constant.Zone.Stack) && zoneTo.is(Constant.Zone.Battlefield))) { + if (c.isToken() || suppress || zoneTo.is(ZoneType.Battlefield) || zoneTo.is(ZoneType.Stack) + || (zoneFrom.is(ZoneType.Stack) && zoneTo.is(ZoneType.Battlefield))) { lastKnownInfo = c; copied = c; } else { @@ -168,12 +168,12 @@ public class GameAction { zoneTo.add(copied); // Tokens outside the battlefield disappear immideately. - if (copied.isToken() && !zoneTo.is(Constant.Zone.Battlefield)) { + if (copied.isToken() && !zoneTo.is(ZoneType.Battlefield)) { zoneTo.remove(copied); } if (zoneFrom != null) { - if (zoneFrom.is(Constant.Zone.Battlefield) && c.isCreature()) { + if (zoneFrom.is(ZoneType.Battlefield) && c.isCreature()) { AllZone.getCombat().removeFromCombat(c); } @@ -203,11 +203,11 @@ public class GameAction { // remove all counters from the card if destination is not the // battlefield // UNLESS we're dealing with Skullbriar, the Walking Grave - if (!zoneTo.is(Constant.Zone.Battlefield)) { + if (!zoneTo.is(ZoneType.Battlefield)) { // remove all counters from the card if destination is not the battlefield // UNLESS we're dealing with Skullbriar, the Walking Grave - if (!(c.getName().equals("Skullbriar, the Walking Grave") && !zoneTo.is(Constant.Zone.Hand) && !zoneTo - .is(Constant.Zone.Library))) { + if (!(c.getName().equals("Skullbriar, the Walking Grave") && !zoneTo.is(ZoneType.Hand) && !zoneTo + .is(ZoneType.Library))) { copied.clearCounters(); } AllZone.getTriggerHandler().suppressMode(TriggerType.Transformed); @@ -232,7 +232,7 @@ public class GameAction { *

* * @param zone - * a {@link forge.game.player.PlayerZone} object. + * a {@link forge.game.zone.PlayerZone} object. * @param c * a {@link forge.Card} object. * @return a {@link forge.Card} object. @@ -244,8 +244,8 @@ public class GameAction { // String prevName = prev != null ? prev.getZoneName() : ""; if (c.hasKeyword("If CARDNAME would leave the battlefield, exile it instead of putting it anywhere else.") - && !zone.is(Constant.Zone.Exile)) { - final PlayerZone removed = c.getOwner().getZone(Constant.Zone.Exile); + && !zone.is(ZoneType.Exile)) { + final PlayerZone removed = c.getOwner().getZone(ZoneType.Exile); c.removeAllExtrinsicKeyword("If CARDNAME would leave the battlefield, " + "exile it instead of putting it anywhere else."); return this.moveTo(removed, c); @@ -255,15 +255,15 @@ public class GameAction { c = GameAction.changeZone(prev, zone, c); - if (zone.is(Zone.Stack)) { + if (zone.is(ZoneType.Stack)) { c.setCastFrom(prev.getZoneType()); } else if (prev == null) { c.setCastFrom(null); - } else if (!(zone.is(Zone.Battlefield) && prev.is(Zone.Stack))) { + } else if (!(zone.is(ZoneType.Battlefield) && prev.is(ZoneType.Stack))) { c.setCastFrom(null); } - if (c.isAura() && zone.is(Constant.Zone.Battlefield) && ((prev == null) || !prev.is(Constant.Zone.Stack)) + if (c.isAura() && zone.is(ZoneType.Battlefield) && ((prev == null) || !prev.is(ZoneType.Stack)) && !c.isEnchanting()) { // TODO Need a way to override this for Abilities that put Auras // into play attached to things @@ -285,8 +285,8 @@ public class GameAction { public final Card moveToPlayFromHand(Card c) { // handles the case for Clone, etc where prev was null - final PlayerZone hand = c.getOwner().getZone(Constant.Zone.Hand); - final PlayerZone play = c.getController().getZone(Constant.Zone.Battlefield); + final PlayerZone hand = c.getOwner().getZone(ZoneType.Hand); + final PlayerZone play = c.getController().getZone(ZoneType.Battlefield); c = GameAction.changeZone(hand, play, c); @@ -340,8 +340,8 @@ public class GameAction { } AllZone.getTriggerHandler().suppressMode(TriggerType.ChangesZone); - ((PlayerZoneComesIntoPlay) AllZone.getHumanPlayer().getZone(Zone.Battlefield)).setTriggers(false); - ((PlayerZoneComesIntoPlay) AllZone.getComputerPlayer().getZone(Zone.Battlefield)).setTriggers(false); + ((PlayerZoneComesIntoPlay) AllZone.getHumanPlayer().getZone(ZoneType.Battlefield)).setTriggers(false); + ((PlayerZoneComesIntoPlay) AllZone.getComputerPlayer().getZone(ZoneType.Battlefield)).setTriggers(false); final int tiz = c.getTurnInZone(); @@ -360,8 +360,8 @@ public class GameAction { AllZone.getTriggerHandler().runTrigger(TriggerType.ChangesController, runParams); AllZone.getTriggerHandler().clearSuppression(TriggerType.ChangesZone); - ((PlayerZoneComesIntoPlay) AllZone.getHumanPlayer().getZone(Zone.Battlefield)).setTriggers(true); - ((PlayerZoneComesIntoPlay) AllZone.getComputerPlayer().getZone(Zone.Battlefield)).setTriggers(true); + ((PlayerZoneComesIntoPlay) AllZone.getHumanPlayer().getZone(ZoneType.Battlefield)).setTriggers(true); + ((PlayerZoneComesIntoPlay) AllZone.getComputerPlayer().getZone(ZoneType.Battlefield)).setTriggers(true); } /** @@ -390,12 +390,12 @@ public class GameAction { public final Card moveToGraveyard(Card c) { final PlayerZone origZone = AllZone.getZoneOf(c); final Player owner = c.getOwner(); - final PlayerZone grave = owner.getZone(Constant.Zone.Graveyard); - final PlayerZone exile = owner.getZone(Constant.Zone.Exile); - final CardList ownerBoard = owner.getCardsIn(Constant.Zone.Battlefield); - final CardList opponentsBoard = owner.getOpponent().getCardsIn(Constant.Zone.Battlefield); + 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); - if (c.getName().equals("Nissa's Chosen") && origZone.is(Constant.Zone.Battlefield)) { + if (c.getName().equals("Nissa's Chosen") && origZone.is(ZoneType.Battlefield)) { return this.moveToLibrary(c, -1); } @@ -424,8 +424,8 @@ public class GameAction { c = this.moveTo(grave, c); // Recover keyword - if (c.isCreature() && origZone.is(Constant.Zone.Battlefield)) { - for (final Card recoverable : c.getOwner().getCardsIn(Zone.Graveyard)) { + if (c.isCreature() && origZone.is(ZoneType.Battlefield)) { + for (final Card recoverable : c.getOwner().getCardsIn(ZoneType.Graveyard)) { if (recoverable.hasStartOfKeyword("Recover") && !recoverable.equals(c)) { final String recoverCost = recoverable.getKeyword().get(recoverable.getKeywordPosition("Recover")) @@ -504,7 +504,7 @@ public class GameAction { * @return a {@link forge.Card} object. */ public final Card moveToHand(final Card c) { - final PlayerZone hand = c.getOwner().getZone(Constant.Zone.Hand); + final PlayerZone hand = c.getOwner().getZone(ZoneType.Hand); return this.moveTo(hand, c); } @@ -518,7 +518,7 @@ public class GameAction { * @return a {@link forge.Card} object. */ public final Card moveToPlay(final Card c) { - final PlayerZone play = c.getOwner().getZone(Constant.Zone.Battlefield); + final PlayerZone play = c.getOwner().getZone(ZoneType.Battlefield); return this.moveTo(play, c); } @@ -535,7 +535,7 @@ public class GameAction { */ public final Card moveToPlay(final Card c, final Player p) { // move to a specific player's Battlefield - final PlayerZone play = p.getZone(Constant.Zone.Battlefield); + final PlayerZone play = p.getZone(ZoneType.Battlefield); return this.moveTo(play, c); } @@ -578,10 +578,10 @@ public class GameAction { */ public final Card moveToLibrary(Card c, int libPosition) { final PlayerZone p = AllZone.getZoneOf(c); - final PlayerZone library = c.getOwner().getZone(Constant.Zone.Library); + final PlayerZone library = c.getOwner().getZone(ZoneType.Library); if (c.hasKeyword("If CARDNAME would leave the battlefield, exile it instead of putting it anywhere else.")) { - final PlayerZone removed = c.getOwner().getZone(Constant.Zone.Exile); + final PlayerZone removed = c.getOwner().getZone(ZoneType.Exile); c.removeAllExtrinsicKeyword("If CARDNAME would leave the battlefield, " + "exile it instead of putting it anywhere else."); return this.moveTo(removed, c); @@ -601,7 +601,7 @@ public class GameAction { AllZone.getTriggerHandler().clearSuppression(TriggerType.Transformed); } - if ((p != null) && p.is(Constant.Zone.Battlefield)) { + if ((p != null) && p.is(ZoneType.Battlefield)) { c = AllZone.getCardFactory().copyCard(c); } @@ -620,7 +620,7 @@ public class GameAction { } else { runParams.put("Origin", null); } - runParams.put("Destination", Constant.Zone.Library); + runParams.put("Destination", ZoneType.Library); AllZone.getTriggerHandler().runTrigger(TriggerType.ChangesZone, runParams); Player owner = p.getPlayer(); @@ -645,7 +645,7 @@ public class GameAction { return c; } - final PlayerZone removed = c.getOwner().getZone(Constant.Zone.Exile); + final PlayerZone removed = c.getOwner().getZone(ZoneType.Exile); return Singletons.getModel().getGameAction().moveTo(removed, c); } @@ -659,7 +659,7 @@ public class GameAction { * the c * @return the card */ - public final Card moveTo(final Zone name, final Card c) { + public final Card moveTo(final ZoneType name, final Card c) { return this.moveTo(name, c, 0); } @@ -676,20 +676,20 @@ public class GameAction { * a int. * @return a {@link forge.Card} object. */ - public final Card moveTo(final Zone name, final Card c, final int libPosition) { + public final Card moveTo(final ZoneType name, final Card c, final int libPosition) { // Call specific functions to set PlayerZone, then move onto moveTo - if (name.equals(Constant.Zone.Hand)) { + if (name.equals(ZoneType.Hand)) { return this.moveToHand(c); - } else if (name.equals(Constant.Zone.Library)) { + } else if (name.equals(ZoneType.Library)) { return this.moveToLibrary(c, libPosition); - } else if (name.equals(Constant.Zone.Battlefield)) { + } else if (name.equals(ZoneType.Battlefield)) { return this.moveToPlay(c); - } else if (name.equals(Constant.Zone.Graveyard)) { + } else if (name.equals(ZoneType.Graveyard)) { return this.moveToGraveyard(c); - } else if (name.equals(Constant.Zone.Exile)) { + } else if (name.equals(ZoneType.Exile)) { return this.exile(c); - } else if (name.equals(Constant.Zone.Ante)) { - final PlayerZone ante = c.getOwner().getZone(Constant.Zone.Ante); + } else if (name.equals(ZoneType.Ante)) { + final PlayerZone ante = c.getOwner().getZone(ZoneType.Ante); return this.moveTo(ante, c); } else { return this.moveToStack(c); @@ -899,7 +899,7 @@ public class GameAction { final HashMap runParams = new HashMap(); AllZone.getTriggerHandler().runTrigger(TriggerType.Always, runParams); - final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); Card c; final Iterator it = list.iterator(); @@ -1038,7 +1038,7 @@ public class GameAction { */ private void destroyPlaneswalkers() { // get all Planeswalkers - final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield).getType("Planeswalker"); + final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield).getType("Planeswalker"); Card c; for (int i = 0; i < list.size(); i++) { @@ -1071,10 +1071,10 @@ public class GameAction { *

*/ private void destroyLegendaryCreatures() { - final CardList a = AllZoneUtil.getCardsIn(Zone.Battlefield).getType("Legendary"); + final CardList a = AllZoneUtil.getCardsIn(ZoneType.Battlefield).getType("Legendary"); while (!a.isEmpty() && !AllZoneUtil.isCardInPlay("Mirror Gallery")) { - CardList b = AllZoneUtil.getCardsIn(Zone.Battlefield, a.get(0).getName()); + CardList b = AllZoneUtil.getCardsIn(ZoneType.Battlefield, a.get(0).getName()); b = b.getType("Legendary"); b = b.filter(new CardListFilter() { @Override @@ -1258,8 +1258,8 @@ public class GameAction { @Override public void resolve() { - if (AllZone.getZoneOf(persistCard).is(Constant.Zone.Graveyard)) { - final PlayerZone ownerPlay = persistCard.getOwner().getZone(Constant.Zone.Battlefield); + if (AllZone.getZoneOf(persistCard).is(ZoneType.Graveyard)) { + final PlayerZone ownerPlay = persistCard.getOwner().getZone(ZoneType.Battlefield); final Card card = GameAction.this.moveTo(ownerPlay, persistCard); card.addCounter(Counters.M1M1, 1); } @@ -1275,8 +1275,8 @@ public class GameAction { @Override public void resolve() { - if (AllZone.getZoneOf(undyingCard).is(Constant.Zone.Graveyard)) { - final PlayerZone ownerPlay = undyingCard.getOwner().getZone(Constant.Zone.Battlefield); + if (AllZone.getZoneOf(undyingCard).is(ZoneType.Graveyard)) { + final PlayerZone ownerPlay = undyingCard.getOwner().getZone(ZoneType.Battlefield); final Card card = GameAction.this.moveTo(ownerPlay, undyingCard); card.addCounter(Counters.P1P1, 1); } @@ -1368,7 +1368,7 @@ public class GameAction { flashback.setFlashBackAbility(true); SpellAbilityRestriction sar = new SpellAbilityRestriction(); sar.setVariables(sa.getRestrictions()); - sar.setZone(Constant.Zone.Graveyard); + sar.setZone(ZoneType.Graveyard); flashback.setRestrictions(sar); // there is a flashback cost (and not the cards cost) @@ -1457,7 +1457,7 @@ public class GameAction { final PlayerZone zone = AllZone.getZoneOf(c); if (c.isLand() && human.canPlayLand()) { - if (zone.is(Zone.Hand) || ((!zone.is(Zone.Battlefield)) && c.hasStartOfKeyword("May be played"))) { + if (zone.is(ZoneType.Hand) || ((!zone.is(ZoneType.Battlefield)) && c.hasStartOfKeyword("May be played"))) { choices.add("Play land"); } } @@ -1621,16 +1621,16 @@ public class GameAction { if (originalCard.getName().equals("Avatar of Woe")) { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); final Player opponent = player.getOpponent(); - CardList playerCreatureList = player.getCardsIn(Zone.Graveyard); + CardList playerCreatureList = player.getCardsIn(ZoneType.Graveyard); playerCreatureList = playerCreatureList.getType("Creature"); - CardList opponentCreatureList = opponent.getCardsIn(Zone.Graveyard); + CardList opponentCreatureList = opponent.getCardsIn(ZoneType.Graveyard); opponentCreatureList = opponentCreatureList.getType("Creature"); if ((playerCreatureList.size() + opponentCreatureList.size()) >= 10) { manaCost = new ManaCost("B B"); } // Avatar of Woe } else if (originalCard.getName().equals("Avatar of Will")) { final Player opponent = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn().getOpponent(); - final CardList opponentHandList = opponent.getCardsIn(Zone.Hand); + final CardList opponentHandList = opponent.getCardsIn(ZoneType.Hand); if (opponentHandList.size() == 0) { manaCost = new ManaCost("U U"); } // Avatar of Will @@ -1649,7 +1649,7 @@ public class GameAction { manaCost = new ManaCost("G G"); } // Avatar of Might } else if (spell.getIsDelve()) { - final int cardsInGrave = originalCard.getController().getCardsIn(Zone.Graveyard).size(); + final int cardsInGrave = originalCard.getController().getCardsIn(ZoneType.Graveyard).size(); final ArrayList choiceList = new ArrayList(); for (int i = 0; i <= cardsInGrave; i++) { choiceList.add(i); @@ -1660,7 +1660,7 @@ public class GameAction { final int chosenAmount = (Integer) GuiUtils .chooseOne("Exile how many cards?", choiceList.toArray()); System.out.println("Delve for " + chosenAmount); - final CardList choices = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard); + final CardList choices = AllZone.getHumanPlayer().getCardsIn(ZoneType.Graveyard); final CardList chosen = new CardList(); for (int i = 0; i < chosenAmount; i++) { final Card nowChosen = GuiUtils.chooseOneOrNone("Exile which card?", choices.toArray()); @@ -1693,7 +1693,7 @@ public class GameAction { } for (int i = 0; i < numToExile; i++) { - final CardList grave = new CardList(AllZone.getComputerPlayer().getZone(Zone.Graveyard) + final CardList grave = new CardList(AllZone.getComputerPlayer().getZone(ZoneType.Graveyard) .getCards()); Card chosen = null; for (final Card c : grave) { // Exile noncreatures first @@ -1722,7 +1722,7 @@ public class GameAction { manaCost.decreaseColorlessMana(numToExile); } } else if (spell.getSourceCard().hasKeyword("Convoke")) { - CardList untappedCreats = spell.getActivatingPlayer().getCardsIn(Zone.Battlefield).getType("Creature"); + CardList untappedCreats = spell.getActivatingPlayer().getCardsIn(ZoneType.Battlefield).getType("Creature"); untappedCreats = untappedCreats.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -1816,7 +1816,7 @@ public class GameAction { } // isSpell // Get Cost Reduction - CardList cardsInPlay = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList cardsInPlay = AllZoneUtil.getCardsIn(ZoneType.Battlefield); cardsInPlay = cardsInPlay.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -1827,8 +1827,8 @@ public class GameAction { } }); cardsInPlay.add(originalCard); - final CardList playerPlay = controller.getCardsIn(Zone.Battlefield); - final CardList playerHand = controller.getCardsIn(Zone.Hand); + final CardList playerPlay = controller.getCardsIn(ZoneType.Battlefield); + final CardList playerHand = controller.getCardsIn(ZoneType.Hand); int xBonus = 0; final int max = 25; if (sa.isMultiKicker()) { @@ -1950,7 +1950,7 @@ public class GameAction { final String spilt = k[7]; final String[] colorSpilt = spilt.split("/"); k[7] = colorSpilt[1]; - CardList playerList = controller.getCardsIn(Zone.Battlefield); + CardList playerList = controller.getCardsIn(ZoneType.Battlefield); playerList = playerList.getType(k[7]); k[3] = String.valueOf(playerList.size()); } @@ -2138,7 +2138,7 @@ public class GameAction { final String spilt = k[7]; final String[] colorSpilt = spilt.split("/"); k[7] = colorSpilt[1]; - CardList playerList = controller.getCardsIn(Zone.Battlefield); + CardList playerList = controller.getCardsIn(ZoneType.Battlefield); playerList = playerList.getType(k[7]); k[3] = String.valueOf(playerList.size()); } diff --git a/src/main/java/forge/GameActionUtil.java b/src/main/java/forge/GameActionUtil.java index d0cde5d8568..522308bf5b3 100644 --- a/src/main/java/forge/GameActionUtil.java +++ b/src/main/java/forge/GameActionUtil.java @@ -22,7 +22,6 @@ import java.util.HashMap; import javax.swing.JOptionPane; -import forge.Constant.Zone; import forge.card.abilityfactory.AbilityFactory; import forge.card.cardfactory.CardFactoryUtil; import forge.card.spellability.Ability; @@ -34,7 +33,8 @@ import forge.control.input.InputPayManaCostUtil; import forge.game.GameLossReason; import forge.game.player.ComputerUtil; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.util.MyRandom; @@ -88,8 +88,8 @@ public final class GameActionUtil { if (!c.isCopiedSpell()) { final CardList humanNexus = AllZone.getHumanPlayer() - .getCardsIn(Zone.Battlefield, "Maelstrom Nexus"); - final CardList computerNexus = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield, + .getCardsIn(ZoneType.Battlefield, "Maelstrom Nexus"); + final CardList computerNexus = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield, "Maelstrom Nexus"); final CardList maelstromNexii = new CardList(); @@ -117,7 +117,7 @@ public final class GameActionUtil { final Ability ability = new Ability(c, "0") { @Override public void resolve() { - final CardList topOfLibrary = controller.getCardsIn(Zone.Library); + final CardList topOfLibrary = controller.getCardsIn(ZoneType.Library); final CardList revealed = new CardList(); if (topOfLibrary.size() == 0) { @@ -212,9 +212,9 @@ public final class GameActionUtil { @Override public void execute() { - final CardList humanThrummingStone = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield, + final CardList humanThrummingStone = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield, "Thrumming Stone"); - final CardList computerThrummingStone = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield, + final CardList computerThrummingStone = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield, "Thrumming Stone"); for (int i = 0; i < humanThrummingStone.size(); i++) { @@ -248,7 +248,7 @@ public final class GameActionUtil { final Ability ability = new Ability(c, "0") { @Override public void resolve() { - final CardList topOfLibrary = controller.getCardsIn(Zone.Library); + final CardList topOfLibrary = controller.getCardsIn(ZoneType.Library); final CardList revealed = new CardList(); int rippleNumber = rippleCount; if (topOfLibrary.size() == 0) { @@ -722,7 +722,7 @@ public final class GameActionUtil { return; } - final CardList playerPerms = player.getCardsIn(Zone.Battlefield); + final CardList playerPerms = player.getCardsIn(ZoneType.Battlefield); if (AllZoneUtil.isCardInPlay("Lich", player)) { final CardList lichs = playerPerms.getName("Lich"); @@ -732,7 +732,7 @@ public final class GameActionUtil { @Override public void resolve() { for (int i = 0; i < damage; i++) { - CardList nonTokens = player.getCardsIn(Zone.Battlefield); + CardList nonTokens = player.getCardsIn(ZoneType.Battlefield); nonTokens = nonTokens.filter(CardListFilter.NON_TOKEN); if (nonTokens.size() == 0) { player.loseConditionMet(GameLossReason.SpellEffect, lich.getName()); @@ -785,7 +785,7 @@ public final class GameActionUtil { } if (c.isCreature() && AllZoneUtil.isCardInPlay("Contested War Zone", player)) { - final CardList zones = player.getCardsIn(Zone.Battlefield, "Contested War Zone"); + final CardList zones = player.getCardsIn(ZoneType.Battlefield, "Contested War Zone"); for (final Card zone : zones) { final Ability ability = new Ability(zone, "0") { @Override @@ -996,7 +996,7 @@ public final class GameActionUtil { @Override public void resolve() { - final CardList libList = opponent.getCardsIn(Zone.Library); + final CardList libList = opponent.getCardsIn(ZoneType.Library); int count = 0; int broken = 0; for (int i = 0; i < libList.size(); i = i + 4) { @@ -1108,26 +1108,26 @@ public final class GameActionUtil { public static boolean specialConditionsMet(final Card sourceCard, final String specialConditions) { if (specialConditions.contains("CardsInHandMore")) { - final CardList specialConditionsCardList = sourceCard.getController().getCardsIn(Zone.Hand); + final CardList specialConditionsCardList = sourceCard.getController().getCardsIn(ZoneType.Hand); final String condition = specialConditions.split("/")[1]; if (specialConditionsCardList.size() < Integer.valueOf(condition)) { return false; } } if (specialConditions.contains("OppHandEmpty")) { - final CardList oppHand = sourceCard.getController().getOpponent().getCardsIn(Zone.Hand); + final CardList oppHand = sourceCard.getController().getOpponent().getCardsIn(ZoneType.Hand); if (!(oppHand.size() == 0)) { return false; } } if (specialConditions.contains("TopCardOfLibraryIsBlack")) { - final PlayerZone lib = sourceCard.getController().getZone(Constant.Zone.Library); + final PlayerZone lib = sourceCard.getController().getZone(ZoneType.Library); if (!(lib.get(0).isBlack())) { return false; } } if (specialConditions.contains("LibraryLE")) { - final CardList library = sourceCard.getController().getCardsIn(Zone.Library); + final CardList library = sourceCard.getController().getCardsIn(ZoneType.Library); final String maxnumber = specialConditions.split("/")[1]; if (library.size() > Integer.valueOf(maxnumber)) { return false; @@ -1141,7 +1141,7 @@ public final class GameActionUtil { } } if (specialConditions.contains("OppCreatureInPlayGE")) { - CardList oppInPlay = sourceCard.getController().getOpponent().getCardsIn(Zone.Battlefield); + CardList oppInPlay = sourceCard.getController().getOpponent().getCardsIn(ZoneType.Battlefield); oppInPlay = oppInPlay.getType("Creature"); final String maxnumber = specialConditions.split("/")[1]; if (!(oppInPlay.size() >= Integer.valueOf(maxnumber))) { @@ -1149,7 +1149,7 @@ public final class GameActionUtil { } } if (specialConditions.contains("LandYouCtrlLE")) { - CardList landInPlay = sourceCard.getController().getCardsIn(Zone.Battlefield); + CardList landInPlay = sourceCard.getController().getCardsIn(ZoneType.Battlefield); landInPlay = landInPlay.getType("Land"); final String maxnumber = specialConditions.split("/")[1]; if (!(landInPlay.size() <= Integer.valueOf(maxnumber))) { @@ -1157,7 +1157,7 @@ public final class GameActionUtil { } } if (specialConditions.contains("LandOppCtrlLE")) { - CardList oppLandInPlay = sourceCard.getController().getOpponent().getCardsIn(Zone.Battlefield); + CardList oppLandInPlay = sourceCard.getController().getOpponent().getCardsIn(ZoneType.Battlefield); oppLandInPlay = oppLandInPlay.getType("Land"); final String maxnumber = specialConditions.split("/")[1]; if (!(oppLandInPlay.size() <= Integer.valueOf(maxnumber))) { @@ -1165,18 +1165,18 @@ public final class GameActionUtil { } } if (specialConditions.contains("OppCtrlMoreCreatures")) { - CardList creaturesInPlayYou = sourceCard.getController().getCardsIn(Zone.Battlefield); + CardList creaturesInPlayYou = sourceCard.getController().getCardsIn(ZoneType.Battlefield); creaturesInPlayYou = creaturesInPlayYou.getType("Creature"); - CardList creaturesInPlayOpp = sourceCard.getController().getOpponent().getCardsIn(Zone.Battlefield); + CardList creaturesInPlayOpp = sourceCard.getController().getOpponent().getCardsIn(ZoneType.Battlefield); creaturesInPlayOpp = creaturesInPlayOpp.getType("Creature"); if (creaturesInPlayYou.size() > creaturesInPlayOpp.size()) { return false; } } if (specialConditions.contains("OppCtrlMoreLands")) { - CardList landsInPlayYou = sourceCard.getController().getCardsIn(Zone.Battlefield); + CardList landsInPlayYou = sourceCard.getController().getCardsIn(ZoneType.Battlefield); landsInPlayYou = landsInPlayYou.getType("Land"); - CardList landsInPlayOpp = sourceCard.getController().getOpponent().getCardsIn(Zone.Battlefield); + CardList landsInPlayOpp = sourceCard.getController().getOpponent().getCardsIn(ZoneType.Battlefield); landsInPlayOpp = landsInPlayOpp.getType("Land"); if (landsInPlayYou.size() > landsInPlayOpp.size()) { return false; @@ -1184,7 +1184,7 @@ public final class GameActionUtil { } if (specialConditions.contains("EnchantedControllerCreaturesGE")) { CardList enchantedControllerInPlay = sourceCard.getEnchantingCard().getController() - .getCardsIn(Zone.Battlefield); + .getCardsIn(ZoneType.Battlefield); enchantedControllerInPlay = enchantedControllerInPlay.getType("Creature"); final String maxnumber = specialConditions.split("/")[1]; if (!(enchantedControllerInPlay.size() >= Integer.valueOf(maxnumber))) { @@ -1209,20 +1209,20 @@ public final class GameActionUtil { } } if (specialConditions.contains("Hellbent")) { - final CardList handcards = sourceCard.getController().getCardsIn(Zone.Hand); + final CardList handcards = sourceCard.getController().getCardsIn(ZoneType.Hand); if (handcards.size() > 0) { return false; } } if (specialConditions.contains("Metalcraft")) { - CardList cardsinPlay = sourceCard.getController().getCardsIn(Zone.Battlefield); + CardList cardsinPlay = sourceCard.getController().getCardsIn(ZoneType.Battlefield); cardsinPlay = cardsinPlay.getType("Artifact"); if (cardsinPlay.size() < 3) { return false; } } if (specialConditions.contains("Morbid")) { - final CardList res = CardUtil.getThisTurnEntered(Zone.Graveyard, Zone.Battlefield, "Creature", sourceCard); + final CardList res = CardUtil.getThisTurnEntered(ZoneType.Graveyard, ZoneType.Battlefield, "Creature", sourceCard); if (res.size() < 1) { return false; } @@ -1231,7 +1231,7 @@ public final class GameActionUtil { if (specialConditions.contains("isPresent")) { final String requirements = specialConditions.replaceAll("isPresent ", ""); - CardList cardsinPlay = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList cardsinPlay = AllZoneUtil.getCardsIn(ZoneType.Battlefield); final String[] conditions = requirements.split(","); cardsinPlay = cardsinPlay.getValidCards(conditions, sourceCard.getController(), sourceCard); if (cardsinPlay.isEmpty()) { @@ -1241,7 +1241,7 @@ public final class GameActionUtil { //is a card of a certain type/color present in yard if (specialConditions.contains("isInGraveyard")) { final String requirements = specialConditions.replaceAll("isInGraveyard ", ""); - CardList cardsinYards = AllZoneUtil.getCardsIn(Zone.Graveyard); + CardList cardsinYards = AllZoneUtil.getCardsIn(ZoneType.Graveyard); final String[] conditions = requirements.split(","); cardsinYards = cardsinYards.getValidCards(conditions, sourceCard.getController(), sourceCard); if (cardsinYards.isEmpty()) { @@ -1251,7 +1251,7 @@ public final class GameActionUtil { //is no card of a certain type/color present? if (specialConditions.contains("isNotPresent")) { final String requirements = specialConditions.replaceAll("isNotPresent ", ""); - CardList cardsInPlay = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList cardsInPlay = AllZoneUtil.getCardsIn(ZoneType.Battlefield); final String[] conditions = requirements.split(","); cardsInPlay = cardsInPlay.getValidCards(conditions, sourceCard.getController(), sourceCard); if (!cardsInPlay.isEmpty()) { @@ -1412,15 +1412,15 @@ public final class GameActionUtil { } // add +1/+1 to cards list.clear(); - final int num = AllZoneUtil.getCardsIn(Zone.Battlefield, "Coat of Arms").size(); + final int num = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Coat of Arms").size(); // for each zone found add +1/+1 to each card for (int j = 0; j < num; j++) { - final CardList creature = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList creature = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (int i = 0; i < creature.size(); i++) { final Card crd = creature.get(i); - CardList type = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList type = AllZoneUtil.getCardsIn(ZoneType.Battlefield); type = type.filter(new CardListFilter() { @Override public boolean addCard(final Card card) { @@ -1458,12 +1458,12 @@ public final class GameActionUtil { @Override public void execute() { - final CardList alphaStatuses = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield) + final CardList alphaStatuses = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield) .getName("Alpha Status"); - alphaStatuses.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield).getName("Alpha Status")); + alphaStatuses.addAll(AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield).getName("Alpha Status")); - final CardList allCreatures = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield).getType("Creature"); - allCreatures.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield).getType("Creature")); + final CardList allCreatures = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield).getType("Creature"); + allCreatures.addAll(AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield).getType("Creature")); for (int i = 0; i < this.previouslyPumped.size(); i++) { this.previouslyPumped.get(i).addSemiPermanentAttackBoost(0 - this.previouslyPumpedValue.get(i)); @@ -1498,10 +1498,10 @@ public final class GameActionUtil { @Override public void execute() { // get all creatures - final CardList cards = AllZoneUtil.getCardsIn(Zone.Battlefield, "Umbra Stalker"); + final CardList cards = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Umbra Stalker"); for (final Card c : cards) { final Player player = c.getController(); - final CardList grave = player.getCardsIn(Zone.Graveyard); + final CardList grave = player.getCardsIn(ZoneType.Graveyard); final int pt = CardFactoryUtil.getNumberOfManaSymbolsByColor("B", grave); c.setBaseAttack(pt); c.setBaseDefense(pt); @@ -1515,7 +1515,7 @@ public final class GameActionUtil { @Override public void execute() { - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = list.filter(new CardListFilter() { @Override @@ -1538,7 +1538,7 @@ public final class GameActionUtil { @Override public void execute() { - final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield, "Old Man of the Sea"); + final CardList 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()) { @@ -1559,7 +1559,7 @@ public final class GameActionUtil { @Override public void execute() { - final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield, "Liu Bei, Lord of Shu"); + final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Liu Bei, Lord of Shu"); if (list.size() > 0) { for (int i = 0; i < list.size(); i++) { @@ -1578,7 +1578,7 @@ public final class GameActionUtil { } // execute() private boolean getsBonus(final Card c) { - CardList list = c.getController().getCardsIn(Zone.Battlefield); + CardList list = c.getController().getCardsIn(ZoneType.Battlefield); list = list.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -1598,7 +1598,7 @@ public final class GameActionUtil { @Override public void execute() { - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = list.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -1616,7 +1616,7 @@ public final class GameActionUtil { } private int countSoundTheCalls() { - CardList list = AllZoneUtil.getCardsIn(Zone.Graveyard); + CardList list = AllZoneUtil.getCardsIn(ZoneType.Graveyard); list = list.getName("Sound the Call"); return list.size(); } @@ -1630,7 +1630,7 @@ public final class GameActionUtil { @Override public void execute() { // get all creatures - final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield, "Tarmogoyf"); + final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Tarmogoyf"); for (int i = 0; i < list.size(); i++) { final Card c = list.get(i); @@ -1641,7 +1641,7 @@ public final class GameActionUtil { } // execute() private int countDiffTypes() { - final CardList list = AllZoneUtil.getCardsIn(Zone.Graveyard); + final CardList list = AllZoneUtil.getCardsIn(ZoneType.Graveyard); int count = 0; for (int q = 0; q < list.size(); q++) { diff --git a/src/main/java/forge/NameChanger.java b/src/main/java/forge/NameChanger.java index fb7df2318af..2863b01909a 100644 --- a/src/main/java/forge/NameChanger.java +++ b/src/main/java/forge/NameChanger.java @@ -24,7 +24,7 @@ import java.util.Map.Entry; import java.util.StringTokenizer; import java.util.TreeMap; -import net.slightlymagic.braids.util.generator.GeneratorFunctions; +import net.slightlymagic.braids.GeneratorFunctions; import com.google.code.jyield.Generator; import com.google.code.jyield.YieldUtils; diff --git a/src/main/java/forge/StaticEffects.java b/src/main/java/forge/StaticEffects.java index 702d552de66..651d2979112 100644 --- a/src/main/java/forge/StaticEffects.java +++ b/src/main/java/forge/StaticEffects.java @@ -23,12 +23,12 @@ import java.util.HashMap; import com.esotericsoftware.minlog.Log; -import forge.Constant.Zone; import forge.card.cardfactory.CardFactoryUtil; import forge.card.replacement.ReplacementEffect; import forge.card.spellability.SpellAbility; import forge.card.staticability.StaticAbility; import forge.game.player.Player; +import forge.game.zone.ZoneType; /** *

@@ -318,7 +318,7 @@ public class StaticEffects { public final void rePopulateStateBasedList() { this.reset(); - final CardList cards = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList 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/abilityfactory/AbilityFactory.java b/src/main/java/forge/card/abilityfactory/AbilityFactory.java index 238e57e8f41..4700a75c881 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactory.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactory.java @@ -26,8 +26,6 @@ import forge.Card; import forge.CardList; import forge.CardUtil; import forge.Command; -import forge.Constant; -import forge.Constant.Zone; import forge.GameActionUtil; import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; @@ -43,6 +41,7 @@ import forge.card.spellability.Target; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; /** *

@@ -386,7 +385,7 @@ public class AbilityFactory { // something // not in play, this Key // should be set - this.abTgt.setZone(Zone.listValueOf(this.mapParams.get("TgtZone"))); + this.abTgt.setZone(ZoneType.listValueOf(this.mapParams.get("TgtZone"))); } // Target Type mostly for Counter: Spell,Activated,Triggered,Ability @@ -571,7 +570,7 @@ public class AbilityFactory { if (this.isTargeted) { // Since all "CopySpell" ABs copy things on // the // Stack no need for it to be everywhere - this.abTgt.setZone(Zone.Stack); + this.abTgt.setZone(ZoneType.Stack); } if (this.isAb) { @@ -591,7 +590,7 @@ public class AbilityFactory { // Since all "Counter" ABs Counter things on the Stack no need for // it to be everywhere if (this.isTargeted) { - this.abTgt.setZone(Zone.Stack); + this.abTgt.setZone(ZoneType.Stack); } if (this.isAb) { @@ -1746,7 +1745,7 @@ public class AbilityFactory { } else if (defined.equals("TopOfLibrary")) { - final CardList lib = hostCard.getController().getCardsIn(Constant.Zone.Library); + final CardList lib = hostCard.getController().getCardsIn(ZoneType.Library); if (lib.size() > 0) { c = lib.get(0); } else { @@ -1807,12 +1806,12 @@ public class AbilityFactory { } } else if (defined.startsWith("ThisTurnEntered")) { final String[] workingCopy = defined.split("_"); - Zone destination, origin; + ZoneType destination, origin; String validFilter; - destination = Zone.smartValueOf(workingCopy[1]); + destination = ZoneType.smartValueOf(workingCopy[1]); if (workingCopy[2].equals("from")) { - origin = Zone.smartValueOf(workingCopy[3]); + origin = ZoneType.smartValueOf(workingCopy[3]); validFilter = workingCopy[4]; } else { origin = null; @@ -2127,7 +2126,7 @@ public class AbilityFactory { sas.add(spell); } } //is it exiled? - if (!sas.get(0).getSourceCard().isInZone(Constant.Zone.Exile)) { + if (!sas.get(0).getSourceCard().isInZone(ZoneType.Exile)) { sas.clear(); } } diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryAnimate.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryAnimate.java index 4a4f416fbfe..48d79207052 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryAnimate.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryAnimate.java @@ -29,7 +29,6 @@ import forge.Card; import forge.CardList; import forge.CardUtil; import forge.Command; -import forge.Constant.Zone; import forge.Singletons; import forge.card.replacement.ReplacementEffect; import forge.card.spellability.AbilityActivated; @@ -43,6 +42,7 @@ import forge.card.trigger.TriggerHandler; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; /** *

@@ -1210,9 +1210,9 @@ public final class AbilityFactoryAnimate { } if ((tgtPlayers == null) || tgtPlayers.isEmpty()) { - list = AllZoneUtil.getCardsIn(Zone.Battlefield); + list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); } else { - list = tgtPlayers.get(0).getCardsIn(Zone.Battlefield); + list = tgtPlayers.get(0).getCardsIn(ZoneType.Battlefield); } list = list.getValidCards(valid.split(","), host.getController(), host); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java index 2855ef63061..b597642b8f0 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryAttach.java @@ -30,7 +30,6 @@ import forge.CardList; import forge.CardListFilter; import forge.CardUtil; import forge.Command; -import forge.Constant.Zone; import forge.GameActionUtil; import forge.GameEntity; import forge.Singletons; @@ -47,6 +46,7 @@ import forge.game.phase.CombatUtil; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.util.MyRandom; @@ -324,7 +324,7 @@ public class AbilityFactoryAttach { // I believe this is the only case where mandatory will be true, so just // check that when starting that work // But we shouldn't attach to things with Protection - if (tgt.getZone().contains(Zone.Battlefield) && !mandatory) { + if (tgt.getZone().contains(ZoneType.Battlefield) && !mandatory) { list = list.getTargetableCards(sa); } else { list = list.getUnprotectedCards(attachSource); @@ -1486,7 +1486,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(Zone.Battlefield); + CardList unattachList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); unattachList = unattachList.getValidCards(valid.split(","), source.getController(), source); for (final Card c : unattachList) { AbilityFactoryAttach.handleUnattachment(o, c, af); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java index 98d72cbfc56..b1d798c838d 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryChangeZone.java @@ -30,8 +30,6 @@ import forge.CardList; import forge.CardListFilter; import forge.CardListUtil; import forge.CardUtil; -import forge.Constant; -import forge.Constant.Zone; import forge.GameActionUtil; import forge.GameEntity; import forge.Singletons; @@ -49,7 +47,8 @@ import forge.game.phase.CombatUtil; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.util.MyRandom; @@ -198,7 +197,7 @@ public final class AbilityFactoryChangeZone { * @return a boolean. */ public static boolean isHidden(final String origin, final boolean hiddenOverride) { - return hiddenOverride || Zone.smartValueOf(origin).isHidden(); + return hiddenOverride || ZoneType.smartValueOf(origin).isHidden(); } @@ -212,7 +211,7 @@ public final class AbilityFactoryChangeZone { * @return a boolean. */ public static boolean isKnown(final String origin) { - return Zone.smartValueOf(origin).isKnown(); + return ZoneType.smartValueOf(origin).isKnown(); } /** @@ -227,9 +226,9 @@ public final class AbilityFactoryChangeZone { */ private static void setMiscellaneous(final AbilityFactory af, final SpellAbility sa) { final HashMap params = af.getMapParams(); - List origin = new ArrayList(); + List origin = new ArrayList(); if (params.containsKey("Origin")) { - origin = Constant.Zone.listValueOf(params.get("Origin")); + origin = ZoneType.listValueOf(params.get("Origin")); } final Target tgt = sa.getTarget(); @@ -240,7 +239,7 @@ public final class AbilityFactoryChangeZone { } if (!(sa instanceof AbilitySub)) { - if (origin.contains(Zone.Battlefield) || params.get("Destination").equals("Battlefield")) { + if (origin.contains(ZoneType.Battlefield) || params.get("Destination").equals("Battlefield")) { af.getHostCard().setSVar("PlayMain1", "TRUE"); } } @@ -430,9 +429,9 @@ public final class AbilityFactoryChangeZone { final Cost abCost = af.getAbCost(); final Card source = af.getHostCard(); final HashMap params = af.getMapParams(); - Constant.Zone origin = null; + ZoneType origin = null; if (params.containsKey("Origin")) { - origin = Constant.Zone.smartValueOf(params.get("Origin")); + origin = ZoneType.smartValueOf(params.get("Origin")); } final String destination = params.get("Destination"); @@ -562,9 +561,9 @@ public final class AbilityFactoryChangeZone { final HashMap params = af.getMapParams(); - List origin = new ArrayList(); + List origin = new ArrayList(); if (params.containsKey("Origin")) { - origin = Zone.listValueOf(params.get("Origin")); + origin = ZoneType.listValueOf(params.get("Origin")); } // this works for hidden because the mana is paid first. @@ -816,18 +815,18 @@ public final class AbilityFactoryChangeZone { } } - List origin = new ArrayList(); + List origin = new ArrayList(); if (params.containsKey("Origin")) { - origin = Zone.listValueOf(params.get("Origin")); + origin = ZoneType.listValueOf(params.get("Origin")); } - Zone destination = Zone.smartValueOf(params.get("Destination")); + ZoneType destination = ZoneType.smartValueOf(params.get("Destination")); // this needs to be zero indexed. Top = 0, Third = 2 int libraryPos = params.containsKey("LibraryPosition") ? Integer.parseInt(params.get("LibraryPosition")) : 0; if (params.containsKey("OriginChoice")) { // Currently only used for Mishra, but may be used by other things // Improve how this message reacts for other cards - final List alt = Zone.listValueOf(params.get("OriginAlternative")); + final List alt = ZoneType.listValueOf(params.get("OriginAlternative")); CardList altFetchList = player.getCardsIn(alt); altFetchList = AbilityFactory.filterListByType(altFetchList, params.get("ChangeType"), sa); @@ -846,7 +845,7 @@ public final class AbilityFactoryChangeZone { sb.append(params.get("AlternativeDestinationMessage")); if (!GameActionUtil.showYesNoDialog(card, sb.toString())) { - destination = Zone.smartValueOf(params.get("DestinationAlternative")); + destination = ZoneType.smartValueOf(params.get("DestinationAlternative")); libraryPos = params.containsKey("LibraryPositionAlternative") ? Integer.parseInt(params .get("LibraryPositionAlternative")) : 0; } @@ -861,26 +860,26 @@ public final class AbilityFactoryChangeZone { if (!params.containsKey("ChangeNum")) { changeNum = fetchList.size(); } - } else if (!origin.contains(Zone.Library) && !origin.contains(Zone.Hand)) { + } else if (!origin.contains(ZoneType.Library) && !origin.contains(ZoneType.Hand)) { fetchList = AllZoneUtil.getCardsIn(origin); } else { fetchList = player.getCardsIn(origin); } if (!defined) { - if (origin.contains(Zone.Library) && !defined) { // Look at whole + if (origin.contains(ZoneType.Library) && !defined) { // Look at whole // library before // moving onto // choosing // a card{ GuiUtils.chooseOneOrNone(af.getHostCard().getName() + " - Looking at Library", - player.getCardsIn(Zone.Library).toArray()); + player.getCardsIn(ZoneType.Library).toArray()); } // Look at opponents hand before moving onto choosing a card - if (origin.contains(Zone.Hand) && player.isComputer()) { + if (origin.contains(ZoneType.Hand) && player.isComputer()) { GuiUtils.chooseOneOrNone(af.getHostCard().getName() + " - Looking at Opponent's Hand", player - .getCardsIn(Zone.Hand).toArray()); + .getCardsIn(ZoneType.Hand).toArray()); } fetchList = AbilityFactory.filterListByType(fetchList, params.get("ChangeType"), sa); } @@ -915,17 +914,17 @@ public final class AbilityFactoryChangeZone { fetchList.remove(c); Card movedCard = null; - if (destination.equals(Zone.Library)) { + if (destination.equals(ZoneType.Library)) { // do not shuffle the library once we have placed a fetched // card on top. if (params.containsKey("Reveal")) { GuiUtils.chooseOne(card + " - Revealed card: ", c); } - if (origin.contains(Zone.Library) && (i < 1)) { + if (origin.contains(ZoneType.Library) && (i < 1)) { player.shuffle(); } movedCard = Singletons.getModel().getGameAction().moveToLibrary(c, libraryPos); - } else if (destination.equals(Zone.Battlefield)) { + } else if (destination.equals(ZoneType.Battlefield)) { if (params.containsKey("Tapped")) { c.setTapped(true); } @@ -956,7 +955,7 @@ public final class AbilityFactoryChangeZone { } movedCard = Singletons.getModel().getGameAction().moveTo(c.getController().getZone(destination), c); - } else if (destination.equals(Zone.Exile)) { + } else if (destination.equals(ZoneType.Exile)) { movedCard = Singletons.getModel().getGameAction().exile(c); if (params.containsKey("ExileFaceDown")) { movedCard.setState(CardCharactersticName.FaceDown); @@ -984,7 +983,7 @@ public final class AbilityFactoryChangeZone { } } - if ((origin.contains(Zone.Library) && !destination.equals(Zone.Library) && !defined) + if ((origin.contains(ZoneType.Library) && !destination.equals(ZoneType.Library) && !defined) || params.containsKey("Shuffle")) { player.shuffle(); } @@ -1017,9 +1016,9 @@ public final class AbilityFactoryChangeZone { } } - List origin = new ArrayList(); + List origin = new ArrayList(); if (params.containsKey("Origin")) { - origin = Zone.listValueOf(params.get("Origin")); + origin = ZoneType.listValueOf(params.get("Origin")); } String type = params.get("ChangeType"); @@ -1036,7 +1035,7 @@ public final class AbilityFactoryChangeZone { if (!params.containsKey("ChangeNum")) { changeNum = fetchList.size(); } - } else if (!origin.contains(Zone.Library) && !origin.contains(Zone.Hand)) { + } else if (!origin.contains(ZoneType.Library) && !origin.contains(ZoneType.Hand)) { fetchList = AllZoneUtil.getCardsIn(origin); fetchList = AbilityFactory.filterListByType(fetchList, type, sa); } else { @@ -1044,7 +1043,7 @@ public final class AbilityFactoryChangeZone { fetchList = AbilityFactory.filterListByType(fetchList, type, sa); } - final Zone destination = Zone.smartValueOf(params.get("Destination")); + final ZoneType destination = ZoneType.smartValueOf(params.get("Destination")); final PlayerZone destZone = player.getZone(destination); @@ -1077,9 +1076,9 @@ public final class AbilityFactoryChangeZone { // creatures // take the // best - } else if (Zone.Battlefield.equals(destination) || Zone.Graveyard.equals(destination)) { + } else if (ZoneType.Battlefield.equals(destination) || ZoneType.Graveyard.equals(destination)) { c = CardFactoryUtil.getMostExpensivePermanentAI(fetchList, sa, false); - } else if (Zone.Exile.equals(destination)) { + } else if (ZoneType.Exile.equals(destination)) { // Exiling your own stuff, if Exiling opponents stuff choose // best if (destZone.getPlayer().isHuman()) { @@ -1089,7 +1088,7 @@ public final class AbilityFactoryChangeZone { } } else { // Don't fetch another tutor with the same name - if (origin.contains(Zone.Library) && !fetchList.getNotName(card.getName()).isEmpty()) { + if (origin.contains(ZoneType.Library) && !fetchList.getNotName(card.getName()).isEmpty()) { fetchList = fetchList.getNotName(card.getName()); } @@ -1101,17 +1100,17 @@ public final class AbilityFactoryChangeZone { fetchList.remove(c); } - if (origin.contains(Zone.Library) && !defined) { + if (origin.contains(ZoneType.Library) && !defined) { player.shuffle(); } for (final Card c : fetched) { Card newCard = null; - if (Zone.Library.equals(destination)) { + if (ZoneType.Library.equals(destination)) { final int libraryPos = params.containsKey("LibraryPosition") ? Integer.parseInt(params .get("LibraryPosition")) : 0; Singletons.getModel().getGameAction().moveToLibrary(c, libraryPos); - } else if (Zone.Battlefield.equals(destination)) { + } else if (ZoneType.Battlefield.equals(destination)) { if (params.containsKey("Tapped")) { c.tap(); } @@ -1148,7 +1147,7 @@ public final class AbilityFactoryChangeZone { } newCard = Singletons.getModel().getGameAction().moveTo(c.getController().getZone(destination), c); - } else if (destination.equals(Zone.Exile)) { + } else if (destination.equals(ZoneType.Exile)) { newCard = Singletons.getModel().getGameAction().exile(c); if (params.containsKey("ExileFaceDown")) { newCard.setState(CardCharactersticName.FaceDown); @@ -1166,7 +1165,7 @@ public final class AbilityFactoryChangeZone { } } - if (!Zone.Battlefield.equals(destination) && !"Card".equals(type) && !defined) { + if (!ZoneType.Battlefield.equals(destination) && !"Card".equals(type) && !defined) { final String picked = af.getHostCard().getName() + " - Computer picked:"; if (fetched.size() > 0) { GuiUtils.chooseOne(picked, fetched.toArray()); @@ -1207,8 +1206,8 @@ public final class AbilityFactoryChangeZone { // basic // land // types - final CardList combined = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); - combined.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Hand)); + final CardList combined = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); + combined.addAll(AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand)); final String[] names = type.split(","); final ArrayList basics = new ArrayList(); @@ -1294,10 +1293,10 @@ public final class AbilityFactoryChangeZone { final Card source = af.getHostCard(); final HashMap params = af.getMapParams(); - final Zone origin = Zone.smartValueOf(params.get("Origin")); - final Zone destination = Zone.smartValueOf(params.get("Destination")); + final ZoneType origin = ZoneType.smartValueOf(params.get("Origin")); + final ZoneType destination = ZoneType.smartValueOf(params.get("Destination")); - float pct = origin.equals(Zone.Battlefield) ? .8f : .667f; + float pct = origin.equals(ZoneType.Battlefield) ? .8f : .667f; final Random r = MyRandom.getRandom(); @@ -1345,7 +1344,7 @@ public final class AbilityFactoryChangeZone { // return this card from battlefield: cards like Blinking Spirit // in general this should only be used to protect from Imminent Harm // (dying or losing control of) - if (origin.equals(Zone.Battlefield)) { + if (origin.equals(ZoneType.Battlefield)) { if (AllZone.getStack().size() == 0) { return false; } @@ -1357,8 +1356,8 @@ public final class AbilityFactoryChangeZone { } // only use blink or bounce effects - if (!(destination.equals(Zone.Exile) && (subAPI.equals("DelayedTrigger") || subAPI.equals("ChangeZone"))) - && !destination.equals(Zone.Hand)) { + if (!(destination.equals(ZoneType.Exile) && (subAPI.equals("DelayedTrigger") || subAPI.equals("ChangeZone"))) + && !destination.equals(ZoneType.Hand)) { return false; } @@ -1419,8 +1418,8 @@ public final class AbilityFactoryChangeZone { final boolean mandatory) { final HashMap params = af.getMapParams(); final Card source = sa.getSourceCard(); - final Zone origin = Zone.smartValueOf(params.get("Origin")); - final Zone destination = Zone.smartValueOf(params.get("Destination")); + final ZoneType origin = ZoneType.smartValueOf(params.get("Origin")); + final ZoneType destination = ZoneType.smartValueOf(params.get("Destination")); final Target tgt = sa.getTarget(); final AbilitySub abSub = sa.getSubAbility(); @@ -1447,13 +1446,13 @@ public final class AbilityFactoryChangeZone { } // Narrow down the list: - if (origin.equals(Zone.Battlefield)) { + if (origin.equals(ZoneType.Battlefield)) { // filter out untargetables list = list.getTargetableCards(sa); CardList aiPermanents = list.getController(AllZone.getComputerPlayer()); // if it's blink or bounce, try to save my about to die stuff - if ((destination.equals(Zone.Hand) || (destination.equals(Zone.Exile) && (subAPI.equals("DelayedTrigger") || (subAPI + if ((destination.equals(ZoneType.Hand) || (destination.equals(ZoneType.Exile) && (subAPI.equals("DelayedTrigger") || (subAPI .equals("ChangeZone") && subAffected.equals("Remembered"))))) && (tgt.getMinTargets(sa.getSourceCard(), sa) <= 1)) { @@ -1517,8 +1516,8 @@ public final class AbilityFactoryChangeZone { } } - } else if (origin.equals(Zone.Graveyard)) { - if (destination.equals(Zone.Hand)) { + } else if (origin.equals(ZoneType.Graveyard)) { + if (destination.equals(ZoneType.Hand)) { // only retrieve cards from computer graveyard list = list.getController(AllZone.getComputerPlayer()); } @@ -1526,8 +1525,8 @@ public final class AbilityFactoryChangeZone { } // blink human targets only during combat - if (origin.equals(Zone.Battlefield) - && destination.equals(Zone.Exile) + if (origin.equals(ZoneType.Battlefield) + && destination.equals(ZoneType.Exile) && (subAPI.equals("DelayedTrigger") || (subAPI.equals("ChangeZone") && subAffected.equals("Remembered"))) && !(Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.COMBAT_DECLARE_ATTACKERS_INSTANT_ABILITY) || sa .isAbility())) { @@ -1535,7 +1534,7 @@ public final class AbilityFactoryChangeZone { } // Exile and bounce opponents stuff - if (destination.equals(Zone.Exile) || origin.equals(Zone.Battlefield)) { + if (destination.equals(ZoneType.Exile) || origin.equals(ZoneType.Battlefield)) { // don't rush bouncing stuff when not going to attack if (!sa.isTrigger() && sa.getPayCosts() != null @@ -1578,10 +1577,10 @@ public final class AbilityFactoryChangeZone { if (!list.isEmpty()) { final Card mostExpensive = CardFactoryUtil.getMostExpensivePermanentAI(list, sa, false); - if (destination.equals(Zone.Battlefield) || origin.equals(Zone.Battlefield)) { + if (destination.equals(ZoneType.Battlefield) || origin.equals(ZoneType.Battlefield)) { if (mostExpensive.isCreature()) { // if a creature is most expensive take the best one - if (destination.equals(Zone.Exile)) { + if (destination.equals(ZoneType.Exile)) { // If Exiling things, don't give bonus to Tokens choice = CardFactoryUtil.getBestCreatureAI(list); } else { @@ -1637,15 +1636,15 @@ public final class AbilityFactoryChangeZone { final HashMap params = af.getMapParams(); final Card source = sa.getSourceCard(); - final Zone origin = Zone.smartValueOf(params.get("Origin")); - final Zone destination = Zone.smartValueOf(params.get("Destination")); + final ZoneType origin = ZoneType.smartValueOf(params.get("Origin")); + final ZoneType destination = ZoneType.smartValueOf(params.get("Destination")); final Target tgt = sa.getTarget(); CardList list = AllZoneUtil.getCardsIn(origin); list = list.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), source); // Narrow down the list: - if (origin.equals(Zone.Battlefield)) { + if (origin.equals(ZoneType.Battlefield)) { // filter out untargetables list = list.getTargetableCards(sa); @@ -1653,7 +1652,7 @@ public final class AbilityFactoryChangeZone { // or save my about to die stuff // if Destination is exile, filter out my cards - } else if (origin.equals(Zone.Graveyard)) { + } else if (origin.equals(ZoneType.Graveyard)) { // Retrieve from Graveyard to: } @@ -1673,10 +1672,10 @@ public final class AbilityFactoryChangeZone { if (!list.isEmpty()) { if (CardFactoryUtil.getMostExpensivePermanentAI(list, sa, false).isCreature() - && (destination.equals(Zone.Battlefield) || origin.equals(Zone.Battlefield))) { + && (destination.equals(ZoneType.Battlefield) || origin.equals(ZoneType.Battlefield))) { // if a creature is most expensive take the best choice = CardFactoryUtil.getBestCreatureToBounceAI(list); - } else if (destination.equals(Zone.Battlefield) || origin.equals(Zone.Battlefield)) { + } else if (destination.equals(ZoneType.Battlefield) || origin.equals(ZoneType.Battlefield)) { choice = CardFactoryUtil.getMostExpensivePermanentAI(list, sa, false); } else { // TODO AI needs more improvement to it's retrieval (reuse @@ -1772,8 +1771,8 @@ public final class AbilityFactoryChangeZone { sb.append(" "); - final Zone destination = Zone.smartValueOf(params.get("Destination")); - final Zone origin = Zone.smartValueOf(params.get("Origin")); + final ZoneType destination = ZoneType.smartValueOf(params.get("Destination")); + final ZoneType origin = ZoneType.smartValueOf(params.get("Origin")); final StringBuilder sbTargets = new StringBuilder(); @@ -1798,9 +1797,9 @@ public final class AbilityFactoryChangeZone { final String fromGraveyard = " from the graveyard"; - if (destination.equals(Zone.Battlefield)) { + if (destination.equals(ZoneType.Battlefield)) { sb.append("Put").append(targetname); - if (origin.equals(Zone.Graveyard)) { + if (origin.equals(ZoneType.Graveyard)) { sb.append(fromGraveyard); } @@ -1814,15 +1813,15 @@ public final class AbilityFactoryChangeZone { sb.append("."); } - if (destination.equals(Zone.Hand)) { + if (destination.equals(ZoneType.Hand)) { sb.append("Return").append(targetname); - if (origin.equals(Zone.Graveyard)) { + if (origin.equals(ZoneType.Graveyard)) { sb.append(fromGraveyard); } sb.append(" to").append(pronoun).append("owners hand."); } - if (destination.equals(Zone.Library)) { + if (destination.equals(ZoneType.Library)) { if (params.containsKey("Shuffle")) { // for things like Gaea's // Blessing sb.append("Shuffle").append(targetname); @@ -1830,7 +1829,7 @@ public final class AbilityFactoryChangeZone { sb.append(" into").append(pronoun).append("owner's library."); } else { sb.append("Put").append(targetname); - if (origin.equals(Zone.Graveyard)) { + if (origin.equals(ZoneType.Graveyard)) { sb.append(fromGraveyard); } @@ -1850,20 +1849,20 @@ public final class AbilityFactoryChangeZone { } } - if (destination.equals(Zone.Exile)) { + if (destination.equals(ZoneType.Exile)) { sb.append("Exile").append(targetname); - if (origin.equals(Zone.Graveyard)) { + if (origin.equals(ZoneType.Graveyard)) { sb.append(fromGraveyard); } sb.append("."); } - if (destination.equals(Zone.Ante)) { + if (destination.equals(ZoneType.Ante)) { sb.append("Ante").append(targetname); sb.append("."); } - if (destination.equals(Zone.Graveyard)) { + if (destination.equals(ZoneType.Graveyard)) { sb.append("Put").append(targetname); sb.append(" from ").append(origin); sb.append(" into").append(pronoun).append("owner's graveyard."); @@ -1894,8 +1893,8 @@ public final class AbilityFactoryChangeZone { final Player player = sa.getActivatingPlayer(); final Card hostCard = sa.getSourceCard(); - final Zone destination = Zone.valueOf(params.get("Destination")); - final Zone origin = Zone.valueOf(params.get("Origin")); + final ZoneType destination = ZoneType.valueOf(params.get("Destination")); + final ZoneType origin = ZoneType.valueOf(params.get("Origin")); if (tgt != null) { tgtCards = tgt.getTargetCards(); @@ -1921,7 +1920,7 @@ public final class AbilityFactoryChangeZone { continue; } - if ((tgt != null) && origin.equals(Zone.Battlefield)) { + if ((tgt != null) && origin.equals(ZoneType.Battlefield)) { // check targeting if (!tgtC.canBeTargetedBy(sa)) { continue; @@ -1930,11 +1929,11 @@ public final class AbilityFactoryChangeZone { Card movedCard = null; Player pl = player; - if (!destination.equals(Zone.Battlefield)) { + if (!destination.equals(ZoneType.Battlefield)) { pl = tgtC.getOwner(); } - if (destination.equals(Zone.Library)) { + if (destination.equals(ZoneType.Library)) { // library position is zero indexed final int libraryPosition = params.containsKey("LibraryPosition") ? Integer.parseInt(params .get("LibraryPosition")) : 0; @@ -1946,7 +1945,7 @@ public final class AbilityFactoryChangeZone { tgtC.getOwner().shuffle(); } } else { - if (destination.equals(Zone.Battlefield)) { + if (destination.equals(ZoneType.Battlefield)) { if (params.containsKey("Tapped") || params.containsKey("Ninjutsu")) { tgtC.setTapped(true); } @@ -1993,7 +1992,7 @@ public final class AbilityFactoryChangeZone { if (params.containsKey("Fizzle")) { ArrayList spells = tgtC.getSpellAbilities(); for (SpellAbility spell : spells) { - if (tgtC.isInZone(Zone.Exile)) { + if (tgtC.isInZone(ZoneType.Exile)) { final SpellAbilityStackInstance si = AllZone.getStack().getInstanceFromSpellAbility(spell); AllZone.getStack().remove(si); } @@ -2029,7 +2028,7 @@ 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 Zone origin) { + private static CardList knownDetermineDefined(final SpellAbility sa, final String defined, final ZoneType origin) { final CardList ret = new CardList(); final ArrayList list = AbilityFactory.getDefinedCards(sa.getSourceCard(), defined, sa); @@ -2176,7 +2175,7 @@ public final class AbilityFactoryChangeZone { final Card source = sa.getSourceCard(); final HashMap params = af.getMapParams(); final String destination = params.get("Destination"); - final Constant.Zone origin = Constant.Zone.smartValueOf(params.get("Origin")); + final ZoneType origin = ZoneType.smartValueOf(params.get("Origin")); if (abCost != null) { // AI currently disabled for these costs @@ -2208,17 +2207,17 @@ public final class AbilityFactoryChangeZone { // TODO improve restrictions on when the AI would want to use this // spBounceAll has some AI we can compare to. - if (origin.equals(Zone.Hand) || origin.equals(Zone.Library)) { + if (origin.equals(ZoneType.Hand) || origin.equals(ZoneType.Library)) { final Target tgt = sa.getTarget(); if (tgt != null) { - if (AllZone.getHumanPlayer().getCardsIn(Zone.Hand).isEmpty() + if (AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand).isEmpty() || !AllZone.getHumanPlayer().canBeTargetedBy(sa)) { return false; } tgt.resetTargets(); tgt.addTarget(AllZone.getHumanPlayer()); } - } else if (origin.equals(Zone.Battlefield)) { + } else if (origin.equals(ZoneType.Battlefield)) { // this statement is assuming the AI is trying to use this spell // offensively // if the AI is using it defensively, then something else needs to @@ -2241,19 +2240,19 @@ public final class AbilityFactoryChangeZone { if (Singletons.getModel().getGameState().getPhaseHandler().is(PhaseType.MAIN1, AllZone.getComputerPlayer())) { return false; } - } else if (origin.equals(Zone.Graveyard)) { + } else if (origin.equals(ZoneType.Graveyard)) { final Target tgt = sa.getTarget(); if (tgt != null) { - if (AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard).isEmpty() + if (AllZone.getHumanPlayer().getCardsIn(ZoneType.Graveyard).isEmpty() || !AllZone.getHumanPlayer().canBeTargetedBy(sa)) { return false; } tgt.resetTargets(); tgt.addTarget(AllZone.getHumanPlayer()); } - } else if (origin.equals(Zone.Exile)) { + } else if (origin.equals(ZoneType.Exile)) { - } else if (origin.equals(Zone.Stack)) { + } else if (origin.equals(ZoneType.Stack)) { // time stop can do something like this: // Origin$ Stack | Destination$ Exile | SubAbility$ DBSkip // DBSKipToPhase | DB$SkipToPhase | Phase$ Cleanup @@ -2261,7 +2260,7 @@ public final class AbilityFactoryChangeZone { return false; } - if (destination.equals(Constant.Zone.Battlefield)) { + if (destination.equals(ZoneType.Battlefield)) { if (params.get("GainControl") != null) { // Check if the cards are valuable enough if ((humanType.getNotType("Creature").size() == 0) && (computerType.getNotType("Creature").size() == 0)) { @@ -2368,8 +2367,8 @@ public final class AbilityFactoryChangeZone { */ private static void changeZoneAllResolve(final AbilityFactory af, final SpellAbility sa) { final HashMap params = af.getMapParams(); - final Zone destination = Zone.smartValueOf(params.get("Destination")); - final List origin = Zone.listValueOf(params.get("Origin")); + final ZoneType destination = ZoneType.smartValueOf(params.get("Destination")); + final List origin = ZoneType.listValueOf(params.get("Origin")); CardList cards = null; @@ -2401,7 +2400,7 @@ public final class AbilityFactoryChangeZone { final int libraryPos = params.containsKey("LibraryPosition") ? Integer.parseInt(params.get("LibraryPosition")) : 0; for (final Card c : cards) { - if (destination.equals(Zone.Battlefield)) { + if (destination.equals(ZoneType.Battlefield)) { // Auras without Candidates stay in their current location if (c.isAura()) { final SpellAbility saAura = AbilityFactoryAttach.getAttachSpellAbility(c); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java index a1179cb3f51..3dce2e9dfaf 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryChoose.java @@ -36,7 +36,6 @@ import forge.CardList; import forge.CardListFilter; import forge.CardUtil; import forge.Constant; -import forge.Constant.Zone; import forge.card.cardfactory.CardFactoryUtil; import forge.card.spellability.AbilityActivated; import forge.card.spellability.AbilitySub; @@ -45,6 +44,7 @@ import forge.card.spellability.SpellAbility; import forge.card.spellability.Target; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.gui.ListChooser; import forge.item.CardDb; @@ -350,15 +350,15 @@ public final class AbilityFactoryChoose { final String logic = params.get("AILogic"); if (logic.equals("MostProminentOnBattlefield")) { chosen = CardFactoryUtil.getMostProminentCreatureType(AllZoneUtil - .getCardsIn(Zone.Battlefield)); + .getCardsIn(ZoneType.Battlefield)); } if (logic.equals("MostProminentComputerControls")) { chosen = CardFactoryUtil.getMostProminentCreatureType(AllZone.getComputerPlayer() - .getCardsIn(Zone.Battlefield)); + .getCardsIn(ZoneType.Battlefield)); } if (logic.equals("MostProminentHumanControls")) { chosen = CardFactoryUtil.getMostProminentCreatureType(AllZone.getHumanPlayer() - .getCardsIn(Zone.Battlefield)); + .getCardsIn(ZoneType.Battlefield)); } if (logic.equals("MostProminentInComputerDeck")) { chosen = CardFactoryUtil.getMostProminentCreatureType(AllZoneUtil.getCardsInGame() @@ -366,7 +366,7 @@ public final class AbilityFactoryChoose { } if (logic.equals("MostProminentInComputerGraveyard")) { chosen = CardFactoryUtil.getMostProminentCreatureType(AllZone.getComputerPlayer() - .getCardsIn(Zone.Graveyard)); + .getCardsIn(ZoneType.Graveyard)); } } if (!CardUtil.isACreatureType(chosen) || invalidTypes.contains(chosen)) { @@ -687,10 +687,10 @@ public final class AbilityFactoryChoose { } else if (logic.equals("MostProminentComputerControls")) { chosen = CardFactoryUtil.getMostProminentColor(AllZone.getComputerPlayer().getCardsIn( - Zone.Battlefield)); + ZoneType.Battlefield)); } else if (logic.equals("MostProminentPermanent")) { - final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); chosen = CardFactoryUtil.getMostProminentColor(list); } else if (logic.equals("MostProminentAttackers")) { @@ -1500,10 +1500,10 @@ public final class AbilityFactoryChoose { final String logic = params.get("AILogic"); if (logic.equals("MostProminentInComputerDeck")) { chosen = CardFactoryUtil.getMostProminentCardName(AllZone.getComputerPlayer() - .getCardsIn(Constant.Zone.Library)); + .getCardsIn(ZoneType.Library)); } else if (logic.equals("MostProminentInHumanDeck")) { chosen = CardFactoryUtil.getMostProminentCardName(AllZone.getHumanPlayer() - .getCardsIn(Constant.Zone.Library)); + .getCardsIn(ZoneType.Library)); } } else { CardList list = AllZoneUtil.getCardsInGame().getController(AllZone.getHumanPlayer()); @@ -1738,7 +1738,7 @@ public final class AbilityFactoryChoose { tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa); } - CardList choices = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList choices = AllZoneUtil.getCardsIn(ZoneType.Battlefield); if (params.containsKey("Choices")) { choices = choices.getValidCards(params.get("Choices"), host.getController(), host); } diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryClash.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryClash.java index 4fc5b58fdb6..c054bb08595 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryClash.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryClash.java @@ -26,7 +26,6 @@ import javax.swing.JOptionPane; import forge.AllZone; import forge.Card; import forge.CardList; -import forge.Constant; import forge.GameActionUtil; import forge.card.cardfactory.CardFactoryUtil; import forge.card.spellability.AbilityActivated; @@ -36,6 +35,7 @@ import forge.card.spellability.SpellAbility; import forge.card.spellability.Target; import forge.card.trigger.TriggerType; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; /** @@ -598,10 +598,10 @@ public final class AbilityFactoryClash { private static boolean twoPilesCanPlayAI(final AbilityFactory af, final SpellAbility sa) { final HashMap params = af.getMapParams(); final Card card = af.getHostCard(); - Constant.Zone zone = null; + ZoneType zone = null; if (params.containsKey("Zone")) { - zone = Constant.Zone.smartValueOf(params.get("Zone")); + zone = ZoneType.smartValueOf(params.get("Zone")); } String valid = ""; @@ -641,11 +641,11 @@ public final class AbilityFactoryClash { private static void twoPilesResolve(final AbilityFactory af, final SpellAbility sa) { final HashMap params = af.getMapParams(); final Card card = af.getHostCard(); - Constant.Zone zone = null; + ZoneType zone = null; boolean pile1WasChosen = true; if (params.containsKey("Zone")) { - zone = Constant.Zone.smartValueOf(params.get("Zone")); + zone = ZoneType.smartValueOf(params.get("Zone")); } String valid = ""; diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryCombat.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryCombat.java index 373e7652572..35f074161ea 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryCombat.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryCombat.java @@ -24,7 +24,6 @@ import forge.AllZone; import forge.Card; import forge.CardList; import forge.CardListFilter; -import forge.Constant.Zone; import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; import forge.card.spellability.AbilityActivated; @@ -36,6 +35,7 @@ import forge.game.phase.CombatUtil; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; /** *

@@ -952,7 +952,7 @@ public final class AbilityFactoryCombat { boolean chance = false; if (abTgt != null) { - CardList list = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield).getType("Creature"); + CardList list = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield).getType("Creature"); list = list.getTargetableCards(sa); list = list.getValidCards(abTgt.getValidTgts(), source.getController(), source); list = list.filter(new CardListFilter() { diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryCopy.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryCopy.java index cce978edfdc..59a14cb297b 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryCopy.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryCopy.java @@ -30,7 +30,6 @@ import forge.CardCharactersticName; import forge.CardList; import forge.CardListFilter; import forge.Command; -import forge.Constant.Zone; import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; import forge.card.spellability.Ability; @@ -43,6 +42,7 @@ import forge.card.trigger.TriggerType; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.util.MyRandom; @@ -280,7 +280,7 @@ public final class AbilityFactoryCopy { final Target abTgt = sa.getTarget(); if (abTgt != null) { - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = list.getValidCards(abTgt.getValidTgts(), source.getController(), source); abTgt.resetTargets(); // target loop diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryCounters.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryCounters.java index 4b43378a51b..ae8e7ea3519 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryCounters.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryCounters.java @@ -28,8 +28,6 @@ import forge.AllZoneUtil; import forge.Card; import forge.CardList; import forge.CardListFilter; -import forge.Constant; -import forge.Constant.Zone; import forge.Counters; import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; @@ -45,7 +43,8 @@ import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.util.MyRandom; import forge.view.ButtonUtil; @@ -280,7 +279,7 @@ public class AbilityFactoryCounters { final Player player = af.isCurse() ? AllZone.getHumanPlayer() : AllZone.getComputerPlayer(); - list = player.getCardsIn(Zone.Battlefield); + list = player.getCardsIn(ZoneType.Battlefield); list = list.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -432,7 +431,7 @@ public class AbilityFactoryCounters { final Player player = af.isCurse() ? AllZone.getHumanPlayer() : AllZone.getComputerPlayer(); - list = player.getCardsIn(Zone.Battlefield); + list = player.getCardsIn(ZoneType.Battlefield); list = list.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -545,7 +544,7 @@ public class AbilityFactoryCounters { // things like Powder Keg, which are way too complex for the AI } } else { - list = player.getCardsIn(Zone.Battlefield); + list = player.getCardsIn(ZoneType.Battlefield); list = list.getTargetableCards(sa); if (abTgt != null) { list = list.getValidCards(abTgt.getValidTgts(), source.getController(), source); @@ -553,7 +552,7 @@ public class AbilityFactoryCounters { if (list.isEmpty() && mandatory) { // If there isn't any prefered cards to target, gotta choose // non-preferred ones - list = player.getOpponent().getCardsIn(Zone.Battlefield); + list = player.getOpponent().getCardsIn(ZoneType.Battlefield); list = list.getTargetableCards(sa); if (abTgt != null) { list = list.getValidCards(abTgt.getValidTgts(), source.getController(), source); @@ -724,7 +723,7 @@ public class AbilityFactoryCounters { final PlayerZone zone = AllZone.getZoneOf(tgtCard); if (zone == null) { // Do nothing, token disappeared - } else if (zone.is(Constant.Zone.Battlefield)) { + } else if (zone.is(ZoneType.Battlefield)) { tgtCard.addCounter(Counters.valueOf(type), counterAmount); } else { // adding counters to something like re-suspend cards @@ -1171,7 +1170,7 @@ public class AbilityFactoryCounters { } } else { - if (zone.is(Constant.Zone.Battlefield) || zone.is(Constant.Zone.Exile)) { + if (zone.is(ZoneType.Battlefield) || zone.is(ZoneType.Exile)) { if (params.containsKey("UpTo") && sa.getActivatingPlayer().isHuman()) { final ArrayList choices = new ArrayList(); for (int i = 0; i <= counterAmount; i++) { @@ -1351,8 +1350,8 @@ public class AbilityFactoryCounters { if (subAb != null && !subAb.chkAIDrawback()) { return false; } - CardList hperms = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); - CardList cperms = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList hperms = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + CardList cperms = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); cperms = cperms.filter(new CardListFilter() { @Override public boolean addCard(final Card crd) { @@ -1417,8 +1416,8 @@ 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(Zone.Battlefield); - CardList cperms = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList hperms = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + CardList cperms = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); if (af.getHostCard().getController().isHuman()) { cperms.addAll(hperms); @@ -1742,8 +1741,8 @@ public class AbilityFactoryCounters { final boolean curse = af.isCurse(); final Target tgt = sa.getTarget(); - hList = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); - cList = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + hList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + cList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); hList = hList.getValidCards(valid, source.getController(), source); cList = cList.getValidCards(valid, source.getController(), source); @@ -1878,7 +1877,7 @@ public class AbilityFactoryCounters { final int counterAmount = AbilityFactory.calculateAmount(af.getHostCard(), params.get("CounterNum"), sa); final String valid = params.get("ValidCards"); - CardList cards = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList cards = AllZoneUtil.getCardsIn(ZoneType.Battlefield); cards = cards.getValidCards(valid, sa.getSourceCard().getController(), sa.getSourceCard()); final Target tgt = sa.getTarget(); @@ -1888,7 +1887,7 @@ public class AbilityFactoryCounters { } for (final Card tgtCard : cards) { - if (AllZone.getZoneOf(tgtCard).is(Constant.Zone.Battlefield)) { + if (AllZone.getZoneOf(tgtCard).is(ZoneType.Battlefield)) { tgtCard.addCounter(Counters.valueOf(type), counterAmount); } else { // adding counters to something like re-suspend cards @@ -2101,7 +2100,7 @@ public class AbilityFactoryCounters { int counterAmount = AbilityFactory.calculateAmount(af.getHostCard(), params.get("CounterNum"), sa); final String valid = params.get("ValidCards"); - CardList cards = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList cards = AllZoneUtil.getCardsIn(ZoneType.Battlefield); cards = cards.getValidCards(valid, sa.getSourceCard().getController(), sa.getSourceCard()); final Target tgt = sa.getTarget(); @@ -2394,13 +2393,13 @@ public class AbilityFactoryCounters { } } else { // targeted final Player player = af.isCurse() ? AllZone.getHumanPlayer() : AllZone.getComputerPlayer(); - CardList list = player.getCardsIn(Zone.Battlefield); + CardList list = player.getCardsIn(ZoneType.Battlefield); list = list.getTargetableCards(sa); list = list.getValidCards(abTgt.getValidTgts(), host.getController(), host); if (list.isEmpty() && mandatory) { // If there isn't any prefered cards to target, gotta choose // non-preferred ones - list = player.getOpponent().getCardsIn(Zone.Battlefield); + list = player.getOpponent().getCardsIn(ZoneType.Battlefield); list = list.getTargetableCards(sa); list = list.getValidCards(abTgt.getValidTgts(), host.getController(), host); preferred = false; diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java index adf12c130cb..b8ecfdfb07b 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryDealDamage.java @@ -27,7 +27,6 @@ import forge.Card; import forge.CardList; import forge.CardListFilter; import forge.CardUtil; -import forge.Constant.Zone; import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; import forge.card.cost.Cost; @@ -41,6 +40,7 @@ import forge.card.spellability.TargetSelection; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.util.MyRandom; /** @@ -434,7 +434,7 @@ public class AbilityFactoryDealDamage { return false; } - final CardList hand = comp.getCardsIn(Zone.Hand); + final CardList hand = comp.getCardsIn(ZoneType.Hand); if (this.abilityFactory.isSpell()) { // If this is a spell, cast it instead of discarding @@ -473,7 +473,7 @@ public class AbilityFactoryDealDamage { final Target tgt = saMe.getTarget(); final Card source = saMe.getSourceCard(); final HashMap params = this.abilityFactory.getMapParams(); - CardList hPlay = pl.getCardsIn(Zone.Battlefield); + CardList hPlay = pl.getCardsIn(ZoneType.Battlefield); hPlay = hPlay.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), source); final ArrayList objects = tgt.getTargets(); @@ -1140,7 +1140,7 @@ public class AbilityFactoryDealDamage { } // TODO: X may be something different than X paid - CardList list = player.getCardsIn(Zone.Battlefield); + CardList list = player.getCardsIn(ZoneType.Battlefield); list = list.getValidCards(validC.split(","), source.getController(), source); final CardListFilter filterKillable = new CardListFilter() { @@ -1265,7 +1265,7 @@ public class AbilityFactoryDealDamage { } if (params.containsKey("ValidCards")) { - list = AllZoneUtil.getCardsIn(Zone.Battlefield); + list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); } if (targetPlayer != null) { @@ -1498,7 +1498,7 @@ public class AbilityFactoryDealDamage { final HashMap params = af.getMapParams(); final Card card = sa.getSourceCard(); - CardList sources = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList sources = AllZoneUtil.getCardsIn(ZoneType.Battlefield); if (params.containsKey("ValidCards")) { sources = sources.getValidCards(params.get("ValidCards"), card.getController(), card); } diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryDebuff.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryDebuff.java index 6aa0a799d5a..ca7916d340c 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryDebuff.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryDebuff.java @@ -29,7 +29,6 @@ import forge.Card; import forge.CardList; import forge.CardListFilter; import forge.Command; -import forge.Constant.Zone; import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; import forge.card.cost.Cost; @@ -43,6 +42,7 @@ import forge.card.spellability.Target; import forge.game.phase.CombatUtil; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; +import forge.game.zone.ZoneType; import forge.util.MyRandom; /** @@ -448,7 +448,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(Zone.Battlefield); + CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); final Target tgt = sa.getTarget(); list = list.getValidCards(tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard()); @@ -737,9 +737,9 @@ public final class AbilityFactoryDebuff { valid = params.get("ValidCards"); } - CardList comp = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList comp = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); comp = comp.getValidCards(valid, hostCard.getController(), hostCard); - CardList human = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); + CardList human = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); human = human.getValidCards(valid, hostCard.getController(), hostCard); // TODO - add blocking situations here also @@ -784,7 +784,7 @@ public final class AbilityFactoryDebuff { valid = params.get("ValidCards"); } - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = list.getValidCards(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 30a98c99c57..84b95499543 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryDestroy.java @@ -28,7 +28,6 @@ import forge.Card; import forge.CardList; import forge.CardListFilter; import forge.CardUtil; -import forge.Constant.Zone; import forge.Counters; import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; @@ -41,6 +40,7 @@ import forge.card.spellability.SpellAbility; import forge.card.spellability.Target; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.util.MyRandom; /** @@ -192,7 +192,7 @@ public class AbilityFactoryDestroy { final boolean noRegen = params.containsKey("NoRegen"); CardList list; - list = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); + list = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); list = list.getTargetableCards(sa); if (abTgt != null) { @@ -335,7 +335,7 @@ public class AbilityFactoryDestroy { if (tgt != null) { CardList list; - list = AllZoneUtil.getCardsIn(Zone.Battlefield); + list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = list.getTargetableCards(sa); list = list.getValidCards(tgt.getValidTgts(), source.getController(), source); @@ -781,8 +781,8 @@ public class AbilityFactoryDestroy { if (params.containsKey("ValidCards")) { valid = params.get("ValidCards"); } - CardList humanlist = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); - CardList computerlist = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList humanlist = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + CardList computerlist = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); if (sa.getTarget() != null) { tgt.resetTargets(); sa.getTarget().addTarget(AllZone.getHumanPlayer()); @@ -860,8 +860,8 @@ public class AbilityFactoryDestroy { valid = valid.replace("X", Integer.toString(xPay)); } - CardList humanlist = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); - CardList computerlist = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList humanlist = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + CardList computerlist = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); final Target tgt = sa.getTarget(); @@ -962,7 +962,7 @@ public class AbilityFactoryDestroy { valid = valid.replace("X", Integer.toString(AbilityFactory.calculateAmount(card, "X", sa))); } - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); if (targetPlayer != null) { list = list.getController(targetPlayer); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryEffect.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryEffect.java index dbdb5895c4f..0ab60a4a81c 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryEffect.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryEffect.java @@ -26,7 +26,6 @@ import forge.Card; import forge.CardList; import forge.CardListFilter; import forge.Command; -import forge.Constant.Zone; import forge.Singletons; import forge.card.replacement.ReplacementEffect; import forge.card.replacement.ReplacementHandler; @@ -43,6 +42,7 @@ import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.util.MyRandom; /** @@ -250,8 +250,8 @@ public class AbilityFactoryEffect { } randomReturn = CombatUtil.lifeInDanger(AllZone.getCombat()); } else if (logic.equals("Evasion")) { - CardList comp = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield).getType("Creature"); - CardList human = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield).getType("Creature"); + CardList comp = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield).getType("Creature"); + CardList human = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield).getType("Creature"); // only count creatures that can attack or block comp = comp.filter(new CardListFilter() { @@ -279,7 +279,7 @@ public class AbilityFactoryEffect { if (name == null) { name = sa.getSourceCard().getName() + "'s Effect"; } - final CardList list = sa.getActivatingPlayer().getCardsIn(Zone.Battlefield, name); + final CardList 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 2d6c117a9c8..c745bae6134 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryGainControl.java @@ -28,8 +28,6 @@ import forge.Card; import forge.CardList; import forge.CardListFilter; import forge.Command; -import forge.Constant; -import forge.Constant.Zone; import forge.GameEntity; import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; @@ -42,6 +40,7 @@ import forge.card.spellability.Target; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; //AB:GainControl|ValidTgts$Creature|TgtPrompt$Select target legendary creature|LoseControl$Untap,LoseControl|SpellDescription$Gain control of target xxxxxxx @@ -305,7 +304,7 @@ public class AbilityFactoryGainControl { } } - CardList list = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); + CardList list = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); list = list.getValidCards(tgt.getValidTgts(), this.hostCard.getController(), this.hostCard); // AI won't try to grab cards that are filtered out of AI decks on // purpose @@ -393,7 +392,7 @@ public class AbilityFactoryGainControl { final Target tgt = sa.getTarget(); if (this.params.containsKey("AllValid")) { - tgtCards = AllZoneUtil.getCardsIn(Constant.Zone.Battlefield); + tgtCards = AllZoneUtil.getCardsIn(ZoneType.Battlefield); tgtCards = AbilityFactory.filterListByType(tgtCards, this.params.get("AllValid"), sa); } else if ((tgt != null) && !this.params.containsKey("Defined")) { tgtCards.addAll(tgt.getTargetCards()); @@ -517,7 +516,7 @@ public class AbilityFactoryGainControl { private boolean gainControlDrawbackAI(final SpellAbility sa) { if ((sa.getTarget() == null) || !sa.getTarget().doesTarget()) { if (this.params.containsKey("AllValid")) { - CardList tgtCards = AllZoneUtil.getCardsIn(Constant.Zone.Battlefield) + CardList tgtCards = AllZoneUtil.getCardsIn(ZoneType.Battlefield) .getController(AllZone.getHumanPlayer()); tgtCards = AbilityFactory.filterListByType(tgtCards, this.params.get("AllValid"), sa); if (tgtCards.isEmpty()) { diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryMana.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryMana.java index c126a3c2ace..2582ebf6ba7 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryMana.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryMana.java @@ -27,7 +27,6 @@ import forge.AllZoneUtil; import forge.Card; import forge.CardList; import forge.Constant; -import forge.Constant.Zone; import forge.Counters; import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; @@ -41,6 +40,7 @@ import forge.card.spellability.Target; import forge.control.input.InputPayManaCostUtil; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.util.MyRandom; @@ -335,7 +335,7 @@ public class AbilityFactoryMana { String chosen = Constant.Color.BLACK; if (logic.equals("MostProminentInComputerHand")) { chosen = CardFactoryUtil.getMostProminentColor(AllZone.getComputerPlayer().getCardsIn( - Zone.Hand)); + ZoneType.Hand)); } GuiUtils.chooseOne("Computer picked: ", chosen); abMana.setExpressChoice(InputPayManaCostUtil.getShortColorString(chosen)); @@ -648,7 +648,7 @@ public class AbilityFactoryMana { cards.add(c); } } else { - cards = AllZoneUtil.getCardsIn(Zone.Battlefield).getValidCards(validCard, abMana.getActivatingPlayer(), + cards = AllZoneUtil.getCardsIn(ZoneType.Battlefield).getValidCards(validCard, abMana.getActivatingPlayer(), card); } @@ -875,7 +875,7 @@ public class AbilityFactoryMana { * @return a boolean. */ private static boolean hasUrzaLands(final Player p) { - final CardList landsControlled = p.getCardsIn(Zone.Battlefield); + final CardList landsControlled = p.getCardsIn(ZoneType.Battlefield); return (landsControlled.containsName("Urza's Mine") && landsControlled.containsName("Urza's Tower") && landsControlled .containsName("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 b2161afcbac..4fb63b384be 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryPermanentState.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryPermanentState.java @@ -27,7 +27,6 @@ import forge.AllZoneUtil; import forge.Card; import forge.CardList; import forge.CardListFilter; -import forge.Constant.Zone; import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; import forge.card.cost.Cost; @@ -41,6 +40,7 @@ import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.util.MyRandom; @@ -367,7 +367,7 @@ public class AbilityFactoryPermanentState { targetController = AllZone.getHumanPlayer(); } - CardList untapList = targetController.getCardsIn(Zone.Battlefield); + CardList untapList = targetController.getCardsIn(ZoneType.Battlefield); untapList = untapList.getTargetableCards(sa); untapList = untapList.getValidCards(tgt.getValidTgts(), source.getController(), source); @@ -439,7 +439,7 @@ public class AbilityFactoryPermanentState { final Card source = sa.getSourceCard(); final Target tgt = sa.getTarget(); - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = list.getValidCards(tgt.getValidTgts(), source.getController(), source); list = list.getTargetableCards(sa); @@ -600,7 +600,7 @@ public class AbilityFactoryPermanentState { if (p.isHuman()) { AllZone.getInputControl().setInput(CardFactoryUtil.inputUntapUpToNType(num, valid)); } else { - CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); list = list.getType(valid); list = list.filter(CardListFilter.TAPPED); @@ -934,7 +934,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(Zone.Battlefield); + CardList tapList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); tapList = tapList.filter(CardListFilter.UNTAPPED); tapList = tapList.getValidCards(tgt.getValidTgts(), source.getController(), source); // filter out enchantments and planeswalkers, their tapped state doesn't @@ -1009,7 +1009,7 @@ public class AbilityFactoryPermanentState { final Card source = sa.getSourceCard(); final Target tgt = sa.getTarget(); - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = list.getValidCards(tgt.getValidTgts(), source.getController(), source); list = list.getTargetableCards(sa); @@ -1303,9 +1303,9 @@ public class AbilityFactoryPermanentState { } if ((tgtPlayers == null) || tgtPlayers.isEmpty()) { - list = AllZoneUtil.getCardsIn(Zone.Battlefield); + list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); } else { - list = tgtPlayers.get(0).getCardsIn(Zone.Battlefield); + list = tgtPlayers.get(0).getCardsIn(ZoneType.Battlefield); } list = list.getValidCards(valid.split(","), card.getController(), card); @@ -1530,9 +1530,9 @@ public class AbilityFactoryPermanentState { } if ((tgtPlayers == null) || tgtPlayers.isEmpty()) { - cards = AllZoneUtil.getCardsIn(Zone.Battlefield); + cards = AllZoneUtil.getCardsIn(ZoneType.Battlefield); } else { - cards = tgtPlayers.get(0).getCardsIn(Zone.Battlefield); + cards = tgtPlayers.get(0).getCardsIn(ZoneType.Battlefield); } cards = AbilityFactory.filterListByType(cards, params.get("ValidCards"), sa); @@ -1573,14 +1573,14 @@ public class AbilityFactoryPermanentState { valid = params.get("ValidCards"); } - CardList validTappables = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList validTappables = AllZoneUtil.getCardsIn(ZoneType.Battlefield); final Target tgt = sa.getTarget(); if (sa.getTarget() != null) { tgt.resetTargets(); tgt.addTarget(AllZone.getHumanPlayer()); - validTappables = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); + validTappables = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); } validTappables = validTappables.getValidCards(valid, source.getController(), source); @@ -1624,7 +1624,7 @@ public class AbilityFactoryPermanentState { * @return a {@link forge.CardList} object. */ private static CardList getTapAllTargets(final String valid, final Card source) { - CardList tmpList = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList tmpList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); tmpList = tmpList.getValidCards(valid, source.getController(), source); tmpList = tmpList.filter(CardListFilter.UNTAPPED); return tmpList; @@ -1694,7 +1694,7 @@ public class AbilityFactoryPermanentState { if (tgt != null) { tgt.resetTargets(); tgt.addTarget(AllZone.getHumanPlayer()); - validTappables = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); + validTappables = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); } if (mandatory) { @@ -2404,7 +2404,7 @@ public class AbilityFactoryPermanentState { final Card source = sa.getSourceCard(); final Target tgt = sa.getTarget(); - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = list.getValidCards(tgt.getValidTgts(), source.getController(), source).getTargetableCards(sa); return false; diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryPlay.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryPlay.java index 891eff7e801..d4e2822070f 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryPlay.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryPlay.java @@ -27,7 +27,6 @@ import forge.AllZoneUtil; import forge.Card; import forge.CardList; import forge.CardListFilter; -import forge.Constant.Zone; import forge.GameActionUtil; import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; @@ -43,6 +42,7 @@ import forge.card.spellability.SpellAbilityRestriction; import forge.card.spellability.Target; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.util.MyRandom; /** @@ -272,7 +272,7 @@ public final class AbilityFactoryPlay { CardList cards; final Target tgt = sa.getTarget(); if (tgt != null) { - Zone zone = tgt.getZone().get(0); + ZoneType zone = tgt.getZone().get(0); cards = AllZoneUtil.getCardsIn(zone); cards = cards.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), source); if (cards.isEmpty()) { @@ -340,9 +340,9 @@ public final class AbilityFactoryPlay { final Target tgt = sa.getTarget(); if (params.containsKey("Valid")) { - Zone zone = Zone.Hand; + ZoneType zone = ZoneType.Hand; if (params.containsKey("ValidZone")) { - zone = Zone.smartValueOf(params.get("ValidZone")); + zone = ZoneType.smartValueOf(params.get("ValidZone")); } tgtCards = AllZoneUtil.getCardsIn(zone); tgtCards = AbilityFactory.filterListByType(tgtCards, params.get("Valid"), sa); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryPreventDamage.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryPreventDamage.java index c944bab02d0..eea461bc3ee 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryPreventDamage.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryPreventDamage.java @@ -26,7 +26,6 @@ import forge.Card; import forge.CardList; import forge.CardListUtil; import forge.CardUtil; -import forge.Constant.Zone; import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; import forge.card.cost.Cost; @@ -40,6 +39,7 @@ import forge.game.phase.CombatUtil; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; /** *

@@ -320,7 +320,7 @@ public class AbilityFactoryPreventDamage { final CardList threatenedTargets = new CardList(); // filter AIs battlefield by what I can target - CardList targetables = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList targetables = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); targetables = targetables.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), hostCard); for (final Card c : targetables) { @@ -343,7 +343,7 @@ public class AbilityFactoryPreventDamage { chance = true; } else { // filter AIs battlefield by what I can target - CardList targetables = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList targetables = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); targetables = targetables.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), hostCard); if (targetables.size() == 0) { @@ -426,7 +426,7 @@ public class AbilityFactoryPreventDamage { final Target tgt = sa.getTarget(); tgt.resetTargets(); // filter AIs battlefield by what I can target - CardList targetables = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList targetables = AllZoneUtil.getCardsIn(ZoneType.Battlefield); targetables = targetables.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), hostCard); final CardList compTargetables = targetables.getController(AllZone.getComputerPlayer()); @@ -731,7 +731,7 @@ public class AbilityFactoryPreventDamage { } if (params.containsKey("ValidCards")) { - list = AllZoneUtil.getCardsIn(Zone.Battlefield); + list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); } list = AbilityFactory.filterListByType(list, params.get("ValidCards"), sa); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryProtection.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryProtection.java index 45416cc9501..14278deab33 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryProtection.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryProtection.java @@ -32,7 +32,6 @@ import forge.CardListFilter; import forge.CardUtil; import forge.Command; import forge.Constant; -import forge.Constant.Zone; import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; import forge.card.cost.Cost; @@ -46,6 +45,7 @@ import forge.game.phase.CombatUtil; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; /** @@ -433,7 +433,7 @@ public final class AbilityFactoryProtection { final HashMap params = af.getMapParams(); final Card host = af.getHostCard(); - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); final Target tgt = sa.getTarget(); list = list.getValidCards(tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard()); @@ -1115,7 +1115,7 @@ public final class AbilityFactoryProtection { valid = params.get("ValidCards"); } if (!valid.equals("")) { - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = list.getValidCards(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 fc73614e69c..8b029c07fc8 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryPump.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryPump.java @@ -28,7 +28,6 @@ import forge.CardList; import forge.CardListFilter; import forge.CardUtil; import forge.Command; -import forge.Constant.Zone; import forge.GameEntity; import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; @@ -45,6 +44,7 @@ import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.util.MyRandom; /** @@ -730,7 +730,7 @@ public class AbilityFactoryPump { } } else { if (!tgt.canTgtCreature()) { - Zone zone = tgt.getZone().get(0); + ZoneType zone = tgt.getZone().get(0); list = AllZoneUtil.getCardsIn(zone); } else { list = this.getPumpCreatures(sa); @@ -801,7 +801,7 @@ public class AbilityFactoryPump { * @return a boolean. */ private boolean pumpMandatoryTarget(final AbilityFactory af, final SpellAbility sa, final boolean mandatory) { - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); final Target tgt = sa.getTarget(); list = list.getValidCards(tgt.getValidTgts(), sa.getActivatingPlayer(), sa.getSourceCard()); @@ -1123,8 +1123,8 @@ public class AbilityFactoryPump { } } - final Zone pumpZone = this.params.containsKey("PumpZone") ? Zone.smartValueOf(this.params.get("PumpZone")) - : Zone.Battlefield; + final ZoneType pumpZone = this.params.containsKey("PumpZone") ? ZoneType.smartValueOf(this.params.get("PumpZone")) + : ZoneType.Battlefield; final int size = tgtCards.size(); for (int j = 0; j < size; j++) { @@ -1376,9 +1376,9 @@ public class AbilityFactoryPump { valid = this.params.get("ValidCards"); } - CardList comp = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList comp = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); comp = comp.getValidCards(valid, this.hostCard.getController(), this.hostCard); - CardList human = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); + CardList human = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); human = human.getValidCards(valid, this.hostCard.getController(), this.hostCard); final Target tgt = sa.getTarget(); @@ -1450,7 +1450,7 @@ public class AbilityFactoryPump { private void pumpAllResolve(final SpellAbility sa) { CardList list; ArrayList tgtPlayers = null; - final ArrayList affectedZones = new ArrayList(); + final ArrayList affectedZones = new ArrayList(); final Target tgt = sa.getTarget(); if (tgt != null) { @@ -1462,20 +1462,20 @@ public class AbilityFactoryPump { if (this.params.containsKey("PumpZone")) { for (final String zone : this.params.get("PumpZone").split(",")) { - affectedZones.add(Zone.valueOf(zone)); + affectedZones.add(ZoneType.valueOf(zone)); } } else { - affectedZones.add(Zone.Battlefield); + affectedZones.add(ZoneType.Battlefield); } list = new CardList(); if ((tgtPlayers == null) || tgtPlayers.isEmpty()) { - for (final Zone zone : affectedZones) { + for (final ZoneType zone : affectedZones) { list.addAll(AllZoneUtil.getCardsIn(zone)); } } else { - for (final Zone zone : affectedZones) { + for (final ZoneType zone : affectedZones) { list.addAll(tgtPlayers.get(0).getCardsIn(zone)); } } @@ -1495,7 +1495,7 @@ public class AbilityFactoryPump { // only pump things in the affected zones. boolean found = false; - for (final Zone z : affectedZones) { + for (final ZoneType z : affectedZones) { if (c.isInZone(z)) { found = true; break; diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryRegenerate.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryRegenerate.java index f45da204673..7db8eaa545e 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryRegenerate.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryRegenerate.java @@ -27,7 +27,6 @@ import forge.Card; import forge.CardList; import forge.CardListUtil; import forge.Command; -import forge.Constant.Zone; import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; import forge.card.cost.Cost; @@ -40,6 +39,7 @@ import forge.card.spellability.Target; import forge.game.phase.CombatUtil; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; +import forge.game.zone.ZoneType; /** *

@@ -289,7 +289,7 @@ public class AbilityFactoryRegenerate { } else { tgt.resetTargets(); // filter AIs battlefield by what I can target - CardList targetables = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList targetables = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); targetables = targetables.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), hostCard); if (targetables.size() == 0) { @@ -392,7 +392,7 @@ public class AbilityFactoryRegenerate { final Target tgt = sa.getTarget(); tgt.resetTargets(); // filter AIs battlefield by what I can target - CardList targetables = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList targetables = AllZoneUtil.getCardsIn(ZoneType.Battlefield); targetables = targetables.getValidCards(tgt.getValidTgts(), AllZone.getComputerPlayer(), hostCard); final CardList compTargetables = targetables.getController(AllZone.getComputerPlayer()); @@ -676,7 +676,7 @@ public class AbilityFactoryRegenerate { valid = params.get("ValidCards"); } - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = list.getValidCards(valid.split(","), hostCard.getController(), hostCard); if (list.size() == 0) { @@ -760,7 +760,7 @@ public class AbilityFactoryRegenerate { valid = params.get("ValidCards"); } - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = list.getValidCards(valid.split(","), hostCard.getController(), hostCard); for (final Card c : list) { diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java index 2628610975f..95961c30618 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryReveal.java @@ -31,8 +31,6 @@ import forge.Card; import forge.CardCharactersticName; import forge.CardList; import forge.CardUtil; -import forge.Constant; -import forge.Constant.Zone; import forge.GameActionUtil; import forge.Singletons; import forge.card.cost.Cost; @@ -45,7 +43,8 @@ import forge.card.spellability.Target; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.util.MyRandom; @@ -264,7 +263,7 @@ public final class AbilityFactoryReveal { } // return false if nothing to dig into - if (libraryOwner.getCardsIn(Constant.Zone.Library).isEmpty()) { + if (libraryOwner.getCardsIn(ZoneType.Library).isEmpty()) { return false; } @@ -332,10 +331,10 @@ public final class AbilityFactoryReveal { final Player player = sa.getActivatingPlayer(); Player choser = player; int numToDig = AbilityFactory.calculateAmount(af.getHostCard(), params.get("DigNum"), sa); - final Zone destZone1 = params.containsKey("DestinationZone") ? Zone.smartValueOf(params.get("DestinationZone")) - : Zone.Hand; - final Zone destZone2 = params.containsKey("DestinationZone2") ? Zone.smartValueOf(params - .get("DestinationZone2")) : Zone.Library; + final ZoneType destZone1 = params.containsKey("DestinationZone") ? ZoneType.smartValueOf(params.get("DestinationZone")) + : ZoneType.Hand; + final ZoneType destZone2 = params.containsKey("DestinationZone2") ? ZoneType.smartValueOf(params + .get("DestinationZone2")) : ZoneType.Library; final int libraryPosition = params.containsKey("LibraryPosition") ? Integer.parseInt(params .get("LibraryPosition")) : -1; @@ -386,7 +385,7 @@ public final class AbilityFactoryReveal { final CardList top = new CardList(); CardList valid = new CardList(); final CardList rest = new CardList(); - final PlayerZone library = p.getZone(Constant.Zone.Library); + final PlayerZone library = p.getZone(ZoneType.Library); numToDig = Math.min(numToDig, library.size()); for (int i = 0; i < numToDig; i++) { @@ -472,11 +471,11 @@ public final class AbilityFactoryReveal { continue; } final PlayerZone zone = c.getOwner().getZone(destZone1); - if (zone.is(Zone.Library)) { + if (zone.is(ZoneType.Library)) { Singletons.getModel().getGameAction().moveToLibrary(c, libraryPosition); } else { Singletons.getModel().getGameAction().moveTo(zone, c); - if (destZone1.equals(Zone.Battlefield) && params.containsKey("Tapped")) { + if (destZone1.equals(ZoneType.Battlefield) && params.containsKey("Tapped")) { c.setTapped(true); } } @@ -494,10 +493,10 @@ public final class AbilityFactoryReveal { // let user get choice Card chosen = null; String prompt = "Choose a card to put into the "; - if (destZone1.equals(Zone.Library) && (libraryPosition == -1)) { + if (destZone1.equals(ZoneType.Library) && (libraryPosition == -1)) { prompt = "Chose a card to put on the bottom of the "; } - if (destZone1.equals(Zone.Library) && (libraryPosition == 0)) { + if (destZone1.equals(ZoneType.Library) && (libraryPosition == 0)) { prompt = "Chose a card to put on top of the "; } if (anyNumber || optional) { @@ -510,12 +509,12 @@ public final class AbilityFactoryReveal { } valid.remove(chosen); final PlayerZone zone = chosen.getOwner().getZone(destZone1); - if (zone.is(Zone.Library)) { + if (zone.is(ZoneType.Library)) { // System.out.println("Moving to lib position: "+libraryPosition); Singletons.getModel().getGameAction().moveToLibrary(chosen, libraryPosition); } else { final Card c = Singletons.getModel().getGameAction().moveTo(zone, chosen); - if (destZone1.equals(Zone.Battlefield) && !keywords.isEmpty()) { + if (destZone1.equals(ZoneType.Battlefield) && !keywords.isEmpty()) { for (final String kw : keywords) { c.addExtrinsicKeyword(kw); } @@ -546,11 +545,11 @@ public final class AbilityFactoryReveal { break; } final PlayerZone zone = chosen.getOwner().getZone(destZone1); - if (zone.is(Zone.Library)) { + if (zone.is(ZoneType.Library)) { Singletons.getModel().getGameAction().moveToLibrary(chosen, libraryPosition); } else { final Card c = Singletons.getModel().getGameAction().moveTo(zone, chosen); - if (destZone1.equals(Zone.Battlefield) && !keywords.isEmpty()) { + if (destZone1.equals(ZoneType.Battlefield) && !keywords.isEmpty()) { for (final String kw : keywords) { chosen.addExtrinsicKeyword(kw); } @@ -577,7 +576,7 @@ public final class AbilityFactoryReveal { } // now, move the rest to destZone2 - if (destZone2.equals(Zone.Library)) { + if (destZone2.equals(ZoneType.Library)) { if (choser.isHuman()) { // put them in any order while (rest.size() > 0) { @@ -605,7 +604,7 @@ public final class AbilityFactoryReveal { Card c = rest.get(i); final PlayerZone toZone = c.getOwner().getZone(destZone2); c = Singletons.getModel().getGameAction().moveTo(toZone, c); - if (destZone2.equals(Zone.Battlefield) && !keywords.isEmpty()) { + if (destZone2.equals(ZoneType.Battlefield) && !keywords.isEmpty()) { for (final String kw : keywords) { c.addExtrinsicKeyword(kw); } @@ -632,7 +631,7 @@ public final class AbilityFactoryReveal { */ private static CardList sharesNameWithCardOnBattlefield(final CardList list) { final CardList toReturn = new CardList(); - final CardList play = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList play = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card c : list) { for (final Card p : play) { if (p.getName().equals(c.getName()) && !toReturn.contains(c)) { @@ -813,18 +812,18 @@ public final class AbilityFactoryReveal { sb.append(untilAmount > 1 ? "those cards" : "that card"); sb.append(" "); - if (found.equals(Constant.Zone.Hand)) { + if (found.equals(ZoneType.Hand)) { sb.append("into his or her hand "); } - if (revealed.equals(Constant.Zone.Graveyard)) { + if (revealed.equals(ZoneType.Graveyard)) { sb.append("and all other cards into his or her graveyard."); } - if (revealed.equals(Constant.Zone.Exile)) { + if (revealed.equals(ZoneType.Exile)) { sb.append("and exile all other cards revealed this way."); } } else { - if (revealed.equals(Constant.Zone.Hand)) { + if (revealed.equals(ZoneType.Hand)) { sb.append("all cards revealed this way into his or her hand"); } } @@ -872,7 +871,7 @@ public final class AbilityFactoryReveal { } // return false if nothing to dig into - if (libraryOwner.getCardsIn(Constant.Zone.Library).isEmpty()) { + if (libraryOwner.getCardsIn(ZoneType.Library).isEmpty()) { return false; } @@ -954,9 +953,9 @@ public final class AbilityFactoryReveal { tgtPlayers = AbilityFactory.getDefinedPlayers(host, params.get("Defined"), sa); } - final Zone foundDest = Zone.smartValueOf(params.get("FoundDestination")); + final ZoneType foundDest = ZoneType.smartValueOf(params.get("FoundDestination")); final int foundLibPos = AbilityFactory.calculateAmount(host, params.get("FoundLibraryPosition"), sa); - final Zone revealedDest = Zone.smartValueOf(params.get("RevealedDestination")); + final ZoneType revealedDest = ZoneType.smartValueOf(params.get("RevealedDestination")); final int revealedLibPos = AbilityFactory.calculateAmount(host, params.get("RevealedLibraryPosition"), sa); for (final Player p : tgtPlayers) { @@ -964,7 +963,7 @@ public final class AbilityFactoryReveal { final CardList found = new CardList(); final CardList revealed = new CardList(); - final PlayerZone library = p.getZone(Constant.Zone.Library); + final PlayerZone library = p.getZone(ZoneType.Library); final int maxToDig = maxRevealed != null ? maxRevealed : library.size(); @@ -991,7 +990,7 @@ public final class AbilityFactoryReveal { final Iterator itr = found.iterator(); while (itr.hasNext()) { final Card c = itr.next(); - if (params.containsKey("GainControl") && foundDest.equals(Zone.Battlefield)) { + if (params.containsKey("GainControl") && foundDest.equals(ZoneType.Battlefield)) { c.addController(af.getHostCard()); Singletons.getModel().getGameAction().moveTo(c.getController().getZone(foundDest), c); } else { @@ -1256,7 +1255,7 @@ public final class AbilityFactoryReveal { final boolean mandatory) { final Target tgt = sa.getTarget(); - final int humanHandSize = AllZone.getHumanPlayer().getCardsIn(Zone.Hand).size(); + final int humanHandSize = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand).size(); if (tgt != null) { // ability is targeted @@ -1332,7 +1331,7 @@ public final class AbilityFactoryReveal { for (final Player p : tgtPlayers) { if ((tgt == null) || p.canBeTargetedBy(sa)) { - final CardList hand = p.getCardsIn(Zone.Hand); + final CardList hand = p.getCardsIn(ZoneType.Hand); if (sa.getActivatingPlayer().isHuman()) { if (hand.size() > 0) { GuiUtils.chooseOne(p + "'s hand", hand.toArray()); @@ -1897,7 +1896,7 @@ public final class AbilityFactoryReveal { */ private static void rearrangeTopOfLibrary(final Card src, final Player player, final int numCards, final boolean mayshuffle) { - final PlayerZone lib = player.getZone(Constant.Zone.Library); + final PlayerZone lib = player.getZone(ZoneType.Library); int maxCards = lib.size(); maxCards = Math.min(maxCards, numCards); if (maxCards == 0) { @@ -2218,7 +2217,7 @@ public final class AbilityFactoryReveal { for (final Player p : tgtPlayers) { if ((tgt == null) || p.canBeTargetedBy(sa)) { - final CardList handChoices = p.getCardsIn(Zone.Hand); + final CardList handChoices = p.getCardsIn(ZoneType.Hand); if (handChoices.size() > 0) { final CardList revealed = new CardList(); if (params.containsKey("Random")) { diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactorySacrifice.java b/src/main/java/forge/card/abilityfactory/AbilityFactorySacrifice.java index b2424eaaf4e..733efe1fa40 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactorySacrifice.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactorySacrifice.java @@ -25,8 +25,6 @@ import forge.AllZone; import forge.AllZoneUtil; import forge.Card; import forge.CardList; -import forge.Constant; -import forge.Constant.Zone; import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; import forge.card.cost.Cost; @@ -38,6 +36,7 @@ import forge.card.spellability.SpellAbility; import forge.card.spellability.Target; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.util.MyRandom; @@ -256,7 +255,7 @@ public class AbilityFactorySacrifice { num = (num == null) ? "1" : num; final int amount = AbilityFactory.calculateAmount(sa.getSourceCard(), num, sa); - CardList list = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); + CardList list = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); list = list.getValidCards(valid.split(","), sa.getActivatingPlayer(), sa.getSourceCard()); if (list.size() == 0) { @@ -393,9 +392,9 @@ public class AbilityFactorySacrifice { amount = Math.min(ComputerUtil.determineLeftoverMana(sa), amount); } - CardList humanList = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); + CardList humanList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); humanList = humanList.getValidCards(valid.split(","), sa.getActivatingPlayer(), sa.getSourceCard()); - CardList computerList = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList computerList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); computerList = computerList.getValidCards(valid.split(","), sa.getActivatingPlayer(), sa.getSourceCard()); @@ -452,7 +451,7 @@ public class AbilityFactorySacrifice { final boolean remSacrificed = params.containsKey("RememberSacrificed"); if (valid.equals("Self")) { - if (AllZone.getZoneOf(card).is(Constant.Zone.Battlefield)) { + if (AllZone.getZoneOf(card).is(ZoneType.Battlefield)) { Singletons.getModel().getGameAction().sacrifice(card); if (remSacrificed) { card.addRemembered(card); @@ -497,7 +496,7 @@ public class AbilityFactorySacrifice { */ private static CardList sacrificeAI(final Player p, final int amount, final String valid, final SpellAbility sa, final boolean destroy) { - CardList battlefield = p.getCardsIn(Zone.Battlefield); + CardList battlefield = p.getCardsIn(ZoneType.Battlefield); CardList sacList = AbilityFactory.filterListByType(battlefield, valid, sa); sacList = ComputerUtil.sacrificePermanents(amount, sacList, destroy); @@ -522,7 +521,7 @@ public class AbilityFactorySacrifice { */ private static CardList sacrificeHuman(final Player p, final int amount, final String valid, final SpellAbility sa, final boolean destroy, final boolean optional) { - CardList battlefield = p.getCardsIn(Zone.Battlefield); + CardList battlefield = p.getCardsIn(ZoneType.Battlefield); CardList list = AbilityFactory.filterListByType(battlefield, valid, sa); CardList sacList = new CardList(); @@ -749,8 +748,8 @@ public class AbilityFactorySacrifice { valid = valid.replace("X", Integer.toString(xPay)); } - CardList humanlist = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); - CardList computerlist = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList humanlist = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); + CardList computerlist = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); humanlist = humanlist.getValidCards(valid.split(","), source.getController(), source); computerlist = computerlist.getValidCards(valid.split(","), source.getController(), source); @@ -826,7 +825,7 @@ public class AbilityFactorySacrifice { if (params.containsKey("Defined")) { list = new CardList(AbilityFactory.getDefinedCards(af.getHostCard(), params.get("Defined"), sa)); } else { - list = AllZoneUtil.getCardsIn(Zone.Battlefield); + list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); } final boolean remSacrificed = params.containsKey("RememberSacrificed"); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactorySetState.java b/src/main/java/forge/card/abilityfactory/AbilityFactorySetState.java index c2a914d46d7..aace76af7c8 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactorySetState.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactorySetState.java @@ -26,13 +26,13 @@ import forge.AllZoneUtil; import forge.Card; import forge.CardCharactersticName; import forge.CardList; -import forge.Constant.Zone; import forge.card.spellability.AbilityActivated; import forge.card.spellability.AbilitySub; import forge.card.spellability.Spell; import forge.card.spellability.SpellAbility; import forge.card.spellability.Target; import forge.game.player.Player; +import forge.game.zone.ZoneType; /** * AbilityFactory for abilities that cause cards to change states. @@ -403,7 +403,7 @@ public class AbilityFactorySetState { valid = valid.replace("X", Integer.toString(AbilityFactory.calculateAmount(card, "X", sa))); } - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); if (targetPlayer != null) { list = list.getController(targetPlayer); diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryToken.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryToken.java index 519ba908fa8..48df612efa7 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryToken.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryToken.java @@ -25,7 +25,6 @@ import forge.AllZone; import forge.AllZoneUtil; import forge.Card; import forge.CardList; -import forge.Constant.Zone; import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; import forge.card.cost.Cost; @@ -40,6 +39,7 @@ import forge.card.trigger.TriggerHandler; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.util.MyRandom; /** @@ -274,7 +274,7 @@ public class AbilityFactoryToken extends AbilityFactory { for (final String type : this.tokenTypes) { if (type.equals("Legendary")) { // Don't kill AIs Legendary tokens - if (AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield, this.tokenName).size() > 0) { + if (AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield, this.tokenName).size() > 0) { return false; } } diff --git a/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java b/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java index fa41b576a77..0c2cfa0c6c9 100644 --- a/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java +++ b/src/main/java/forge/card/abilityfactory/AbilityFactoryZoneAffecting.java @@ -27,8 +27,6 @@ import forge.Card; import forge.CardList; import forge.CardListUtil; import forge.CardUtil; -import forge.Constant; -import forge.Constant.Zone; import forge.GameActionUtil; import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; @@ -42,6 +40,7 @@ import forge.card.spellability.Target; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.util.MyRandom; @@ -350,13 +349,13 @@ public class AbilityFactoryZoneAffecting { final HashMap params = af.getMapParams(); final Card source = sa.getSourceCard(); - int computerHandSize = AllZone.getComputerPlayer().getCardsIn(Constant.Zone.Hand).size(); - final int humanLibrarySize = AllZone.getHumanPlayer().getCardsIn(Constant.Zone.Library).size(); - final int computerLibrarySize = AllZone.getComputerPlayer().getCardsIn(Constant.Zone.Library).size(); + int computerHandSize = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand).size(); + final int humanLibrarySize = AllZone.getHumanPlayer().getCardsIn(ZoneType.Library).size(); + final int computerLibrarySize = AllZone.getComputerPlayer().getCardsIn(ZoneType.Library).size(); final int computerMaxHandSize = AllZone.getComputerPlayer().getMaxHandSize(); //if a spell is used don't count the card - if (sa.isSpell() && source.isInZone(Constant.Zone.Hand)) { + if (sa.isSpell() && source.isInZone(ZoneType.Hand)) { computerHandSize -= 1; } @@ -544,7 +543,7 @@ public class AbilityFactoryZoneAffecting { if ((tgt == null) || p.canBeTargetedBy(sa)) { if (optional) { if (p.isComputer()) { - if (numCards >= p.getCardsIn(Zone.Library).size()) { + if (numCards >= p.getCardsIn(ZoneType.Library).size()) { // AI shouldn't itself continue; } @@ -735,12 +734,12 @@ public class AbilityFactoryZoneAffecting { sb.append(p.toString()).append(" "); } - final Zone dest = Zone.smartValueOf(params.get("Destination")); - if ((dest == null) || dest.equals(Zone.Graveyard)) { + final ZoneType dest = ZoneType.smartValueOf(params.get("Destination")); + if ((dest == null) || dest.equals(ZoneType.Graveyard)) { sb.append("mills "); - } else if (dest.equals(Zone.Exile)) { + } else if (dest.equals(ZoneType.Exile)) { sb.append("exiles "); - } else if (dest.equals(Zone.Ante)) { + } else if (dest.equals(ZoneType.Ante)) { sb.append("antes "); } sb.append(numCards); @@ -834,7 +833,7 @@ public class AbilityFactoryZoneAffecting { if (params.get("NumCards").equals("X") && source.getSVar("X").equals("Count$xPaid")) { // Set PayX here to maximum value. final int cardsToDiscard = Math.min(ComputerUtil.determineLeftoverMana(sa), AllZone.getHumanPlayer() - .getCardsIn(Constant.Zone.Library).size()); + .getCardsIn(ZoneType.Library).size()); source.setSVar("PayX", Integer.toString(cardsToDiscard)); if (cardsToDiscard <= 0) { return false; @@ -873,7 +872,7 @@ public class AbilityFactoryZoneAffecting { final int numCards = AbilityFactory.calculateAmount(sa.getSourceCard(), params.get("NumCards"), sa); - final CardList pLibrary = AllZone.getHumanPlayer().getCardsIn(Constant.Zone.Library); + final CardList pLibrary = AllZone.getHumanPlayer().getCardsIn(ZoneType.Library); if (pLibrary.size() == 0) { // deck already empty, no need to mill if (!mandatory) { @@ -940,7 +939,7 @@ public class AbilityFactoryZoneAffecting { if (params.get("NumCards").equals("X") && source.getSVar("X").equals("Count$xPaid")) { // Set PayX here to maximum value. final int cardsToDiscard = Math.min(ComputerUtil.determineLeftoverMana(sa), AllZone.getHumanPlayer() - .getCardsIn(Constant.Zone.Library).size()); + .getCardsIn(ZoneType.Library).size()); source.setSVar("PayX", Integer.toString(cardsToDiscard)); } @@ -978,9 +977,9 @@ public class AbilityFactoryZoneAffecting { tgtPlayers = AbilityFactory.getDefinedPlayers(sa.getSourceCard(), params.get("Defined"), sa); } - Zone destination = Zone.smartValueOf(params.get("Destination")); + ZoneType destination = ZoneType.smartValueOf(params.get("Destination")); if (destination == null) { - destination = Constant.Zone.Graveyard; + destination = ZoneType.Graveyard; } for (final Player p : tgtPlayers) { @@ -1203,7 +1202,7 @@ public class AbilityFactoryZoneAffecting { p.discardUnless(numCards, params.get("UnlessType"), sa); } else if (mode.equals("RevealDiscardAll")) { // Reveal - final CardList dPHand = p.getCardsIn(Zone.Hand); + final CardList dPHand = p.getCardsIn(ZoneType.Hand); if (p.isHuman()) { // "reveal to computer" for information gathering @@ -1229,7 +1228,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(Zone.Hand); + CardList dPHand = p.getCardsIn(ZoneType.Hand); if (dPHand.size() != 0) { if (params.containsKey("RevealNumber")) { String amountString = params.get("RevealNumber"); @@ -1450,7 +1449,7 @@ public class AbilityFactoryZoneAffecting { } - final boolean humanHasHand = AllZone.getHumanPlayer().getCardsIn(Constant.Zone.Hand).size() > 0; + final boolean humanHasHand = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand).size() > 0; if (tgt != null) { if (!AbilityFactoryZoneAffecting.discardTargetAI(af, sa)) { @@ -1483,7 +1482,7 @@ public class AbilityFactoryZoneAffecting { if (params.get("NumCards").equals("X") && source.getSVar("X").equals("Count$xPaid")) { // Set PayX here to maximum value. final int cardsToDiscard = Math.min(ComputerUtil.determineLeftoverMana(sa), AllZone.getHumanPlayer() - .getCardsIn(Constant.Zone.Hand).size()); + .getCardsIn(ZoneType.Hand).size()); source.setSVar("PayX", Integer.toString(cardsToDiscard)); } } @@ -1538,7 +1537,7 @@ public class AbilityFactoryZoneAffecting { */ private static boolean discardTargetAI(final AbilityFactory af, final SpellAbility sa) { final Target tgt = sa.getTarget(); - if (AllZone.getHumanPlayer().getCardsIn(Constant.Zone.Hand).size() < 1) { + if (AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand).size() < 1) { return false; } if (tgt != null) { diff --git a/src/main/java/forge/card/cardfactory/AbstractCardFactory.java b/src/main/java/forge/card/cardfactory/AbstractCardFactory.java index 6b2cc867cb0..f03d3ea5d61 100644 --- a/src/main/java/forge/card/cardfactory/AbstractCardFactory.java +++ b/src/main/java/forge/card/cardfactory/AbstractCardFactory.java @@ -37,8 +37,6 @@ import forge.CardList; import forge.CardListFilter; import forge.CardUtil; import forge.Command; -import forge.Constant; -import forge.Constant.Zone; import forge.Counters; import forge.GameActionUtil; import forge.Singletons; @@ -56,7 +54,8 @@ import forge.control.input.InputPayManaCost; import forge.game.GameLossReason; import forge.game.player.ComputerUtil; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.properties.ForgeProps; import forge.properties.NewConstants; @@ -602,8 +601,8 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { @Override public boolean canPlay() { - final CardList grave = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard); - final CardList aiGrave = AllZone.getComputerPlayer().getCardsIn(Zone.Graveyard); + final CardList grave = AllZone.getHumanPlayer().getCardsIn(ZoneType.Graveyard); + final CardList aiGrave = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard); return ((grave.getType("Creature").size() > 1) || (aiGrave.getType("Creature").size() > 1)) && super.canPlay(); } @@ -615,8 +614,8 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { @Override public void showMessage() { - CardList grave = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard); - CardList aiGrave = AllZone.getComputerPlayer().getCardsIn(Zone.Graveyard); + CardList grave = AllZone.getHumanPlayer().getCardsIn(ZoneType.Graveyard); + CardList aiGrave = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard); grave = grave.getType("Creature"); aiGrave = aiGrave.getType("Creature"); @@ -639,9 +638,9 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { CardList newGrave; final Card c = (Card) o; if (c.getOwner().isHuman()) { - newGrave = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard); + newGrave = AllZone.getHumanPlayer().getCardsIn(ZoneType.Graveyard); } else { - newGrave = AllZone.getComputerPlayer().getCardsIn(Zone.Graveyard); + newGrave = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard); } newGrave = newGrave.getType("Creature"); @@ -691,7 +690,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (zone.is(Constant.Zone.Hand) && c.isLand()) { + if (zone.is(ZoneType.Hand) && c.isLand()) { AllZone.getHumanPlayer().discard(c, null); this.stop(); } else if (c.equals(card)) { @@ -705,13 +704,13 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { @Override public void resolve() { if (card.getController().isHuman()) { - if (AllZone.getHumanPlayer().getZone(Zone.Hand).isEmpty()) { + if (AllZone.getHumanPlayer().getZone(ZoneType.Hand).isEmpty()) { Singletons.getModel().getGameAction().sacrifice(card); } else { AllZone.getInputControl().setInput(discard); } } else { - CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); list = list.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -748,7 +747,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { @Override public boolean canPlay() { - CardList list = card.getController().getCardsIn(Zone.Hand); + CardList list = card.getController().getCardsIn(ZoneType.Hand); list.remove(card); list = list.filter(new CardListFilter() { @Override @@ -796,7 +795,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { @Override public void resolve() { - final CardList topOfLibrary = card.getController().getCardsIn(Zone.Library); + final CardList topOfLibrary = card.getController().getCardsIn(ZoneType.Library); final CardList revealed = new CardList(); if (topOfLibrary.size() == 0) { @@ -880,7 +879,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { final int limit = 4; // at most, this can target 4 cards final Player player = this.getTargetPlayer(); - CardList lands = player.getCardsIn(Zone.Graveyard); + CardList lands = player.getCardsIn(ZoneType.Graveyard); lands = lands.filter(CardListFilter.BASIC_LANDS); if (card.getController().isHuman()) { // now, select up to four lands @@ -925,7 +924,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { } private CardList getComputerLands() { - final CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Graveyard); + final CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard); return list.getType("Basic"); } }; // ability @@ -948,7 +947,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { @Override public boolean canPlayAI() { - final CardList libList = AllZone.getHumanPlayer().getCardsIn(Zone.Library); + final CardList libList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Library); // CardList list = // AllZoneUtil.getCardsInPlay("Painter's Servant"); return libList.size() > 0; // && list.size() > 0; @@ -957,7 +956,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { @Override public void resolve() { final Player target = this.getTargetPlayer(); - final CardList library = this.getTargetPlayer().getCardsIn(Zone.Library); + final CardList library = this.getTargetPlayer().getCardsIn(ZoneType.Library); boolean loop = true; final CardList grinding = new CardList(); @@ -1068,7 +1067,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (zone.is(Constant.Zone.Hand, AllZone.getHumanPlayer()) && !this.exiled.contains(c)) { + if (zone.is(ZoneType.Hand, AllZone.getHumanPlayer()) && !this.exiled.contains(c)) { this.exiled.add(c); this.showMessage(); } @@ -1083,7 +1082,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { // Put that many cards from the top of your // library into your hand. // Ruling: This is not a draw... - final PlayerZone lib = AllZone.getHumanPlayer().getZone(Constant.Zone.Library); + final PlayerZone lib = AllZone.getHumanPlayer().getZone(ZoneType.Library); int numCards = 0; while ((lib.size() > 0) && (numCards < this.exiled.size())) { Singletons.getModel().getGameAction().moveToHand(lib.get(0)); @@ -1143,7 +1142,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { @Override public boolean canPlay() { - final PlayerZone lib = card.getController().getZone(Constant.Zone.Library); + final PlayerZone lib = card.getController().getZone(ZoneType.Library); return super.canPlay() && ((lib.size() > 0) && lib.get(0).equals(topCard[0])); } @@ -1186,7 +1185,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { @Override public void resolve() { - final PlayerZone lib = card.getController().getZone(Constant.Zone.Library); + final PlayerZone lib = card.getController().getZone(ZoneType.Library); if (lib.size() > 0) { // shuffle your library @@ -1356,7 +1355,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { @Override public void resolve() { if (card.getController().isComputer()) { - final CardList cards = AllZoneUtil.getCardsIn(Constant.Zone.Battlefield).getType("Artifact"); + final CardList cards = AllZoneUtil.getCardsIn(ZoneType.Battlefield).getType("Artifact"); if (!cards.isEmpty()) { copyTarget[0] = CardFactoryUtil.getBestAI(cards); } @@ -1432,7 +1431,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { @Override public void selectCard(final Card c, final PlayerZone z) { - if (z.is(Constant.Zone.Battlefield) && c.isArtifact()) { + if (z.is(ZoneType.Battlefield) && c.isArtifact()) { copyTarget[0] = c; this.stopSetNext(new InputPayManaCost(copy)); } @@ -1465,7 +1464,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { @Override public void showMessage() { - if (AllZone.getHumanPlayer().getZone(Constant.Zone.Hand).size() == 0) { + if (AllZone.getHumanPlayer().getZone(ZoneType.Hand).size() == 0) { this.stop(); } Singletons.getControl().getControlMatch().showMessage(prompt); @@ -1474,7 +1473,7 @@ public abstract class AbstractCardFactory implements CardFactoryInterface { @Override public void selectCard(final Card card, final PlayerZone zone) { - if (zone.is(Constant.Zone.Hand) && card.getDrawnThisTurn()) { + if (zone.is(ZoneType.Hand) && card.getDrawnThisTurn()) { if (player.canPayLife(4) && GameActionUtil.showYesNoDialog(card, cardQuestion)) { player.payLife(4, card); // card stays in hand diff --git a/src/main/java/forge/card/cardfactory/CardFactoryAuras.java b/src/main/java/forge/card/cardfactory/CardFactoryAuras.java index 7bcc37d8cf9..2dcc35a41fc 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryAuras.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryAuras.java @@ -30,8 +30,6 @@ import forge.CardListFilter; import forge.CardListUtil; import forge.CardUtil; import forge.Command; -import forge.Constant; -import forge.Constant.Zone; import forge.Singletons; import forge.card.cost.Cost; import forge.card.spellability.Ability; @@ -40,7 +38,8 @@ import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellPermanent; import forge.card.spellability.Target; import forge.control.input.Input; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; /** @@ -368,7 +367,7 @@ class CardFactoryAuras { @Override public boolean canPlayAI() { - final CardList stuffy = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield, "Stuffy Doll"); + final CardList stuffy = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield, "Stuffy Doll"); if (stuffy.size() > 0) { this.setTargetCard(stuffy.get(0)); @@ -423,7 +422,7 @@ class CardFactoryAuras { // This includes creatures Animate Dead can't enchant once // in play. // The human may try to Animate them, the AI will not. - return AllZoneUtil.getCardsIn(Zone.Graveyard).filter(CardListFilter.CREATURES); + return AllZoneUtil.getCardsIn(ZoneType.Graveyard).filter(CardListFilter.CREATURES); } @Override @@ -458,18 +457,18 @@ class CardFactoryAuras { // Target AbCost and Restriction are set here to get this working as // expected final Target tgt = new Target(card, "Select a creature in a graveyard", "Creature".split(",")); - tgt.setZone(Constant.Zone.Graveyard); + tgt.setZone(ZoneType.Graveyard); animate.setTarget(tgt); final Cost cost = new Cost(card, "1 B", false); animate.setPayCosts(cost); - animate.getRestrictions().setZone(Constant.Zone.Hand); + animate.getRestrictions().setZone(ZoneType.Hand); final Ability attach = new Ability(card, "0") { @Override public void resolve() { - final PlayerZone play = card.getController().getZone(Constant.Zone.Battlefield); + final PlayerZone play = card.getController().getZone(ZoneType.Battlefield); // Animate Dead got destroyed before its ability resolved if (!play.contains(card)) { @@ -479,7 +478,7 @@ class CardFactoryAuras { final Card animated = targetC[0]; final PlayerZone grave = AllZone.getZoneOf(animated); - if (!grave.is(Constant.Zone.Graveyard)) { + if (!grave.is(ZoneType.Graveyard)) { // Animated Creature got removed before ability resolved Singletons.getModel().getGameAction().sacrifice(card); return; @@ -532,7 +531,7 @@ class CardFactoryAuras { public void resolve() { final Card c = targetC[0]; - final PlayerZone play = card.getController().getZone(Constant.Zone.Battlefield); + final PlayerZone play = card.getController().getZone(ZoneType.Battlefield); if (play.contains(c)) { Singletons.getModel().getGameAction().sacrifice(c); @@ -547,7 +546,7 @@ class CardFactoryAuras { public void execute() { final Card c = targetC[0]; - final PlayerZone play = card.getController().getZone(Constant.Zone.Battlefield); + final PlayerZone play = card.getController().getZone(ZoneType.Battlefield); if (play.contains(c)) { AllZone.getStack().addSimultaneousStackEntry(detach); diff --git a/src/main/java/forge/card/cardfactory/CardFactoryCreatures.java b/src/main/java/forge/card/cardfactory/CardFactoryCreatures.java index 37fda069da1..c1dc6666b01 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryCreatures.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryCreatures.java @@ -34,7 +34,6 @@ import forge.CardListFilter; import forge.CardUtil; import forge.Command; import forge.Constant; -import forge.Constant.Zone; import forge.Counters; import forge.GameActionUtil; import forge.Singletons; @@ -52,7 +51,8 @@ import forge.card.trigger.TriggerType; import forge.control.input.Input; import forge.control.input.InputPayManaCost; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.util.MyRandom; import forge.view.ButtonUtil; @@ -191,7 +191,7 @@ public class CardFactoryCreatures { @Override public boolean canPlayAI() { - final CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + final CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); return list.containsName("Glorious Anthem") || list.containsName("Gaea's Anthem"); } @@ -228,7 +228,7 @@ public class CardFactoryCreatures { @Override public void chooseTargetAI() { - CardList perms = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList perms = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); perms = perms.getTargetableCards(this).filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -241,7 +241,7 @@ public class CardFactoryCreatures { @Override public boolean canPlayAI() { - CardList perms = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList perms = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); perms = perms.getTargetableCards(this).filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -317,13 +317,13 @@ public class CardFactoryCreatures { @Override public boolean canPlayAI() { int reqHand = 1; - if (AllZone.getZoneOf(card).is(Constant.Zone.Hand)) { + if (AllZone.getZoneOf(card).is(ZoneType.Hand)) { reqHand++; } // Don't play if it would sacrifice as soon as it comes into // play - return AllZone.getComputerPlayer().getCardsIn(Constant.Zone.Hand).size() > reqHand; + return AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand).size() > reqHand; } }; card.clearFirstSpell(); @@ -333,7 +333,7 @@ public class CardFactoryCreatures { @Override public void resolve() { - final CardList hand = card.getController().getCardsIn(Zone.Hand); + final CardList hand = card.getController().getCardsIn(ZoneType.Hand); if (hand.size() == 0) { Singletons.getModel().getGameAction().sacrifice(card); } else { @@ -369,7 +369,7 @@ public class CardFactoryCreatures { public void execute() { if (card.getController().isHuman()) { - final CardList artifacts = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield) + final CardList artifacts = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield) .getType("Artifact"); if (artifacts.size() != 0) { @@ -382,7 +382,7 @@ public class CardFactoryCreatures { } } else { // computer - CardList art = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList art = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); art = art.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -417,8 +417,8 @@ public class CardFactoryCreatures { @Override public boolean canPlayAI() { - return (!AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield).getType("Artifact").isEmpty() && AllZone - .getZoneOf(this.getSourceCard()).is(Constant.Zone.Hand)); + return (!AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield).getType("Artifact").isEmpty() && AllZone + .getZoneOf(this.getSourceCard()).is(ZoneType.Hand)); } }); card.addComesIntoPlayCommand(intoPlay); @@ -433,7 +433,7 @@ public class CardFactoryCreatures { // TODO - this needs to be targeted final Player opp = card.getController().getOpponent(); - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = list.getValidCards("Card.Other+YouCtrl".split(","), card.getController(), card); for (final Card c : list) { @@ -465,7 +465,7 @@ public class CardFactoryCreatures { final SpellAbility ability = new Ability(card, "2") { @Override public boolean canPlay() { - CardList possible = card.getController().getCardsIn(Zone.Hand); + CardList possible = card.getController().getCardsIn(ZoneType.Hand); possible = possible.filter(CardListFilter.NON_LANDS); return !possible.isEmpty() && super.canPlay(); } @@ -494,7 +494,7 @@ public class CardFactoryCreatures { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (zone.is(Constant.Zone.Hand) && !c.isLand()) { + if (zone.is(ZoneType.Hand) && !c.isLand()) { Singletons.getModel().getGameAction().exile(c); chosen.push(c); final StringBuilder sb = new StringBuilder(); @@ -567,7 +567,7 @@ public class CardFactoryCreatures { return; } - if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.canBeTargetedBy(ability)) { + if (c.isLand() && zone.is(ZoneType.Battlefield) && c.canBeTargetedBy(ability)) { // System.out.println("c is: " +c); target[index[0]] = c; index[0]++; @@ -622,9 +622,9 @@ public class CardFactoryCreatures { // 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(); - list.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Library)); - list.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Hand)); - list.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield)); + list.addAll(AllZone.getComputerPlayer().getCardsIn(ZoneType.Library)); + list.addAll(AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand)); + list.addAll(AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield)); color[0] = Constant.Color.WHITE; int max = list.getKeywordsContain(color[0]).size(); @@ -705,7 +705,7 @@ public class CardFactoryCreatures { @Override public void execute() { - final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield, "Stangg Twin"); + final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Stangg Twin"); if (list.size() == 1) { Singletons.getModel().getGameAction().exile(list.get(0)); @@ -766,7 +766,7 @@ public class CardFactoryCreatures { lifeGain = CardFactoryUtil.getNumberOfPermanentsByColor((String) o); } else { - final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); final String color = CardFactoryUtil.getMostProminentColor(list); lifeGain = CardFactoryUtil.getNumberOfPermanentsByColor(color); } @@ -795,7 +795,7 @@ public class CardFactoryCreatures { @Override public void resolve() { final Player player = card.getController(); - final PlayerZone lib = player.getZone(Constant.Zone.Library); + final PlayerZone lib = player.getZone(ZoneType.Library); if (lib.size() < 1) { return; @@ -831,7 +831,7 @@ public class CardFactoryCreatures { @Override public boolean canPlayAI() { - CardList wolves = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList wolves = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); wolves = wolves.getType("Wolf"); wolves = wolves.filter(new CardListFilter() { @@ -851,7 +851,7 @@ public class CardFactoryCreatures { final int totalPower = power; - CardList targetables = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); + CardList targetables = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); targetables = targetables.getTargetableCards(this).filter(new CardListFilter() { @Override @@ -872,7 +872,7 @@ public class CardFactoryCreatures { @Override public void resolve() { - CardList wolves = card.getController().getCardsIn(Zone.Battlefield); + CardList wolves = card.getController().getCardsIn(ZoneType.Battlefield); wolves = wolves.getType("Wolf"); wolves = wolves.filter(new CardListFilter() { @@ -1104,7 +1104,7 @@ public class CardFactoryCreatures { if (card.getName().equals("Academy Rector")) { Singletons.getModel().getGameAction().exile(card); } - CardList list = AllZone.getHumanPlayer().getCardsIn(Zone.Library); + CardList list = AllZone.getHumanPlayer().getCardsIn(ZoneType.Library); list = list.getType("Enchantment"); if (list.size() > 0) { @@ -1163,7 +1163,7 @@ public class CardFactoryCreatures { message[0] = "Select an enchantment"; } - final CardList allCards = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList allCards = AllZoneUtil.getCardsIn(ZoneType.Battlefield); // Make sure that we were able to match // the selected aura with our list of @@ -1214,7 +1214,7 @@ public class CardFactoryCreatures { // player is the computer else { - CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Library); + CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Library); list = list.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -1277,7 +1277,7 @@ public class CardFactoryCreatures { } // resolve() public int countKithkin() { - CardList kithkin = card.getController().getCardsIn(Zone.Battlefield); + CardList kithkin = card.getController().getCardsIn(ZoneType.Battlefield); kithkin = kithkin.filter(new CardListFilter() { @Override @@ -1383,7 +1383,7 @@ public class CardFactoryCreatures { public boolean canPlayAI() { // Dark Depths: - CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield, "Dark Depths"); + CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield, "Dark Depths"); list = list.filter(new CardListFilter() { @Override public boolean addCard(final Card crd) { @@ -1397,7 +1397,7 @@ public class CardFactoryCreatures { } // Get rid of Planeswalkers: - list = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); + list = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); list = list.filter(new CardListFilter() { @Override public boolean addCard(final Card crd) { @@ -1440,7 +1440,7 @@ public class CardFactoryCreatures { int intermSumPower = 0; int intermSumToughness = 0; // intermSumPower = intermSumToughness = 0; - CardList creats = card.getController().getCardsIn(Zone.Graveyard); + CardList creats = card.getController().getCardsIn(ZoneType.Graveyard); creats = creats.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -1473,7 +1473,7 @@ public class CardFactoryCreatures { count++; } // is this needed? - AllZone.getComputerPlayer().getZone(Zone.Battlefield).updateObservers(); + AllZone.getComputerPlayer().getZone(ZoneType.Battlefield).updateObservers(); } numCreatures[0] = count; } @@ -1493,7 +1493,7 @@ public class CardFactoryCreatures { @Override public boolean canPlayAI() { // get all creatures - CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Graveyard); + CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard); list = list.filter(CardListFilter.CREATURES); return 0 < list.size(); } @@ -1516,12 +1516,12 @@ public class CardFactoryCreatures { final Player player = card.getController(); final Player opp = player.getOpponent(); int max = 0; - CardList play = opp.getCardsIn(Zone.Battlefield); + CardList play = opp.getCardsIn(ZoneType.Battlefield); play = play.filter(CardListFilter.NON_TOKEN); play = play.filter(CardListFilter.WHITE); max += play.size(); - CardList grave = opp.getCardsIn(Zone.Graveyard); + CardList grave = opp.getCardsIn(ZoneType.Graveyard); grave = grave.filter(CardListFilter.WHITE); max += grave.size(); @@ -1653,7 +1653,7 @@ public class CardFactoryCreatures { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (zone.is(Constant.Zone.Battlefield, ability.getTargetPlayer()) && !targetPerms.contains(c)) { + if (zone.is(ZoneType.Battlefield, ability.getTargetPlayer()) && !targetPerms.contains(c)) { if (c.canBeTargetedBy(ability)) { targetPerms.add(c); } @@ -1745,7 +1745,7 @@ public class CardFactoryCreatures { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (c.isCreature() && zone.is(Constant.Zone.Battlefield, AllZone.getHumanPlayer()) + if (c.isCreature() && zone.is(ZoneType.Battlefield, AllZone.getHumanPlayer()) && !toSac.contains(c)) { toSac.add(c); } @@ -1958,7 +1958,7 @@ public class CardFactoryCreatures { @Override public void selectCard(final Card c, final PlayerZone z) { - if (z.is(Constant.Zone.Battlefield) + if (z.is(ZoneType.Battlefield) && (c.isCreature() || (cardName.equals("Phyrexian Metamorph") && c.isArtifact()))) { if (cardName.equals("Jwari Shapeshifter") && !c.isType("Ally")) { return; @@ -1975,7 +1975,7 @@ public class CardFactoryCreatures { @Override public void showMessage() { final String message = "Select a creature in a graveyard"; - final CardList choices = AllZoneUtil.getCardsIn(Zone.Graveyard); + final CardList choices = AllZoneUtil.getCardsIn(ZoneType.Graveyard); final Object o = GuiUtils.chooseOneOrNone(message, choices.toArray()); if (null == o) { this.stop(); @@ -2019,7 +2019,7 @@ 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(Zone.Hand); + final CardList hand = this.getTargetPlayer().getCardsIn(ZoneType.Hand); int numCards = card.getXManaCostPaid(); numCards = Math.min(hand.size(), numCards); diff --git a/src/main/java/forge/card/cardfactory/CardFactoryInstants.java b/src/main/java/forge/card/cardfactory/CardFactoryInstants.java index 945ce6f95f5..6e8bf91b79c 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryInstants.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryInstants.java @@ -23,8 +23,6 @@ import forge.Card; import forge.CardList; import forge.CardListFilter; import forge.Command; -import forge.Constant; -import forge.Constant.Zone; import forge.Singletons; import forge.card.cost.Cost; import forge.card.spellability.Ability; @@ -35,7 +33,8 @@ import forge.card.spellability.Target; import forge.game.phase.PhaseUtil; import forge.game.player.ComputerUtil; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.util.MyRandom; @@ -240,7 +239,7 @@ public class CardFactoryInstants { @Override public boolean canPlayAI() { - CardList humanArts = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); + CardList humanArts = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); humanArts = humanArts.getType("Artifact"); return humanArts.size() > 0; } //canPlayAI @@ -253,7 +252,7 @@ public class CardFactoryInstants { @Override public void resolve() { Player player = getTargetPlayer(); - CardList artifacts = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList artifacts = AllZoneUtil.getCardsIn(ZoneType.Battlefield); artifacts = artifacts.getType("Artifact"); for (int i = 0; i < artifacts.size(); i++) { @@ -287,7 +286,7 @@ public class CardFactoryInstants { } public void humanResolve() { - final CardList libraryList = AllZone.getHumanPlayer().getCardsIn(Zone.Library); + final CardList libraryList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Library); final CardList selectedCards = new CardList(); Object o = GuiUtils.chooseOneOrNone("Select first card", libraryList.toArray()); @@ -327,7 +326,7 @@ public class CardFactoryInstants { } public void computerResolve() { - final CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Library); + final CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Library); final CardList selectedCards = new CardList(); // pick best creature @@ -368,13 +367,13 @@ public class CardFactoryInstants { @Override public boolean canPlay() { - final CardList library = card.getController().getCardsIn(Zone.Library); + final CardList library = card.getController().getCardsIn(ZoneType.Library); return library.size() >= 3 && super.canPlay(); } @Override public boolean canPlayAI() { - CardList creature = AllZone.getComputerPlayer().getCardsIn(Zone.Library); + CardList creature = AllZone.getComputerPlayer().getCardsIn(ZoneType.Library); creature = creature.getType("Creature"); return creature.size() >= 3; } @@ -396,7 +395,7 @@ public class CardFactoryInstants { final Player player = card.getController(); final int max = card.getXManaCostPaid(); - final CardList graveList = tPlayer.getCardsIn(Zone.Graveyard); + final CardList graveList = tPlayer.getCardsIn(ZoneType.Graveyard); final int x = Math.min(max, graveList.size()); if (player.isHuman()) { @@ -430,7 +429,7 @@ public class CardFactoryInstants { @Override public boolean canPlayAI() { - final CardList graveList = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard); + final CardList graveList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Graveyard); final int maxX = ComputerUtil.getAvailableMana().size() - 1; return (maxX >= 3) && (graveList.size() > 0); @@ -546,7 +545,7 @@ public class CardFactoryInstants { @Override public void resolve() { - final PlayerZone lib = card.getController().getZone(Constant.Zone.Library); + final PlayerZone lib = card.getController().getZone(ZoneType.Library); final CardList choices = new CardList(); for (int i = 0; (i < 3) && (lib.size() > 0); i++) { choices.add(lib.get(i)); @@ -584,7 +583,7 @@ public class CardFactoryInstants { @Override public void resolve() { final Player you = card.getController(); - final CardList ens = AllZoneUtil.getCardsIn(Zone.Battlefield).filter(CardListFilter.ENCHANTMENTS); + final CardList ens = AllZoneUtil.getCardsIn(ZoneType.Battlefield).filter(CardListFilter.ENCHANTMENTS); final CardList toReturn = ens.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -642,7 +641,7 @@ public class CardFactoryInstants { final String[] choices = new String[] { "Artifact", "Creature", "Land" }; final Object o = GuiUtils.chooseOne("Select permanent type", choices); final String cardType = (String) o; - final CardList list = this.getTargetPlayer().getCardsIn(Zone.Battlefield).getType(cardType); + final CardList list = this.getTargetPlayer().getCardsIn(ZoneType.Battlefield).getType(cardType); final String[] tapOrUntap = new String[] { "Tap", "Untap" }; final Object z = GuiUtils.chooseOne("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 cb87cdb0d26..39c6854db0a 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryLands.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryLands.java @@ -25,8 +25,6 @@ import forge.Card; import forge.CardList; import forge.CardListFilter; import forge.Command; -import forge.Constant; -import forge.Constant.Zone; import forge.Counters; import forge.GameActionUtil; import forge.Singletons; @@ -38,7 +36,8 @@ import forge.card.spellability.SpellAbility; import forge.control.input.Input; import forge.game.phase.PhaseType; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.util.MyRandom; import forge.view.ButtonUtil; @@ -156,14 +155,14 @@ class CardFactoryLands { return false; } this.inPlay.clear(); - this.inPlay.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield)); + this.inPlay.addAll(AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield)); return (this.inPlay.filter(targets).size() > 1) && super.canPlayAI(); } @Override public void resolve() { this.inPlay.clear(); - this.inPlay.addAll(AllZoneUtil.getCardsIn(Zone.Battlefield)); + this.inPlay.addAll(AllZoneUtil.getCardsIn(ZoneType.Battlefield)); for (final Card targ : this.inPlay.filter(targets)) { targ.addCounter(Counters.P1P1, 1); } @@ -219,7 +218,7 @@ class CardFactoryLands { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isUntapped()) { + if (c.isLand() && zone.is(ZoneType.Battlefield) && c.isUntapped()) { Singletons.getModel().getGameAction().sacrifice(c); if (paid[0] < 1) { paid[0]++; @@ -273,7 +272,7 @@ class CardFactoryLands { @Override public void execute() { - final CardList land = this.player.getCardsIn(Zone.Battlefield).getValidCards(type[0], this.player, + final CardList land = this.player.getCardsIn(ZoneType.Battlefield).getValidCards(type[0], this.player, card); if (this.player.isComputer()) { @@ -309,7 +308,7 @@ class CardFactoryLands { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (c.isLand() && zone.is(Zone.Battlefield) && land.contains(c)) { + if (c.isLand() && zone.is(ZoneType.Battlefield) && land.contains(c)) { Singletons.getModel().getGameAction().sacrifice(c); this.stop(); } @@ -337,7 +336,7 @@ class CardFactoryLands { @Override public void execute() { final Player player = card.getController(); - final CardList land = player.getCardsIn(Zone.Battlefield, "Sheltered Valley"); + final CardList land = player.getCardsIn(ZoneType.Battlefield, "Sheltered Valley"); land.remove(card); if (land.size() > 0) { @@ -402,7 +401,7 @@ class CardFactoryLands { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isUntapped()) { + if (c.isLand() && zone.is(ZoneType.Battlefield) && c.isUntapped()) { Singletons.getModel().getGameAction().sacrifice(c); if (paid[0] < 1) { paid[0]++; @@ -467,7 +466,7 @@ class CardFactoryLands { } public void computerExecute() { - CardList hand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + CardList hand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); hand = hand.getType(type); if (hand.size() > 0) { this.revealCard(hand.get(0)); @@ -490,7 +489,7 @@ class CardFactoryLands { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (zone.is(Constant.Zone.Hand) && c.isType(type)) { + if (zone.is(ZoneType.Hand) && c.isType(type)) { final StringBuilder sb = new StringBuilder(); sb.append("Revealed card: ").append(c.getName()); JOptionPane.showMessageDialog(null, sb.toString(), card.getName(), @@ -682,7 +681,7 @@ class CardFactoryLands { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (c.isLand() && zone.is(Constant.Zone.Battlefield, AllZone.getHumanPlayer()) + if (c.isLand() && zone.is(ZoneType.Battlefield, AllZone.getHumanPlayer()) && !c.isType("Lair")) { Singletons.getModel().getGameAction().moveToHand(c); this.stop(); @@ -720,7 +719,7 @@ class CardFactoryLands { final Player player = card.getController(); final StringBuilder sb = new StringBuilder(); sb.append(type[0]).append(".untapped"); - final CardList land = player.getCardsIn(Zone.Battlefield) + final CardList land = player.getCardsIn(ZoneType.Battlefield) .getValidCards(sb.toString(), player, card); if (player.isComputer()) { @@ -751,7 +750,7 @@ class CardFactoryLands { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (zone.is(Constant.Zone.Battlefield) && land.contains(c)) { + if (zone.is(ZoneType.Battlefield) && land.contains(c)) { Singletons.getModel().getGameAction().moveToHand(c); this.stop(); } diff --git a/src/main/java/forge/card/cardfactory/CardFactorySorceries.java b/src/main/java/forge/card/cardfactory/CardFactorySorceries.java index d953008e271..5c9250e0660 100644 --- a/src/main/java/forge/card/cardfactory/CardFactorySorceries.java +++ b/src/main/java/forge/card/cardfactory/CardFactorySorceries.java @@ -34,8 +34,6 @@ import forge.CardListFilter; import forge.CardListUtil; import forge.CardUtil; import forge.Command; -import forge.Constant; -import forge.Constant.Zone; import forge.HandSizeOp; import forge.Singletons; import forge.card.cost.Cost; @@ -49,7 +47,8 @@ import forge.control.input.InputPayManaCostAbility; import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.player.PlayerUtil; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.view.ButtonUtil; @@ -142,7 +141,7 @@ public class CardFactorySorceries { return; } - if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.canBeTargetedBy(spell)) { + if (c.isLand() && zone.is(ZoneType.Battlefield) && c.canBeTargetedBy(spell)) { target[index[0]] = c; index[0]++; this.showMessage(); @@ -258,7 +257,7 @@ public class CardFactorySorceries { Card choice = null; // check for no cards in hand on resolve - final CardList lib = card.getController().getCardsIn(Zone.Library); + final CardList lib = card.getController().getCardsIn(ZoneType.Library); final CardList cards = new CardList(); final CardList exiled = new CardList(); if (lib.size() == 0) { @@ -427,7 +426,7 @@ public class CardFactorySorceries { @Override public boolean canPlayAI() { - final CardList cards = AllZone.getComputerPlayer().getCardsIn(Zone.Library); + final CardList cards = AllZone.getComputerPlayer().getCardsIn(ZoneType.Library); return cards.size() >= 8; } }; // SpellAbility @@ -444,7 +443,7 @@ public class CardFactorySorceries { @Override public void resolve() { - final CardList all = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList 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[] { @@ -621,7 +620,7 @@ public class CardFactorySorceries { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.getController().isHuman() + if (c.isLand() && zone.is(ZoneType.Battlefield) && c.getController().isHuman() /* && c.getName().equals(humanBasic.get(count)) */ && c.isType(humanBasic.get(this.count)) /* && !saveList.contains(c) */) { @@ -675,7 +674,7 @@ 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(Zone.Battlefield); + final CardList land = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); final String[] basic = { "Forest", "Plains", "Mountain", "Island", "Swamp" }; for (final String element : basic) { @@ -711,8 +710,8 @@ public class CardFactorySorceries { public boolean canPlayAI() { // Haunting Echoes shouldn't be cast if only basic land in // graveyard or library is empty - CardList graveyard = AllZone.getHumanPlayer().getCardsIn(Zone.Graveyard); - final CardList library = AllZone.getHumanPlayer().getCardsIn(Zone.Library); + CardList graveyard = AllZone.getHumanPlayer().getCardsIn(ZoneType.Graveyard); + final CardList library = AllZone.getHumanPlayer().getCardsIn(ZoneType.Library); final int graveCount = graveyard.size(); graveyard = graveyard.filter(new CardListFilter() { @Override @@ -730,10 +729,10 @@ public class CardFactorySorceries { public void resolve() { final Player player = this.getTargetPlayer(); - CardList grave = player.getCardsIn(Zone.Graveyard); + CardList grave = player.getCardsIn(ZoneType.Graveyard); grave = grave.getNotType("Basic"); - final CardList lib = player.getCardsIn(Zone.Library); + final CardList lib = player.getCardsIn(ZoneType.Library); for (final Card c : grave) { final CardList remLib = lib.getName(c.getName()); @@ -819,8 +818,8 @@ public class CardFactorySorceries { } // Hand - final CardList humHand = AllZone.getHumanPlayer().getCardsIn(Zone.Hand); - final CardList compHand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + final CardList humHand = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand); + final CardList compHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); final int handDiff = Math.abs(humHand.size() - compHand.size()); if (compHand.size() > humHand.size()) { @@ -858,8 +857,8 @@ public class CardFactorySorceries { compCreats = compCreats.getType("Creature"); diff += 1.5 * (humCreats.size() - compCreats.size()); - final CardList humHand = AllZone.getHumanPlayer().getCardsIn(Zone.Hand); - final CardList compHand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + final CardList humHand = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand); + final CardList compHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); diff += 0.5 * (humHand.size() - compHand.size()); return diff > 2; @@ -883,7 +882,7 @@ public class CardFactorySorceries { // is structured, it will already have played land to it's // limit - CardList hand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + CardList hand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); hand = hand.getType("Land"); return hand.size() > 0; } @@ -922,7 +921,7 @@ public class CardFactorySorceries { // turn // is structured, it will already have played its first // land. - CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); list = list.getType("Land"); return list.size() > 0; @@ -1111,7 +1110,7 @@ public class CardFactorySorceries { return; // cannot target the same creature twice. } - if (c.isCreature() && zone.is(Constant.Zone.Battlefield)) { + if (c.isCreature() && zone.is(ZoneType.Battlefield)) { targets.add(c); this.showMessage(); } @@ -1146,15 +1145,15 @@ public class CardFactorySorceries { /* * We want compy to have less cards in hand than the human */ - final CardList humanHand = AllZone.getHumanPlayer().getCardsIn(Zone.Hand); - final CardList computerHand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + final CardList humanHand = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand); + final CardList computerHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); return computerHand.size() < humanHand.size(); } @Override public void resolve() { - final CardList humanHand = AllZone.getHumanPlayer().getCardsIn(Zone.Hand); - final CardList computerHand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + final CardList humanHand = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand); + final CardList computerHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); final int num = Math.max(humanHand.size(), computerHand.size()); @@ -1204,7 +1203,7 @@ public class CardFactorySorceries { } final HashMap countInGraveyard = new HashMap(); - final CardList allGrave = AllZone.getComputerPlayer().getCardsIn(Constant.Zone.Graveyard); + final CardList allGrave = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard); allGrave.getType("Creature"); for (final Card c : allGrave) { for (final String type : c.getType()) { @@ -1232,7 +1231,7 @@ public class CardFactorySorceries { } // Actually put everything on the battlefield - CardList bidded = AllZoneUtil.getCardsIn(Constant.Zone.Graveyard); + CardList bidded = AllZoneUtil.getCardsIn(ZoneType.Graveyard); bidded = bidded.getType("Creature"); for (final Card c : bidded) { if (c.isType(input[1]) || (!input[0].equals("") && c.isType(input[0]))) { @@ -1305,7 +1304,7 @@ public class CardFactorySorceries { public void resolve() { final Player player = card.getController(); final Player opp = player.getOpponent(); - final PlayerZone lib = card.getController().getZone(Constant.Zone.Library); + final PlayerZone lib = card.getController().getZone(ZoneType.Library); int maxCards = lib.size(); maxCards = Math.min(maxCards, 10); if (maxCards == 0) { @@ -1332,7 +1331,7 @@ public class CardFactorySorceries { @Override public boolean canPlayAI() { - return !AllZone.getComputerPlayer().getZone(Zone.Library).isEmpty(); + return !AllZone.getComputerPlayer().getZone(ZoneType.Library).isEmpty(); } }; // SpellAbility @@ -1405,7 +1404,7 @@ public class CardFactorySorceries { } // resolve() void discardDraw(final Player player) { - final CardList hand = player.getCardsIn(Zone.Hand); + final CardList hand = player.getCardsIn(ZoneType.Hand); final int numDraw = hand.size(); // move hand to library @@ -1424,7 +1423,7 @@ public class CardFactorySorceries { // in hand play CARDNAME @Override public boolean canPlayAI() { - CardList c = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + CardList c = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); c = c.filter(CardListFilter.NON_LANDS); return (2 >= c.size()) || (AllZone.getComputerPlayer().hasMetalcraft() && (AllZone.getHumanPlayer().getLife() <= 3)); @@ -1447,7 +1446,7 @@ public class CardFactorySorceries { @Override public void resolve() { final Player player = card.getController(); - for (final Card c : player.getCardsIn(Zone.Graveyard)) { + for (final Card c : player.getCardsIn(ZoneType.Graveyard)) { Singletons.getModel().getGameAction().moveToHand(c); } @@ -1506,7 +1505,7 @@ public class CardFactorySorceries { if (userChoice.contains(cardChoice[1]) || card.getChoices().contains(cardChoice[1])) { final Card c = ab1card[0]; if (c != null) { - if (card.getController().getZone(Zone.Graveyard).contains(c) && c.canBeTargetedBy(this)) { + if (card.getController().getZone(ZoneType.Graveyard).contains(c) && c.canBeTargetedBy(this)) { Singletons.getModel().getGameAction().moveToPlay(c); } } @@ -1623,7 +1622,7 @@ public class CardFactorySorceries { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (c.isCreature() && zone.is(Constant.Zone.Battlefield) && c.canBeTargetedBy(spell) + if (c.isCreature() && zone.is(ZoneType.Battlefield) && c.canBeTargetedBy(spell) && !ab3cards.contains(c)) { ab3cards.add(c); this.count++; @@ -1660,7 +1659,7 @@ public class CardFactorySorceries { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (c.isCreature() && zone.is(Constant.Zone.Battlefield) && c.canBeTargetedBy(spell)) { + if (c.isCreature() && zone.is(ZoneType.Battlefield) && c.canBeTargetedBy(spell)) { if (card.isCopiedSpell()) { card.getChoiceTargets().remove(0); } @@ -1688,7 +1687,7 @@ public class CardFactorySorceries { @Override public void showMessage() { - CardList grave = card.getController().getCardsIn(Constant.Zone.Graveyard); + CardList grave = card.getController().getCardsIn(ZoneType.Graveyard); grave = grave.filter(CardListFilter.CREATURES); grave = grave.filter(new CardListFilter() { @Override @@ -1847,7 +1846,7 @@ public class CardFactorySorceries { // get all final CardList creatures = AllZoneUtil.getCreaturesInPlay(); - CardList grave = card.getController().getCardsIn(Zone.Graveyard); + CardList grave = card.getController().getCardsIn(ZoneType.Graveyard); grave = grave.filter(CardListFilter.CREATURES); if (AllZone.getHumanPlayer().canBeTargetedBy(spell) @@ -1962,7 +1961,7 @@ public class CardFactorySorceries { final Card[] newArtifact = new Card[1]; // Sacrifice an artifact - CardList arts = p.getCardsIn(Constant.Zone.Battlefield); + CardList arts = p.getCardsIn(ZoneType.Battlefield); arts = arts.filter(CardListFilter.ARTIFACTS); final Object toSac = GuiUtils.chooseOneOrNone("Sacrifice an artifact", arts.toArray()); if (toSac != null) { @@ -1974,7 +1973,7 @@ public class CardFactorySorceries { } // Search your library for an artifact - final CardList lib = p.getCardsIn(Zone.Library); + final CardList lib = p.getCardsIn(ZoneType.Library); GuiUtils.chooseOneOrNone("Looking at Library", lib.toArray()); final CardList libArts = lib.filter(CardListFilter.ARTIFACTS); final Object o = GuiUtils.chooseOneOrNone("Search for artifact", libArts.toArray()); diff --git a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java index bbf5ca68d99..9712af51b37 100644 --- a/src/main/java/forge/card/cardfactory/CardFactoryUtil.java +++ b/src/main/java/forge/card/cardfactory/CardFactoryUtil.java @@ -37,8 +37,6 @@ import forge.CardListFilter; import forge.CardUtil; import forge.Command; import forge.CommandArgs; -import forge.Constant; -import forge.Constant.Zone; import forge.Counters; import forge.GameActionUtil; import forge.HandSizeOp; @@ -66,7 +64,8 @@ import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.util.MyRandom; import forge.view.ButtonUtil; @@ -908,7 +907,7 @@ public class CardFactoryUtil { } }; final SpellAbilityRestriction restrict = new SpellAbilityRestriction(); - restrict.setZone(Zone.Graveyard); + restrict.setZone(ZoneType.Graveyard); restrict.setSorcerySpeed(true); unearth.setRestrictions(restrict); @@ -1040,8 +1039,8 @@ public class CardFactoryUtil { // The AI should cycle lands if it has 6 already and no cards in // hand with higher CMC - final CardList hand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); - CardList lands = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + final CardList hand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); + CardList lands = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); lands.addAll(hand); lands = lands.getType("Land"); @@ -1076,7 +1075,7 @@ public class CardFactoryUtil { sbStack.append(sourceCard).append(" Cycling: Draw a card"); cycle.setStackDescription(sbStack.toString()); - cycle.getRestrictions().setZone(Constant.Zone.Hand); + cycle.getRestrictions().setZone(ZoneType.Hand); return cycle; } // abilityCycle() @@ -1119,7 +1118,7 @@ public class CardFactoryUtil { @Override public void resolve() { - final CardList cards = sourceCard.getController().getCardsIn(Zone.Library); + final CardList cards = sourceCard.getController().getCardsIn(ZoneType.Library); final CardList sameType = new CardList(); for (int i = 0; i < cards.size(); i++) { @@ -1163,7 +1162,7 @@ public class CardFactoryUtil { sbStack.append("cycling: Search your library for a ").append(description).append(" card.)"); cycle.setStackDescription(sbStack.toString()); - cycle.getRestrictions().setZone(Constant.Zone.Hand); + cycle.getRestrictions().setZone(ZoneType.Hand); return cycle; } // abilityTypecycle() @@ -1198,7 +1197,7 @@ public class CardFactoryUtil { @Override public void resolve() { - final CardList cards = sourceCard.getController().getCardsIn(Zone.Library); + final CardList cards = sourceCard.getController().getCardsIn(ZoneType.Library); final CardList sameCost = new CardList(); for (int i = 0; i < cards.size(); i++) { @@ -1237,7 +1236,7 @@ public class CardFactoryUtil { sbStack.append("for a card with the same converted mana cost.)"); transmute.setStackDescription(sbStack.toString()); - transmute.getRestrictions().setZone(Constant.Zone.Hand); + transmute.getRestrictions().setZone(ZoneType.Hand); return transmute; } // abilityTransmute() @@ -1292,7 +1291,7 @@ public class CardFactoryUtil { sbStack.append(suspendCounters).append(" turns.)"); suspend.setStackDescription(sbStack.toString()); - suspend.getRestrictions().setZone(Constant.Zone.Hand); + suspend.getRestrictions().setZone(ZoneType.Hand); return suspend; } // abilitySuspend() @@ -1356,7 +1355,7 @@ public class CardFactoryUtil { } CardList getCreature() { - CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); list = list.getTargetableCards(this).filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -1648,7 +1647,7 @@ public class CardFactoryUtil { final SpellAbility desc = new Ability(sourceCard, "0") { @Override public void resolve() { - final CardList cards = sourceCard.getController().getCardsIn(Zone.Graveyard); + final CardList cards = sourceCard.getController().getCardsIn(ZoneType.Graveyard); final CardList sameCost = new CardList(); final int cost = CardUtil.getConvertedManaCost(manacost); for (int i = 0; i < cards.size(); i++) { @@ -1988,7 +1987,7 @@ public class CardFactoryUtil { @Override public void selectCard(final Card card2, final PlayerZone zone) { - if (card2.isCreature() && card2.isArtifact() && zone.is(Constant.Zone.Battlefield) + if (card2.isCreature() && card2.isArtifact() && zone.is(ZoneType.Battlefield) && card.canBeTargetedBy(ability)) { ability.setTargetCard(card2); final StringBuilder sb = new StringBuilder(); @@ -2037,7 +2036,7 @@ public class CardFactoryUtil { * @return a {@link forge.CardList} object. */ public static CardList getHumanCreatureAI(final String keyword, final SpellAbility spell, final boolean targeted) { - CardList creature = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); + CardList creature = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); creature = creature.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -2065,7 +2064,7 @@ public class CardFactoryUtil { * @return a {@link forge.CardList} object. */ public static CardList getHumanCreatureAI(final int toughness, final SpellAbility spell, final boolean targeted) { - CardList creature = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); + CardList creature = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); creature = creature.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -2108,7 +2107,7 @@ public class CardFactoryUtil { * @return a int. */ public static int getNumberOfPermanentsByColor(final String color) { - final CardList cards = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList cards = AllZoneUtil.getCardsIn(ZoneType.Battlefield); final CardList coloredPerms = new CardList(); @@ -2130,7 +2129,7 @@ public class CardFactoryUtil { * @return a boolean. */ public static boolean multipleControlled(final Card c) { - final CardList list = c.getController().getCardsIn(Zone.Battlefield); + final CardList list = c.getController().getCardsIn(ZoneType.Battlefield); list.remove(c); return list.containsName(c.getName()); @@ -2147,7 +2146,7 @@ public class CardFactoryUtil { */ public static boolean oppHasKismet(final Player player) { final Player opp = player.getOpponent(); - CardList list = opp.getCardsIn(Zone.Battlefield); + CardList list = opp.getCardsIn(ZoneType.Battlefield); list = list.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -2170,7 +2169,7 @@ public class CardFactoryUtil { * @return a int. */ public static int getNumberOfManaSymbolsControlledByColor(final String colorAbb, final Player player) { - final CardList cards = player.getCardsIn(Zone.Battlefield); + final CardList cards = player.getCardsIn(ZoneType.Battlefield); return CardFactoryUtil.getNumberOfManaSymbolsByColor(colorAbb, cards); } @@ -2286,7 +2285,7 @@ public class CardFactoryUtil { } else { // If an Aura's target is removed before it resolves, the Aura // fizzles - if (source.isAura() && !target.isInZone(Constant.Zone.Battlefield)) { + if (source.isAura() && !target.isInZone(ZoneType.Battlefield)) { return false; } } @@ -2408,11 +2407,11 @@ public class CardFactoryUtil { final CardList cl = new CardList(); final Player opponent = activator.getOpponent(); - cl.addAll(CardFactoryUtil.getActivateablesFromZone(activator.getZone(Constant.Zone.Graveyard), activator)); - cl.addAll(CardFactoryUtil.getActivateablesFromZone(activator.getZone(Constant.Zone.Exile), activator)); - cl.addAll(CardFactoryUtil.getActivateablesFromZone(activator.getZone(Constant.Zone.Library), activator)); - cl.addAll(CardFactoryUtil.getActivateablesFromZone(activator.getZone(Constant.Zone.Command), activator)); - cl.addAll(CardFactoryUtil.getActivateablesFromZone(opponent.getZone(Constant.Zone.Exile), activator)); + cl.addAll(CardFactoryUtil.getActivateablesFromZone(activator.getZone(ZoneType.Graveyard), activator)); + cl.addAll(CardFactoryUtil.getActivateablesFromZone(activator.getZone(ZoneType.Exile), activator)); + cl.addAll(CardFactoryUtil.getActivateablesFromZone(activator.getZone(ZoneType.Library), activator)); + cl.addAll(CardFactoryUtil.getActivateablesFromZone(activator.getZone(ZoneType.Command), activator)); + cl.addAll(CardFactoryUtil.getActivateablesFromZone(opponent.getZone(ZoneType.Exile), activator)); return cl; } @@ -2433,7 +2432,7 @@ public class CardFactoryUtil { CardList cl = new CardList(zone.getCards()); // Only check the top card of the library - if (zone.is(Constant.Zone.Library) && !cl.isEmpty()) { + if (zone.is(ZoneType.Library) && !cl.isEmpty()) { cl = new CardList(cl.get(0)); } @@ -2441,7 +2440,7 @@ public class CardFactoryUtil { cl = cl.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { - if (zone.is(Constant.Zone.Graveyard)) { + if (zone.is(ZoneType.Graveyard)) { if (c.hasUnearth()) { return true; } @@ -2457,7 +2456,7 @@ public class CardFactoryUtil { } for (final SpellAbility sa : c.getSpellAbility()) { - final Zone restrictZone = sa.getRestrictions().getZone(); + final ZoneType restrictZone = sa.getRestrictions().getZone(); if (zone.is(restrictZone)) { return true; } @@ -2465,8 +2464,8 @@ public class CardFactoryUtil { if (sa.isSpell() && (c.hasKeyword("May be played") || c.hasKeyword("May be played by your Opponent") || c.hasKeyword("May be played without paying its mana cost") || (c - .hasStartOfKeyword("Flashback") && zone.is(Zone.Graveyard))) - && restrictZone.equals(Zone.Hand)) { + .hasStartOfKeyword("Flashback") && zone.is(ZoneType.Graveyard))) + && restrictZone.equals(ZoneType.Hand)) { return true; } } @@ -2556,7 +2555,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(Zone.Battlefield); + CardList cardsonbattlefield = AllZoneUtil.getCardsIn(ZoneType.Battlefield); cardsonbattlefield = cardsonbattlefield.getValidCards(rest, players.get(0), source); n = cardsonbattlefield.size(); @@ -2569,13 +2568,13 @@ public class CardFactoryUtil { if (sq[0].contains("CardsInHand")) { if (players.size() > 0) { - return CardFactoryUtil.doXMath(players.get(0).getCardsIn(Zone.Hand).size(), m, source); + return CardFactoryUtil.doXMath(players.get(0).getCardsIn(ZoneType.Hand).size(), m, source); } } if (sq[0].contains("DomainPlayer")) { final CardList someCards = new CardList(); - someCards.addAll(players.get(0).getCardsIn(Zone.Battlefield)); + someCards.addAll(players.get(0).getCardsIn(ZoneType.Battlefield)); final String[] basic = { "Forest", "Plains", "Mountain", "Island", "Swamp" }; for (int i = 0; i < basic.length; i++) { @@ -2588,18 +2587,18 @@ public class CardFactoryUtil { if (sq[0].contains("CardsInLibrary")) { if (players.size() > 0) { - return CardFactoryUtil.doXMath(players.get(0).getCardsIn(Zone.Library).size(), m, source); + return CardFactoryUtil.doXMath(players.get(0).getCardsIn(ZoneType.Library).size(), m, source); } } if (sq[0].contains("CardsInGraveyard")) { if (players.size() > 0) { - return CardFactoryUtil.doXMath(players.get(0).getCardsIn(Zone.Graveyard).size(), m, source); + return CardFactoryUtil.doXMath(players.get(0).getCardsIn(ZoneType.Graveyard).size(), m, source); } } if (sq[0].contains("LandsInGraveyard")) { if (players.size() > 0) { - return CardFactoryUtil.doXMath(players.get(0).getCardsIn(Zone.Graveyard).getType("Land").size(), m, + return CardFactoryUtil.doXMath(players.get(0).getCardsIn(ZoneType.Graveyard).getType("Land").size(), m, source); } } @@ -2612,7 +2611,7 @@ public class CardFactoryUtil { if (sq[0].contains("CardsInPlay")) { if (players.size() > 0) { - return CardFactoryUtil.doXMath(players.get(0).getCardsIn(Zone.Battlefield).size(), m, source); + return CardFactoryUtil.doXMath(players.get(0).getCardsIn(ZoneType.Battlefield).size(), m, source); } } @@ -2624,7 +2623,7 @@ public class CardFactoryUtil { if (sq[0].contains("TopOfLibraryCMC")) { if (players.size() > 0) { - return CardFactoryUtil.doXMath(players.get(0).getCardsIn(Zone.Library, 1).getTotalConvertedManaCost(), + return CardFactoryUtil.doXMath(players.get(0).getCardsIn(ZoneType.Library, 1).getTotalConvertedManaCost(), m, source); } } @@ -2725,7 +2724,7 @@ public class CardFactoryUtil { String restrictions = l[0].replace("Valid ", ""); restrictions = restrictions.replace("Count$", ""); final String[] rest = restrictions.split(","); - CardList cardsonbattlefield = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList cardsonbattlefield = AllZoneUtil.getCardsIn(ZoneType.Battlefield); cardsonbattlefield = cardsonbattlefield.getValidCards(rest, cardController, c); n = cardsonbattlefield.size(); @@ -2843,7 +2842,7 @@ public class CardFactoryUtil { // Count$Domain if (sq[0].contains("Domain")) { - someCards.addAll(cardController.getCardsIn(Zone.Battlefield)); + someCards.addAll(cardController.getCardsIn(ZoneType.Battlefield)); final String[] basic = { "Forest", "Plains", "Mountain", "Island", "Swamp" }; for (int i = 0; i < basic.length; i++) { @@ -2856,7 +2855,7 @@ public class CardFactoryUtil { // Count$OpponentDom if (sq[0].contains("OpponentDom")) { - someCards.addAll(cardController.getOpponent().getCardsIn(Zone.Battlefield)); + someCards.addAll(cardController.getOpponent().getCardsIn(ZoneType.Battlefield)); final String[] basic = { "Forest", "Plains", "Mountain", "Island", "Swamp" }; for (int i = 0; i < basic.length; i++) { @@ -2869,7 +2868,7 @@ public class CardFactoryUtil { // Count$ColoredCreatures *a DOMAIN for creatures* if (sq[0].contains("ColoredCreatures")) { - someCards.addAll(cardController.getCardsIn(Zone.Battlefield)); + someCards.addAll(cardController.getCardsIn(ZoneType.Battlefield)); someCards = someCards.filter(CardListFilter.CREATURES); final String[] colors = { "green", "white", "red", "blue", "black" }; @@ -2976,21 +2975,21 @@ public class CardFactoryUtil { // Count$TopOfLibraryCMC if (sq[0].contains("TopOfLibraryCMC")) { - final CardList topcard = cardController.getCardsIn(Zone.Library, 1); + final CardList topcard = cardController.getCardsIn(ZoneType.Library, 1); return CardFactoryUtil.doXMath(topcard.getTotalConvertedManaCost(), m, c); } // Count$EnchantedControllerCreatures if (sq[0].contains("EnchantedControllerCreatures")) { - CardList enchantedControllerInPlay = c.getEnchantingCard().getController().getCardsIn(Zone.Battlefield); + CardList enchantedControllerInPlay = c.getEnchantingCard().getController().getCardsIn(ZoneType.Battlefield); enchantedControllerInPlay = enchantedControllerInPlay.getType("Creature"); return enchantedControllerInPlay.size(); } // Count$LowestLibrary if (sq[0].contains("LowestLibrary")) { - return Math.min(AllZone.getHumanPlayer().getZone(Zone.Library).size(), - AllZone.getComputerPlayer().getZone(Zone.Library).size()); + return Math.min(AllZone.getHumanPlayer().getZone(ZoneType.Library).size(), + AllZone.getComputerPlayer().getZone(ZoneType.Library).size()); } // Count$Chroma. @@ -3030,7 +3029,7 @@ public class CardFactoryUtil { // Count$wasCastFrom.. if (sq[0].startsWith("wasCastFrom")) { final String strZone = sq[0].substring(11); - final Zone realZone = Zone.smartValueOf(strZone); + final ZoneType realZone = ZoneType.smartValueOf(strZone); if (c.getCastFrom() == realZone) { return CardFactoryUtil.doXMath(Integer.parseInt(sq[1]), m, c); } else { @@ -3055,8 +3054,8 @@ public class CardFactoryUtil { } if (sq[0].contains("GraveyardWithGE20Cards")) { - if (Math.max(AllZone.getHumanPlayer().getZone(Zone.Graveyard).size(), - AllZone.getComputerPlayer().getZone(Zone.Graveyard).size()) >= 20) { + if (Math.max(AllZone.getHumanPlayer().getZone(ZoneType.Graveyard).size(), + AllZone.getComputerPlayer().getZone(ZoneType.Graveyard).size()) >= 20) { return CardFactoryUtil.doXMath(Integer.parseInt(sq[1]), m, c); } else { return CardFactoryUtil.doXMath(Integer.parseInt(sq[2]), m, c); @@ -3146,12 +3145,12 @@ public class CardFactoryUtil { // Count$ThisTurnEntered if (sq[0].contains("ThisTurnEntered")) { final String[] workingCopy = l[0].split("_"); - Zone destination, origin; + ZoneType destination, origin; String validFilter; - destination = Zone.smartValueOf(workingCopy[1]); + destination = ZoneType.smartValueOf(workingCopy[1]); if (workingCopy[2].equals("from")) { - origin = Zone.smartValueOf(workingCopy[3]); + origin = ZoneType.smartValueOf(workingCopy[3]); validFilter = workingCopy[4]; } else { origin = null; @@ -3184,7 +3183,7 @@ public class CardFactoryUtil { // Count$Morbid.. if (sq[0].startsWith("Morbid")) { - final CardList res = CardUtil.getThisTurnEntered(Zone.Graveyard, Zone.Battlefield, "Creature", c); + final CardList res = CardUtil.getThisTurnEntered(ZoneType.Graveyard, ZoneType.Battlefield, "Creature", c); if (res.size() > 0) { return CardFactoryUtil.doXMath(Integer.parseInt(sq[1]), m, c); } else { @@ -3204,77 +3203,77 @@ public class CardFactoryUtil { if (sq[0].contains("YouCtrl")) { if (!mf) { - someCards.addAll(cardController.getCardsIn(Zone.Battlefield)); + someCards.addAll(cardController.getCardsIn(ZoneType.Battlefield)); mf = true; } } if (sq[0].contains("InYourYard")) { if (!my) { - someCards.addAll(cardController.getCardsIn(Zone.Graveyard)); + someCards.addAll(cardController.getCardsIn(ZoneType.Graveyard)); my = true; } } if (sq[0].contains("InYourLibrary")) { if (!my) { - someCards.addAll(cardController.getCardsIn(Zone.Library)); + someCards.addAll(cardController.getCardsIn(ZoneType.Library)); my = true; } } if (sq[0].contains("InYourHand")) { if (!mh) { - someCards.addAll(cardController.getCardsIn(Zone.Hand)); + someCards.addAll(cardController.getCardsIn(ZoneType.Hand)); mh = true; } } if (sq[0].contains("OppCtrl")) { if (!of) { - someCards.addAll(oppController.getCardsIn(Zone.Battlefield)); + someCards.addAll(oppController.getCardsIn(ZoneType.Battlefield)); of = true; } } if (sq[0].contains("InOppYard")) { if (!oy) { - someCards.addAll(oppController.getCardsIn(Zone.Graveyard)); + someCards.addAll(oppController.getCardsIn(ZoneType.Graveyard)); oy = true; } } if (sq[0].contains("InOppHand")) { if (!oh) { - someCards.addAll(oppController.getCardsIn(Zone.Hand)); + someCards.addAll(oppController.getCardsIn(ZoneType.Hand)); oh = true; } } if (sq[0].contains("OnBattlefield")) { if (!mf) { - someCards.addAll(cardController.getCardsIn(Zone.Battlefield)); + someCards.addAll(cardController.getCardsIn(ZoneType.Battlefield)); } if (!of) { - someCards.addAll(oppController.getCardsIn(Zone.Battlefield)); + someCards.addAll(oppController.getCardsIn(ZoneType.Battlefield)); } } if (sq[0].contains("InAllYards")) { if (!my) { - someCards.addAll(cardController.getCardsIn(Zone.Graveyard)); + someCards.addAll(cardController.getCardsIn(ZoneType.Graveyard)); } if (!oy) { - someCards.addAll(oppController.getCardsIn(Zone.Graveyard)); + someCards.addAll(oppController.getCardsIn(ZoneType.Graveyard)); } } if (sq[0].contains("InAllHands")) { if (!mh) { - someCards.addAll(cardController.getCardsIn(Zone.Hand)); + someCards.addAll(cardController.getCardsIn(ZoneType.Hand)); } if (!oh) { - someCards.addAll(oppController.getCardsIn(Zone.Hand)); + someCards.addAll(oppController.getCardsIn(ZoneType.Hand)); } } @@ -3286,7 +3285,7 @@ public class CardFactoryUtil { if (parent.getTarget() != null) { for (final Object tgtP : parent.getTarget().getTargetPlayers()) { if (tgtP instanceof Player) { - someCards.addAll(((Player) tgtP).getCardsIn(Zone.Hand)); + someCards.addAll(((Player) tgtP).getCardsIn(ZoneType.Hand)); } } } @@ -3568,7 +3567,7 @@ public class CardFactoryUtil { @Override public void selectCard(final Card card, final PlayerZone zone) { - if (card.isType(type) && zone.is(Constant.Zone.Battlefield)) { + if (card.isType(type) && zone.is(ZoneType.Battlefield)) { card.untap(); this.count++; if (this.count == this.stop) { @@ -3725,7 +3724,7 @@ public class CardFactoryUtil { public static String getPropagandaCost(final Card c) { int cost = 0; - final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card card : list) { if (card.hasStartOfKeyword("Creatures can't attack unless their controller pays")) { final int keywordPosition = card @@ -3764,7 +3763,7 @@ public class CardFactoryUtil { * @return a int. */ public static int getUsableManaSources(final Player player) { - CardList list = player.getCardsIn(Zone.Battlefield); + CardList list = player.getCardsIn(ZoneType.Battlefield); list = list.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -4080,7 +4079,7 @@ public class CardFactoryUtil { final boolean extraLand = player.getNumLandsPlayed() > 0; if (extraLand) { - final CardList fastbonds = player.getCardsIn(Zone.Battlefield, "Fastbond"); + final CardList fastbonds = player.getCardsIn(ZoneType.Battlefield, "Fastbond"); for (final Card f : fastbonds) { final SpellAbility ability = new Ability(f, "0") { @Override @@ -4646,7 +4645,7 @@ public class CardFactoryUtil { final SpellAbilityRestriction restriction = new SpellAbilityRestriction(); restriction.setRestrictions(mapParams); if (!mapParams.containsKey("ActivationZone")) { - restriction.setZone(Constant.Zone.Hand); + restriction.setZone(ZoneType.Hand); } altCostSA.setRestrictions(restriction); altCostSA.setDescription(sb.toString()); @@ -4713,7 +4712,7 @@ public class CardFactoryUtil { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (!zone.is(Constant.Zone.Battlefield) || !c.isCreature()) { + if (!zone.is(ZoneType.Battlefield) || !c.isCreature()) { return; } if (c.canBeTargetedBy(haunterDiesWork)) { @@ -4984,7 +4983,7 @@ public class CardFactoryUtil { @Override public void execute() { - final CardList clICtrl = card.getOwner().getCardsIn(Zone.Battlefield); + final CardList clICtrl = card.getOwner().getCardsIn(ZoneType.Battlefield); boolean fnd = false; @@ -5040,7 +5039,7 @@ public class CardFactoryUtil { @Override public void execute() { - final CardList cardsInPlay = AllZoneUtil.getCardsIn(Zone.Battlefield).getType("World"); + final CardList cardsInPlay = AllZoneUtil.getCardsIn(ZoneType.Battlefield).getType("World"); cardsInPlay.remove(card); for (int i = 0; i < cardsInPlay.size(); i++) { Singletons.getModel().getGameAction().sacrificeDestroy(cardsInPlay.get(i)); @@ -5151,7 +5150,7 @@ public class CardFactoryUtil { count++; } // is this needed? - AllZone.getComputerPlayer().getZone(Zone.Battlefield).updateObservers(); + AllZone.getComputerPlayer().getZone(ZoneType.Battlefield).updateObservers(); } numCreatures[0] = count; } @@ -5189,7 +5188,7 @@ public class CardFactoryUtil { public void execute() { // Target as Modular is Destroyed if (card.getController().isComputer()) { - CardList choices = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList choices = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); choices = choices.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { diff --git a/src/main/java/forge/card/cost/Cost.java b/src/main/java/forge/card/cost/Cost.java index ad41d1f3db6..4a404d2e01d 100644 --- a/src/main/java/forge/card/cost/Cost.java +++ b/src/main/java/forge/card/cost/Cost.java @@ -21,11 +21,11 @@ import java.util.ArrayList; import java.util.regex.Pattern; import forge.Card; -import forge.Constant; import forge.Counters; import forge.Singletons; import forge.card.mana.ManaCost; import forge.card.spellability.SpellAbility; +import forge.game.zone.ZoneType; /** *

@@ -239,7 +239,7 @@ public class Cost { parse = this.abUpdateParse(parse, Cost.EXILE_STR); final String description = splitStr.length > 2 ? splitStr[2] : null; - this.costParts.add(new CostExile(splitStr[0], splitStr[1], description, Constant.Zone.Battlefield)); + this.costParts.add(new CostExile(splitStr[0], splitStr[1], description, ZoneType.Battlefield)); } while (parse.contains(Cost.EXILE_FROM_HAND_STR)) { @@ -247,7 +247,7 @@ public class Cost { parse = this.abUpdateParse(parse, Cost.EXILE_FROM_HAND_STR); final String description = splitStr.length > 2 ? splitStr[2] : null; - this.costParts.add(new CostExile(splitStr[0], splitStr[1], description, Constant.Zone.Hand)); + this.costParts.add(new CostExile(splitStr[0], splitStr[1], description, ZoneType.Hand)); } while (parse.contains(Cost.EXILE_FROM_GRAVE_STR)) { @@ -255,7 +255,7 @@ public class Cost { parse = this.abUpdateParse(parse, Cost.EXILE_FROM_GRAVE_STR); final String description = splitStr.length > 2 ? splitStr[2] : null; - this.costParts.add(new CostExile(splitStr[0], splitStr[1], description, Constant.Zone.Graveyard)); + this.costParts.add(new CostExile(splitStr[0], splitStr[1], description, ZoneType.Graveyard)); } while (parse.contains(Cost.EXILE_FROM_TOP_STR)) { @@ -263,7 +263,7 @@ public class Cost { parse = this.abUpdateParse(parse, Cost.EXILE_FROM_TOP_STR); final String description = splitStr.length > 2 ? splitStr[2] : null; - this.costParts.add(new CostExile(splitStr[0], splitStr[1], description, Constant.Zone.Library)); + this.costParts.add(new CostExile(splitStr[0], splitStr[1], description, ZoneType.Library)); } while (parse.contains(Cost.RETURN_STR)) { diff --git a/src/main/java/forge/card/cost/CostDiscard.java b/src/main/java/forge/card/cost/CostDiscard.java index c2614c2c447..85466301ba1 100644 --- a/src/main/java/forge/card/cost/CostDiscard.java +++ b/src/main/java/forge/card/cost/CostDiscard.java @@ -21,15 +21,14 @@ import forge.AllZone; import forge.Card; import forge.CardList; import forge.CardListUtil; -import forge.Constant; -import forge.Constant.Zone; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; import forge.card.spellability.SpellAbility; import forge.control.input.Input; import forge.game.player.ComputerUtil; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.view.ButtonUtil; /** @@ -110,12 +109,12 @@ 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(Zone.Hand); + CardList handList = activator.getCardsIn(ZoneType.Hand); final String type = this.getType(); final Integer amount = this.convertAmount(); if (this.getThis()) { - if (!source.isInZone(Constant.Zone.Hand)) { + if (!source.isInZone(ZoneType.Hand)) { return false; } } else if (type.equals("Hand")) { @@ -160,7 +159,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(Zone.Hand); + CardList handList = activator.getCardsIn(ZoneType.Hand); final String discType = this.getType(); final String amount = this.getAmount(); this.resetList(); @@ -234,7 +233,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(Zone.Hand); + final CardList hand = activator.getCardsIn(ZoneType.Hand); this.resetList(); if (type.equals("LastDrawn")) { if (!hand.contains(activator.getLastDrawnCard())) { @@ -310,7 +309,7 @@ public class CostDiscard extends CostPartWithList { this.done(); } - if (AllZone.getHumanPlayer().getZone(Zone.Hand).size() == 0) { + if (AllZone.getHumanPlayer().getZone(ZoneType.Hand).size() == 0) { this.stop(); } final StringBuilder type = new StringBuilder(""); @@ -337,7 +336,7 @@ public class CostDiscard extends CostPartWithList { @Override public void selectCard(final Card card, final PlayerZone zone) { - if (zone.is(Constant.Zone.Hand) && handList.contains(card)) { + if (zone.is(ZoneType.Hand) && handList.contains(card)) { // send in CardList for Typing card.getController().discard(card, sp); part.addToList(card); @@ -347,7 +346,7 @@ public class CostDiscard extends CostPartWithList { // in case no more cards in hand if (this.nDiscard == nNeeded) { this.done(); - } else if (AllZone.getHumanPlayer().getZone(Zone.Hand).size() == 0) { + } else if (AllZone.getHumanPlayer().getZone(ZoneType.Hand).size() == 0) { // really // shouldn't // happen diff --git a/src/main/java/forge/card/cost/CostExile.java b/src/main/java/forge/card/cost/CostExile.java index 877fc64f256..abef646a66a 100644 --- a/src/main/java/forge/card/cost/CostExile.java +++ b/src/main/java/forge/card/cost/CostExile.java @@ -24,8 +24,6 @@ import javax.swing.JOptionPane; import forge.AllZone; import forge.Card; import forge.CardList; -import forge.Constant; -import forge.Constant.Zone; import forge.GameActionUtil; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; @@ -33,7 +31,8 @@ import forge.card.spellability.SpellAbility; import forge.control.input.Input; import forge.game.player.ComputerUtil; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.view.ButtonUtil; @@ -46,14 +45,14 @@ public class CostExile extends CostPartWithList { // ExileFromGraveyard // ExileFromTop (of library) - private Constant.Zone from = Constant.Zone.Battlefield; + private ZoneType from = ZoneType.Battlefield; /** * Gets the from. * * @return the from */ - public final Constant.Zone getFrom() { + public final ZoneType getFrom() { return this.from; } @@ -69,7 +68,7 @@ public class CostExile extends CostPartWithList { * @param from * the from */ - public CostExile(final String amount, final String type, final String description, final Constant.Zone from) { + public CostExile(final String amount, final String type, final String description, final ZoneType from) { super(amount, type, description); if (from != null) { this.from = from; @@ -89,13 +88,13 @@ public class CostExile extends CostPartWithList { if (this.getThis()) { sb.append(this.getType()); - if (!this.from.equals(Zone.Battlefield)) { + if (!this.from.equals(ZoneType.Battlefield)) { sb.append(" from your ").append(this.from); } return sb.toString(); } - if (this.from.equals(Zone.Battlefield)) { + if (this.from.equals(ZoneType.Battlefield)) { final String desc = this.getTypeDescription() == null ? this.getType() : this.getTypeDescription(); sb.append(Cost.convertAmountTypeToWords(i, this.getAmount(), desc)); @@ -199,9 +198,9 @@ public class CostExile extends CostPartWithList { } if (this.getThis()) { CostUtil.setInput(CostExile.exileThis(ability, payment, this)); - } else if (this.from.equals(Constant.Zone.Battlefield) || this.from.equals(Constant.Zone.Hand)) { + } else if (this.from.equals(ZoneType.Battlefield) || this.from.equals(ZoneType.Hand)) { CostUtil.setInput(CostExile.exileType(ability, this, this.getType(), payment, c)); - } else if (this.from.equals(Constant.Zone.Library)) { + } else if (this.from.equals(ZoneType.Library)) { CostExile.exileFromTop(ability, this, payment, c); } else { CostUtil.setInput(CostExile.exileFrom(ability, this, this.getType(), payment, c)); @@ -237,8 +236,8 @@ public class CostExile extends CostPartWithList { c = AbilityFactory.calculateAmount(source, this.getAmount(), ability); } - if (this.from.equals(Constant.Zone.Library)) { - this.setList(AllZone.getComputerPlayer().getCardsIn(Zone.Library, c)); + if (this.from.equals(ZoneType.Library)) { + this.setList(AllZone.getComputerPlayer().getCardsIn(ZoneType.Library, c)); } else { this.setList(ComputerUtil.chooseExileFrom(this.getFrom(), this.getType(), source, ability.getTargetCard(), c)); @@ -268,7 +267,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(Zone.Library, nNeeded); + final CardList list = sa.getActivatingPlayer().getCardsIn(ZoneType.Library, nNeeded); if (list.size() > nNeeded) { // I don't believe this is possible @@ -403,7 +402,7 @@ public class CostExile extends CostPartWithList { msg.append("s"); } - if (part.getFrom().equals(Constant.Zone.Hand)) { + if (part.getFrom().equals(ZoneType.Hand)) { msg.append(" from your Hand"); } this.typeList = sa.getActivatingPlayer().getCardsIn(part.getFrom()); diff --git a/src/main/java/forge/card/cost/CostMana.java b/src/main/java/forge/card/cost/CostMana.java index 878f3dd3ec6..2f19a3f6c36 100644 --- a/src/main/java/forge/card/cost/CostMana.java +++ b/src/main/java/forge/card/cost/CostMana.java @@ -21,7 +21,6 @@ import com.google.common.base.Strings; import forge.AllZone; import forge.Card; -import forge.Constant.Zone; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; import forge.card.mana.ManaCost; @@ -33,7 +32,8 @@ import forge.control.input.InputPayManaCostUtil; import forge.game.phase.PhaseHandler; import forge.game.player.ComputerUtil; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.view.ButtonUtil; /** @@ -307,7 +307,7 @@ public class CostMana extends CostPart { public void selectButtonCancel() { this.stop(); payment.cancelCost(); - AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); + AllZone.getHumanPlayer().getZone(ZoneType.Battlefield).updateObservers(); } @Override @@ -467,7 +467,7 @@ public class CostMana extends CostPart { this.stop(); this.resetManaCost(); payment.cancelCost(); - AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); + AllZone.getHumanPlayer().getZone(ZoneType.Battlefield).updateObservers(); } @Override diff --git a/src/main/java/forge/card/cost/CostMill.java b/src/main/java/forge/card/cost/CostMill.java index 01cf7dcf374..274a6ce651a 100644 --- a/src/main/java/forge/card/cost/CostMill.java +++ b/src/main/java/forge/card/cost/CostMill.java @@ -22,14 +22,13 @@ import java.util.Iterator; import forge.AllZone; import forge.Card; import forge.CardList; -import forge.Constant; -import forge.Constant.Zone; import forge.GameActionUtil; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; import forge.card.spellability.SpellAbility; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; /** * This is for the "Mill" Cost. Putting cards from the top of your library into @@ -57,7 +56,7 @@ public class CostMill extends CostPartWithList { */ @Override public final boolean canPay(final SpellAbility ability, final Card source, final Player activator, final Cost cost) { - final PlayerZone zone = activator.getZone(Constant.Zone.Library); + final PlayerZone zone = activator.getZone(ZoneType.Library); Integer i = this.convertAmount(); @@ -95,7 +94,7 @@ public class CostMill extends CostPartWithList { c = AbilityFactory.calculateAmount(source, this.getAmount(), ability); } - this.setList(AllZone.getComputerPlayer().getCardsIn(Zone.Library, c)); + this.setList(AllZone.getComputerPlayer().getCardsIn(ZoneType.Library, c)); if ((this.getList() == null) || (this.getList().size() < c)) { return false; @@ -139,7 +138,7 @@ public class CostMill extends CostPartWithList { c = AbilityFactory.calculateAmount(source, amount, ability); } } - final CardList list = activator.getCardsIn(Zone.Library, c); + final CardList 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/CostPutCounter.java b/src/main/java/forge/card/cost/CostPutCounter.java index 16241b3378d..610b61c17f0 100644 --- a/src/main/java/forge/card/cost/CostPutCounter.java +++ b/src/main/java/forge/card/cost/CostPutCounter.java @@ -19,7 +19,6 @@ package forge.card.cost; import forge.Card; import forge.CardList; -import forge.Constant.Zone; import forge.Counters; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; @@ -27,7 +26,8 @@ import forge.card.cardfactory.CardFactoryUtil; import forge.card.spellability.SpellAbility; import forge.control.input.Input; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.view.ButtonUtil; /** @@ -135,7 +135,7 @@ public class CostPutCounter extends CostPartWithList { } } else { // 3 Cards have Put a -1/-1 Counter on a Creature you control. - final CardList typeList = activator.getCardsIn(Zone.Battlefield).getValidCards(this.getType().split(";"), + final CardList typeList = activator.getCardsIn(ZoneType.Battlefield).getValidCards(this.getType().split(";"), activator, source); if (typeList.size() == 0) { @@ -214,7 +214,7 @@ public class CostPutCounter extends CostPartWithList { c = AbilityFactory.calculateAmount(source, this.getAmount(), ability); } - final CardList typeList = activator.getCardsIn(Zone.Battlefield).getValidCards(this.getType().split(";"), + final CardList typeList = activator.getCardsIn(ZoneType.Battlefield).getValidCards(this.getType().split(";"), activator, source); Card card = null; @@ -268,7 +268,7 @@ public class CostPutCounter extends CostPartWithList { msg.append("s"); } - this.typeList = sa.getActivatingPlayer().getCardsIn(Zone.Battlefield); + this.typeList = sa.getActivatingPlayer().getCardsIn(ZoneType.Battlefield); this.typeList = this.typeList.getValidCards(type.split(";"), sa.getActivatingPlayer(), sa.getSourceCard()); Singletons.getControl().getControlMatch().showMessage(msg.toString()); diff --git a/src/main/java/forge/card/cost/CostReturn.java b/src/main/java/forge/card/cost/CostReturn.java index 72ab989eccb..9d5032f8d01 100644 --- a/src/main/java/forge/card/cost/CostReturn.java +++ b/src/main/java/forge/card/cost/CostReturn.java @@ -22,14 +22,14 @@ import javax.swing.JOptionPane; import forge.AllZoneUtil; import forge.Card; import forge.CardList; -import forge.Constant.Zone; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; import forge.card.spellability.SpellAbility; import forge.control.input.Input; import forge.game.player.ComputerUtil; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.view.ButtonUtil; /** @@ -105,7 +105,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(Zone.Battlefield); + CardList typeList = activator.getCardsIn(ZoneType.Battlefield); typeList = typeList.getValidCards(this.getType().split(";"), activator, source); final Integer amount = this.convertAmount(); @@ -144,7 +144,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(Zone.Battlefield); + final CardList list = activator.getCardsIn(ZoneType.Battlefield); if (c == null) { final String sVar = source.getSVar(amount); // Generalize this @@ -228,7 +228,7 @@ public class CostReturn extends CostPartWithList { msg.append("s"); } - this.typeList = sa.getActivatingPlayer().getCardsIn(Zone.Battlefield); + this.typeList = sa.getActivatingPlayer().getCardsIn(ZoneType.Battlefield); this.typeList = this.typeList.getValidCards(type.split(";"), sa.getActivatingPlayer(), sa.getSourceCard()); Singletons.getControl().getControlMatch().showMessage(msg.toString()); diff --git a/src/main/java/forge/card/cost/CostReveal.java b/src/main/java/forge/card/cost/CostReveal.java index 2c847d64f38..cd6a079251c 100644 --- a/src/main/java/forge/card/cost/CostReveal.java +++ b/src/main/java/forge/card/cost/CostReveal.java @@ -20,15 +20,14 @@ package forge.card.cost; import forge.AllZone; import forge.Card; import forge.CardList; -import forge.Constant; -import forge.Constant.Zone; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; import forge.card.spellability.SpellAbility; import forge.control.input.Input; import forge.game.player.ComputerUtil; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.view.ButtonUtil; @@ -61,12 +60,12 @@ 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(Zone.Hand); + CardList handList = activator.getCardsIn(ZoneType.Hand); final String type = this.getType(); final Integer amount = this.convertAmount(); if (this.getThis()) { - if (!source.isInZone(Constant.Zone.Hand)) { + if (!source.isInZone(ZoneType.Hand)) { return false; } } else { @@ -91,7 +90,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(Zone.Hand); + CardList hand = activator.getCardsIn(ZoneType.Hand); this.resetList(); if (this.getThis()) { @@ -147,7 +146,7 @@ public class CostReveal extends CostPartWithList { } else { Integer c = this.convertAmount(); - CardList handList = activator.getCardsIn(Zone.Hand); + CardList handList = activator.getCardsIn(ZoneType.Hand); handList = handList.getValidCards(this.getType().split(";"), activator, ability.getSourceCard()); if (c == null) { @@ -241,7 +240,7 @@ public class CostReveal extends CostPartWithList { this.done(); } - if (AllZone.getHumanPlayer().getZone(Zone.Hand).size() < nNeeded) { + if (AllZone.getHumanPlayer().getZone(ZoneType.Hand).size() < nNeeded) { this.stop(); } final StringBuilder type = new StringBuilder(""); @@ -268,7 +267,7 @@ public class CostReveal extends CostPartWithList { @Override public void selectCard(final Card card, final PlayerZone zone) { - if (zone.is(Constant.Zone.Hand) && handList.contains(card)) { + if (zone.is(ZoneType.Hand) && handList.contains(card)) { // send in CardList for Typing handList.remove(card); part.addToList(card); @@ -277,7 +276,7 @@ public class CostReveal extends CostPartWithList { // in case no more cards in hand if (this.nReveal == nNeeded) { this.done(); - } else if (AllZone.getHumanPlayer().getZone(Zone.Hand).size() == 0) { + } else if (AllZone.getHumanPlayer().getZone(ZoneType.Hand).size() == 0) { // really // shouldn't // happen diff --git a/src/main/java/forge/card/cost/CostSacrifice.java b/src/main/java/forge/card/cost/CostSacrifice.java index 8b11526aca8..c6112eedfbf 100644 --- a/src/main/java/forge/card/cost/CostSacrifice.java +++ b/src/main/java/forge/card/cost/CostSacrifice.java @@ -22,14 +22,14 @@ import javax.swing.JOptionPane; import forge.AllZoneUtil; import forge.Card; import forge.CardList; -import forge.Constant.Zone; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; import forge.card.spellability.SpellAbility; import forge.control.input.Input; import forge.game.player.ComputerUtil; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.view.ButtonUtil; /** @@ -98,7 +98,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(Zone.Battlefield); + CardList typeList = activator.getCardsIn(ZoneType.Battlefield); typeList = typeList.getValidCards(this.getType().split(";"), activator, source); final Integer amount = this.convertAmount(); @@ -143,7 +143,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(Zone.Battlefield); + CardList list = activator.getCardsIn(ZoneType.Battlefield); list = list.getValidCards(type.split(";"), activator, source); if (this.getThis()) { @@ -188,7 +188,7 @@ public class CostSacrifice extends CostPartWithList { if (this.getThis()) { this.getList().add(source); } else if (this.getAmount().equals("All")) { - CardList typeList = activator.getCardsIn(Zone.Battlefield); + CardList typeList = activator.getCardsIn(ZoneType.Battlefield); typeList = typeList.getValidCards(this.getType().split(","), activator, source); // Does the AI want to use Sacrifice All? return false; diff --git a/src/main/java/forge/card/cost/CostTapType.java b/src/main/java/forge/card/cost/CostTapType.java index 806f19ed683..b25cb7f89fc 100644 --- a/src/main/java/forge/card/cost/CostTapType.java +++ b/src/main/java/forge/card/cost/CostTapType.java @@ -20,15 +20,14 @@ package forge.card.cost; import forge.Card; import forge.CardList; import forge.CardListFilter; -import forge.Constant; -import forge.Constant.Zone; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; import forge.card.spellability.SpellAbility; import forge.control.input.Input; import forge.game.player.ComputerUtil; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.view.ButtonUtil; /** @@ -113,7 +112,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(Zone.Battlefield); + CardList typeList = activator.getCardsIn(ZoneType.Battlefield); typeList = typeList.getValidCards(this.getType().split(";"), activator, source); @@ -152,7 +151,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(Zone.Battlefield); + CardList typeList = ability.getActivatingPlayer().getCardsIn(ZoneType.Battlefield); typeList = typeList.getValidCards(this.getType().split(";"), ability.getActivatingPlayer(), ability.getSourceCard()); typeList = typeList.filter(CardListFilter.UNTAPPED); @@ -187,7 +186,7 @@ public class CostTapType extends CostPartWithList { if (c == null) { final String sVar = source.getSVar(amount); if (sVar.equals("XChoice")) { - CardList typeList = ability.getActivatingPlayer().getCardsIn(Zone.Battlefield); + CardList typeList = ability.getActivatingPlayer().getCardsIn(ZoneType.Battlefield); typeList = typeList.getValidCards(this.getType().split(";"), ability.getActivatingPlayer(), ability.getSourceCard()); typeList = typeList.filter(CardListFilter.UNTAPPED); @@ -255,7 +254,7 @@ public class CostTapType extends CostPartWithList { @Override public void selectCard(final Card card, final PlayerZone zone) { - if (zone.is(Constant.Zone.Battlefield) && cardList.contains(card) && card.isUntapped()) { + if (zone.is(ZoneType.Battlefield) && cardList.contains(card) && card.isUntapped()) { // send in CardList for Typing card.tap(); tapType.addToList(card); diff --git a/src/main/java/forge/card/cost/CostUtil.java b/src/main/java/forge/card/cost/CostUtil.java index 032c77e77b3..d4fd40fbd57 100644 --- a/src/main/java/forge/card/cost/CostUtil.java +++ b/src/main/java/forge/card/cost/CostUtil.java @@ -22,12 +22,12 @@ import java.util.Random; import forge.AllZone; import forge.Card; import forge.CardList; -import forge.Constant.Zone; import forge.Counters; import forge.card.abilityfactory.AbilityFactory; import forge.card.spellability.SpellAbility; import forge.control.input.Input; import forge.game.player.ComputerUtil; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; /** @@ -61,7 +61,7 @@ public class CostUtil { continue; } - CardList typeList = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList typeList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); typeList = typeList.getValidCards(type.split(","), source.getController(), source); if (ComputerUtil.getCardPreference(source, "SacCost", typeList) == null) { return false; @@ -96,7 +96,7 @@ public class CostUtil { continue; } - CardList typeList = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList typeList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); typeList = typeList.getValidCards(type.split(","), source.getController(), source); if (ComputerUtil.getCardPreference(source, "SacCost", typeList) == null) { return false; @@ -150,7 +150,7 @@ public class CostUtil { final CostDiscard disc = (CostDiscard) part; final String type = disc.getType(); - CardList typeList = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + CardList typeList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); typeList = typeList.getValidCards(type.split(","), source.getController(), source); if (ComputerUtil.getCardPreference(source, "DiscardCost", typeList) == null) { return false; diff --git a/src/main/java/forge/card/replacement/ReplaceMoved.java b/src/main/java/forge/card/replacement/ReplaceMoved.java index 6571829d9d9..7ec52ca31e0 100644 --- a/src/main/java/forge/card/replacement/ReplaceMoved.java +++ b/src/main/java/forge/card/replacement/ReplaceMoved.java @@ -3,8 +3,8 @@ package forge.card.replacement; import java.util.HashMap; import forge.Card; -import forge.Constant.Zone; import forge.card.spellability.SpellAbility; +import forge.game.zone.ZoneType; /** * TODO: Write javadoc for this type. @@ -36,14 +36,14 @@ public class ReplaceMoved extends ReplacementEffect { } } if (this.getMapParams().containsKey("Origin")) { - Zone z = Zone.smartValueOf(this.getMapParams().get("Origin")); - if (z != (Zone) runParams.get("Origin")) { + ZoneType z = ZoneType.smartValueOf(this.getMapParams().get("Origin")); + if (z != (ZoneType) runParams.get("Origin")) { return false; } } if (this.getMapParams().containsKey("Destination")) { - Zone z = Zone.smartValueOf(this.getMapParams().get("Destination")); - if (z != (Zone) runParams.get("Destination")) { + ZoneType z = ZoneType.smartValueOf(this.getMapParams().get("Destination")); + if (z != (ZoneType) runParams.get("Destination")) { return false; } } diff --git a/src/main/java/forge/card/replacement/ReplacementEffect.java b/src/main/java/forge/card/replacement/ReplacementEffect.java index 9266be0befd..345e39982af 100644 --- a/src/main/java/forge/card/replacement/ReplacementEffect.java +++ b/src/main/java/forge/card/replacement/ReplacementEffect.java @@ -23,11 +23,11 @@ import forge.AllZoneUtil; import forge.Card; import forge.CardList; import forge.CardUtil; -import forge.Constant.Zone; import forge.card.TriggerReplacementBase; import forge.card.abilityfactory.AbilityFactory; import forge.card.cardfactory.CardFactoryUtil; import forge.card.spellability.SpellAbility; +import forge.game.zone.ZoneType; /** * TODO: Write javadoc for this type. @@ -263,13 +263,13 @@ public abstract class ReplacementEffect extends TriggerReplacementBase { if (this.getMapParams().containsKey("IsPresent")) { final String sIsPresent = this.getMapParams().get("IsPresent"); String presentCompare = "GE1"; - Zone presentZone = Zone.Battlefield; + ZoneType presentZone = ZoneType.Battlefield; String presentPlayer = "Any"; if (this.getMapParams().containsKey("PresentCompare")) { presentCompare = this.getMapParams().get("PresentCompare"); } if (this.getMapParams().containsKey("PresentZone")) { - presentZone = Zone.smartValueOf(this.getMapParams().get("PresentZone")); + presentZone = ZoneType.smartValueOf(this.getMapParams().get("PresentZone")); } if (this.getMapParams().containsKey("PresentPlayer")) { presentPlayer = this.getMapParams().get("PresentPlayer"); @@ -302,13 +302,13 @@ public abstract class ReplacementEffect extends TriggerReplacementBase { if (this.getMapParams().containsKey("IsPresent2")) { final String sIsPresent = this.getMapParams().get("IsPresent2"); String presentCompare = "GE1"; - Zone presentZone = Zone.Battlefield; + ZoneType presentZone = ZoneType.Battlefield; String presentPlayer = "Any"; if (this.getMapParams().containsKey("PresentCompare2")) { presentCompare = this.getMapParams().get("PresentCompare2"); } if (this.getMapParams().containsKey("PresentZone2")) { - presentZone = Zone.smartValueOf(this.getMapParams().get("PresentZone2")); + presentZone = ZoneType.smartValueOf(this.getMapParams().get("PresentZone2")); } if (this.getMapParams().containsKey("PresentPlayer2")) { presentPlayer = this.getMapParams().get("PresentPlayer2"); diff --git a/src/main/java/forge/card/replacement/ReplacementHandler.java b/src/main/java/forge/card/replacement/ReplacementHandler.java index 9dfb340b3ad..1fa9006d647 100644 --- a/src/main/java/forge/card/replacement/ReplacementHandler.java +++ b/src/main/java/forge/card/replacement/ReplacementHandler.java @@ -23,13 +23,13 @@ import java.util.List; import forge.AllZone; import forge.Card; -import forge.Constant.Zone; import forge.GameActionUtil; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; import forge.card.spellability.SpellAbility; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; /** @@ -71,7 +71,7 @@ public class ReplacementHandler { // Round up Static replacement effects for (final Player p : AllZone.getPlayersInGame()) { - for (final Card crd : p.getCardsIn(Zone.Battlefield)) { + for (final Card crd : p.getCardsIn(ZoneType.Battlefield)) { for (final ReplacementEffect replacementEffect : crd.getReplacementEffects()) { if (replacementEffect.requirementsCheck()) { if (!replacementEffect.hasRun() && replacementEffect.canReplace(runParams)) { diff --git a/src/main/java/forge/card/spellability/AbilityActivated.java b/src/main/java/forge/card/spellability/AbilityActivated.java index 10c55a366d0..3a2e7e47d11 100644 --- a/src/main/java/forge/card/spellability/AbilityActivated.java +++ b/src/main/java/forge/card/spellability/AbilityActivated.java @@ -23,10 +23,10 @@ import forge.AllZone; import forge.AllZoneUtil; import forge.Card; import forge.CardList; -import forge.Constant.Zone; import forge.card.cost.Cost; import forge.card.cost.CostPayment; import forge.card.staticability.StaticAbility; +import forge.game.zone.ZoneType; /** *

@@ -90,7 +90,7 @@ public abstract class AbilityActivated extends SpellAbility implements java.io.S } // CantBeActivated static abilities - final CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList 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 c9ab14504cb..f6296b7804b 100644 --- a/src/main/java/forge/card/spellability/Spell.java +++ b/src/main/java/forge/card/spellability/Spell.java @@ -23,8 +23,6 @@ import forge.AllZone; import forge.AllZoneUtil; import forge.Card; import forge.CardList; -import forge.Constant; -import forge.Constant.Zone; import forge.card.cardfactory.CardFactoryUtil; import forge.card.cost.Cost; import forge.card.cost.CostPayment; @@ -32,6 +30,7 @@ import forge.card.staticability.StaticAbility; import forge.error.ErrorViewer; import forge.game.phase.PhaseHandler; import forge.game.player.Player; +import forge.game.zone.ZoneType; /** *

@@ -59,7 +58,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable this.setManaCost(sourceCard.getManaCost()); this.setStackDescription(sourceCard.getSpellText()); - this.getRestrictions().setZone(Constant.Zone.Hand); + this.getRestrictions().setZone(ZoneType.Hand); } /** @@ -82,7 +81,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable this.setPayCosts(abCost); this.setTarget(abTgt); this.setStackDescription(sourceCard.getSpellText()); - this.getRestrictions().setZone(Constant.Zone.Hand); + this.getRestrictions().setZone(ZoneType.Hand); } /** {@inheritDoc} */ @@ -116,7 +115,7 @@ public abstract class Spell extends SpellAbility implements java.io.Serializable } // CantBeCast static abilities - final CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); allp.add(card); for (final Card ca : allp) { final ArrayList staticAbilities = ca.getStaticAbilities(); @@ -136,7 +135,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(Zone.Battlefield); + CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = list.getValidCards(needsToPlay.split(","), card.getController(), card); if (list.isEmpty()) { diff --git a/src/main/java/forge/card/spellability/SpellAbilityCondition.java b/src/main/java/forge/card/spellability/SpellAbilityCondition.java index bb907dc9a65..88918361a8b 100644 --- a/src/main/java/forge/card/spellability/SpellAbilityCondition.java +++ b/src/main/java/forge/card/spellability/SpellAbilityCondition.java @@ -21,13 +21,13 @@ import java.util.HashMap; import forge.AllZoneUtil; import forge.CardList; -import forge.Constant.Zone; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; import forge.card.cardfactory.CardFactoryUtil; import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseType; import forge.game.player.Player; +import forge.game.zone.ZoneType; /** *

@@ -78,7 +78,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables { } if (params.containsKey("ConditionZone")) { - this.setZone(Zone.smartValueOf(params.get("ContitionZone"))); + this.setZone(ZoneType.smartValueOf(params.get("ContitionZone"))); } if (params.containsKey("ConditionSorcerySpeed")) { @@ -233,7 +233,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables { if (this.getCardsInHand() != -1) { // Can handle Library of Alexandria, or Hellbent - if (activator.getCardsIn(Zone.Hand).size() != this.getCardsInHand()) { + if (activator.getCardsIn(ZoneType.Hand).size() != this.getCardsInHand()) { return false; } } @@ -243,7 +243,7 @@ public class SpellAbilityCondition extends SpellAbilityVariables { if (this.getPresentDefined() != null) { list.addAll(AbilityFactory.getDefinedCards(sa.getSourceCard(), this.getPresentDefined(), sa)); } else { - list = AllZoneUtil.getCardsIn(Zone.Battlefield); + list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); } list = list.getValidCards(this.getIsPresent().split(","), sa.getActivatingPlayer(), sa.getSourceCard()); diff --git a/src/main/java/forge/card/spellability/SpellAbilityRequirements.java b/src/main/java/forge/card/spellability/SpellAbilityRequirements.java index cef40d0260e..82677d5050f 100644 --- a/src/main/java/forge/card/spellability/SpellAbilityRequirements.java +++ b/src/main/java/forge/card/spellability/SpellAbilityRequirements.java @@ -24,7 +24,7 @@ import forge.Card; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; import forge.card.cost.CostPayment; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; /** *

diff --git a/src/main/java/forge/card/spellability/SpellAbilityRestriction.java b/src/main/java/forge/card/spellability/SpellAbilityRestriction.java index 422e9c1503e..97efe12038d 100644 --- a/src/main/java/forge/card/spellability/SpellAbilityRestriction.java +++ b/src/main/java/forge/card/spellability/SpellAbilityRestriction.java @@ -23,14 +23,14 @@ import forge.AllZone; import forge.AllZoneUtil; import forge.Card; import forge.CardList; -import forge.Constant.Zone; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; import forge.card.cardfactory.CardFactoryUtil; import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseType; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; /** *

@@ -90,11 +90,11 @@ public class SpellAbilityRestriction extends SpellAbilityVariables { } if (params.containsKey("ActivationZone")) { - this.setZone(Zone.smartValueOf(params.get("ActivationZone"))); + this.setZone(ZoneType.smartValueOf(params.get("ActivationZone"))); } if (params.containsKey("Flashback")) { - this.setZone(Zone.Graveyard); + this.setZone(ZoneType.Graveyard); } if (params.containsKey("SorcerySpeed")) { @@ -144,7 +144,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables { this.setPresentCompare(params.get("PresentCompare")); } if (params.containsKey("PresentZone")) { - this.setPresentZone(Zone.smartValueOf(params.get("PresentZone"))); + this.setPresentZone(ZoneType.smartValueOf(params.get("PresentZone"))); } } @@ -188,7 +188,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables { if (!cardZone.is(this.getZone())) { // If Card is not in the default activating zone, do some additional checks // Not a Spell, or on Battlefield, return false - if (!sa.isSpell() || cardZone.is(Zone.Battlefield) || !this.getZone().equals(Zone.Hand)) { + if (!sa.isSpell() || cardZone.is(ZoneType.Battlefield) || !this.getZone().equals(ZoneType.Hand)) { return false; } else if (!c.hasKeyword("May be played") && !c.hasKeyword("May be played by your opponent")) { return false; @@ -282,7 +282,7 @@ public class SpellAbilityRestriction extends SpellAbilityVariables { } if (this.getCardsInHand() != -1) { - if (activator.getCardsIn(Zone.Hand).size() != this.getCardsInHand()) { + if (activator.getCardsIn(ZoneType.Hand).size() != this.getCardsInHand()) { return false; } } diff --git a/src/main/java/forge/card/spellability/SpellAbilityVariables.java b/src/main/java/forge/card/spellability/SpellAbilityVariables.java index 76a13c9d144..0811b1c2c91 100644 --- a/src/main/java/forge/card/spellability/SpellAbilityVariables.java +++ b/src/main/java/forge/card/spellability/SpellAbilityVariables.java @@ -20,8 +20,8 @@ package forge.card.spellability; import java.util.ArrayList; import java.util.List; -import forge.Constant; import forge.game.phase.PhaseType; +import forge.game.zone.ZoneType; /** *

@@ -85,7 +85,7 @@ public class SpellAbilityVariables { // default values for Sorcery speed abilities /** The zone. */ - private Constant.Zone zone = Constant.Zone.Battlefield; + private ZoneType zone = ZoneType.Battlefield; /** The phases. */ private List phases = new ArrayList(); @@ -140,7 +140,7 @@ public class SpellAbilityVariables { private String presentDefined = null; /** The present zone. */ - private Constant.Zone presentZone = Constant.Zone.Battlefield; + private ZoneType presentZone = ZoneType.Battlefield; /** The svar to check. */ private String sVarToCheck = null; @@ -246,7 +246,7 @@ public class SpellAbilityVariables { * @param zone * a {@link java.lang.String} object. */ - public final void setZone(final Constant.Zone zone) { + public final void setZone(final ZoneType zone) { this.zone = zone; } @@ -257,7 +257,7 @@ public class SpellAbilityVariables { * * @return a {@link java.lang.String} object. */ - public final Constant.Zone getZone() { + public final ZoneType getZone() { return this.zone; } @@ -533,7 +533,7 @@ public class SpellAbilityVariables { * * @return the present zone */ - public final Constant.Zone getPresentZone() { + public final ZoneType getPresentZone() { return this.presentZone; } @@ -543,7 +543,7 @@ public class SpellAbilityVariables { * @param presentZone * the new present zone */ - public final void setPresentZone(final Constant.Zone presentZone) { + public final void setPresentZone(final ZoneType presentZone) { this.presentZone = presentZone; } diff --git a/src/main/java/forge/card/spellability/SpellPermanent.java b/src/main/java/forge/card/spellability/SpellPermanent.java index 35c9cd97708..128044917ed 100644 --- a/src/main/java/forge/card/spellability/SpellPermanent.java +++ b/src/main/java/forge/card/spellability/SpellPermanent.java @@ -26,8 +26,6 @@ import forge.CardList; import forge.CardUtil; import forge.Command; import forge.CommandReturn; -import forge.Constant; -import forge.Constant.Zone; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; import forge.card.cardfactory.CardFactoryUtil; @@ -39,6 +37,7 @@ import forge.game.phase.PhaseType; import forge.game.player.ComputerAIGeneral; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.view.ButtonUtil; /** @@ -76,7 +75,7 @@ public class SpellPermanent extends Spell { private final CommandReturn championGetCreature = new CommandReturn() { @Override public Object execute() { - final CardList cards = SpellPermanent.this.getSourceCard().getController().getCardsIn(Zone.Battlefield); + final CardList cards = SpellPermanent.this.getSourceCard().getController().getCardsIn(ZoneType.Battlefield); return cards.getValidCards(SpellPermanent.this.championValid, SpellPermanent.this.getSourceCard() .getController(), SpellPermanent.this.getSourceCard()); } @@ -97,7 +96,7 @@ public class SpellPermanent extends Spell { } else if (controller.isHuman()) { AllZone.getInputControl().setInput(SpellPermanent.this.championInputComes); } else { // Computer - CardList computer = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList computer = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); computer = computer.getValidCards(SpellPermanent.this.championValid, controller, source); computer.remove(source); @@ -288,7 +287,7 @@ public class SpellPermanent extends Spell { wait = false; } // get all cards the computer controls with BuffedBy - final CardList buffed = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + final CardList 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) { @@ -301,7 +300,7 @@ public class SpellPermanent extends Spell { } // BuffedBy // get all cards the human controls with AntiBuffedBy - final CardList antibuffed = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); + final CardList 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) { @@ -312,9 +311,9 @@ public class SpellPermanent extends Spell { } } } // AntiBuffedBy - final CardList vengevines = AllZone.getComputerPlayer().getCardsIn(Zone.Graveyard, "Vengevine"); + final CardList vengevines = AllZone.getComputerPlayer().getCardsIn(ZoneType.Graveyard, "Vengevine"); if (vengevines.size() > 0) { - final CardList creatures = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + final CardList creatures = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); final CardList creatures2 = new CardList(); for (int i = 0; i < creatures.size(); i++) { if (creatures.get(i).isCreature() @@ -360,13 +359,13 @@ public class SpellPermanent extends Spell { String mana = this.getPayCosts().getTotalMana(); // check on legendary if (card.isType("Legendary")) { - final CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + final CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); if (list.containsName(card.getName())) { return false; } } if (card.isPlaneswalker()) { - CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); list = list.getType("Planeswalker"); for (int i = 0; i < list.size(); i++) { @@ -379,7 +378,7 @@ public class SpellPermanent extends Spell { } } if (card.isType("World")) { - CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); list = list.getType("World"); if (list.size() > 0) { return false; @@ -398,7 +397,7 @@ public class SpellPermanent extends Spell { } final CardList cl = (CardList) this.championGetCreature.execute(); - if ((o == null) || !(cl.size() > 0) || !this.getSourceCard().isInZone(Constant.Zone.Hand)) { + if ((o == null) || !(cl.size() > 0) || !this.getSourceCard().isInZone(ZoneType.Hand)) { return false; } } @@ -436,7 +435,7 @@ public class SpellPermanent extends Spell { continue; } - if (!params.get("Destination").equals(Zone.Battlefield.toString())) { + if (!params.get("Destination").equals(ZoneType.Battlefield.toString())) { continue; } @@ -494,6 +493,6 @@ public class SpellPermanent extends Spell { public void resolve() { final Card c = this.getSourceCard(); c.addController(this.getActivatingPlayer()); - Singletons.getModel().getGameAction().moveTo(this.getActivatingPlayer().getZone(Constant.Zone.Battlefield), c); + Singletons.getModel().getGameAction().moveTo(this.getActivatingPlayer().getZone(ZoneType.Battlefield), c); } } diff --git a/src/main/java/forge/card/spellability/Target.java b/src/main/java/forge/card/spellability/Target.java index 05388b2578b..1b74a1f6eff 100644 --- a/src/main/java/forge/card/spellability/Target.java +++ b/src/main/java/forge/card/spellability/Target.java @@ -24,9 +24,9 @@ import java.util.List; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.Constant; import forge.card.abilityfactory.AbilityFactory; import forge.game.player.Player; +import forge.game.zone.ZoneType; /** *

@@ -240,7 +240,7 @@ public class Target { return (this.choice != null) && (this.getMinTargets(c, sa) <= this.choice.getNumTargeted()); } - private List tgtZone = Arrays.asList(Constant.Zone.Battlefield); + private List tgtZone = Arrays.asList(ZoneType.Battlefield); /** *

@@ -250,7 +250,7 @@ public class Target { * @param tZone * a {@link java.lang.String} object. */ - public final void setZone(final Constant.Zone tZone) { + public final void setZone(final ZoneType tZone) { this.tgtZone = Arrays.asList(tZone); } @@ -260,7 +260,7 @@ public class Target { * @param tZone * the new zone */ - public final void setZone(final List tZone) { + public final void setZone(final List tZone) { this.tgtZone = tZone; } @@ -271,7 +271,7 @@ public class Target { * * @return a {@link java.lang.String} object. */ - public final List getZone() { + public final List getZone() { return this.tgtZone; } diff --git a/src/main/java/forge/card/spellability/TargetSelection.java b/src/main/java/forge/card/spellability/TargetSelection.java index fc1911e64b0..b4a81fc7870 100644 --- a/src/main/java/forge/card/spellability/TargetSelection.java +++ b/src/main/java/forge/card/spellability/TargetSelection.java @@ -25,13 +25,12 @@ import forge.AllZone; import forge.AllZoneUtil; import forge.Card; import forge.CardList; -import forge.Constant; -import forge.Constant.Zone; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; import forge.control.input.Input; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.view.ButtonUtil; @@ -250,10 +249,10 @@ public class TargetSelection { */ public final void chooseValidInput() { final Target tgt = this.getTgt(); - final List zone = tgt.getZone(); + final List zone = tgt.getZone(); final boolean mandatory = this.target.getMandatory() ? this.target.hasCandidates(this.ability, true) : false; - if (zone.contains(Constant.Zone.Stack) && (zone.size() == 1)) { + if (zone.contains(ZoneType.Stack) && (zone.size() == 1)) { // If Zone is Stack, the choices are handled slightly differently this.chooseCardFromStack(mandatory); return; @@ -301,7 +300,7 @@ public class TargetSelection { } } - if (zone.contains(Constant.Zone.Battlefield)) { + if (zone.contains(ZoneType.Battlefield)) { AllZone.getInputControl().setInput(this.inputTargetSpecific(choices, true, mandatory, objects)); } else { this.chooseCardFromList(choices, true, mandatory); diff --git a/src/main/java/forge/card/staticability/StaticAbility.java b/src/main/java/forge/card/staticability/StaticAbility.java index a6b60c72007..797a80c5154 100644 --- a/src/main/java/forge/card/staticability/StaticAbility.java +++ b/src/main/java/forge/card/staticability/StaticAbility.java @@ -24,13 +24,13 @@ import java.util.Map; import forge.AllZone; import forge.AllZoneUtil; import forge.Card; -import forge.Constant.Zone; import forge.GameEntity; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; import forge.card.spellability.SpellAbility; import forge.game.phase.PhaseType; import forge.game.player.Player; +import forge.game.zone.ZoneType; /** * The Class StaticAbility. @@ -384,12 +384,12 @@ public class StaticAbility { if (this.mapParams.containsKey("EffectZone")) { if (!this.mapParams.get("EffectZone").equals("All") - && !Zone.listValueOf(this.mapParams.get("EffectZone")) + && !ZoneType.listValueOf(this.mapParams.get("EffectZone")) .contains(AllZone.getZoneOf(this.hostCard).getZoneType())) { return false; } } else { - if (!this.hostCard.isInZone(Zone.Battlefield)) { // default + if (!this.hostCard.isInZone(ZoneType.Battlefield)) { // default return false; } } @@ -431,10 +431,10 @@ public class StaticAbility { } if (this.mapParams.containsKey("TopCardOfLibraryIs")) { - if (controller.getCardsIn(Zone.Library).isEmpty()) { + if (controller.getCardsIn(ZoneType.Library).isEmpty()) { return false; } - final Card topCard = controller.getCardsIn(Zone.Library).get(0); + final Card topCard = controller.getCardsIn(ZoneType.Library).get(0); if (!topCard.isValid(this.mapParams.get("TopCardOfLibraryIs").split(","), controller, this.hostCard)) { return false; } diff --git a/src/main/java/forge/card/staticability/StaticAbilityCantBeCast.java b/src/main/java/forge/card/staticability/StaticAbilityCantBeCast.java index 91f4336355d..9d201b36b33 100644 --- a/src/main/java/forge/card/staticability/StaticAbilityCantBeCast.java +++ b/src/main/java/forge/card/staticability/StaticAbilityCantBeCast.java @@ -22,11 +22,11 @@ import java.util.List; import forge.AllZone; import forge.Card; -import forge.Constant.Zone; import forge.card.spellability.AbilityMana; import forge.card.spellability.SpellAbility; import forge.game.phase.PhaseHandler; import forge.game.player.Player; +import forge.game.zone.ZoneType; /** * The Class StaticAbility_CantBeCast. @@ -63,7 +63,7 @@ public class StaticAbilityCantBeCast { } if (params.containsKey("Origin")) { - List src = Zone.listValueOf(params.get("Origin")); + List src = ZoneType.listValueOf(params.get("Origin")); if (!src.contains(AllZone.getZoneOf(card).getZoneType())) { return false; } diff --git a/src/main/java/forge/card/staticability/StaticAbilityCantTarget.java b/src/main/java/forge/card/staticability/StaticAbilityCantTarget.java index e5bf195184c..818750e7caf 100644 --- a/src/main/java/forge/card/staticability/StaticAbilityCantTarget.java +++ b/src/main/java/forge/card/staticability/StaticAbilityCantTarget.java @@ -20,10 +20,9 @@ package forge.card.staticability; import java.util.HashMap; import forge.Card; -import forge.Constant; -import forge.Constant.Zone; import forge.card.spellability.SpellAbility; import forge.game.player.Player; +import forge.game.zone.ZoneType; /** * The Class StaticAbilityCantTarget. @@ -49,11 +48,11 @@ public class StaticAbilityCantTarget { final Player activator = spellAbility.getActivatingPlayer(); if (params.containsKey("AffectedZone")) { - if (!card.isInZone(Zone.smartValueOf(params.get("AffectedZone")))) { + if (!card.isInZone(ZoneType.smartValueOf(params.get("AffectedZone")))) { return false; } } else { // default zone is battlefield - if (!card.isInZone(Constant.Zone.Battlefield)) { + if (!card.isInZone(ZoneType.Battlefield)) { return false; } } diff --git a/src/main/java/forge/card/staticability/StaticAbilityContinuous.java b/src/main/java/forge/card/staticability/StaticAbilityContinuous.java index 705674e6167..583b757b188 100644 --- a/src/main/java/forge/card/staticability/StaticAbilityContinuous.java +++ b/src/main/java/forge/card/staticability/StaticAbilityContinuous.java @@ -26,7 +26,6 @@ import forge.AllZoneUtil; import forge.Card; import forge.CardList; import forge.CardUtil; -import forge.Constant.Zone; import forge.StaticEffect; import forge.card.abilityfactory.AbilityFactory; import forge.card.cardfactory.CardFactoryUtil; @@ -35,6 +34,7 @@ import forge.card.spellability.SpellAbility; import forge.card.trigger.Trigger; import forge.card.trigger.TriggerHandler; import forge.game.player.Player; +import forge.game.zone.ZoneType; /** * The Class StaticAbility_Continuous. @@ -374,9 +374,9 @@ public class StaticAbilityContinuous { CardList affectedCards = new CardList(); if (params.containsKey("AffectedZone")) { - affectedCards.addAll(AllZoneUtil.getCardsIn(Zone.listValueOf(params.get("AffectedZone")))); + affectedCards.addAll(AllZoneUtil.getCardsIn(ZoneType.listValueOf(params.get("AffectedZone")))); } else { - affectedCards = AllZoneUtil.getCardsIn(Zone.Battlefield); + affectedCards = AllZoneUtil.getCardsIn(ZoneType.Battlefield); } if (params.containsKey("Affected") && !params.get("Affected").contains(",")) { diff --git a/src/main/java/forge/card/trigger/Trigger.java b/src/main/java/forge/card/trigger/Trigger.java index d335dd0492b..6d6e0dc94cc 100644 --- a/src/main/java/forge/card/trigger/Trigger.java +++ b/src/main/java/forge/card/trigger/Trigger.java @@ -26,14 +26,14 @@ import forge.AllZoneUtil; import forge.Card; import forge.CardList; import forge.CardUtil; -import forge.Constant.Zone; import forge.Singletons; import forge.card.TriggerReplacementBase; import forge.card.abilityfactory.AbilityFactory; import forge.card.cardfactory.CardFactoryUtil; import forge.card.spellability.SpellAbility; import forge.game.phase.PhaseType; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; /** *

@@ -395,13 +395,13 @@ public abstract class Trigger extends TriggerReplacementBase { if (this.getMapParams().containsKey("IsPresent")) { final String sIsPresent = this.getMapParams().get("IsPresent"); String presentCompare = "GE1"; - Zone presentZone = Zone.Battlefield; + ZoneType presentZone = ZoneType.Battlefield; String presentPlayer = "Any"; if (this.getMapParams().containsKey("PresentCompare")) { presentCompare = this.getMapParams().get("PresentCompare"); } if (this.getMapParams().containsKey("PresentZone")) { - presentZone = Zone.smartValueOf(this.getMapParams().get("PresentZone")); + presentZone = ZoneType.smartValueOf(this.getMapParams().get("PresentZone")); } if (this.getMapParams().containsKey("PresentPlayer")) { presentPlayer = this.getMapParams().get("PresentPlayer"); @@ -434,13 +434,13 @@ public abstract class Trigger extends TriggerReplacementBase { if (this.getMapParams().containsKey("IsPresent2")) { final String sIsPresent = this.getMapParams().get("IsPresent2"); String presentCompare = "GE1"; - Zone presentZone = Zone.Battlefield; + ZoneType presentZone = ZoneType.Battlefield; String presentPlayer = "Any"; if (this.getMapParams().containsKey("PresentCompare2")) { presentCompare = this.getMapParams().get("PresentCompare2"); } if (this.getMapParams().containsKey("PresentZone2")) { - presentZone = Zone.smartValueOf(this.getMapParams().get("PresentZone2")); + presentZone = ZoneType.smartValueOf(this.getMapParams().get("PresentZone2")); } if (this.getMapParams().containsKey("PresentPlayer2")) { presentPlayer = this.getMapParams().get("PresentPlayer2"); @@ -579,7 +579,7 @@ public abstract class Trigger extends TriggerReplacementBase { /** The temporary. */ private boolean temporary = false; - private EnumSet validHostZones; + private EnumSet validHostZones; /** * Sets the temporary. @@ -710,7 +710,7 @@ public abstract class Trigger extends TriggerReplacementBase { } - public void setTriggerZone(EnumSet zones) { + public void setTriggerZone(EnumSet zones) { validHostZones = zones; } diff --git a/src/main/java/forge/card/trigger/TriggerHandler.java b/src/main/java/forge/card/trigger/TriggerHandler.java index f95d5a47f84..6b80feb4dd1 100644 --- a/src/main/java/forge/card/trigger/TriggerHandler.java +++ b/src/main/java/forge/card/trigger/TriggerHandler.java @@ -27,8 +27,6 @@ import forge.Card; import forge.CardList; import forge.Command; import forge.CommandArgs; -import forge.Constant; -import forge.Constant.Zone; import forge.GameActionUtil; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; @@ -45,6 +43,7 @@ import forge.game.phase.PhaseType; //import forge.util.TextUtil; import forge.game.player.ComputerUtil; import forge.game.player.Player; +import forge.game.zone.ZoneType; /** *

@@ -208,7 +207,7 @@ public class TriggerHandler { String triggerZones = mapParams.remove("TriggerZones"); if ( null != triggerZones ) - ret.setTriggerZone(EnumSet.copyOf(Zone.listValueOf(triggerZones))); + ret.setTriggerZone(EnumSet.copyOf(ZoneType.listValueOf(triggerZones))); String triggerPhases = mapParams.remove("TriggerPhases"); if ( null != triggerPhases ) @@ -287,7 +286,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(Zone.StaticAbilitiesSourceZones); + CardList allCards = AllZoneUtil.getCardsIn(ZoneType.StaticAbilitiesSourceZones); boolean checkStatics = false; // Static triggers @@ -304,8 +303,8 @@ public class TriggerHandler { } // AP - allCards = playerAP.getCardsIn(Zone.StaticAbilitiesSourceZones); - allCards.addAll(AllZoneUtil.getCardsIn(Constant.Zone.Stack).getController(playerAP)); + allCards = playerAP.getCardsIn(ZoneType.StaticAbilitiesSourceZones); + allCards.addAll(AllZoneUtil.getCardsIn(ZoneType.Stack).getController(playerAP)); for (final Card c : allCards) { for (final Trigger t : c.getTriggers()) { if (!t.isStatic()) { @@ -325,8 +324,8 @@ public class TriggerHandler { } // NAP - allCards = playerAP.getOpponent().getCardsIn(Zone.StaticAbilitiesSourceZones); - allCards.addAll(AllZoneUtil.getCardsIn(Constant.Zone.Stack).getController(playerAP.getOpponent())); + allCards = playerAP.getOpponent().getCardsIn(ZoneType.StaticAbilitiesSourceZones); + allCards.addAll(AllZoneUtil.getCardsIn(ZoneType.Stack).getController(playerAP.getOpponent())); for (final Card c : allCards) { for (final Trigger t : c.getTriggers()) { if (!t.isStatic()) { diff --git a/src/main/java/forge/control/ControlMatchUI.java b/src/main/java/forge/control/ControlMatchUI.java index 8af3fba7bb1..765f2d238c7 100644 --- a/src/main/java/forge/control/ControlMatchUI.java +++ b/src/main/java/forge/control/ControlMatchUI.java @@ -28,7 +28,6 @@ import forge.AllZone; import forge.Card; import forge.CardList; import forge.Constant; -import forge.Constant.Zone; import forge.Singletons; import forge.control.match.ControlDetail; import forge.control.match.ControlDock; @@ -40,6 +39,7 @@ import forge.control.match.ControlTabber; import forge.game.GameType; import forge.game.phase.PhaseType; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.gui.CardContainer; import forge.gui.GuiMultipleBlockers; import forge.gui.toolbox.FLabel; @@ -121,12 +121,12 @@ public class ControlMatchUI implements CardContainer { // Update observers AllZone.getHumanPlayer().updateObservers(); - AllZone.getHumanPlayer().getZone(Zone.Hand).updateObservers(); - AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); + AllZone.getHumanPlayer().getZone(ZoneType.Hand).updateObservers(); + AllZone.getHumanPlayer().getZone(ZoneType.Battlefield).updateObservers(); AllZone.getComputerPlayer().updateObservers(); - AllZone.getComputerPlayer().getZone(Zone.Hand).updateObservers(); - AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); + AllZone.getComputerPlayer().getZone(ZoneType.Hand).updateObservers(); + AllZone.getHumanPlayer().getZone(ZoneType.Battlefield).updateObservers(); AllZone.getStack().updateObservers(); AllZone.getInputControl().updateObservers(); diff --git a/src/main/java/forge/control/input/Input.java b/src/main/java/forge/control/input/Input.java index e44c42ede79..6432e1bb899 100644 --- a/src/main/java/forge/control/input/Input.java +++ b/src/main/java/forge/control/input/Input.java @@ -21,7 +21,7 @@ import forge.AllZone; import forge.Card; import forge.Singletons; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; /** *

@@ -55,7 +55,7 @@ public abstract class Input implements java.io.Serializable { * @param c * a {@link forge.Card} object. * @param zone - * a {@link forge.game.player.PlayerZone} object. + * a {@link forge.game.zone.PlayerZone} object. */ public void selectCard(final Card c, final PlayerZone zone) { } diff --git a/src/main/java/forge/control/input/InputAttack.java b/src/main/java/forge/control/input/InputAttack.java index 2f715a47f1f..4111e942fce 100644 --- a/src/main/java/forge/control/input/InputAttack.java +++ b/src/main/java/forge/control/input/InputAttack.java @@ -20,10 +20,9 @@ package forge.control.input; import forge.AllZone; import forge.Card; import forge.CardList; -import forge.Constant; -import forge.Constant.Zone; import forge.game.phase.CombatUtil; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.view.ButtonUtil; import forge.Singletons; @@ -59,7 +58,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(Zone.Battlefield); + CardList possibleAttackers = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); possibleAttackers = possibleAttackers.getType("Creature"); for (int i = 0; i < possibleAttackers.size(); i++) { final Card c = possibleAttackers.get(i); @@ -93,7 +92,7 @@ public class InputAttack extends Input { return; } - if (zone.is(Constant.Zone.Battlefield, AllZone.getHumanPlayer()) + if (zone.is(ZoneType.Battlefield, AllZone.getHumanPlayer()) && CombatUtil.canAttack(card, AllZone.getCombat())) { // TODO add the propaganda code here and remove it in @@ -104,7 +103,7 @@ public class InputAttack extends Input { AllZone.getCombat().addAttacker(card); // just to make sure the attack symbol is marked - AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); + AllZone.getHumanPlayer().getZone(ZoneType.Battlefield).updateObservers(); CombatUtil.showCombat(); } else { @@ -120,7 +119,7 @@ public class InputAttack extends Input { * @param card * a {@link forge.Card} object. * @param zone - * a {@link forge.game.player.PlayerZone} object. + * a {@link forge.game.zone.PlayerZone} object. */ public void unselectCard(final Card card, final PlayerZone zone) { diff --git a/src/main/java/forge/control/input/InputBlock.java b/src/main/java/forge/control/input/InputBlock.java index d053b26be04..ab43b660c30 100644 --- a/src/main/java/forge/control/input/InputBlock.java +++ b/src/main/java/forge/control/input/InputBlock.java @@ -21,10 +21,10 @@ import java.util.ArrayList; import forge.AllZone; import forge.Card; -import forge.Constant; import forge.Singletons; import forge.game.phase.CombatUtil; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.view.ButtonUtil; /** @@ -95,7 +95,7 @@ public class InputBlock extends Input { // is attacking? if (AllZone.getCombat().getAttackers().contains(card)) { this.currentAttacker = card; - } else if (zone.is(Constant.Zone.Battlefield, AllZone.getHumanPlayer()) && card.isCreature() + } else if (zone.is(ZoneType.Battlefield, AllZone.getHumanPlayer()) && card.isCreature() && CombatUtil.canBlock(this.currentAttacker, card, AllZone.getCombat()) && this.currentAttacker != null && !this.allBlocking.contains(card) && card.getController().isHuman()) { diff --git a/src/main/java/forge/control/input/InputCleanup.java b/src/main/java/forge/control/input/InputCleanup.java index 559031fc19e..71d8f005c6d 100644 --- a/src/main/java/forge/control/input/InputCleanup.java +++ b/src/main/java/forge/control/input/InputCleanup.java @@ -19,10 +19,9 @@ package forge.control.input; import forge.AllZone; import forge.Card; -import forge.Constant; -import forge.Constant.Zone; import forge.game.phase.CombatUtil; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.view.ButtonUtil; import forge.Singletons; @@ -46,7 +45,7 @@ public class InputCleanup extends Input { return; } - final int n = AllZone.getHumanPlayer().getCardsIn(Zone.Hand).size(); + final int n = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand).size(); final int max = AllZone.getHumanPlayer().getMaxHandSize(); // goes to the next phase if (n <= max || max <= -1) { @@ -70,7 +69,7 @@ public class InputCleanup extends Input { /** {@inheritDoc} */ @Override public final void selectCard(final Card card, final PlayerZone zone) { - if (zone.is(Constant.Zone.Hand, AllZone.getHumanPlayer())) { + if (zone.is(ZoneType.Hand, AllZone.getHumanPlayer())) { card.getController().discard(card, null); if (AllZone.getStack().size() == 0) { this.showMessage(); @@ -84,7 +83,7 @@ public class InputCleanup extends Input { *

*/ public void aiCleanupDiscard() { - final int size = AllZone.getComputerPlayer().getCardsIn(Zone.Hand).size(); + final int size = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand).size(); if (AllZone.getComputerPlayer().getMaxHandSize() != -1) { final int numDiscards = size - AllZone.getComputerPlayer().getMaxHandSize(); diff --git a/src/main/java/forge/control/input/InputMulligan.java b/src/main/java/forge/control/input/InputMulligan.java index f6daa918f7e..a2918e38ce6 100644 --- a/src/main/java/forge/control/input/InputMulligan.java +++ b/src/main/java/forge/control/input/InputMulligan.java @@ -23,8 +23,6 @@ import forge.AllZone; import forge.AllZoneUtil; import forge.Card; import forge.CardList; -import forge.Constant; -import forge.Constant.Zone; import forge.GameAction; import forge.GameActionUtil; import forge.Singletons; @@ -35,7 +33,8 @@ import forge.game.phase.PhaseHandler; import forge.game.phase.PhaseUtil; import forge.game.player.ComputerUtil; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.quest.QuestController; import forge.quest.bazaar.QuestItemType; import forge.view.ButtonUtil; @@ -80,7 +79,7 @@ public class InputMulligan extends Input { * @return an int */ public final int doMulligan(final Player player, final GamePlayerRating playerRating) { - final CardList hand = player.getCardsIn(Zone.Hand); + final CardList hand = player.getCardsIn(ZoneType.Hand); for (final Card c : hand) { Singletons.getModel().getGameAction().moveToLibrary(c); } @@ -131,7 +130,7 @@ public class InputMulligan extends Input { // 0 in its hand while (aiTakesMulligan) { - final CardList handList = aiPlayer.getCardsIn(Zone.Hand); + final CardList handList = aiPlayer.getCardsIn(ZoneType.Hand); final boolean hasLittleCmc0Cards = handList.getValidCards("Card.cmcEQ0", aiPlayer, null).size() < 2; aiTakesMulligan = (handList.size() > InputMulligan.AI_MULLIGAN_THRESHOLD) && hasLittleCmc0Cards; @@ -143,7 +142,7 @@ public class InputMulligan extends Input { // Human Leylines & Chancellors ButtonUtil.reset(); final AbilityFactory af = new AbilityFactory(); - final CardList humanOpeningHand = AllZone.getHumanPlayer().getCardsIn(Zone.Hand); + final CardList humanOpeningHand = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand); for (final Card c : humanOpeningHand) { final ArrayList kws = c.getKeyword(); @@ -169,7 +168,7 @@ public class InputMulligan extends Input { } // Computer Leylines & Chancellors - final CardList aiOpeningHand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + final CardList aiOpeningHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); for (final Card c : aiOpeningHand) { if (!c.getName().startsWith("Leyline")) { final ArrayList kws = c.getKeyword(); @@ -191,7 +190,7 @@ public class InputMulligan extends Input { } } if (c.getName().startsWith("Leyline") - && !(c.getName().startsWith("Leyline of Singularity") && (AllZoneUtil.getCardsIn(Zone.Battlefield, + && !(c.getName().startsWith("Leyline of Singularity") && (AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Leyline of Singularity").size() > 0))) { ga.moveToPlay(c); ga.checkStateEffects(); @@ -201,8 +200,8 @@ public class InputMulligan extends Input { if (ga.isStartCut() && !(humanOpeningHand.contains(ga.getHumanCut()) || aiOpeningHand.contains(ga.getComputerCut()))) { - ga.moveTo(AllZone.getHumanPlayer().getZone(Constant.Zone.Library), ga.getHumanCut()); - ga.moveTo(AllZone.getComputerPlayer().getZone(Constant.Zone.Library), ga.getComputerCut()); + ga.moveTo(AllZone.getHumanPlayer().getZone(ZoneType.Library), ga.getHumanCut()); + ga.moveTo(AllZone.getComputerPlayer().getZone(ZoneType.Library), ga.getComputerCut()); } ga.checkStateEffects(); @@ -216,9 +215,9 @@ public class InputMulligan extends Input { @Override public void selectCard(Card c0, PlayerZone z0) { - if (c0.getName().equals("Serum Powder") && z0.is(Zone.Hand)) { + if (c0.getName().equals("Serum Powder") && z0.is(ZoneType.Hand)) { if (GameActionUtil.showYesNoDialog(c0, "Use " + c0.getName() + "'s ability?")) { - CardList hand = c0.getController().getCardsIn(Zone.Hand); + CardList hand = c0.getController().getCardsIn(ZoneType.Hand); for (Card c : hand) { Singletons.getModel().getGameAction().exile(c); } diff --git a/src/main/java/forge/control/input/InputPassPriority.java b/src/main/java/forge/control/input/InputPassPriority.java index 107345fb688..e0a4ccbfaa3 100644 --- a/src/main/java/forge/control/input/InputPassPriority.java +++ b/src/main/java/forge/control/input/InputPassPriority.java @@ -22,7 +22,7 @@ import forge.Card; import forge.Singletons; import forge.game.phase.PhaseType; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; import forge.gui.GuiDisplayUtil; import forge.view.ButtonUtil; diff --git a/src/main/java/forge/control/input/InputPayManaCost.java b/src/main/java/forge/control/input/InputPayManaCost.java index 79093a40e88..c4b8c98ba31 100644 --- a/src/main/java/forge/control/input/InputPayManaCost.java +++ b/src/main/java/forge/control/input/InputPayManaCost.java @@ -19,14 +19,14 @@ package forge.control.input; import forge.AllZone; import forge.Card; -import forge.Constant.Zone; import forge.Singletons; import forge.card.mana.ManaCost; import forge.card.spellability.SpellAbility; import forge.card.trigger.TriggerType; import forge.game.phase.PhaseHandler; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.view.ButtonUtil; //pays the cost of a card played from the player's hand @@ -268,7 +268,7 @@ public class InputPayManaCost extends InputMana { this.resetManaCost(); AllZone.getHumanPlayer().getManaPool().unpaid(this.spell, true); - AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); // DO + AllZone.getHumanPlayer().getZone(ZoneType.Battlefield).updateObservers(); // DO this.stop(); } diff --git a/src/main/java/forge/control/input/InputPayManaCostAbility.java b/src/main/java/forge/control/input/InputPayManaCostAbility.java index 123387abc48..fd1a55bb6d6 100644 --- a/src/main/java/forge/control/input/InputPayManaCostAbility.java +++ b/src/main/java/forge/control/input/InputPayManaCostAbility.java @@ -20,11 +20,11 @@ package forge.control.input; import forge.AllZone; import forge.Card; import forge.Command; -import forge.Constant.Zone; import forge.Singletons; import forge.card.mana.ManaCost; import forge.card.spellability.SpellAbility; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.view.ButtonUtil; //if cost is paid, Command.execute() is called @@ -155,7 +155,7 @@ public class InputPayManaCostAbility extends InputMana { // only tap card if the mana is needed this.manaCost = InputPayManaCostUtil.activateManaAbility(this.fakeAbility, card, this.manaCost); - if (card.getManaAbility().isEmpty() || card.isInZone(Zone.Hand)) { + if (card.getManaAbility().isEmpty() || card.isInZone(ZoneType.Hand)) { Singletons.getControl().getControlMatch().getMessageControl().remind(); } diff --git a/src/main/java/forge/control/input/InputPayManaCostUtil.java b/src/main/java/forge/control/input/InputPayManaCostUtil.java index 925a427e82f..4adf8402901 100644 --- a/src/main/java/forge/control/input/InputPayManaCostUtil.java +++ b/src/main/java/forge/control/input/InputPayManaCostUtil.java @@ -26,7 +26,6 @@ import forge.AllZone; import forge.Card; import forge.CardUtil; import forge.Constant; -import forge.Constant.Zone; import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; import forge.card.abilityfactory.AbilityFactoryMana; @@ -34,6 +33,7 @@ import forge.card.mana.ManaCost; import forge.card.mana.ManaPool; import forge.card.spellability.AbilityMana; import forge.card.spellability.SpellAbility; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; /** @@ -193,7 +193,7 @@ public class InputPayManaCostUtil { manaCost = AllZone.getHumanPlayer().getManaPool().subtractMana(sa, manaCost, chosen); - AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); + AllZone.getHumanPlayer().getZone(ZoneType.Battlefield).updateObservers(); // DO NOT REMOVE THIS, otherwise the cards don't always tap (copied) return manaCost; diff --git a/src/main/java/forge/control/match/ControlField.java b/src/main/java/forge/control/match/ControlField.java index cf43d73ebfd..74aedd9f4f6 100644 --- a/src/main/java/forge/control/match/ControlField.java +++ b/src/main/java/forge/control/match/ControlField.java @@ -34,7 +34,6 @@ import forge.AllZone; import forge.Card; import forge.CardList; import forge.Constant; -import forge.Constant.Zone; import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; import forge.control.input.Input; @@ -44,7 +43,8 @@ import forge.control.input.InputMana; import forge.control.input.InputPayManaCost; import forge.control.input.InputPayManaCostAbility; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.gui.ForgeAction; import forge.gui.GuiDisplayUtil; import forge.gui.GuiUtils; @@ -118,9 +118,9 @@ public class ControlField { * stats, etc. */ public void addObservers() { - this.player.getZone(Zone.Hand).addObserver(observerZones); + this.player.getZone(ZoneType.Hand).addObserver(observerZones); this.player.addObserver(observerDetails); - this.player.getZone(Zone.Battlefield).addObserver(observerPlay); + this.player.getZone(ZoneType.Battlefield).addObserver(observerPlay); } /** @@ -318,11 +318,11 @@ public class ControlField { @Override public void mousePressed(final MouseEvent e) { if (!ControlField.this.player.isComputer()) { - new ZoneAction(ControlField.this.player.getZone(Zone.Hand), HumanHand.BASE) + new ZoneAction(ControlField.this.player.getZone(ZoneType.Hand), HumanHand.BASE) .actionPerformed(null); } else if (Constant.Runtime.DEV_MODE[0] || ControlField.this.player.hasKeyword("Play with your hand revealed.")) { - new ZoneAction(ControlField.this.player.getZone(Zone.Hand), ComputerHand.BASE) + new ZoneAction(ControlField.this.player.getZone(ZoneType.Hand), ComputerHand.BASE) .actionPerformed(null); } } @@ -333,7 +333,7 @@ public class ControlField { @Override public void mousePressed(final MouseEvent e) { if (!ControlField.this.player.isComputer()) { - new ZoneAction(AllZone.getHumanPlayer().getZone(Zone.Graveyard), + new ZoneAction(AllZone.getHumanPlayer().getZone(ZoneType.Graveyard), NewConstants.Lang.GuiDisplay.HUMAN_FLASHBACK) { private static final long serialVersionUID = 8120331222693706164L; @@ -349,7 +349,7 @@ public class ControlField { } } .actionPerformed(null); } else { - new ZoneAction(ControlField.this.player.getZone(Zone.Graveyard), + new ZoneAction(ControlField.this.player.getZone(ZoneType.Graveyard), NewConstants.Lang.GuiDisplay.COMPUTER_FLASHBACK) { private static final long serialVersionUID = 8120331222693706164L; @@ -375,10 +375,10 @@ public class ControlField { if (!Constant.Runtime.DEV_MODE[0]) { return; } if (!ControlField.this.player.isComputer()) { - new ZoneAction(ControlField.this.player.getZone(Zone.Library), HumanLibrary.BASE) + new ZoneAction(ControlField.this.player.getZone(ZoneType.Library), HumanLibrary.BASE) .actionPerformed(null); } else { - new ZoneAction(ControlField.this.player.getZone(Zone.Library), ComputerLibrary.BASE) + new ZoneAction(ControlField.this.player.getZone(ZoneType.Library), ComputerLibrary.BASE) .actionPerformed(null); } } @@ -389,10 +389,10 @@ public class ControlField { @Override public void mousePressed(final MouseEvent e) { if (ControlField.this.player.isComputer()) { - new ZoneAction(ControlField.this.player.getZone(Zone.Exile), + new ZoneAction(ControlField.this.player.getZone(ZoneType.Exile), NewConstants.Lang.GuiDisplay.COMPUTER_EXILED).actionPerformed(null); } else { - new ZoneAction(ControlField.this.player.getZone(Zone.Exile), + new ZoneAction(ControlField.this.player.getZone(ZoneType.Exile), NewConstants.Lang.GuiDisplay.HUMAN_EXILED).actionPerformed(null); } } @@ -403,10 +403,10 @@ public class ControlField { @Override public void mousePressed(final MouseEvent e) { if (ControlField.this.player.isComputer()) { - new ZoneAction(ControlField.this.player.getZone(Zone.Graveyard), + new ZoneAction(ControlField.this.player.getZone(ZoneType.Graveyard), NewConstants.Lang.GuiDisplay.COMPUTER_GRAVEYARD).actionPerformed(null); } else { - new ZoneAction(ControlField.this.player.getZone(Zone.Graveyard), + new ZoneAction(ControlField.this.player.getZone(ZoneType.Graveyard), NewConstants.Lang.GuiDisplay.HUMAN_GRAVEYARD).actionPerformed(null); } } @@ -449,7 +449,7 @@ public class ControlField { final Input input = Singletons.getControl().getControlMatch().getMessageControl().getInputControl().getInput(); - if (c != null && c.isInZone(Zone.Battlefield)) { + if (c != null && c.isInZone(ZoneType.Battlefield)) { if (c.isTapped() && ((input instanceof InputPayManaCost) || (input instanceof InputPayManaCostAbility))) { final forge.view.arcane.CardPanel cardPanel = ControlField.this.view.getTabletop().getCardPanel( @@ -492,12 +492,12 @@ public class ControlField { if (c.getController() != null) { Singletons.getControl().getControlMatch().getMessageControl() .getInputControl().selectCard(c, - c.getController().getZone(Zone.Battlefield)); + c.getController().getZone(ZoneType.Battlefield)); } else { //in weird case card has no controller revert to default behaviour Singletons.getControl().getControlMatch().getMessageControl() .getInputControl().selectCard(c, - AllZone.getHumanPlayer().getZone(Zone.Battlefield)); + AllZone.getHumanPlayer().getZone(ZoneType.Battlefield)); } } diff --git a/src/main/java/forge/control/match/ControlHand.java b/src/main/java/forge/control/match/ControlHand.java index 411383defa3..51af83dd872 100644 --- a/src/main/java/forge/control/match/ControlHand.java +++ b/src/main/java/forge/control/match/ControlHand.java @@ -34,9 +34,9 @@ import javax.swing.SwingUtilities; import forge.AllZone; import forge.Card; -import forge.Constant.Zone; import forge.Singletons; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.view.arcane.CardPanel; import forge.view.arcane.HandArea; import forge.view.arcane.util.Animation; @@ -77,7 +77,7 @@ public class ControlHand { } final Card c = view.getHandArea().getCardFromMouseOverPanel(); if (c != null) { - Singletons.getControl().getControlMatch().getMessageControl().getInputControl().selectCard(c, AllZone.getHumanPlayer().getZone(Zone.Hand)); + Singletons.getControl().getControlMatch().getMessageControl().getInputControl().selectCard(c, AllZone.getHumanPlayer().getZone(ZoneType.Hand)); Singletons.getView().getViewMatch().getBtnOK().requestFocusInWindow(); } } @@ -168,7 +168,7 @@ public class ControlHand { /** Adds observers to hand panel. */ public void addObservers() { - AllZone.getHumanPlayer().getZone(Zone.Hand).addObserver(o1); + AllZone.getHumanPlayer().getZone(ZoneType.Hand).addObserver(o1); } /** Adds listeners to hand panel: clicks, mouseover, etc. */ @@ -210,7 +210,7 @@ public class ControlHand { } Singletons.getControl().getControlMatch().getMessageControl().getInputControl() - .selectCard(cardobj, AllZone.getHumanPlayer().getZone(Zone.Hand)); + .selectCard(cardobj, AllZone.getHumanPlayer().getZone(ZoneType.Hand)); } }); } diff --git a/src/main/java/forge/control/match/ControlWinLose.java b/src/main/java/forge/control/match/ControlWinLose.java index 544b63629ff..0e98e4580a0 100644 --- a/src/main/java/forge/control/match/ControlWinLose.java +++ b/src/main/java/forge/control/match/ControlWinLose.java @@ -8,12 +8,12 @@ import forge.AllZone; import forge.Card; import forge.CardList; import forge.Constant; -import forge.Constant.Zone; import forge.Singletons; import forge.control.FControl; import forge.deck.Deck; import forge.game.GameNew; import forge.game.GameType; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.gui.OverlayUtils; import forge.item.CardDb; @@ -94,7 +94,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(Zone.Ante); + CardList compAntes = AllZone.getComputerPlayer().getCardsIn(ZoneType.Ante); //remove compy's ante cards form his deck for (Card c : compAntes) { @@ -112,7 +112,7 @@ public class ControlWinLose { } } else { //compy won - CardList humanAntes = AllZone.getHumanPlayer().getCardsIn(Zone.Ante); + CardList humanAntes = AllZone.getHumanPlayer().getCardsIn(ZoneType.Ante); //remove compy's ante cards form his deck for (Card c : humanAntes) { diff --git a/src/main/java/forge/game/GameNew.java b/src/main/java/forge/game/GameNew.java index b24a3f71a31..aac52641ec2 100644 --- a/src/main/java/forge/game/GameNew.java +++ b/src/main/java/forge/game/GameNew.java @@ -14,7 +14,6 @@ import forge.CardList; import forge.CardListFilter; import forge.CardUtil; import forge.Constant; -import forge.Constant.Zone; import forge.GameAction; import forge.Singletons; import forge.card.trigger.TriggerType; @@ -23,6 +22,7 @@ import forge.control.input.InputMulligan; import forge.deck.Deck; import forge.game.phase.PhaseHandler; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.gui.toolbox.FLabel; import forge.item.CardPrinted; import forge.properties.ForgePreferences.FPref; @@ -67,12 +67,12 @@ public class GameNew { AllZone.getHumanPlayer().updateObservers(); for (final Card c : human) { - AllZone.getHumanPlayer().getZone(Zone.Battlefield).add(c); + AllZone.getHumanPlayer().getZone(ZoneType.Battlefield).add(c); c.setSickness(true); } for (final Card c : computer) { - AllZone.getComputerPlayer().getZone(Zone.Battlefield).add(c); + AllZone.getComputerPlayer().getZone(ZoneType.Battlefield).add(c); c.setSickness(true); } @@ -139,7 +139,7 @@ public class GameNew { && !Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE)) { hAnteRemoved.add(card.getName()); } else { - AllZone.getHumanPlayer().getZone(Zone.Library).add(card); + AllZone.getHumanPlayer().getZone(ZoneType.Library).add(card); } } } @@ -165,7 +165,7 @@ public class GameNew { && !Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE)) { cAnteRemoved.add(card.getName()); } else { - AllZone.getComputerPlayer().getZone(Zone.Library).add(card); + AllZone.getComputerPlayer().getZone(ZoneType.Library).add(card); } if (card.getSVar("RemAIDeck").equals("True") && !rAICards.contains(card.getName())) { @@ -230,12 +230,12 @@ public class GameNew { final boolean smoothLand = Constant.Runtime.SMOOTH[0]; if (smoothLand) { - final Iterable c1 = GameNew.smoothComputerManaCurve(AllZone.getComputerPlayer().getCardsIn(Zone.Library)); - AllZone.getComputerPlayer().getZone(Zone.Library).setCards(c1); + final Iterable c1 = GameNew.smoothComputerManaCurve(AllZone.getComputerPlayer().getCardsIn(ZoneType.Library)); + AllZone.getComputerPlayer().getZone(ZoneType.Library).setCards(c1); } else { // WTF? (it was so before refactor) - AllZone.getComputerPlayer().getZone(Zone.Library) - .setCards(AllZone.getComputerPlayer().getCardsIn(Zone.Library)); + AllZone.getComputerPlayer().getZone(ZoneType.Library) + .setCards(AllZone.getComputerPlayer().getCardsIn(ZoneType.Library)); AllZone.getComputerPlayer().shuffle(); } @@ -257,7 +257,7 @@ public class GameNew { final String nl = System.getProperty("line.separator"); final StringBuilder msg = new StringBuilder(); for (final Player p : AllZone.getPlayersInGame()) { - final CardList lib = p.getCardsIn(Zone.Library); + final CardList lib = p.getCardsIn(ZoneType.Library); Card ante; if ((lib.size() > 0) && (lib.getNotType("Basic").size() > 1)) { ante = CardUtil.getRandom(lib.toArray()); @@ -270,7 +270,7 @@ public class GameNew { throw new RuntimeException(p + " library is empty."); } AllZone.getGameLog().add("Ante", p + " anted " + ante, 0); - Singletons.getModel().getGameAction().moveTo(Zone.Ante, ante); + Singletons.getModel().getGameAction().moveTo(ZoneType.Ante, ante); msg.append(p.getName()).append(" ante: ").append(ante).append(nl); } JOptionPane.showMessageDialog(null, msg, "Ante", JOptionPane.INFORMATION_MESSAGE); @@ -281,7 +281,7 @@ public class GameNew { AllZone.getComputerPlayer().drawCard(); } - Singletons.getControl().getControlMatch().setCard(AllZone.getHumanPlayer().getCardsIn(Zone.Hand).get(0)); + Singletons.getControl().getControlMatch().setCard(AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand).get(0)); AllZone.getInputControl().setInput(new InputMulligan()); PhaseHandler.setGameBegins(1); // is this needed? It's already in InputMulligan... @@ -307,7 +307,7 @@ public class GameNew { gs.setGameOver(false); for (final Player p : gs.getPlayers()) { - for (final Zone z : Player.ALL_ZONES) { + for (final ZoneType z : Player.ALL_ZONES) { p.getZone(z).reset(); } } @@ -448,9 +448,9 @@ public class GameNew { */ private static void seeWhoPlaysFirst() { final GameAction ga = Singletons.getModel().getGameAction(); - CardList hLibrary = AllZone.getHumanPlayer().getCardsIn(Zone.Library); + CardList hLibrary = AllZone.getHumanPlayer().getCardsIn(ZoneType.Library); hLibrary = hLibrary.filter(CardListFilter.NON_LANDS); - CardList cLibrary = AllZone.getComputerPlayer().getCardsIn(Zone.Library); + CardList cLibrary = AllZone.getComputerPlayer().getCardsIn(ZoneType.Library); cLibrary = cLibrary.filter(CardListFilter.NON_LANDS); final boolean starterDetermined = false; @@ -479,9 +479,9 @@ public class GameNew { } cutCount = cutCount + 1; - ga.moveTo(AllZone.getHumanPlayer().getZone(Constant.Zone.Library), + ga.moveTo(AllZone.getHumanPlayer().getZone(ZoneType.Library), ga.getHumanCut()); - ga.moveTo(AllZone.getComputerPlayer().getZone(Constant.Zone.Library), + ga.moveTo(AllZone.getComputerPlayer().getZone(ZoneType.Library), ga.getComputerCut()); final StringBuilder sb = new StringBuilder(); diff --git a/src/main/java/forge/game/GameState.java b/src/main/java/forge/game/GameState.java index 6a138758a7b..015b4b131c9 100644 --- a/src/main/java/forge/game/GameState.java +++ b/src/main/java/forge/game/GameState.java @@ -17,9 +17,7 @@ */ package forge.game; -import forge.Constant; import forge.GameLog; -import forge.MagicStack; import forge.StaticEffects; import forge.card.replacement.ReplacementHandler; import forge.card.trigger.TriggerHandler; @@ -30,10 +28,12 @@ import forge.game.phase.PhaseHandler; import forge.game.phase.Untap; import forge.game.phase.Upkeep; import forge.game.player.AIPlayer; -import forge.game.player.DefaultPlayerZone; import forge.game.player.HumanPlayer; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.DefaultPlayerZone; +import forge.game.zone.MagicStack; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; /** * Represents the state of a single game and is @@ -62,7 +62,7 @@ public class GameState { private final GameLog gameLog = new GameLog(); private boolean gameOver = false; - private final PlayerZone stackZone = new DefaultPlayerZone(Constant.Zone.Stack, null); + private final PlayerZone stackZone = new DefaultPlayerZone(ZoneType.Stack, null); private long timestamp = 0; private GameSummary gameSummary; diff --git a/src/main/java/forge/game/phase/Combat.java b/src/main/java/forge/game/phase/Combat.java index 1238240a12e..71099789414 100644 --- a/src/main/java/forge/game/phase/Combat.java +++ b/src/main/java/forge/game/phase/Combat.java @@ -36,9 +36,9 @@ import forge.CardUtil; import forge.GameActionUtil; import forge.GameEntity; import forge.Singletons; -import forge.Constant.Zone; import forge.card.trigger.TriggerType; import forge.game.player.Player; +import forge.game.zone.ZoneType; /** *

@@ -114,7 +114,7 @@ public class Combat { */ public final void initiatePossibleDefenders(final Player defender) { this.defenders.add(defender); - CardList planeswalkers = defender.getCardsIn(Zone.Battlefield); + CardList planeswalkers = defender.getCardsIn(ZoneType.Battlefield); planeswalkers = planeswalkers.getType("Planeswalker"); for (final Card pw : planeswalkers) { this.defenders.add(pw); diff --git a/src/main/java/forge/game/phase/CombatUtil.java b/src/main/java/forge/game/phase/CombatUtil.java index 627a43d191b..2835e68045f 100644 --- a/src/main/java/forge/game/phase/CombatUtil.java +++ b/src/main/java/forge/game/phase/CombatUtil.java @@ -37,7 +37,6 @@ import forge.GameAction; import forge.GameActionUtil; import forge.GameEntity; import forge.Singletons; -import forge.Constant.Zone; import forge.card.TriggerReplacementBase; import forge.card.abilityfactory.AbilityFactory; import forge.card.cardfactory.CardFactoryUtil; @@ -50,7 +49,8 @@ import forge.control.input.InputPayManaCostAbility; import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.player.PlayerUtil; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; /** @@ -80,7 +80,7 @@ public class CombatUtil { if (blocker == null) { return false; } - for (final Card c : AllZoneUtil.getCardsIn(Constant.Zone.Battlefield)) { + for (final Card c : AllZoneUtil.getCardsIn(ZoneType.Battlefield)) { for (final String keyword : c.getKeyword()) { if (keyword.equals("No more than one creature can block each combat.") && (combat.getAllBlockers().size() > 0)) { @@ -125,7 +125,7 @@ public class CombatUtil { return false; } - final CardList kulrath = AllZoneUtil.getCardsIn(Zone.Battlefield, "Kulrath Knight"); + final CardList kulrath = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Kulrath Knight"); if (kulrath.size() > 0) { for (int i = 0; i < kulrath.size(); i++) { final Card cKK = kulrath.get(i); @@ -189,7 +189,7 @@ public class CombatUtil { // Landwalk if (!AllZoneUtil.isCardInPlay("Staff of the Ages")) { // "Creatures with landwalk abilities can be blocked as though they didn't have those abilities." - final CardList blkCL = attacker.getController().getOpponent().getCardsIn(Zone.Battlefield); + final CardList blkCL = attacker.getController().getOpponent().getCardsIn(ZoneType.Battlefield); CardList temp = new CardList(); if (attacker.hasKeyword("Plainswalk")) { @@ -424,7 +424,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 = combat.getDefendingPlayer().getCardsIn(Zone.Battlefield) + final CardList possibleBlockers = combat.getDefendingPlayer().getCardsIn(ZoneType.Battlefield) .getType("Creature"); possibleBlockers.remove(blocker); if (!CombatUtil.canBeBlocked(attacker, possibleBlockers)) { @@ -486,7 +486,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 = combat.getDefendingPlayer().getCardsIn(Zone.Battlefield) + final CardList blockers = combat.getDefendingPlayer().getCardsIn(ZoneType.Battlefield) .getType("Creature"); blockers.remove(blocker); if (!CombatUtil.canBeBlocked(attacker, blockers)) { @@ -503,7 +503,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 = combat.getDefendingPlayer().getCardsIn(Zone.Battlefield) + final CardList blockers = combat.getDefendingPlayer().getCardsIn(ZoneType.Battlefield) .getType("Creature"); blockers.remove(blocker); if (!CombatUtil.canBeBlocked(attacker, blockers)) { @@ -729,7 +729,7 @@ public class CombatUtil { public static boolean canAttack(final Card c, final Combat combat) { int cntAttackers = combat.getAttackers().size(); - for (final Card card : AllZoneUtil.getCardsIn(Constant.Zone.Battlefield)) { + for (final Card card : AllZoneUtil.getCardsIn(ZoneType.Battlefield)) { for (final String keyword : card.getKeyword()) { if (keyword.equals("No more than one creature can attack each combat.") && cntAttackers > 0) { return false; @@ -835,7 +835,7 @@ public class CombatUtil { } // hasKeyword = CARDNAME can't attack if defending player controls an // untapped creature with power ... - final CardList list = c.getController().getOpponent().getCardsIn(Zone.Battlefield); + final CardList list = c.getController().getOpponent().getCardsIn(ZoneType.Battlefield); CardList temp; if (c.hasKeyword("CARDNAME can't attack unless defending player controls an Island.")) { @@ -884,7 +884,7 @@ public class CombatUtil { } if (c.getName().equals("Harbor Serpent")) { - final CardList allislands = AllZoneUtil.getCardsIn(Zone.Battlefield).getType("Island"); + final CardList allislands = AllZoneUtil.getCardsIn(ZoneType.Battlefield).getType("Island"); if (allislands.size() < 5) { return false; } @@ -904,7 +904,7 @@ public class CombatUtil { } if (AllZoneUtil.isCardInPlay("Kulrath Knight")) { - final CardList all = AllZoneUtil.getCardsIn(Zone.Battlefield, "Kulrath Knight"); + final CardList all = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Kulrath Knight"); for (int i = 0; i < all.size(); i++) { final Card cKK = all.get(i); final Player oppKK = cKK.getController().getOpponent(); @@ -1542,7 +1542,7 @@ public class CombatUtil { // look out for continuous static abilities that only care for blocking // creatures - final CardList cardList = AllZoneUtil.getCardsIn(Constant.Zone.Battlefield); + final CardList cardList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card card : cardList) { for (final StaticAbility stAb : card.getStaticAbilities()) { final HashMap params = stAb.getMapParams(); @@ -1569,7 +1569,7 @@ public class CombatUtil { } final ArrayList theTriggers = new ArrayList(); - for (Card card : AllZoneUtil.getCardsIn(Constant.Zone.Battlefield)) { + for (Card card : AllZoneUtil.getCardsIn(ZoneType.Battlefield)) { theTriggers.addAll(card.getTriggers()); } theTriggers.addAll(attacker.getTriggers()); @@ -1643,7 +1643,7 @@ public class CombatUtil { toughness += defender.getKeywordMagnitude("Bushido"); final ArrayList theTriggers = new ArrayList(); - for (Card card : AllZoneUtil.getCardsIn(Constant.Zone.Battlefield)) { + for (Card card : AllZoneUtil.getCardsIn(ZoneType.Battlefield)) { theTriggers.addAll(card.getTriggers()); } theTriggers.addAll(attacker.getTriggers()); @@ -1734,7 +1734,7 @@ public class CombatUtil { power += attacker.getKeywordMagnitude("Bushido"); final ArrayList theTriggers = new ArrayList(); - for (Card card : AllZoneUtil.getCardsIn(Constant.Zone.Battlefield)) { + for (Card card : AllZoneUtil.getCardsIn(ZoneType.Battlefield)) { theTriggers.addAll(card.getTriggers()); } // if the defender has first strike and wither the attacker will deal @@ -1751,7 +1751,7 @@ public class CombatUtil { // look out for continuous static abilities that only care for attacking // creatures - final CardList cardList = AllZoneUtil.getCardsIn(Constant.Zone.Battlefield); + final CardList cardList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card card : cardList) { for (final StaticAbility stAb : card.getStaticAbilities()) { final HashMap params = stAb.getMapParams(); @@ -1859,7 +1859,7 @@ public class CombatUtil { int toughness = 0; final ArrayList theTriggers = new ArrayList(); - for (Card card : AllZoneUtil.getCardsIn(Constant.Zone.Battlefield)) { + for (Card card : AllZoneUtil.getCardsIn(ZoneType.Battlefield)) { theTriggers.addAll(card.getTriggers()); } if (defender != null) { @@ -1869,7 +1869,7 @@ public class CombatUtil { // look out for continuous static abilities that only care for attacking // creatures - final CardList cardList = AllZoneUtil.getCardsIn(Constant.Zone.Battlefield); + final CardList cardList = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card card : cardList) { for (final StaticAbility stAb : card.getStaticAbilities()) { final HashMap params = stAb.getMapParams(); @@ -1991,7 +1991,7 @@ public class CombatUtil { */ public static boolean checkDestroyBlockerTrigger(final Card attacker, final Card defender) { final ArrayList theTriggers = new ArrayList(); - for (Card card : AllZoneUtil.getCardsIn(Constant.Zone.Battlefield)) { + for (Card card : AllZoneUtil.getCardsIn(ZoneType.Battlefield)) { theTriggers.addAll(card.getTriggers()); } for (Trigger trigger : theTriggers) { @@ -2043,7 +2043,7 @@ public class CombatUtil { */ public static boolean checkDestroyAttackerTrigger(final Card attacker, final Card defender) { final ArrayList theTriggers = new ArrayList(); - for (Card card : AllZoneUtil.getCardsIn(Constant.Zone.Battlefield)) { + for (Card card : AllZoneUtil.getCardsIn(ZoneType.Battlefield)) { theTriggers.addAll(card.getTriggers()); } for (Trigger trigger : theTriggers) { @@ -2347,7 +2347,7 @@ public class CombatUtil { *

*/ public static void removeAllDamage() { - final CardList cl = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList cl = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card c : cl) { c.setDamage(0); } @@ -2617,7 +2617,7 @@ public class CombatUtil { @Override public void resolve() { if (crd.getController().isHuman()) { - final CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + final CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); ComputerUtil.sacrificePermanents(a, list, false); } else { AllZone.getInputControl().setInput(PlayerUtil.inputSacrificePermanents(a)); @@ -2646,7 +2646,7 @@ public class CombatUtil { else if (c.getName().equals("Spectral Bears")) { final Player opp = c.getController().getOpponent(); - CardList list = opp.getCardsIn(Zone.Battlefield); + CardList list = opp.getCardsIn(ZoneType.Battlefield); list = list.filter(new CardListFilter() { @Override public boolean addCard(final Card crd) { @@ -2658,7 +2658,7 @@ public class CombatUtil { } } else if (c.getName().equals("Spectral Force")) { final Player opp = c.getController().getOpponent(); - CardList list = opp.getCardsIn(Zone.Battlefield); + CardList list = opp.getCardsIn(ZoneType.Battlefield); list = list.filter(CardListFilter.BLACK); if (list.size() == 0) { c.addExtrinsicKeyword("This card doesn't untap during your next untap step."); @@ -2700,7 +2700,7 @@ public class CombatUtil { else if (c.getName().equals("Sapling of Colfenor") && !c.getDamageHistory().getCreatureAttackedThisCombat()) { final Player player = c.getController(); - final PlayerZone lib = player.getZone(Constant.Zone.Library); + final PlayerZone lib = player.getZone(ZoneType.Library); if (lib.size() > 0) { final CardList cl = new CardList(); @@ -2909,7 +2909,7 @@ public class CombatUtil { final Player phasingPlayer = c.getController(); // Finest Hour untaps the creature on the first combat phase - if ((phasingPlayer.getCardsIn(Zone.Battlefield, "Finest Hour").size() > 0) + if ((phasingPlayer.getCardsIn(ZoneType.Battlefield, "Finest Hour").size() > 0) && Singletons.getModel().getGameState().getPhaseHandler().isFirstCombat()) { // Untap the attacking creature final Ability fhUntap = new Ability(c, "0") { @@ -2926,7 +2926,7 @@ public class CombatUtil { AllZone.getStack().addSimultaneousStackEntry(fhUntap); // If any Finest Hours, queue up a new combat phase - for (int ix = 0; ix < phasingPlayer.getCardsIn(Zone.Battlefield, "Finest Hour").size(); ix++) { + for (int ix = 0; ix < phasingPlayer.getCardsIn(ZoneType.Battlefield, "Finest Hour").size(); ix++) { final Ability fhAddCombat = new Ability(c, "0") { @Override public void resolve() { @@ -2942,13 +2942,13 @@ public class CombatUtil { } } - if (phasingPlayer.getCardsIn(Zone.Battlefield, "Sovereigns of Lost Alara").size() > 0) { - for (int i = 0; i < phasingPlayer.getCardsIn(Zone.Battlefield, "Sovereigns of Lost Alara").size(); i++) { + if (phasingPlayer.getCardsIn(ZoneType.Battlefield, "Sovereigns of Lost Alara").size() > 0) { + for (int i = 0; i < phasingPlayer.getCardsIn(ZoneType.Battlefield, "Sovereigns of Lost Alara").size(); i++) { final Card attacker = c; final Ability ability4 = new Ability(c, "0") { @Override public void resolve() { - CardList enchantments = attacker.getController().getCardsIn(Zone.Library); + CardList enchantments = attacker.getController().getCardsIn(ZoneType.Library); enchantments = enchantments.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -2978,7 +2978,7 @@ public class CombatUtil { } if ((enchantment != null) && AllZoneUtil.isCardInPlay(attacker)) { GameAction.changeZone(AllZone.getZoneOf(enchantment), - enchantment.getOwner().getZone(Constant.Zone.Battlefield), enchantment); + enchantment.getOwner().getZone(ZoneType.Battlefield), enchantment); enchantment.enchantEntity(attacker); } attacker.getController().shuffle(); diff --git a/src/main/java/forge/game/phase/EndOfTurn.java b/src/main/java/forge/game/phase/EndOfTurn.java index 8dc72c31ebc..553461cd2cf 100644 --- a/src/main/java/forge/game/phase/EndOfTurn.java +++ b/src/main/java/forge/game/phase/EndOfTurn.java @@ -25,10 +25,10 @@ import forge.CardListFilter; import forge.CardListUtil; import forge.Counters; import forge.Singletons; -import forge.Constant.Zone; import forge.card.spellability.Ability; import forge.card.spellability.SpellAbility; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; /** @@ -54,7 +54,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable { // TODO - should this freeze the Stack? // Pyrohemia and Pestilence - final CardList all = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList all = AllZoneUtil.getCardsIn(ZoneType.Battlefield); EndOfTurn.endOfTurnWallOfReverence(); EndOfTurn.endOfTurnLighthouseChronologist(); @@ -209,7 +209,7 @@ public class EndOfTurn extends Phase implements java.io.Serializable { private static void endOfTurnWallOfReverence() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList list = player.getCardsIn(Zone.Battlefield, "Wall of Reverence"); + final CardList list = player.getCardsIn(ZoneType.Battlefield, "Wall of Reverence"); Ability ability; for (int i = 0; i < list.size(); i++) { @@ -254,7 +254,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(Zone.Battlefield); + CardList list = opponent.getCardsIn(ZoneType.Battlefield); list = list.filter(new CardListFilter() { @Override diff --git a/src/main/java/forge/game/phase/PhaseHandler.java b/src/main/java/forge/game/phase/PhaseHandler.java index fec735e9fdf..9b30ca30bd8 100644 --- a/src/main/java/forge/game/phase/PhaseHandler.java +++ b/src/main/java/forge/game/phase/PhaseHandler.java @@ -31,9 +31,9 @@ import forge.CardListFilter; import forge.GameActionUtil; import forge.MyObservable; import forge.Singletons; -import forge.Constant.Zone; import forge.card.trigger.TriggerType; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.properties.ForgePreferences.FPref; /** @@ -422,7 +422,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable { this.getPlayerTurn().clearAssignedDamage(); // Reset Damage received map - final CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card c : list) { c.resetPreventNextDamage(); c.resetReceivedDamageFromThisTurn(); @@ -449,8 +449,8 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable { AllZone.getComputerPlayer().resetPreventNextDamage(); AllZone.getEndOfTurn().executeUntil(); - final CardList cHand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); - final CardList hHand = AllZone.getHumanPlayer().getCardsIn(Zone.Hand); + final CardList cHand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); + final CardList hHand = AllZone.getHumanPlayer().getCardsIn(ZoneType.Hand); for (final Card c : cHand) { c.setDrawnThisTurn(false); } @@ -619,7 +619,7 @@ public class PhaseHandler extends MyObservable implements java.io.Serializable { */ private Player skipTurnTimeVault(Player turn) { // time vault: - CardList vaults = turn.getCardsIn(Zone.Battlefield, "Time Vault"); + CardList vaults = turn.getCardsIn(ZoneType.Battlefield, "Time Vault"); vaults = vaults.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -793,7 +793,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(Zone.Battlefield); + CardList list = player.getCardsIn(ZoneType.Battlefield); list = list.getType("Creature"); diff --git a/src/main/java/forge/game/phase/PhaseUtil.java b/src/main/java/forge/game/phase/PhaseUtil.java index 37a509c8841..55a3da46d1c 100644 --- a/src/main/java/forge/game/phase/PhaseUtil.java +++ b/src/main/java/forge/game/phase/PhaseUtil.java @@ -25,11 +25,11 @@ import forge.Card; import forge.CardList; import forge.CardListFilter; import forge.Singletons; -import forge.Constant.Zone; import forge.card.trigger.TriggerType; import forge.control.ControlMatchUI; import forge.game.phase.PhaseType; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.view.match.ViewField.PhaseLabel; /** @@ -88,7 +88,7 @@ public class PhaseUtil { // For tokens a player starts the game with they don't recover from Sum. // Sickness on first turn if (Singletons.getModel().getGameState().getPhaseHandler().getTurn() > 0) { - final CardList list = turn.getCardsIncludePhasingIn(Zone.Battlefield); + final CardList list = turn.getCardsIncludePhasingIn(ZoneType.Battlefield); for (final Card c : list) { c.setSickness(false); } @@ -112,7 +112,7 @@ public class PhaseUtil { Singletons.getModel().getGameState().getUntap().executeAt(); // otherwise land seems to stay tapped when it is really untapped - AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); + AllZone.getHumanPlayer().getZone(ZoneType.Battlefield).updateObservers(); Singletons.getModel().getGameState().getPhaseHandler().setNeedToNextPhase(true); } @@ -153,7 +153,7 @@ public class PhaseUtil { final Player turn = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - if ((turn.getCardsIn(Zone.Hand).size() == 0) && AllZoneUtil.isCardInPlay("Gibbering Descent", turn)) { + if ((turn.getCardsIn(ZoneType.Hand).size() == 0) && AllZoneUtil.isCardInPlay("Gibbering Descent", turn)) { return true; } @@ -299,7 +299,7 @@ public class PhaseUtil { if (list.size() == 1) { final Player attackingPlayer = AllZone.getCombat().getAttackingPlayer(); - CardList exalted = attackingPlayer.getCardsIn(Zone.Battlefield); + CardList exalted = attackingPlayer.getCardsIn(ZoneType.Battlefield); exalted = exalted.getKeyword("Exalted"); if (exalted.size() > 0) { diff --git a/src/main/java/forge/game/phase/Untap.java b/src/main/java/forge/game/phase/Untap.java index a08d37874ba..ae4b8c7c8f1 100644 --- a/src/main/java/forge/game/phase/Untap.java +++ b/src/main/java/forge/game/phase/Untap.java @@ -24,16 +24,15 @@ import forge.AllZoneUtil; import forge.Card; import forge.CardList; import forge.CardListFilter; -import forge.Constant; import forge.Counters; import forge.GameActionUtil; import forge.GameEntity; import forge.Singletons; -import forge.Constant.Zone; import forge.card.cardfactory.CardFactoryUtil; import forge.control.input.Input; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.view.ButtonUtil; /** @@ -82,7 +81,7 @@ public class Untap extends Phase implements java.io.Serializable { return false; } - final CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList 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 @@ -107,7 +106,7 @@ public class Untap extends Phase implements java.io.Serializable { */ private static void doUntap() { final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - CardList list = player.getCardsIn(Zone.Battlefield); + CardList list = player.getCardsIn(ZoneType.Battlefield); for (final Card c : list) { if (c.getBounceAtUntap() && c.getName().contains("Undiscovered Paradise")) { @@ -182,7 +181,7 @@ public class Untap extends Phase implements java.io.Serializable { } // opponent untapping during your untap phase - final CardList opp = player.getOpponent().getCardsIn(Zone.Battlefield); + final CardList 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(); @@ -220,7 +219,7 @@ public class Untap extends Phase implements java.io.Serializable { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (c.isLand() && zone.is(Constant.Zone.Battlefield) && c.isTapped() && Untap.canUntap(c)) { + if (c.isLand() && zone.is(ZoneType.Battlefield) && c.isTapped() && Untap.canUntap(c)) { c.untap(); this.stop(); } @@ -240,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(Zone.Battlefield); + CardList artList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); artList = artList.filter(CardListFilter.ARTIFACTS); artList = artList.filter(CardListFilter.TAPPED).filter(new CardListFilter() { @Override @@ -268,14 +267,14 @@ public class Untap extends Phase implements java.io.Serializable { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (c.isArtifact() && zone.is(Constant.Zone.Battlefield) && c.getController().isHuman() + if (c.isArtifact() && zone.is(ZoneType.Battlefield) && c.getController().isHuman() && Untap.canUntap(c)) { c.untap(); this.stop(); } } // selectCard() }; // Input - CardList artList = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); + CardList artList = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); artList = artList.filter(CardListFilter.ARTIFACTS); artList = artList.filter(CardListFilter.TAPPED).filter(new CardListFilter() { @Override @@ -317,7 +316,7 @@ public class Untap extends Phase implements java.io.Serializable { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (c.isCreature() && zone.is(Constant.Zone.Battlefield) && c.getController().isHuman() + if (c.isCreature() && zone.is(ZoneType.Battlefield) && c.getController().isHuman() && Untap.canUntap(c)) { c.untap(); this.stop(); @@ -338,7 +337,7 @@ public class Untap extends Phase implements java.io.Serializable { } // Remove temporary keywords - list = player.getCardsIn(Zone.Battlefield); + list = player.getCardsIn(ZoneType.Battlefield); for (final Card c : list) { c.removeAllExtrinsicKeyword("This card doesn't untap during your next untap step."); c.removeAllExtrinsicKeyword("HIDDEN This card doesn't untap during your next untap step."); @@ -352,11 +351,11 @@ public class Untap extends Phase implements java.io.Serializable { private static boolean canOnlyUntapOneLand() { // Winter Orb was given errata so it no longer matters if it's tapped or // not - if (AllZoneUtil.getCardsIn(Zone.Battlefield, "Winter Orb").size() > 0) { + if (AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Winter Orb").size() > 0) { return true; } - if (Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn().getCardsIn(Zone.Battlefield, "Mungha Wurm").size() > 0) { + if (Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn().getCardsIn(ZoneType.Battlefield, "Mungha Wurm").size() > 0) { return true; } @@ -365,7 +364,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 = turn.getCardsIncludePhasingIn(Constant.Zone.Battlefield).filter(new CardListFilter() { + final CardList list = turn.getCardsIncludePhasingIn(ZoneType.Battlefield).filter(new CardListFilter() { @Override public boolean addCard(final Card c) { diff --git a/src/main/java/forge/game/phase/Upkeep.java b/src/main/java/forge/game/phase/Upkeep.java index 779909232d5..4f36aa02d3a 100644 --- a/src/main/java/forge/game/phase/Upkeep.java +++ b/src/main/java/forge/game/phase/Upkeep.java @@ -27,12 +27,10 @@ import forge.CardList; import forge.CardListFilter; import forge.CardListUtil; import forge.Command; -import forge.Constant; import forge.Counters; import forge.GameAction; import forge.GameActionUtil; import forge.Singletons; -import forge.Constant.Zone; import forge.card.cardfactory.CardFactoryUtil; import forge.card.spellability.Ability; import forge.card.spellability.AbilityMana; @@ -43,7 +41,8 @@ import forge.control.input.Input; import forge.game.player.ComputerUtil; import forge.game.player.Player; import forge.game.player.PlayerUtil; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.view.ButtonUtil; @@ -125,7 +124,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(Zone.Battlefield, "Braid of Fire"); + final CardList braids = player.getCardsIn(ZoneType.Battlefield, "Braid of Fire"); for (int i = 0; i < braids.size(); i++) { final Card c = braids.get(i); @@ -163,7 +162,7 @@ public class Upkeep extends Phase implements java.io.Serializable { *

*/ private static void upkeepEcho() { - CardList list = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn().getCardsIn(Zone.Battlefield); + CardList list = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn().getCardsIn(ZoneType.Battlefield); list = list.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -278,7 +277,7 @@ public class Upkeep extends Phase implements java.io.Serializable { *

*/ private static void upkeepUpkeepCost() { - final CardList list = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn().getCardsIn(Zone.Battlefield); + final CardList list = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn().getCardsIn(ZoneType.Battlefield); for (int i = 0; i < list.size(); i++) { final Card c = list.get(i); @@ -472,8 +471,8 @@ public class Upkeep extends Phase implements java.io.Serializable { * regenerated. */ final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList the = AllZoneUtil.getCardsIn(Zone.Battlefield, "The Abyss"); - final CardList magus = AllZoneUtil.getCardsIn(Zone.Battlefield, "Magus of the Abyss"); + final CardList the = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "The Abyss"); + final CardList magus = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Magus of the Abyss"); final CardList cards = new CardList(); cards.addAll(the); @@ -551,7 +550,7 @@ public class Upkeep extends Phase implements java.io.Serializable { * you don't, tap Yawgmoth Demon and it deals 2 damage to you. */ final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList cards = player.getCardsIn(Zone.Battlefield, "Yawgmoth Demon"); + final CardList cards = player.getCardsIn(ZoneType.Battlefield, "Yawgmoth Demon"); for (int i = 0; i < cards.size(); i++) { final Card c = cards.get(i); @@ -559,7 +558,7 @@ public class Upkeep extends Phase implements java.io.Serializable { final Ability sacrificeArtifact = new Ability(c, "") { @Override public void resolve() { - final CardList artifacts = player.getCardsIn(Zone.Battlefield).filter(CardListFilter.ARTIFACTS); + final CardList artifacts = player.getCardsIn(ZoneType.Battlefield).filter(CardListFilter.ARTIFACTS); if (player.isHuman()) { AllZone.getInputControl().setInput(new Input() { @@ -584,7 +583,7 @@ public class Upkeep extends Phase implements java.io.Serializable { @Override public void selectCard(final Card artifact, final PlayerZone zone) { // probably need to restrict by controller also - if (artifact.isArtifact() && zone.is(Constant.Zone.Battlefield) + if (artifact.isArtifact() && zone.is(ZoneType.Battlefield) && zone.getPlayer().isHuman()) { Singletons.getModel().getGameAction().sacrifice(artifact); this.stop(); @@ -629,8 +628,8 @@ 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(Zone.Battlefield, "Drop of Honey"); - drops.addAll(player.getCardsIn(Zone.Battlefield, "Porphyry Nodes")); + final CardList drops = player.getCardsIn(ZoneType.Battlefield, "Drop of Honey"); + drops.addAll(player.getCardsIn(ZoneType.Battlefield, "Porphyry Nodes")); final CardList cards = drops; for (int i = 0; i < cards.size(); i++) { @@ -705,7 +704,7 @@ public class Upkeep extends Phase implements java.io.Serializable { */ final Player player = Singletons.getModel().getGameState().getPhaseHandler().getPlayerTurn(); - final CardList cards = player.getCardsIn(Zone.Battlefield, "Demonic Hordes"); + final CardList cards = player.getCardsIn(ZoneType.Battlefield, "Demonic Hordes"); for (int i = 0; i < cards.size(); i++) { @@ -737,7 +736,7 @@ public class Upkeep extends Phase implements java.io.Serializable { final Ability pay = new Ability(c, "0") { @Override public void resolve() { - if (AllZone.getZoneOf(c).is(Constant.Zone.Battlefield)) { + if (AllZone.getZoneOf(c).is(ZoneType.Battlefield)) { final StringBuilder cost = new StringBuilder(); cost.append("Pay cost for ").append(c).append("\r\n"); GameActionUtil.payManaDuringAbilityResolve(cost.toString(), noPay.getManaCost(), @@ -793,9 +792,9 @@ 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(Zone.Battlefield, "Ink Dissolver"); + final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Ink Dissolver"); - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is // empty. // Useful for games when the "Milling = Loss Condition" check box is @@ -813,7 +812,7 @@ public class Upkeep extends Phase implements java.io.Serializable { // abilities when ready @Override public void resolve() { - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); if (library.size() <= 0) { return; } @@ -879,9 +878,9 @@ 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(Zone.Battlefield, "Kithkin Zephyrnaut"); + final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Kithkin Zephyrnaut"); - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is // empty. // Useful for games when the "Milling = Loss Condition" check box is @@ -899,7 +898,7 @@ public class Upkeep extends Phase implements java.io.Serializable { // abilities when ready @Override public void resolve() { - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); if (library.size() <= 0) { return; } @@ -981,9 +980,9 @@ 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(Zone.Battlefield, "Leaf-Crowned Elder"); + final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Leaf-Crowned Elder"); - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is // empty. // Useful for games when the "Milling = Loss Condition" check box is @@ -1001,7 +1000,7 @@ public class Upkeep extends Phase implements java.io.Serializable { // abilities when ready @Override public void resolve() { - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); if (library.size() <= 0) { return; } @@ -1081,9 +1080,9 @@ 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(Zone.Battlefield, "Mudbutton Clanger"); + final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Mudbutton Clanger"); - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is // empty. // Useful for games when the "Milling = Loss Condition" check box is @@ -1101,7 +1100,7 @@ public class Upkeep extends Phase implements java.io.Serializable { // abilities when ready @Override public void resolve() { - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); if (library.size() <= 0) { return; } @@ -1178,10 +1177,10 @@ 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(Zone.Battlefield, "Nightshade Schemers"); + final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Nightshade Schemers"); final Player opponent = player.getOpponent(); - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is // empty. // Useful for games when the "Milling = Loss Condition" check box is @@ -1199,7 +1198,7 @@ public class Upkeep extends Phase implements java.io.Serializable { // abilities when ready @Override public void resolve() { - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); if (library.size() <= 0) { return; } @@ -1263,9 +1262,9 @@ 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(Zone.Battlefield, "Pyroclast Consul"); + final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Pyroclast Consul"); - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is // empty. // Useful for games when the "Milling = Loss Condition" check box is @@ -1283,7 +1282,7 @@ public class Upkeep extends Phase implements java.io.Serializable { // abilities when ready @Override public void resolve() { - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); if (library.size() <= 0) { return; } @@ -1362,10 +1361,10 @@ 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(Zone.Battlefield, "Sensation Gorger"); + final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Sensation Gorger"); final Player opponent = player.getOpponent(); - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is // empty. // Useful for games when the "Milling = Loss Condition" check box is @@ -1383,8 +1382,8 @@ public class Upkeep extends Phase implements java.io.Serializable { // abilities when ready @Override public void resolve() { - final PlayerZone library = player.getZone(Constant.Zone.Library); - final PlayerZone hand = player.getZone(Constant.Zone.Hand); + final PlayerZone library = player.getZone(ZoneType.Library); + final PlayerZone hand = player.getZone(ZoneType.Hand); if (library.size() <= 0) { return; } @@ -1454,10 +1453,10 @@ 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(Zone.Battlefield, "Squeaking Pie Grubfellows"); + final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Squeaking Pie Grubfellows"); final Player opponent = player.getOpponent(); - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is // empty. // Useful for games when the "Milling = Loss Condition" check box is @@ -1475,7 +1474,7 @@ public class Upkeep extends Phase implements java.io.Serializable { // abilities when ready @Override public void resolve() { - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); if (library.size() <= 0) { return; } @@ -1540,9 +1539,9 @@ 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(Zone.Battlefield, "Wandering Graybeard"); + final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Wandering Graybeard"); - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is // empty. // Useful for games when the "Milling = Loss Condition" check box is @@ -1560,7 +1559,7 @@ public class Upkeep extends Phase implements java.io.Serializable { // abilities when ready @Override public void resolve() { - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); if (library.size() <= 0) { return; } @@ -1624,9 +1623,9 @@ 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(Zone.Battlefield, "Waterspout Weavers"); + final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Waterspout Weavers"); - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is // empty. // Useful for games when the "Milling = Loss Condition" check box is @@ -1644,7 +1643,7 @@ public class Upkeep extends Phase implements java.io.Serializable { // abilities when ready @Override public void resolve() { - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); if (library.size() <= 0) { return; } @@ -1729,9 +1728,9 @@ 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(Zone.Battlefield, "Winnower Patrol"); + final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Winnower Patrol"); - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is // empty. // Useful for games when the "Milling = Loss Condition" check box is @@ -1749,7 +1748,7 @@ public class Upkeep extends Phase implements java.io.Serializable { // abilities when ready @Override public void resolve() { - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); if (library.size() <= 0) { return; } @@ -1813,9 +1812,9 @@ 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(Zone.Battlefield, "Wolf-Skull Shaman"); + final CardList kinship = player.getCardsIn(ZoneType.Battlefield, "Wolf-Skull Shaman"); - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); // Players would not choose to trigger Kinship ability if library is // empty. // Useful for games when the "Milling = Loss Condition" check box is @@ -1833,7 +1832,7 @@ public class Upkeep extends Phase implements java.io.Serializable { // abilities when ready @Override public void resolve() { - final PlayerZone library = player.getZone(Constant.Zone.Library); + final PlayerZone library = player.getZone(ZoneType.Library); if (library.size() <= 0) { return; } @@ -1905,7 +1904,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(Zone.Exile); + CardList list = player.getCardsIn(ZoneType.Exile); list = list.filter(new CardListFilter() { @Override @@ -1934,7 +1933,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(Zone.Battlefield); + CardList list = player.getCardsIn(ZoneType.Battlefield); list = list.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -1971,7 +1970,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(Zone.Battlefield); + CardList list = player.getCardsIn(ZoneType.Battlefield); list = list.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -2011,7 +2010,7 @@ public class Upkeep extends Phase implements java.io.Serializable { *

*/ private static void upkeepOathOfDruids() { - final CardList oathList = AllZoneUtil.getCardsIn(Zone.Battlefield, "Oath of Druids"); + final CardList oathList = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Oath of Druids"); if (oathList.isEmpty()) { return; } @@ -2024,8 +2023,8 @@ 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(Zone.Library); - final PlayerZone battlefield = player.getZone(Constant.Zone.Battlefield); + final CardList libraryList = player.getCardsIn(ZoneType.Library); + final PlayerZone battlefield = player.getZone(ZoneType.Battlefield); boolean oathFlag = true; if (AllZoneUtil.compareTypeAmountInPlay(player, "Creature") < 0) { @@ -2037,8 +2036,8 @@ public class Upkeep extends Phase implements java.io.Serializable { oathFlag = false; } } else { // if player == Computer - final CardList creaturesInLibrary = player.getCardsIn(Zone.Library).getType("Creature"); - final CardList creaturesInBattlefield = player.getCardsIn(Zone.Battlefield).getType( + final CardList creaturesInLibrary = player.getCardsIn(ZoneType.Library).getType("Creature"); + final CardList creaturesInBattlefield = player.getCardsIn(ZoneType.Battlefield).getType( "Creature"); // if there are at least 3 creatures in library, @@ -2093,7 +2092,7 @@ public class Upkeep extends Phase implements java.io.Serializable { *

*/ private static void upkeepOathOfGhouls() { - final CardList oathList = AllZoneUtil.getCardsIn(Zone.Battlefield, "Oath of Ghouls"); + final CardList oathList = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Oath of Ghouls"); if (oathList.isEmpty()) { return; } @@ -2105,7 +2104,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 = player.getCardsIn(Zone.Graveyard).getType("Creature"); + final CardList graveyardCreatures = player.getCardsIn(ZoneType.Graveyard).getType("Creature"); if (AllZoneUtil.compareTypeAmountInGraveyard(player, "Creature") > 0) { if (player.isHuman()) { @@ -2144,8 +2143,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(Zone.Battlefield, "Karma"); - final CardList swamps = player.getCardsIn(Zone.Battlefield).getType("Swamp"); + final CardList karmas = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Karma"); + final CardList swamps = player.getCardsIn(ZoneType.Battlefield).getType("Swamp"); // determine how much damage to deal the current player final int damage = swamps.size(); @@ -2189,7 +2188,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(Zone.Battlefield, "Power Surge"); + final CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Power Surge"); final int damage = player.getNumPowerSurgeLands(); for (final Card surge : list) { @@ -2225,7 +2224,7 @@ public class Upkeep extends Phase implements java.io.Serializable { final String keyword2 = "At the beginning of your upkeep, you may have this " + "creature become a copy of another target creature. If you do, " + "this creature gains this ability."; - CardList list = player.getCardsIn(Zone.Battlefield); + CardList list = player.getCardsIn(ZoneType.Battlefield); list = list.filter(new CardListFilter() { public boolean addCard(Card c) { return c.hasAnyKeyword(new String[] {keyword1, keyword2}); @@ -2298,7 +2297,7 @@ public class Upkeep extends Phase implements java.io.Serializable { @Override public void selectCard(final Card selectedCard, final PlayerZone z) { - if (z.is(Constant.Zone.Battlefield) && selectedCard.isCreature() + if (z.is(ZoneType.Battlefield) && selectedCard.isCreature() && selectedCard.canBeTargetedBy(switchTargets)) { newTarget[0] = selectedCard; final StringBuilder sb = new StringBuilder(); @@ -2329,14 +2328,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(Zone.Battlefield, "Tangle Wire"); + final CardList 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 = player.getCardsIn(Zone.Battlefield).filter(new CardListFilter() { + final CardList list = player.getCardsIn(ZoneType.Battlefield).filter(new CardListFilter() { @Override public boolean addCard(final Card c) { return (c.isArtifact() || c.isLand() || c.isCreature()) && c.isUntapped(); @@ -2373,7 +2372,7 @@ public class Upkeep extends Phase implements java.io.Serializable { @Override public void selectCard(final Card card, final PlayerZone zone) { - if (zone.is(Constant.Zone.Battlefield, AllZone.getHumanPlayer()) + if (zone.is(ZoneType.Battlefield, AllZone.getHumanPlayer()) && list.contains(card)) { card.tap(); list.remove(card); @@ -2403,7 +2402,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(Zone.Battlefield); + CardList blaze = player.getCardsIn(ZoneType.Battlefield); blaze = blaze.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -2502,7 +2501,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(Zone.Battlefield, "Curse of Misfortunes"); + final CardList misfortunes = player.getCardsIn(ZoneType.Battlefield, "Curse of Misfortunes"); for (int i = 0; i < misfortunes.size(); i++) { final Card source = misfortunes.get(i); @@ -2510,7 +2509,7 @@ 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(Zone.Library); + CardList enchantmentsInLibrary = source.getController().getCardsIn(ZoneType.Library); final CardList enchantmentsAttached = new CardList(source.getEnchantingPlayer().getEnchantedBy()); enchantmentsInLibrary = enchantmentsInLibrary.filter(new CardListFilter() { @Override @@ -2537,7 +2536,7 @@ public class Upkeep extends Phase implements java.io.Serializable { } if (enchantment != null) { GameAction.changeZone(AllZone.getZoneOf(enchantment), - enchantment.getOwner().getZone(Constant.Zone.Battlefield), enchantment); + enchantment.getOwner().getZone(ZoneType.Battlefield), enchantment); enchantment.enchantEntity(source.getEnchantingPlayer()); } source.getController().shuffle(); diff --git a/src/main/java/forge/game/player/AIPlayer.java b/src/main/java/forge/game/player/AIPlayer.java index c3b7d750190..3e28571a510 100644 --- a/src/main/java/forge/game/player/AIPlayer.java +++ b/src/main/java/forge/game/player/AIPlayer.java @@ -26,9 +26,9 @@ import forge.CardListFilter; import forge.CardListUtil; import forge.CardUtil; import forge.Singletons; -import forge.Constant.Zone; import forge.card.cardfactory.CardFactoryUtil; import forge.card.spellability.SpellAbility; +import forge.game.zone.ZoneType; import forge.util.MyRandom; /** @@ -132,7 +132,7 @@ public class AIPlayer extends Player { /** {@inheritDoc} */ @Override public final CardList mayDrawCards(final int n) { - if (this.getCardsIn(Zone.Library).size() > n) { + if (this.getCardsIn(ZoneType.Library).size() > n) { return this.drawCards(n); } else { return new CardList(); @@ -156,12 +156,12 @@ public class AIPlayer extends Player { dredgers.shuffle(); final Card c = dredgers.get(0); // rule 702.49a - if (this.getDredgeNumber(c) <= this.getCardsIn(Zone.Library).size()) { + if (this.getDredgeNumber(c) <= this.getCardsIn(ZoneType.Library).size()) { // dredge library, put card in hand Singletons.getModel().getGameAction().moveToHand(c); // put dredge number in graveyard for (int i = 0; i < this.getDredgeNumber(c); i++) { - final Card c2 = this.getCardsIn(Zone.Library).get(0); + final Card c2 = this.getCardsIn(ZoneType.Library).get(0); Singletons.getModel().getGameAction().moveToGraveyard(c2); } return true; @@ -179,7 +179,7 @@ public class AIPlayer extends Player { /** {@inheritDoc} */ @Override public final CardList discard(final int num, final SpellAbility sa, final boolean duringResolution) { - int max = this.getCardsIn(Zone.Hand).size(); + int max = this.getCardsIn(ZoneType.Hand).size(); max = Math.min(max, num); final CardList discarded = ComputerUtil.discardNumTypeAI(max, null, sa); for (int i = 0; i < discarded.size(); i++) { @@ -192,7 +192,7 @@ 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(Zone.Hand); + final CardList hand = this.getCardsIn(ZoneType.Hand); final CardList tHand = hand.getType(uType); if (tHand.size() > 0) { @@ -227,9 +227,9 @@ public class AIPlayer extends Player { position = -1; } } - final CardList hand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + final CardList hand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); - CardList blIP = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList blIP = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); blIP = blIP.getType("Basic"); if (blIP.size() > 5) { @@ -261,7 +261,7 @@ public class AIPlayer extends Player { for (int i = 0; i < num; i++) { boolean bottom = false; if (topN.get(i).isBasicLand()) { - CardList bl = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList bl = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); bl = bl.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -276,7 +276,7 @@ public class AIPlayer extends Player { bottom = bl.size() > 5; // if control more than 5 Basic land, // probably don't need more } else if (topN.get(i).isCreature()) { - CardList cl = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList cl = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); cl = cl.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { diff --git a/src/main/java/forge/game/player/ComputerAIGeneral.java b/src/main/java/forge/game/player/ComputerAIGeneral.java index 24880adb1d7..5f3bfacdc22 100644 --- a/src/main/java/forge/game/player/ComputerAIGeneral.java +++ b/src/main/java/forge/game/player/ComputerAIGeneral.java @@ -28,7 +28,6 @@ import forge.AllZoneUtil; import forge.Card; import forge.CardList; import forge.Singletons; -import forge.Constant.Zone; import forge.card.abilityfactory.AbilityFactory; import forge.card.cardfactory.CardFactoryUtil; import forge.card.spellability.SpellAbility; @@ -36,6 +35,7 @@ import forge.card.spellability.SpellPermanent; import forge.card.trigger.Trigger; import forge.card.trigger.TriggerType; import forge.game.phase.PhaseType; +import forge.game.zone.ZoneType; /** *

@@ -99,9 +99,9 @@ public class ComputerAIGeneral implements Computer { * @return a boolean. */ public static boolean hasACardGivingHaste() { - final CardList all = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + final CardList all = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); all.addAll(CardFactoryUtil.getExternalZoneActivationCards(AllZone.getComputerPlayer())); - all.addAll(AllZone.getComputerPlayer().getCardsIn(Zone.Hand)); + all.addAll(AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand)); for (final Card c : all) { for (final SpellAbility sa : c.getSpellAbility()) { @@ -135,15 +135,15 @@ public class ComputerAIGeneral implements Computer { private CardList getAvailableCards() { final Player computer = AllZone.getComputerPlayer(); final Player human = AllZone.getHumanPlayer(); - CardList all = computer.getCardsIn(Zone.Hand); - all.addAll(computer.getCardsIn(Zone.Battlefield)); - all.addAll(computer.getCardsIn(Zone.Exile)); - all.addAll(computer.getCardsIn(Zone.Graveyard)); - if (!computer.getCardsIn(Zone.Library).isEmpty()) { - all.add(computer.getCardsIn(Zone.Library).get(0)); + CardList all = computer.getCardsIn(ZoneType.Hand); + all.addAll(computer.getCardsIn(ZoneType.Battlefield)); + all.addAll(computer.getCardsIn(ZoneType.Exile)); + all.addAll(computer.getCardsIn(ZoneType.Graveyard)); + if (!computer.getCardsIn(ZoneType.Library).isEmpty()) { + all.add(computer.getCardsIn(ZoneType.Library).get(0)); } - all.addAll(human.getCardsIn(Zone.Exile)); - all.addAll(human.getCardsIn(Zone.Battlefield)); + all.addAll(human.getCardsIn(ZoneType.Exile)); + all.addAll(human.getCardsIn(ZoneType.Battlefield)); return all; } @@ -163,7 +163,7 @@ public class ComputerAIGeneral implements Computer { continue; } - if (!params.get("Destination").equals(Zone.Battlefield.toString())) { + if (!params.get("Destination").equals(ZoneType.Battlefield.toString())) { continue; } @@ -185,13 +185,13 @@ public class ComputerAIGeneral implements Computer { private ArrayList getPossibleETBCounters() { final Player computer = AllZone.getComputerPlayer(); final Player human = AllZone.getHumanPlayer(); - CardList all = computer.getCardsIn(Zone.Hand); - all.addAll(computer.getCardsIn(Zone.Exile)); - all.addAll(computer.getCardsIn(Zone.Graveyard)); - if (!computer.getCardsIn(Zone.Library).isEmpty()) { - all.add(computer.getCardsIn(Zone.Library).get(0)); + CardList all = computer.getCardsIn(ZoneType.Hand); + all.addAll(computer.getCardsIn(ZoneType.Exile)); + all.addAll(computer.getCardsIn(ZoneType.Graveyard)); + if (!computer.getCardsIn(ZoneType.Library).isEmpty()) { + all.add(computer.getCardsIn(ZoneType.Library).get(0)); } - all.addAll(human.getCardsIn(Zone.Exile)); + all.addAll(human.getCardsIn(ZoneType.Exile)); final ArrayList spellAbilities = new ArrayList(); for (final Card c : all) { @@ -280,7 +280,7 @@ public class ComputerAIGeneral implements Computer { Log.debug(sb.toString()); } - AllZone.getComputerPlayer().getZone(Zone.Battlefield).updateObservers(); + AllZone.getComputerPlayer().getZone(ZoneType.Battlefield).updateObservers(); Singletons.getModel().getGameState().getPhaseHandler().setNeedToNextPhase(true); } diff --git a/src/main/java/forge/game/player/ComputerUtil.java b/src/main/java/forge/game/player/ComputerUtil.java index b6f68ba5e6d..6cdac6fa9bb 100644 --- a/src/main/java/forge/game/player/ComputerUtil.java +++ b/src/main/java/forge/game/player/ComputerUtil.java @@ -29,10 +29,8 @@ import forge.CardList; import forge.CardListFilter; import forge.CardListUtil; import forge.CardUtil; -import forge.Constant; import forge.GameAction; import forge.Singletons; -import forge.Constant.Zone; import forge.card.abilityfactory.AbilityFactory; import forge.card.cardfactory.CardFactoryUtil; import forge.card.cost.Cost; @@ -50,6 +48,7 @@ import forge.control.input.InputPayManaCostUtil; import forge.error.ErrorViewer; import forge.game.phase.Combat; import forge.game.phase.CombatUtil; +import forge.game.zone.ZoneType; /** *

@@ -191,7 +190,7 @@ public class ComputerUtil { // Consider the costs here for relative "scoring" if (CostUtil.hasDiscardHandCost(cost)) { // Null Brooch aid - restrict -= (AllZone.getComputerPlayer().getCardsIn(Zone.Hand).size() * 20); + restrict -= (AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand).size() * 20); } // Abilities before Spells (card advantage) @@ -923,7 +922,7 @@ public class ComputerUtil { * @return a {@link forge.CardList} object. */ public static CardList getAvailableMana(final Player player) { - final CardList list = player.getCardsIn(Zone.Battlefield); + final CardList list = player.getCardsIn(ZoneType.Battlefield); final CardList manaSources = list.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -1181,10 +1180,10 @@ public class ComputerUtil { */ public static boolean chooseLandsToPlay() { final Player computer = AllZone.getComputerPlayer(); - CardList landList = computer.getCardsIn(Zone.Hand); + CardList landList = computer.getCardsIn(ZoneType.Hand); landList = landList.filter(CardListFilter.LANDS); - final CardList lands = computer.getCardsIn(Zone.Graveyard); + final CardList lands = computer.getCardsIn(ZoneType.Graveyard); for (final Card crd : lands) { if (crd.isLand() && crd.hasStartOfKeyword("May be played")) { landList.add(crd); @@ -1196,7 +1195,7 @@ public class ComputerUtil { public boolean addCard(final Card c) { if (c.getSVar("NeedsToPlay").length() > 0) { final String needsToPlay = c.getSVar("NeedsToPlay"); - CardList list = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList list = AllZoneUtil.getCardsIn(ZoneType.Battlefield); list = list.getValidCards(needsToPlay.split(","), c.getController(), c); if (list.isEmpty()) { @@ -1204,7 +1203,7 @@ public class ComputerUtil { } } if (c.isType("Legendary") && !c.getName().equals("Flagstones of Trokair")) { - final CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + final CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); if (list.containsName(c.getName())) { return false; } @@ -1215,8 +1214,8 @@ public class ComputerUtil { final ArrayList spellAbilities = c.getSpellAbilities(); for (final SpellAbility sa : spellAbilities) { if (sa.isCycling()) { - final CardList hand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); - CardList lands = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + final CardList hand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); + CardList lands = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); lands.addAll(hand); lands = lands.getType("Land"); @@ -1330,7 +1329,7 @@ public class ComputerUtil { */ public static CardList chooseSacrificeType(final String type, final Card activate, final Card target, final int amount) { - CardList typeList = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList typeList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); typeList = typeList.getValidCards(type.split(","), activate.getController(), activate); if ((target != null) && target.getController().isComputer() && typeList.contains(target)) { typeList.remove(target); // don't sacrifice the card we're pumping @@ -1377,7 +1376,7 @@ public class ComputerUtil { * @return a CardList of discarded cards. */ public static CardList discardNumTypeAI(final int numDiscard, final String[] uTypes, final SpellAbility sa) { - CardList hand = AllZone.getComputerPlayer().getCardsIn(Zone.Hand); + CardList hand = AllZone.getComputerPlayer().getCardsIn(ZoneType.Hand); Card sourceCard = null; if ((uTypes != null) && (sa != null)) { @@ -1413,7 +1412,7 @@ public class ComputerUtil { if (hand.size() <= 0) { continue; } - final CardList landsInPlay = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield).getType("Land"); + final CardList landsInPlay = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield).getType("Land"); if (landsInPlay.size() > 5) { final CardList landsInHand = hand.getType("Land"); if (landsInHand.size() > 0) { // discard lands @@ -1451,7 +1450,7 @@ public class ComputerUtil { * @return a {@link forge.CardList} object. */ public static CardList chooseExileType(final String type, final Card activate, final Card target, final int amount) { - return ComputerUtil.chooseExileFrom(Constant.Zone.Battlefield, type, activate, target, amount); + return ComputerUtil.chooseExileFrom(ZoneType.Battlefield, type, activate, target, amount); } /** @@ -1471,7 +1470,7 @@ public class ComputerUtil { */ public static CardList chooseExileFromHandType(final String type, final Card activate, final Card target, final int amount) { - return ComputerUtil.chooseExileFrom(Constant.Zone.Hand, type, activate, target, amount); + return ComputerUtil.chooseExileFrom(ZoneType.Hand, type, activate, target, amount); } /** @@ -1491,7 +1490,7 @@ public class ComputerUtil { */ public static CardList chooseExileFromGraveType(final String type, final Card activate, final Card target, final int amount) { - return ComputerUtil.chooseExileFrom(Constant.Zone.Graveyard, type, activate, target, amount); + return ComputerUtil.chooseExileFrom(ZoneType.Graveyard, type, activate, target, amount); } /** @@ -1511,7 +1510,7 @@ public class ComputerUtil { * a int. * @return a {@link forge.CardList} object. */ - public static CardList chooseExileFrom(final Constant.Zone zone, final String type, final Card activate, + public static CardList chooseExileFrom(final ZoneType zone, final String type, final Card activate, final Card target, final int amount) { CardList typeList = AllZone.getComputerPlayer().getCardsIn(zone); typeList = typeList.getValidCards(type.split(","), activate.getController(), activate); @@ -1548,7 +1547,7 @@ public class ComputerUtil { * @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(Zone.Battlefield); + CardList typeList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); typeList = typeList.getValidCards(type.split(","), activate.getController(), activate); // is this needed? @@ -1588,7 +1587,7 @@ public class ComputerUtil { * @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(Zone.Battlefield); + CardList typeList = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); typeList = typeList.getValidCards(type.split(","), activate.getController(), activate); if ((target != null) && target.getController().isComputer() && typeList.contains(target)) { // bounce @@ -1620,7 +1619,7 @@ public class ComputerUtil { * @return a {@link forge.CardList} object. */ public static CardList getPossibleAttackers() { - CardList list = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + CardList list = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); list = list.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { @@ -1638,8 +1637,8 @@ public class ComputerUtil { * @return a {@link forge.game.phase.Combat} object. */ public static Combat getAttackers() { - final ComputerUtilAttack att = new ComputerUtilAttack(AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield), - AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield)); + final ComputerUtilAttack att = new ComputerUtilAttack(AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield), + AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield)); return att.getAttackers(); } @@ -1652,7 +1651,7 @@ public class ComputerUtil { * @return a {@link forge.game.phase.Combat} object. */ public static Combat getBlockers() { - final CardList blockers = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); + final CardList blockers = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield); return ComputerUtilBlock.getBlockers(AllZone.getCombat(), blockers); } @@ -1787,7 +1786,7 @@ public class ComputerUtil { } final Player controller = card.getController(); - final CardList l = controller.getCardsIn(Zone.Battlefield); + final CardList 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 @@ -1807,7 +1806,7 @@ public class ComputerUtil { final Target tgt = sa.getTarget(); if (tgt != null) { - if (AllZoneUtil.getCardsIn(Zone.Battlefield) + if (AllZoneUtil.getCardsIn(ZoneType.Battlefield) .getValidCards(tgt.getValidTgts(), controller, sa.getSourceCard()).contains(card)) { return true; } @@ -1839,7 +1838,7 @@ public class ComputerUtil { int prevented = 0; final Player controller = card.getController(); - final CardList l = controller.getCardsIn(Zone.Battlefield); + final CardList 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 @@ -1857,7 +1856,7 @@ public class ComputerUtil { } final Target tgt = sa.getTarget(); if (tgt != null) { - if (AllZoneUtil.getCardsIn(Zone.Battlefield) + if (AllZoneUtil.getCardsIn(ZoneType.Battlefield) .getValidCards(tgt.getValidTgts(), controller, af.getHostCard()).contains(card)) { prevented += AbilityFactory.calculateAmount(af.getHostCard(), mapParams.get("Amount"), sa); diff --git a/src/main/java/forge/game/player/ComputerUtilAttack.java b/src/main/java/forge/game/player/ComputerUtilAttack.java index f485af8f0b8..a94e2ec78d5 100644 --- a/src/main/java/forge/game/player/ComputerUtilAttack.java +++ b/src/main/java/forge/game/player/ComputerUtilAttack.java @@ -26,16 +26,15 @@ import forge.Card; import forge.CardList; import forge.CardListFilter; import forge.CardListUtil; -import forge.Constant; import forge.Counters; import forge.GameEntity; import forge.Singletons; -import forge.Constant.Zone; import forge.card.cardfactory.CardFactoryUtil; import forge.card.trigger.Trigger; import forge.card.trigger.TriggerType; import forge.game.phase.Combat; import forge.game.phase.CombatUtil; +import forge.game.zone.ZoneType; import forge.util.MyRandom; //doesHumanAttackAndWin() uses the global variable AllZone.getComputerPlayer() @@ -255,7 +254,7 @@ public class ComputerUtilAttack { final int humanExaltedBonus = this.countExaltedBonus(AllZone.getHumanPlayer()); if (humanExaltedBonus > 0) { - final int nFinestHours = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield, "Finest Hour").size(); + final int nFinestHours = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield, "Finest Hour").size(); if (((blockersNeeded == 0) || (nFinestHours > 0)) && (this.humanList.size() > 0)) { // @@ -337,7 +336,7 @@ public class ComputerUtilAttack { // Beastmaster Ascension if (AllZoneUtil.isCardInPlay("Beastmaster Ascension", AllZone.getComputerPlayer()) && (this.attackers.size() > 1)) { - final CardList beastions = AllZone.getComputerPlayer().getCardsIn(Constant.Zone.Battlefield) + final CardList beastions = AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield) .getName("Beastmaster Ascension"); int minCreatures = 7; for (final Card beastion : beastions) { @@ -481,8 +480,8 @@ public class ComputerUtilAttack { if ((combat.getAttackers().isEmpty()) && ((this.countExaltedBonus(AllZone.getComputerPlayer()) >= 3) || AllZoneUtil.isCardInPlay("Rafiq of the Many", AllZone.getComputerPlayer()) - || (AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield, "Battlegrace Angel").size() >= 2) - || ((AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield, "Finest Hour").size() >= 1) + || (AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield, "Battlegrace Angel").size() >= 2) + || ((AllZone.getComputerPlayer().getCardsIn(ZoneType.Battlefield, "Finest Hour").size() >= 1) && Singletons.getModel().getGameState().getPhaseHandler().isFirstCombat()))) { int biggest = 0; Card att = null; @@ -729,7 +728,7 @@ public class ComputerUtilAttack { * @return a int. */ public final int countExaltedBonus(final Player player) { - CardList list = player.getCardsIn(Zone.Battlefield); + CardList list = player.getCardsIn(ZoneType.Battlefield); list = list.filter(new CardListFilter() { @Override public boolean addCard(final Card c) { diff --git a/src/main/java/forge/game/player/HumanPlayer.java b/src/main/java/forge/game/player/HumanPlayer.java index b16a34263cf..1501e75aa26 100644 --- a/src/main/java/forge/game/player/HumanPlayer.java +++ b/src/main/java/forge/game/player/HumanPlayer.java @@ -22,9 +22,9 @@ import forge.Card; import forge.CardList; import forge.GameActionUtil; import forge.Singletons; -import forge.Constant.Zone; import forge.card.spellability.SpellAbility; import forge.control.input.Input; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; /** @@ -144,14 +144,14 @@ public class HumanPlayer extends Player { if (o.equals("Yes")) { final Card c = GuiUtils.chooseOne("Select card to dredge", this.getDredge().toArray()); // rule 702.49a - if (this.getDredgeNumber(c) <= AllZone.getHumanPlayer().getZone(Zone.Library).size()) { + if (this.getDredgeNumber(c) <= AllZone.getHumanPlayer().getZone(ZoneType.Library).size()) { // might have to make this more sophisticated // dredge library, put card in hand Singletons.getModel().getGameAction().moveToHand(c); for (int i = 0; i < this.getDredgeNumber(c); i++) { - final Card c2 = AllZone.getHumanPlayer().getZone(Zone.Library).get(0); + final Card c2 = AllZone.getHumanPlayer().getZone(ZoneType.Library).get(0); Singletons.getModel().getGameAction().moveToGraveyard(c2); } dredged = true; @@ -174,7 +174,7 @@ public class HumanPlayer extends Player { /** {@inheritDoc} */ @Override public final void discardUnless(final int num, final String uType, final SpellAbility sa) { - if (this.getCardsIn(Zone.Hand).size() > 0) { + if (this.getCardsIn(ZoneType.Hand).size() > 0) { AllZone.getInputControl().setInput(PlayerUtil.inputDiscardNumUnless(num, uType, sa)); } } diff --git a/src/main/java/forge/game/player/Player.java b/src/main/java/forge/game/player/Player.java index 696a815ee29..132625776bb 100644 --- a/src/main/java/forge/game/player/Player.java +++ b/src/main/java/forge/game/player/Player.java @@ -39,7 +39,6 @@ import forge.GameActionUtil; import forge.GameEntity; import forge.HandSizeOp; import forge.Singletons; -import forge.Constant.Zone; import forge.card.cardfactory.CardFactoryUtil; import forge.card.mana.ManaPool; import forge.card.spellability.SpellAbility; @@ -47,6 +46,10 @@ import forge.card.staticability.StaticAbility; import forge.card.trigger.TriggerType; import forge.game.GameLossReason; import forge.game.phase.PhaseHandler; +import forge.game.zone.DefaultPlayerZone; +import forge.game.zone.PlayerZone; +import forge.game.zone.PlayerZoneComesIntoPlay; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.util.MyRandom; @@ -130,11 +133,11 @@ public abstract class Player extends GameEntity { private boolean attackedWithCreatureThisTurn = false; /** The zones. */ - private final Map zones = new EnumMap(Constant.Zone.class); + private final Map zones = new EnumMap(ZoneType.class); /** The Constant ALL_ZONES. */ - public static final List ALL_ZONES = Collections.unmodifiableList(Arrays.asList(Zone.Battlefield, - Zone.Library, Zone.Graveyard, Zone.Hand, Zone.Exile, Zone.Command, Zone.Ante)); + public static final List ALL_ZONES = Collections.unmodifiableList(Arrays.asList(ZoneType.Battlefield, + ZoneType.Library, ZoneType.Graveyard, ZoneType.Hand, ZoneType.Exile, ZoneType.Command, ZoneType.Ante)); /** *

@@ -161,8 +164,8 @@ public abstract class Player extends GameEntity { * a int. */ public Player(final String myName, final int myLife, final int myPoisonCounters) { - for (final Zone z : Player.ALL_ZONES) { - final PlayerZone toPut = z == Zone.Battlefield ? new PlayerZoneComesIntoPlay(z, this) + for (final ZoneType z : Player.ALL_ZONES) { + final PlayerZone toPut = z == ZoneType.Battlefield ? new PlayerZoneComesIntoPlay(z, this) : new DefaultPlayerZone(z, this); this.zones.put(z, toPut); } @@ -521,7 +524,7 @@ public abstract class Player extends GameEntity { "As long as you have 0 or less life, all damage is dealt to you as though its source had infect."); if ((this.getLife() <= 0) && !infect) { - final CardList cards = this.getCardsIn(Zone.Battlefield); + final CardList cards = this.getCardsIn(ZoneType.Battlefield); for (final Card card : cards) { if (card.hasKeyword(sb.toString())) { infect = true; @@ -637,7 +640,7 @@ public abstract class Player extends GameEntity { } // Prevent Damage static abilities - final CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card ca : allp) { final ArrayList staticAbilities = ca.getStaticAbilities(); for (final StaticAbility stAb : staticAbilities) { @@ -685,7 +688,7 @@ public abstract class Player extends GameEntity { int restDamage = damage; if (AllZoneUtil.isCardInPlay("Sulfuric Vapors") && source.isSpell() && source.isRed()) { - final int amount = AllZoneUtil.getCardsIn(Zone.Battlefield, "Sulfuric Vapors").size(); + final int amount = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Sulfuric Vapors").size(); for (int i = 0; i < amount; i++) { restDamage += 1; } @@ -693,21 +696,21 @@ public abstract class Player extends GameEntity { if (AllZoneUtil.isCardInPlay("Pyromancer's Swath", source.getController()) && (source.isInstant() || source.isSorcery())) { - final int amount = source.getController().getCardsIn(Zone.Battlefield, "Pyromancer's Swath").size(); + final int amount = source.getController().getCardsIn(ZoneType.Battlefield, "Pyromancer's Swath").size(); for (int i = 0; i < amount; i++) { restDamage += 2; } } // if (AllZoneUtil.isCardInPlay("Furnace of Rath")) { - final int amount = AllZoneUtil.getCardsIn(Zone.Battlefield, "Furnace of Rath").size(); + final int amount = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Furnace of Rath").size(); for (int i = 0; i < amount; i++) { restDamage += restDamage; } } // if (AllZoneUtil.isCardInPlay("Gratuitous Violence", source.getController()) && source.isCreature()) { - final int amount = source.getController().getCardsIn(Zone.Battlefield, "Gratuitous Violence").size(); + final int amount = source.getController().getCardsIn(ZoneType.Battlefield, "Gratuitous Violence").size(); for (int i = 0; i < amount; i++) { restDamage += restDamage; } @@ -715,7 +718,7 @@ public abstract class Player extends GameEntity { // if (AllZoneUtil.isCardInPlay("Fire Servant", source.getController()) && source.isRed() && (source.isInstant() || source.isSorcery())) { - final int amount = source.getController().getCardsIn(Zone.Battlefield, "Fire Servant").size(); + final int amount = source.getController().getCardsIn(ZoneType.Battlefield, "Fire Servant").size(); for (int i = 0; i < amount; i++) { restDamage *= 2; } @@ -723,7 +726,7 @@ public abstract class Player extends GameEntity { // if (AllZoneUtil.isCardInPlay("Benevolent Unicorn") && source.isSpell()) { - final int amount = AllZoneUtil.getCardsIn(Zone.Battlefield, "Benevolent Unicorn").size(); + final int amount = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Benevolent Unicorn").size(); for (int i = 0; i < amount; i++) { if (restDamage > 0) { restDamage -= 1; @@ -776,7 +779,7 @@ public abstract class Player extends GameEntity { if (AllZoneUtil.isCardInPlay("Crumbling Sanctuary")) { for (int i = 0; i < damage; i++) { - final CardList lib = this.getCardsIn(Zone.Library); + final CardList lib = this.getCardsIn(ZoneType.Library); if (lib.size() > 0) { Singletons.getModel().getGameAction().exile(lib.get(0)); } @@ -1239,7 +1242,7 @@ public abstract class Player extends GameEntity { } if (!firstFromDraw && AllZoneUtil.isCardInPlay("Chains of Mephistopheles")) { - if (!this.getZone(Zone.Hand).isEmpty()) { + if (!this.getZone(ZoneType.Hand).isEmpty()) { if (this.isHuman()) { this.discardChainsOfMephistopheles(); } else { // Computer @@ -1266,7 +1269,7 @@ public abstract class Player extends GameEntity { */ private CardList doDraw() { final CardList drawn = new CardList(); - final PlayerZone library = this.getZone(Constant.Zone.Library); + final PlayerZone library = this.getZone(ZoneType.Library); // Replacement effects final HashMap repRunParams = new HashMap(); @@ -1285,7 +1288,7 @@ public abstract class Player extends GameEntity { if ((this.numDrawnThisTurn == 0) && this.isComputer()) { boolean reveal = false; - final CardList cards = this.getCardsIn(Zone.Battlefield); + final CardList cards = this.getCardsIn(ZoneType.Battlefield); for (final Card card : cards) { if (card.hasKeyword("Reveal the first card you draw each turn")) { reveal = true; @@ -1326,7 +1329,7 @@ public abstract class Player extends GameEntity { * the zone * @return the zone */ - public final PlayerZone getZone(final Zone zone) { + public final PlayerZone getZone(final ZoneType zone) { return this.zones.get(zone); } @@ -1338,8 +1341,8 @@ public abstract class Player extends GameEntity { * the zone * @return a CardList with all the cards currently in requested zone */ - public final CardList getCardsIn(final Constant.Zone zone) { - final List cards = zone == Zone.Stack ? AllZone.getStackZone().getCards() : this.getZone(zone).getCards(); + public final CardList getCardsIn(final ZoneType zone) { + final List cards = zone == ZoneType.Stack ? AllZone.getStackZone().getCards() : this.getZone(zone).getCards(); return new CardList(cards); } @@ -1359,8 +1362,8 @@ public abstract class Player extends GameEntity { * the zone * @return the cards include phasing in */ - public final CardList getCardsIncludePhasingIn(final Constant.Zone zone) { - final List cards = zone == Zone.Stack ? AllZone.getStackZone().getCards() : this.getZone(zone) + public final CardList getCardsIncludePhasingIn(final ZoneType zone) { + final List cards = zone == ZoneType.Stack ? AllZone.getStackZone().getCards() : this.getZone(zone) .getCards(false); return new CardList(cards); } @@ -1375,7 +1378,7 @@ public abstract class Player extends GameEntity { * the n * @return a CardList with all the cards currently in requested zone */ - public final CardList getCardsIn(final Constant.Zone zone, final int n) { + public final CardList getCardsIn(final ZoneType zone, final int n) { return new CardList(this.getZone(zone).getCards(n)); } @@ -1386,9 +1389,9 @@ public abstract class Player extends GameEntity { * the zones * @return a CardList with all the cards currently in requested zones */ - public final CardList getCardsIn(final List zones) { + public final CardList getCardsIn(final List zones) { final CardList result = new CardList(); - for (final Constant.Zone z : zones) { + for (final ZoneType z : zones) { if (this.getZone(z) != null) { result.addAll(this.getZone(z).getCards()); } @@ -1396,9 +1399,9 @@ public abstract class Player extends GameEntity { return result; } - public final CardList getCardsIn(final Constant.Zone[] zones) { + public final CardList getCardsIn(final ZoneType[] zones) { final CardList result = new CardList(); - for (final Constant.Zone z : zones) { + for (final ZoneType z : zones) { if (this.getZone(z) != null) { result.addAll(this.getZone(z).getCards()); } @@ -1415,7 +1418,7 @@ public abstract class Player extends GameEntity { * the card name * @return a CardList with all the cards currently in that player's library */ - public final CardList getCardsIn(final Constant.Zone zone, final String cardName) { + public final CardList getCardsIn(final ZoneType zone, final String cardName) { return this.getCardsIn(zone).getName(cardName); } @@ -1428,13 +1431,13 @@ public abstract class Player extends GameEntity { */ protected final CardList getDredge() { final CardList dredge = new CardList(); - final CardList cl = this.getCardsIn(Zone.Graveyard); + final CardList cl = this.getCardsIn(ZoneType.Graveyard); for (final Card c : cl) { final ArrayList kw = c.getKeyword(); for (int i = 0; i < kw.size(); i++) { if (kw.get(i).toString().startsWith("Dredge")) { - if (this.getCardsIn(Zone.Library).size() >= this.getDredgeNumber(c)) { + if (this.getCardsIn(ZoneType.Library).size() >= this.getDredgeNumber(c)) { dredge.add(c); } } @@ -1594,7 +1597,7 @@ public abstract class Player extends GameEntity { * @return the card list */ public final CardList discardHand(final SpellAbility sa) { - final CardList list = this.getCardsIn(Zone.Hand); + final CardList list = this.getCardsIn(ZoneType.Hand); this.discardRandom(list.size(), sa); return list; } @@ -1643,7 +1646,7 @@ public abstract class Player extends GameEntity { public final CardList discardRandom(final int num, final SpellAbility sa, final String valid) { final CardList discarded = new CardList(); for (int i = 0; i < num; i++) { - CardList list = this.getCardsIn(Zone.Hand); + CardList list = this.getCardsIn(ZoneType.Hand); list = list.getValidCards(valid, sa.getSourceCard().getController(), sa.getSourceCard()); if (list.size() != 0) { final Card disc = CardUtil.getRandom(list.toArray()); @@ -1678,7 +1681,7 @@ public abstract class Player extends GameEntity { * @return the card list */ public final CardList mill(final int n) { - return this.mill(n, Constant.Zone.Graveyard, false); + return this.mill(n, ZoneType.Graveyard, false); } /** @@ -1694,13 +1697,13 @@ public abstract class Player extends GameEntity { * a boolean. * @return the card list */ - public final CardList mill(final int n, final Constant.Zone zone, final boolean bottom) { - final CardList lib = this.getCardsIn(Zone.Library); + 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(); final int max = Math.min(n, lib.size()); - final Zone destination = this.getZone(zone).getZoneType(); + final ZoneType destination = this.getZone(zone).getZoneType(); for (int i = 0; i < max; i++) { if (bottom) { @@ -1732,8 +1735,8 @@ public abstract class Player extends GameEntity { *

*/ public final void shuffle() { - final PlayerZone library = this.getZone(Constant.Zone.Library); - final Card[] c = this.getCardsIn(Zone.Library).toArray(); + final PlayerZone library = this.getZone(ZoneType.Library); + final Card[] c = this.getCardsIn(ZoneType.Library).toArray(); if (c.length <= 1) { return; @@ -1795,7 +1798,7 @@ public abstract class Player extends GameEntity { */ public final void scry(int numScry) { final CardList topN = new CardList(); - final PlayerZone library = this.getZone(Constant.Zone.Library); + final PlayerZone library = this.getZone(ZoneType.Library); numScry = Math.min(numScry, library.size()); for (int i = 0; i < numScry; i++) { topN.add(library.get(i)); @@ -1816,7 +1819,7 @@ public abstract class Player extends GameEntity { public final void playLand(final Card land) { if (this.canPlayLand()) { land.addController(this); - Singletons.getModel().getGameAction().moveTo(this.getZone(Constant.Zone.Battlefield), land); + Singletons.getModel().getGameAction().moveTo(this.getZone(ZoneType.Battlefield), land); CardFactoryUtil.playLandEffects(land); this.numLandsPlayed++; @@ -1850,7 +1853,7 @@ public abstract class Player extends GameEntity { } // CantBeCast static abilities - final CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card ca : allp) { final ArrayList staticAbilities = ca.getStaticAbilities(); for (final StaticAbility stAb : staticAbilities) { @@ -1861,7 +1864,7 @@ public abstract class Player extends GameEntity { } return PhaseHandler.canCastSorcery(this) - && ((this.numLandsPlayed < this.maxLandsToPlay) || (this.getCardsIn(Zone.Battlefield, "Fastbond") + && ((this.numLandsPlayed < this.maxLandsToPlay) || (this.getCardsIn(ZoneType.Battlefield, "Fastbond") .size() > 0)); } @@ -1898,7 +1901,7 @@ public abstract class Player extends GameEntity { * @return a {@link forge.Card} object. */ public final Card getPlaneswalker() { - final CardList c = this.getCardsIn(Zone.Battlefield).getType("Planeswalker"); + final CardList c = this.getCardsIn(ZoneType.Battlefield).getType("Planeswalker"); if ((null != c) && (c.size() > 0)) { return c.get(0); } else { @@ -2214,14 +2217,14 @@ public abstract class Player extends GameEntity { return false; } - CardList list = this.getCardsIn(Zone.Battlefield); + CardList list = this.getCardsIn(ZoneType.Battlefield); list = list.getKeyword("You can't lose the game."); if (list.size() > 0) { return true; } - CardList oppList = this.getOpponent().getCardsIn(Zone.Battlefield); + CardList oppList = this.getOpponent().getCardsIn(ZoneType.Battlefield); oppList = oppList.getKeyword("Your opponents can't lose the game."); return oppList.size() > 0; @@ -2235,7 +2238,7 @@ public abstract class Player extends GameEntity { * @return a boolean. */ public final boolean cantLoseForZeroOrLessLife() { - CardList list = this.getCardsIn(Zone.Battlefield); + CardList list = this.getCardsIn(ZoneType.Battlefield); list = list.getKeyword("You don't lose the game for having 0 or less life."); return list.size() > 0; @@ -2249,14 +2252,14 @@ public abstract class Player extends GameEntity { * @return a boolean. */ public final boolean cantWin() { - CardList list = this.getCardsIn(Zone.Battlefield); + CardList list = this.getCardsIn(ZoneType.Battlefield); list = list.getKeyword("You can't win the game."); if (list.size() > 0) { return true; } - CardList oppList = this.getOpponent().getCardsIn(Zone.Battlefield); + CardList oppList = this.getOpponent().getCardsIn(ZoneType.Battlefield); oppList = oppList.getKeyword("Your opponents can't win the game."); return oppList.size() > 0; @@ -2318,7 +2321,7 @@ public abstract class Player extends GameEntity { * @return a boolean. */ public final boolean hasMetalcraft() { - final CardList list = this.getCardsIn(Zone.Battlefield).getType("Artifact"); + final CardList list = this.getCardsIn(ZoneType.Battlefield).getType("Artifact"); return list.size() >= 3; } @@ -2330,7 +2333,7 @@ public abstract class Player extends GameEntity { * @return a boolean. */ public final boolean hasThreshold() { - return this.getZone(Zone.Graveyard).getCards().size() >= 7; + return this.getZone(ZoneType.Graveyard).getCards().size() >= 7; } /** @@ -2341,7 +2344,7 @@ public abstract class Player extends GameEntity { * @return a boolean. */ public final boolean hasHellbent() { - return this.getZone(Zone.Hand).getCards().isEmpty(); + return this.getZone(ZoneType.Hand).getCards().isEmpty(); } /** @@ -2352,7 +2355,7 @@ public abstract class Player extends GameEntity { * @return a boolean. */ public final boolean hasLandfall() { - final CardList list = ((DefaultPlayerZone) this.getZone(Zone.Battlefield)).getCardsAddedThisTurn(null).getType( + final CardList list = ((DefaultPlayerZone) this.getZone(ZoneType.Battlefield)).getCardsAddedThisTurn(null).getType( "Land"); return !list.isEmpty(); } @@ -2675,7 +2678,7 @@ public abstract class Player extends GameEntity { */ final Player player = source.getController(); final Player opponent = player.getOpponent(); - final Constant.Zone lib = Constant.Zone.Library; + final ZoneType lib = ZoneType.Library; final PlayerZone pLib = player.getZone(lib); final PlayerZone oLib = opponent.getZone(lib); @@ -2759,7 +2762,7 @@ public abstract class Player extends GameEntity { * Update label observers. */ public final void updateLabelObservers() { - this.getZone(Zone.Hand).updateObservers(); + this.getZone(ZoneType.Hand).updateObservers(); } // ////////////////////////////// diff --git a/src/main/java/forge/game/player/PlayerUtil.java b/src/main/java/forge/game/player/PlayerUtil.java index 1e9318ceee5..0ded70beeac 100644 --- a/src/main/java/forge/game/player/PlayerUtil.java +++ b/src/main/java/forge/game/player/PlayerUtil.java @@ -21,11 +21,11 @@ import forge.AllZone; import forge.Card; import forge.CardList; import forge.CardListFilter; -import forge.Constant; import forge.Singletons; -import forge.Constant.Zone; import forge.card.spellability.SpellAbility; import forge.control.input.Input; +import forge.game.zone.PlayerZone; +import forge.game.zone.ZoneType; import forge.view.ButtonUtil; /** @@ -53,7 +53,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(Zone.Battlefield); + CardList list = player.getCardsIn(ZoneType.Battlefield); list = list.getKeyword("Damage that would reduce your life total to less than 1 reduces it to 1 instead."); list = list.filter(new CardListFilter() { @Override @@ -88,7 +88,7 @@ public final class PlayerUtil { @Override public void showMessage() { - if (AllZone.getHumanPlayer().getZone(Zone.Hand).size() == 0) { + if (AllZone.getHumanPlayer().getZone(ZoneType.Hand).size() == 0) { this.stop(); } Singletons.getControl().getControlMatch().showMessage( @@ -103,14 +103,14 @@ public final class PlayerUtil { @Override public void selectCard(final Card card, final PlayerZone zone) { - if (zone.is(Constant.Zone.Hand)) { + if (zone.is(ZoneType.Hand)) { card.getController().discard(card, sp); this.n++; if (card.isType(uType.toString())) { this.stop(); } else { - if ((this.n == nCards) || (AllZone.getHumanPlayer().getZone(Zone.Hand).size() == 0)) { + if ((this.n == nCards) || (AllZone.getHumanPlayer().getZone(ZoneType.Hand).size() == 0)) { this.stop(); } else { this.showMessage(); @@ -144,7 +144,7 @@ public final class PlayerUtil { @Override public void showMessage() { - if (AllZone.getHumanPlayer().getZone(Zone.Hand).size() == 0) { + if (AllZone.getHumanPlayer().getZone(ZoneType.Hand).size() == 0) { this.stop(); } if (nCards == 0) { @@ -157,12 +157,12 @@ public final class PlayerUtil { @Override public void selectCard(final Card card, final PlayerZone zone) { - if (zone.is(Constant.Zone.Hand)) { + if (zone.is(ZoneType.Hand)) { card.getController().discard(card, sp); this.n++; // in case no more cards in hand - if ((this.n == nCards) || (AllZone.getHumanPlayer().getZone(Zone.Hand).size() == 0)) { + if ((this.n == nCards) || (AllZone.getHumanPlayer().getZone(ZoneType.Hand).size() == 0)) { this.stop(); } else { this.showMessage(); @@ -186,7 +186,7 @@ public final class PlayerUtil { @Override public void showMessage() { - if (AllZone.getHumanPlayer().getZone(Zone.Hand).size() == 0) { + if (AllZone.getHumanPlayer().getZone(ZoneType.Hand).size() == 0) { this.stop(); } @@ -196,7 +196,7 @@ public final class PlayerUtil { @Override public void selectCard(final Card card, final PlayerZone zone) { - if (zone.is(Constant.Zone.Hand)) { + if (zone.is(ZoneType.Hand)) { card.getController().discard(card, null); this.done(); } @@ -238,7 +238,7 @@ public final class PlayerUtil { * @since 1.0.15 */ public static Input inputSacrificePermanents(final int nCards) { - final CardList list = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); + final CardList list = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); return PlayerUtil.inputSacrificePermanentsFromList(nCards, list, "Select a permanent to sacrifice"); } // input_sacrificePermanents() @@ -255,7 +255,7 @@ public final class PlayerUtil { * @since 1.0.15 */ public static Input inputSacrificePermanents(final int nCards, final String type) { - CardList list = AllZone.getHumanPlayer().getCardsIn(Zone.Battlefield); + CardList list = AllZone.getHumanPlayer().getCardsIn(ZoneType.Battlefield); list = list.getType(type); return PlayerUtil.inputSacrificePermanentsFromList(nCards, list, "Select a " + type + " to sacrifice"); @@ -294,7 +294,7 @@ public final class PlayerUtil { @Override public void selectCard(final Card card, final PlayerZone zone) { - if (zone.equals(AllZone.getHumanPlayer().getZone(Zone.Battlefield)) && list.contains(card)) { + if (zone.equals(AllZone.getHumanPlayer().getZone(ZoneType.Battlefield)) && list.contains(card)) { Singletons.getModel().getGameAction().sacrifice(card); this.n++; list.remove(card); @@ -334,7 +334,7 @@ public final class PlayerUtil { Singletons.getControl().getControlMatch().showMessage("Select a card to put on the " + topOrBottom + " of your library."); ButtonUtil.disableAll(); - if ((this.n == num) || (AllZone.getHumanPlayer().getZone(Zone.Hand).size() == 0)) { + if ((this.n == num) || (AllZone.getHumanPlayer().getZone(ZoneType.Hand).size() == 0)) { this.stop(); } } @@ -346,7 +346,7 @@ public final class PlayerUtil { @Override public void selectCard(final Card card, final PlayerZone zone) { - if (zone.is(Constant.Zone.Hand)) { + if (zone.is(ZoneType.Hand)) { int position = 0; if (topOrBottom.equalsIgnoreCase("bottom")) { position = -1; diff --git a/src/main/java/forge/game/player/DefaultPlayerZone.java b/src/main/java/forge/game/zone/DefaultPlayerZone.java similarity index 90% rename from src/main/java/forge/game/player/DefaultPlayerZone.java rename to src/main/java/forge/game/zone/DefaultPlayerZone.java index e82485f1213..148e0e98f84 100644 --- a/src/main/java/forge/game/player/DefaultPlayerZone.java +++ b/src/main/java/forge/game/zone/DefaultPlayerZone.java @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package forge.game.player; +package forge.game.zone; import java.util.ArrayList; import java.util.List; @@ -24,10 +24,9 @@ import java.util.Observable; import forge.AllZone; import forge.Card; import forge.CardList; -import forge.Constant; import forge.Singletons; -import forge.Constant.Zone; import forge.card.trigger.TriggerType; +import forge.game.player.Player; /** *

@@ -43,12 +42,12 @@ public class DefaultPlayerZone extends PlayerZone implements java.io.Serializabl /** The cards. */ private List cardList = new ArrayList(); - private final Constant.Zone zoneName; + private final ZoneType zoneName; private final Player player; private boolean update = true; private final CardList cardsAddedThisTurn = new CardList(); - private final ArrayList cardsAddedThisTurnSource = new ArrayList(); + private final ArrayList cardsAddedThisTurnSource = new ArrayList(); /** *

@@ -60,7 +59,7 @@ public class DefaultPlayerZone extends PlayerZone implements java.io.Serializabl * @param inPlayer * a {@link forge.game.player.Player} object. */ - public DefaultPlayerZone(final Constant.Zone zone, final Player inPlayer) { + public DefaultPlayerZone(final ZoneType zone, final Player inPlayer) { this.zoneName = zone; this.player = inPlayer; } @@ -89,17 +88,17 @@ public class DefaultPlayerZone extends PlayerZone implements java.io.Serializabl } } - if (this.is(Zone.Graveyard) + if (this.is(ZoneType.Graveyard) && c.hasKeyword("If CARDNAME would be put into a graveyard " + "from anywhere, reveal CARDNAME and shuffle it into its owner's library instead.")) { - final PlayerZone lib = c.getOwner().getZone(Constant.Zone.Library); + final PlayerZone lib = c.getOwner().getZone(ZoneType.Library); lib.add(c); c.getOwner().shuffle(); return; } - if (c.isUnearthed() && (this.is(Zone.Graveyard) || this.is(Zone.Hand) || this.is(Zone.Library))) { - final PlayerZone removed = c.getOwner().getZone(Constant.Zone.Exile); + if (c.isUnearthed() && (this.is(ZoneType.Graveyard) || this.is(ZoneType.Hand) || this.is(ZoneType.Library))) { + final PlayerZone removed = c.getOwner().getZone(ZoneType.Exile); removed.add(c); c.setUnearthed(false); return; @@ -109,7 +108,7 @@ public class DefaultPlayerZone extends PlayerZone implements java.io.Serializabl c.setTurnInZone(Singletons.getModel().getGameState().getPhaseHandler().getTurn()); - if (!this.is(Zone.Battlefield) && c.isTapped()) { + if (!this.is(ZoneType.Battlefield) && c.isTapped()) { AllZone.getTriggerHandler().suppressMode(TriggerType.Untaps); c.untap(); AllZone.getTriggerHandler().clearSuppression(TriggerType.Untaps); @@ -154,7 +153,7 @@ public class DefaultPlayerZone extends PlayerZone implements java.io.Serializabl } } - if (!this.is(Zone.Battlefield) && c.isTapped()) { + if (!this.is(ZoneType.Battlefield) && c.isTapped()) { AllZone.getTriggerHandler().suppressMode(TriggerType.Untaps); c.untap(); AllZone.getTriggerHandler().clearSuppression(TriggerType.Untaps); @@ -236,7 +235,7 @@ public class DefaultPlayerZone extends PlayerZone implements java.io.Serializabl * @return a boolean */ @Override - public final boolean is(final Constant.Zone zone) { + public final boolean is(final ZoneType zone) { return zone.equals(this.zoneName); } @@ -246,7 +245,7 @@ public class DefaultPlayerZone extends PlayerZone implements java.io.Serializabl * @see forge.IPlayerZone#is(java.util.List) */ @Override - public final boolean is(final List zones) { + public final boolean is(final List zones) { return zones.contains(this.zoneName); } @@ -260,7 +259,7 @@ public class DefaultPlayerZone extends PlayerZone implements java.io.Serializabl * @return a boolean */ @Override - public final boolean is(final Constant.Zone zone, final Player player) { + public final boolean is(final ZoneType zone, final Player player) { return (zone.equals(this.zoneName) && this.player.isPlayer(player)); } @@ -284,7 +283,7 @@ public class DefaultPlayerZone extends PlayerZone implements java.io.Serializabl * @return a {@link java.lang.String} object. */ @Override - public final Constant.Zone getZoneType() { + public final ZoneType getZoneType() { return this.zoneName; } @@ -410,7 +409,7 @@ 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 Constant.Zone origin) { + public final CardList getCardsAddedThisTurn(final ZoneType origin) { //System.out.print("Request cards put into " + this.getZoneType() + " from " + origin + ".Amount: "); final CardList ret = new CardList(); for (int i = 0; i < this.cardsAddedThisTurn.size(); i++) { diff --git a/src/main/java/forge/game/player/IPlayerZone.java b/src/main/java/forge/game/zone/IPlayerZone.java similarity index 94% rename from src/main/java/forge/game/player/IPlayerZone.java rename to src/main/java/forge/game/zone/IPlayerZone.java index 5a713e39033..5ee3f0de8cf 100644 --- a/src/main/java/forge/game/player/IPlayerZone.java +++ b/src/main/java/forge/game/zone/IPlayerZone.java @@ -15,12 +15,12 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package forge.game.player; +package forge.game.zone; import java.util.List; import forge.Card; -import forge.Constant; +import forge.game.player.Player; /** *

@@ -172,7 +172,7 @@ interface IPlayerZone { * a {@link java.lang.String} object. * @return a boolean. */ - boolean is(Constant.Zone zone); + boolean is(ZoneType zone); /** * Checks if is. @@ -181,7 +181,7 @@ interface IPlayerZone { * the zones * @return true, if successful */ - boolean is(List zones); + boolean is(List zones); /** *

@@ -194,7 +194,7 @@ interface IPlayerZone { * a {@link forge.game.player.Player} object. * @return a boolean. */ - boolean is(Constant.Zone zone, Player player); + boolean is(ZoneType zone, Player player); /** *

@@ -212,7 +212,7 @@ interface IPlayerZone { * * @return a {@link java.lang.String} object. */ - Constant.Zone getZoneType(); // returns the Zone's name like Graveyard + ZoneType getZoneType(); // returns the Zone's name like Graveyard /** *

diff --git a/src/main/java/forge/MagicStack.java b/src/main/java/forge/game/zone/MagicStack.java similarity index 98% rename from src/main/java/forge/MagicStack.java rename to src/main/java/forge/game/zone/MagicStack.java index b154d395bc0..a1856757738 100644 --- a/src/main/java/forge/MagicStack.java +++ b/src/main/java/forge/game/zone/MagicStack.java @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package forge; +package forge.game.zone; import java.util.ArrayList; import java.util.HashMap; @@ -24,7 +24,15 @@ import java.util.Stack; import com.esotericsoftware.minlog.Log; -import forge.Constant.Zone; +import forge.AllZone; +import forge.AllZoneUtil; +import forge.Card; +import forge.CardList; +import forge.CardListFilter; +import forge.Command; +import forge.GameActionUtil; +import forge.MyObservable; +import forge.Singletons; import forge.card.abilityfactory.AbilityFactory; import forge.card.cardfactory.CardFactoryUtil; import forge.card.mana.ManaCost; @@ -47,7 +55,6 @@ import forge.control.input.InputPayManaCostAbility; import forge.game.phase.PhaseType; import forge.game.player.ComputerUtil; import forge.game.player.Player; -import forge.game.player.PlayerZone; import forge.gui.GuiDisplayUtil; import forge.gui.GuiUtils; import forge.view.ButtonUtil; @@ -188,7 +195,7 @@ public class MagicStack extends MyObservable { // on the stack zone, move there if (ability.isSpell()) { final Card source = ability.getSourceCard(); - if (!source.isCopiedSpell() && !source.isInZone(Constant.Zone.Stack)) { + if (!source.isCopiedSpell() && !source.isInZone(ZoneType.Stack)) { ability.setSourceCard(Singletons.getModel().getGameAction().moveToStack(source)); } } @@ -765,7 +772,7 @@ public class MagicStack extends MyObservable { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (zone.is(Constant.Zone.Battlefield) && c.getController().isHuman() && c.isLand()) { + if (zone.is(ZoneType.Battlefield) && c.getController().isHuman() && c.isLand()) { Singletons.getModel().getGameAction().sacrifice(c); this.stop(); } @@ -802,9 +809,9 @@ public class MagicStack extends MyObservable { */ if (sp.isSpell() && AllZoneUtil.isCardInPlay("Bazaar of Wonders")) { boolean found = false; - CardList all = AllZoneUtil.getCardsIn(Zone.Battlefield); + CardList all = AllZoneUtil.getCardsIn(ZoneType.Battlefield); all = all.filter(CardListFilter.NON_TOKEN); - final CardList graves = AllZoneUtil.getCardsIn(Zone.Graveyard); + final CardList graves = AllZoneUtil.getCardsIn(ZoneType.Graveyard); all.addAll(graves); for (final Card c : all) { @@ -814,7 +821,7 @@ public class MagicStack extends MyObservable { } if (found) { - final CardList bazaars = AllZoneUtil.getCardsIn(Zone.Battlefield, "Bazaar of Wonders"); // should + final CardList bazaars = AllZoneUtil.getCardsIn(ZoneType.Battlefield, "Bazaar of Wonders"); // should // only // be // 1... @@ -921,7 +928,7 @@ public class MagicStack extends MyObservable { } if (source.hasStartOfKeyword("Haunt") && !source.isCreature() - && AllZone.getZoneOf(source).is(Constant.Zone.Graveyard)) { + && AllZone.getZoneOf(source).is(ZoneType.Graveyard)) { final CardList creats = AllZoneUtil.getCreaturesInPlay(); final Ability haunterDiesWork = new Ability(source, "0") { @Override @@ -950,7 +957,7 @@ public class MagicStack extends MyObservable { @Override public void selectCard(final Card c, final PlayerZone zone) { - if (!zone.is(Constant.Zone.Battlefield) || !c.isCreature()) { + if (!zone.is(ZoneType.Battlefield) || !c.isCreature()) { return; } if (c.canBeTargetedBy(haunterDiesWork)) { @@ -1003,8 +1010,8 @@ public class MagicStack extends MyObservable { Singletons.getModel().getGameAction().exile(source); sa.setFlashBackAbility(false); } else if (source.hasKeyword("Rebound") - && source.getCastFrom() == Zone.Hand - && AllZone.getZoneOf(source).is(Zone.Stack) + && source.getCastFrom() == ZoneType.Hand + && AllZone.getZoneOf(source).is(ZoneType.Stack) && source.getOwner().isPlayer(source.getController())) //This may look odd, but it's a provision for when we add Commandeer { @@ -1073,7 +1080,7 @@ public class MagicStack extends MyObservable { // If Spell and still on the Stack then let it goto the graveyard or // replace its own movement else if (!source.isCopiedSpell() && (source.isInstant() || source.isSorcery() || fizzle) - && source.isInZone(Constant.Zone.Stack)) { + && source.isInZone(ZoneType.Stack)) { Singletons.getModel().getGameAction().moveToGraveyard(source); } } @@ -1113,7 +1120,7 @@ public class MagicStack extends MyObservable { // verified by System.identityHashCode(card); final Card tmp = sa.getSourceCard(); if (tmp.getClones().size() > 0) { - for (final Card c : AllZoneUtil.getCardsIn(Zone.Battlefield)) { + for (final Card c : AllZoneUtil.getCardsIn(ZoneType.Battlefield)) { if (c.equals(tmp)) { c.setClones(tmp.getClones()); } diff --git a/src/main/java/forge/game/player/PlayerZone.java b/src/main/java/forge/game/zone/PlayerZone.java similarity index 97% rename from src/main/java/forge/game/player/PlayerZone.java rename to src/main/java/forge/game/zone/PlayerZone.java index 34cc7c485b6..042a952cced 100644 --- a/src/main/java/forge/game/player/PlayerZone.java +++ b/src/main/java/forge/game/zone/PlayerZone.java @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package forge.game.player; +package forge.game.zone; import java.util.Observer; diff --git a/src/main/java/forge/game/player/PlayerZoneComesIntoPlay.java b/src/main/java/forge/game/zone/PlayerZoneComesIntoPlay.java similarity index 96% rename from src/main/java/forge/game/player/PlayerZoneComesIntoPlay.java rename to src/main/java/forge/game/zone/PlayerZoneComesIntoPlay.java index 8382877c3b0..3ab7c0ecd27 100644 --- a/src/main/java/forge/game/player/PlayerZoneComesIntoPlay.java +++ b/src/main/java/forge/game/zone/PlayerZoneComesIntoPlay.java @@ -15,7 +15,7 @@ * You should have received a copy of the GNU General Public License * along with this program. If not, see . */ -package forge.game.player; +package forge.game.zone; import java.util.ArrayList; import java.util.List; @@ -26,14 +26,13 @@ import forge.Card; import forge.CardList; import forge.CardListFilter; import forge.Command; -import forge.Constant; import forge.Counters; import forge.GameActionUtil; -import forge.Constant.Zone; import forge.card.cardfactory.CardFactoryUtil; import forge.card.spellability.Ability; import forge.card.spellability.SpellAbility; import forge.card.staticability.StaticAbility; +import forge.game.player.Player; /** *

@@ -60,7 +59,7 @@ public class PlayerZoneComesIntoPlay extends DefaultPlayerZone { * @param player * a {@link forge.game.player.Player} object. */ - public PlayerZoneComesIntoPlay(final Constant.Zone zone, final Player player) { + public PlayerZoneComesIntoPlay(final ZoneType zone, final Player player) { super(zone, player); } @@ -83,7 +82,7 @@ public class PlayerZoneComesIntoPlay extends DefaultPlayerZone { c.setTapped(true); } else { // ETBTapped static abilities - final CardList allp = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList allp = AllZoneUtil.getCardsIn(ZoneType.Battlefield); for (final Card ca : allp) { final ArrayList staticAbilities = ca.getStaticAbilities(); for (final StaticAbility stAb : staticAbilities) { @@ -150,7 +149,7 @@ public class PlayerZoneComesIntoPlay extends DefaultPlayerZone { } if (c.isLand()) { - CardList list = player.getCardsIn(Zone.Battlefield); + CardList list = player.getCardsIn(ZoneType.Battlefield); list = list.filter(new CardListFilter() { @Override @@ -164,14 +163,14 @@ public class PlayerZoneComesIntoPlay extends DefaultPlayerZone { } // Tectonic Instability - final CardList tis = AllZoneUtil.getCardsIn(Zone.Battlefield, "Tectonic Instability"); + final CardList 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(Zone.Battlefield); + CardList lands = tisLand.getController().getCardsIn(ZoneType.Battlefield); lands = lands.filter(CardListFilter.LANDS); for (final Card land : lands) { land.tap(); @@ -186,7 +185,7 @@ public class PlayerZoneComesIntoPlay extends DefaultPlayerZone { } - final CardList les = c.getOwner().getOpponent().getCardsIn(Zone.Battlefield, "Land Equilibrium"); + final CardList les = c.getOwner().getOpponent().getCardsIn(ZoneType.Battlefield, "Land Equilibrium"); final Card lesLand = c; if (les.size() > 0) { final Card source = les.get(0); diff --git a/src/main/java/forge/game/zone/ZoneType.java b/src/main/java/forge/game/zone/ZoneType.java new file mode 100644 index 00000000000..5438897445b --- /dev/null +++ b/src/main/java/forge/game/zone/ZoneType.java @@ -0,0 +1,75 @@ +package forge.game.zone; + +import java.util.ArrayList; +import java.util.List; + +/** + * The Enum Zone. + */ +public enum ZoneType { + + /** The Hand. */ + Hand(true), + + /** The Library. */ + Library(true), + + /** The Graveyard. */ + Graveyard(false), + + /** The Battlefield. */ + Battlefield(false), + + /** The Exile. */ + Exile(false), + + /** The Command. */ + Command(false), + + /** The Stack. */ + Stack(false), + + Sideboard(true), + /** Ante. */ + Ante(false); + + public static final ZoneType[] StaticAbilitiesSourceZones = new ZoneType[]{Battlefield, Graveyard, Exile/*, Hand*/}; + + private final boolean holdsHiddenInfo; + private ZoneType(boolean holdsHidden) { + holdsHiddenInfo = holdsHidden; + } + + + public static ZoneType smartValueOf(final String value) { + if (value == null) { + return null; + } + if ("All".equals(value)) { + return null; + } + final String valToCompate = value.trim(); + for (final ZoneType v : ZoneType.values()) { + if (v.name().compareToIgnoreCase(valToCompate) == 0) { + return v; + } + } + throw new IllegalArgumentException("No element named " + value + " in enum Zone"); + } + + public static List listValueOf(final String values) { + final List result = new ArrayList(); + for (final String s : values.split("[, ]+")) { + result.add(ZoneType.smartValueOf(s)); + } + return result; + } + + public boolean isHidden() { + return holdsHiddenInfo; + } + + public boolean isKnown() { + return !holdsHiddenInfo; + } +} \ No newline at end of file diff --git a/src/main/java/forge/gui/CardDetailPanel.java b/src/main/java/forge/gui/CardDetailPanel.java index 4faba6797d9..3bf40f32d60 100644 --- a/src/main/java/forge/gui/CardDetailPanel.java +++ b/src/main/java/forge/gui/CardDetailPanel.java @@ -35,10 +35,9 @@ import javax.swing.border.EtchedBorder; import forge.AllZone; import forge.Card; -import forge.Constant; -import forge.Constant.Zone; import forge.Counters; import forge.GameEntity; +import forge.game.zone.ZoneType; /** * The class CardDetailPanel. Shows the details of a card. @@ -297,16 +296,16 @@ public class CardDetailPanel extends JPanel implements CardContainer { if ((card.hasKeyword("Play with the top card of your library revealed.") || card .hasKeyword("Players play with the top card of their libraries revealed.")) && (card.getController() != null) - && card.isInZone(Constant.Zone.Battlefield) - && !card.getController().getZone(Zone.Library).isEmpty()) { + && card.isInZone(ZoneType.Battlefield) + && !card.getController().getZone(ZoneType.Library).isEmpty()) { area.append("\r\nTop card of your library: "); - area.append(card.getController().getCardsIn(Zone.Library, 1)); + area.append(card.getController().getCardsIn(ZoneType.Library, 1)); } if (card.hasKeyword("Players play with the top card of their libraries revealed.") - && (card.getController() != null) && card.isInZone(Constant.Zone.Battlefield) - && !card.getController().getOpponent().getZone(Zone.Library).isEmpty()) { + && (card.getController() != null) && card.isInZone(ZoneType.Battlefield) + && !card.getController().getOpponent().getZone(ZoneType.Library).isEmpty()) { area.append("\r\nTop card of your opponent's library: "); - area.append(card.getController().getOpponent().getCardsIn(Zone.Library, 1)); + area.append(card.getController().getOpponent().getCardsIn(ZoneType.Library, 1)); } // chosen type diff --git a/src/main/java/forge/gui/GuiDisplayUtil.java b/src/main/java/forge/gui/GuiDisplayUtil.java index d6e9a968866..78a2f97f10a 100644 --- a/src/main/java/forge/gui/GuiDisplayUtil.java +++ b/src/main/java/forge/gui/GuiDisplayUtil.java @@ -41,10 +41,10 @@ import forge.CardUtil; import forge.Constant; import forge.Counters; import forge.Singletons; -import forge.Constant.Zone; import forge.card.spellability.AbilityMana; import forge.card.trigger.TriggerType; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.item.CardDb; import forge.item.CardPrinted; import forge.view.arcane.PlayArea; @@ -325,8 +325,8 @@ public final class GuiDisplayUtil { *

*/ public static void updateGUI() { - AllZone.getComputerPlayer().getZone(Zone.Battlefield).updateObservers(); - AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); + AllZone.getComputerPlayer().getZone(ZoneType.Battlefield).updateObservers(); + AllZone.getHumanPlayer().getZone(ZoneType.Battlefield).updateObservers(); //AllZone.getHumanPlayer().getZone(Zone.Hand).updateObservers(); AllZone.getComputerPlayer().updateObservers(); AllZone.getHumanPlayer().updateObservers(); @@ -506,43 +506,43 @@ public final class GuiDisplayUtil { AllZone.getTriggerHandler().suppressMode(TriggerType.ChangesZone); AllZone.getCombat().reset(); for (final Card c : humanDevSetup) { - AllZone.getHumanPlayer().getZone(Zone.Hand).add(c); + AllZone.getHumanPlayer().getZone(ZoneType.Hand).add(c); Singletons.getModel().getGameAction().moveToPlay(c); c.setSickness(false); } for (final Card c : computerDevSetup) { - AllZone.getComputerPlayer().getZone(Zone.Hand).add(c); + AllZone.getComputerPlayer().getZone(ZoneType.Hand).add(c); Singletons.getModel().getGameAction().moveToPlay(c); c.setSickness(false); } if (computerDevGraveyardSetup.size() > 0) { - AllZone.getComputerPlayer().getZone(Zone.Graveyard).setCards(computerDevGraveyardSetup); + AllZone.getComputerPlayer().getZone(ZoneType.Graveyard).setCards(computerDevGraveyardSetup); } if (humanDevGraveyardSetup.size() > 0) { - AllZone.getHumanPlayer().getZone(Zone.Graveyard).setCards(humanDevGraveyardSetup); + AllZone.getHumanPlayer().getZone(ZoneType.Graveyard).setCards(humanDevGraveyardSetup); } if (computerDevHandSetup.size() > 0) { - AllZone.getComputerPlayer().getZone(Zone.Hand).setCards(computerDevHandSetup); + AllZone.getComputerPlayer().getZone(ZoneType.Hand).setCards(computerDevHandSetup); } if (humanDevHandSetup.size() > 0) { - AllZone.getHumanPlayer().getZone(Zone.Hand).setCards(humanDevHandSetup); + AllZone.getHumanPlayer().getZone(ZoneType.Hand).setCards(humanDevHandSetup); } if (humanDevLibrarySetup.size() > 0) { - AllZone.getHumanPlayer().getZone(Zone.Library).setCards(humanDevLibrarySetup); + AllZone.getHumanPlayer().getZone(ZoneType.Library).setCards(humanDevLibrarySetup); } if (computerDevLibrarySetup.size() > 0) { - AllZone.getComputerPlayer().getZone(Zone.Library).setCards(computerDevLibrarySetup); + AllZone.getComputerPlayer().getZone(ZoneType.Library).setCards(computerDevLibrarySetup); } if (humanDevExileSetup.size() > 0) { - AllZone.getHumanPlayer().getZone(Zone.Exile).setCards(humanDevExileSetup); + AllZone.getHumanPlayer().getZone(ZoneType.Exile).setCards(humanDevExileSetup); } if (computerDevExileSetup.size() > 0) { - AllZone.getComputerPlayer().getZone(Zone.Exile).setCards(computerDevExileSetup); + AllZone.getComputerPlayer().getZone(ZoneType.Exile).setCards(computerDevExileSetup); } AllZone.getTriggerHandler().clearSuppression(TriggerType.ChangesZone); @@ -556,16 +556,16 @@ public final class GuiDisplayUtil { Singletons.getModel().getGameAction().checkStateEffects(); Singletons.getModel().getGameState().getPhaseHandler().updateObservers(); - AllZone.getHumanPlayer().getZone(Zone.Exile).updateObservers(); - AllZone.getComputerPlayer().getZone(Zone.Exile).updateObservers(); - AllZone.getHumanPlayer().getZone(Zone.Hand).updateObservers(); - AllZone.getComputerPlayer().getZone(Zone.Hand).updateObservers(); - AllZone.getHumanPlayer().getZone(Zone.Graveyard).updateObservers(); - AllZone.getComputerPlayer().getZone(Zone.Graveyard).updateObservers(); - AllZone.getHumanPlayer().getZone(Zone.Battlefield).updateObservers(); - AllZone.getComputerPlayer().getZone(Zone.Battlefield).updateObservers(); - AllZone.getHumanPlayer().getZone(Zone.Library).updateObservers(); - AllZone.getComputerPlayer().getZone(Zone.Library).updateObservers(); + AllZone.getHumanPlayer().getZone(ZoneType.Exile).updateObservers(); + AllZone.getComputerPlayer().getZone(ZoneType.Exile).updateObservers(); + AllZone.getHumanPlayer().getZone(ZoneType.Hand).updateObservers(); + AllZone.getComputerPlayer().getZone(ZoneType.Hand).updateObservers(); + AllZone.getHumanPlayer().getZone(ZoneType.Graveyard).updateObservers(); + AllZone.getComputerPlayer().getZone(ZoneType.Graveyard).updateObservers(); + AllZone.getHumanPlayer().getZone(ZoneType.Battlefield).updateObservers(); + AllZone.getComputerPlayer().getZone(ZoneType.Battlefield).updateObservers(); + AllZone.getHumanPlayer().getZone(ZoneType.Library).updateObservers(); + AllZone.getComputerPlayer().getZone(ZoneType.Library).updateObservers(); } /** @@ -623,7 +623,7 @@ public final class GuiDisplayUtil { * @since 1.0.15 */ public static void devModeTutor() { - final CardList lib = AllZone.getHumanPlayer().getCardsIn(Zone.Library); + final CardList lib = AllZone.getHumanPlayer().getCardsIn(ZoneType.Library); final Object o = GuiUtils.chooseOneOrNone("Choose a card", lib.toArray()); if (null == o) { return; @@ -665,7 +665,7 @@ public final class GuiDisplayUtil { * @since 1.0.15 */ public static void devModeAddCounter() { - final CardList play = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList play = AllZoneUtil.getCardsIn(ZoneType.Battlefield); final Object o = GuiUtils.chooseOneOrNone("Add counters to which card?", play.toArray()); if (null == o) { return; @@ -697,7 +697,7 @@ public final class GuiDisplayUtil { * @since 1.0.15 */ public static void devModeTapPerm() { - final CardList play = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList play = AllZoneUtil.getCardsIn(ZoneType.Battlefield); final Object o = GuiUtils.chooseOneOrNone("Choose a permanent", play.toArray()); if (null == o) { return; @@ -715,7 +715,7 @@ public final class GuiDisplayUtil { * @since 1.0.15 */ public static void devModeUntapPerm() { - final CardList play = AllZoneUtil.getCardsIn(Zone.Battlefield); + final CardList play = AllZoneUtil.getCardsIn(ZoneType.Battlefield); final Object o = GuiUtils.chooseOneOrNone("Choose a permanent", play.toArray()); if (null == o) { return; diff --git a/src/main/java/forge/gui/GuiInput.java b/src/main/java/forge/gui/GuiInput.java index dbaf936e5c6..82020709aae 100644 --- a/src/main/java/forge/gui/GuiInput.java +++ b/src/main/java/forge/gui/GuiInput.java @@ -26,7 +26,7 @@ import forge.MyObservable; import forge.Singletons; import forge.control.input.Input; import forge.game.player.Player; -import forge.game.player.PlayerZone; +import forge.game.zone.PlayerZone; /** *

@@ -121,7 +121,7 @@ public class GuiInput extends MyObservable implements Observer { * @param card * a {@link forge.Card} object. * @param zone - * a {@link forge.game.player.PlayerZone} object. + * a {@link forge.game.zone.PlayerZone} object. */ public final void selectCard(final Card card, final PlayerZone zone) { this.getInput().selectCard(card, zone); diff --git a/src/main/java/forge/gui/MultiPhaseProgressMonitorWithETA.java b/src/main/java/forge/gui/MultiPhaseProgressMonitorWithETA.java index 204ae4460e9..3969406375e 100644 --- a/src/main/java/forge/gui/MultiPhaseProgressMonitorWithETA.java +++ b/src/main/java/forge/gui/MultiPhaseProgressMonitorWithETA.java @@ -25,7 +25,7 @@ import javax.swing.WindowConstants; import forge.util.ThreadUtil; -import net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor; +import net.slightlymagic.braids.BaseProgressMonitor; /** * GUI Progress Monitor that displays the ETA (Estimated Time of Arrival or @@ -173,7 +173,7 @@ public class MultiPhaseProgressMonitorWithETA extends BaseProgressMonitor { * * @param numUnits * cannot be higher than Integer.MAX_VALUE - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#setTotalUnitsThisPhase(long) + * @see net.slightlymagic.braids.BraidsProgressMonitor#setTotalUnitsThisPhase(long) */ @Override public final void setTotalUnitsThisPhase(final long numUnits) { @@ -224,7 +224,7 @@ public class MultiPhaseProgressMonitorWithETA extends BaseProgressMonitor { * * @param numUnits * the num units - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#incrementUnitsCompletedThisPhase(long) + * @see net.slightlymagic.braids.BraidsProgressMonitor#incrementUnitsCompletedThisPhase(long) */ @Override public final void incrementUnitsCompletedThisPhase(final long numUnits) { diff --git a/src/main/java/forge/view/match/QuestWinLoseHandler.java b/src/main/java/forge/view/match/QuestWinLoseHandler.java index 9f7ff58b75e..a269d89f007 100644 --- a/src/main/java/forge/view/match/QuestWinLoseHandler.java +++ b/src/main/java/forge/view/match/QuestWinLoseHandler.java @@ -19,7 +19,6 @@ package forge.view.match; import forge.AllZone; import forge.CardList; import forge.Constant; -import forge.Constant.Zone; import forge.Singletons; import forge.control.FControl; import forge.control.match.ControlWinLose; @@ -31,6 +30,7 @@ import forge.game.GameNew; import forge.game.GamePlayerRating; import forge.game.GameSummary; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.gui.GuiUtils; import forge.gui.ListChooser; import forge.gui.OverlayUtils; @@ -156,14 +156,14 @@ public class QuestWinLoseHandler extends ControlWinLose { //do per-game actions if (matchState.hasWonLastGame(AllZone.getHumanPlayer().getName())) { if (isAnte) { - final CardList antes = AllZone.getComputerPlayer().getCardsIn(Zone.Ante); + final CardList 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(Zone.Ante); + final CardList 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/view/match/ViewField.java b/src/main/java/forge/view/match/ViewField.java index 8cf70979e4c..1f235b150ea 100644 --- a/src/main/java/forge/view/match/ViewField.java +++ b/src/main/java/forge/view/match/ViewField.java @@ -35,12 +35,12 @@ import javax.swing.border.MatteBorder; import net.miginfocom.swing.MigLayout; import forge.AllZone; -import forge.Constant.Zone; import forge.Singletons; import forge.card.cardfactory.CardFactoryUtil; import forge.card.mana.ManaPool; import forge.control.match.ControlField; import forge.game.player.Player; +import forge.game.zone.ZoneType; import forge.gui.toolbox.FLabel; import forge.gui.toolbox.FPanel; import forge.gui.toolbox.FSkin; @@ -291,11 +291,11 @@ public class ViewField extends FPanel { *   Player obj */ public void updateZones(final Player p0) { - this.getLblHand().setText("" + p0.getZone(Zone.Hand).size()); - this.getLblGraveyard().setText("" + p0.getZone(Zone.Graveyard).size()); - this.getLblLibrary().setText("" + p0.getZone(Zone.Library).size()); + this.getLblHand().setText("" + p0.getZone(ZoneType.Hand).size()); + this.getLblGraveyard().setText("" + p0.getZone(ZoneType.Graveyard).size()); + this.getLblLibrary().setText("" + p0.getZone(ZoneType.Library).size()); this.getLblFlashback().setText("" + CardFactoryUtil.getExternalZoneActivationCards(p0).size()); - this.getLblExile().setText("" + p0.getZone(Zone.Exile).size()); + this.getLblExile().setText("" + p0.getZone(ZoneType.Exile).size()); } /** diff --git a/src/main/java/forge/view/match/ViewTabber.java b/src/main/java/forge/view/match/ViewTabber.java index ed77853f80e..47762b7e521 100644 --- a/src/main/java/forge/view/match/ViewTabber.java +++ b/src/main/java/forge/view/match/ViewTabber.java @@ -48,13 +48,13 @@ import net.miginfocom.swing.MigLayout; import forge.AllZone; import forge.CardList; import forge.CardUtil; -import forge.Constant.Zone; import forge.GameLog; -import forge.MagicStack; import forge.Singletons; import forge.card.spellability.SpellAbilityStackInstance; import forge.control.match.ControlTabber; import forge.game.player.Player; +import forge.game.zone.MagicStack; +import forge.game.zone.ZoneType; import forge.gui.ForgeAction; import forge.gui.MultiLineLabelUI; import forge.gui.toolbox.FSkin; @@ -414,7 +414,7 @@ public class ViewTabber extends JPanel { temp[5].setText(""); } if (Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE)) { - CardList list = p0.getCardsIn(Zone.Ante); + CardList 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/net/slightlymagic/braids/util/progress_monitor/BaseProgressMonitor.java b/src/main/java/net/slightlymagic/braids/BaseProgressMonitor.java similarity index 89% rename from src/main/java/net/slightlymagic/braids/util/progress_monitor/BaseProgressMonitor.java rename to src/main/java/net/slightlymagic/braids/BaseProgressMonitor.java index d1c408dc241..18395800c41 100644 --- a/src/main/java/net/slightlymagic/braids/util/progress_monitor/BaseProgressMonitor.java +++ b/src/main/java/net/slightlymagic/braids/BaseProgressMonitor.java @@ -18,7 +18,7 @@ * limitations under the Apache License. * */ -package net.slightlymagic.braids.util.progress_monitor; +package net.slightlymagic.braids; import java.util.Date; @@ -30,7 +30,7 @@ import com.esotericsoftware.minlog.Log; * * Absolute times are measured in seconds, in congruence with ProgressMonitor. * - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor + * @see net.slightlymagic.braids.BraidsProgressMonitor */ public class BaseProgressMonitor implements BraidsProgressMonitor { private int numPhases; @@ -167,7 +167,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor { * Gets the num phases. * * @return the num phases - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#getNumPhases() + * @see net.slightlymagic.braids.BraidsProgressMonitor#getNumPhases() */ public final int getNumPhases() { return this.numPhases; @@ -177,7 +177,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor { * Gets the min update interval sec. * * @return the min update interval sec - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#getMinUpdateIntervalSec() + * @see net.slightlymagic.braids.BraidsProgressMonitor#getMinUpdateIntervalSec() */ public final float getMinUpdateIntervalSec() { return this.minUIUpdateIntervalSec; @@ -187,7 +187,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor { * Gets the current phase. * * @return the current phase - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#getCurrentPhase() + * @see net.slightlymagic.braids.BraidsProgressMonitor#getCurrentPhase() */ public final int getCurrentPhase() { return this.currentPhase; @@ -197,7 +197,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor { * Gets the units completed so far this phase. * * @return the units completed so far this phase - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#getUnitsCompletedSoFarThisPhase() + * @see net.slightlymagic.braids.BraidsProgressMonitor#getUnitsCompletedSoFarThisPhase() */ public final long getUnitsCompletedSoFarThisPhase() { return this.unitsCompletedSoFarThisPhase; @@ -207,7 +207,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor { * Gets the total units this phase. * * @return the total units this phase - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#getTotalUnitsThisPhase() + * @see net.slightlymagic.braids.BraidsProgressMonitor#getTotalUnitsThisPhase() */ public final long getTotalUnitsThisPhase() { return this.totalUnitsThisPhase; @@ -217,7 +217,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor { * Gets the last ui update time. * * @return the last ui update time - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#getLastUIUpdateTime() + * @see net.slightlymagic.braids.BraidsProgressMonitor#getLastUIUpdateTime() */ public final long getLastUIUpdateTime() { return this.lastUIUpdateTime; @@ -227,7 +227,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor { * Gets the phase one start time. * * @return the phase one start time - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#getPhaseOneStartTime() + * @see net.slightlymagic.braids.BraidsProgressMonitor#getPhaseOneStartTime() */ public final long getPhaseOneStartTime() { return this.phaseOneStartTime; @@ -237,7 +237,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor { * Gets the current phase start time. * * @return the current phase start time - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#getCurrentPhaseStartTime() + * @see net.slightlymagic.braids.BraidsProgressMonitor#getCurrentPhaseStartTime() */ public final long getCurrentPhaseStartTime() { return this.currentPhaseStartTime; @@ -248,7 +248,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor { * * @param value * the new min update interval sec - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#setMinUpdateIntervalSec(float) + * @see net.slightlymagic.braids.BraidsProgressMonitor#setMinUpdateIntervalSec(float) */ public final void setMinUpdateIntervalSec(final float value) { this.minUIUpdateIntervalSec = value; @@ -259,7 +259,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor { * * @param value * the new total units this phase - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#setTotalUnitsThisPhase(long) + * @see net.slightlymagic.braids.BraidsProgressMonitor#setTotalUnitsThisPhase(long) */ public void setTotalUnitsThisPhase(final long value) { this.totalUnitsThisPhase = value; @@ -269,7 +269,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor { * Gets the percent complete of this phase as string. * * @return the percent complete of this phase as string - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#getPercentCompleteOfThisPhaseAsString() + * @see net.slightlymagic.braids.BraidsProgressMonitor#getPercentCompleteOfThisPhaseAsString() */ public final String getPercentCompleteOfThisPhaseAsString() { @@ -286,7 +286,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor { * Gets the total percent complete as string. * * @return the total percent complete as string - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#getTotalPercentCompleteAsString() + * @see net.slightlymagic.braids.BraidsProgressMonitor#getTotalPercentCompleteAsString() */ public final String getTotalPercentCompleteAsString() { Float percent = getTotalPercentCompleteAsFloat(); @@ -315,7 +315,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor { * @param thisPhaseOnly * the this phase only * @return the relative eta as string - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#getRelativeETAAsString(boolean) + * @see net.slightlymagic.braids.BraidsProgressMonitor#getRelativeETAAsString(boolean) */ public final String getRelativeETAAsString(final boolean thisPhaseOnly) { @@ -365,7 +365,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor { * @param thisPhaseOnly * the this phase only * @return the absolute eta as local time string - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#getAbsoluteETAAsLocalTimeString(boolean) + * @see net.slightlymagic.braids.BraidsProgressMonitor#getAbsoluteETAAsLocalTimeString(boolean) */ public final String getAbsoluteETAAsLocalTimeString(final boolean thisPhaseOnly) { Long etaTime = getAbsoluteETATime(thisPhaseOnly); @@ -382,7 +382,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor { * * @param numUnits * the num units - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#incrementUnitsCompletedThisPhase(long) + * @see net.slightlymagic.braids.BraidsProgressMonitor#incrementUnitsCompletedThisPhase(long) */ public void incrementUnitsCompletedThisPhase(final long numUnits) { this.unitsCompletedSoFarThisPhase += numUnits; @@ -400,7 +400,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor { * Should update ui. * * @return true, if successful - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#shouldUpdateUI() + * @see net.slightlymagic.braids.BraidsProgressMonitor#shouldUpdateUI() */ public final boolean shouldUpdateUI() { @@ -416,7 +416,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor { * * @param totalUnitsNextPhase * the total units next phase - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#markCurrentPhaseAsComplete(long) + * @see net.slightlymagic.braids.BraidsProgressMonitor#markCurrentPhaseAsComplete(long) */ public final void markCurrentPhaseAsComplete(final long totalUnitsNextPhase) { @@ -462,7 +462,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor { * * @param message * the message - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#sendMessage(java.lang.String) + * @see net.slightlymagic.braids.BraidsProgressMonitor#sendMessage(java.lang.String) */ public final void sendMessage(final String message) { } @@ -472,7 +472,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor { * * @param value * the new current phase as exponential - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#setCurrentPhaseAsExponential(float) + * @see net.slightlymagic.braids.BraidsProgressMonitor#setCurrentPhaseAsExponential(float) */ public final void setCurrentPhaseAsExponential(final float value) { this.currentPhaseExponent = value; @@ -482,7 +482,7 @@ public class BaseProgressMonitor implements BraidsProgressMonitor { * Gets the current phase exponent. * * @return the current phase exponent - * @see net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor#getCurrentPhaseExponent() + * @see net.slightlymagic.braids.BraidsProgressMonitor#getCurrentPhaseExponent() */ public final float getCurrentPhaseExponent() { return this.currentPhaseExponent; diff --git a/src/main/java/net/slightlymagic/braids/util/progress_monitor/BraidsProgressMonitor.java b/src/main/java/net/slightlymagic/braids/BraidsProgressMonitor.java similarity index 99% rename from src/main/java/net/slightlymagic/braids/util/progress_monitor/BraidsProgressMonitor.java rename to src/main/java/net/slightlymagic/braids/BraidsProgressMonitor.java index c896f8e25c3..03db96534a0 100644 --- a/src/main/java/net/slightlymagic/braids/util/progress_monitor/BraidsProgressMonitor.java +++ b/src/main/java/net/slightlymagic/braids/BraidsProgressMonitor.java @@ -18,7 +18,7 @@ * limitations under the Apache License. * */ -package net.slightlymagic.braids.util.progress_monitor; +package net.slightlymagic.braids; /** * Interface for a progress monitor that can have multiple phases and diff --git a/src/main/java/net/slightlymagic/braids/util/generator/FindNonDirectoriesSkipDotDirectoriesGenerator.java b/src/main/java/net/slightlymagic/braids/FindNonDirectoriesSkipDotDirectoriesGenerator.java similarity index 98% rename from src/main/java/net/slightlymagic/braids/util/generator/FindNonDirectoriesSkipDotDirectoriesGenerator.java rename to src/main/java/net/slightlymagic/braids/FindNonDirectoriesSkipDotDirectoriesGenerator.java index 4260119e69e..1aa44a19d03 100644 --- a/src/main/java/net/slightlymagic/braids/util/generator/FindNonDirectoriesSkipDotDirectoriesGenerator.java +++ b/src/main/java/net/slightlymagic/braids/FindNonDirectoriesSkipDotDirectoriesGenerator.java @@ -18,7 +18,7 @@ * limitations under the Apache License. * */ -package net.slightlymagic.braids.util.generator; +package net.slightlymagic.braids; import java.io.File; diff --git a/src/main/java/net/slightlymagic/braids/util/generator/GeneratorFunctions.java b/src/main/java/net/slightlymagic/braids/GeneratorFunctions.java similarity index 99% rename from src/main/java/net/slightlymagic/braids/util/generator/GeneratorFunctions.java rename to src/main/java/net/slightlymagic/braids/GeneratorFunctions.java index 6d33055aa28..7e956a2f1f5 100644 --- a/src/main/java/net/slightlymagic/braids/util/generator/GeneratorFunctions.java +++ b/src/main/java/net/slightlymagic/braids/GeneratorFunctions.java @@ -18,7 +18,7 @@ * limitations under the Apache License. * */ -package net.slightlymagic.braids.util.generator; +package net.slightlymagic.braids; import java.util.ArrayList; import java.util.NoSuchElementException; diff --git a/src/main/java/net/slightlymagic/braids/util/generator/package-info.java b/src/main/java/net/slightlymagic/braids/util/generator/package-info.java deleted file mode 100644 index b9188278dfd..00000000000 --- a/src/main/java/net/slightlymagic/braids/util/generator/package-info.java +++ /dev/null @@ -1,11 +0,0 @@ -/** - * Utilities to be used with Java-Yield Generators. - * - * Files in this package and all subpackages are Copyright 2011 Braids Cabal-Conjurer. - * They are licensed under both the GPL and the Apache 2.0 license. - * - * For documentation on Java-Yield and its generators, see - * {@link com.google.code.jyield.Generator}. - */ -package net.slightlymagic.braids.util.generator; - diff --git a/src/main/java/net/slightlymagic/braids/util/progress_monitor/StderrProgressMonitor.java b/src/main/java/net/slightlymagic/braids/util/progress_monitor/StderrProgressMonitor.java deleted file mode 100644 index 8e1f1349755..00000000000 --- a/src/main/java/net/slightlymagic/braids/util/progress_monitor/StderrProgressMonitor.java +++ /dev/null @@ -1,132 +0,0 @@ -/* - * The files in the directory "net/slightlymagic/braids" and in all subdirectories of it (the "Files") are - * Copyright 2011 Braids Cabal-Conjurer. They are available under either Forge's - * main license (the GNU Public License; see LICENSE.txt in Forge's top directory) - * or under the Apache License, as explained below. - * - * The Files are additionally licensed under the Apache License, Version 2.0 (the - * "Apache License"); you may not use the files in this directory except in - * compliance with one of its two licenses. You may obtain a copy of the Apache - * License at - * - * http://www.apache.org/licenses/LICENSE-2.0 - * - * Unless required by applicable law or agreed to in writing, software - * distributed under the Apache License is distributed on an "AS IS" BASIS, - * WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied. - * See the Apache License for the specific language governing permissions and - * limitations under the Apache License. - * - */ -package net.slightlymagic.braids.util.progress_monitor; - -/** - * The Class StderrProgressMonitor. - */ -public class StderrProgressMonitor extends BaseProgressMonitor { - - /** - * Instantiates a new stderr progress monitor. - * - * @param numPhases - * the num phases - * @param totalUnitsFirstPhase - * the total units first phase - * @see net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor#BaseProgressMonitor(int, - * long) - */ - public StderrProgressMonitor(final int numPhases, final long totalUnitsFirstPhase) { - this(numPhases, totalUnitsFirstPhase, 2.0f, null); - } - - /** - * Instantiates a new stderr progress monitor. - * - * @param numPhases - * the num phases - * @param totalUnitsFirstPhase - * the total units first phase - * @param minUpdateIntervalSec - * the min update interval sec - * @see net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor#BaseProgressMonitor(int, - * long, float) - */ - public StderrProgressMonitor(final int numPhases, - final long totalUnitsFirstPhase, final float minUpdateIntervalSec) { - this(numPhases, totalUnitsFirstPhase, minUpdateIntervalSec, null); - } - - /** - * Instantiates a new stderr progress monitor. - * - * @param numPhases - * the num phases - * @param totalUnitsFirstPhase - * the total units first phase - * @param minUpdateIntervalSec - * the min update interval sec - * @param phaseWeights - * the phase weights - * @see net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor#BaseProgressMonitor(int, - * long, float, float[]) - */ - public StderrProgressMonitor(final int numPhases, final long totalUnitsFirstPhase, - final float minUpdateIntervalSec, final float[] phaseWeights) { - super(numPhases, totalUnitsFirstPhase, minUpdateIntervalSec, phaseWeights); - } - - /* - * (non-Javadoc) - * - * @see net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor# - * incrementUnitsCompletedThisPhase(long) - */ - - /** - * Increment units completed this phase. - * - * @param numUnits long - * @see net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor#BaseProgressMonitor(int) - */ - @Override - public final void incrementUnitsCompletedThisPhase(final long numUnits) { - super.incrementUnitsCompletedThisPhase(numUnits); - - if (shouldUpdateUI()) { - - if ((getNumPhases() > 1)) { - printUpdate("Phase " + getCurrentPhase() + ": " + getUnitsCompletedSoFarThisPhase() - + " units processed. " + "Overall: " + getTotalPercentCompleteAsString() + "% complete, " - + "ETA in " + getRelativeETAAsString() + "."); - } else { - printUpdate("Overall: " + getUnitsCompletedSoFarThisPhase() + " units processed " + "(" - + getTotalPercentCompleteAsString() + "%); " + "ETA in " + getRelativeETAAsString() + "."); - } - } - } - - /** - * Displays a message to stderr, overwriting the current estimate; calls - * from outside this class should provide a newline character at the end of - * the messsage. - * - * @param message - * the message to display - */ - public final void printUpdate(String message) { - - while (message.length() < 79) { - message += ' '; - } - - System.err.print("\r"); - System.err.print(message); - - if (message.length() > 79) { - System.err.print("\n"); - } - - justUpdatedUI(); - - } -} diff --git a/src/main/java/net/slightlymagic/braids/util/progress_monitor/package-info.java b/src/main/java/net/slightlymagic/braids/util/progress_monitor/package-info.java deleted file mode 100644 index be9a2d30064..00000000000 --- a/src/main/java/net/slightlymagic/braids/util/progress_monitor/package-info.java +++ /dev/null @@ -1,2 +0,0 @@ -/** Forge Card Game. */ -package net.slightlymagic.braids.util.progress_monitor;