diff --git a/src/main/java/forge/model/BuildInfo.java b/src/main/java/forge/model/BuildInfo.java index 97bd7ac3667..d7950f03e50 100644 --- a/src/main/java/forge/model/BuildInfo.java +++ b/src/main/java/forge/model/BuildInfo.java @@ -7,8 +7,6 @@ import java.nio.charset.Charset; import java.util.jar.Attributes; import java.util.jar.JarFile; import java.util.jar.Manifest; -//import java.util.regex.Matcher; -//import java.util.regex.Pattern; /** * Provides access to information about the current version and build ID. @@ -206,7 +204,7 @@ public class BuildInfo { */ public final String toPrettyString() { final String rawVersion = getVersion(); - //final String rawBuildID = getBuildID(); + // final String rawBuildID = getBuildID(); String version; if (rawVersion == null) { @@ -215,14 +213,12 @@ public class BuildInfo { version = rawVersion; } - /*String buildID; - if (rawBuildID == null) { - buildID = "Unknown"; - } else { - buildID = rawBuildID; - } */ + /* + * String buildID; if (rawBuildID == null) { buildID = "Unknown"; } else + * { buildID = rawBuildID; } + */ - return "Forge version " + version; //", build ID " + buildID; + return "Forge version " + version; // ", build ID " + buildID; } } diff --git a/src/main/java/forge/model/FGameState.java b/src/main/java/forge/model/FGameState.java index 4e20e46c4ff..563a6a4581a 100644 --- a/src/main/java/forge/model/FGameState.java +++ b/src/main/java/forge/model/FGameState.java @@ -3,6 +3,7 @@ package forge.model; import forge.AIPlayer; import forge.Combat; import forge.Constant; +import forge.Constant.Zone; import forge.DefaultPlayerZone; import forge.EndOfCombat; import forge.EndOfTurn; @@ -14,7 +15,6 @@ import forge.Player; import forge.PlayerZone; import forge.StaticEffects; import forge.Upkeep; -import forge.Constant.Zone; import forge.card.trigger.TriggerHandler; import forge.game.GameSummary; @@ -22,9 +22,13 @@ import forge.game.GameSummary; * Represents the Forge Game State. */ public class FGameState { + + /** The Constant HUMAN_PLAYER_NAME. */ public static final String HUMAN_PLAYER_NAME = "Human"; + + /** The Constant AI_PLAYER_NAME. */ public static final String AI_PLAYER_NAME = "Computer"; - + private Player humanPlayer = new HumanPlayer(HUMAN_PLAYER_NAME); private Player computerPlayer = new AIPlayer(AI_PLAYER_NAME); private EndOfTurn endOfTurn = new EndOfTurn(); @@ -37,7 +41,6 @@ public class FGameState { private TriggerHandler triggerHandler = new TriggerHandler(); private Combat combat = new Combat(); - private PlayerZone stackZone = new DefaultPlayerZone(Constant.Zone.Stack, null); private long timestamp = 0; @@ -46,199 +49,241 @@ public class FGameState { /** * Constructor. */ - public FGameState() { /* no more zones to map here */ } - + public FGameState() { /* no more zones to map here */ + } /** + * Gets the human player. + * * @return the humanPlayer */ public final Player getHumanPlayer() { return humanPlayer; } - /** - * @param humanPlayer0 the humanPlayer to set + * Sets the human player. + * + * @param humanPlayer0 + * the humanPlayer to set */ protected final void setHumanPlayer(final Player humanPlayer0) { this.humanPlayer = humanPlayer0; } - /** + * Gets the computer player. + * * @return the computerPlayer */ public final Player getComputerPlayer() { return computerPlayer; } - /** - * @param computerPlayer0 the computerPlayer to set + * Sets the computer player. + * + * @param computerPlayer0 + * the computerPlayer to set */ protected final void setComputerPlayer(final Player computerPlayer0) { this.computerPlayer = computerPlayer0; } - - public final Player[] getPlayers() { - return new Player[]{ humanPlayer, computerPlayer }; - } - /** + * Gets the players. + * + * @return the players + */ + public final Player[] getPlayers() { + return new Player[] {humanPlayer, computerPlayer}; + } + + /** + * Gets the end of turn. + * * @return the endOfTurn */ public final EndOfTurn getEndOfTurn() { return endOfTurn; } - /** - * @param endOfTurn0 the endOfTurn to set + * Sets the end of turn. + * + * @param endOfTurn0 + * the endOfTurn to set */ protected final void setEndOfTurn(final EndOfTurn endOfTurn0) { this.endOfTurn = endOfTurn0; } - /** + * Gets the end of combat. + * * @return the endOfCombat */ public final EndOfCombat getEndOfCombat() { return endOfCombat; } - /** - * @param endOfCombat0 the endOfCombat to set + * Sets the end of combat. + * + * @param endOfCombat0 + * the endOfCombat to set */ protected final void setEndOfCombat(final EndOfCombat endOfCombat0) { this.endOfCombat = endOfCombat0; } - /** + * Gets the upkeep. + * * @return the upkeep */ public final Upkeep getUpkeep() { return upkeep; } - /** - * @param upkeep0 the upkeep to set + * Sets the upkeep. + * + * @param upkeep0 + * the upkeep to set */ protected final void setUpkeep(final Upkeep upkeep0) { this.upkeep = upkeep0; } - /** + * Gets the phase. + * * @return the phase */ public final Phase getPhase() { return phase; } - /** - * @param phase0 the phase to set + * Sets the phase. + * + * @param phase0 + * the phase to set */ protected final void setPhase(final Phase phase0) { this.phase = phase0; } - /** + * Gets the stack. + * * @return the stack */ public final MagicStack getStack() { return stack; } - /** - * @param stack0 the stack to set + * Sets the stack. + * + * @param stack0 + * the stack to set */ protected final void setStack(final MagicStack stack0) { this.stack = stack0; } - /** + * Gets the game action. + * * @return the gameAction */ public final GameAction getGameAction() { return gameAction; } - /** - * @param gameAction0 the gameAction to set + * Sets the game action. + * + * @param gameAction0 + * the gameAction to set */ protected final void setGameAction(final GameAction gameAction0) { this.gameAction = gameAction0; } - /** + * Gets the static effects. + * * @return the staticEffects */ public final StaticEffects getStaticEffects() { return staticEffects; } - /** - * @param staticEffects0 the staticEffects to set + * Sets the static effects. + * + * @param staticEffects0 + * the staticEffects to set */ protected final void setStaticEffects(final StaticEffects staticEffects0) { this.staticEffects = staticEffects0; } - /** + * Gets the trigger handler. + * * @return the triggerHandler */ public final TriggerHandler getTriggerHandler() { return triggerHandler; } - /** - * @param triggerHandler0 the triggerHandler to set + * Sets the trigger handler. + * + * @param triggerHandler0 + * the triggerHandler to set */ protected final void setTriggerHandler(final TriggerHandler triggerHandler0) { this.triggerHandler = triggerHandler0; } - /** + * Gets the combat. + * * @return the combat */ public final Combat getCombat() { return combat; } - /** - * @param combat0 the combat to set + * Sets the combat. + * + * @param combat0 + * the combat to set */ public final void setCombat(final Combat combat0) { this.combat = combat0; } - /** + * Gets the stack zone. + * * @return the stackZone */ public final PlayerZone getStackZone() { return stackZone; } - /** - * @param stackZone0 the stackZone to set + * Sets the stack zone. + * + * @param stackZone0 + * the stackZone to set */ protected final void setStackZone(final PlayerZone stackZone0) { this.stackZone = stackZone0; @@ -254,32 +299,38 @@ public class FGameState { return getTimestamp(); } - /** + * Gets the timestamp. + * * @return the timestamp */ public final long getTimestamp() { return timestamp; } - /** - * @param timestamp0 the timestamp to set + * Sets the timestamp. + * + * @param timestamp0 + * the timestamp to set */ protected final void setTimestamp(final long timestamp0) { this.timestamp = timestamp0; } - - public GameSummary getGameInfo() { + /** + * Gets the game info. + * + * @return the game info + */ + public final GameSummary getGameInfo() { return gameInfo; } - /** - * Call this each time you start a new game, ok? + * Call this each time you start a new game, ok?. */ - public void newGameCleanup() { + public final void newGameCleanup() { gameInfo = new GameSummary(humanPlayer.getName(), computerPlayer.getName()); getHumanPlayer().reset(); @@ -290,11 +341,11 @@ public class FGameState { getCombat().reset(); for (Player p : getPlayers()) { - for(Zone z : Player.ALL_ZONES) { + for (Zone z : Player.ALL_ZONES) { p.getZone(z).reset(); } } - + getStaticEffects().reset(); } diff --git a/src/main/java/forge/model/FModel.java b/src/main/java/forge/model/FModel.java index b87be5f5180..8a3c001fb44 100644 --- a/src/main/java/forge/model/FModel.java +++ b/src/main/java/forge/model/FModel.java @@ -7,51 +7,50 @@ import java.io.IOException; import java.io.OutputStream; import java.io.PrintStream; +import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor; +import arcane.util.MultiplexOutputStream; import forge.Constant; import forge.HttpUtil; import forge.properties.ForgePreferences; -//import net.slightlymagic.braids.util.progress_monitor.BaseProgressMonitor; -import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor; -import arcane.util.MultiplexOutputStream; - /** * The default Model implementation for Forge. - * + * * This used to be an interface, but it seems unlikely that we will ever use a * different model. - * + * * In case we need to convert it into an interface in the future, all fields of * this class must be either private or public static final. */ public class FModel { - //private static final int NUM_INIT_PHASES = 1; + // private static final int NUM_INIT_PHASES = 1; private final transient OutputStream logFileStream; private final transient PrintStream oldSystemOut; private final transient PrintStream oldSystemErr; private BuildInfo buildInfo; + + /** The preferences. */ public ForgePreferences preferences; private FGameState gameState; /** * Constructor. - * - * @param theMonitor a progress monitor (from the View) that shows the - * progress of the model's initialization. - * - * @throws FileNotFoundException if we could not find or write to the log file. + * + * @param theMonitor + * a progress monitor (from the View) that shows the progress of + * the model's initialization. + * + * @throws FileNotFoundException + * if we could not find or write to the log file. */ public FModel(final BraidsProgressMonitor theMonitor) throws FileNotFoundException { - /* To be implemented later. -Braids - BraidsProgressMonitor monitor; - if (theMonitor == null) { - monitor = new BaseProgressMonitor(NUM_INIT_PHASES, 1); - } - else { - monitor = theMonitor; - } - */ + /* + * To be implemented later. -Braids BraidsProgressMonitor monitor; if + * (theMonitor == null) { monitor = new + * BaseProgressMonitor(NUM_INIT_PHASES, 1); } else { monitor = + * theMonitor; } + */ final File logFile = new File("forge.log"); final boolean deleteSucceeded = logFile.delete(); @@ -70,7 +69,8 @@ public class FModel { try { setPreferences(new ForgePreferences("forge.preferences")); } catch (Exception exn) { - throw new RuntimeException(exn); // NOPMD by Braids on 8/13/11 8:21 PM + throw new RuntimeException(exn); // NOPMD by Braids on 8/13/11 8:21 + // PM } Constant.Runtime.Mill[0] = preferences.millingLossCondition; @@ -90,7 +90,9 @@ public class FModel { /** * Destructor for FModel. - * @throws Throwable indirectly + * + * @throws Throwable + * indirectly */ @Override protected final void finalize() throws Throwable { @@ -99,8 +101,8 @@ public class FModel { } /** - * Opposite of constructor; resets all system resources and closes the - * log file. + * Opposite of constructor; resets all system resources and closes the log + * file. */ public final void close() { System.setOut(oldSystemOut); @@ -114,7 +116,7 @@ public class FModel { /** * Getter for buildInfo. - * + * * @return the buildInfo */ public final BuildInfo getBuildInfo() { @@ -123,14 +125,17 @@ public class FModel { /** * Setter for buildInfo. - * - * @param neoBuildInfo the buildInfo to set + * + * @param neoBuildInfo + * the buildInfo to set */ protected final void setBuildInfo(final BuildInfo neoBuildInfo) { this.buildInfo = neoBuildInfo; } /** + * Gets the preferences. + * * @return the preferences */ public final ForgePreferences getPreferences() { @@ -138,7 +143,10 @@ public class FModel { } /** - * @param neoPreferences the preferences to set + * Sets the preferences. + * + * @param neoPreferences + * the preferences to set */ public final void setPreferences(final ForgePreferences neoPreferences) { this.preferences = neoPreferences; @@ -146,6 +154,7 @@ public class FModel { /** * Getter for gameState. + * * @return the game state */ public final FGameState getGameState() { @@ -154,6 +163,7 @@ public class FModel { /** * Create and return a new game state. + * * @return a fresh game state */ public final FGameState resetGameState() { @@ -161,6 +171,4 @@ public class FModel { return gameState; } - } - diff --git a/src/main/java/forge/properties/ForgePreferences.java b/src/main/java/forge/properties/ForgePreferences.java index 7249cc2379b..824f27cae82 100644 --- a/src/main/java/forge/properties/ForgePreferences.java +++ b/src/main/java/forge/properties/ForgePreferences.java @@ -1,60 +1,123 @@ package forge.properties; -import java.io.*; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileNotFoundException; +import java.io.FileOutputStream; +import java.io.IOException; import java.util.ArrayList; import java.util.List; +// TODO: Auto-generated Javadoc /** - *

ForgePreferences class.

- * + *

+ * ForgePreferences class. + *

+ * * @author Forge * @version $Id$ */ public class ForgePreferences extends Preferences { + + /** The new gui. */ public boolean newGui; + + /** The stack ai land. */ public boolean stackAiLand; + + /** The milling loss condition. */ public boolean millingLossCondition; + + /** The developer mode. */ public boolean developerMode; + + /** The upload draft ai. */ public boolean uploadDraftAI; + + /** The rand c foil. */ public boolean randCFoil; - + + /** The skin. */ public String skin; + + /** The laf. */ public String laf; + + /** The laf fonts. */ public boolean lafFonts; + + /** The stack offset. */ public StackOffsetType stackOffset; + + /** The max stack size. */ public int maxStackSize; + + /** The card size. */ public CardSizeType cardSize; + + /** The card overlay. */ public boolean cardOverlay; + + /** The scale larger than original. */ public boolean scaleLargerThanOriginal; - + + /** The deck gen rmv artifacts. */ public boolean deckGenRmvArtifacts; + + /** The deck gen rmv small. */ public boolean deckGenRmvSmall; - + + /** The Bugz name. */ public String BugzName; + + /** The Bugz pwd. */ public String BugzPwd; // Phases + /** The b ai upkeep. */ public boolean bAIUpkeep; + + /** The b ai draw. */ public boolean bAIDraw; + + /** The b aieot. */ public boolean bAIEOT; + + /** The b ai begin combat. */ public boolean bAIBeginCombat; + + /** The b ai end combat. */ public boolean bAIEndCombat; + + /** The b human upkeep. */ public boolean bHumanUpkeep; + + /** The b human draw. */ public boolean bHumanDraw; + + /** The b human eot. */ public boolean bHumanEOT; + + /** The b human begin combat. */ public boolean bHumanBeginCombat; + + /** The b human end combat. */ public boolean bHumanEndCombat; private List saveListeners = new ArrayList(); private final String fileName; /** - *

Constructor for ForgePreferences.

- * - * @param fileName a {@link java.lang.String} object. - * @throws java.lang.Exception if any. + *

+ * Constructor for ForgePreferences. + *

+ * + * @param fileName + * a {@link java.lang.String} object. + * @throws Exception + * the exception */ - public ForgePreferences(String fileName) throws Exception { + public ForgePreferences(final String fileName) throws Exception { this.fileName = fileName; File f = new File(fileName); if (!f.exists()) { @@ -74,24 +137,24 @@ public class ForgePreferences extends Preferences { stackAiLand = getBoolean("AI.stack.land", false); millingLossCondition = getBoolean("loss.condition.milling", true); developerMode = getBoolean("developer.mode", false); - + uploadDraftAI = getBoolean("upload.Draft.AI", true); - + randCFoil = getBoolean("rand.C.Foil", true); laf = get("gui.laf", ""); lafFonts = getBoolean("gui.laf.fonts", false); - skin = get("gui.skin","default"); + skin = get("gui.skin", "default"); cardOverlay = getBoolean("card.overlay", true); cardSize = CardSizeType.valueOf(get("card.images.size", "medium")); stackOffset = StackOffsetType.valueOf(get("stack.offset", "tiny")); maxStackSize = getInt("stack.max.size", 3); scaleLargerThanOriginal = getBoolean("card.scale.larger.than.original", true); - + deckGenRmvArtifacts = getBoolean("deck.gen.rmv.artifacts", false); deckGenRmvSmall = getBoolean("deck.gen.rmv.small", false); - + BugzName = get("bugz.user.name", ""); BugzPwd = get("bugz.user.pwd", ""); @@ -109,11 +172,14 @@ public class ForgePreferences extends Preferences { } /** - *

save.

- * - * @throws java.lang.Exception if any. + *

+ * save. + *

+ * + * @throws Exception + * the exception */ - public void save() throws Exception { + public final void save() throws Exception { set("gui.new", newGui); @@ -121,7 +187,7 @@ public class ForgePreferences extends Preferences { set("loss.condition.milling", millingLossCondition); set("developer.mode", developerMode); set("upload.Draft.AI", uploadDraftAI); - + set("rand.C.Foil", randCFoil); set("gui.skin", skin); @@ -136,10 +202,10 @@ public class ForgePreferences extends Preferences { for (SavePreferencesListener listeners : saveListeners) { listeners.savePreferences(); } - + set("deck.gen.rmv.artifacts", deckGenRmvArtifacts); set("deck.gen.rmv.small", deckGenRmvSmall); - + set("bugz.user.name", BugzName); set("bugz.user.pwd", BugzPwd); @@ -164,19 +230,48 @@ public class ForgePreferences extends Preferences { } /** - *

addSaveListener.

- * - * @param listener a {@link forge.properties.SavePreferencesListener} object. + *

+ * addSaveListener. + *

+ * + * @param listener + * a {@link forge.properties.SavePreferencesListener} object. */ - public void addSaveListener(SavePreferencesListener listener) { + public final void addSaveListener(final SavePreferencesListener listener) { saveListeners.add(listener); } - static public enum CardSizeType { - tiny, smaller, small, medium, large, huge + /** + * The Enum CardSizeType. + */ + public static enum CardSizeType { + + /** The tiny. */ + tiny, + /** The smaller. */ + smaller, + /** The small. */ + small, + /** The medium. */ + medium, + /** The large. */ + large, + /** The huge. */ + huge } + /** + * The Enum StackOffsetType. + */ static public enum StackOffsetType { - tiny, small, medium, large + + /** The tiny. */ + tiny, + /** The small. */ + small, + /** The medium. */ + medium, + /** The large. */ + large } } diff --git a/src/main/java/forge/properties/ForgeProps.java b/src/main/java/forge/properties/ForgeProps.java index 01c8dc1656d..a1ad8950489 100644 --- a/src/main/java/forge/properties/ForgeProps.java +++ b/src/main/java/forge/properties/ForgeProps.java @@ -1,29 +1,29 @@ package forge.properties; + /** * ForgeProps.java * * Created on 30.08.2009 */ - -import forge.error.ErrorViewer; -import tree.properties.TreeProperties; +import static java.lang.String.format; import java.io.File; import java.io.IOException; import java.util.Locale; -import static java.lang.String.format; - +import tree.properties.TreeProperties; +import forge.error.ErrorViewer; /** - * The class ForgeProps. Wrapper around TreeProperties to support the uses in forge. - * + * The class ForgeProps. Wrapper around TreeProperties to support the uses in + * forge. + * * @author Forge * @version $Id$ */ public class ForgeProps { - /** Constant properties */ + /** Constant properties. */ private static final TreeProperties properties; static { @@ -39,7 +39,7 @@ public class ForgeProps { } /** - * Returns the tree properties of forge + * Returns the tree properties of forge. * * @return a {@link treeProperties.TreeProperties} object. */ @@ -48,27 +48,29 @@ public class ForgeProps { } /** - * Returns the string property value, or null if there's no such property + * Returns the string property value, or null if there's no such property. * * @param key a {@link java.lang.String} object. * @return a {@link java.lang.String} object. */ - public static String getProperty(String key) { + public static String getProperty(final String key) { return getProperty(key, null); } /** - * Returns the string property value, or def if there's no such property + * Returns the string property value, or def if there's no such property. * * @param key a {@link java.lang.String} object. * @param def a {@link java.lang.String} object. * @return a {@link java.lang.String} object. */ - public static String getProperty(String key, String def) { + public static String getProperty(final String key, final String def) { String result; try { result = getProperties().getProperty(key); - if (result == null) result = def; + if (result == null) { + result = def; + } } catch (Exception ex) { result = def; } @@ -76,27 +78,29 @@ public class ForgeProps { } /** - * Returns the File property value, or null if there's no such property + * Returns the File property value, or null if there's no such property. * * @param key a {@link java.lang.String} object. * @return a {@link java.io.File} object. */ - public static File getFile(String key) { + public static File getFile(final String key) { return getFile(key, null); } /** - * Returns the File property value, or def if there's no such property + * Returns the File property value, or def if there's no such property. * * @param key a {@link java.lang.String} object. * @param def a {@link java.io.File} object. * @return a {@link java.io.File} object. */ - public static File getFile(String key, File def) { + public static File getFile(final String key, final File def) { File result; try { result = getProperties().getFile(key); - if (result == null) result = def; + if (result == null) { + result = def; + } } catch (Exception ex) { result = def; } @@ -104,46 +108,58 @@ public class ForgeProps { } /** - * Returns the localized version of the specified property. The key is a format string containing "%s", which - * is replaced with a language code (ISO 639-1, see {@link Locale#getLanguage()}). First, the configured - * language is used. Second, the locale's code is used. If none of them contains the requested key, "en" is - * used as the language code. - * - * @param key a {@link java.lang.String} object. + * Returns the localized version of the specified property. The key is a + * format string containing "%s", which is replaced with a language code + * (ISO 639-1, see {@link Locale#getLanguage()}). First, the configured + * language is used. Second, the locale's code is used. If none of them + * contains the requested key, "en" is used as the language code. + * + * @param key + * a {@link java.lang.String} object. * @return a {@link java.lang.String} object. */ - public static String getLocalized(String key) { + public static String getLocalized(final String key) { return getLocalized(key, null); } /** - * Returns the localized version of the specified property. The key is a format string containing "%s", which - * is replaced with a language code (ISO 639-1, see {@link Locale#getLanguage()}). First, the configured - * language is used. Second, the locale's code is used. If none of them contains the requested key, "en" is - * used as the language code. If even that has no value, the def parameter is returned. - * - * @param key a {@link java.lang.String} object. - * @param def a {@link java.lang.String} object. + * Returns the localized version of the specified property. The key is a + * format string containing "%s", which is replaced with a language code + * (ISO 639-1, see {@link Locale#getLanguage()}). First, the configured + * language is used. Second, the locale's code is used. If none of them + * contains the requested key, "en" is used as the language code. If even + * that has no value, the def parameter is returned. + * + * @param key + * a {@link java.lang.String} object. + * @param def + * a {@link java.lang.String} object. * @return a {@link java.lang.String} object. */ - public static String getLocalized(String key, String def) { - //the list of languages to look for, in the order to be used - //the first is the configured language - //the second is the default locale's language code + public static String getLocalized(final String key, final String def) { + // the list of languages to look for, in the order to be used + // the first is the configured language + // the second is the default locale's language code String[] languages = {getProperty(NewConstants.LANG.LANGUAGE), Locale.getDefault().getLanguage(), "en"}; try { for (String lang : languages) { - //could be if a property does not exist - //just skip it, and try the next - if (lang == null) continue; + // could be if a property does not exist + // just skip it, and try the next + if (lang == null) { + continue; + } String result = getProperty(format(key, lang)); - if (result != null) return result; + if (result != null) { + return result; + } } - //exceptions are skipped here; also the error viewer uses this, and reporting exceptions may result - //in a more fatal error (stack overflow) + // exceptions are skipped here; also the error viewer uses this, and + // reporting exceptions may result + // in a more fatal error (stack overflow) } catch (Exception ex) { } - //if no property was found, or an error occurred, return the default value + // if no property was found, or an error occurred, return the default + // value return def; } } diff --git a/src/main/java/forge/properties/NewConstants.java b/src/main/java/forge/properties/NewConstants.java index ffb7c16198f..04a46dd8e37 100644 --- a/src/main/java/forge/properties/NewConstants.java +++ b/src/main/java/forge/properties/NewConstants.java @@ -1,6 +1,6 @@ package forge.properties; - +// TODO: Auto-generated Javadoc /** * NewConstants.java * @@ -9,13 +9,16 @@ package forge.properties; /** * These are mostly property keys. - * + * * @author Clemens Koza * @version V0.0 22.08.2009 */ public interface NewConstants { - //General properties - /** Constant HOW_TO_REPORT_BUGS_URL = "program/howToReportBugsURL". */ + // General properties + /** + * Constant + * HOW_TO_REPORT_BUGS_URL = "program/howToReportBugsURL". + */ String HOW_TO_REPORT_BUGS_URL = "program/howToReportBugsURL"; /** Constant SHOW2CDECK="showdeck/2color". */ @@ -101,7 +104,10 @@ public interface NewConstants { /** Constant BOOSTERDATA="boosterdata". */ String BOOSTERDATA = "boosterdata"; + /** The MT g_ data. */ String MTG_DATA = "mtg-data"; + + /** The SYMBOL s_ small. */ String SYMBOLS_SMALL = "symbols/small"; /** Constant IMAGE_BASE="image/base". */ @@ -152,20 +158,34 @@ public interface NewConstants { /** Property path for a rare card. */ String RARE = "quest/rare"; + /** The PRICE. */ String PRICE = "quest/price"; - String BOOSTER_PRICE= "quest/boosterprice"; + /** The BOOSTE r_ price. */ + String BOOSTER_PRICE = "quest/boosterprice"; + + /** The DATA. */ String DATA = "quest/data"; + + /** The PREFS. */ String PREFS = "quest/prefs"; + /** The DECKS. */ String DECKS = "quest/decks-dir"; + + /** The XMLDATA. */ String XMLDATA = "quest/data-xml"; - + + /** The OPPONEN t_ icons. */ String OPPONENT_ICONS = "quest/opponent/icons"; + + /** The OPPONEN t_ dir. */ String OPPONENT_DIR = "image/icon"; - + + /** The PE t_ sho p_ icons. */ String PET_SHOP_ICONS = "quest/pet/icons"; - + + /** The PE t_ toke n_ images. */ String PET_TOKEN_IMAGES = "quest/pet/tokens"; } @@ -173,12 +193,25 @@ public interface NewConstants { * These are GUI-related properties. */ public static interface GUI { + + /** + * The Interface GuiDisplay. + */ public static interface GuiDisplay { + + /** The LAYOUT. */ String LAYOUT = "gui/Display"; + + /** The LAYOU t_ new. */ String LAYOUT_NEW = "gui/Display/new"; } + /** + * The Interface GuiDeckEditor. + */ public static interface GuiDeckEditor { + + /** The LAYOUT. */ String LAYOUT = "gui/DeckEditor"; } @@ -188,354 +221,836 @@ public interface NewConstants { * These are localization properties. */ public static interface LANG { + + /** The PROGRA m_ name. */ String PROGRAM_NAME = "%s/program/name"; + + /** The LANGUAGE. */ String LANGUAGE = "lang"; + /** + * The Interface HowTo. + */ public static interface HowTo { + + /** The TITLE. */ String TITLE = "%s/HowTo/title"; + + /** The MESSAGE. */ String MESSAGE = "%s/HowTo/message"; } + /** + * The Interface ErrorViewer. + */ public static interface ErrorViewer { + + /** The SHO w_ error. */ String SHOW_ERROR = "%s/ErrorViewer/show"; + /** The TITLE. */ String TITLE = "%s/ErrorViewer/title"; + + /** The MESSAGE. */ String MESSAGE = "%s/ErrorViewer/message"; + + /** The BUTTO n_ save. */ String BUTTON_SAVE = "%s/ErrorViewer/button/save"; + + /** The BUTTO n_ close. */ String BUTTON_CLOSE = "%s/ErrorViewer/button/close"; + + /** The BUTTO n_ exit. */ String BUTTON_EXIT = "%s/ErrorViewer/button/exit"; + /** + * The Interface ERRORS. + */ public static interface ERRORS { + + /** The SAV e_ message. */ String SAVE_MESSAGE = "%s/ErrorViewer/errors/save/message"; + + /** The SHO w_ message. */ String SHOW_MESSAGE = "%s/ErrorViewer/errors/show/message"; } } + /** + * The Interface Gui_BoosterDraft. + */ public static interface Gui_BoosterDraft { + + /** The CLOS e_ message. */ String CLOSE_MESSAGE = "%s/BoosterDraft/close/message"; + + /** The SAV e_ message. */ String SAVE_MESSAGE = "%s/BoosterDraft/save/message"; + + /** The SAV e_ title. */ String SAVE_TITLE = "%s/BoosterDraft/save/title"; + + /** The RENAM e_ message. */ String RENAME_MESSAGE = "%s/BoosterDraft/rename/message"; + + /** The RENAM e_ title. */ String RENAME_TITLE = "%s/BoosterDraft/rename/title"; + + /** The SAV e_ draf t_ message. */ String SAVE_DRAFT_MESSAGE = "%s/BoosterDraft/saveDraft/message"; + + /** The SAV e_ draf t_ title. */ String SAVE_DRAFT_TITLE = "%s/BoosterDraft/saveDraft/title"; } + /** + * The Interface GuiDisplay. + */ public static interface GuiDisplay { + + /** + * The Interface MENU_BAR. + */ public static interface MENU_BAR { + + /** + * The Interface MENU. + */ public static interface MENU { + + /** The TITLE. */ String TITLE = "%s/Display/menu/title"; } + /** + * The Interface PHASE. + */ public static interface PHASE { + + /** The TITLE. */ String TITLE = "%s/Display/phase/title"; } + /** + * The Interface DEV. + */ public static interface DEV { + + /** The TITLE. */ String TITLE = "%s/Display/dev/title"; } } + /** The HUMA n_ title. */ String HUMAN_TITLE = "%s/Display/human/title"; + /** The HUMA n_ decklist. */ String HUMAN_DECKLIST = "%s/Display/human/decklist"; - + + /** + * The Interface HUMAN_HAND. + */ public static interface HUMAN_HAND { + + /** The TITLE. */ String TITLE = "%s/Display/human/hand/title"; } + /** + * The Interface HUMAN_LIBRARY. + */ public static interface HUMAN_LIBRARY { + + /** The BASE. */ String BASE = "%s/Display/human/library"; + + /** The TITLE. */ String TITLE = "%s/Display/human/library/title"; + + /** The MENU. */ String MENU = "%s/Display/human/library/menu"; + + /** The BUTTON. */ String BUTTON = "%s/Display/human/library/button"; } + /** The HUMA n_ graveyard. */ String HUMAN_GRAVEYARD = "%s/Display/human/graveyard"; + /** + * The Interface HUMAN_GRAVEYARD. + */ public static interface HUMAN_GRAVEYARD { + + /** The TITLE. */ String TITLE = "%s/Display/human/graveyard/title"; + + /** The BUTTON. */ String BUTTON = "%s/Display/human/graveyard/button"; + + /** The MENU. */ String MENU = "%s/Display/human/graveyard/menu"; } + /** The HUMA n_ removed. */ String HUMAN_REMOVED = "%s/Display/human/removed"; + /** + * The Interface HUMAN_REMOVED. + */ public static interface HUMAN_REMOVED { + + /** The TITLE. */ String TITLE = "%s/Display/human/removed/title"; + + /** The BUTTON. */ String BUTTON = "%s/Display/human/removed/button"; + + /** The MENU. */ String MENU = "%s/Display/human/removed/menu"; } + /** The COMBAT. */ String COMBAT = "%s/Display/combat/title"; + /** The HUMA n_ flashback. */ String HUMAN_FLASHBACK = "%s/Display/human/flashback"; + /** + * The Interface HUMAN_FLASHBACK. + */ public static interface HUMAN_FLASHBACK { + + /** The TITLE. */ String TITLE = "%s/Display/human/flashback/title"; + + /** The BUTTON. */ String BUTTON = "%s/Display/human/flashback/button"; + + /** The MENU. */ String MENU = "%s/Display/human/flashback/menu"; } + /** The COMPUTE r_ title. */ String COMPUTER_TITLE = "%s/Display/computer/title"; - + /** + * The Interface COMPUTER_HAND. + */ public static interface COMPUTER_HAND { + + /** The BASE. */ String BASE = "%s/Display/computer/hand"; + + /** The TITLE. */ String TITLE = "%s/Display/computer/hand/title"; + + /** The BUTTON. */ String BUTTON = "%s/Display/computer/hand/button"; + + /** The MENU. */ String MENU = "%s/Display/computer/hand/menu"; } - + /** + * The Interface COMPUTER_LIBRARY. + */ public static interface COMPUTER_LIBRARY { + + /** The BASE. */ String BASE = "%s/Display/computer/library"; + + /** The TITLE. */ String TITLE = "%s/Display/computer/library/title"; + + /** The BUTTON. */ String BUTTON = "%s/Display/computer/library/button"; + + /** The MENU. */ String MENU = "%s/Display/computer/library/menu"; } - + /** The COMPUTE r_ graveyard. */ String COMPUTER_GRAVEYARD = "%s/Display/computer/graveyard"; + /** + * The Interface COMPUTER_GRAVEYARD. + */ public static interface COMPUTER_GRAVEYARD { + + /** The TITLE. */ String TITLE = "%s/Display/computer/graveyard/title"; + + /** The BUTTON. */ String BUTTON = "%s/Display/computer/graveyard/button"; + + /** The MENU. */ String MENU = "%s/Display/computer/graveyard/menu"; } - + /** The COMPUTE r_ removed. */ String COMPUTER_REMOVED = "%s/Display/computer/removed"; + /** + * The Interface COMPUTER_REMOVED. + */ public static interface COMPUTER_REMOVED { + + /** The TITLE. */ String TITLE = "%s/Display/computer/removed/title"; + + /** The BUTTON. */ String BUTTON = "%s/Display/computer/removed/button"; + + /** The MENU. */ String MENU = "%s/Display/computer/removed/menu"; } + /** The CONCEDE. */ String CONCEDE = "%s/Display/concede"; + /** + * The Interface CONCEDE. + */ public static interface CONCEDE { + + /** The BUTTON. */ String BUTTON = "%s/Display/concede/button"; + + /** The MENU. */ String MENU = "%s/Display/concede/menu"; } + /** The MANAGEN. */ String MANAGEN = "%s/Display/managen"; + /** + * The Interface MANAGEN. + */ public static interface MANAGEN { + + /** The BUTTON. */ String BUTTON = "%s/Display/managen/button"; + + /** The MENU. */ String MENU = "%s/Display/managen/menu"; } + /** The SETUPBATTLEFIELD. */ String SETUPBATTLEFIELD = "%s/Display/setupbattlefield"; + /** + * The Interface SETUPBATTLEFIELD. + */ public static interface SETUPBATTLEFIELD { + + /** The BUTTON. */ String BUTTON = "%s/Display/setupbattlefield/button"; + + /** The MENU. */ String MENU = "%s/Display/setupbattlefield/menu"; } + /** The TUTOR. */ String TUTOR = "%s/Display/tutor"; + /** + * The Interface TUTOR. + */ public static interface TUTOR { + + /** The BUTTON. */ String BUTTON = "%s/Display/tutor/button"; + + /** The MENU. */ String MENU = "%s/Display/tutor/menu"; } + /** The ADDCOUNTER. */ String ADDCOUNTER = "%s/Display/addcounter"; + /** + * The Interface ADDCOUNTER. + */ public static interface ADDCOUNTER { + + /** The BUTTON. */ String BUTTON = "%s/Display/addcounter/button"; + + /** The MENU. */ String MENU = "%s/Display/addcounter/menu"; } + /** The TAPPERM. */ String TAPPERM = "%s/Display/tapperm"; + /** + * The Interface TAPPERM. + */ public static interface TAPPERM { + + /** The BUTTON. */ String BUTTON = "%s/Display/tapperm/button"; + + /** The MENU. */ String MENU = "%s/Display/tapperm/menu"; } + /** The UNTAPPERM. */ String UNTAPPERM = "%s/Display/untapperm"; + /** + * The Interface UNTAPPERM. + */ public static interface UNTAPPERM { + + /** The BUTTON. */ String BUTTON = "%s/Display/untapperm/button"; + + /** The MENU. */ String MENU = "%s/Display/untapperm/menu"; } + /** The NOLANDLIMIT. */ String NOLANDLIMIT = "%s/Display/nolandlimit"; + /** + * The Interface NOLANDLIMIT. + */ public static interface NOLANDLIMIT { + + /** The BUTTON. */ String BUTTON = "%s/Display/nolandlimit/button"; + + /** The MENU. */ String MENU = "%s/Display/nolandlimit/menu"; } - + + /** The SETLIFE. */ String SETLIFE = "%s/Display/setlife"; + /** + * The Interface SETLIFE. + */ public static interface SETLIFE { + + /** The BUTTON. */ String BUTTON = "%s/Display/setlife/button"; + + /** The MENU. */ String MENU = "%s/Display/setlife/menu"; } - + + /** + * The Interface TRIGGER. + */ public static interface TRIGGER { + + /** The ALWAYSACCEPT. */ String ALWAYSACCEPT = "%s/Display/alwaysaccept"; + + /** The ALWAYSDECLINE. */ String ALWAYSDECLINE = "%s/Display/alwaysdecline"; + + /** The ALWAYSASK. */ String ALWAYSASK = "%s/Display/alwaysask"; } } + /** + * The Interface Gui_DownloadPictures. + */ public static interface Gui_DownloadPictures { + + /** The TITLE. */ String TITLE = "%s/DownloadPictures/title"; + /** The PROX y_ address. */ String PROXY_ADDRESS = "%s/DownloadPictures/proxy/address"; + + /** The PROX y_ port. */ String PROXY_PORT = "%s/DownloadPictures/proxy/port"; + /** The N o_ proxy. */ String NO_PROXY = "%s/DownloadPictures/proxy/type/none"; + + /** The HTT p_ proxy. */ String HTTP_PROXY = "%s/DownloadPictures/proxy/type/http"; + + /** The SOCK s_ proxy. */ String SOCKS_PROXY = "%s/DownloadPictures/proxy/type/socks"; + /** The N o_ more. */ String NO_MORE = "%s/DownloadPictures/no-more"; + /** The BA r_ befor e_ start. */ String BAR_BEFORE_START = "%s/DownloadPictures/bar/before-start"; + + /** The BA r_ wait. */ String BAR_WAIT = "%s/DownloadPictures/bar/wait"; + + /** The BA r_ close. */ String BAR_CLOSE = "%s/DownloadPictures/bar/close"; + /** + * The Interface BUTTONS. + */ public static interface BUTTONS { + + /** The START. */ String START = "%s/DownloadPictures/button/start"; + + /** The CANCEL. */ String CANCEL = "%s/DownloadPictures/button/cancel"; + + /** The CLOSE. */ String CLOSE = "%s/DownloadPictures/button/close"; } + /** + * The Interface ERRORS. + */ public static interface ERRORS { + + /** The PROX y_ connect. */ String PROXY_CONNECT = "%s/DownloadPictures/errors/proxy/connect"; + + /** The OTHER. */ String OTHER = "%s/DownloadPictures/errors/other"; } } - + /** + * The Interface OldGuiNewGame. + */ public static interface OldGuiNewGame { + + /** + * The Interface NEW_GAME_TEXT. + */ public static interface NEW_GAME_TEXT { + + /** The GAMETYPE. */ String GAMETYPE = "%s/NewGame/gametype"; + + /** The LIBRARY. */ String LIBRARY = "%s/NewGame/library"; + + /** The SETTINGS. */ String SETTINGS = "%s/NewGame/settings"; + + /** The NE w_ game. */ String NEW_GAME = "%s/NewGame/new_game"; + + /** The CONSTRUCTE d_ text. */ String CONSTRUCTED_TEXT = "%s/NewGame/constructed_text"; + + /** The SEALE d_ text. */ String SEALED_TEXT = "%s/NewGame/sealed_text"; + + /** The BOOSTE r_ text. */ String BOOSTER_TEXT = "%s/NewGame/booster_text"; + + /** The YOURDECK. */ String YOURDECK = "%s/NewGame/yourdeck"; + + /** The OPPONENT. */ String OPPONENT = "%s/NewGame/opponent"; + + /** The DEC k_ editor. */ String DECK_EDITOR = "%s/NewGame/deckeditor"; + + /** The NE w_ gui. */ String NEW_GUI = "%s/NewGame/newgui"; + + /** The A i_ land. */ String AI_LAND = "%s/NewGame/ailand"; + + /** The DE v_ mode. */ String DEV_MODE = "%s/NewGame/devmode"; + + /** The QUES t_ mode. */ String QUEST_MODE = "%s/NewGame/questmode"; + + /** The STAR t_ game. */ String START_GAME = "%s/NewGame/startgame"; + + /** The SAV e_ seale d_ msg. */ String SAVE_SEALED_MSG = "%s/NewGame/savesealed_msg"; + + /** The SAV e_ seale d_ ttl. */ String SAVE_SEALED_TTL = "%s/NewGame/savesealed_ttl"; } + /** + * The Interface MENU_BAR. + */ public static interface MENU_BAR { + + /** + * The Interface MENU. + */ public static interface MENU { + + /** The TITLE. */ String TITLE = "%s/NewGame/menu/title"; + + /** The LF. */ String LF = "%s/NewGame/menu/lookAndFeel"; + + /** The DOWNLOADPRICE. */ String DOWNLOADPRICE = "%s/NewGame/menu/downloadPrice"; + + /** The DOWNLOAD. */ String DOWNLOAD = "%s/NewGame/menu/download"; + + /** The DOWNLOADLQ. */ String DOWNLOADLQ = "%s/NewGame/menu/downloadlq"; + + /** The DOWNLOADSETLQ. */ String DOWNLOADSETLQ = "%s/NewGame/menu/downloadsetlq"; + + /** The DOWNLOADQUESTIMG. */ String DOWNLOADQUESTIMG = "%s/NewGame/menu/downloadquest"; + + /** The IMPORTPICTURE. */ String IMPORTPICTURE = "%s/NewGame/menu/importPicture"; + + /** The CAR d_ sizes. */ String CARD_SIZES = "%s/NewGame/menu/cardSizes"; + + /** The CAR d_ stack. */ String CARD_STACK = "%s/NewGame/menu/cardStack"; + + /** The CAR d_ stac k_ offset. */ String CARD_STACK_OFFSET = "%s/NewGame/menu/cardStackOffset"; + + /** The ABOUT. */ String ABOUT = "%s/NewGame/menu/about"; + + /** The EXIT. */ String EXIT = "%s/NewGame/menu/exit"; } + /** + * The Interface OPTIONS. + */ public static interface OPTIONS { + + /** The TITLE. */ String TITLE = "%s/NewGame/options/title"; + + /** The FONT. */ String FONT = "%s/NewGame/options/font"; + + /** The CAR d_ overlay. */ String CARD_OVERLAY = "%s/NewGame/options/cardOverlay"; + + /** The CAR d_ scale. */ String CARD_SCALE = "%s/NewGame/options/cardScale"; + /** + * The Interface GENERATE. + */ public static interface GENERATE { + + /** The TITLE. */ String TITLE = "%s/NewGame/options/generate/title"; + + /** The REMOV e_ small. */ String REMOVE_SMALL = "%s/NewGame/options/generate/removeSmall"; + + /** The REMOV e_ artifacts. */ String REMOVE_ARTIFACTS = "%s/NewGame/options/generate/removeArtifacts"; } } + /** + * The Interface HELP. + */ public static interface HELP { + + /** The TITLE. */ String TITLE = "%s/NewGame/help/title"; } } + /** + * The Interface ERRORS. + */ public static interface ERRORS { } } + /** + * The Interface WinLoseFrame. + */ public static interface WinLoseFrame { + + /** + * The Interface WINLOSETEXT. + */ public static interface WINLOSETEXT { + + /** The WON. */ String WON = "%s/WinLose/won"; + + /** The LOST. */ String LOST = "%s/WinLose/lost"; + + /** The WIN. */ String WIN = "%s/WinLose/win"; + + /** The LOSE. */ String LOSE = "%s/WinLose/lose"; + + /** The CONTINUE. */ String CONTINUE = "%s/WinLose/continue"; + + /** The RESTART. */ String RESTART = "%s/WinLose/restart"; - String QUIT = "%s/WinLose/quit"; - } - } - // end - - // Doublestrike 02-10-11 - this is soon to be deprecated. - public static interface Gui_WinLose { - public static interface WINLOSE_TEXT { - String WON = "%s/WinLose/won"; - String LOST = "%s/WinLose/lost"; - String WIN = "%s/WinLose/win"; - String LOSE = "%s/WinLose/lose"; - String CONTINUE = "%s/WinLose/continue"; - String RESTART = "%s/WinLose/restart"; + + /** The QUIT. */ String QUIT = "%s/WinLose/quit"; } } + // end + + // Doublestrike 02-10-11 - this is soon to be deprecated. + /** + * The Interface Gui_WinLose. + */ + public static interface Gui_WinLose { + + /** + * The Interface WINLOSE_TEXT. + */ + public static interface WINLOSE_TEXT { + + /** The WON. */ + String WON = "%s/WinLose/won"; + + /** The LOST. */ + String LOST = "%s/WinLose/lost"; + + /** The WIN. */ + String WIN = "%s/WinLose/win"; + + /** The LOSE. */ + String LOSE = "%s/WinLose/lose"; + + /** The CONTINUE. */ + String CONTINUE = "%s/WinLose/continue"; + + /** The RESTART. */ + String RESTART = "%s/WinLose/restart"; + + /** The QUIT. */ + String QUIT = "%s/WinLose/quit"; + } + } + + /** + * The Interface Gui_DownloadPrices. + */ public static interface Gui_DownloadPrices { + + /** + * The Interface DOWNLOADPRICES. + */ public static interface DOWNLOADPRICES { + + /** The TITLE. */ String TITLE = "%s/DownloadPrices/title"; + + /** The STAR t_ update. */ String START_UPDATE = "%s/DownloadPrices/startupdate"; + + /** The DOWNLOADING. */ String DOWNLOADING = "%s/DownloadPrices/downloading"; + + /** The COMPILING. */ String COMPILING = "%s/DownloadPrices/compiling"; } } + /** + * The Interface GameAction. + */ public static interface GameAction { - public static interface GAMEACTION_TEXT { - String HEADS = "%s/GameAction/heads"; - String TAILS = "%s/GameAction/tails"; - String HEADS_OR_TAILS = "%s/GameAction/heads_or_tails"; - String COIN_TOSS = "%s/GameAction/coin_toss"; - String HUMAN_WIN = "%s/GameAction/human_win"; - String COMPUTER_WIN = "%s/GameAction/computer_win"; - String COMPUTER_STARTS = "%s/GameAction/computer_starts"; - String HUMAN_STARTS = "%s/GameAction/human_starts"; - String HUMAN_MANA_COST = "%s/GameAction/human_mana_cost"; - String COMPUTER_MANA_COST = "%s/GameAction/computer_mana_cost"; - String COMPUTER_CUT = "%s/GameAction/computer_cut"; - String HUMAN_CUT = "%s/GameAction/human_cut"; - String CUT_NUMBER = "%s/GameAction/cut_number"; - String RESOLVE_STARTER = "%s/GameAction/resolve_starter"; - String EQUAL_CONVERTED_MANA = "%s/GameAction/equal_converted_mana"; - String CUTTING_AGAIN = "%s/GameAction/cutting_again"; - String YES = "%s/GameAction/yes"; - String NO = "%s/GameAction/no"; - String WANT_DREDGE = "%s/GameAction/want_dredge"; - String SELECT_DREDGE = "%s/GameAction/select_dredge"; - String CHOOSE_2ND_LAND = "%s/GameAction/choose_2nd_land"; + /** + * The Interface GAMEACTION_TEXT. + */ + public static interface GAMEACTION_TEXT { + + /** The HEADS. */ + String HEADS = "%s/GameAction/heads"; + + /** The TAILS. */ + String TAILS = "%s/GameAction/tails"; + + /** The HEAD s_ o r_ tails. */ + String HEADS_OR_TAILS = "%s/GameAction/heads_or_tails"; + + /** The COI n_ toss. */ + String COIN_TOSS = "%s/GameAction/coin_toss"; + + /** The HUMA n_ win. */ + String HUMAN_WIN = "%s/GameAction/human_win"; + + /** The COMPUTE r_ win. */ + String COMPUTER_WIN = "%s/GameAction/computer_win"; + + /** The COMPUTE r_ starts. */ + String COMPUTER_STARTS = "%s/GameAction/computer_starts"; + + /** The HUMA n_ starts. */ + String HUMAN_STARTS = "%s/GameAction/human_starts"; + + /** The HUMA n_ man a_ cost. */ + String HUMAN_MANA_COST = "%s/GameAction/human_mana_cost"; + + /** The COMPUTE r_ man a_ cost. */ + String COMPUTER_MANA_COST = "%s/GameAction/computer_mana_cost"; + + /** The COMPUTE r_ cut. */ + String COMPUTER_CUT = "%s/GameAction/computer_cut"; + + /** The HUMA n_ cut. */ + String HUMAN_CUT = "%s/GameAction/human_cut"; + + /** The CU t_ number. */ + String CUT_NUMBER = "%s/GameAction/cut_number"; + + /** The RESOLV e_ starter. */ + String RESOLVE_STARTER = "%s/GameAction/resolve_starter"; + + /** The EQUA l_ converte d_ mana. */ + String EQUAL_CONVERTED_MANA = "%s/GameAction/equal_converted_mana"; + + /** The CUTTIN g_ again. */ + String CUTTING_AGAIN = "%s/GameAction/cutting_again"; + + /** The YES. */ + String YES = "%s/GameAction/yes"; + + /** The NO. */ + String NO = "%s/GameAction/no"; + + /** The WAN t_ dredge. */ + String WANT_DREDGE = "%s/GameAction/want_dredge"; + + /** The SELEC t_ dredge. */ + String SELECT_DREDGE = "%s/GameAction/select_dredge"; + + /** The CHOOS e_2 n d_ land. */ + String CHOOSE_2ND_LAND = "%s/GameAction/choose_2nd_land"; } } } } - diff --git a/src/main/java/forge/properties/Preferences.java b/src/main/java/forge/properties/Preferences.java index 1d9db49f956..57b5851944a 100644 --- a/src/main/java/forge/properties/Preferences.java +++ b/src/main/java/forge/properties/Preferences.java @@ -1,44 +1,55 @@ package forge.properties; - import java.io.FileInputStream; import java.io.FileOutputStream; import java.io.IOException; -import java.util.*; - +import java.util.Collections; +import java.util.Enumeration; +import java.util.Properties; +import java.util.Set; +import java.util.Vector; /** * A collection of name/value pairs with sorted keys and utility methods. - * + * * @author Forge * @version $Id$ */ public class Preferences { + + /** The props. */ protected Properties props; /** - *

Constructor for Preferences.

+ *

+ * Constructor for Preferences. + *

*/ public Preferences() { props = new Properties(); } /** - *

Constructor for Preferences.

- * - * @param prefs a {@link forge.properties.Preferences} object. + *

+ * Constructor for Preferences. + *

+ * + * @param prefs + * a {@link forge.properties.Preferences} object. */ - public Preferences(Preferences prefs) { + public Preferences(final Preferences prefs) { props = prefs.props; } /** - *

keys.

- * + *

+ * keys. + *

+ * * @return a {@link java.util.Enumeration} object. */ - public synchronized Enumeration keys() { - @SuppressWarnings({"unchecked", "rawtypes"}) + public final synchronized Enumeration keys() { + @SuppressWarnings({ "unchecked", "rawtypes" }) Set keysEnum = (Set) props.keySet(); Vector keyList = new Vector(); keyList.addAll(keysEnum); @@ -47,15 +58,21 @@ public class Preferences { } /** - *

getInt.

- * - * @param name a {@link java.lang.String} object. - * @param defaultValue a int. + *

+ * getInt. + *

+ * + * @param name + * a {@link java.lang.String} object. + * @param defaultValue + * a int. * @return a int. */ - public int getInt(String name, int defaultValue) { + public final int getInt(final String name, final int defaultValue) { String value = props.getProperty(name); - if (value == null) return defaultValue; + if (value == null) { + return defaultValue; + } try { return Integer.parseInt(value); } catch (NumberFormatException ex) { @@ -64,72 +81,103 @@ public class Preferences { } /** - *

getBoolean.

- * - * @param name a {@link java.lang.String} object. - * @param defaultValue a boolean. + *

+ * getBoolean. + *

+ * + * @param name + * a {@link java.lang.String} object. + * @param defaultValue + * a boolean. * @return a boolean. */ - public boolean getBoolean(String name, boolean defaultValue) { + public final boolean getBoolean(final String name, final boolean defaultValue) { String value = props.getProperty(name); - if (value == null) return defaultValue; + if (value == null) { + return defaultValue; + } return Boolean.parseBoolean(value); } /** - *

getLong.

- * - * @param name a {@link java.lang.String} object. - * @param defaultValue a long. + *

+ * getLong. + *

+ * + * @param name + * a {@link java.lang.String} object. + * @param defaultValue + * a long. * @return a long. */ - public long getLong(String name, long defaultValue) { + public final long getLong(final String name, final long defaultValue) { String value = props.getProperty(name); - if (value == null) return defaultValue; + if (value == null) { + return defaultValue; + } return Long.parseLong(value); } /** - *

set.

- * - * @param key a {@link java.lang.String} object. - * @param value a {@link java.lang.Object} object. + *

+ * set. + *

+ * + * @param key + * a {@link java.lang.String} object. + * @param value + * a {@link java.lang.Object} object. */ - public void set(String key, Object value) { + public final void set(final String key, final Object value) { props.setProperty(key, String.valueOf(value)); } /** - *

get.

- * - * @param key a {@link java.lang.String} object. - * @param value a {@link java.lang.Object} object. + *

+ * get. + *

+ * + * @param key + * a {@link java.lang.String} object. + * @param value + * a {@link java.lang.Object} object. * @return a {@link java.lang.String} object. */ - public String get(String key, Object value) { + public final String get(final String key, final Object value) { String string = null; - if (value != null) string = String.valueOf(value); + if (value != null) { + string = String.valueOf(value); + } return props.getProperty(key, string); } /** - *

load.

- * - * @param stream a {@link java.io.FileInputStream} object. - * @throws java.io.IOException if any. + *

+ * load. + *

+ * + * @param stream + * a {@link java.io.FileInputStream} object. + * @throws IOException + * Signals that an I/O exception has occurred. */ - public void load(FileInputStream stream) throws IOException { + public final void load(final FileInputStream stream) throws IOException { props.load(stream); } /** - *

store.

- * - * @param stream a {@link java.io.FileOutputStream} object. - * @param comments a {@link java.lang.String} object. - * @throws java.io.IOException if any. + *

+ * store. + *

+ * + * @param stream + * a {@link java.io.FileOutputStream} object. + * @param comments + * a {@link java.lang.String} object. + * @throws IOException + * Signals that an I/O exception has occurred. */ - public void store(FileOutputStream stream, String comments) throws IOException { + public final void store(final FileOutputStream stream, final String comments) throws IOException { props.store(stream, comments); } } diff --git a/src/main/java/forge/properties/SavePreferencesListener.java b/src/main/java/forge/properties/SavePreferencesListener.java index f211fe65b8c..fe09bac026d 100644 --- a/src/main/java/forge/properties/SavePreferencesListener.java +++ b/src/main/java/forge/properties/SavePreferencesListener.java @@ -1,14 +1,18 @@ package forge.properties; /** - *

SavePreferencesListener interface.

- * + *

+ * SavePreferencesListener interface. + *

+ * * @author Forge * @version $Id$ */ public interface SavePreferencesListener { /** - *

savePreferences.

+ *

+ * savePreferences. + *

*/ - public void savePreferences(); + void savePreferences(); } diff --git a/src/main/java/forge/properties/package-info.java b/src/main/java/forge/properties/package-info.java index e42a8b073e2..f3bb8ba6afc 100644 --- a/src/main/java/forge/properties/package-info.java +++ b/src/main/java/forge/properties/package-info.java @@ -1,2 +1,2 @@ -/** Forge Card Game */ +/** Forge Card Game. */ package forge.properties; diff --git a/src/main/java/forge/quest/data/QuestData.java b/src/main/java/forge/quest/data/QuestData.java index 4c63245caa7..7a06f3e1904 100644 --- a/src/main/java/forge/quest/data/QuestData.java +++ b/src/main/java/forge/quest/data/QuestData.java @@ -1,5 +1,11 @@ package forge.quest.data; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; + +import net.slightlymagic.maxmtg.Predicate; import forge.MyRandom; import forge.SetUtils; import forge.deck.Deck; @@ -12,114 +18,138 @@ import forge.properties.NewConstants; import forge.quest.data.item.QuestInventory; import forge.quest.data.pet.QuestPetManager; -import java.util.ArrayList; -import java.util.HashMap; -import java.util.List; -import java.util.Map; - -import net.slightlymagic.maxmtg.Predicate; - +// TODO: Auto-generated Javadoc //when you create QuestDataOld and AFTER you copy the AI decks over //you have to call one of these two methods below //see Gui_QuestOptions for more details /** - *

QuestData class.

- * + *

+ * QuestData class. + *

+ * * @author Forge * @version $Id$ */ public final class QuestData { - //This field holds the version of the Quest Data - /** Constant CURRENT_VERSION_NUMBER=2 */ + // This field holds the version of the Quest Data + /** Constant CURRENT_VERSION_NUMBER=2. */ public static final int CURRENT_VERSION_NUMBER = 2; - //This field places the version number into QD instance, - //but only when the object is created through the constructor - //DO NOT RENAME THIS FIELD + // This field places the version number into QD instance, + // but only when the object is created through the constructor + // DO NOT RENAME THIS FIELD + /** The version number. */ int versionNumber = CURRENT_VERSION_NUMBER; + /** The rank index. */ int rankIndex; // level + + /** The win. */ int win; // number of wins + + /** The lost. */ int lost; + /** The credits. */ long credits; // this money is good for all modes - - int life; // for fantasy mode, how much life bought at shop to start game with - QuestInventory inventory = new QuestInventory(); // different gadgets - QuestPetManager petManager = new QuestPetManager(); // pets that start match with you + /** The life. */ + int life; // for fantasy mode, how much life bought at shop to start game + // with + /** The inventory. */ + QuestInventory inventory = new QuestInventory(); // different gadgets + + /** The pet manager. */ + QuestPetManager petManager = new QuestPetManager(); // pets that start match + // with you // Diffuculty - they store both index and title + /** The diff index. */ int diffIndex; + + /** The difficulty. */ String difficulty; // Quest mode - there should be an enum :( + /** The mode. */ String mode = ""; + + /** The Constant FANTASY. */ public static final String FANTASY = "Fantasy"; + + /** The Constant REALISTIC. */ public static final String REALISTIC = "Realistic"; // Decks collected by player + /** The my decks. */ Map myDecks = new HashMap(); // Cards associated with quest - ItemPool cardPool = new ItemPool(InventoryItem.class); // player's belonging - ItemPool shopList = new ItemPool(InventoryItem.class); // the current shop list - ItemPool newCardList = new ItemPool(InventoryItem.class); // cards acquired since last game-win/loss + /** The card pool. */ + ItemPool cardPool = new ItemPool(InventoryItem.class); // player's + // belonging + /** The shop list. */ + ItemPool shopList = new ItemPool(InventoryItem.class); // the + // current + // shop + // list + /** The new card list. */ + ItemPool newCardList = new ItemPool(InventoryItem.class); // cards + // acquired + // since + // last + // game-win/loss // Challenge history + /** The challenges played. */ int challengesPlayed = 0; + + /** The available challenges. */ List availableChallenges = new ArrayList(); + + /** The completed challenges. */ List completedChallenges = new ArrayList(); - - // Challenges used to be called quests. During the renaming, - // files could be corrupted. These fields ensure old files still work. + + // Challenges used to be called quests. During the renaming, + // files could be corrupted. These fields ensure old files still work. // These fields should be phased out after a little while. - // The old files, if played once, are updated automatically to the new system. + // The old files, if played once, are updated automatically to the new + // system. + /** The quests played. */ int questsPlayed = -1; + + /** The available quests. */ List availableQuests = null; + + /** The completed quests. */ List completedQuests = null; // own randomizer seed private long randomSeed = 0; // Utility class to access cards, has access to private fields - // Moved some methods there that otherwise would make this class even more complex + // Moved some methods there that otherwise would make this class even more + // complex private transient QuestUtilCards myCards; - public static final String[] RANK_TITLES = new String[]{ - "Level 0 - Confused Wizard", - "Level 1 - Mana Mage", - "Level 2 - Death by Megrim", - "Level 3 - Shattered the Competition", - "Level 4 - Black Knighted", - "Level 5 - Shockingly Good", - "Level 6 - Regressed into Timmy", - "Level 7 - Loves Blue Control", - "Level 8 - Immobilized by Fear", - "Level 9 - Lands = Friends", - "Level 10 - Forging new paths", - "Level 11 - Infect-o-tron", - "Level 12 - Great Balls of Fire", - "Level 13 - Artifact Schmartifact", - "Level 14 - Mike Mulligan's The Name", - "Level 15 - Fresh Air: Good For The Health", - "Level 16 - In It For The Love", - "Level 17 - Sticks, Stones, Bones", - "Level 18 - Credits For Breakfast", - "Level 19 - Millasaurus", - "Level 20 - One-turn Wonder", - "Teaching Gandalf a Lesson", - "What Do You Do With The Other Hand?", - "Freelance Sorcerer, Works Weekends", - "Should We Hire Commentators?", - "Saltblasted For Your Talent", - "Serra Angel Is Your Girlfriend", - }; + /** The Constant RANK_TITLES. */ + public static final String[] RANK_TITLES = new String[] {"Level 0 - Confused Wizard", "Level 1 - Mana Mage", + "Level 2 - Death by Megrim", "Level 3 - Shattered the Competition", "Level 4 - Black Knighted", + "Level 5 - Shockingly Good", "Level 6 - Regressed into Timmy", "Level 7 - Loves Blue Control", + "Level 8 - Immobilized by Fear", "Level 9 - Lands = Friends", "Level 10 - Forging new paths", + "Level 11 - Infect-o-tron", "Level 12 - Great Balls of Fire", "Level 13 - Artifact Schmartifact", + "Level 14 - Mike Mulligan's The Name", "Level 15 - Fresh Air: Good For The Health", + "Level 16 - In It For The Love", "Level 17 - Sticks, Stones, Bones", "Level 18 - Credits For Breakfast", + "Level 19 - Millasaurus", "Level 20 - One-turn Wonder", "Teaching Gandalf a Lesson", + "What Do You Do With The Other Hand?", "Freelance Sorcerer, Works Weekends", + "Should We Hire Commentators?", "Saltblasted For Your Talent", "Serra Angel Is Your Girlfriend", }; /** - *

Constructor for QuestData.

+ *

+ * Constructor for QuestData. + *

*/ public QuestData() { initTransients(); @@ -132,15 +162,30 @@ public final class QuestData { myCards = new QuestUtilCards(this); // to avoid NPE some pools will be created here if they are null - if (null == newCardList) { newCardList = new ItemPool(InventoryItem.class); } - if (null == shopList) { shopList = new ItemPool(InventoryItem.class); } + if (null == newCardList) { + newCardList = new ItemPool(InventoryItem.class); + } + if (null == shopList) { + shopList = new ItemPool(InventoryItem.class); + } } + /** + * New game. + * + * @param diff + * the diff + * @param m0de + * the m0de + * @param standardStart + * the standard start + */ public void newGame(final int diff, final String m0de, final boolean standardStart) { setDifficulty(diff); - Predicate filter = standardStart ? SetUtils.getStandard().getFilterPrinted() : CardPrinted.Predicates.Presets.isTrue; + Predicate filter = standardStart ? SetUtils.getStandard().getFilterPrinted() + : CardPrinted.Predicates.Presets.isTrue; myCards.setupNewGameCardPool(filter, diff); credits = QuestPreferences.getStartingCredits(); @@ -150,102 +195,267 @@ public final class QuestData { } // All belongings - public QuestInventory getInventory() { return inventory; } - public QuestPetManager getPetManager() { return petManager; } + /** + * Gets the inventory. + * + * @return the inventory + */ + public QuestInventory getInventory() { + return inventory; + } + + /** + * Gets the pet manager. + * + * @return the pet manager + */ + public QuestPetManager getPetManager() { + return petManager; + } + // Cards - class uses data from here - public QuestUtilCards getCards() { return myCards; } + /** + * Gets the cards. + * + * @return the cards + */ + public QuestUtilCards getCards() { + return myCards; + } // Challenge performance + /** + * Gets the challenges played. + * + * @return the challenges played + */ public int getChallengesPlayed() { // This should be phased out after a while, when // old quest decks have been updated. (changes made 19-9-11) - if(questsPlayed!=-1) { + if (questsPlayed != -1) { challengesPlayed = questsPlayed; - questsPlayed = -1; + questsPlayed = -1; } - + return challengesPlayed; } - - public void addChallengesPlayed() { challengesPlayed++; } - public List getAvailableChallenges() { + /** + * Adds the challenges played. + */ + public void addChallengesPlayed() { + challengesPlayed++; + } + + /** + * Gets the available challenges. + * + * @return the available challenges + */ + public List getAvailableChallenges() { // This should be phased out after a while, when // old quest decks have been updated. (changes made 19-9-11) - if(availableQuests != null) { + if (availableQuests != null) { availableChallenges = availableQuests; availableQuests = null; } - - return availableChallenges != null ? new ArrayList(availableChallenges) : null; + + return availableChallenges != null ? new ArrayList(availableChallenges) : null; } - - public void setAvailableChallenges(final List list) { availableChallenges = list; } - public void clearAvailableChallenges() { availableChallenges.clear(); } - + /** - *

getCompletedChallenges.

+ * Sets the available challenges. + * + * @param list + * the new available challenges + */ + public void setAvailableChallenges(final List list) { + availableChallenges = list; + } + + /** + * Clear available challenges. + */ + public void clearAvailableChallenges() { + availableChallenges.clear(); + } + + /** + *

+ * getCompletedChallenges. + *

* Returns stored list of non-repeatable challenge IDs. * * @return List */ - public List getCompletedChallenges() { + public List getCompletedChallenges() { // This should be phased out after a while, when // old quest decks have been updated. (changes made 19-9-11) - // Also, poorly named - this should be "getLockedChalleneges" or similar. - if(completedQuests != null) { + // Also, poorly named - this should be "getLockedChalleneges" or + // similar. + if (completedQuests != null) { completedChallenges = completedQuests; completedQuests = null; } - - return completedChallenges != null ? new ArrayList(completedChallenges) : null; + + return completedChallenges != null ? new ArrayList(completedChallenges) : null; } - + /** - *

addCompletedChallenge.

+ *

+ * addCompletedChallenge. + *

* Add non-repeatable challenge ID to list. * - * @param int i + * @param i + * the i */ - + // Poorly named - this should be "setLockedChalleneges" or similar. - public void addCompletedChallenge(int i) { + public void addCompletedChallenge(final int i) { completedChallenges.add(i); } // Wins & Losses - public int getLost() { return lost; } - public void addLost() { lost++; } - public int getWin() { return win; } - public void addWin() { //changes getRank() + /** + * Gets the lost. + * + * @return the lost + */ + public int getLost() { + return lost; + } + + /** + * Adds the lost. + */ + public void addLost() { + lost++; + } + + /** + * Gets the win. + * + * @return the win + */ + public int getWin() { + return win; + } + + /** + * Adds the win. + */ + public void addWin() { // changes getRank() win++; int winsToLvlUp = QuestPreferences.getWinsForRankIncrease(diffIndex); - if (win % winsToLvlUp == 0) { rankIndex++; } + if (win % winsToLvlUp == 0) { + rankIndex++; + } } // Life (only fantasy) - public int getLife() { return isFantasy() ? life : 20; } - public void addLife(final int n) { life += n; } + /** + * Gets the life. + * + * @return the life + */ + public int getLife() { + return isFantasy() ? life : 20; + } + + /** + * Adds the life. + * + * @param n + * the n + */ + public void addLife(final int n) { + life += n; + } // Credits - public void addCredits(final long c) { credits += c; } - public void subtractCredits(final long c) { credits = credits > c ? credits - c : 0; } - public long getCredits() { return credits; } + /** + * Adds the credits. + * + * @param c + * the c + */ + public void addCredits(final long c) { + credits += c; + } + + /** + * Subtract credits. + * + * @param c + * the c + */ + public void subtractCredits(final long c) { + credits = credits > c ? credits - c : 0; + } + + /** + * Gets the credits. + * + * @return the credits + */ + public long getCredits() { + return credits; + } // Quest mode - public boolean isFantasy() { return mode.equals(FANTASY); } - public String getMode() { return mode == null ? "" : mode; } + /** + * Checks if is fantasy. + * + * @return true, if is fantasy + */ + public boolean isFantasy() { + return mode.equals(FANTASY); + } + + /** + * Gets the mode. + * + * @return the mode + */ + public String getMode() { + return mode == null ? "" : mode; + } // Difficulty - public String getDifficulty() { return difficulty; } - public int getDifficultyIndex() { return diffIndex; } + /** + * Gets the difficulty. + * + * @return the difficulty + */ + public String getDifficulty() { + return difficulty; + } + /** + * Gets the difficulty index. + * + * @return the difficulty index + */ + public int getDifficultyIndex() { + return diffIndex; + } + + /** + * Sets the difficulty. + * + * @param i + * the new difficulty + */ public void setDifficulty(final int i) { diffIndex = i; difficulty = QuestPreferences.getDifficulty(i); } + /** + * Guess difficulty index. + */ public void guessDifficultyIndex() { String[] diffStr = QuestPreferences.getDifficulty(); for (int i = 0; i < diffStr.length; i++) { @@ -256,21 +466,64 @@ public final class QuestData { } // Level, read-only ( note: it increments in addWin() ) - public int getLevel() { return rankIndex; } - public String getRank() { - if (rankIndex >= RANK_TITLES.length) { rankIndex = RANK_TITLES.length - 1; } + /** + * Gets the level. + * + * @return the level + */ + public int getLevel() { + return rankIndex; + } + + /** + * Gets the rank. + * + * @return the rank + */ + public String getRank() { + if (rankIndex >= RANK_TITLES.length) { + rankIndex = RANK_TITLES.length - 1; + } return RANK_TITLES[rankIndex]; } // decks management - public List getDeckNames() { return new ArrayList(myDecks.keySet()); } - public void removeDeck(final String deckName) { myDecks.remove(deckName); } - public void addDeck(final Deck d) { myDecks.put(d.getName(), d); } + /** + * Gets the deck names. + * + * @return the deck names + */ + public List getDeckNames() { + return new ArrayList(myDecks.keySet()); + } /** - *

getDeck.

- * - * @param deckName a {@link java.lang.String} object. + * Removes the deck. + * + * @param deckName + * the deck name + */ + public void removeDeck(final String deckName) { + myDecks.remove(deckName); + } + + /** + * Adds the deck. + * + * @param d + * the d + */ + public void addDeck(final Deck d) { + myDecks.put(d.getName(), d); + } + + /** + *

+ * getDeck. + *

+ * + * @param deckName + * a {@link java.lang.String} object. * @return a {@link forge.deck.Deck} object. */ public Deck getDeck(final String deckName) { @@ -284,7 +537,14 @@ public final class QuestData { } // randomizer - related - public long getRandomSeed() { return randomSeed; } + /** + * Gets the random seed. + * + * @return the random seed + */ + public long getRandomSeed() { + return randomSeed; + } /** * This method should be called whenever the opponents should change. @@ -296,15 +556,30 @@ public final class QuestData { // SERIALIZATION - related things // This must be called by XML-serializer via reflection + /** + * Read resolve. + * + * @return the object + */ public Object readResolve() { initTransients(); return this; } + /** + * Checks for save file. + * + * @return true, if successful + */ public boolean hasSaveFile() { - return ForgeProps.getFile(NewConstants.QUEST.DATA).exists() || - ForgeProps.getFile(NewConstants.QUEST.XMLDATA).exists(); + return ForgeProps.getFile(NewConstants.QUEST.DATA).exists() + || ForgeProps.getFile(NewConstants.QUEST.XMLDATA).exists(); } - public void saveData() { QuestDataIO.saveData(this); } + /** + * Save data. + */ + public void saveData() { + QuestDataIO.saveData(this); + } } diff --git a/src/main/java/forge/quest/data/QuestDataIO.java b/src/main/java/forge/quest/data/QuestDataIO.java index 0348b3921c1..5d38f34d66b 100644 --- a/src/main/java/forge/quest/data/QuestDataIO.java +++ b/src/main/java/forge/quest/data/QuestDataIO.java @@ -1,12 +1,32 @@ package forge.quest.data; +import java.io.BufferedOutputStream; +import java.io.File; +import java.io.FileInputStream; +import java.io.FileOutputStream; +import java.io.InputStreamReader; +import java.io.StringReader; +import java.util.ArrayList; +import java.util.List; +import java.util.Map.Entry; +import java.util.zip.GZIPInputStream; +import java.util.zip.GZIPOutputStream; + +import javax.xml.parsers.DocumentBuilder; +import javax.xml.parsers.DocumentBuilderFactory; + +import org.apache.commons.lang3.StringUtils; +import org.w3c.dom.Document; +import org.w3c.dom.NodeList; +import org.xml.sax.InputSource; + import com.thoughtworks.xstream.XStream; -import com.thoughtworks.xstream.io.HierarchicalStreamReader; -import com.thoughtworks.xstream.io.HierarchicalStreamWriter; -import com.thoughtworks.xstream.mapper.MapperWrapper; import com.thoughtworks.xstream.converters.Converter; import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.converters.UnmarshallingContext; +import com.thoughtworks.xstream.io.HierarchicalStreamReader; +import com.thoughtworks.xstream.io.HierarchicalStreamWriter; +import com.thoughtworks.xstream.mapper.MapperWrapper; import forge.error.ErrorViewer; import forge.game.GameType; @@ -19,54 +39,47 @@ import forge.properties.ForgeProps; import forge.properties.NewConstants; import forge.quest.data.item.QuestInventory; -import org.apache.commons.lang3.StringUtils; -import org.w3c.dom.Document; -import org.w3c.dom.NodeList; -import org.xml.sax.InputSource; - -import javax.xml.parsers.DocumentBuilder; -import javax.xml.parsers.DocumentBuilderFactory; -import java.io.*; -import java.util.ArrayList; -import java.util.List; -import java.util.Map.Entry; -import java.util.zip.GZIPInputStream; -import java.util.zip.GZIPOutputStream; - /** - *

QuestDataIO class.

- * + *

+ * QuestDataIO class. + *

+ * * @author Forge * @version $Id$ */ public class QuestDataIO { /** - *

Constructor for QuestDataIO.

+ *

+ * Constructor for QuestDataIO. + *

*/ public QuestDataIO() { } /** - *

loadData.

- * + *

+ * loadData. + *

+ * * @return a {@link forge.quest.data.QuestData} object. */ public static QuestData loadData() { try { - //read file "questData" + // read file "questData" QuestData data = null; File xmlSaveFile = ForgeProps.getFile(NewConstants.QUEST.XMLDATA); - GZIPInputStream zin = - new GZIPInputStream(new FileInputStream(xmlSaveFile)); + GZIPInputStream zin = new GZIPInputStream(new FileInputStream(xmlSaveFile)); StringBuilder xml = new StringBuilder(); char[] buf = new char[1024]; InputStreamReader reader = new InputStreamReader(zin); while (reader.ready()) { int len = reader.read(buf); - if (len == -1) { break; } // when end of stream was reached + if (len == -1) { + break; + } // when end of stream was reached xml.append(buf, 0, len); } @@ -75,7 +88,7 @@ public class QuestDataIO { xStream.registerConverter(new GameTypeToXml()); xStream.alias("CardPool", ItemPool.class); data = (QuestData) xStream.fromXML(xml.toString()); - + if (data.versionNumber != QuestData.CURRENT_VERSION_NUMBER) { updateSaveFile(data, xml.toString()); } @@ -90,52 +103,54 @@ public class QuestDataIO { } /** - *

updateSaveFile.

- * - * @param newData a {@link forge.quest.data.QuestData} object. - * @param input a {@link java.lang.String} object. + *

+ * updateSaveFile. + *

+ * + * @param newData + * a {@link forge.quest.data.QuestData} object. + * @param input + * a {@link java.lang.String} object. */ - private static void updateSaveFile( - final QuestData newData, final String input) { + private static void updateSaveFile(final QuestData newData, final String input) { try { - DocumentBuilder builder = - DocumentBuilderFactory.newInstance().newDocumentBuilder(); + DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder(); InputSource is = new InputSource(); is.setCharacterStream(new StringReader(input)); Document document = builder.parse(is); - switch (newData.versionNumber) { - //There should be a fall-through b/w the cases so that each + // There should be a fall-through b/w the cases so that each // version's changes get applied progressively - case 0: + case 0: // First beta release with new file format, // inventory needs to be migrated - newData.inventory = new QuestInventory(); - NodeList elements = document.getElementsByTagName("estatesLevel"); - newData.getInventory().setItemLevel("Estates", Integer.parseInt(elements.item(0).getTextContent())); - elements = document.getElementsByTagName("luckyCoinLevel"); - newData.getInventory().setItemLevel("Lucky Coin", Integer.parseInt(elements.item(0).getTextContent())); - elements = document.getElementsByTagName("sleightOfHandLevel"); - newData.getInventory().setItemLevel("Sleight", Integer.parseInt(elements.item(0).getTextContent())); - elements = document.getElementsByTagName("gearLevel"); + newData.inventory = new QuestInventory(); + NodeList elements = document.getElementsByTagName("estatesLevel"); + newData.getInventory().setItemLevel("Estates", Integer.parseInt(elements.item(0).getTextContent())); + elements = document.getElementsByTagName("luckyCoinLevel"); + newData.getInventory().setItemLevel("Lucky Coin", Integer.parseInt(elements.item(0).getTextContent())); + elements = document.getElementsByTagName("sleightOfHandLevel"); + newData.getInventory().setItemLevel("Sleight", Integer.parseInt(elements.item(0).getTextContent())); + elements = document.getElementsByTagName("gearLevel"); - int gearLevel = Integer.parseInt(elements.item(0).getTextContent()); - if (gearLevel >= 1) { - newData.inventory.setItemLevel("Map", 1); - } - if (gearLevel == 2) { - newData.inventory.setItemLevel("Zeppelin", 1); - } - // fall-through - case 1: - // nothing to do here, everything is managed by CardPoolToXml deserializer - break; - default: - break; + int gearLevel = Integer.parseInt(elements.item(0).getTextContent()); + if (gearLevel >= 1) { + newData.inventory.setItemLevel("Map", 1); + } + if (gearLevel == 2) { + newData.inventory.setItemLevel("Zeppelin", 1); + } + // fall-through + case 1: + // nothing to do here, everything is managed by CardPoolToXml + // deserializer + break; + default: + break; } - //mark the QD as the latest version + // mark the QD as the latest version newData.versionNumber = QuestData.CURRENT_VERSION_NUMBER; } catch (Exception e) { @@ -144,9 +159,12 @@ public class QuestDataIO { } /** - *

saveData.

- * - * @param qd a {@link forge.quest.data.QuestData} object. + *

+ * saveData. + *

+ * + * @param qd + * a {@link forge.quest.data.QuestData} object. */ public static void saveData(final QuestData qd) { try { @@ -161,10 +179,11 @@ public class QuestDataIO { zout.flush(); zout.close(); - //BufferedOutputStream boutUnp = new BufferedOutputStream(new FileOutputStream(f + ".xml")); - //xStream.toXML(qd, boutUnp); - //boutUnp.flush(); - //boutUnp.close(); + // BufferedOutputStream boutUnp = new BufferedOutputStream(new + // FileOutputStream(f + ".xml")); + // xStream.toXML(qd, boutUnp); + // boutUnp.flush(); + // boutUnp.close(); } catch (Exception ex) { ErrorViewer.showError(ex, "Error saving Quest Data."); @@ -173,8 +192,9 @@ public class QuestDataIO { } /** - * Xstream subclass that ignores fields that are present in the save but not in the class. - * This one is intended to skip fields defined in Object class (but are there any fields?) + * Xstream subclass that ignores fields that are present in the save but not + * in the class. This one is intended to skip fields defined in Object class + * (but are there any fields?) */ private static class IgnoringXStream extends XStream { List ignoredFields = new ArrayList(); @@ -183,9 +203,7 @@ public class QuestDataIO { protected MapperWrapper wrapMapper(MapperWrapper next) { return new MapperWrapper(next) { @Override - public boolean shouldSerializeMember( - @SuppressWarnings("rawtypes") Class definedIn, - String fieldName) { + public boolean shouldSerializeMember(@SuppressWarnings("rawtypes") Class definedIn, String fieldName) { if (definedIn == Object.class) { ignoredFields.add(fieldName); return false; @@ -196,7 +214,6 @@ public class QuestDataIO { } } - private static class GameTypeToXml implements Converter { @SuppressWarnings("rawtypes") @Override @@ -214,9 +231,9 @@ public class QuestDataIO { String value = reader.getValue(); return GameType.smartValueOf(value); } - + } - + private static class CardPoolToXml implements Converter { @SuppressWarnings("rawtypes") @Override @@ -224,40 +241,41 @@ public class QuestDataIO { return clasz.equals(ItemPool.class); } - private void write(CardPrinted cref, Integer count, HierarchicalStreamWriter writer) - { + private void write(CardPrinted cref, Integer count, HierarchicalStreamWriter writer) { writer.startNode("card"); writer.addAttribute("c", cref.getName()); writer.addAttribute("s", cref.getSet()); - if (cref.isFoil()) { writer.addAttribute("foil", "1"); } - if (cref.getArtIndex() > 0) { writer.addAttribute("i", Integer.toString(cref.getArtIndex())); } + if (cref.isFoil()) { + writer.addAttribute("foil", "1"); + } + if (cref.getArtIndex() > 0) { + writer.addAttribute("i", Integer.toString(cref.getArtIndex())); + } writer.addAttribute("n", count.toString()); writer.endNode(); } - private void write(BoosterPack booster, Integer count, HierarchicalStreamWriter writer) - { + private void write(BoosterPack booster, Integer count, HierarchicalStreamWriter writer) { writer.startNode("booster"); writer.addAttribute("s", booster.getSet()); writer.addAttribute("n", count.toString()); writer.endNode(); } - - + @Override public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { @SuppressWarnings("unchecked") ItemPool pool = (ItemPool) source; for (Entry e : pool) { - InventoryItem item = e.getKey(); + InventoryItem item = e.getKey(); Integer count = e.getValue(); if (item instanceof CardPrinted) { write((CardPrinted) item, count, writer); } else if (item instanceof BoosterPack) { write((BoosterPack) item, count, writer); - } + } } - + } @Override @@ -269,7 +287,7 @@ public class QuestDataIO { int cnt = StringUtils.isNumeric(sCnt) ? Integer.parseInt(sCnt) : 1; String nodename = reader.getNodeName(); - if("string".equals(nodename)) { + if ("string".equals(nodename)) { result.add(CardDb.instance().getCard(reader.getValue())); } else if ("card".equals(nodename)) { // new format result.add(readCardPrinted(reader), cnt); @@ -280,15 +298,13 @@ public class QuestDataIO { } return result; } - - private BoosterPack readBooster(final HierarchicalStreamReader reader) - { + + private BoosterPack readBooster(final HierarchicalStreamReader reader) { String set = reader.getAttribute("s"); return new BoosterPack(set); } - private CardPrinted readCardPrinted(final HierarchicalStreamReader reader) - { + private CardPrinted readCardPrinted(final HierarchicalStreamReader reader) { String name = reader.getAttribute("c"); String set = reader.getAttribute("s"); String sIndex = reader.getAttribute("i"); diff --git a/src/main/java/forge/quest/data/QuestMatchState.java b/src/main/java/forge/quest/data/QuestMatchState.java index 659d9fca1e3..45c8c1109fe 100644 --- a/src/main/java/forge/quest/data/QuestMatchState.java +++ b/src/main/java/forge/quest/data/QuestMatchState.java @@ -7,39 +7,72 @@ import java.util.Map; import forge.game.GameSummary; - /** - *

QuestMatchState class.

- * + *

+ * QuestMatchState class. + *

+ * * @author Forge * @version $Id$ */ - public class QuestMatchState { + + /** The Constant GAMES_PER_MATCH. */ public static final int GAMES_PER_MATCH = 3; + + /** The Constant MIN_GAMES_TO_WIN_MATCH. */ public static final int MIN_GAMES_TO_WIN_MATCH = 2; private List gamesPlayed = new ArrayList(); - //ArrayList + // ArrayList + + /** + * Adds the game played. + * + * @param completedGame + * the completed game + */ public final void addGamePlayed(final GameSummary completedGame) { gamesPlayed.add(completedGame); } + /** + * Gets the games played. + * + * @return the games played + */ public final GameSummary[] getGamesPlayed() { return gamesPlayed.toArray(new GameSummary[gamesPlayed.size()]); } + /** + * Gets the games played count. + * + * @return the games played count + */ public final int getGamesPlayedCount() { return gamesPlayed.size(); } - public final boolean hasWonLastGame(String playerName) { + /** + * Checks for won last game. + * + * @param playerName + * the player name + * @return true, if successful + */ + public final boolean hasWonLastGame(final String playerName) { int iLastGame = gamesPlayed.size() - 1; return iLastGame >= 0 ? gamesPlayed.get(iLastGame).isWinner(playerName) : false; } + /** + * Checks if is match over. + * + * @return true, if is match over + */ public final boolean isMatchOver() { int totalGames = 0; @@ -51,8 +84,8 @@ public class QuestMatchState { winsCount.put(winner, wins + 1); totalGames++; } - - int maxWins = 0; + + int maxWins = 0; for (Integer win : winsCount.values()) { maxWins = Math.max(maxWins, win); } @@ -60,18 +93,37 @@ public class QuestMatchState { return maxWins >= MIN_GAMES_TO_WIN_MATCH || totalGames >= GAMES_PER_MATCH; } + /** + * Count games won by. + * + * @param name + * the name + * @return the int + */ public final int countGamesWonBy(String name) { int wins = 0; for (GameSummary game : gamesPlayed) { - if (game.isWinner(name)) { wins++; } + if (game.isWinner(name)) { + wins++; + } } return wins; } + /** + * Checks if is match won by. + * + * @param name + * the name + * @return true, if is match won by + */ public final boolean isMatchWonBy(String name) { return countGamesWonBy(name) >= MIN_GAMES_TO_WIN_MATCH; } + /** + * Reset. + */ public final void reset() { gamesPlayed.clear(); } diff --git a/src/main/java/forge/quest/data/QuestPreferences.java b/src/main/java/forge/quest/data/QuestPreferences.java index 3e834215ca6..e8e689a0fe1 100644 --- a/src/main/java/forge/quest/data/QuestPreferences.java +++ b/src/main/java/forge/quest/data/QuestPreferences.java @@ -1,158 +1,163 @@ package forge.quest.data; -import forge.properties.ForgeProps; -import forge.properties.NewConstants.QUEST; - import java.io.BufferedReader; import java.io.FileReader; import java.io.Serializable; +import forge.properties.ForgeProps; +import forge.properties.NewConstants.QUEST; + /** - *

QuestPreferences class.

- * + *

+ * QuestPreferences class. + *

+ * * @author Forge * @version $Id$ */ public class QuestPreferences implements Serializable { - /** Constant serialVersionUID=3266336025656577905L */ + /** Constant serialVersionUID=3266336025656577905L. */ private static final long serialVersionUID = 3266336025656577905L; - /** Constant numDiff=4 */ + /** Constant numDiff=4. */ private static int numDiff = 4; // Descriptive difficulty names - /** Constant sDifficulty="{Easy, Normal, Hard, Very Hard}" */ + /** Constant sDifficulty="{Easy, Normal, Hard, Very Hard}". */ private static String[] sDifficulty = {"Easy", "Normal", "Hard", "Very Hard"}; // Default match wins it takes to gain a booster - /** Constant winsForBooster={1, 1, 2, 2} */ - private static int[] winsForBooster = {1, 1, 2, 2}; - /** Constant winsForRankIncrease={1, 2, 3, 4} */ - private static int[] winsForRankIncrease = {1, 2, 3, 4}; - /** Constant winsForMediumAI={6, 6, 11, 11} */ - private static int[] winsForMediumAI = {6, 6, 11, 11}; - /** Constant winsForHardAI={9, 9, 21, 21} */ - private static int[] winsForHardAI = {9, 9, 21, 21}; - /** Constant winsForVeryHardAI={29, 29, 31, 31} */ - private static int[] winsForVeryHardAI = {29, 29, 31, 31}; + /** Constant winsForBooster={1, 1, 2, 2}. */ + private static int[] winsForBooster = { 1, 1, 2, 2 }; + /** Constant winsForRankIncrease={1, 2, 3, 4}. */ + private static int[] winsForRankIncrease = { 1, 2, 3, 4 }; + /** Constant winsForMediumAI={6, 6, 11, 11}. */ + private static int[] winsForMediumAI = { 6, 6, 11, 11 }; + /** Constant winsForHardAI={9, 9, 21, 21}. */ + private static int[] winsForHardAI = { 9, 9, 21, 21 }; + /** Constant winsForVeryHardAI={29, 29, 31, 31}. */ + private static int[] winsForVeryHardAI = { 29, 29, 31, 31 }; // Default starting land for a quest - /** Constant startingBasicLand=20 */ + /** Constant startingBasicLand=20. */ private static int startingBasicLand = 20; - /** Constant startingSnowBasicLand=20 */ + /** Constant startingSnowBasicLand=20. */ private static int startingSnowBasicLand = 20; // Default starting amount of each rarity - /** Constant startingCommons={45, 40, 40, 40} */ - private static int[] startingCommons = {45, 40, 40, 40}; - /** Constant startingUncommons={20, 15, 15, 15} */ - private static int[] startingUncommons = {20, 15, 15, 15}; - /** Constant startingRares={10, 10, 10, 10} */ - private static int[] startingRares = {10, 10, 10, 10}; + /** Constant startingCommons={45, 40, 40, 40}. */ + private static int[] startingCommons = { 45, 40, 40, 40 }; + /** Constant startingUncommons={20, 15, 15, 15}. */ + private static int[] startingUncommons = { 20, 15, 15, 15 }; + /** Constant startingRares={10, 10, 10, 10}. */ + private static int[] startingRares = { 10, 10, 10, 10 }; - /** Constant startingCredits=250 */ + /** Constant startingCredits=250. */ private static int startingCredits = 250; - /** Constant boosterPackRare=1 */ + /** Constant boosterPackRare=1. */ private static int boosterPackRare = 1; - /** Constant boosterPackUncommon=3 */ + /** Constant boosterPackUncommon=3. */ private static int boosterPackUncommon = 3; - /** Constant boosterPackCommon=9 */ + /** Constant boosterPackCommon=9. */ private static int boosterPackCommon = 9; - /** Constant matchRewardBase=10 */ + /** Constant matchRewardBase=10. */ private static int matchRewardBase = 10; - /** Constant matchRewardTotalWins=0.3 */ + /** Constant matchRewardTotalWins=0.3. */ private static double matchRewardTotalWins = 0.3; - /** Constant matchRewardNoLosses=10 */ + /** Constant matchRewardNoLosses=10. */ private static int matchRewardNoLosses = 10; - /** Constant matchRewardPoisonWinBonus=50 */ + /** Constant matchRewardPoisonWinBonus=50. */ private static int matchRewardPoisonWinBonus = 50; - /** Constant matchRewardMilledWinBonus=40 */ + /** Constant matchRewardMilledWinBonus=40. */ private static int matchRewardMilledWinBonus = 40; - /** Constant matchRewardAltWinBonus=100 */ + /** Constant matchRewardAltWinBonus=100. */ private static int matchRewardAltWinBonus = 100; - /** Constant matchRewardWinOnFirstTurn=1500 */ + /** Constant matchRewardWinOnFirstTurn=1500. */ private static int matchRewardWinOnFirstTurn = 1500; - /** Constant matchRewardWinByTurnFive=250 */ + /** Constant matchRewardWinByTurnFive=250. */ private static int matchRewardWinByTurnFive = 250; - /** Constant matchRewardWinByTurnTen=50 */ + /** Constant matchRewardWinByTurnTen=50. */ private static int matchRewardWinByTurnTen = 50; - /** Constant matchRewardWinByTurnFifteen=5 */ + /** Constant matchRewardWinByTurnFifteen=5. */ private static int matchRewardWinByTurnFifteen = 5; - /** Constant matchRewardMullToZero=500 */ + /** Constant matchRewardMullToZero=500. */ private static int matchRewardMullToZero = 500; - static { // if quest.prefs exists grabPrefsFromFile(); } /** - *

grabPrefsFromFile.

+ *

+ * grabPrefsFromFile. + *

*/ public static void grabPrefsFromFile() { try { BufferedReader input = new BufferedReader(new FileReader(ForgeProps.getFile(QUEST.PREFS))); String line = null; while ((line = input.readLine()) != null) { - if (line.startsWith("#") || line.length() == 0) + if (line.startsWith("#") || line.length() == 0) { continue; + } String[] split = line.split("="); - if (split[0].equals("difficultyString")) + if (split[0].equals("difficultyString")) { setDifficulty(split[1]); - else if (split[0].equals("winsForBooster")) + } else if (split[0].equals("winsForBooster")) { setWinsForBooster(split[1]); - else if (split[0].equals("winsForRankIncrease")) + } else if (split[0].equals("winsForRankIncrease")) { setWinsForRank(split[1]); - else if (split[0].equals("winsForMediumAI")) + } else if (split[0].equals("winsForMediumAI")) { setWinsForMediumAI(split[1]); - else if (split[0].equals("winsForHardAI")) + } else if (split[0].equals("winsForHardAI")) { setWinsForHardAI(split[1]); - else if (split[0].equals("startingBasicLand")) + } else if (split[0].equals("startingBasicLand")) { setStartingBasic(split[1]); - else if (split[0].equals("startingSnowBasicLand")) + } else if (split[0].equals("startingSnowBasicLand")) { setStartingSnowBasic(split[1]); - else if (split[0].equals("startingCommons")) + } else if (split[0].equals("startingCommons")) { setStartingCommons(split[1]); - else if (split[0].equals("startingUncommons")) + } else if (split[0].equals("startingUncommons")) { setStartingUncommons(split[1]); - else if (split[0].equals("startingRares")) + } else if (split[0].equals("startingRares")) { setStartingRares(split[1]); - else if (split[0].equals("startingCredits")) + } else if (split[0].equals("startingCredits")) { setStartingCredits(split[1]); - else if (split[0].equals("boosterPackCommon")) + } else if (split[0].equals("boosterPackCommon")) { setNumCommon(split[1]); - else if (split[0].equals("boosterPackUncommon")) + } else if (split[0].equals("boosterPackUncommon")) { setNumUncommon(split[1]); - else if (split[0].equals("boosterPackRare")) + } else if (split[0].equals("boosterPackRare")) { setNumRares(split[1]); - else if (split[0].equals("matchRewardBase")) + } else if (split[0].equals("matchRewardBase")) { setMatchRewardBase(split[1]); - else if (split[0].equals("matchRewardTotalWins")) + } else if (split[0].equals("matchRewardTotalWins")) { setMatchRewardTotalWins(split[1]); - else if (split[0].equals("matchRewardNoLosses")) + } else if (split[0].equals("matchRewardNoLosses")) { setMatchRewardNoLosses(split[1]); - else if (split[0].equals("matchRewardMilledWinBonus")) + } else if (split[0].equals("matchRewardMilledWinBonus")) { setMatchRewardMilledWinBonus(split[1]); - else if (split[0].equals("matchRewardPoisonWinBonus")) + } else if (split[0].equals("matchRewardPoisonWinBonus")) { setMatchRewardPoisonWinBonus(split[1]); - else if (split[0].equals("matchRewardAltWinBonus")) + } else if (split[0].equals("matchRewardAltWinBonus")) { setMatchRewardAltWinBonus(split[1]); - else if (split[0].equals("matchRewardWinOnFirstTurn")) + } else if (split[0].equals("matchRewardWinOnFirstTurn")) { setMatchRewardWinFirst(split[1]); - else if (split[0].equals("matchRewardWinByTurnFive")) + } else if (split[0].equals("matchRewardWinByTurnFive")) { setMatchRewardWinByFifth(split[1]); - else if (split[0].equals("matchRewardWinByTurnTen")) + } else if (split[0].equals("matchRewardWinByTurnTen")) { setMatchRewardWinByTen(split[1]); - else if (split[0].equals("matchRewardWinByTurnFifteen")) + } else if (split[0].equals("matchRewardWinByTurnFifteen")) { setMatchRewardWinByFifteen(split[1]); - else if (split[0].equals("matchRewardMullToZero")) + } else if (split[0].equals("matchRewardMullToZero")) { setMatchMullToZero(split[1]); + } } } catch (Exception e) { System.out.println("Trouble grabbing quest data preferences. Using default values."); @@ -160,8 +165,10 @@ public class QuestPreferences implements Serializable { } /** - *

getDifficulty.

- * + *

+ * getDifficulty. + *

+ * * @return an array of {@link java.lang.String} objects. */ public static String[] getDifficulty() { @@ -169,68 +176,88 @@ public class QuestPreferences implements Serializable { } /** - *

getDifficulty.

- * - * @param index a int. + *

+ * getDifficulty. + *

+ * + * @param index + * a int. * @return a {@link java.lang.String} object. */ - public static String getDifficulty(int index) { + public static String getDifficulty(final int index) { return sDifficulty[index]; } /** - *

Getter for the field winsForBooster.

- * - * @param index a int. + *

+ * Getter for the field winsForBooster. + *

+ * + * @param index + * a int. * @return a int. */ - public static int getWinsForBooster(int index) { + public static int getWinsForBooster(final int index) { return winsForBooster[index]; } /** - *

Getter for the field winsForRankIncrease.

- * - * @param index a int. + *

+ * Getter for the field winsForRankIncrease. + *

+ * + * @param index + * a int. * @return a int. */ - public static int getWinsForRankIncrease(int index) { + public static int getWinsForRankIncrease(final int index) { return winsForRankIncrease[index]; } /** - *

Getter for the field winsForMediumAI.

- * - * @param index a int. + *

+ * Getter for the field winsForMediumAI. + *

+ * + * @param index + * a int. * @return a int. */ - public static int getWinsForMediumAI(int index) { + public static int getWinsForMediumAI(final int index) { return winsForMediumAI[index]; } /** - *

Getter for the field winsForHardAI.

- * - * @param index a int. + *

+ * Getter for the field winsForHardAI. + *

+ * + * @param index + * a int. * @return a int. */ - public static int getWinsForHardAI(int index) { + public static int getWinsForHardAI(final int index) { return winsForHardAI[index]; } /** - *

Getter for the field winsForVeryHardAI.

- * - * @param index a int. + *

+ * Getter for the field winsForVeryHardAI. + *

+ * + * @param index + * a int. * @return a int. */ - public static int getWinsForVeryHardAI(int index) { + public static int getWinsForVeryHardAI(final int index) { return winsForVeryHardAI[index]; } /** - *

getStartingBasic.

- * + *

+ * getStartingBasic. + *

+ * * @return a int. */ public static int getStartingBasic() { @@ -238,8 +265,10 @@ public class QuestPreferences implements Serializable { } /** - *

getStartingSnowBasic.

- * + *

+ * getStartingSnowBasic. + *

+ * * @return a int. */ public static int getStartingSnowBasic() { @@ -247,38 +276,49 @@ public class QuestPreferences implements Serializable { } /** - *

Getter for the field startingCommons.

- * - * @param index a int. + *

+ * Getter for the field startingCommons. + *

+ * + * @param index + * a int. * @return a int. */ - public static int getStartingCommons(int index) { + public static int getStartingCommons(final int index) { return startingCommons[index]; } /** - *

Getter for the field startingUncommons.

- * - * @param index a int. + *

+ * Getter for the field startingUncommons. + *

+ * + * @param index + * a int. * @return a int. */ - public static int getStartingUncommons(int index) { + public static int getStartingUncommons(final int index) { return startingUncommons[index]; } /** - *

Getter for the field startingRares.

- * - * @param index a int. + *

+ * Getter for the field startingRares. + *

+ * + * @param index + * a int. * @return a int. */ - public static int getStartingRares(int index) { + public static int getStartingRares(final int index) { return startingRares[index]; } /** - *

Getter for the field startingCredits.

- * + *

+ * Getter for the field startingCredits. + *

+ * * @return a int. */ public static int getStartingCredits() { @@ -286,8 +326,10 @@ public class QuestPreferences implements Serializable { } /** - *

getNumCommon.

- * + *

+ * getNumCommon. + *

+ * * @return a int. */ public static int getNumCommon() { @@ -295,8 +337,10 @@ public class QuestPreferences implements Serializable { } /** - *

getNumUncommon.

- * + *

+ * getNumUncommon. + *

+ * * @return a int. */ public static int getNumUncommon() { @@ -304,18 +348,21 @@ public class QuestPreferences implements Serializable { } /** - *

getNumRare.

- * + *

+ * getNumRare. + *

+ * * @return a int. */ public static int getNumRare() { return boosterPackRare; } - /** - *

Getter for the field matchRewardBase.

- * + *

+ * Getter for the field matchRewardBase. + *

+ * * @return a int. */ public static int getMatchRewardBase() { @@ -323,8 +370,10 @@ public class QuestPreferences implements Serializable { } /** - *

Getter for the field matchRewardTotalWins.

- * + *

+ * Getter for the field matchRewardTotalWins. + *

+ * * @return a double. */ public static double getMatchRewardTotalWins() { @@ -332,8 +381,10 @@ public class QuestPreferences implements Serializable { } /** - *

Getter for the field matchRewardNoLosses.

- * + *

+ * Getter for the field matchRewardNoLosses. + *

+ * * @return a int. */ public static int getMatchRewardNoLosses() { @@ -341,8 +392,10 @@ public class QuestPreferences implements Serializable { } /** - *

Getter for the field matchRewardPoisonWinBonus.

- * + *

+ * Getter for the field matchRewardPoisonWinBonus. + *

+ * * @return a int. */ public static int getMatchRewardPoisonWinBonus() { @@ -350,8 +403,10 @@ public class QuestPreferences implements Serializable { } /** - *

Getter for the field matchRewardMilledWinBonus.

- * + *

+ * Getter for the field matchRewardMilledWinBonus. + *

+ * * @return a int. */ public static int getMatchRewardMilledWinBonus() { @@ -359,18 +414,21 @@ public class QuestPreferences implements Serializable { } /** - *

Getter for the field matchRewardAltWinBonus.

- * + *

+ * Getter for the field matchRewardAltWinBonus. + *

+ * * @return a int. */ public static int getMatchRewardAltWinBonus() { return matchRewardAltWinBonus; } - /** - *

getMatchRewardWinFirst.

- * + *

+ * getMatchRewardWinFirst. + *

+ * * @return a int. */ public static int getMatchRewardWinFirst() { @@ -378,8 +436,10 @@ public class QuestPreferences implements Serializable { } /** - *

getMatchRewardWinByFifth.

- * + *

+ * getMatchRewardWinByFifth. + *

+ * * @return a int. */ public static int getMatchRewardWinByFifth() { @@ -387,8 +447,10 @@ public class QuestPreferences implements Serializable { } /** - *

getMatchRewardWinByTen.

- * + *

+ * getMatchRewardWinByTen. + *

+ * * @return a int. */ public static int getMatchRewardWinByTen() { @@ -396,8 +458,10 @@ public class QuestPreferences implements Serializable { } /** - *

getMatchRewardWinByFifteen.

- * + *

+ * getMatchRewardWinByFifteen. + *

+ * * @return a int. */ public static int getMatchRewardWinByFifteen() { @@ -405,261 +469,342 @@ public class QuestPreferences implements Serializable { } /** - *

getMatchMullToZero.

- * + *

+ * getMatchMullToZero. + *

+ * * @return a int. */ public static int getMatchMullToZero() { return matchRewardMullToZero; } - // setters /** - *

setDifficulty.

- * - * @param diff a {@link java.lang.String} object. + *

+ * setDifficulty. + *

+ * + * @param diff + * a {@link java.lang.String} object. */ - public static void setDifficulty(String diff) { + public static void setDifficulty(final String diff) { sDifficulty = diff.split(","); } /** - *

Setter for the field winsForBooster.

- * - * @param wins a {@link java.lang.String} object. + *

+ * Setter for the field winsForBooster. + *

+ * + * @param wins + * a {@link java.lang.String} object. */ - public static void setWinsForBooster(String wins) { + public static void setWinsForBooster(final String wins) { String[] winsStr = wins.split(","); - for (int i = 0; i < numDiff; i++) + for (int i = 0; i < numDiff; i++) { winsForBooster[i] = Integer.parseInt(winsStr[i]); + } } /** - *

setWinsForRank.

- * - * @param wins a {@link java.lang.String} object. + *

+ * setWinsForRank. + *

+ * + * @param wins + * a {@link java.lang.String} object. */ - public static void setWinsForRank(String wins) { + public static void setWinsForRank(final String wins) { String[] winsStr = wins.split(","); - for (int i = 0; i < numDiff; i++) + for (int i = 0; i < numDiff; i++) { winsForRankIncrease[i] = Integer.parseInt(winsStr[i]); + } } /** - *

Setter for the field winsForMediumAI.

- * - * @param wins a {@link java.lang.String} object. + *

+ * Setter for the field winsForMediumAI. + *

+ * + * @param wins + * a {@link java.lang.String} object. */ - public static void setWinsForMediumAI(String wins) { + public static void setWinsForMediumAI(final String wins) { String[] winsStr = wins.split(","); - for (int i = 0; i < numDiff; i++) + for (int i = 0; i < numDiff; i++) { winsForMediumAI[i] = Integer.parseInt(winsStr[i]); + } } /** - *

Setter for the field winsForHardAI.

- * - * @param wins a {@link java.lang.String} object. + *

+ * Setter for the field winsForHardAI. + *

+ * + * @param wins + * a {@link java.lang.String} object. */ - public static void setWinsForHardAI(String wins) { + public static void setWinsForHardAI(final String wins) { String[] winsStr = wins.split(","); - for (int i = 0; i < numDiff; i++) + for (int i = 0; i < numDiff; i++) { winsForHardAI[i] = Integer.parseInt(winsStr[i]); + } } /** - *

setStartingBasic.

- * - * @param land a {@link java.lang.String} object. + *

+ * setStartingBasic. + *

+ * + * @param land + * a {@link java.lang.String} object. */ - public static void setStartingBasic(String land) { + public static void setStartingBasic(final String land) { startingBasicLand = Integer.parseInt(land); } /** - *

setStartingSnowBasic.

- * - * @param land a {@link java.lang.String} object. + *

+ * setStartingSnowBasic. + *

+ * + * @param land + * a {@link java.lang.String} object. */ - public static void setStartingSnowBasic(String land) { + public static void setStartingSnowBasic(final String land) { startingSnowBasicLand = Integer.parseInt(land); } /** - *

Setter for the field startingCommons.

- * - * @param rarity a {@link java.lang.String} object. + *

+ * Setter for the field startingCommons. + *

+ * + * @param rarity + * a {@link java.lang.String} object. */ - public static void setStartingCommons(String rarity) { + public static void setStartingCommons(final String rarity) { String[] splitStr = rarity.split(","); - for (int i = 0; i < numDiff; i++) + for (int i = 0; i < numDiff; i++) { startingCommons[i] = Integer.parseInt(splitStr[i]); + } } /** - *

Setter for the field startingUncommons.

- * - * @param rarity a {@link java.lang.String} object. + *

+ * Setter for the field startingUncommons. + *

+ * + * @param rarity + * a {@link java.lang.String} object. */ - public static void setStartingUncommons(String rarity) { + public static void setStartingUncommons(final String rarity) { String[] splitStr = rarity.split(","); - for (int i = 0; i < numDiff; i++) + for (int i = 0; i < numDiff; i++) { startingUncommons[i] = Integer.parseInt(splitStr[i]); + } } /** - *

Setter for the field startingRares.

- * - * @param rarity a {@link java.lang.String} object. + *

+ * Setter for the field startingRares. + *

+ * + * @param rarity + * a {@link java.lang.String} object. */ - public static void setStartingRares(String rarity) { + public static void setStartingRares(final String rarity) { String[] splitStr = rarity.split(","); - for (int i = 0; i < numDiff; i++) + for (int i = 0; i < numDiff; i++) { startingRares[i] = Integer.parseInt(splitStr[i]); + } } /** - *

Setter for the field startingCredits.

- * - * @param credits a {@link java.lang.String} object. + *

+ * Setter for the field startingCredits. + *

+ * + * @param credits + * a {@link java.lang.String} object. */ - public static void setStartingCredits(String credits) { + public static void setStartingCredits(final String credits) { startingCredits = Integer.parseInt(credits); } /** - *

setNumCommon.

- * - * @param pack a {@link java.lang.String} object. + *

+ * setNumCommon. + *

+ * + * @param pack + * a {@link java.lang.String} object. */ - public static void setNumCommon(String pack) { + public static void setNumCommon(final String pack) { boosterPackCommon = Integer.parseInt(pack); } /** - *

setNumUncommon.

- * - * @param pack a {@link java.lang.String} object. + *

+ * setNumUncommon. + *

+ * + * @param pack + * a {@link java.lang.String} object. */ - public static void setNumUncommon(String pack) { + public static void setNumUncommon(final String pack) { boosterPackUncommon = Integer.parseInt(pack); } /** - *

setNumRares.

- * - * @param pack a {@link java.lang.String} object. + *

+ * setNumRares. + *

+ * + * @param pack + * a {@link java.lang.String} object. */ - public static void setNumRares(String pack) { + public static void setNumRares(final String pack) { boosterPackRare = Integer.parseInt(pack); } - /** - *

Setter for the field matchRewardBase.

- * - * @param match a {@link java.lang.String} object. + *

+ * Setter for the field matchRewardBase. + *

+ * + * @param match + * a {@link java.lang.String} object. */ - public static void setMatchRewardBase(String match) { + public static void setMatchRewardBase(final String match) { matchRewardBase = Integer.parseInt(match); } /** - *

Setter for the field matchRewardTotalWins.

- * - * @param match a {@link java.lang.String} object. + *

+ * Setter for the field matchRewardTotalWins. + *

+ * + * @param match + * a {@link java.lang.String} object. */ - public static void setMatchRewardTotalWins(String match) { + public static void setMatchRewardTotalWins(final String match) { matchRewardTotalWins = Double.parseDouble(match); } /** - *

Setter for the field matchRewardNoLosses.

- * - * @param match a {@link java.lang.String} object. + *

+ * Setter for the field matchRewardNoLosses. + *

+ * + * @param match + * a {@link java.lang.String} object. */ - public static void setMatchRewardNoLosses(String match) { + public static void setMatchRewardNoLosses(final String match) { matchRewardNoLosses = Integer.parseInt(match); } /** - *

Setter for the field matchRewardPoisonWinBonus.

- * - * @param match a {@link java.lang.String} object. + *

+ * Setter for the field matchRewardPoisonWinBonus. + *

+ * + * @param match + * a {@link java.lang.String} object. */ - public static void setMatchRewardPoisonWinBonus(String match) { + public static void setMatchRewardPoisonWinBonus(final String match) { matchRewardPoisonWinBonus = Integer.parseInt(match); } /** - *

Setter for the field matchRewardMilledWinBonus.

- * - * @param match a {@link java.lang.String} object. + *

+ * Setter for the field matchRewardMilledWinBonus. + *

+ * + * @param match + * a {@link java.lang.String} object. */ - public static void setMatchRewardMilledWinBonus(String match) { + public static void setMatchRewardMilledWinBonus(final String match) { matchRewardMilledWinBonus = Integer.parseInt(match); } /** - *

Setter for the field matchRewardAltWinBonus.

- * - * @param match a {@link java.lang.String} object. + *

+ * Setter for the field matchRewardAltWinBonus. + *

+ * + * @param match + * a {@link java.lang.String} object. */ - public static void setMatchRewardAltWinBonus(String match) { + public static void setMatchRewardAltWinBonus(final String match) { matchRewardAltWinBonus = Integer.parseInt(match); } - /** - *

setMatchRewardWinFirst.

- * - * @param match a {@link java.lang.String} object. + *

+ * setMatchRewardWinFirst. + *

+ * + * @param match + * a {@link java.lang.String} object. */ - public static void setMatchRewardWinFirst(String match) { + public static void setMatchRewardWinFirst(final String match) { matchRewardWinOnFirstTurn = Integer.parseInt(match); } /** - *

setMatchRewardWinByFifth.

- * - * @param match a {@link java.lang.String} object. + *

+ * setMatchRewardWinByFifth. + *

+ * + * @param match + * a {@link java.lang.String} object. */ - public static void setMatchRewardWinByFifth(String match) { + public static void setMatchRewardWinByFifth(final String match) { matchRewardWinByTurnFive = Integer.parseInt(match); } /** - *

setMatchRewardWinByTen.

- * - * @param match a {@link java.lang.String} object. + *

+ * setMatchRewardWinByTen. + *

+ * + * @param match + * a {@link java.lang.String} object. */ - public static void setMatchRewardWinByTen(String match) { + public static void setMatchRewardWinByTen(final String match) { matchRewardWinByTurnTen = Integer.parseInt(match); } /** - *

setMatchRewardWinByFifteen.

- * - * @param match a {@link java.lang.String} object. + *

+ * setMatchRewardWinByFifteen. + *

+ * + * @param match + * a {@link java.lang.String} object. */ - public static void setMatchRewardWinByFifteen(String match) { + public static void setMatchRewardWinByFifteen(final String match) { matchRewardWinByTurnFifteen = Integer.parseInt(match); } /** - *

setMatchMullToZero.

- * - * @param match a {@link java.lang.String} object. + *

+ * setMatchMullToZero. + *

+ * + * @param match + * a {@link java.lang.String} object. */ - public static void setMatchMullToZero(String match) { + public static void setMatchMullToZero(final String match) { matchRewardMullToZero = Integer.parseInt(match); } } diff --git a/src/main/java/forge/quest/data/QuestUtil.java b/src/main/java/forge/quest/data/QuestUtil.java index 5387c7db7b2..65891340320 100644 --- a/src/main/java/forge/quest/data/QuestUtil.java +++ b/src/main/java/forge/quest/data/QuestUtil.java @@ -1,31 +1,36 @@ package forge.quest.data; +import java.util.List; + import forge.AllZone; import forge.Card; import forge.CardList; import forge.CardUtil; import forge.Constant; import forge.Player; -import forge.card.CardRarity; import forge.card.BoosterUtils; +import forge.card.CardRarity; import forge.item.CardPrinted; import forge.quest.gui.main.QuestChallenge; import forge.quest.gui.main.QuestEvent; -import java.util.List; - /** - *

QuestUtil class.

+ *

+ * QuestUtil class. + *

* MODEL - Static utility methods to help with minor tasks around Quest. - * + * * @author Forge * @version $Id$ */ public class QuestUtil { /** - *

getComputerStartingCards.

- * - * @param qd a {@link forge.quest.data.QuestData} object. + *

+ * getComputerStartingCards. + *

+ * + * @param qd + * a {@link forge.quest.data.QuestData} object. * @return a {@link forge.CardList} object. */ public static CardList getComputerStartingCards(final QuestData qd) { @@ -33,32 +38,39 @@ public class QuestUtil { } /** - *

getComputerStartingCards.

+ *

+ * getComputerStartingCards. + *

* Returns new card instances of extra AI cards in play at start of event. - * - * @param qd a {@link forge.quest.data.QuestData} object. - * @param qe a {@link forge.quest.gui.main.QuestEvent} object. + * + * @param qd + * a {@link forge.quest.data.QuestData} object. + * @param qe + * a {@link forge.quest.gui.main.QuestEvent} object. * @return a {@link forge.CardList} object. */ - public static CardList getComputerStartingCards(final QuestData qd, QuestEvent qe) { + public static CardList getComputerStartingCards(final QuestData qd, final QuestEvent qe) { CardList list = new CardList(); - - if(qe.getEventType().equals("challenge")) { - List extras = ((QuestChallenge)qe).getAIExtraCards(); - - for(String s : extras) { + + if (qe.getEventType().equals("challenge")) { + List extras = ((QuestChallenge) qe).getAIExtraCards(); + + for (String s : extras) { list.add(readExtraCard(s, AllZone.getComputerPlayer())); } } - + return list; } /** - *

getHumanStartingCards.

+ *

+ * getHumanStartingCards. + *

* Returns list of current plant/pet configuration only. - * - * @param qd a {@link forge.quest.data.QuestData} object. + * + * @param qd + * a {@link forge.quest.data.QuestData} object. * @return a {@link forge.CardList} object. */ public static CardList getHumanStartingCards(final QuestData qd) { @@ -76,119 +88,121 @@ public class QuestUtil { } /** - *

getHumanStartingCards.

- * Returns new card instances of extra human cards, - * including current plant/pet configuration, - * and cards in play at start of quest. - * - * @param qd a {@link forge.quest.data.QuestData} object. - * @param qe a {@link forge.quest.gui.main.QuestEvent} object. + *

+ * getHumanStartingCards. + *

+ * Returns new card instances of extra human cards, including current + * plant/pet configuration, and cards in play at start of quest. + * + * @param qd + * a {@link forge.quest.data.QuestData} object. + * @param qe + * a {@link forge.quest.gui.main.QuestEvent} object. * @return a {@link forge.CardList} object. */ - public static CardList getHumanStartingCards(final QuestData qd, QuestEvent qe) { + public static CardList getHumanStartingCards(final QuestData qd, final QuestEvent qe) { CardList list = getHumanStartingCards(qd); - - if(qe.getEventType().equals("challenge")) { - List extras = ((QuestChallenge)qe).getHumanExtraCards(); - - for(String s : extras) { + + if (qe.getEventType().equals("challenge")) { + List extras = ((QuestChallenge) qe).getHumanExtraCards(); + + for (String s : extras) { list.add(readExtraCard(s, AllZone.getHumanPlayer())); } } return list; } - + /** - *

createToken.

+ *

+ * createToken. + *

* Creates a card instance for token defined by property string. * - * @param s Properties string of token (TOKEN;W;1;1;sheep;type;type;type...) + * @param s + * Properties string of token + * (TOKEN;W;1;1;sheep;type;type;type...) * @return token Card */ - public static Card createToken(String s) { - String[] properties = s.split(";");; - + public static Card createToken(final String s) { + String[] properties = s.split(";"); Card c = new Card(); c.setToken(true); - - //c.setManaCost(properties[1]); + + // c.setManaCost(properties[1]); c.addColor(properties[1]); c.setBaseAttack(Integer.parseInt(properties[2])); c.setBaseDefense(Integer.parseInt(properties[3])); c.setName(properties[4]); - - c.setImageName( - properties[1]+" "+ - properties[2]+" "+ - properties[3]+" "+ - properties[4] - ); + + c.setImageName(properties[1] + " " + properties[2] + " " + properties[3] + " " + properties[4]); int x = 5; - while(x != properties.length) { + while (x != properties.length) { c.addType(properties[x++]); - } + } return c; } - + /** - *

generateCardRewardList.

+ *

+ * generateCardRewardList. + *

* Takes a reward list string, parses, and returns list of cards rewarded. * - * @param s Properties string of reward (97 multicolor rares) + * @param s + * Properties string of reward (97 multicolor rares) * @return CardList */ - public static List generateCardRewardList(String s) { + public static List generateCardRewardList(final String s) { String[] temp = s.split(" "); - + int qty = Integer.parseInt(temp[0]); // Determine rarity CardRarity rar = CardRarity.Uncommon; - if(temp[2].equalsIgnoreCase("rare") || temp[2].equalsIgnoreCase("rares")) { + if (temp[2].equalsIgnoreCase("rare") || temp[2].equalsIgnoreCase("rares")) { rar = CardRarity.Rare; } - + // Determine color ("random" defaults to null color) String col = null; - if(temp[1].equalsIgnoreCase("black")) { + if (temp[1].equalsIgnoreCase("black")) { col = Constant.Color.Black; - } - else if(temp[1].equalsIgnoreCase("blue")) { + } else if (temp[1].equalsIgnoreCase("blue")) { col = Constant.Color.Blue; - } - else if(temp[1].equalsIgnoreCase("colorless")) { + } else if (temp[1].equalsIgnoreCase("colorless")) { col = Constant.Color.Colorless; - } - else if(temp[1].equalsIgnoreCase("green")) { + } else if (temp[1].equalsIgnoreCase("green")) { col = Constant.Color.Green; - } - else if(temp[1].equalsIgnoreCase("multicolor")) { + } else if (temp[1].equalsIgnoreCase("multicolor")) { col = "Multicolor"; // Note: No constant color for this?? - } - else if(temp[1].equalsIgnoreCase("red")) { + } else if (temp[1].equalsIgnoreCase("red")) { col = Constant.Color.Red; - } - else if(temp[1].equalsIgnoreCase("white")) { + } else if (temp[1].equalsIgnoreCase("white")) { col = Constant.Color.White; } - + return BoosterUtils.generateCards(qty, rar, col); } - + /** - *

readExtraCard.

+ *

+ * readExtraCard. + *

* Creates single card for a string read from unique event properties. * * @param name + * the name * @param owner - * @return + * the owner + * @return the card */ - public static Card readExtraCard(String name, Player owner) { + public static Card readExtraCard(final String name, final Player owner) { // Token card creation Card tempcard; - if(name.startsWith("TOKEN")) { + if (name.startsWith("TOKEN")) { tempcard = QuestUtil.createToken(name); tempcard.addController(owner); tempcard.setOwner(owner); @@ -202,4 +216,4 @@ public class QuestUtil { return tempcard; } -} //QuestUtil +} // QuestUtil diff --git a/src/main/java/forge/quest/data/QuestUtilCards.java b/src/main/java/forge/quest/data/QuestUtilCards.java index a56a2581462..74db4da280b 100644 --- a/src/main/java/forge/quest/data/QuestUtilCards.java +++ b/src/main/java/forge/quest/data/QuestUtilCards.java @@ -6,12 +6,11 @@ import java.util.Map.Entry; import net.slightlymagic.braids.util.lambda.Lambda1; import net.slightlymagic.maxmtg.Predicate; - import forge.MyRandom; import forge.SetUtils; import forge.card.BoosterGenerator; -import forge.card.CardRarity; import forge.card.BoosterUtils; +import forge.card.CardRarity; import forge.card.CardSet; import forge.deck.Deck; import forge.item.BoosterPack; @@ -21,15 +20,34 @@ import forge.item.InventoryItem; import forge.item.ItemPool; import forge.item.ItemPoolView; -/** - * This is a helper class to execute operations on QuestData. - * It has been created to decrease complexity of questData class +/** + * This is a helper class to execute operations on QuestData. It has been + * created to decrease complexity of questData class */ public final class QuestUtilCards { private QuestData q; - public QuestUtilCards(final QuestData qd) { q = qd; } - public void addBasicLands(ItemPool pool, final int nBasic, final int nSnow) { + /** + * Instantiates a new quest util cards. + * + * @param qd + * the qd + */ + public QuestUtilCards(final QuestData qd) { + q = qd; + } + + /** + * Adds the basic lands. + * + * @param pool + * the pool + * @param nBasic + * the n basic + * @param nSnow + * the n snow + */ + public void addBasicLands(final ItemPool pool, final int nBasic, final int nSnow) { CardDb db = CardDb.instance(); pool.add(db.getCard("Forest", "M10"), nBasic); pool.add(db.getCard("Mountain", "M10"), nBasic); @@ -44,11 +62,17 @@ public final class QuestUtilCards { pool.add(db.getCard("Snow-Covered Plains", "ICE"), nSnow); } - //adds 11 cards, to the current card pool - //(I chose 11 cards instead of 15 in order to make things more challenging) + // adds 11 cards, to the current card pool + // (I chose 11 cards instead of 15 in order to make things more challenging) /** - *

addCards.

+ *

+ * addCards. + *

+ * + * @param fSets + * the f sets + * @return the array list */ public ArrayList addCards(final Predicate fSets) { int nCommon = QuestPreferences.getNumCommon(); @@ -64,13 +88,25 @@ public final class QuestUtilCards { return newCards; } + /** + * Adds the all cards. + * + * @param newCards + * the new cards + */ public void addAllCards(final Iterable newCards) { for (CardPrinted card : newCards) { addSingleCard(card); } } - - public void addSingleCard(CardPrinted card) { + + /** + * Adds the single card. + * + * @param card + * the card + */ + public void addSingleCard(final CardPrinted card) { q.cardPool.add(card); // register card into that list so that it would appear as a new one. @@ -78,19 +114,40 @@ public final class QuestUtilCards { } private static final Predicate rarePredicate = CardPrinted.Predicates.Presets.isRareOrMythic; + + /** + * Adds the random rare. + * + * @return the card printed + */ public CardPrinted addRandomRare() { CardPrinted card = rarePredicate.random(CardDb.instance().getAllCards()); addSingleCard(card); return card; } + + /** + * Adds the random rare. + * + * @param n + * the n + * @return the list + */ public List addRandomRare(final int n) { List newCards = rarePredicate.random(CardDb.instance().getAllCards(), n); addAllCards(newCards); return newCards; } - public void setupNewGameCardPool(final Predicate filter, final int idxDifficulty) - { + /** + * Setup new game card pool. + * + * @param filter + * the filter + * @param idxDifficulty + * the idx difficulty + */ + public void setupNewGameCardPool(final Predicate filter, final int idxDifficulty) { int nC = QuestPreferences.getStartingCommons(idxDifficulty); int nU = QuestPreferences.getStartingUncommons(idxDifficulty); int nR = QuestPreferences.getStartingRares(idxDifficulty); @@ -98,6 +155,14 @@ public final class QuestUtilCards { addAllCards(BoosterUtils.getQuestStarterDeck(filter, nC, nU, nR)); } + /** + * Buy card. + * + * @param card + * the card + * @param value + * the value + */ public void buyCard(final CardPrinted card, final int value) { if (q.credits >= value) { q.credits -= value; @@ -106,6 +171,14 @@ public final class QuestUtilCards { } } + /** + * Buy booster. + * + * @param booster + * the booster + * @param value + * the value + */ public void buyBooster(final BoosterPack booster, final int value) { if (q.credits >= value) { q.credits -= value; @@ -114,8 +187,18 @@ public final class QuestUtilCards { } } + /** + * Sell card. + * + * @param card + * the card + * @param price + * the price + */ public void sellCard(final CardPrinted card, final int price) { - if (price > 0) { q.credits += price; } + if (price > 0) { + q.credits += price; + } q.cardPool.remove(card); q.shopList.add(card); @@ -127,10 +210,20 @@ public final class QuestUtilCards { } } + /** + * Clear shop list. + */ public void clearShopList() { - if (null != q.shopList) { q.shopList.clear(); } + if (null != q.shopList) { + q.shopList.clear(); + } } + /** + * Gets the sell mutliplier. + * + * @return the sell mutliplier + */ public double getSellMutliplier() { double multi = 0.20 + (0.001 * q.getWin()); if (multi > 0.6) { @@ -139,19 +232,34 @@ public final class QuestUtilCards { int lvlEstates = q.isFantasy() ? q.inventory.getItemLevel("Estates") : 0; switch (lvlEstates) { - case 1: multi += 0.01; break; - case 2: multi += 0.0175; break; - case 3: multi += 0.025; break; - default: break; + case 1: + multi += 0.01; + break; + case 2: + multi += 0.0175; + break; + case 3: + multi += 0.025; + break; + default: + break; } return multi; } + /** + * Gets the sell price limit. + * + * @return the sell price limit + */ public int getSellPriceLimit() { return q.getWin() <= 50 ? 1000 : Integer.MAX_VALUE; } + /** + * Generate cards in shop. + */ public void generateCardsInShop() { BoosterGenerator pack = new BoosterGenerator(CardDb.instance().getAllCards()); @@ -160,28 +268,41 @@ public final class QuestUtilCards { int totalPacks = Math.min(levelPacks + winPacks, 6); final Predicate filterExt = CardSet.Predicates.Presets.setsInExt; - final Predicate filterT2booster = Predicate.and(CardSet.Predicates.canMakeBooster, CardSet.Predicates.Presets.setsInT2); - final Predicate filterExtButT2 = Predicate.and(CardSet.Predicates.canMakeBooster, Predicate.and(filterExt, Predicate.not(CardSet.Predicates.Presets.setsInT2))); - final Predicate filterNotExt = Predicate.and(CardSet.Predicates.canMakeBooster, Predicate.not(filterExt)); - - + final Predicate filterT2booster = Predicate.and(CardSet.Predicates.canMakeBooster, + CardSet.Predicates.Presets.setsInT2); + final Predicate filterExtButT2 = Predicate.and(CardSet.Predicates.canMakeBooster, + Predicate.and(filterExt, Predicate.not(CardSet.Predicates.Presets.setsInT2))); + final Predicate filterNotExt = Predicate.and(CardSet.Predicates.canMakeBooster, + Predicate.not(filterExt)); + q.shopList.clear(); for (int i = 0; i < totalPacks; i++) { q.shopList.addAllCards(pack.getBoosterPack(7, 3, 1, 0, 0, 0, 0, 0, 0)); // add some boosters int rollD100 = MyRandom.random.nextInt(100); - Predicate filter = rollD100 < 40 ? filterT2booster : (rollD100 < 75 ? filterExtButT2 : filterNotExt); + Predicate filter = rollD100 < 40 ? filterT2booster : (rollD100 < 75 ? filterExtButT2 + : filterNotExt); q.shopList.addAllCards(filter.random(SetUtils.getAllSets(), 1, BoosterPack.fnFromSet)); } addBasicLands(q.shopList, 10, 5); } + /** + * Gets the cardpool. + * + * @return the cardpool + */ public ItemPool getCardpool() { return q.cardPool; } + /** + * Gets the shop list. + * + * @return the shop list + */ public ItemPoolView getShopList() { if (q.shopList.isEmpty()) { generateCardsInShop(); @@ -189,26 +310,41 @@ public final class QuestUtilCards { return q.shopList; } + /** + * Gets the new cards. + * + * @return the new cards + */ public ItemPoolView getNewCards() { return q.newCardList; } + /** + * Reset new list. + */ public void resetNewList() { q.newCardList.clear(); } - // These functions provide a way to sort and compare cards in a table according to their new-ness - // It might be a good idea to store them in a base class for both quest-mode deck editors + // These functions provide a way to sort and compare cards in a table + // according to their new-ness + // It might be a good idea to store them in a base class for both quest-mode + // deck editors // Maybe we should consider doing so later + /** The fn new compare. */ @SuppressWarnings("rawtypes") - public final Lambda1> fnNewCompare = - new Lambda1>() { @Override - public Comparable apply(final Entry from) { - return q.newCardList.contains(from.getKey()) ? Integer.valueOf(1) : Integer.valueOf(0); - } }; - public final Lambda1> fnNewGet = - new Lambda1>() { @Override - public Object apply(final Entry from) { - return q.newCardList.contains(from.getKey()) ? "NEW" : ""; - } }; + public final Lambda1> fnNewCompare = new Lambda1>() { + @Override + public Comparable apply(final Entry from) { + return q.newCardList.contains(from.getKey()) ? Integer.valueOf(1) : Integer.valueOf(0); + } + }; + + /** The fn new get. */ + public final Lambda1> fnNewGet = new Lambda1>() { + @Override + public Object apply(final Entry from) { + return q.newCardList.contains(from.getKey()) ? "NEW" : ""; + } + }; } diff --git a/src/main/java/forge/quest/data/ReadPriceList.java b/src/main/java/forge/quest/data/ReadPriceList.java index 8ad6f7e76c0..da5c73c09a0 100644 --- a/src/main/java/forge/quest/data/ReadPriceList.java +++ b/src/main/java/forge/quest/data/ReadPriceList.java @@ -1,13 +1,5 @@ package forge.quest.data; - -import com.esotericsoftware.minlog.Log; - -import forge.MyRandom; -import forge.error.ErrorViewer; -import forge.properties.ForgeProps; -import forge.properties.NewConstants; - import java.io.BufferedReader; import java.io.File; import java.io.FileReader; @@ -15,43 +7,58 @@ import java.util.HashMap; import java.util.Map; import java.util.Random; +import com.esotericsoftware.minlog.Log; + +import forge.MyRandom; +import forge.error.ErrorViewer; +import forge.properties.ForgeProps; +import forge.properties.NewConstants; /** - *

ReadPriceList class.

- * + *

+ * ReadPriceList class. + *

+ * * @author Forge * @version $Id$ */ public class ReadPriceList implements NewConstants { - /** Constant comment="//" */ - final private static String comment = "//"; + /** Constant comment="//". */ + private static final String comment = "//"; private HashMap priceMap; /** - *

Constructor for ReadPriceList.

+ *

+ * Constructor for ReadPriceList. + *

*/ public ReadPriceList() { setup(); } /** - *

setup.

+ *

+ * setup. + *

*/ private void setup() { priceMap = readFile(ForgeProps.getFile(QUEST.PRICE)); priceMap.putAll(readFile(ForgeProps.getFile(QUEST.BOOSTER_PRICE))); - - }//setup() + + } // setup() /** - *

readFile.

- * - * @param file a {@link java.io.File} object. + *

+ * readFile. + *

+ * + * @param file + * a {@link java.io.File} object. * @return a {@link java.util.HashMap} object. */ - private HashMap readFile(File file) { + private HashMap readFile(final File file) { BufferedReader in; HashMap map = new HashMap(); Random r = MyRandom.random; @@ -60,30 +67,38 @@ public class ReadPriceList implements NewConstants { in = new BufferedReader(new FileReader(file)); String line = in.readLine(); - //stop reading if end of file or blank line is read + // stop reading if end of file or blank line is read while (line != null && (line.trim().length() != 0)) { if (!line.startsWith(comment)) { - String s[] = line.split("="); + String[] s = line.split("="); String name = s[0].trim(); String price = s[1].trim(); - //System.out.println("Name: " + name + ", Price: " + price); + // System.out.println("Name: " + name + ", Price: " + + // price); try { int val = Integer.parseInt(price.trim()); - if (!(name.equals("Plains") || name.equals("Island") || name.equals("Swamp") || name.equals("Mountain") || name.equals("Forest") || - name.equals("Snow-Covered Plains") || name.equals("Snow-Covered Island") || name.equals("Snow-Covered Swamp") || name.equals("Snow-Covered Mountain") || name.equals("Snow-Covered Forest"))) { + if (!(name.equals("Plains") || name.equals("Island") || name.equals("Swamp") + || name.equals("Mountain") || name.equals("Forest") + || name.equals("Snow-Covered Plains") || name.equals("Snow-Covered Island") + || name.equals("Snow-Covered Swamp") || name.equals("Snow-Covered Mountain") || name + .equals("Snow-Covered Forest"))) { float ff = 0; - if (r.nextInt(100) < 90) // +/- 10% + if (r.nextInt(100) < 90) { ff = (float) r.nextInt(10) * (float) .01; - else // +/- 50% + } else { + // +/- 50% ff = (float) r.nextInt(50) * (float) .01; + } - if (r.nextInt(100) < 50) // -ff% + if (r.nextInt(100) < 50) { val = (int) ((float) val * ((float) 1 - ff)); - else // +ff% + } else { + // +ff% val = (int) ((float) val * ((float) 1 + ff)); + } } map.put(name, val); @@ -92,7 +107,7 @@ public class ReadPriceList implements NewConstants { } } line = in.readLine(); - }//if + } // if } catch (Exception ex) { ErrorViewer.showError(ex); @@ -100,14 +115,16 @@ public class ReadPriceList implements NewConstants { } return map; - }//readFile() + } // readFile() /** - *

getPriceList.

- * + *

+ * getPriceList. + *

+ * * @return a {@link java.util.Map} object. */ - public Map getPriceList() { + public final Map getPriceList() { return priceMap; } } diff --git a/src/main/java/forge/quest/data/bazaar/QuestStallDefinition.java b/src/main/java/forge/quest/data/bazaar/QuestStallDefinition.java index a50f523576c..f47d0d64792 100644 --- a/src/main/java/forge/quest/data/bazaar/QuestStallDefinition.java +++ b/src/main/java/forge/quest/data/bazaar/QuestStallDefinition.java @@ -1,26 +1,42 @@ package forge.quest.data.bazaar; /** - *

QuestStallDefinition class.

- * + *

+ * QuestStallDefinition class. + *

+ * * @author Forge * @version $Id$ */ public class QuestStallDefinition { + + /** The name. */ public String name; + + /** The display name. */ public String displayName; + + /** The icon name. */ public String iconName; + + /** The fluff. */ public String fluff; /** - *

Constructor for QuestStallDefinition.

- * - * @param name a {@link java.lang.String} object. - * @param displayName a {@link java.lang.String} object. - * @param fluff a {@link java.lang.String} object. - * @param iconName a {@link java.lang.String} object. + *

+ * Constructor for QuestStallDefinition. + *

+ * + * @param name + * a {@link java.lang.String} object. + * @param displayName + * a {@link java.lang.String} object. + * @param fluff + * a {@link java.lang.String} object. + * @param iconName + * a {@link java.lang.String} object. */ - public QuestStallDefinition(String name, String displayName, String fluff, String iconName) { + public QuestStallDefinition(final String name, final String displayName, final String fluff, final String iconName) { this.name = name; this.displayName = displayName; this.fluff = fluff; diff --git a/src/main/java/forge/quest/data/bazaar/QuestStallManager.java b/src/main/java/forge/quest/data/bazaar/QuestStallManager.java index f543ef829bd..11b95e5e1ef 100644 --- a/src/main/java/forge/quest/data/bazaar/QuestStallManager.java +++ b/src/main/java/forge/quest/data/bazaar/QuestStallManager.java @@ -1,63 +1,60 @@ package forge.quest.data.bazaar; +import java.util.ArrayList; +import java.util.HashMap; +import java.util.List; +import java.util.Map; +import java.util.SortedSet; +import java.util.TreeSet; + import forge.AllZone; -import java.util.*; - /** - *

QuestStallManager class.

- * + *

+ * QuestStallManager class. + *

+ * * @author Forge * @version $Id$ */ public class QuestStallManager { - /** Constant stalls */ + /** Constant stalls. */ static Map stalls; - /** Constant items */ + /** Constant items. */ static Map> items; /** - *

buildStalls.

+ *

+ * buildStalls. + *

*/ public static void buildStalls() { stalls = new HashMap(); - stalls.put(ALCHEMIST, - new QuestStallDefinition(ALCHEMIST, - "Alchemist", - "The walls of this alchemist's stall are covered with shelves with potions, oils, " + - "powders, poultices and elixirs, each meticulously labeled.", - "BottlesIconSmall.png")); - stalls.put(BANKER, - new QuestStallDefinition(BANKER, - "Banker", - "A large book large enough to be seen from the outside rests on the Banker's desk.", - "CoinIconSmall.png")); - stalls.put(BOOKSTORE, - new QuestStallDefinition(BOOKSTORE, - "Bookstore", - "Tomes of different sizes are stacked in man-high towers.", - "BookIconSmall.png")); - stalls.put(GEAR, - new QuestStallDefinition(GEAR, - "Adventuring Gear", - "This adventurer's market has a tool for every need ... or so the plaque on the wall claims.", - "GearIconSmall.png")); + stalls.put(ALCHEMIST, new QuestStallDefinition(ALCHEMIST, "Alchemist", + "The walls of this alchemist's stall are covered with shelves with potions, oils, " + + "powders, poultices and elixirs, each meticulously labeled.", "BottlesIconSmall.png")); + stalls.put(BANKER, new QuestStallDefinition(BANKER, "Banker", + "A large book large enough to be seen from the outside rests on the Banker's desk.", + "CoinIconSmall.png")); + stalls.put(BOOKSTORE, new QuestStallDefinition(BOOKSTORE, "Bookstore", + "Tomes of different sizes are stacked in man-high towers.", "BookIconSmall.png")); + stalls.put(GEAR, new QuestStallDefinition(GEAR, "Adventuring Gear", + "This adventurer's market has a tool for every need ... or so the plaque on the wall claims.", + "GearIconSmall.png")); stalls.put(NURSERY, - new QuestStallDefinition(NURSERY, - "Nursery", + new QuestStallDefinition(NURSERY, "Nursery", "The smells of the one hundred and one different plants forms a unique fragrance.", "LeafIconSmall.png")); - stalls.put(PET_SHOP, - new QuestStallDefinition(PET_SHOP, - "Pet Shop", - "This large stall echoes with a multitude of animal noises.", - "FoxIconSmall.png")); + stalls.put(PET_SHOP, new QuestStallDefinition(PET_SHOP, "Pet Shop", + "This large stall echoes with a multitude of animal noises.", "FoxIconSmall.png")); } /** - *

getStallNames.

- * + *

+ * getStallNames. + *

+ * * @return a {@link java.util.List} object. */ public static List getStallNames() { @@ -72,12 +69,15 @@ public class QuestStallManager { } /** - *

getStall.

- * - * @param stallName a {@link java.lang.String} object. + *

+ * getStall. + *

+ * + * @param stallName + * a {@link java.lang.String} object. * @return a {@link forge.quest.data.bazaar.QuestStallDefinition} object. */ - public static QuestStallDefinition getStall(String stallName) { + public static QuestStallDefinition getStall(final String stallName) { if (stalls == null) { buildStalls(); } @@ -86,7 +86,9 @@ public class QuestStallManager { } /** - *

buildItems.

+ *

+ * buildItems. + *

*/ public static void buildItems() { SortedSet itemSet = new TreeSet(); @@ -107,9 +109,12 @@ public class QuestStallManager { } /** - *

Getter for the field items.

- * - * @param stallName a {@link java.lang.String} object. + *

+ * Getter for the field items. + *

+ * + * @param stallName + * a {@link java.lang.String} object. * @return a {@link java.util.List} object. */ public static List getItems(String stallName) { @@ -127,17 +132,22 @@ public class QuestStallManager { return ret; } - /** Constant ALCHEMIST="Alchemist" */ + /** Constant ALCHEMIST="Alchemist". */ public static final String ALCHEMIST = "Alchemist"; - /** Constant BANKER="Banker" */ + + /** Constant BANKER="Banker". */ public static final String BANKER = "Banker"; - /** Constant BOOKSTORE="Bookstore" */ + + /** Constant BOOKSTORE="Bookstore". */ public static final String BOOKSTORE = "Bookstore"; - /** Constant GEAR="Gear" */ + + /** Constant GEAR="Gear". */ public static final String GEAR = "Gear"; - /** Constant NURSERY="Nursery" */ + + /** Constant NURSERY="Nursery". */ public static final String NURSERY = "Nursery"; - /** Constant PET_SHOP="Pet Shop" */ + + /** Constant PET_SHOP="Pet Shop". */ public static final String PET_SHOP = "Pet Shop"; } diff --git a/src/main/java/forge/quest/data/bazaar/QuestStallPurchasable.java b/src/main/java/forge/quest/data/bazaar/QuestStallPurchasable.java index 11066b5bf6c..5af5cde6fc0 100644 --- a/src/main/java/forge/quest/data/bazaar/QuestStallPurchasable.java +++ b/src/main/java/forge/quest/data/bazaar/QuestStallPurchasable.java @@ -1,57 +1,68 @@ package forge.quest.data.bazaar; /** - * This interface defines a thing that can be sold at the Bazaar + * This interface defines a thing that can be sold at the Bazaar. * * @author Forge * @version $Id$ */ public interface QuestStallPurchasable extends Comparable { /** - *

getPurchaseName.

- * + *

+ * getPurchaseName. + *

+ * * @return The Name of the item */ - public String getPurchaseName(); + String getPurchaseName(); /** - *

getPurchaseDescription.

- * + *

+ * getPurchaseDescription. + *

+ * * @return an HTML formatted item description */ - public String getPurchaseDescription(); + String getPurchaseDescription(); /** - *

getImageName.

- * + *

+ * getImageName. + *

+ * * @return the name of the image that is displayed in the bazaar */ - public String getImageName(); + String getImageName(); /** - *

getPrice.

- * + *

+ * getPrice. + *

+ * * @return the cost of the item in credits */ - public int getPrice(); + int getPrice(); /** - * Returns if the item is available for purchase; + * Returns if the item is available for purchase;. * * @return true if the item can be displayed in a store - * false if the item should not be displayed in store since, for example, prerequisites are not met + * false if the item should not be displayed in store + * since, for example, prerequisites are not met */ - public boolean isAvailableForPurchase(); + boolean isAvailableForPurchase(); /** - * Executed when the item is bought + * Executed when the item is bought. */ - public void onPurchase(); + void onPurchase(); /** - *

getStallName.

- * + *

+ * getStallName. + *

+ * * @return the name of the stall form which this item can be purchased */ - public String getStallName(); + String getStallName(); } diff --git a/src/main/java/forge/quest/data/bazaar/package-info.java b/src/main/java/forge/quest/data/bazaar/package-info.java index 8527e67a23b..5e879340f22 100644 --- a/src/main/java/forge/quest/data/bazaar/package-info.java +++ b/src/main/java/forge/quest/data/bazaar/package-info.java @@ -1,2 +1,2 @@ -/** Forge Card Game */ +/** Forge Card Game. */ package forge.quest.data.bazaar; diff --git a/src/main/java/forge/quest/data/item/QuestInventory.java b/src/main/java/forge/quest/data/item/QuestInventory.java index 04a814bff37..79a6ad3bb25 100644 --- a/src/main/java/forge/quest/data/item/QuestInventory.java +++ b/src/main/java/forge/quest/data/item/QuestInventory.java @@ -1,18 +1,29 @@ package forge.quest.data.item; -import java.util.*; +import java.util.Collection; +import java.util.HashMap; +import java.util.Map; +import java.util.Set; +import java.util.SortedSet; +import java.util.TreeSet; /** - *

QuestInventory class.

- * + *

+ * QuestInventory class. + *

+ * * @author Forge * @version $Id$ */ public class QuestInventory { + + /** The inventory. */ Map inventory = new HashMap(); /** - *

Constructor for QuestInventory.

+ *

+ * Constructor for QuestInventory. + *

*/ public QuestInventory() { Set allItems = getAllItems(); @@ -22,31 +33,40 @@ public class QuestInventory { } /** - *

hasItem.

- * - * @param itemName a {@link java.lang.String} object. + *

+ * hasItem. + *

+ * + * @param itemName + * a {@link java.lang.String} object. * @return a boolean. */ - public boolean hasItem(String itemName) { + public final boolean hasItem(final String itemName) { return inventory.containsKey(itemName) && inventory.get(itemName).getLevel() > 0; } /** - *

addItem.

- * - * @param item a {@link forge.quest.data.item.QuestItemAbstract} object. + *

+ * addItem. + *

+ * + * @param item + * a {@link forge.quest.data.item.QuestItemAbstract} object. */ - public void addItem(QuestItemAbstract item) { + public final void addItem(final QuestItemAbstract item) { inventory.put(item.getName(), item); } /** - *

getItemLevel.

- * - * @param itemName a {@link java.lang.String} object. + *

+ * getItemLevel. + *

+ * + * @param itemName + * a {@link java.lang.String} object. * @return a int. */ - public int getItemLevel(String itemName) { + public final int getItemLevel(final String itemName) { QuestItemAbstract item = inventory.get(itemName); if (item == null) { return 0; @@ -55,19 +75,24 @@ public class QuestInventory { } /** - *

setItemLevel.

- * - * @param itemName a {@link java.lang.String} object. - * @param level a int. + *

+ * setItemLevel. + *

+ * + * @param itemName + * a {@link java.lang.String} object. + * @param level + * a int. */ - public void setItemLevel(String itemName, int level) { + public final void setItemLevel(final String itemName, final int level) { inventory.get(itemName).setLevel(level); } - /** - *

getAllItems.

- * + *

+ * getAllItems. + *

+ * * @return a {@link java.util.Set} object. */ private static Set getAllItems() { @@ -83,10 +108,12 @@ public class QuestInventory { return set; } - //Magic to support added pet types when reading saves. + // Magic to support added pet types when reading saves. /** - *

readResolve.

- * + *

+ * readResolve. + *

+ * * @return a {@link java.lang.Object} object. */ private Object readResolve() { @@ -98,10 +125,11 @@ public class QuestInventory { return this; } - /** - *

getItems.

- * + *

+ * getItems. + *

+ * * @return a {@link java.util.Collection} object. */ public Collection getItems() { @@ -109,9 +137,12 @@ public class QuestInventory { } /** - *

getItem.

- * - * @param itemName a {@link java.lang.String} object. + *

+ * getItem. + *

+ * + * @param itemName + * a {@link java.lang.String} object. * @return a {@link forge.quest.data.item.QuestItemAbstract} object. */ public QuestItemAbstract getItem(String itemName) { diff --git a/src/main/java/forge/quest/data/item/QuestItemAbstract.java b/src/main/java/forge/quest/data/item/QuestItemAbstract.java index 017a985e69e..cc5ffa8c5df 100644 --- a/src/main/java/forge/quest/data/item/QuestItemAbstract.java +++ b/src/main/java/forge/quest/data/item/QuestItemAbstract.java @@ -4,8 +4,10 @@ import forge.AllZone; import forge.quest.data.bazaar.QuestStallPurchasable; /** - *

Abstract QuestItemAbstract class.

- * + *

+ * Abstract QuestItemAbstract class. + *

+ * * @author Forge * @version $Id$ */ @@ -15,34 +17,42 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable { private String shopName; private int maxLevel = 1; - /** - *

Constructor for QuestItemAbstract.

- * - * @param name a {@link java.lang.String} object. - * @param shopName a {@link java.lang.String} object. + *

+ * Constructor for QuestItemAbstract. + *

+ * + * @param name + * a {@link java.lang.String} object. + * @param shopName + * a {@link java.lang.String} object. */ - protected QuestItemAbstract(String name, String shopName) { + protected QuestItemAbstract(final String name, final String shopName) { this.name = name; this.shopName = shopName; } /** - *

Constructor for QuestItemAbstract.

- * - * @param name a {@link java.lang.String} object. - * @param shopName a {@link java.lang.String} object. - * @param maxLevel a int. + *

+ * Constructor for QuestItemAbstract. + *

+ * + * @param name + * a {@link java.lang.String} object. + * @param shopName + * a {@link java.lang.String} object. + * @param maxLevel + * a int. */ - protected QuestItemAbstract(String name, String shopName, int maxLevel) { + protected QuestItemAbstract(final String name, final String shopName, final int maxLevel) { this.name = name; this.shopName = shopName; this.maxLevel = maxLevel; } /** - * This is the name shared across all item levels e.g., "Estates" - * + * This is the name shared across all item levels e.g., "Estates". + * * @return a {@link java.lang.String} object. */ public final String getName() { @@ -50,8 +60,8 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable { } /** - * This is the name used in purchasing the item e.g.,"Estates Training 1" - * + * This is the name used in purchasing the item e.g.,"Estates Training 1". + * * @return a {@link java.lang.String} object. */ public String getPurchaseName() { @@ -59,15 +69,16 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable { } /** - *

getStallName.

- * + *

+ * getStallName. + *

+ * * @return a {@link java.lang.String} object. */ - public String getStallName() { + public final String getStallName() { return shopName; } - /** * This method will be invoked when an item is bought in a shop. */ @@ -76,10 +87,11 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable { AllZone.getQuestData().getInventory().setItemLevel(name, currentLevel + 1); } - /** - *

isAvailableForPurchase.

- * + *

+ * isAvailableForPurchase. + *

+ * * @return a boolean. */ public boolean isAvailableForPurchase() { @@ -87,64 +99,79 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable { } /** - *

Getter for the field level.

- * + *

+ * Getter for the field level. + *

+ * * @return a int. */ - public int getLevel() { + public final int getLevel() { return level; } /** - *

Setter for the field level.

- * - * @param level a int. + *

+ * Setter for the field level. + *

+ * + * @param level + * a int. */ - public void setLevel(int level) { + public final void setLevel(final int level) { this.level = level; } /** - *

Getter for the field maxLevel.

- * + *

+ * Getter for the field maxLevel. + *

+ * * @return a int. */ - public int getMaxLevel() { + public final int getMaxLevel() { return maxLevel; } /** - *

isLeveledItem.

- * + *

+ * isLeveledItem. + *

+ * * @return a boolean. */ - public boolean isLeveledItem() { + public final boolean isLeveledItem() { return maxLevel == 1; } /** - *

getPurchaseDescription.

- * + *

+ * getPurchaseDescription. + *

+ * * @return a {@link java.lang.String} object. */ public abstract String getPurchaseDescription(); /** - *

getImageName.

- * + *

+ * getImageName. + *

+ * * @return a {@link java.lang.String} object. */ public abstract String getImageName(); /** - *

getPrice.

- * + *

+ * getPrice. + *

+ * * @return a int. */ public abstract int getPrice(); /** {@inheritDoc} */ - public int compareTo(Object o) { + public final int compareTo(final Object o) { QuestStallPurchasable q = (QuestStallPurchasable) o; return this.getPurchaseName().compareTo(q.getPurchaseName()); } diff --git a/src/main/java/forge/quest/data/item/QuestItemElixir.java b/src/main/java/forge/quest/data/item/QuestItemElixir.java index a513a5d2d30..4d27da0abeb 100644 --- a/src/main/java/forge/quest/data/item/QuestItemElixir.java +++ b/src/main/java/forge/quest/data/item/QuestItemElixir.java @@ -4,15 +4,17 @@ import forge.AllZone; import forge.quest.data.bazaar.QuestStallManager; /** - * This item has special coding because of the - * + * This item has special coding. + * * @author Forge * @version $Id$ */ public class QuestItemElixir extends QuestItemAbstract { /** - *

Constructor for QuestItemElixir.

+ *

+ * Constructor for QuestItemElixir. + *

*/ QuestItemElixir() { super("Elixir of Life", QuestStallManager.ALCHEMIST, 15); @@ -20,19 +22,19 @@ public class QuestItemElixir extends QuestItemAbstract { /** {@inheritDoc} */ @Override - public String getPurchaseDescription() { + public final String getPurchaseDescription() { return "Gives +1 to maximum life
Current Life: " + AllZone.getQuestData().getLife(); } /** {@inheritDoc} */ @Override - public String getImageName() { + public final String getImageName() { return "ElixirIcon.png"; } /** {@inheritDoc} */ @Override - public int getPrice() { + public final int getPrice() { if (getLevel() < 5) { return 250; } else if (getLevel() < 10) { @@ -44,7 +46,7 @@ public class QuestItemElixir extends QuestItemAbstract { /** {@inheritDoc} */ @Override - public void onPurchase() { + public final void onPurchase() { AllZone.getQuestData().addLife(1); } diff --git a/src/main/java/forge/quest/data/item/QuestItemEstates.java b/src/main/java/forge/quest/data/item/QuestItemEstates.java index 6a6b634a350..530e447a335 100644 --- a/src/main/java/forge/quest/data/item/QuestItemEstates.java +++ b/src/main/java/forge/quest/data/item/QuestItemEstates.java @@ -3,14 +3,18 @@ package forge.quest.data.item; import forge.quest.data.bazaar.QuestStallManager; /** - *

QuestItemEstates class.

- * + *

+ * QuestItemEstates class. + *

+ * * @author Forge * @version $Id$ */ public class QuestItemEstates extends QuestItemAbstract { /** - *

Constructor for QuestItemEstates.

+ *

+ * Constructor for QuestItemEstates. + *

*/ QuestItemEstates() { super("Estates", QuestStallManager.BANKER, 3); @@ -18,20 +22,20 @@ public class QuestItemEstates extends QuestItemAbstract { /** {@inheritDoc} */ @Override - public String getPurchaseDescription() { - return String.format("Gives a bonus of %d%% to match winnings.
" + - "Improves sell percentage by %.2f%%.", (10 + getLevel() * 5), (1 + getLevel() * 0.75)); + public final String getPurchaseDescription() { + return String.format("Gives a bonus of %d%% to match winnings.
" + + "Improves sell percentage by %.2f%%.", (10 + getLevel() * 5), (1 + getLevel() * 0.75)); } /** {@inheritDoc} */ @Override - public String getImageName() { + public final String getImageName() { return "GoldIconLarge.png"; } /** {@inheritDoc} */ @Override - public int getPrice() { + public final int getPrice() { if (getLevel() == 0) { return 500; } else if (getLevel() == 1) { @@ -41,5 +45,4 @@ public class QuestItemEstates extends QuestItemAbstract { } } - } diff --git a/src/main/java/forge/quest/data/item/QuestItemLuckyCoin.java b/src/main/java/forge/quest/data/item/QuestItemLuckyCoin.java index 935bc106e31..22b94b5d04a 100644 --- a/src/main/java/forge/quest/data/item/QuestItemLuckyCoin.java +++ b/src/main/java/forge/quest/data/item/QuestItemLuckyCoin.java @@ -3,14 +3,18 @@ package forge.quest.data.item; import forge.quest.data.bazaar.QuestStallManager; /** - *

QuestItemLuckyCoin class.

- * + *

+ * QuestItemLuckyCoin class. + *

+ * * @author Forge * @version $Id$ */ public class QuestItemLuckyCoin extends QuestItemAbstract { /** - *

Constructor for QuestItemLuckyCoin.

+ *

+ * Constructor for QuestItemLuckyCoin. + *

*/ QuestItemLuckyCoin() { super("Lucky Coin", QuestStallManager.BANKER); @@ -18,22 +22,21 @@ public class QuestItemLuckyCoin extends QuestItemAbstract { /** {@inheritDoc} */ @Override - public String getPurchaseDescription() { - return "This coin is believed to give good luck to its owner.
" + - "Improves the chance of getting a random
rare after each match by 15%."; + public final String getPurchaseDescription() { + return "This coin is believed to give good luck to its owner.
" + + "Improves the chance of getting a random
rare after each match by 15%."; } /** {@inheritDoc} */ @Override - public String getImageName() { + public final String getImageName() { return "CoinIcon.png"; } /** {@inheritDoc} */ @Override - public int getPrice() { + public final int getPrice() { return 2000; } - } diff --git a/src/main/java/forge/quest/data/item/QuestItemMap.java b/src/main/java/forge/quest/data/item/QuestItemMap.java index 064d58fcec5..c53a442a089 100644 --- a/src/main/java/forge/quest/data/item/QuestItemMap.java +++ b/src/main/java/forge/quest/data/item/QuestItemMap.java @@ -3,14 +3,18 @@ package forge.quest.data.item; import forge.quest.data.bazaar.QuestStallManager; /** - *

QuestItemMap class.

- * + *

+ * QuestItemMap class. + *

+ * * @author Forge * @version $Id$ */ public class QuestItemMap extends QuestItemAbstract { /** - *

Constructor for QuestItemMap.

+ *

+ * Constructor for QuestItemMap. + *

*/ QuestItemMap() { super("Map", QuestStallManager.GEAR); @@ -18,26 +22,26 @@ public class QuestItemMap extends QuestItemAbstract { /** {@inheritDoc} */ @Override - public String getPurchaseName() { + public final String getPurchaseName() { return "Adventurer's Map"; } /** {@inheritDoc} */ @Override - public String getPurchaseDescription() { - return "These ancient charts should facilitate navigation during your travels significantly.
" + - "Effect: Quest assignments become available more frequently."; + public final String getPurchaseDescription() { + return "These ancient charts should facilitate navigation during your travels significantly.
" + + "Effect: Quest assignments become available more frequently."; } /** {@inheritDoc} */ @Override - public String getImageName() { + public final String getImageName() { return "MapIconLarge.png"; } /** {@inheritDoc} */ @Override - public int getPrice() { + public final int getPrice() { return 2000; } } diff --git a/src/main/java/forge/quest/data/item/QuestItemSleight.java b/src/main/java/forge/quest/data/item/QuestItemSleight.java index 424cc1f5f7e..3281ef92728 100644 --- a/src/main/java/forge/quest/data/item/QuestItemSleight.java +++ b/src/main/java/forge/quest/data/item/QuestItemSleight.java @@ -3,14 +3,18 @@ package forge.quest.data.item; import forge.quest.data.bazaar.QuestStallManager; /** - *

QuestItemSleight class.

- * + *

+ * QuestItemSleight class. + *

+ * * @author Forge * @version $Id$ */ public class QuestItemSleight extends QuestItemAbstract { /** - *

Constructor for QuestItemSleight.

+ *

+ * Constructor for QuestItemSleight. + *

*/ QuestItemSleight() { super("Sleight", QuestStallManager.BOOKSTORE); @@ -19,26 +23,26 @@ public class QuestItemSleight extends QuestItemAbstract { /** {@inheritDoc} */ @Override - public String getImageName() { + public final String getImageName() { return "BookIcon.png"; } /** {@inheritDoc} */ @Override - public int getPrice() { + public final int getPrice() { return 2000; } /** {@inheritDoc} */ @Override - public String getPurchaseName() { + public final String getPurchaseName() { return "Sleight of Hand Vol. I"; } /** {@inheritDoc} */ @Override - public String getPurchaseDescription() { - return "These volumes explain how to perform the most difficult of sleights.
" + - "Effect: Your first mulligan is free"; + public final String getPurchaseDescription() { + return "These volumes explain how to perform the most difficult of sleights.
" + + "Effect: Your first mulligan is free"; } } diff --git a/src/main/java/forge/quest/data/item/QuestItemZeppelin.java b/src/main/java/forge/quest/data/item/QuestItemZeppelin.java index 95282d2da29..c64b361db47 100644 --- a/src/main/java/forge/quest/data/item/QuestItemZeppelin.java +++ b/src/main/java/forge/quest/data/item/QuestItemZeppelin.java @@ -3,17 +3,24 @@ package forge.quest.data.item; import forge.AllZone; import forge.quest.data.bazaar.QuestStallManager; +// TODO: Auto-generated Javadoc /** - *

QuestItemZeppelin class.

- * + *

+ * QuestItemZeppelin class. + *

+ * * @author Forge * @version $Id$ */ public class QuestItemZeppelin extends QuestItemAbstract { + + /** The zeppelin used. */ boolean zeppelinUsed = false; /** - *

Constructor for QuestItemZeppelin.

+ *

+ * Constructor for QuestItemZeppelin. + *

*/ QuestItemZeppelin() { super("Zeppelin", QuestStallManager.GEAR); @@ -21,52 +28,57 @@ public class QuestItemZeppelin extends QuestItemAbstract { /** {@inheritDoc} */ @Override - public String getPurchaseName() { + public final String getPurchaseName() { return "Zeppelin"; } /** {@inheritDoc} */ @Override - public String getPurchaseDescription() { - return "This extremely comfortable airship allows for more efficient and safe travel
to faraway destinations.
" + - "Effect: Quest assignments become available more frequently
" + - "Effect: Adds +3 to max life during quest games.
" + - "Effect: Allows travel to far places, allowing you to see a new set of opponents"; + public final String getPurchaseDescription() { + return "This extremely comfortable airship allows for more efficient and safe travel
to faraway destinations.
" + + "Effect: Quest assignments become available more frequently
" + + "Effect: Adds +3 to max life during quest games.
" + + "Effect: Allows travel to far places, allowing you to see a new set of opponents"; } /** {@inheritDoc} */ @Override - public String getImageName() { + public final String getImageName() { return "ZeppelinIcon.png"; } /** {@inheritDoc} */ @Override - public int getPrice() { + public final int getPrice() { return 5000; } /** {@inheritDoc} */ @Override - public boolean isAvailableForPurchase() { + public final boolean isAvailableForPurchase() { return super.isAvailableForPurchase() && AllZone.getQuestData().getInventory().hasItem("Map"); } /** - *

hasBeenUsed.

- * + *

+ * hasBeenUsed. + *

+ * * @return a boolean. */ - public boolean hasBeenUsed() { + public final boolean hasBeenUsed() { return zeppelinUsed; } /** - *

Setter for the field zeppelinUsed.

- * - * @param used a boolean. + *

+ * Setter for the field zeppelinUsed. + *

+ * + * @param used + * a boolean. */ - public void setZeppelinUsed(boolean used) { + public final void setZeppelinUsed(final boolean used) { this.zeppelinUsed = used; } } diff --git a/src/main/java/forge/quest/data/item/package-info.java b/src/main/java/forge/quest/data/item/package-info.java index 90bbdf4a192..5a70110941d 100644 --- a/src/main/java/forge/quest/data/item/package-info.java +++ b/src/main/java/forge/quest/data/item/package-info.java @@ -1,2 +1,2 @@ -/** Forge Card Game */ +/** Forge Card Game. */ package forge.quest.data.item; diff --git a/src/main/java/forge/quest/data/package-info.java b/src/main/java/forge/quest/data/package-info.java index 015e6b48495..3273e2ca3b4 100644 --- a/src/main/java/forge/quest/data/package-info.java +++ b/src/main/java/forge/quest/data/package-info.java @@ -1,2 +1,2 @@ -/** Forge Card Game */ +/** Forge Card Game. */ package forge.quest.data; diff --git a/src/main/java/forge/quest/package-info.java b/src/main/java/forge/quest/package-info.java index 22646334494..92c34f0b898 100644 --- a/src/main/java/forge/quest/package-info.java +++ b/src/main/java/forge/quest/package-info.java @@ -1,2 +1,2 @@ -/** Forge Card Game */ +/** Forge Card Game. */ package forge.quest;