Reduced CheckStyle violations in src/main/java/forge/AllZone.java.

This commit is contained in:
Braids
2011-08-29 16:31:21 +00:00
parent fd25e38c9e
commit 119398c5a5

View File

@@ -1,6 +1,10 @@
package forge; package forge;
import java.util.Iterator;
import java.util.Map;
import net.slightlymagic.braids.util.UtilFunctions;
import forge.card.cardFactory.CardFactoryInterface; import forge.card.cardFactory.CardFactoryInterface;
import forge.card.cardFactory.PreloadingCardFactory; import forge.card.cardFactory.PreloadingCardFactory;
import forge.card.mana.ManaPool; import forge.card.mana.ManaPool;
@@ -9,16 +13,10 @@ import forge.deck.DeckManager;
import forge.game.GameSummary; import forge.game.GameSummary;
import forge.gui.input.InputControl; import forge.gui.input.InputControl;
import forge.model.FGameState; import forge.model.FGameState;
import forge.model.FModel;
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.QuestMatchState;
import forge.quest.data.QuestData;
import java.util.Iterator;
import java.util.Map;
import net.slightlymagic.braids.util.UtilFunctions;
/** /**
* Please use public getters and setters instead of direct field access. * Please use public getters and setters instead of direct field access.
@@ -28,44 +26,59 @@ import net.slightlymagic.braids.util.UtilFunctions;
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class AllZone implements NewConstants { public final class AllZone implements NewConstants {
//only for testing, should read decks from local directory //only for testing, should read decks from local directory
// public static final IO IO = new IO("all-decks"); // public static final IO IO = new IO("all-decks");
/**
* Do not instantiate.
*/
private AllZone() {
// blank
}
/** Constant <code>QuestData</code> */ /** Global <code>questData</code>. */
private static forge.quest.data.QuestData QuestData = null; private static forge.quest.data.QuestData questData = null;
/** Constant <code>QuestAssignment</code> */
private static Quest_Assignment QuestAssignment = null; /** Global <code>QuestAssignment</code>. */
/** Constant <code>NameChanger</code> */ private static Quest_Assignment questAssignment = null;
private static final NameChanger NameChanger = new NameChanger();
/** Constant <code>ColorChanger</code> */ /** Constant <code>NAME_CHANGER</code>. */
private static final ColorChanger colorChanger = new ColorChanger(); private static final NameChanger NAME_CHANGER = new NameChanger();
/** Constant <code>COLOR_CHANGER</code>. */
private static final ColorChanger COLOR_CHANGER = new ColorChanger();
// Phase is now a prerequisite for CardFactory // Phase is now a prerequisite for CardFactory
/** Constant <code>CardFactory</code> */ /** Global <code>cardFactory</code>. */
private static CardFactoryInterface cardFactory = null; private static CardFactoryInterface cardFactory = null;
/** Constant <code>InputControl</code> */ /** Constant <code>inputControl</code>. */
private static final InputControl InputControl = new InputControl(); private static final InputControl INPUT_CONTROL = new InputControl();
/** Game state observer <code>GameSummary</code> collects statistics and players' performance*/ /** Game state observer <code>gameInfo</code> collects statistics and players' performance. */
private static GameSummary gameInfo = new GameSummary(); private static GameSummary gameInfo = new GameSummary();
/** Match State for quests are stored in a <code>QuestMatchState</code> class instance*/
/**
* Match State for quests are stored in a <code>QuestMatchState</code> class instance.
*
* @deprecated Variable 'matchState' must be private and have accessor methods.
*/
public static QuestMatchState matchState = new QuestMatchState(); public 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
/** Constant <code>Computer</code> */ /** Global <code>computer</code>. */
private static ComputerAI_Input Computer; private static ComputerAI_Input computer;
//shared between Input_Attack, Input_Block, Input_CombatDamage , InputState_Computer //shared between Input_Attack, Input_Block, Input_CombatDamage , InputState_Computer
/** Constant <code>Display</code> */ /** Global <code>display</code>. */
private static Display Display; private static Display display;
/** Constant <code>DeckManager</code> */ /** Constant <code>DECK_MGR</code>. */
private final static DeckManager dMgr = new DeckManager(ForgeProps.getFile(NEW_DECKS)); private static final DeckManager DECK_MGR = new DeckManager(ForgeProps.getFile(NEW_DECKS));
/** /**
* <p>getHumanPlayer.</p> * <p>getHumanPlayer.</p>
@@ -104,17 +117,17 @@ public class AllZone implements NewConstants {
* @since 1.0.15 * @since 1.0.15
*/ */
public static forge.quest.data.QuestData getQuestData() { public static forge.quest.data.QuestData getQuestData() {
return QuestData; return questData;
} }
/** /**
* <p>setQuestData.</p> * <p>setQuestData.</p>
* *
* @param questData 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(forge.quest.data.QuestData questData) { public static void setQuestData(final QuestData questData0) {
QuestData = questData; questData = questData0;
} }
/** /**
@@ -124,7 +137,7 @@ public class AllZone implements NewConstants {
* @since 1.0.15 * @since 1.0.15
*/ */
public static Quest_Assignment getQuestAssignment() { public static Quest_Assignment getQuestAssignment() {
return QuestAssignment; return questAssignment;
} }
/** /**
@@ -133,8 +146,8 @@ public class AllZone implements NewConstants {
* @param assignment a {@link forge.Quest_Assignment} object. * @param assignment a {@link forge.Quest_Assignment} object.
* @since 1.0.15 * @since 1.0.15
*/ */
public static void setQuestAssignment(Quest_Assignment assignment) { public static void setQuestAssignment(final Quest_Assignment assignment) {
QuestAssignment = assignment; questAssignment = assignment;
} }
/** /**
@@ -144,7 +157,7 @@ public class AllZone implements NewConstants {
* @since 1.0.15 * @since 1.0.15
*/ */
public static NameChanger getNameChanger() { public static NameChanger getNameChanger() {
return NameChanger; return NAME_CHANGER;
} }
/** /**
@@ -208,18 +221,22 @@ public class AllZone implements NewConstants {
* @since 1.0.15 * @since 1.0.15
*/ */
public static CardFactoryInterface getCardFactory() { public static CardFactoryInterface getCardFactory() {
if (cardFactory == null) { if (cardFactory == null) {
setCardFactory(new PreloadingCardFactory(ForgeProps.getFile(CARDSFOLDER))); setCardFactory(new PreloadingCardFactory(ForgeProps.getFile(CARDSFOLDER)));
} }
return cardFactory; return cardFactory;
} }
public static void setCardFactory(CardFactoryInterface factory) { /**
UtilFunctions.checkNotNull("factory", factory); * Setter for cardFactory.
cardFactory = factory; * @param factory the factory to set
} */
public static void setCardFactory(final CardFactoryInterface factory) {
UtilFunctions.checkNotNull("factory", factory);
cardFactory = factory;
}
/** /**
* <p>getStack.</p> * <p>getStack.</p>
* *
* Will eventually be marked deprecated. * Will eventually be marked deprecated.
@@ -244,7 +261,7 @@ public class AllZone implements NewConstants {
* @since 1.0.15 * @since 1.0.15
*/ */
public static InputControl getInputControl() { public static InputControl getInputControl() {
return InputControl; return INPUT_CONTROL;
} }
/** /**
@@ -312,7 +329,7 @@ public class AllZone implements NewConstants {
* @since 1.0.15 * @since 1.0.15
*/ */
public static ComputerAI_Input getComputer() { public static ComputerAI_Input getComputer() {
return Computer; return computer;
} }
/** /**
@@ -321,8 +338,8 @@ public class AllZone implements NewConstants {
* @param input a {@link forge.ComputerAI_Input} object. * @param input a {@link forge.ComputerAI_Input} object.
* @since 1.0.15 * @since 1.0.15
*/ */
public static void setComputer(ComputerAI_Input input) { public static void setComputer(final ComputerAI_Input input) {
Computer = input; computer = input;
} }
/** /**
@@ -345,11 +362,10 @@ public class AllZone implements NewConstants {
* @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(Combat attackers) { public static void setCombat(final Combat attackers) {
Singletons.getModel().getGameState().setCombat(attackers); Singletons.getModel().getGameState().setCombat(attackers);
} }
//Human_Play, Computer_Play is different because Card.comesIntoPlay() is called when a card is added by PlayerZone.add(Card)
/** /**
* <p>getHumanBattlefield.</p> * <p>getHumanBattlefield.</p>
* *
@@ -523,7 +539,7 @@ public class AllZone implements NewConstants {
* @since 1.0.15 * @since 1.0.15
*/ */
public static ManaPool getComputerManaPool() { public static ManaPool getComputerManaPool() {
return AllZone.getComputerPlayer().getManaPool(); return AllZone.getComputerPlayer().getManaPool();
} }
/** /**
@@ -533,17 +549,17 @@ public class AllZone implements NewConstants {
* @since 1.0.15 * @since 1.0.15
*/ */
public static Display getDisplay() { public static Display getDisplay() {
return Display; return display;
} }
/** /**
* <p>setDisplay.</p> * <p>setDisplay.</p>
* *
* @param display a {@link forge.Display} object. * @param display0 a {@link forge.Display} object.
* @since 1.0.15 * @since 1.0.15
*/ */
public static void setDisplay(Display display) { public static void setDisplay(final Display display0) {
Display = display; display = display0;
} }
/** /**
@@ -563,14 +579,15 @@ public class AllZone implements NewConstants {
* @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 getZone(Card c) { public static PlayerZone getZone(final Card c) {
Iterator<PlayerZone> it = getMap().values().iterator(); Iterator<PlayerZone> it = getMap().values().iterator();
PlayerZone p; PlayerZone p;
while (it.hasNext()) { while (it.hasNext()) {
p = (PlayerZone) it.next(); p = (PlayerZone) it.next();
if (AllZoneUtil.isCardInZone(p, c)) if (AllZoneUtil.isCardInZone(p, c)) {
return p; return p;
}
} }
return null; return null;
} }
@@ -579,14 +596,23 @@ public class AllZone implements NewConstants {
* <p>getZone.</p> * <p>getZone.</p>
* *
* @param zone a {@link java.lang.String} object. * @param zone a {@link java.lang.String} object.
* @param player a {@link forge.Player} object. * @param finalPlayer a {@link forge.Player} object.
* @return a {@link forge.PlayerZone} object. * @return a {@link forge.PlayerZone} object.
*/ */
public static PlayerZone getZone(String zone, Player player) { public static PlayerZone getZone(final String zone, final Player finalPlayer) {
if (zone.equals("Stack")) player = null; Player player;
if (zone.equals("Stack")) {
player = null;
}
else {
player = finalPlayer;
}
Object o = getMap().get(zone + player); Object o = getMap().get(zone + player);
if (o == null)
if (o == null) {
throw new RuntimeException("AllZone : getZone() invalid parameters " + zone + " " + player); throw new RuntimeException("AllZone : getZone() invalid parameters " + zone + " " + player);
}
return (PlayerZone) o; return (PlayerZone) o;
} }
@@ -606,12 +632,13 @@ public class AllZone implements NewConstants {
((DefaultPlayerZone) getComputerBattlefield()).resetCardsAddedThisTurn(); ((DefaultPlayerZone) getComputerBattlefield()).resetCardsAddedThisTurn();
((DefaultPlayerZone) getComputerGraveyard()).resetCardsAddedThisTurn(); ((DefaultPlayerZone) getComputerGraveyard()).resetCardsAddedThisTurn();
} }
/** /**
* <p>getDeckManager.</p> * <p>getDeckManager.</p>
* @return dMgr
*/ */
public static DeckManager getDeckManager() { public static DeckManager getDeckManager() {
return dMgr; return DECK_MGR;
} }
/** /**
@@ -622,11 +649,11 @@ public class AllZone implements NewConstants {
* @return the next timestamp * @return the next timestamp
*/ */
public static long getNextTimestamp() { public static long getNextTimestamp() {
return Singletons.getModel().getGameState().getNextTimestamp(); return Singletons.getModel().getGameState().getNextTimestamp();
} }
/** /**
* <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() {
@@ -661,17 +688,24 @@ public class AllZone implements NewConstants {
// player.reset() now handles this // player.reset() now handles this
//AllZone.getHumanPlayer().clearHandSizeOperations(); //AllZone.getHumanPlayer().clearHandSizeOperations();
//AllZone.getComputerPlayer().clearHandSizeOperations(); //AllZone.getComputerPlayer().clearHandSizeOperations();
getTriggerHandler().clearRegistered(); getTriggerHandler().clearRegistered();
} }
/**
* Getter for matchState.
* @return the matchState
*/
public static QuestMatchState getMatchState() { public static QuestMatchState getMatchState() {
return matchState; return matchState;
} }
/**
* Getter for colorChanger.
* @return the colorChanger
*/
public static ColorChanger getColorChanger() { public static ColorChanger getColorChanger() {
// TODO Auto-generated method stub return COLOR_CHANGER;
return colorChanger;
} }
}//AllZone } //AllZone