diff --git a/src/main/java/forge/AIPlayer.java b/src/main/java/forge/AIPlayer.java index 6684f259891..4b174028c03 100644 --- a/src/main/java/forge/AIPlayer.java +++ b/src/main/java/forge/AIPlayer.java @@ -1,58 +1,71 @@ package forge; +import java.util.Random; + import forge.Constant.Zone; import forge.card.cardFactory.CardFactoryUtil; import forge.card.spellability.SpellAbility; -import java.util.Random; - - /** - *
AIPlayer class.
- * + *+ * AIPlayer class. + *
+ * * @author Forge * @version $Id$ */ public class AIPlayer extends Player { /** - *Constructor for AIPlayer.
- * - * @param myName a {@link java.lang.String} object. + *+ * Constructor for AIPlayer. + *
+ * + * @param myName + * a {@link java.lang.String} object. */ public AIPlayer(final String myName) { this(myName, 20, 0); } /** - *Constructor for AIPlayer.
- * - * @param myName a {@link java.lang.String} object. - * @param myLife a int. - * @param myPoisonCounters a int. + *+ * Constructor for AIPlayer. + *
+ * + * @param myName + * a {@link java.lang.String} object. + * @param myLife + * a int. + * @param myPoisonCounters + * a int. */ public AIPlayer(final String myName, final int myLife, final int myPoisonCounters) { super(myName, myLife, myPoisonCounters); } /** - *getOpponent.
- * + *+ * getOpponent. + *
+ * * @return a {@link forge.Player} object. */ public final Player getOpponent() { return AllZone.getHumanPlayer(); } - //////////////// - /// - /// Methods to ease transition to Abstract Player class - /// - /////////////// + // ////////////// + // / + // / Methods to ease transition to Abstract Player class + // / + // ///////////// /** - *isHuman.
- * + *+ * isHuman. + *
+ * * @return a boolean. */ public final boolean isHuman() { @@ -60,25 +73,27 @@ public class AIPlayer extends Player { } /** - *isComputer.
- * + *+ * isComputer. + *
+ * * @return a boolean. */ public final boolean isComputer() { return true; } - /////////////// - /// - /// End transition methods - /// - /////////////// + // ///////////// + // / + // / End transition methods + // / + // ///////////// - //////////////////////////////// - /// - /// replaces AllZone.getGameAction().draw* methods - /// - //////////////////////////////// + // ////////////////////////////// + // / + // / replaces AllZone.getGameAction().draw* methods + // / + // ////////////////////////////// /** {@inheritDoc} */ public final CardList mayDrawCard() { @@ -95,23 +110,25 @@ public class AIPlayer extends Player { } /** - *dredge.
- * + *+ * dredge. + *
+ * * @return a boolean. */ public final boolean dredge() { CardList dredgers = getDredge(); Random random = MyRandom.random; - //use dredge if there are more than one of them in your graveyard + // use dredge if there are more than one of them in your graveyard if (dredgers.size() > 1 || (dredgers.size() == 1 && random.nextBoolean())) { dredgers.shuffle(); Card c = dredgers.get(0); - //rule 702.49a + // rule 702.49a if (getDredgeNumber(c) <= getCardsIn(Zone.Library).size()) { - //dredge library, put card in hand + // dredge library, put card in hand AllZone.getGameAction().moveToHand(c); - //put dredge number in graveyard + // put dredge number in graveyard for (int i = 0; i < getDredgeNumber(c); i++) { Card c2 = getCardsIn(Zone.Library).get(0); AllZone.getGameAction().moveToGraveyard(c2); @@ -122,11 +139,11 @@ public class AIPlayer extends Player { return false; } - //////////////////////////////// - /// - /// replaces AllZone.getGameAction().discard* methods - /// - //////////////////////////////// + // ////////////////////////////// + // / + // / replaces AllZone.getGameAction().discard* methods + // / + // ////////////////////////////// /** {@inheritDoc} */ public final CardList discard(final int num, final SpellAbility sa, final boolean duringResolution) { @@ -138,7 +155,7 @@ public class AIPlayer extends Player { } return discarded; - } //end discard + } // end discard /** {@inheritDoc} */ public final void discardUnless(final int num, final String uType, final SpellAbility sa) { @@ -148,7 +165,11 @@ public class AIPlayer extends Player { if (tHand.size() > 0) { CardListUtil.sortCMC(tHand); tHand.reverse(); - tHand.get(0).getController().discard(tHand.get(0), sa); //this got changed to doDiscard basically + tHand.get(0).getController().discard(tHand.get(0), sa); // this got + // changed + // to + // doDiscard + // basically return; } AllZone.getComputerPlayer().discard(num, sa, false); @@ -197,8 +218,7 @@ public class AIPlayer extends Player { } } - - /////////////////////////// + // ///////////////////////// /** {@inheritDoc} */ protected final void doScry(final CardList topN, final int n) { @@ -217,7 +237,8 @@ public class AIPlayer extends Player { } }); - bottom = bl.size() > 5; // if control more than 5 Basic land, probably don't need more + 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); cl = cl.filter(new CardListFilter() { @@ -230,17 +251,18 @@ public class AIPlayer extends Player { } }); - bottom = cl.size() > 5; // if control more than 5 Creatures, probably don't need more + bottom = cl.size() > 5; // if control more than 5 Creatures, + // probably don't need more } if (bottom) { Card c = topN.get(i); AllZone.getGameAction().moveToBottomOfLibrary(c); - //topN.remove(c); + // topN.remove(c); } } num = topN.size(); // put the rest on top in random order - for (int i = 0; i < num; i++) { + for (int i = 0; i < num; i++) { Random rndm = MyRandom.random; int r = rndm.nextInt(topN.size()); Card c = topN.get(r); @@ -252,7 +274,7 @@ public class AIPlayer extends Player { /** {@inheritDoc} */ public final void sacrificePermanent(final String prompt, final CardList choices) { if (choices.size() > 0) { - //TODO - this could probably use better AI + // TODO - this could probably use better AI Card c = CardFactoryUtil.AI_getWorstPermanent(choices, false, false, false, false); AllZone.getGameAction().sacrificeDestroy(c); } @@ -260,7 +282,8 @@ public class AIPlayer extends Player { /** {@inheritDoc} */ protected final void clashMoveToTopOrBottom(final Card c) { - //computer just puts the card back until such time it can make a smarter decision + // computer just puts the card back until such time it can make a + // smarter decision AllZone.getGameAction().moveToLibrary(c); } @@ -270,4 +293,4 @@ public class AIPlayer extends Player { drawCard(); } -} //end AIPlayer class +} // end AIPlayer class diff --git a/src/main/java/forge/AllZone.java b/src/main/java/forge/AllZone.java index ca6637d6cfa..1420d3c6e0f 100644 --- a/src/main/java/forge/AllZone.java +++ b/src/main/java/forge/AllZone.java @@ -1,6 +1,5 @@ package forge; - import java.util.Arrays; import java.util.List; @@ -16,8 +15,8 @@ import forge.gui.skin.FSkin; import forge.model.FGameState; import forge.properties.ForgeProps; import forge.properties.NewConstants; -import forge.quest.data.QuestMatchState; import forge.quest.data.QuestData; +import forge.quest.data.QuestMatchState; import forge.quest.gui.main.QuestEvent; import forge.quest.gui.main.QuestEventManager; @@ -25,13 +24,13 @@ import forge.quest.gui.main.QuestEventManager; * Please use public getters and setters instead of direct field access. * * If you need a setter, by all means, add it. - * + * * @author Forge * @version $Id$ */ public final class AllZone implements NewConstants { - //only for testing, should read decks from local directory - // public static final IO IO = new IO("all-decks"); + // only for testing, should read decks from local directory + // public static final IO IO = new IO("all-decks"); /** * Do not instantiate. @@ -45,10 +44,10 @@ public final class AllZone implements NewConstants { /** GlobalquestData. */
private static forge.quest.data.QuestData questData = null;
-
+
/** Global QuestChallenge. */
private static QuestEvent questEvent = null;
-
+
/** Global questEventManager. */
private static QuestEventManager questEventManager = null;
@@ -57,7 +56,7 @@ public final class AllZone implements NewConstants {
/** Constant COLOR_CHANGER. */
private static final ColorChanger COLOR_CHANGER = new ColorChanger();
-
+
// Phase is now a prerequisite for CardFactory
/** Global cardFactory. */
private static CardFactoryInterface cardFactory = null;
@@ -65,15 +64,16 @@ public final class AllZone implements NewConstants {
/** Constant inputControl. */
private static final InputControl INPUT_CONTROL = new InputControl(Singletons.getModel());
- /**
- * Match State for challenges are stored in a QuestMatchState class instance.
+ /**
+ * Match State for challenges are stored in a QuestMatchState
+ * class instance.
*/
private static QuestMatchState matchState = new QuestMatchState();
- //initialized at Runtime since it has to be the last object constructed
+ // initialized at Runtime since it has to be the last object constructed
-
- //shared between Input_Attack, Input_Block, Input_CombatDamage , InputState_Computer
+ // shared between Input_Attack, Input_Block, Input_CombatDamage ,
+ // InputState_Computer
/** Global display. */
private static Display display;
@@ -82,7 +82,9 @@ public final class AllZone implements NewConstants {
private static DeckManager deckManager;
/**
- * getHumanPlayer.
+ *+ * getHumanPlayer. + *
* * Will eventually be marked deprecated. * @@ -100,8 +102,10 @@ public final class AllZone implements NewConstants { } /** - *getComputerPlayer.
- * + *+ * getComputerPlayer. + *
+ * * Will eventually be marked deprecated. * * @return a {@link forge.Player} object. @@ -110,19 +114,21 @@ public final class AllZone implements NewConstants { public static Player getComputerPlayer() { return Singletons.getModel().getGameState().getComputerPlayer(); } - + /** * get a list of all players participating in this game. - * + * * @return a list of all player participating in this game */ public static ListgetQuestData.
- * + *+ * getQuestData. + *
+ * * @return a {@link forge.quest.data.QuestData} object. * @since 1.0.15 */ @@ -131,18 +137,23 @@ public final class AllZone implements NewConstants { } /** - *setQuestData.
- * - * @param questData0 a {@link forge.quest.data.QuestData} object. + *+ * setQuestData. + *
+ * + * @param questData0 + * a {@link forge.quest.data.QuestData} object. * @since 1.0.15 */ public static void setQuestData(final QuestData questData0) { questData = questData0; } - + /** - *getQuestEvent.
- * + *+ * getQuestEvent. + *
+ * * @return a {@link forge.quest.gui.main.QuestEvent} object. * @since 1.0.15 */ @@ -151,17 +162,21 @@ public final class AllZone implements NewConstants { } /** - *setQuestEvent.
- * - * @param {@link forge.quest.gui.main.QuestEvent} object. + *+ * setQuestEvent. + *
+ * + * @param q a {@link forge.quest.gui.main.QuestEvent} object. */ public static void setQuestEvent(final QuestEvent q) { questEvent = q; } - + /** - *getQuestEventManager.
- * + *+ * getQuestEventManager. + *
+ * * @return {@link forge.quest.gui.main.QuestEventManager} object. * @since 1.0.15 */ @@ -170,17 +185,21 @@ public final class AllZone implements NewConstants { } /** - *setQuestEventManager.
- * - * @param {@link forge.quest.gui.main.QuestEventManager} object + *+ * setQuestEventManager. + *
+ * + * @param qem a {@link forge.quest.gui.main.QuestEventManager} object */ public static void setQuestEventManager(final QuestEventManager qem) { questEventManager = qem; } /** - *getNameChanger.
- * + *+ * getNameChanger. + *
+ * * @return a {@link forge.NameChanger} object. * @since 1.0.15 */ @@ -189,8 +208,10 @@ public final class AllZone implements NewConstants { } /** - *getEndOfTurn.
- * + *+ * getEndOfTurn. + *
+ * * Will eventually be marked deprecated. * * @return a {@link forge.EndOfTurn} object. @@ -201,8 +222,10 @@ public final class AllZone implements NewConstants { } /** - *getEndOfCombat.
- * + *+ * getEndOfCombat. + *
+ * * Will eventually be marked deprecated. * * @return a {@link forge.EndOfCombat} object. @@ -213,8 +236,10 @@ public final class AllZone implements NewConstants { } /** - *getUpkeep.
- * + *+ * getUpkeep. + *
+ * * Will eventually be marked deprecated. * * @return a {@link forge.EndOfCombat} object. @@ -225,8 +250,10 @@ public final class AllZone implements NewConstants { } /** - *getPhase.
- * + *+ * getPhase. + *
+ * * Will eventually be marked deprecated. * * @return a {@link forge.Phase} object; may be null. @@ -243,22 +270,27 @@ public final class AllZone implements NewConstants { } /** - *getCardFactory.
- * + *+ * getCardFactory. + *
+ * * @return a {@link forge.card.cardFactory.CardFactoryInterface} object. * @since 1.0.15 */ public static CardFactoryInterface getCardFactory() { - if (cardFactory == null) { - //setCardFactory(new LazyCardFactory(ForgeProps.getFile(CARDSFOLDER))); - setCardFactory(new PreloadingCardFactory(ForgeProps.getFile(CARDSFOLDER))); - } + if (cardFactory == null) { + // setCardFactory(new + // LazyCardFactory(ForgeProps.getFile(CARDSFOLDER))); + setCardFactory(new PreloadingCardFactory(ForgeProps.getFile(CARDSFOLDER))); + } return cardFactory; } /** * Setter for cardFactory. - * @param factory the factory to set + * + * @param factory + * the factory to set */ public static void setCardFactory(final CardFactoryInterface factory) { UtilFunctions.checkNotNull("factory", factory); @@ -266,8 +298,10 @@ public final class AllZone implements NewConstants { } /** - *getStack.
- * + *+ * getStack. + *
+ * * Will eventually be marked deprecated. * * @return a {@link forge.MagicStack} object. @@ -284,8 +318,10 @@ public final class AllZone implements NewConstants { } /** - *getInputControl.
- * + *+ * getInputControl. + *
+ * * @return a {@link forge.gui.input.InputControl} object. * @since 1.0.15 */ @@ -294,8 +330,10 @@ public final class AllZone implements NewConstants { } /** - *getGameAction.
- * + *+ * getGameAction. + *
+ * * Will eventually be marked deprecated. * * @return a {@link forge.GameAction} object. @@ -312,8 +350,10 @@ public final class AllZone implements NewConstants { } /** - *getStaticEffects.
- * + *+ * getStaticEffects. + *
+ * * Will eventually be marked deprecated. * * @return a {@link forge.StaticEffects} object. @@ -330,8 +370,10 @@ public final class AllZone implements NewConstants { } /** - *getGameInfo.
- * + *+ * getGameInfo. + *
+ * * @return a {@link forge.GameSummary} object. * @since 1.0.15 */ @@ -340,8 +382,10 @@ public final class AllZone implements NewConstants { } /** - *getTriggerHandler.
- * + *+ * getTriggerHandler. + *
+ * * Will eventually be marked deprecated. * * @return a {@link forge.card.trigger.TriggerHandler} object. @@ -351,10 +395,11 @@ public final class AllZone implements NewConstants { return Singletons.getModel().getGameState().getTriggerHandler(); } - /** - *getCombat.
- * + *+ * getCombat. + *
+ * * Will eventually be marked deprecated. * * @return a {@link forge.Combat} object. @@ -365,21 +410,25 @@ public final class AllZone implements NewConstants { } /** - *setCombat.
- * + *+ * setCombat. + *
+ * * Will eventually be marked deprecated. * - * @param attackers a {@link forge.Combat} object. + * @param attackers + * a {@link forge.Combat} object. * @since 1.0.15 */ public static void setCombat(final Combat attackers) { Singletons.getModel().getGameState().setCombat(attackers); } - /** - *getStackZone.
- * + *+ * getStackZone. + *
+ * * Will eventually be marked deprecated. * * @return a {@link forge.PlayerZone} object. @@ -390,8 +439,10 @@ public final class AllZone implements NewConstants { } /** - *getDisplay.
- * + *+ * getDisplay. + *
+ * * @return a {@link forge.Display} object. * @since 1.0.15 */ @@ -400,9 +451,12 @@ public final class AllZone implements NewConstants { } /** - *setDisplay.
- * - * @param display0 a {@link forge.Display} object. + *+ * setDisplay. + *
+ * + * @param display0 + * a {@link forge.Display} object. * @since 1.0.15 */ public static void setDisplay(final Display display0) { @@ -410,24 +464,30 @@ public final class AllZone implements NewConstants { } /** - *getZone.
- * - * @param c a {@link forge.Card} object. + *+ * getZone. + *
+ * + * @param c + * a {@link forge.Card} object. * @return a {@link forge.PlayerZone} object. */ public static PlayerZone getZoneOf(final Card c) { final FGameState gameState = Singletons.getModel().getGameState(); - if (gameState == null) { return null; } + if (gameState == null) { + return null; + } if (gameState.getStackZone().contains(c)) { return gameState.getStackZone(); } for (Player p : gameState.getPlayers()) { - for(Zone z : Player.ALL_ZONES) { + for (Zone z : Player.ALL_ZONES) { PlayerZone pz = p.getZone(z); - if (pz.contains(c)) + if (pz.contains(c)) { return pz; + } } } @@ -435,20 +495,27 @@ public final class AllZone implements NewConstants { } /** - *resetZoneMoveTracking.
+ *+ * resetZoneMoveTracking. + *
*/ public static void resetZoneMoveTracking() { final FGameState gameState = Singletons.getModel().getGameState(); - if (gameState == null) { return; } + if (gameState == null) { + return; + } for (Player p : gameState.getPlayers()) { - for(Zone z : Player.ALL_ZONES) { + for (Zone z : Player.ALL_ZONES) { p.getZone(z).resetCardsAddedThisTurn(); } } } - /** - *getDeckManager.
+ /** + *+ * getDeckManager. + *
+ * * @return dMgr */ public static DeckManager getDeckManager() { @@ -470,11 +537,13 @@ public final class AllZone implements NewConstants { } /** - *Resets everything possible to set a new game.
+ *+ * Resets everything possible to set a new game. + *
*/ public static void newGameCleanup() { Singletons.getModel().getGameState().newGameCleanup(); - + getDisplay().showCombat(""); getDisplay().loadPrefs(); @@ -485,6 +554,7 @@ public final class AllZone implements NewConstants { /** * Getter for matchState. + * * @return the matchState */ public static QuestMatchState getMatchState() { @@ -493,14 +563,17 @@ public final class AllZone implements NewConstants { /** * Getter for colorChanger. + * * @return the colorChanger */ public static ColorChanger getColorChanger() { return COLOR_CHANGER; } - + /** - *getSkin.
+ *+ * getSkin. + *
* Gets current display skin. * * @return a {@link forge.gui.skin.FSkin} object. @@ -511,13 +584,16 @@ public final class AllZone implements NewConstants { } /** - *setSkin.
+ *+ * setSkin. + *
* Sets current display skin. * - * @param attackers a {@link forge.gui.skin.FSkin} object. + * @param fs + * a {@link forge.gui.skin.FSkin} object. * @since 1.0.15 */ public static void setSkin(final FSkin fs) { SKIN = fs; } -} //AllZone +} // AllZone diff --git a/src/main/java/forge/AllZoneUtil.java b/src/main/java/forge/AllZoneUtil.java index a1082786233..4c1bab35fd0 100644 --- a/src/main/java/forge/AllZoneUtil.java +++ b/src/main/java/forge/AllZoneUtil.java @@ -1,31 +1,30 @@ package forge; - -import forge.Constant.Zone; import java.util.ArrayList; import java.util.List; +import forge.Constant.Zone; + /** - * AllZoneUtil contains static functions used to get CardLists of various - * cards in various zones. - * + * AllZoneUtil contains static functions used to get CardLists of various cards + * in various zones. + * * @author dennis.r.friedrichsen (slapshot5 on slightlymagic.net) * @version $Id$ */ public abstract class AllZoneUtil { + // ////////// Creatures - //////////// Creatures - - /** - * gets a list of all cards owned by both players that have are currently in the given zone. - * + * gets a list of all cards owned by both players that have are currently in + * the given zone. + * @param zone Constant.Zone * @return a CardList with all cards currently in a graveyard */ public static CardList getCardsIn(final Constant.Zone zone) { CardList cards = new CardList(); - if ( zone == Zone.Stack) { + if (zone == Zone.Stack) { cards.addAll(AllZone.getStackZone().getCards()); } else { for (Player p : AllZone.getPlayersInGame()) { @@ -35,35 +34,44 @@ public abstract class AllZoneUtil { return cards; } + /** + * + * getCardsIn. + * @param zones a ListisCardInPlay.
- * - * @param card a {@link forge.Card} object. + *+ * isCardInPlay. + *
+ * + * @param card + * a {@link forge.Card} object. * @return a boolean. */ public static boolean isCardInPlay(final Card card) { @@ -139,8 +148,9 @@ public abstract class AllZoneUtil { /** * Answers the question: "IsgetCardState.
- * - * @param card a {@link forge.Card} object. + *+ * getCardState. + *
+ * + * @param card + * a {@link forge.Card} object. * @return a {@link forge.Card} object. */ public static Card getCardState(final Card card) { @@ -208,10 +227,14 @@ public abstract class AllZoneUtil { } /** - *compareTypeAmountInPlay.
- * - * @param player a {@link forge.Player} object. - * @param type a {@link java.lang.String} object. + *+ * compareTypeAmountInPlay. + *
+ * + * @param player + * a {@link forge.Player} object. + * @param type + * a {@link java.lang.String} object. * @return a int. */ public static int compareTypeAmountInPlay(final Player player, final String type) { @@ -223,10 +246,14 @@ public abstract class AllZoneUtil { } /** - *compareTypeAmountInGraveyard.
- * - * @param player a {@link forge.Player} object. - * @param type a {@link java.lang.String} object. + *+ * compareTypeAmountInGraveyard. + *
+ * + * @param player + * a {@link forge.Player} object. + * @param type + * a {@link java.lang.String} object. * @return a int. */ public static int compareTypeAmountInGraveyard(final Player player, final String type) { @@ -237,51 +264,71 @@ public abstract class AllZoneUtil { return (playerList.size() - opponentList.size()); } - /** * a CardListFilter to get all cards that are a part of this game. - * - * @return a {@link forge.CardList} with all cards in all Battlefields, Hands, Graveyards, Libraries, and Exiles. + * + * @return a {@link forge.CardList} with all cards in all Battlefields, + * Hands, Graveyards, Libraries, and Exiles. */ public static CardList getCardsInGame() { CardList all = new CardList(); for (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()); // not sure if library should be included. + all.addAll(player.getZone(Zone.Library).getCards()); // not sure if + // library + // should be + // included. all.addAll(player.getZone(Zone.Battlefield).getCards(false)); - all.addAll(player.getZone(Zone.Exile).getCards()); // Spawnsire of Ulamog plays spells from here? + all.addAll(player.getZone(Zone.Exile).getCards()); // Spawnsire of + // Ulamog plays + // spells from + // here? } all.addAll(AllZone.getStackZone().getCards()); return all; } /** - *getDoublingSeasonMagnitude.
- * - * @param player the {@link forge.Player} player to determine if is affected by Doubling Season + *+ * getDoublingSeasonMagnitude. + *
+ * + * @param player + * the {@link forge.Player} player to determine if is affected by + * Doubling Season * @return a int. */ public static int getDoublingSeasonMagnitude(final Player player) { int doublingSeasons = player.getCardsIn(Zone.Battlefield, "Doubling Season").size(); - return (int) Math.pow(2, doublingSeasons); // pow(a,0) = 1; pow(a,1) = a ... no worries about size = 0 + return (int) Math.pow(2, doublingSeasons); // pow(a,0) = 1; pow(a,1) = a + // ... no worries about size + // = 0 } - + /** - *getTokenDoublersMagnitude.
- * - * @param player the {@link forge.Player} player to determine if is affected by Doubling Season + *+ * getTokenDoublersMagnitude. + *
+ * + * @param player + * the {@link forge.Player} player to determine if is affected by + * Doubling Season * @return a int. */ public static int getTokenDoublersMagnitude(final Player player) { - int tokenDoublers = player.getCardsIn(Zone.Battlefield, "Parallel Lives").size() + player.getCardsIn(Zone.Battlefield,"Doubling Season").size(); - return (int) Math.pow(2, tokenDoublers); // pow(a,0) = 1; pow(a,1) = a ... no worries about size = 0 + int tokenDoublers = player.getCardsIn(Zone.Battlefield, "Parallel Lives").size() + + player.getCardsIn(Zone.Battlefield, "Doubling Season").size(); + return (int) Math.pow(2, tokenDoublers); // pow(a,0) = 1; pow(a,1) = a + // ... no worries about size = + // 0 } /** * gets a list of all opponents of a given player. - * - * @param p the player whose opponents to get + * + * @param p + * the player whose opponents to get * @return a list of all opponents */ public static ArrayListcompare.
- * - * @param leftSide a int. - * @param comp a {@link java.lang.String} object. - * @param rightSide a int. + *+ * compare. + *
+ * + * @param leftSide + * a int. + * @param comp + * a {@link java.lang.String} object. + * @param rightSide + * a int. * @return a boolean. * @since 1.0.15 */ @@ -319,4 +371,4 @@ public abstract class AllZoneUtil { return false; } -}//end class AllZoneUtil +} // end class AllZoneUtil diff --git a/src/main/java/forge/Base64Coder.java b/src/main/java/forge/Base64Coder.java index 8ca4d5f2c46..0dc2428e69b 100644 --- a/src/main/java/forge/Base64Coder.java +++ b/src/main/java/forge/Base64Coder.java @@ -19,95 +19,128 @@ package forge; * A Base64 encoder/decoder. * * - * This class is used to encode and decode data in Base64 format as described in RFC 1521. + * This class is used to encode and decode data in Base64 format as described in + * RFC 1521. * * - * Project home page: www.source-code.biz/base64coder/javasystemLineSeparator="System.getProperty(line.separator)" */
+ /**
+ * Constant.
+ * systemLineSeparator="System.getProperty(line.separator)"
+ */
private static final String systemLineSeparator = System.getProperty("line.separator");
// Mapping table from 6-bit nibbles to Base64 characters.
- /** Constant map1=new char[64] */
+ /** Constant map1=new char[64]. */
private static char[] map1 = new char[64];
static {
int i = 0;
- for (char c = 'A'; c <= 'Z'; c++) map1[i++] = c;
- for (char c = 'a'; c <= 'z'; c++) map1[i++] = c;
- for (char c = '0'; c <= '9'; c++) map1[i++] = c;
+ for (char c = 'A'; c <= 'Z'; c++) {
+ map1[i++] = c;
+ }
+ for (char c = 'a'; c <= 'z'; c++) {
+ map1[i++] = c;
+ }
+ for (char c = '0'; c <= '9'; c++) {
+ map1[i++] = c;
+ }
map1[i++] = '+';
map1[i++] = '/';
}
// Mapping table from Base64 characters to 6-bit nibbles.
- /** Constant map2=new byte[128] */
+ /** Constant map2=new byte[128]. */
private static byte[] map2 = new byte[128];
static {
- for (int i = 0; i < map2.length; i++) map2[i] = -1;
- for (int i = 0; i < 64; i++) map2[map1[i]] = (byte) i;
+ for (int i = 0; i < map2.length; i++) {
+ map2[i] = -1;
+ }
+ for (int i = 0; i < 64; i++) {
+ map2[map1[i]] = (byte) i;
+ }
}
/**
- * Encodes a string into Base64 format.
- * No blanks or line breaks are inserted.
- *
- * @param s A String to be encoded.
+ * Encodes a string into Base64 format. No blanks or line breaks are
+ * inserted.
+ *
+ * @param s
+ * A String to be encoded.
* @return A String containing the Base64 encoded data.
*/
- public static String encodeString(String s) {
+ public static String encodeString(final String s) {
return new String(encode(s.getBytes()));
}
/**
- * encodeString.
- * - * @param s a {@link java.lang.String} object. - * @param noPad a boolean. + *+ * encodeString. + *
+ * + * @param s + * a {@link java.lang.String} object. + * @param noPad + * a boolean. * @return a {@link java.lang.String} object. */ - public static String encodeString(String s, boolean noPad) { + public static String encodeString(final String s, final boolean noPad) { String t = new String(encode(s.getBytes())); - if (noPad) + if (noPad) { t = t.replace("=", ""); + } return t; } /** - * Encodes a byte array into Base 64 format and breaks the output into lines of 76 characters. - * This method is compatible withsun.misc.BASE64Encoder.encodeBuffer(byte[]).
- *
- * @param in An array containing the data bytes to be encoded.
+ * Encodes a byte array into Base 64 format and breaks the output into lines
+ * of 76 characters. This method is compatible with
+ * sun.misc.BASE64Encoder.encodeBuffer(byte[]).
+ *
+ * @param in
+ * An array containing the data bytes to be encoded.
* @return A String containing the Base64 encoded data, broken into lines.
*/
- public static String encodeLines(byte[] in) {
+ public static String encodeLines(final byte[] in) {
return encodeLines(in, 0, in.length, 76, systemLineSeparator);
}
/**
- * Encodes a byte array into Base 64 format and breaks the output into lines.
- *
- * @param in An array containing the data bytes to be encoded.
- * @param iOff Offset of the first byte in in to be processed.
- * @param iLen Number of bytes to be processed in in, starting at iOff.
- * @param lineLen Line length for the output data. Should be a multiple of 4.
- * @param lineSeparator The line separator to be used to separate the output lines.
+ * Encodes a byte array into Base 64 format and breaks the output into
+ * lines.
+ *
+ * @param in
+ * An array containing the data bytes to be encoded.
+ * @param iOff
+ * Offset of the first byte in in to be processed.
+ * @param iLen
+ * Number of bytes to be processed in in, starting
+ * at iOff.
+ * @param lineLen
+ * Line length for the output data. Should be a multiple of 4.
+ * @param lineSeparator
+ * The line separator to be used to separate the output lines.
* @return A String containing the Base64 encoded data, broken into lines.
*/
- public static String encodeLines(byte[] in, int iOff, int iLen, int lineLen, String lineSeparator) {
+ public static String encodeLines(final byte[] in, final int iOff, int iLen, int lineLen, String lineSeparator) {
int blockLen = (lineLen * 3) / 4;
- if (blockLen <= 0) throw new IllegalArgumentException();
+ if (blockLen <= 0) {
+ throw new IllegalArgumentException();
+ }
int lines = (iLen + blockLen - 1) / blockLen;
int bufLen = ((iLen + 2) / 3) * 4 + lines * lineSeparator.length();
StringBuilder buf = new StringBuilder(bufLen);
@@ -122,40 +155,47 @@ public class Base64Coder {
}
/**
- * Encodes a byte array into Base64 format.
- * No blanks or line breaks are inserted in the output.
- *
- * @param in An array containing the data bytes to be encoded.
+ * Encodes a byte array into Base64 format. No blanks or line breaks are
+ * inserted in the output.
+ *
+ * @param in
+ * An array containing the data bytes to be encoded.
* @return A character array containing the Base64 encoded data.
*/
- public static char[] encode(byte[] in) {
+ public static char[] encode(final byte[] in) {
return encode(in, 0, in.length);
}
/**
- * Encodes a byte array into Base64 format.
- * No blanks or line breaks are inserted in the output.
- *
- * @param in An array containing the data bytes to be encoded.
- * @param iLen Number of bytes to process in in.
+ * Encodes a byte array into Base64 format. No blanks or line breaks are
+ * inserted in the output.
+ *
+ * @param in
+ * An array containing the data bytes to be encoded.
+ * @param iLen
+ * Number of bytes to process in in.
* @return A character array containing the Base64 encoded data.
*/
- public static char[] encode(byte[] in, int iLen) {
+ public static char[] encode(final byte[] in, final int iLen) {
return encode(in, 0, iLen);
}
/**
- * Encodes a byte array into Base64 format.
- * No blanks or line breaks are inserted in the output.
- *
- * @param in An array containing the data bytes to be encoded.
- * @param iOff Offset of the first byte in in to be processed.
- * @param iLen Number of bytes to process in in, starting at iOff.
+ * Encodes a byte array into Base64 format. No blanks or line breaks are
+ * inserted in the output.
+ *
+ * @param in
+ * An array containing the data bytes to be encoded.
+ * @param iOff
+ * Offset of the first byte in in to be processed.
+ * @param iLen
+ * Number of bytes to process in in, starting at
+ * iOff.
* @return A character array containing the Base64 encoded data.
*/
- public static char[] encode(byte[] in, int iOff, int iLen) {
- int oDataLen = (iLen * 4 + 2) / 3; // output length without padding
- int oLen = ((iLen + 2) / 3) * 4; // output length including padding
+ public static char[] encode(final byte[] in, final int iOff, final int iLen) {
+ int oDataLen = (iLen * 4 + 2) / 3; // output length without padding
+ int oLen = ((iLen + 2) / 3) * 4; // output length including padding
char[] out = new char[oLen];
int ip = iOff;
int iEnd = iOff + iLen;
@@ -179,75 +219,94 @@ public class Base64Coder {
}
/**
- * Decodes a string from Base64 format.
- * No blanks or line breaks are allowed within the Base64 encoded input data.
- *
- * @param s A Base64 String to be decoded.
+ * Decodes a string from Base64 format. No blanks or line breaks are allowed
+ * within the Base64 encoded input data.
+ *
+ * @param s
+ * A Base64 String to be decoded.
* @return A String containing the decoded data.
- * @throws java.lang.IllegalArgumentException If the input is not valid Base64 encoded data.
+ *
+ * If the input is not valid Base64 encoded data.
*/
- public static String decodeString(String s) {
+ public static String decodeString(final String s) {
return new String(decode(s));
}
/**
- * Decodes a byte array from Base64 format and ignores line separators, tabs and blanks.
- * CR, LF, Tab and Space characters are ignored in the input data.
- * This method is compatible with sun.misc.BASE64Decoder.decodeBuffer(String).
- *
- * @param s A Base64 String to be decoded.
+ * Decodes a byte array from Base64 format and ignores line separators, tabs
+ * and blanks. CR, LF, Tab and Space characters are ignored in the input
+ * data. This method is compatible with
+ * sun.misc.BASE64Decoder.decodeBuffer(String).
+ *
+ * @param s
+ * A Base64 String to be decoded.
* @return An array containing the decoded data bytes.
- * @throws java.lang.IllegalArgumentException If the input is not valid Base64 encoded data.
+ *
+ * If the input is not valid Base64 encoded data.
*/
- public static byte[] decodeLines(String s) {
+ public static byte[] decodeLines(final String s) {
char[] buf = new char[s.length()];
int p = 0;
for (int ip = 0; ip < s.length(); ip++) {
char c = s.charAt(ip);
- if (c != ' ' && c != '\r' && c != '\n' && c != '\t')
+ if (c != ' ' && c != '\r' && c != '\n' && c != '\t') {
buf[p++] = c;
+ }
}
return decode(buf, 0, p);
}
/**
- * Decodes a byte array from Base64 format.
- * No blanks or line breaks are allowed within the Base64 encoded input data.
- *
- * @param s A Base64 String to be decoded.
+ * Decodes a byte array from Base64 format. No blanks or line breaks are
+ * allowed within the Base64 encoded input data.
+ *
+ * @param s
+ * A Base64 String to be decoded.
* @return An array containing the decoded data bytes.
- * @throws java.lang.IllegalArgumentException If the input is not valid Base64 encoded data.
+ *
+ * If the input is not valid Base64 encoded data.
*/
- public static byte[] decode(String s) {
+ public static byte[] decode(final String s) {
return decode(s.toCharArray());
}
/**
- * Decodes a byte array from Base64 format.
- * No blanks or line breaks are allowed within the Base64 encoded input data.
- *
- * @param in A character array containing the Base64 encoded data.
+ * Decodes a byte array from Base64 format. No blanks or line breaks are
+ * allowed within the Base64 encoded input data.
+ *
+ * @param in
+ * A character array containing the Base64 encoded data.
* @return An array containing the decoded data bytes.
- * @throws java.lang.IllegalArgumentException If the input is not valid Base64 encoded data.
+ *
+ * If the input is not valid Base64 encoded data.
*/
- public static byte[] decode(char[] in) {
+ public static byte[] decode(final char[] in) {
return decode(in, 0, in.length);
}
/**
- * Decodes a byte array from Base64 format.
- * No blanks or line breaks are allowed within the Base64 encoded input data.
- *
- * @param in A character array containing the Base64 encoded data.
- * @param iOff Offset of the first character in in to be processed.
- * @param iLen Number of characters to process in in, starting at iOff.
+ * Decodes a byte array from Base64 format. No blanks or line breaks are
+ * allowed within the Base64 encoded input data.
+ *
+ * @param in
+ * A character array containing the Base64 encoded data.
+ * @param iOff
+ * Offset of the first character in in to be
+ * processed.
+ * @param iLen
+ * Number of characters to process in in, starting
+ * at iOff.
* @return An array containing the decoded data bytes.
- * @throws java.lang.IllegalArgumentException If the input is not valid Base64 encoded data.
+ *
+ * If the input is not valid Base64 encoded data.
*/
- public static byte[] decode(char[] in, int iOff, int iLen) {
- if (iLen % 4 != 0)
+ public static byte[] decode(final char[] in, final int iOff, int iLen) {
+ if (iLen % 4 != 0) {
throw new IllegalArgumentException("Length of Base64 encoded input string is not a multiple of 4.");
- while (iLen > 0 && in[iOff + iLen - 1] == '=') iLen--;
+ }
+ while (iLen > 0 && in[iOff + iLen - 1] == '=') {
+ iLen--;
+ }
int oLen = (iLen * 3) / 4;
byte[] out = new byte[oLen];
int ip = iOff;
@@ -258,27 +317,35 @@ public class Base64Coder {
int i1 = in[ip++];
int i2 = ip < iEnd ? in[ip++] : 'A';
int i3 = ip < iEnd ? in[ip++] : 'A';
- if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127)
+ if (i0 > 127 || i1 > 127 || i2 > 127 || i3 > 127) {
throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
+ }
int b0 = map2[i0];
int b1 = map2[i1];
int b2 = map2[i2];
int b3 = map2[i3];
- if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0)
+ if (b0 < 0 || b1 < 0 || b2 < 0 || b3 < 0) {
throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
+ }
int o0 = (b0 << 2) | (b1 >>> 4);
int o1 = ((b1 & 0xf) << 4) | (b2 >>> 2);
int o2 = ((b2 & 3) << 6) | b3;
out[op++] = (byte) o0;
- if (op < oLen) out[op++] = (byte) o1;
- if (op < oLen) out[op++] = (byte) o2;
+ if (op < oLen) {
+ out[op++] = (byte) o1;
+ }
+ if (op < oLen) {
+ out[op++] = (byte) o2;
+ }
}
return out;
}
// Dummy constructor.
/**
- * Constructor for Base64Coder.
+ *+ * Constructor for Base64Coder. + *
*/ private Base64Coder() { } diff --git a/src/main/java/forge/ButtonUtil.java b/src/main/java/forge/ButtonUtil.java index 45d86e24440..5fa44d59dfb 100644 --- a/src/main/java/forge/ButtonUtil.java +++ b/src/main/java/forge/ButtonUtil.java @@ -1,14 +1,18 @@ package forge; /** - *ButtonUtil class.
- * + *+ * ButtonUtil class. + *
+ * * @author Forge * @version $Id$ */ public class ButtonUtil { /** - *reset.
+ *+ * reset. + *
*/ public static void reset() { getOK().setText("OK"); @@ -19,7 +23,9 @@ public class ButtonUtil { } /** - *enableOnlyOK.
+ *+ * enableOnlyOK. + *
*/ public static void enableOnlyOK() { getOK().setSelectable(true); @@ -27,7 +33,9 @@ public class ButtonUtil { } /** - *enableOnlyCancel.
+ *+ * enableOnlyCancel. + *
*/ public static void enableOnlyCancel() { getOK().setSelectable(false); @@ -35,7 +43,9 @@ public class ButtonUtil { } /** - *disableAll.
+ *+ * disableAll. + *
*/ public static void disableAll() { getOK().setSelectable(false); @@ -43,7 +53,9 @@ public class ButtonUtil { } /** - *enableAll.
+ *+ * enableAll. + *
*/ public static void enableAll() { getOK().setSelectable(true); @@ -51,22 +63,28 @@ public class ButtonUtil { } /** - *disableOK.
+ *+ * disableOK. + *
*/ public static void disableOK() { getOK().setSelectable(false); } /** - *disableCancel.
+ *+ * disableCancel. + *
*/ public static void disableCancel() { getCancel().setSelectable(false); } /** - *getOK.
- * + *+ * getOK. + *
+ * * @return a {@link forge.MyButton} object. */ private static MyButton getOK() { @@ -74,8 +92,10 @@ public class ButtonUtil { } /** - *getCancel.
- * + *+ * getCancel. + *
+ * * @return a {@link forge.MyButton} object. */ private static MyButton getCancel() { diff --git a/src/main/java/forge/Card_Color.java b/src/main/java/forge/Card_Color.java index 0f3d2f51594..ddfb7abddda 100644 --- a/src/main/java/forge/Card_Color.java +++ b/src/main/java/forge/Card_Color.java @@ -1,24 +1,29 @@ package forge; -import forge.card.mana.ManaCost; - import java.util.ArrayList; import java.util.EnumSet; +import forge.card.mana.ManaCost; + /** - *Card_Color class.
- * + *+ * Card_Color class. + *
+ * * @author Forge * @version $Id$ */ public class Card_Color { - // takes care of individual card color, for global color change effects use AllZone.getGameInfo().getColorChanges() + // takes care of individual card color, for global color change effects use + // AllZone.getGameInfo().getColorChanges() private EnumSetGetter for the field additional.
+ * Getter for the field additional.
+ *
Getter for the field stamp.
+ * Getter for the field stamp.
+ *
getTimestamp.
- * + *+ * getTimestamp. + *
+ * * @return a long. */ public static long getTimestamp() { @@ -52,12 +61,18 @@ public class Card_Color { } /** - *Constructor for Card_Color.
- * - * @param mc a {@link forge.card.mana.ManaCost} object. - * @param c a {@link forge.Card} object. - * @param addToColors a boolean. - * @param baseColor a boolean. + *+ * Constructor for Card_Color. + *
+ * + * @param mc + * a {@link forge.card.mana.ManaCost} object. + * @param c + * a {@link forge.Card} object. + * @param addToColors + * a boolean. + * @param baseColor + * a boolean. */ Card_Color(final ManaCost mc, final Card c, final boolean addToColors, final boolean baseColor) { additional = addToColors; @@ -71,9 +86,12 @@ public class Card_Color { } /** - *Constructor for Card_Color.
- * - * @param c a {@link forge.Card} object. + *+ * Constructor for Card_Color. + *
+ * + * @param c + * a {@link forge.Card} object. */ public Card_Color(final Card c) { col = Color.Colorless(); @@ -83,9 +101,12 @@ public class Card_Color { } /** - *addToCardColor.
- * - * @param s a {@link java.lang.String} object. + *+ * addToCardColor. + *
+ * + * @param s + * a {@link java.lang.String} object. * @return a boolean. */ final boolean addToCardColor(final String s) { @@ -98,7 +119,9 @@ public class Card_Color { } /** - *fixColorless.
+ *+ * fixColorless. + *
*/ final void fixColorless() { if (col.size() > 1 && col.contains(Color.Colorless)) { @@ -107,19 +130,27 @@ public class Card_Color { } /** - *increaseTimestamp.
+ *+ * increaseTimestamp. + *
*/ static void increaseTimestamp() { timeStamp++; } /** - *equals.
- * - * @param cost a {@link java.lang.String} object. - * @param c a {@link forge.Card} object. - * @param addToColors a boolean. - * @param time a long. + *+ * equals. + *
+ * + * @param cost + * a {@link java.lang.String} object. + * @param c + * a {@link forge.Card} object. + * @param addToColors + * a boolean. + * @param time + * a long. * @return a boolean. */ public final boolean equals(final String cost, final Card c, final boolean addToColors, final long time) { @@ -127,8 +158,10 @@ public class Card_Color { } /** - *toStringArray.
- * + *+ * toStringArray. + *
+ * * @return a {@link java.util.ArrayList} object. */ public final ArrayListCard_Keywords class.
- * + *+ * Card_Keywords class. + *
+ * * @author Forge * @version $Id: Card_Keywords.java 10217 2011-09-04 10:14:19Z Sloth $ */ -public class Card_Keywords implements ComparablegetTimestamp.
- * + *+ * getTimestamp. + *
+ * * @return a long. */ public final long getTimestamp() { return timeStamp; } - Card_Keywords(final ArrayList