checkstyle

This commit is contained in:
jendave
2011-10-25 17:08:39 +00:00
parent 06509c266d
commit 2a8882b57d
8 changed files with 704 additions and 404 deletions

View File

@@ -1,14 +1,15 @@
package forge; package forge;
import java.util.Random;
import forge.Constant.Zone; import forge.Constant.Zone;
import forge.card.cardFactory.CardFactoryUtil; import forge.card.cardFactory.CardFactoryUtil;
import forge.card.spellability.SpellAbility; import forge.card.spellability.SpellAbility;
import java.util.Random;
/** /**
* <p>AIPlayer class.</p> * <p>
* AIPlayer class.
* </p>
* *
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
@@ -16,27 +17,37 @@ import java.util.Random;
public class AIPlayer extends Player { public class AIPlayer extends Player {
/** /**
* <p>Constructor for AIPlayer.</p> * <p>
* Constructor for AIPlayer.
* </p>
* *
* @param myName a {@link java.lang.String} object. * @param myName
* a {@link java.lang.String} object.
*/ */
public AIPlayer(final String myName) { public AIPlayer(final String myName) {
this(myName, 20, 0); this(myName, 20, 0);
} }
/** /**
* <p>Constructor for AIPlayer.</p> * <p>
* Constructor for AIPlayer.
* </p>
* *
* @param myName a {@link java.lang.String} object. * @param myName
* @param myLife a int. * a {@link java.lang.String} object.
* @param myPoisonCounters a int. * @param myLife
* a int.
* @param myPoisonCounters
* a int.
*/ */
public AIPlayer(final String myName, final int myLife, final int myPoisonCounters) { public AIPlayer(final String myName, final int myLife, final int myPoisonCounters) {
super(myName, myLife, myPoisonCounters); super(myName, myLife, myPoisonCounters);
} }
/** /**
* <p>getOpponent.</p> * <p>
* getOpponent.
* </p>
* *
* @return a {@link forge.Player} object. * @return a {@link forge.Player} object.
*/ */
@@ -51,7 +62,9 @@ public class AIPlayer extends Player {
// ///////////// // /////////////
/** /**
* <p>isHuman.</p> * <p>
* isHuman.
* </p>
* *
* @return a boolean. * @return a boolean.
*/ */
@@ -60,7 +73,9 @@ public class AIPlayer extends Player {
} }
/** /**
* <p>isComputer.</p> * <p>
* isComputer.
* </p>
* *
* @return a boolean. * @return a boolean.
*/ */
@@ -95,7 +110,9 @@ public class AIPlayer extends Player {
} }
/** /**
* <p>dredge.</p> * <p>
* dredge.
* </p>
* *
* @return a boolean. * @return a boolean.
*/ */
@@ -148,7 +165,11 @@ public class AIPlayer extends Player {
if (tHand.size() > 0) { if (tHand.size() > 0) {
CardListUtil.sortCMC(tHand); CardListUtil.sortCMC(tHand);
tHand.reverse(); 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; return;
} }
AllZone.getComputerPlayer().discard(num, sa, false); AllZone.getComputerPlayer().discard(num, sa, false);
@@ -197,7 +218,6 @@ public class AIPlayer extends Player {
} }
} }
// ///////////////////////// // /////////////////////////
/** {@inheritDoc} */ /** {@inheritDoc} */
@@ -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()) { } else if (topN.get(i).isCreature()) {
CardList cl = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield); CardList cl = AllZone.getComputerPlayer().getCardsIn(Zone.Battlefield);
cl = cl.filter(new CardListFilter() { cl = cl.filter(new CardListFilter() {
@@ -230,7 +251,8 @@ 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) { if (bottom) {
Card c = topN.get(i); Card c = topN.get(i);
@@ -260,7 +282,8 @@ public class AIPlayer extends Player {
/** {@inheritDoc} */ /** {@inheritDoc} */
protected final void clashMoveToTopOrBottom(final Card c) { 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); AllZone.getGameAction().moveToLibrary(c);
} }

View File

@@ -1,6 +1,5 @@
package forge; package forge;
import java.util.Arrays; import java.util.Arrays;
import java.util.List; import java.util.List;
@@ -16,8 +15,8 @@ import forge.gui.skin.FSkin;
import forge.model.FGameState; import forge.model.FGameState;
import forge.properties.ForgeProps; import forge.properties.ForgeProps;
import forge.properties.NewConstants; import forge.properties.NewConstants;
import forge.quest.data.QuestMatchState;
import forge.quest.data.QuestData; import forge.quest.data.QuestData;
import forge.quest.data.QuestMatchState;
import forge.quest.gui.main.QuestEvent; import forge.quest.gui.main.QuestEvent;
import forge.quest.gui.main.QuestEventManager; import forge.quest.gui.main.QuestEventManager;
@@ -66,14 +65,15 @@ public final class AllZone implements NewConstants {
private static final InputControl INPUT_CONTROL = new InputControl(Singletons.getModel()); private static final InputControl INPUT_CONTROL = new InputControl(Singletons.getModel());
/** /**
* Match State for challenges are stored in a <code>QuestMatchState</code> class instance. * Match State for challenges are stored in a <code>QuestMatchState</code>
* class instance.
*/ */
private static QuestMatchState matchState = new QuestMatchState(); 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 ,
//shared between Input_Attack, Input_Block, Input_CombatDamage , InputState_Computer // InputState_Computer
/** Global <code>display</code>. */ /** Global <code>display</code>. */
private static Display display; private static Display display;
@@ -82,7 +82,9 @@ public final class AllZone implements NewConstants {
private static DeckManager deckManager; private static DeckManager deckManager;
/** /**
* <p>getHumanPlayer.</p> * <p>
* getHumanPlayer.
* </p>
* *
* Will eventually be marked deprecated. * Will eventually be marked deprecated.
* *
@@ -100,7 +102,9 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>getComputerPlayer.</p> * <p>
* getComputerPlayer.
* </p>
* *
* Will eventually be marked deprecated. * Will eventually be marked deprecated.
* *
@@ -121,7 +125,9 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>getQuestData.</p> * <p>
* getQuestData.
* </p>
* *
* @return a {@link forge.quest.data.QuestData} object. * @return a {@link forge.quest.data.QuestData} object.
* @since 1.0.15 * @since 1.0.15
@@ -131,9 +137,12 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>setQuestData.</p> * <p>
* setQuestData.
* </p>
* *
* @param questData0 a {@link forge.quest.data.QuestData} object. * @param questData0
* a {@link forge.quest.data.QuestData} object.
* @since 1.0.15 * @since 1.0.15
*/ */
public static void setQuestData(final QuestData questData0) { public static void setQuestData(final QuestData questData0) {
@@ -141,7 +150,9 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>getQuestEvent.</p> * <p>
* getQuestEvent.
* </p>
* *
* @return a {@link forge.quest.gui.main.QuestEvent} object. * @return a {@link forge.quest.gui.main.QuestEvent} object.
* @since 1.0.15 * @since 1.0.15
@@ -151,16 +162,20 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>setQuestEvent.</p> * <p>
* setQuestEvent.
* </p>
* *
* @param {@link forge.quest.gui.main.QuestEvent} object. * @param q a {@link forge.quest.gui.main.QuestEvent} object.
*/ */
public static void setQuestEvent(final QuestEvent q) { public static void setQuestEvent(final QuestEvent q) {
questEvent = q; questEvent = q;
} }
/** /**
* <p>getQuestEventManager.</p> * <p>
* getQuestEventManager.
* </p>
* *
* @return {@link forge.quest.gui.main.QuestEventManager} object. * @return {@link forge.quest.gui.main.QuestEventManager} object.
* @since 1.0.15 * @since 1.0.15
@@ -170,16 +185,20 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>setQuestEventManager.</p> * <p>
* setQuestEventManager.
* </p>
* *
* @param {@link forge.quest.gui.main.QuestEventManager} object * @param qem a {@link forge.quest.gui.main.QuestEventManager} object
*/ */
public static void setQuestEventManager(final QuestEventManager qem) { public static void setQuestEventManager(final QuestEventManager qem) {
questEventManager = qem; questEventManager = qem;
} }
/** /**
* <p>getNameChanger.</p> * <p>
* getNameChanger.
* </p>
* *
* @return a {@link forge.NameChanger} object. * @return a {@link forge.NameChanger} object.
* @since 1.0.15 * @since 1.0.15
@@ -189,7 +208,9 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>getEndOfTurn.</p> * <p>
* getEndOfTurn.
* </p>
* *
* Will eventually be marked deprecated. * Will eventually be marked deprecated.
* *
@@ -201,7 +222,9 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>getEndOfCombat.</p> * <p>
* getEndOfCombat.
* </p>
* *
* Will eventually be marked deprecated. * Will eventually be marked deprecated.
* *
@@ -213,7 +236,9 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>getUpkeep.</p> * <p>
* getUpkeep.
* </p>
* *
* Will eventually be marked deprecated. * Will eventually be marked deprecated.
* *
@@ -225,7 +250,9 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>getPhase.</p> * <p>
* getPhase.
* </p>
* *
* Will eventually be marked deprecated. * Will eventually be marked deprecated.
* *
@@ -243,14 +270,17 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>getCardFactory.</p> * <p>
* getCardFactory.
* </p>
* *
* @return a {@link forge.card.cardFactory.CardFactoryInterface} object. * @return a {@link forge.card.cardFactory.CardFactoryInterface} object.
* @since 1.0.15 * @since 1.0.15
*/ */
public static CardFactoryInterface getCardFactory() { public static CardFactoryInterface getCardFactory() {
if (cardFactory == null) { if (cardFactory == null) {
//setCardFactory(new LazyCardFactory(ForgeProps.getFile(CARDSFOLDER))); // setCardFactory(new
// LazyCardFactory(ForgeProps.getFile(CARDSFOLDER)));
setCardFactory(new PreloadingCardFactory(ForgeProps.getFile(CARDSFOLDER))); setCardFactory(new PreloadingCardFactory(ForgeProps.getFile(CARDSFOLDER)));
} }
return cardFactory; return cardFactory;
@@ -258,7 +288,9 @@ public final class AllZone implements NewConstants {
/** /**
* Setter for cardFactory. * Setter for cardFactory.
* @param factory the factory to set *
* @param factory
* the factory to set
*/ */
public static void setCardFactory(final CardFactoryInterface factory) { public static void setCardFactory(final CardFactoryInterface factory) {
UtilFunctions.checkNotNull("factory", factory); UtilFunctions.checkNotNull("factory", factory);
@@ -266,7 +298,9 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>getStack.</p> * <p>
* getStack.
* </p>
* *
* Will eventually be marked deprecated. * Will eventually be marked deprecated.
* *
@@ -284,7 +318,9 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>getInputControl.</p> * <p>
* getInputControl.
* </p>
* *
* @return a {@link forge.gui.input.InputControl} object. * @return a {@link forge.gui.input.InputControl} object.
* @since 1.0.15 * @since 1.0.15
@@ -294,7 +330,9 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>getGameAction.</p> * <p>
* getGameAction.
* </p>
* *
* Will eventually be marked deprecated. * Will eventually be marked deprecated.
* *
@@ -312,7 +350,9 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>getStaticEffects.</p> * <p>
* getStaticEffects.
* </p>
* *
* Will eventually be marked deprecated. * Will eventually be marked deprecated.
* *
@@ -330,7 +370,9 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>getGameInfo.</p> * <p>
* getGameInfo.
* </p>
* *
* @return a {@link forge.GameSummary} object. * @return a {@link forge.GameSummary} object.
* @since 1.0.15 * @since 1.0.15
@@ -340,7 +382,9 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>getTriggerHandler.</p> * <p>
* getTriggerHandler.
* </p>
* *
* Will eventually be marked deprecated. * Will eventually be marked deprecated.
* *
@@ -351,9 +395,10 @@ public final class AllZone implements NewConstants {
return Singletons.getModel().getGameState().getTriggerHandler(); return Singletons.getModel().getGameState().getTriggerHandler();
} }
/** /**
* <p>getCombat.</p> * <p>
* getCombat.
* </p>
* *
* Will eventually be marked deprecated. * Will eventually be marked deprecated.
* *
@@ -365,20 +410,24 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>setCombat.</p> * <p>
* setCombat.
* </p>
* *
* Will eventually be marked deprecated. * Will eventually be marked deprecated.
* *
* @param attackers a {@link forge.Combat} object. * @param attackers
* a {@link forge.Combat} object.
* @since 1.0.15 * @since 1.0.15
*/ */
public static void setCombat(final Combat attackers) { public static void setCombat(final Combat attackers) {
Singletons.getModel().getGameState().setCombat(attackers); Singletons.getModel().getGameState().setCombat(attackers);
} }
/** /**
* <p>getStackZone.</p> * <p>
* getStackZone.
* </p>
* *
* Will eventually be marked deprecated. * Will eventually be marked deprecated.
* *
@@ -390,7 +439,9 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>getDisplay.</p> * <p>
* getDisplay.
* </p>
* *
* @return a {@link forge.Display} object. * @return a {@link forge.Display} object.
* @since 1.0.15 * @since 1.0.15
@@ -400,9 +451,12 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>setDisplay.</p> * <p>
* setDisplay.
* </p>
* *
* @param display0 a {@link forge.Display} object. * @param display0
* a {@link forge.Display} object.
* @since 1.0.15 * @since 1.0.15
*/ */
public static void setDisplay(final Display display0) { public static void setDisplay(final Display display0) {
@@ -410,14 +464,19 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>getZone.</p> * <p>
* getZone.
* </p>
* *
* @param c a {@link forge.Card} object. * @param c
* a {@link forge.Card} object.
* @return a {@link forge.PlayerZone} object. * @return a {@link forge.PlayerZone} object.
*/ */
public static PlayerZone getZoneOf(final Card c) { public static PlayerZone getZoneOf(final Card c) {
final FGameState gameState = Singletons.getModel().getGameState(); final FGameState gameState = Singletons.getModel().getGameState();
if (gameState == null) { return null; } if (gameState == null) {
return null;
}
if (gameState.getStackZone().contains(c)) { if (gameState.getStackZone().contains(c)) {
return gameState.getStackZone(); return gameState.getStackZone();
@@ -426,20 +485,25 @@ public final class AllZone implements NewConstants {
for (Player p : gameState.getPlayers()) { for (Player p : gameState.getPlayers()) {
for (Zone z : Player.ALL_ZONES) { for (Zone z : Player.ALL_ZONES) {
PlayerZone pz = p.getZone(z); PlayerZone pz = p.getZone(z);
if (pz.contains(c)) if (pz.contains(c)) {
return pz; return pz;
} }
} }
}
return null; return null;
} }
/** /**
* <p>resetZoneMoveTracking.</p> * <p>
* resetZoneMoveTracking.
* </p>
*/ */
public static void resetZoneMoveTracking() { public static void resetZoneMoveTracking() {
final FGameState gameState = Singletons.getModel().getGameState(); final FGameState gameState = Singletons.getModel().getGameState();
if (gameState == null) { return; } if (gameState == null) {
return;
}
for (Player p : gameState.getPlayers()) { for (Player p : gameState.getPlayers()) {
for (Zone z : Player.ALL_ZONES) { for (Zone z : Player.ALL_ZONES) {
p.getZone(z).resetCardsAddedThisTurn(); p.getZone(z).resetCardsAddedThisTurn();
@@ -448,7 +512,10 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>getDeckManager.</p> * <p>
* getDeckManager.
* </p>
*
* @return dMgr * @return dMgr
*/ */
public static DeckManager getDeckManager() { public static DeckManager getDeckManager() {
@@ -470,7 +537,9 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>Resets everything possible to set a new game.</p> * <p>
* Resets everything possible to set a new game.
* </p>
*/ */
public static void newGameCleanup() { public static void newGameCleanup() {
Singletons.getModel().getGameState().newGameCleanup(); Singletons.getModel().getGameState().newGameCleanup();
@@ -485,6 +554,7 @@ public final class AllZone implements NewConstants {
/** /**
* Getter for matchState. * Getter for matchState.
*
* @return the matchState * @return the matchState
*/ */
public static QuestMatchState getMatchState() { public static QuestMatchState getMatchState() {
@@ -493,6 +563,7 @@ public final class AllZone implements NewConstants {
/** /**
* Getter for colorChanger. * Getter for colorChanger.
*
* @return the colorChanger * @return the colorChanger
*/ */
public static ColorChanger getColorChanger() { public static ColorChanger getColorChanger() {
@@ -500,7 +571,9 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>getSkin.</p> * <p>
* getSkin.
* </p>
* Gets current display skin. * Gets current display skin.
* *
* @return a {@link forge.gui.skin.FSkin} object. * @return a {@link forge.gui.skin.FSkin} object.
@@ -511,10 +584,13 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>setSkin.</p> * <p>
* setSkin.
* </p>
* Sets current display skin. * 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 * @since 1.0.15
*/ */
public static void setSkin(final FSkin fs) { public static void setSkin(final FSkin fs) {

View File

@@ -1,26 +1,25 @@
package forge; package forge;
import forge.Constant.Zone;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import forge.Constant.Zone;
/** /**
* AllZoneUtil contains static functions used to get CardLists of various * AllZoneUtil contains static functions used to get CardLists of various cards
* cards in various zones. * in various zones.
* *
* @author dennis.r.friedrichsen (slapshot5 on slightlymagic.net) * @author dennis.r.friedrichsen (slapshot5 on slightlymagic.net)
* @version $Id$ * @version $Id$
*/ */
public abstract class AllZoneUtil { 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 * @return a CardList with all cards currently in a graveyard
*/ */
public static CardList getCardsIn(final Constant.Zone zone) { public static CardList getCardsIn(final Constant.Zone zone) {
@@ -35,6 +34,12 @@ public abstract class AllZoneUtil {
return cards; return cards;
} }
/**
*
* getCardsIn.
* @param zones a List<Constant.Zone>
* @return CardList
*/
public static CardList getCardsIn(final List<Constant.Zone> zones) { public static CardList getCardsIn(final List<Constant.Zone> zones) {
CardList cards = new CardList(); CardList cards = new CardList();
for (Zone z : zones) { for (Zone z : zones) {
@@ -51,18 +56,21 @@ public abstract class AllZoneUtil {
} }
/** /**
* 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 a Constant.Zone
* @param cardName a String
* @return a CardList with all cards currently in a graveyard * @return a CardList with all cards currently in a graveyard
*/ */
public static CardList getCardsIn(final Constant.Zone zone, String cardName) { public static CardList getCardsIn(final Constant.Zone zone, final String cardName) {
return getCardsIn(zone).getName(cardName); return getCardsIn(zone).getName(cardName);
} }
// ////////// Creatures // ////////// Creatures
/** /**
* use to get a CardList of all creatures on the battlefield for both players * use to get a CardList of all creatures on the battlefield for both.
* players
* *
* @return a CardList of all creatures on the battlefield on both sides * @return a CardList of all creatures on the battlefield on both sides
*/ */
@@ -74,7 +82,8 @@ public abstract class AllZoneUtil {
/** /**
* use to get a list of creatures in play for a given player. * use to get a list of creatures in play for a given player.
* *
* @param player the player to get creatures for * @param player
* the player to get creatures for
* @return a CardList containing all creatures a given player has in play * @return a CardList containing all creatures a given player has in play
*/ */
public static CardList getCreaturesInPlay(final Player player) { public static CardList getCreaturesInPlay(final Player player) {
@@ -82,14 +91,13 @@ public abstract class AllZoneUtil {
return creats.filter(CardListFilter.creatures); return creats.filter(CardListFilter.creatures);
} }
// /////////////// Lands // /////////////// Lands
/** /**
* use to get a list of all lands a given player has on the battlefield. * use to get a list of all lands a given player has on the battlefield.
* *
* @param player the player whose lands we want to get * @param player
* the player whose lands we want to get
* @return a CardList containing all lands the given player has in play * @return a CardList containing all lands the given player has in play
*/ */
public static CardList getPlayerLandsInPlay(final Player player) { public static CardList getPlayerLandsInPlay(final Player player) {
@@ -112,25 +120,26 @@ public abstract class AllZoneUtil {
// //
// ============================================================================= // =============================================================================
/** /**
* answers the question "is the given card in any exile zone?". * answers the question "is the given card in any exile zone?".
* *
* @param c the card to look for in Exile * @param c
* the card to look for in Exile
* @return true is the card is in Human or Computer's Exile zone * @return true is the card is in Human or Computer's Exile zone
*/ */
public static boolean isCardExiled(final Card c) { public static boolean isCardExiled(final Card c) {
return getCardsIn(Zone.Exile).contains(c); return getCardsIn(Zone.Exile).contains(c);
} }
// /Check if a certain card is in play // /Check if a certain card is in play
/** /**
* <p>isCardInPlay.</p> * <p>
* isCardInPlay.
* </p>
* *
* @param card a {@link forge.Card} object. * @param card
* a {@link forge.Card} object.
* @return a boolean. * @return a boolean.
*/ */
public static boolean isCardInPlay(final Card card) { public static boolean isCardInPlay(final Card card) {
@@ -140,7 +149,8 @@ public abstract class AllZoneUtil {
/** /**
* Answers the question: "Is <card name> in play?". * Answers the question: "Is <card name> in play?".
* *
* @param cardName the name of the card to look for * @param cardName
* the name of the card to look for
* @return true is the card is in play, false otherwise * @return true is the card is in play, false otherwise
*/ */
public static boolean isCardInPlay(final String cardName) { public static boolean isCardInPlay(final String cardName) {
@@ -150,8 +160,10 @@ public abstract class AllZoneUtil {
/** /**
* Answers the question: "Does <player> have <card name> in play?". * Answers the question: "Does <player> have <card name> in play?".
* *
* @param cardName the name of the card to look for * @param cardName
* @param player the player whose battlefield we want to check * the name of the card to look for
* @param player
* the player whose battlefield we want to check
* @return true if that player has that card in play, false otherwise * @return true if that player has that card in play, false otherwise
*/ */
public static boolean isCardInPlay(final String cardName, final Player player) { public static boolean isCardInPlay(final String cardName, final Player player) {
@@ -163,7 +175,8 @@ public abstract class AllZoneUtil {
/** /**
* gets a list of all Cards of a given color on the battlefield. * gets a list of all Cards of a given color on the battlefield.
* *
* @param color the color of cards to get * @param color
* the color of cards to get
* @return a CardList of all cards in play of a given color * @return a CardList of all cards in play of a given color
*/ */
public static CardList getColorInPlay(final String color) { public static CardList getColorInPlay(final String color) {
@@ -173,10 +186,13 @@ public abstract class AllZoneUtil {
} }
/** /**
* gets a list of all Cards of a given color a given player has on the battlefield. * gets a list of all Cards of a given color a given player has on the
* battlefield.
* *
* @param player the player's cards to get * @param player
* @param color the color of cards to get * the player's cards to get
* @param color
* the color of cards to get
* @return a CardList of all cards in play of a given color * @return a CardList of all cards in play of a given color
*/ */
public static CardList getPlayerColorInPlay(final Player player, final String color) { public static CardList getPlayerColorInPlay(final Player player, final String color) {
@@ -191,9 +207,12 @@ public abstract class AllZoneUtil {
} }
/** /**
* <p>getCardState.</p> * <p>
* getCardState.
* </p>
* *
* @param card a {@link forge.Card} object. * @param card
* a {@link forge.Card} object.
* @return a {@link forge.Card} object. * @return a {@link forge.Card} object.
*/ */
public static Card getCardState(final Card card) { public static Card getCardState(final Card card) {
@@ -208,10 +227,14 @@ public abstract class AllZoneUtil {
} }
/** /**
* <p>compareTypeAmountInPlay.</p> * <p>
* compareTypeAmountInPlay.
* </p>
* *
* @param player a {@link forge.Player} object. * @param player
* @param type a {@link java.lang.String} object. * a {@link forge.Player} object.
* @param type
* a {@link java.lang.String} object.
* @return a int. * @return a int.
*/ */
public static int compareTypeAmountInPlay(final Player player, final String type) { public static int compareTypeAmountInPlay(final Player player, final String type) {
@@ -223,10 +246,14 @@ public abstract class AllZoneUtil {
} }
/** /**
* <p>compareTypeAmountInGraveyard.</p> * <p>
* compareTypeAmountInGraveyard.
* </p>
* *
* @param player a {@link forge.Player} object. * @param player
* @param type a {@link java.lang.String} object. * a {@link forge.Player} object.
* @param type
* a {@link java.lang.String} object.
* @return a int. * @return a int.
*/ */
public static int compareTypeAmountInGraveyard(final Player player, final String type) { public static int compareTypeAmountInGraveyard(final Player player, final String type) {
@@ -237,51 +264,71 @@ public abstract class AllZoneUtil {
return (playerList.size() - opponentList.size()); return (playerList.size() - opponentList.size());
} }
/** /**
* a CardListFilter to get all cards that are a part of this game. * a CardListFilter to get all cards that are a part of this game.
* *
* @return a {@link forge.CardList} with all cards in all Battlefields, Hands, Graveyards, Libraries, and Exiles. * @return a {@link forge.CardList} with all cards in all Battlefields,
* Hands, Graveyards, Libraries, and Exiles.
*/ */
public static CardList getCardsInGame() { public static CardList getCardsInGame() {
CardList all = new CardList(); CardList all = new CardList();
for (Player player : AllZone.getPlayersInGame()) { for (Player player : AllZone.getPlayersInGame()) {
all.addAll(player.getZone(Zone.Graveyard).getCards()); all.addAll(player.getZone(Zone.Graveyard).getCards());
all.addAll(player.getZone(Zone.Hand).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.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()); all.addAll(AllZone.getStackZone().getCards());
return all; return all;
} }
/** /**
* <p>getDoublingSeasonMagnitude.</p> * <p>
* getDoublingSeasonMagnitude.
* </p>
* *
* @param player the {@link forge.Player} player to determine if is affected by Doubling Season * @param player
* the {@link forge.Player} player to determine if is affected by
* Doubling Season
* @return a int. * @return a int.
*/ */
public static int getDoublingSeasonMagnitude(final Player player) { public static int getDoublingSeasonMagnitude(final Player player) {
int doublingSeasons = player.getCardsIn(Zone.Battlefield, "Doubling Season").size(); 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
} }
/** /**
* <p>getTokenDoublersMagnitude.</p> * <p>
* getTokenDoublersMagnitude.
* </p>
* *
* @param player the {@link forge.Player} player to determine if is affected by Doubling Season * @param player
* the {@link forge.Player} player to determine if is affected by
* Doubling Season
* @return a int. * @return a int.
*/ */
public static int getTokenDoublersMagnitude(final Player player) { public static int getTokenDoublersMagnitude(final Player player) {
int tokenDoublers = player.getCardsIn(Zone.Battlefield, "Parallel Lives").size() + player.getCardsIn(Zone.Battlefield,"Doubling Season").size(); int tokenDoublers = player.getCardsIn(Zone.Battlefield, "Parallel Lives").size()
return (int) Math.pow(2, tokenDoublers); // pow(a,0) = 1; pow(a,1) = a ... no worries about size = 0 + 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. * gets a list of all opponents of a given player.
* *
* @param p the player whose opponents to get * @param p
* the player whose opponents to get
* @return a list of all opponents * @return a list of all opponents
*/ */
public static ArrayList<Player> getOpponents(final Player p) { public static ArrayList<Player> getOpponents(final Player p) {
@@ -291,11 +338,16 @@ public abstract class AllZoneUtil {
} }
/** /**
* <p>compare.</p> * <p>
* compare.
* </p>
* *
* @param leftSide a int. * @param leftSide
* @param comp a {@link java.lang.String} object. * a int.
* @param rightSide a int. * @param comp
* a {@link java.lang.String} object.
* @param rightSide
* a int.
* @return a boolean. * @return a boolean.
* @since 1.0.15 * @since 1.0.15
*/ */

View File

@@ -19,95 +19,128 @@ package forge;
* A Base64 encoder/decoder. * A Base64 encoder/decoder.
* <p/> * <p/>
* <p/> * <p/>
* 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.
* <p/> * <p/>
* <p/> * <p/>
* Project home page: <a href="http://www.source-code.biz/base64coder/java/">www.source-code.biz/base64coder/java</a><br> * Project home page: <a
* href="http://www.source-code.biz/base64coder/java/">www.
* source-code.biz/base64coder/java</a><br>
* Author: Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland<br> * Author: Christian d'Heureuse, Inventec Informatik AG, Zurich, Switzerland<br>
* Multi-licensed: EPL / LGPL / GPL / AL / BSD. * Multi-licensed: EPL / LGPL / GPL / AL / BSD.
* *
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class Base64Coder { public final class Base64Coder {
// The line separator string of the operating system. // The line separator string of the operating system.
/** Constant <code>systemLineSeparator="System.getProperty(line.separator)"</code> */ /**
* Constant.
* <code>systemLineSeparator="System.getProperty(line.separator)"</code>
*/
private static final String systemLineSeparator = System.getProperty("line.separator"); private static final String systemLineSeparator = System.getProperty("line.separator");
// Mapping table from 6-bit nibbles to Base64 characters. // Mapping table from 6-bit nibbles to Base64 characters.
/** Constant <code>map1=new char[64]</code> */ /** Constant <code>map1=new char[64]</code>. */
private static char[] map1 = new char[64]; private static char[] map1 = new char[64];
static { static {
int i = 0; int i = 0;
for (char c = 'A'; c <= 'Z'; c++) map1[i++] = c; for (char c = 'A'; c <= 'Z'; c++) {
for (char c = 'a'; c <= 'z'; c++) map1[i++] = 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 = '0'; c <= '9'; c++) {
map1[i++] = c;
}
map1[i++] = '+'; map1[i++] = '+';
map1[i++] = '/'; map1[i++] = '/';
} }
// Mapping table from Base64 characters to 6-bit nibbles. // Mapping table from Base64 characters to 6-bit nibbles.
/** Constant <code>map2=new byte[128]</code> */ /** Constant <code>map2=new byte[128]</code>. */
private static byte[] map2 = new byte[128]; private static byte[] map2 = new byte[128];
static { static {
for (int i = 0; i < map2.length; i++) map2[i] = -1; for (int i = 0; i < map2.length; i++) {
for (int i = 0; i < 64; i++) map2[map1[i]] = (byte) i; map2[i] = -1;
}
for (int i = 0; i < 64; i++) {
map2[map1[i]] = (byte) i;
}
} }
/** /**
* Encodes a string into Base64 format. * Encodes a string into Base64 format. No blanks or line breaks are
* No blanks or line breaks are inserted. * inserted.
* *
* @param s A String to be encoded. * @param s
* A String to be encoded.
* @return A String containing the Base64 encoded data. * @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())); return new String(encode(s.getBytes()));
} }
/** /**
* <p>encodeString.</p> * <p>
* encodeString.
* </p>
* *
* @param s a {@link java.lang.String} object. * @param s
* @param noPad a boolean. * a {@link java.lang.String} object.
* @param noPad
* a boolean.
* @return a {@link java.lang.String} object. * @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())); String t = new String(encode(s.getBytes()));
if (noPad) if (noPad) {
t = t.replace("=", ""); t = t.replace("=", "");
}
return t; return t;
} }
/** /**
* Encodes a byte array into Base 64 format and breaks the output into lines of 76 characters. * Encodes a byte array into Base 64 format and breaks the output into lines
* This method is compatible with <code>sun.misc.BASE64Encoder.encodeBuffer(byte[])</code>. * of 76 characters. This method is compatible with
* <code>sun.misc.BASE64Encoder.encodeBuffer(byte[])</code>.
* *
* @param in An array containing the data bytes to be encoded. * @param in
* An array containing the data bytes to be encoded.
* @return A String containing the Base64 encoded data, broken into lines. * @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); return encodeLines(in, 0, in.length, 76, systemLineSeparator);
} }
/** /**
* Encodes a byte array into Base 64 format and breaks the output into 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 in
* @param iOff Offset of the first byte in <code>in</code> to be processed. * An array containing the data bytes to be encoded.
* @param iLen Number of bytes to be processed in <code>in</code>, starting at <code>iOff</code>. * @param iOff
* @param lineLen Line length for the output data. Should be a multiple of 4. * Offset of the first byte in <code>in</code> to be processed.
* @param lineSeparator The line separator to be used to separate the output lines. * @param iLen
* Number of bytes to be processed in <code>in</code>, starting
* at <code>iOff</code>.
* @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. * @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; int blockLen = (lineLen * 3) / 4;
if (blockLen <= 0) throw new IllegalArgumentException(); if (blockLen <= 0) {
throw new IllegalArgumentException();
}
int lines = (iLen + blockLen - 1) / blockLen; int lines = (iLen + blockLen - 1) / blockLen;
int bufLen = ((iLen + 2) / 3) * 4 + lines * lineSeparator.length(); int bufLen = ((iLen + 2) / 3) * 4 + lines * lineSeparator.length();
StringBuilder buf = new StringBuilder(bufLen); StringBuilder buf = new StringBuilder(bufLen);
@@ -122,38 +155,45 @@ public class Base64Coder {
} }
/** /**
* Encodes a byte array into Base64 format. * Encodes a byte array into Base64 format. No blanks or line breaks are
* No blanks or line breaks are inserted in the output. * inserted in the output.
* *
* @param in An array containing the data bytes to be encoded. * @param in
* An array containing the data bytes to be encoded.
* @return A character array containing the Base64 encoded data. * @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); return encode(in, 0, in.length);
} }
/** /**
* Encodes a byte array into Base64 format. * Encodes a byte array into Base64 format. No blanks or line breaks are
* No blanks or line breaks are inserted in the output. * inserted in the output.
* *
* @param in An array containing the data bytes to be encoded. * @param in
* @param iLen Number of bytes to process in <code>in</code>. * An array containing the data bytes to be encoded.
* @param iLen
* Number of bytes to process in <code>in</code>.
* @return A character array containing the Base64 encoded data. * @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); return encode(in, 0, iLen);
} }
/** /**
* Encodes a byte array into Base64 format. * Encodes a byte array into Base64 format. No blanks or line breaks are
* No blanks or line breaks are inserted in the output. * inserted in the output.
* *
* @param in An array containing the data bytes to be encoded. * @param in
* @param iOff Offset of the first byte in <code>in</code> to be processed. * An array containing the data bytes to be encoded.
* @param iLen Number of bytes to process in <code>in</code>, starting at <code>iOff</code>. * @param iOff
* Offset of the first byte in <code>in</code> to be processed.
* @param iLen
* Number of bytes to process in <code>in</code>, starting at
* <code>iOff</code>.
* @return A character array containing the Base64 encoded data. * @return A character array containing the Base64 encoded data.
*/ */
public static char[] encode(byte[] in, int iOff, int iLen) { public static char[] encode(final byte[] in, final int iOff, final int iLen) {
int oDataLen = (iLen * 4 + 2) / 3; // output length without padding int oDataLen = (iLen * 4 + 2) / 3; // output length without padding
int oLen = ((iLen + 2) / 3) * 4; // output length including padding int oLen = ((iLen + 2) / 3) * 4; // output length including padding
char[] out = new char[oLen]; char[] out = new char[oLen];
@@ -179,75 +219,94 @@ public class Base64Coder {
} }
/** /**
* Decodes a string from Base64 format. * Decodes a string from Base64 format. No blanks or line breaks are allowed
* No blanks or line breaks are allowed within the Base64 encoded input data. * within the Base64 encoded input data.
* *
* @param s A Base64 String to be decoded. * @param s
* A Base64 String to be decoded.
* @return A String containing the decoded data. * @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)); return new String(decode(s));
} }
/** /**
* Decodes a byte array from Base64 format and ignores line separators, tabs and blanks. * Decodes a byte array from Base64 format and ignores line separators, tabs
* CR, LF, Tab and Space characters are ignored in the input data. * and blanks. CR, LF, Tab and Space characters are ignored in the input
* This method is compatible with <code>sun.misc.BASE64Decoder.decodeBuffer(String)</code>. * data. This method is compatible with
* <code>sun.misc.BASE64Decoder.decodeBuffer(String)</code>.
* *
* @param s A Base64 String to be decoded. * @param s
* A Base64 String to be decoded.
* @return An array containing the decoded data bytes. * @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()]; char[] buf = new char[s.length()];
int p = 0; int p = 0;
for (int ip = 0; ip < s.length(); ip++) { for (int ip = 0; ip < s.length(); ip++) {
char c = s.charAt(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; buf[p++] = c;
} }
}
return decode(buf, 0, p); return decode(buf, 0, p);
} }
/** /**
* Decodes a byte array from Base64 format. * Decodes a byte array from Base64 format. No blanks or line breaks are
* No blanks or line breaks are allowed within the Base64 encoded input data. * allowed within the Base64 encoded input data.
* *
* @param s A Base64 String to be decoded. * @param s
* A Base64 String to be decoded.
* @return An array containing the decoded data bytes. * @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()); return decode(s.toCharArray());
} }
/** /**
* Decodes a byte array from Base64 format. * Decodes a byte array from Base64 format. No blanks or line breaks are
* No blanks or line breaks are allowed within the Base64 encoded input data. * allowed within the Base64 encoded input data.
* *
* @param in A character array containing the Base64 encoded data. * @param in
* A character array containing the Base64 encoded data.
* @return An array containing the decoded data bytes. * @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); return decode(in, 0, in.length);
} }
/** /**
* Decodes a byte array from Base64 format. * Decodes a byte array from Base64 format. No blanks or line breaks are
* No blanks or line breaks are allowed within the Base64 encoded input data. * allowed within the Base64 encoded input data.
* *
* @param in A character array containing the Base64 encoded data. * @param in
* @param iOff Offset of the first character in <code>in</code> to be processed. * A character array containing the Base64 encoded data.
* @param iLen Number of characters to process in <code>in</code>, starting at <code>iOff</code>. * @param iOff
* Offset of the first character in <code>in</code> to be
* processed.
* @param iLen
* Number of characters to process in <code>in</code>, starting
* at <code>iOff</code>.
* @return An array containing the decoded data bytes. * @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) { public static byte[] decode(final char[] in, final int iOff, int iLen) {
if (iLen % 4 != 0) if (iLen % 4 != 0) {
throw new IllegalArgumentException("Length of Base64 encoded input string is not a multiple of 4."); 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; int oLen = (iLen * 3) / 4;
byte[] out = new byte[oLen]; byte[] out = new byte[oLen];
int ip = iOff; int ip = iOff;
@@ -258,27 +317,35 @@ public class Base64Coder {
int i1 = in[ip++]; int i1 = in[ip++];
int i2 = ip < iEnd ? in[ip++] : 'A'; int i2 = ip < iEnd ? in[ip++] : 'A';
int i3 = 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."); throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
}
int b0 = map2[i0]; int b0 = map2[i0];
int b1 = map2[i1]; int b1 = map2[i1];
int b2 = map2[i2]; int b2 = map2[i2];
int b3 = map2[i3]; 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."); throw new IllegalArgumentException("Illegal character in Base64 encoded data.");
}
int o0 = (b0 << 2) | (b1 >>> 4); int o0 = (b0 << 2) | (b1 >>> 4);
int o1 = ((b1 & 0xf) << 4) | (b2 >>> 2); int o1 = ((b1 & 0xf) << 4) | (b2 >>> 2);
int o2 = ((b2 & 3) << 6) | b3; int o2 = ((b2 & 3) << 6) | b3;
out[op++] = (byte) o0; out[op++] = (byte) o0;
if (op < oLen) out[op++] = (byte) o1; if (op < oLen) {
if (op < oLen) out[op++] = (byte) o2; out[op++] = (byte) o1;
}
if (op < oLen) {
out[op++] = (byte) o2;
}
} }
return out; return out;
} }
// Dummy constructor. // Dummy constructor.
/** /**
* <p>Constructor for Base64Coder.</p> * <p>
* Constructor for Base64Coder.
* </p>
*/ */
private Base64Coder() { private Base64Coder() {
} }

View File

@@ -1,14 +1,18 @@
package forge; package forge;
/** /**
* <p>ButtonUtil class.</p> * <p>
* ButtonUtil class.
* </p>
* *
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class ButtonUtil { public class ButtonUtil {
/** /**
* <p>reset.</p> * <p>
* reset.
* </p>
*/ */
public static void reset() { public static void reset() {
getOK().setText("OK"); getOK().setText("OK");
@@ -19,7 +23,9 @@ public class ButtonUtil {
} }
/** /**
* <p>enableOnlyOK.</p> * <p>
* enableOnlyOK.
* </p>
*/ */
public static void enableOnlyOK() { public static void enableOnlyOK() {
getOK().setSelectable(true); getOK().setSelectable(true);
@@ -27,7 +33,9 @@ public class ButtonUtil {
} }
/** /**
* <p>enableOnlyCancel.</p> * <p>
* enableOnlyCancel.
* </p>
*/ */
public static void enableOnlyCancel() { public static void enableOnlyCancel() {
getOK().setSelectable(false); getOK().setSelectable(false);
@@ -35,7 +43,9 @@ public class ButtonUtil {
} }
/** /**
* <p>disableAll.</p> * <p>
* disableAll.
* </p>
*/ */
public static void disableAll() { public static void disableAll() {
getOK().setSelectable(false); getOK().setSelectable(false);
@@ -43,7 +53,9 @@ public class ButtonUtil {
} }
/** /**
* <p>enableAll.</p> * <p>
* enableAll.
* </p>
*/ */
public static void enableAll() { public static void enableAll() {
getOK().setSelectable(true); getOK().setSelectable(true);
@@ -51,21 +63,27 @@ public class ButtonUtil {
} }
/** /**
* <p>disableOK.</p> * <p>
* disableOK.
* </p>
*/ */
public static void disableOK() { public static void disableOK() {
getOK().setSelectable(false); getOK().setSelectable(false);
} }
/** /**
* <p>disableCancel.</p> * <p>
* disableCancel.
* </p>
*/ */
public static void disableCancel() { public static void disableCancel() {
getCancel().setSelectable(false); getCancel().setSelectable(false);
} }
/** /**
* <p>getOK.</p> * <p>
* getOK.
* </p>
* *
* @return a {@link forge.MyButton} object. * @return a {@link forge.MyButton} object.
*/ */
@@ -74,7 +92,9 @@ public class ButtonUtil {
} }
/** /**
* <p>getCancel.</p> * <p>
* getCancel.
* </p>
* *
* @return a {@link forge.MyButton} object. * @return a {@link forge.MyButton} object.
*/ */

View File

@@ -1,23 +1,28 @@
package forge; package forge;
import forge.card.mana.ManaCost;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.EnumSet; import java.util.EnumSet;
import forge.card.mana.ManaCost;
/** /**
* <p>Card_Color class.</p> * <p>
* Card_Color class.
* </p>
* *
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class Card_Color { 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 EnumSet<Color> col; private EnumSet<Color> col;
private boolean additional; private boolean additional;
/** /**
* <p>Getter for the field <code>additional</code>.</p> * <p>
* Getter for the field <code>additional</code>.
* </p>
* *
* @return a boolean. * @return a boolean.
*/ */
@@ -29,7 +34,9 @@ public class Card_Color {
private long stamp = 0; private long stamp = 0;
/** /**
* <p>Getter for the field <code>stamp</code>.</p> * <p>
* Getter for the field <code>stamp</code>.
* </p>
* *
* @return a long. * @return a long.
*/ */
@@ -43,7 +50,9 @@ public class Card_Color {
private static long timeStamp = 0; private static long timeStamp = 0;
/** /**
* <p>getTimestamp.</p> * <p>
* getTimestamp.
* </p>
* *
* @return a long. * @return a long.
*/ */
@@ -52,12 +61,18 @@ public class Card_Color {
} }
/** /**
* <p>Constructor for Card_Color.</p> * <p>
* Constructor for Card_Color.
* </p>
* *
* @param mc a {@link forge.card.mana.ManaCost} object. * @param mc
* @param c a {@link forge.Card} object. * a {@link forge.card.mana.ManaCost} object.
* @param addToColors a boolean. * @param c
* @param baseColor a boolean. * 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) { Card_Color(final ManaCost mc, final Card c, final boolean addToColors, final boolean baseColor) {
additional = addToColors; additional = addToColors;
@@ -71,9 +86,12 @@ public class Card_Color {
} }
/** /**
* <p>Constructor for Card_Color.</p> * <p>
* Constructor for Card_Color.
* </p>
* *
* @param c a {@link forge.Card} object. * @param c
* a {@link forge.Card} object.
*/ */
public Card_Color(final Card c) { public Card_Color(final Card c) {
col = Color.Colorless(); col = Color.Colorless();
@@ -83,9 +101,12 @@ public class Card_Color {
} }
/** /**
* <p>addToCardColor.</p> * <p>
* addToCardColor.
* </p>
* *
* @param s a {@link java.lang.String} object. * @param s
* a {@link java.lang.String} object.
* @return a boolean. * @return a boolean.
*/ */
final boolean addToCardColor(final String s) { final boolean addToCardColor(final String s) {
@@ -98,7 +119,9 @@ public class Card_Color {
} }
/** /**
* <p>fixColorless.</p> * <p>
* fixColorless.
* </p>
*/ */
final void fixColorless() { final void fixColorless() {
if (col.size() > 1 && col.contains(Color.Colorless)) { if (col.size() > 1 && col.contains(Color.Colorless)) {
@@ -107,19 +130,27 @@ public class Card_Color {
} }
/** /**
* <p>increaseTimestamp.</p> * <p>
* increaseTimestamp.
* </p>
*/ */
static void increaseTimestamp() { static void increaseTimestamp() {
timeStamp++; timeStamp++;
} }
/** /**
* <p>equals.</p> * <p>
* equals.
* </p>
* *
* @param cost a {@link java.lang.String} object. * @param cost
* @param c a {@link forge.Card} object. * a {@link java.lang.String} object.
* @param addToColors a boolean. * @param c
* @param time a long. * a {@link forge.Card} object.
* @param addToColors
* a boolean.
* @param time
* a long.
* @return a boolean. * @return a boolean.
*/ */
public final boolean equals(final String cost, final Card c, final boolean addToColors, final long time) { public final boolean equals(final String cost, final Card c, final boolean addToColors, final long time) {
@@ -127,7 +158,9 @@ public class Card_Color {
} }
/** /**
* <p>toStringArray.</p> * <p>
* toStringArray.
* </p>
* *
* @return a {@link java.util.ArrayList} object. * @return a {@link java.util.ArrayList} object.
*/ */

View File

@@ -2,9 +2,10 @@ package forge;
import java.util.ArrayList; import java.util.ArrayList;
/** /**
* <p>Card_Keywords class.</p> * <p>
* Card_Keywords class.
* </p>
* *
* @author Forge * @author Forge
* @version $Id: Card_Keywords.java 10217 2011-09-04 10:14:19Z Sloth $ * @version $Id: Card_Keywords.java 10217 2011-09-04 10:14:19Z Sloth $
@@ -17,7 +18,9 @@ public class Card_Keywords implements Comparable<Card_Keywords>{
private long timeStamp = 0; private long timeStamp = 0;
/** /**
* <p>getTimestamp.</p> * <p>
* getTimestamp.
* </p>
* *
* @return a long. * @return a long.
*/ */
@@ -25,22 +28,46 @@ public class Card_Keywords implements Comparable<Card_Keywords>{
return timeStamp; return timeStamp;
} }
Card_Keywords(final ArrayList<String> keywordList, final ArrayList<String> removeKeywordList, final boolean removeAll, /**
final long stamp) { *
* Card_Keywords.
* @param keywordList an ArrayList<String>
* @param removeKeywordList a ArrayList<String>
* @param removeAll a boolean
* @param stamp a long
*/
Card_Keywords(final ArrayList<String> keywordList, final ArrayList<String> removeKeywordList,
final boolean removeAll, final long stamp)
{
keywords = keywordList; keywords = keywordList;
removeKeywords = removeKeywordList; removeKeywords = removeKeywordList;
removeAllKeywords = removeAll; removeAllKeywords = removeAll;
timeStamp = stamp; timeStamp = stamp;
} }
/**
*
* getKeywords.
* @return ArrayList<String>
*/
public final ArrayList<String> getKeywords() { public final ArrayList<String> getKeywords() {
return keywords; return keywords;
} }
/**
*
* getRemoveKeywords.
* @return ArrayList<String>
*/
public final ArrayList<String> getRemoveKeywords() { public final ArrayList<String> getRemoveKeywords() {
return removeKeywords; return removeKeywords;
} }
/**
*
* isRemoveAllKeywords.
* @return boolean
*/
public final boolean isRemoveAllKeywords() { public final boolean isRemoveAllKeywords() {
return removeAllKeywords; return removeAllKeywords;
} }

View File

@@ -32,13 +32,15 @@ public class Card_Type implements Comparable<Card_Type> {
* *
* @param types an ArrayList<String> * @param types an ArrayList<String>
* @param removeSuperType a boolean * @param removeSuperType a boolean
* @param removeTypes an ArrayList<String>
* @param removeCardType a boolean * @param removeCardType a boolean
* @param removeSubType a boolean * @param removeSubType a boolean
* @param removeCreatureType a boolean * @param removeCreatureType a boolean
* @param stamp a long * @param stamp a long
*/ */
Card_Type(final ArrayList<String> types, final ArrayList<String> removeTypes, final boolean removeSuperType, Card_Type(final ArrayList<String> types, final ArrayList<String> removeTypes, final boolean removeSuperType,
final boolean removeCardType, final boolean removeSubType, final boolean removeCreatureType, final long stamp) final boolean removeCardType, final boolean removeSubType,
final boolean removeCreatureType, final long stamp)
{ {
type = types; type = types;
removeType = removeTypes; removeType = removeTypes;
@@ -51,7 +53,7 @@ public class Card_Type implements Comparable<Card_Type> {
/** /**
* *
* Write javadoc for this method. * getType.
* @return type * @return type
*/ */
public final ArrayList<String> getType() { public final ArrayList<String> getType() {
@@ -60,7 +62,7 @@ public class Card_Type implements Comparable<Card_Type> {
/** /**
* *
* Write javadoc for this method. * getRemoveType.
* @return removeType * @return removeType
*/ */
public final ArrayList<String> getRemoveType() { public final ArrayList<String> getRemoveType() {
@@ -69,7 +71,7 @@ public class Card_Type implements Comparable<Card_Type> {
/** /**
* *
* Write javadoc for this method. * isRemoveSuperTypes.
* @return removeSuperTypes * @return removeSuperTypes
*/ */
public final boolean isRemoveSuperTypes() { public final boolean isRemoveSuperTypes() {
@@ -78,7 +80,7 @@ public class Card_Type implements Comparable<Card_Type> {
/** /**
* *
* Write javadoc for this method. * isRemoveCardTypes.
* @return removeCardTypes * @return removeCardTypes
*/ */
public final boolean isRemoveCardTypes() { public final boolean isRemoveCardTypes() {
@@ -87,7 +89,7 @@ public class Card_Type implements Comparable<Card_Type> {
/** /**
* *
* Write javadoc for this method. * isRemoveSubTypes.
* @return removeSubTypes * @return removeSubTypes
*/ */
public final boolean isRemoveSubTypes() { public final boolean isRemoveSubTypes() {
@@ -96,7 +98,7 @@ public class Card_Type implements Comparable<Card_Type> {
/** /**
* *
* Write javadoc for this method. * isRemoveCreatureTypes.
* @return removeCreatureTypes * @return removeCreatureTypes
*/ */
public final boolean isRemoveCreatureTypes() { public final boolean isRemoveCreatureTypes() {