checkstyle

This commit is contained in:
jendave
2011-10-26 09:16:29 +00:00
parent beced32e97
commit c7ec34a658
31 changed files with 2634 additions and 1123 deletions

View File

@@ -7,8 +7,6 @@ import java.nio.charset.Charset;
import java.util.jar.Attributes; import java.util.jar.Attributes;
import java.util.jar.JarFile; import java.util.jar.JarFile;
import java.util.jar.Manifest; 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. * Provides access to information about the current version and build ID.
@@ -206,7 +204,7 @@ public class BuildInfo {
*/ */
public final String toPrettyString() { public final String toPrettyString() {
final String rawVersion = getVersion(); final String rawVersion = getVersion();
//final String rawBuildID = getBuildID(); // final String rawBuildID = getBuildID();
String version; String version;
if (rawVersion == null) { if (rawVersion == null) {
@@ -215,14 +213,12 @@ public class BuildInfo {
version = rawVersion; version = rawVersion;
} }
/*String buildID; /*
if (rawBuildID == null) { * String buildID; if (rawBuildID == null) { buildID = "Unknown"; } else
buildID = "Unknown"; * { buildID = rawBuildID; }
} else { */
buildID = rawBuildID;
} */
return "Forge version " + version; //", build ID " + buildID; return "Forge version " + version; // ", build ID " + buildID;
} }
} }

View File

@@ -3,6 +3,7 @@ package forge.model;
import forge.AIPlayer; import forge.AIPlayer;
import forge.Combat; import forge.Combat;
import forge.Constant; import forge.Constant;
import forge.Constant.Zone;
import forge.DefaultPlayerZone; import forge.DefaultPlayerZone;
import forge.EndOfCombat; import forge.EndOfCombat;
import forge.EndOfTurn; import forge.EndOfTurn;
@@ -14,7 +15,6 @@ import forge.Player;
import forge.PlayerZone; import forge.PlayerZone;
import forge.StaticEffects; import forge.StaticEffects;
import forge.Upkeep; import forge.Upkeep;
import forge.Constant.Zone;
import forge.card.trigger.TriggerHandler; import forge.card.trigger.TriggerHandler;
import forge.game.GameSummary; import forge.game.GameSummary;
@@ -22,9 +22,13 @@ import forge.game.GameSummary;
* Represents the Forge Game State. * Represents the Forge Game State.
*/ */
public class FGameState { public class FGameState {
/** The Constant HUMAN_PLAYER_NAME. */
public static final String HUMAN_PLAYER_NAME = "Human"; public static final String HUMAN_PLAYER_NAME = "Human";
/** The Constant AI_PLAYER_NAME. */
public static final String AI_PLAYER_NAME = "Computer"; public static final String AI_PLAYER_NAME = "Computer";
private Player humanPlayer = new HumanPlayer(HUMAN_PLAYER_NAME); private Player humanPlayer = new HumanPlayer(HUMAN_PLAYER_NAME);
private Player computerPlayer = new AIPlayer(AI_PLAYER_NAME); private Player computerPlayer = new AIPlayer(AI_PLAYER_NAME);
private EndOfTurn endOfTurn = new EndOfTurn(); private EndOfTurn endOfTurn = new EndOfTurn();
@@ -37,7 +41,6 @@ public class FGameState {
private TriggerHandler triggerHandler = new TriggerHandler(); private TriggerHandler triggerHandler = new TriggerHandler();
private Combat combat = new Combat(); private Combat combat = new Combat();
private PlayerZone stackZone = new DefaultPlayerZone(Constant.Zone.Stack, null); private PlayerZone stackZone = new DefaultPlayerZone(Constant.Zone.Stack, null);
private long timestamp = 0; private long timestamp = 0;
@@ -46,199 +49,241 @@ public class FGameState {
/** /**
* Constructor. * Constructor.
*/ */
public FGameState() { /* no more zones to map here */ } public FGameState() { /* no more zones to map here */
}
/** /**
* Gets the human player.
*
* @return the humanPlayer * @return the humanPlayer
*/ */
public final Player getHumanPlayer() { public final Player getHumanPlayer() {
return humanPlayer; 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) { protected final void setHumanPlayer(final Player humanPlayer0) {
this.humanPlayer = humanPlayer0; this.humanPlayer = humanPlayer0;
} }
/** /**
* Gets the computer player.
*
* @return the computerPlayer * @return the computerPlayer
*/ */
public final Player getComputerPlayer() { public final Player getComputerPlayer() {
return computerPlayer; 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) { protected final void setComputerPlayer(final Player computerPlayer0) {
this.computerPlayer = 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 * @return the endOfTurn
*/ */
public final EndOfTurn getEndOfTurn() { public final EndOfTurn getEndOfTurn() {
return endOfTurn; 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) { protected final void setEndOfTurn(final EndOfTurn endOfTurn0) {
this.endOfTurn = endOfTurn0; this.endOfTurn = endOfTurn0;
} }
/** /**
* Gets the end of combat.
*
* @return the endOfCombat * @return the endOfCombat
*/ */
public final EndOfCombat getEndOfCombat() { public final EndOfCombat getEndOfCombat() {
return endOfCombat; 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) { protected final void setEndOfCombat(final EndOfCombat endOfCombat0) {
this.endOfCombat = endOfCombat0; this.endOfCombat = endOfCombat0;
} }
/** /**
* Gets the upkeep.
*
* @return the upkeep * @return the upkeep
*/ */
public final Upkeep getUpkeep() { public final Upkeep getUpkeep() {
return upkeep; return upkeep;
} }
/** /**
* @param upkeep0 the upkeep to set * Sets the upkeep.
*
* @param upkeep0
* the upkeep to set
*/ */
protected final void setUpkeep(final Upkeep upkeep0) { protected final void setUpkeep(final Upkeep upkeep0) {
this.upkeep = upkeep0; this.upkeep = upkeep0;
} }
/** /**
* Gets the phase.
*
* @return the phase * @return the phase
*/ */
public final Phase getPhase() { public final Phase getPhase() {
return phase; return phase;
} }
/** /**
* @param phase0 the phase to set * Sets the phase.
*
* @param phase0
* the phase to set
*/ */
protected final void setPhase(final Phase phase0) { protected final void setPhase(final Phase phase0) {
this.phase = phase0; this.phase = phase0;
} }
/** /**
* Gets the stack.
*
* @return the stack * @return the stack
*/ */
public final MagicStack getStack() { public final MagicStack getStack() {
return stack; return stack;
} }
/** /**
* @param stack0 the stack to set * Sets the stack.
*
* @param stack0
* the stack to set
*/ */
protected final void setStack(final MagicStack stack0) { protected final void setStack(final MagicStack stack0) {
this.stack = stack0; this.stack = stack0;
} }
/** /**
* Gets the game action.
*
* @return the gameAction * @return the gameAction
*/ */
public final GameAction getGameAction() { public final GameAction getGameAction() {
return gameAction; 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) { protected final void setGameAction(final GameAction gameAction0) {
this.gameAction = gameAction0; this.gameAction = gameAction0;
} }
/** /**
* Gets the static effects.
*
* @return the staticEffects * @return the staticEffects
*/ */
public final StaticEffects getStaticEffects() { public final StaticEffects getStaticEffects() {
return staticEffects; 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) { protected final void setStaticEffects(final StaticEffects staticEffects0) {
this.staticEffects = staticEffects0; this.staticEffects = staticEffects0;
} }
/** /**
* Gets the trigger handler.
*
* @return the triggerHandler * @return the triggerHandler
*/ */
public final TriggerHandler getTriggerHandler() { public final TriggerHandler getTriggerHandler() {
return triggerHandler; 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) { protected final void setTriggerHandler(final TriggerHandler triggerHandler0) {
this.triggerHandler = triggerHandler0; this.triggerHandler = triggerHandler0;
} }
/** /**
* Gets the combat.
*
* @return the combat * @return the combat
*/ */
public final Combat getCombat() { public final Combat getCombat() {
return combat; return combat;
} }
/** /**
* @param combat0 the combat to set * Sets the combat.
*
* @param combat0
* the combat to set
*/ */
public final void setCombat(final Combat combat0) { public final void setCombat(final Combat combat0) {
this.combat = combat0; this.combat = combat0;
} }
/** /**
* Gets the stack zone.
*
* @return the stackZone * @return the stackZone
*/ */
public final PlayerZone getStackZone() { public final PlayerZone getStackZone() {
return stackZone; 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) { protected final void setStackZone(final PlayerZone stackZone0) {
this.stackZone = stackZone0; this.stackZone = stackZone0;
@@ -254,32 +299,38 @@ public class FGameState {
return getTimestamp(); return getTimestamp();
} }
/** /**
* Gets the timestamp.
*
* @return the timestamp * @return the timestamp
*/ */
public final long getTimestamp() { public final long getTimestamp() {
return timestamp; return timestamp;
} }
/** /**
* @param timestamp0 the timestamp to set * Sets the timestamp.
*
* @param timestamp0
* the timestamp to set
*/ */
protected final void setTimestamp(final long timestamp0) { protected final void setTimestamp(final long timestamp0) {
this.timestamp = timestamp0; this.timestamp = timestamp0;
} }
/**
public GameSummary getGameInfo() { * Gets the game info.
*
* @return the game info
*/
public final GameSummary getGameInfo() {
return gameInfo; 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()); gameInfo = new GameSummary(humanPlayer.getName(), computerPlayer.getName());
getHumanPlayer().reset(); getHumanPlayer().reset();
@@ -290,11 +341,11 @@ public class FGameState {
getCombat().reset(); getCombat().reset();
for (Player p : getPlayers()) { for (Player p : getPlayers()) {
for(Zone z : Player.ALL_ZONES) { for (Zone z : Player.ALL_ZONES) {
p.getZone(z).reset(); p.getZone(z).reset();
} }
} }
getStaticEffects().reset(); getStaticEffects().reset();
} }

View File

@@ -7,51 +7,50 @@ import java.io.IOException;
import java.io.OutputStream; import java.io.OutputStream;
import java.io.PrintStream; import java.io.PrintStream;
import net.slightlymagic.braids.util.progress_monitor.BraidsProgressMonitor;
import arcane.util.MultiplexOutputStream;
import forge.Constant; import forge.Constant;
import forge.HttpUtil; import forge.HttpUtil;
import forge.properties.ForgePreferences; 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. * The default Model implementation for Forge.
* *
* This used to be an interface, but it seems unlikely that we will ever use a * This used to be an interface, but it seems unlikely that we will ever use a
* different model. * different model.
* *
* In case we need to convert it into an interface in the future, all fields of * 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. * this class must be either private or public static final.
*/ */
public class FModel { 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 OutputStream logFileStream;
private final transient PrintStream oldSystemOut; private final transient PrintStream oldSystemOut;
private final transient PrintStream oldSystemErr; private final transient PrintStream oldSystemErr;
private BuildInfo buildInfo; private BuildInfo buildInfo;
/** The preferences. */
public ForgePreferences preferences; public ForgePreferences preferences;
private FGameState gameState; private FGameState gameState;
/** /**
* Constructor. * Constructor.
* *
* @param theMonitor a progress monitor (from the View) that shows the * @param theMonitor
* progress of the model's initialization. * 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. *
* @throws FileNotFoundException
* if we could not find or write to the log file.
*/ */
public FModel(final BraidsProgressMonitor theMonitor) throws FileNotFoundException { public FModel(final BraidsProgressMonitor theMonitor) throws FileNotFoundException {
/* To be implemented later. -Braids /*
BraidsProgressMonitor monitor; * To be implemented later. -Braids BraidsProgressMonitor monitor; if
if (theMonitor == null) { * (theMonitor == null) { monitor = new
monitor = new BaseProgressMonitor(NUM_INIT_PHASES, 1); * BaseProgressMonitor(NUM_INIT_PHASES, 1); } else { monitor =
} * theMonitor; }
else { */
monitor = theMonitor;
}
*/
final File logFile = new File("forge.log"); final File logFile = new File("forge.log");
final boolean deleteSucceeded = logFile.delete(); final boolean deleteSucceeded = logFile.delete();
@@ -70,7 +69,8 @@ public class FModel {
try { try {
setPreferences(new ForgePreferences("forge.preferences")); setPreferences(new ForgePreferences("forge.preferences"));
} catch (Exception exn) { } 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; Constant.Runtime.Mill[0] = preferences.millingLossCondition;
@@ -90,7 +90,9 @@ public class FModel {
/** /**
* Destructor for FModel. * Destructor for FModel.
* @throws Throwable indirectly *
* @throws Throwable
* indirectly
*/ */
@Override @Override
protected final void finalize() throws Throwable { protected final void finalize() throws Throwable {
@@ -99,8 +101,8 @@ public class FModel {
} }
/** /**
* Opposite of constructor; resets all system resources and closes the * Opposite of constructor; resets all system resources and closes the log
* log file. * file.
*/ */
public final void close() { public final void close() {
System.setOut(oldSystemOut); System.setOut(oldSystemOut);
@@ -114,7 +116,7 @@ public class FModel {
/** /**
* Getter for buildInfo. * Getter for buildInfo.
* *
* @return the buildInfo * @return the buildInfo
*/ */
public final BuildInfo getBuildInfo() { public final BuildInfo getBuildInfo() {
@@ -123,14 +125,17 @@ public class FModel {
/** /**
* Setter for buildInfo. * Setter for buildInfo.
* *
* @param neoBuildInfo the buildInfo to set * @param neoBuildInfo
* the buildInfo to set
*/ */
protected final void setBuildInfo(final BuildInfo neoBuildInfo) { protected final void setBuildInfo(final BuildInfo neoBuildInfo) {
this.buildInfo = neoBuildInfo; this.buildInfo = neoBuildInfo;
} }
/** /**
* Gets the preferences.
*
* @return the preferences * @return the preferences
*/ */
public final ForgePreferences getPreferences() { 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) { public final void setPreferences(final ForgePreferences neoPreferences) {
this.preferences = neoPreferences; this.preferences = neoPreferences;
@@ -146,6 +154,7 @@ public class FModel {
/** /**
* Getter for gameState. * Getter for gameState.
*
* @return the game state * @return the game state
*/ */
public final FGameState getGameState() { public final FGameState getGameState() {
@@ -154,6 +163,7 @@ public class FModel {
/** /**
* Create and return a new game state. * Create and return a new game state.
*
* @return a fresh game state * @return a fresh game state
*/ */
public final FGameState resetGameState() { public final FGameState resetGameState() {
@@ -161,6 +171,4 @@ public class FModel {
return gameState; return gameState;
} }
} }

View File

@@ -1,60 +1,123 @@
package forge.properties; 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.ArrayList;
import java.util.List; import java.util.List;
// TODO: Auto-generated Javadoc
/** /**
* <p>ForgePreferences class.</p> * <p>
* * ForgePreferences class.
* </p>
*
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class ForgePreferences extends Preferences { public class ForgePreferences extends Preferences {
/** The new gui. */
public boolean newGui; public boolean newGui;
/** The stack ai land. */
public boolean stackAiLand; public boolean stackAiLand;
/** The milling loss condition. */
public boolean millingLossCondition; public boolean millingLossCondition;
/** The developer mode. */
public boolean developerMode; public boolean developerMode;
/** The upload draft ai. */
public boolean uploadDraftAI; public boolean uploadDraftAI;
/** The rand c foil. */
public boolean randCFoil; public boolean randCFoil;
/** The skin. */
public String skin; public String skin;
/** The laf. */
public String laf; public String laf;
/** The laf fonts. */
public boolean lafFonts; public boolean lafFonts;
/** The stack offset. */
public StackOffsetType stackOffset; public StackOffsetType stackOffset;
/** The max stack size. */
public int maxStackSize; public int maxStackSize;
/** The card size. */
public CardSizeType cardSize; public CardSizeType cardSize;
/** The card overlay. */
public boolean cardOverlay; public boolean cardOverlay;
/** The scale larger than original. */
public boolean scaleLargerThanOriginal; public boolean scaleLargerThanOriginal;
/** The deck gen rmv artifacts. */
public boolean deckGenRmvArtifacts; public boolean deckGenRmvArtifacts;
/** The deck gen rmv small. */
public boolean deckGenRmvSmall; public boolean deckGenRmvSmall;
/** The Bugz name. */
public String BugzName; public String BugzName;
/** The Bugz pwd. */
public String BugzPwd; public String BugzPwd;
// Phases // Phases
/** The b ai upkeep. */
public boolean bAIUpkeep; public boolean bAIUpkeep;
/** The b ai draw. */
public boolean bAIDraw; public boolean bAIDraw;
/** The b aieot. */
public boolean bAIEOT; public boolean bAIEOT;
/** The b ai begin combat. */
public boolean bAIBeginCombat; public boolean bAIBeginCombat;
/** The b ai end combat. */
public boolean bAIEndCombat; public boolean bAIEndCombat;
/** The b human upkeep. */
public boolean bHumanUpkeep; public boolean bHumanUpkeep;
/** The b human draw. */
public boolean bHumanDraw; public boolean bHumanDraw;
/** The b human eot. */
public boolean bHumanEOT; public boolean bHumanEOT;
/** The b human begin combat. */
public boolean bHumanBeginCombat; public boolean bHumanBeginCombat;
/** The b human end combat. */
public boolean bHumanEndCombat; public boolean bHumanEndCombat;
private List<SavePreferencesListener> saveListeners = new ArrayList<SavePreferencesListener>(); private List<SavePreferencesListener> saveListeners = new ArrayList<SavePreferencesListener>();
private final String fileName; private final String fileName;
/** /**
* <p>Constructor for ForgePreferences.</p> * <p>
* * Constructor for ForgePreferences.
* @param fileName a {@link java.lang.String} object. * </p>
* @throws java.lang.Exception if any. *
* @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; this.fileName = fileName;
File f = new File(fileName); File f = new File(fileName);
if (!f.exists()) { if (!f.exists()) {
@@ -74,24 +137,24 @@ public class ForgePreferences extends Preferences {
stackAiLand = getBoolean("AI.stack.land", false); stackAiLand = getBoolean("AI.stack.land", false);
millingLossCondition = getBoolean("loss.condition.milling", true); millingLossCondition = getBoolean("loss.condition.milling", true);
developerMode = getBoolean("developer.mode", false); developerMode = getBoolean("developer.mode", false);
uploadDraftAI = getBoolean("upload.Draft.AI", true); uploadDraftAI = getBoolean("upload.Draft.AI", true);
randCFoil = getBoolean("rand.C.Foil", true); randCFoil = getBoolean("rand.C.Foil", true);
laf = get("gui.laf", ""); laf = get("gui.laf", "");
lafFonts = getBoolean("gui.laf.fonts", false); lafFonts = getBoolean("gui.laf.fonts", false);
skin = get("gui.skin","default"); skin = get("gui.skin", "default");
cardOverlay = getBoolean("card.overlay", true); cardOverlay = getBoolean("card.overlay", true);
cardSize = CardSizeType.valueOf(get("card.images.size", "medium")); cardSize = CardSizeType.valueOf(get("card.images.size", "medium"));
stackOffset = StackOffsetType.valueOf(get("stack.offset", "tiny")); stackOffset = StackOffsetType.valueOf(get("stack.offset", "tiny"));
maxStackSize = getInt("stack.max.size", 3); maxStackSize = getInt("stack.max.size", 3);
scaleLargerThanOriginal = getBoolean("card.scale.larger.than.original", true); scaleLargerThanOriginal = getBoolean("card.scale.larger.than.original", true);
deckGenRmvArtifacts = getBoolean("deck.gen.rmv.artifacts", false); deckGenRmvArtifacts = getBoolean("deck.gen.rmv.artifacts", false);
deckGenRmvSmall = getBoolean("deck.gen.rmv.small", false); deckGenRmvSmall = getBoolean("deck.gen.rmv.small", false);
BugzName = get("bugz.user.name", ""); BugzName = get("bugz.user.name", "");
BugzPwd = get("bugz.user.pwd", ""); BugzPwd = get("bugz.user.pwd", "");
@@ -109,11 +172,14 @@ public class ForgePreferences extends Preferences {
} }
/** /**
* <p>save.</p> * <p>
* * save.
* @throws java.lang.Exception if any. * </p>
*
* @throws Exception
* the exception
*/ */
public void save() throws Exception { public final void save() throws Exception {
set("gui.new", newGui); set("gui.new", newGui);
@@ -121,7 +187,7 @@ public class ForgePreferences extends Preferences {
set("loss.condition.milling", millingLossCondition); set("loss.condition.milling", millingLossCondition);
set("developer.mode", developerMode); set("developer.mode", developerMode);
set("upload.Draft.AI", uploadDraftAI); set("upload.Draft.AI", uploadDraftAI);
set("rand.C.Foil", randCFoil); set("rand.C.Foil", randCFoil);
set("gui.skin", skin); set("gui.skin", skin);
@@ -136,10 +202,10 @@ public class ForgePreferences extends Preferences {
for (SavePreferencesListener listeners : saveListeners) { for (SavePreferencesListener listeners : saveListeners) {
listeners.savePreferences(); listeners.savePreferences();
} }
set("deck.gen.rmv.artifacts", deckGenRmvArtifacts); set("deck.gen.rmv.artifacts", deckGenRmvArtifacts);
set("deck.gen.rmv.small", deckGenRmvSmall); set("deck.gen.rmv.small", deckGenRmvSmall);
set("bugz.user.name", BugzName); set("bugz.user.name", BugzName);
set("bugz.user.pwd", BugzPwd); set("bugz.user.pwd", BugzPwd);
@@ -164,19 +230,48 @@ public class ForgePreferences extends Preferences {
} }
/** /**
* <p>addSaveListener.</p> * <p>
* * addSaveListener.
* @param listener a {@link forge.properties.SavePreferencesListener} object. * </p>
*
* @param listener
* a {@link forge.properties.SavePreferencesListener} object.
*/ */
public void addSaveListener(SavePreferencesListener listener) { public final void addSaveListener(final SavePreferencesListener listener) {
saveListeners.add(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 { static public enum StackOffsetType {
tiny, small, medium, large
/** The tiny. */
tiny,
/** The small. */
small,
/** The medium. */
medium,
/** The large. */
large
} }
} }

View File

@@ -1,29 +1,29 @@
package forge.properties; package forge.properties;
/** /**
* ForgeProps.java * ForgeProps.java
* *
* Created on 30.08.2009 * Created on 30.08.2009
*/ */
import static java.lang.String.format;
import forge.error.ErrorViewer;
import tree.properties.TreeProperties;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.util.Locale; 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 * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class ForgeProps { public class ForgeProps {
/** Constant <code>properties</code> */ /** Constant <code>properties</code>. */
private static final TreeProperties properties; private static final TreeProperties properties;
static { 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. * @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. * @param key a {@link java.lang.String} object.
* @return 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); 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 key a {@link java.lang.String} object.
* @param def a {@link java.lang.String} object. * @param def a {@link java.lang.String} object.
* @return 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; String result;
try { try {
result = getProperties().getProperty(key); result = getProperties().getProperty(key);
if (result == null) result = def; if (result == null) {
result = def;
}
} catch (Exception ex) { } catch (Exception ex) {
result = def; 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. * @param key a {@link java.lang.String} object.
* @return a {@link java.io.File} 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); 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 key a {@link java.lang.String} object.
* @param def a {@link java.io.File} object. * @param def a {@link java.io.File} object.
* @return 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; File result;
try { try {
result = getProperties().getFile(key); result = getProperties().getFile(key);
if (result == null) result = def; if (result == null) {
result = def;
}
} catch (Exception ex) { } catch (Exception ex) {
result = def; 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 * Returns the localized version of the specified property. The key is a
* is replaced with a language code (ISO 639-1, see {@link Locale#getLanguage()}). First, the configured * format string containing "%s", which is replaced with a language code
* language is used. Second, the locale's code is used. If none of them contains the requested key, "en" is * (ISO 639-1, see {@link Locale#getLanguage()}). First, the configured
* used as the language code. * 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. *
* @param key
* a {@link java.lang.String} object.
* @return 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); return getLocalized(key, null);
} }
/** /**
* Returns the localized version of the specified property. The key is a format string containing "%s", which * Returns the localized version of the specified property. The key is a
* is replaced with a language code (ISO 639-1, see {@link Locale#getLanguage()}). First, the configured * format string containing "%s", which is replaced with a language code
* language is used. Second, the locale's code is used. If none of them contains the requested key, "en" is * (ISO 639-1, see {@link Locale#getLanguage()}). First, the configured
* used as the language code. If even that has no value, the def parameter is returned. * 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
* @param key a {@link java.lang.String} object. * that has no value, the def parameter is returned.
* @param def a {@link java.lang.String} object. *
* @param key
* a {@link java.lang.String} object.
* @param def
* a {@link java.lang.String} object.
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public static String getLocalized(String key, String def) { public static String getLocalized(final String key, final String def) {
//the list of languages to look for, in the order to be used // the list of languages to look for, in the order to be used
//the first is the configured language // the first is the configured language
//the second is the default locale's language code // the second is the default locale's language code
String[] languages = {getProperty(NewConstants.LANG.LANGUAGE), Locale.getDefault().getLanguage(), "en"}; String[] languages = {getProperty(NewConstants.LANG.LANGUAGE), Locale.getDefault().getLanguage(), "en"};
try { try {
for (String lang : languages) { for (String lang : languages) {
//could be if a property does not exist // could be if a property does not exist
//just skip it, and try the next // just skip it, and try the next
if (lang == null) continue; if (lang == null) {
continue;
}
String result = getProperty(format(key, lang)); 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 // exceptions are skipped here; also the error viewer uses this, and
//in a more fatal error (stack overflow) // reporting exceptions may result
// in a more fatal error (stack overflow)
} catch (Exception ex) { } 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; return def;
} }
} }

View File

@@ -1,6 +1,6 @@
package forge.properties; package forge.properties;
// TODO: Auto-generated Javadoc
/** /**
* NewConstants.java * NewConstants.java
* *
@@ -9,13 +9,16 @@ package forge.properties;
/** /**
* These are mostly property keys. * These are mostly property keys.
* *
* @author Clemens Koza * @author Clemens Koza
* @version V0.0 22.08.2009 * @version V0.0 22.08.2009
*/ */
public interface NewConstants { public interface NewConstants {
//General properties // General properties
/** Constant <code>HOW_TO_REPORT_BUGS_URL = "program/howToReportBugsURL"</code>. */ /**
* Constant
* <code>HOW_TO_REPORT_BUGS_URL = "program/howToReportBugsURL"</code>.
*/
String HOW_TO_REPORT_BUGS_URL = "program/howToReportBugsURL"; String HOW_TO_REPORT_BUGS_URL = "program/howToReportBugsURL";
/** Constant <code>SHOW2CDECK="showdeck/2color"</code>. */ /** Constant <code>SHOW2CDECK="showdeck/2color"</code>. */
@@ -101,7 +104,10 @@ public interface NewConstants {
/** Constant <code>BOOSTERDATA="boosterdata"</code>. */ /** Constant <code>BOOSTERDATA="boosterdata"</code>. */
String BOOSTERDATA = "boosterdata"; String BOOSTERDATA = "boosterdata";
/** The MT g_ data. */
String MTG_DATA = "mtg-data"; String MTG_DATA = "mtg-data";
/** The SYMBOL s_ small. */
String SYMBOLS_SMALL = "symbols/small"; String SYMBOLS_SMALL = "symbols/small";
/** Constant <code>IMAGE_BASE="image/base"</code>. */ /** Constant <code>IMAGE_BASE="image/base"</code>. */
@@ -152,20 +158,34 @@ public interface NewConstants {
/** Property path for a rare card. */ /** Property path for a rare card. */
String RARE = "quest/rare"; String RARE = "quest/rare";
/** The PRICE. */
String PRICE = "quest/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"; String DATA = "quest/data";
/** The PREFS. */
String PREFS = "quest/prefs"; String PREFS = "quest/prefs";
/** The DECKS. */
String DECKS = "quest/decks-dir"; String DECKS = "quest/decks-dir";
/** The XMLDATA. */
String XMLDATA = "quest/data-xml"; String XMLDATA = "quest/data-xml";
/** The OPPONEN t_ icons. */
String OPPONENT_ICONS = "quest/opponent/icons"; String OPPONENT_ICONS = "quest/opponent/icons";
/** The OPPONEN t_ dir. */
String OPPONENT_DIR = "image/icon"; String OPPONENT_DIR = "image/icon";
/** The PE t_ sho p_ icons. */
String PET_SHOP_ICONS = "quest/pet/icons"; String PET_SHOP_ICONS = "quest/pet/icons";
/** The PE t_ toke n_ images. */
String PET_TOKEN_IMAGES = "quest/pet/tokens"; String PET_TOKEN_IMAGES = "quest/pet/tokens";
} }
@@ -173,12 +193,25 @@ public interface NewConstants {
* These are GUI-related properties. * These are GUI-related properties.
*/ */
public static interface GUI { public static interface GUI {
/**
* The Interface GuiDisplay.
*/
public static interface GuiDisplay { public static interface GuiDisplay {
/** The LAYOUT. */
String LAYOUT = "gui/Display"; String LAYOUT = "gui/Display";
/** The LAYOU t_ new. */
String LAYOUT_NEW = "gui/Display/new"; String LAYOUT_NEW = "gui/Display/new";
} }
/**
* The Interface GuiDeckEditor.
*/
public static interface GuiDeckEditor { public static interface GuiDeckEditor {
/** The LAYOUT. */
String LAYOUT = "gui/DeckEditor"; String LAYOUT = "gui/DeckEditor";
} }
@@ -188,354 +221,836 @@ public interface NewConstants {
* These are localization properties. * These are localization properties.
*/ */
public static interface LANG { public static interface LANG {
/** The PROGRA m_ name. */
String PROGRAM_NAME = "%s/program/name"; String PROGRAM_NAME = "%s/program/name";
/** The LANGUAGE. */
String LANGUAGE = "lang"; String LANGUAGE = "lang";
/**
* The Interface HowTo.
*/
public static interface HowTo { public static interface HowTo {
/** The TITLE. */
String TITLE = "%s/HowTo/title"; String TITLE = "%s/HowTo/title";
/** The MESSAGE. */
String MESSAGE = "%s/HowTo/message"; String MESSAGE = "%s/HowTo/message";
} }
/**
* The Interface ErrorViewer.
*/
public static interface ErrorViewer { public static interface ErrorViewer {
/** The SHO w_ error. */
String SHOW_ERROR = "%s/ErrorViewer/show"; String SHOW_ERROR = "%s/ErrorViewer/show";
/** The TITLE. */
String TITLE = "%s/ErrorViewer/title"; String TITLE = "%s/ErrorViewer/title";
/** The MESSAGE. */
String MESSAGE = "%s/ErrorViewer/message"; String MESSAGE = "%s/ErrorViewer/message";
/** The BUTTO n_ save. */
String BUTTON_SAVE = "%s/ErrorViewer/button/save"; String BUTTON_SAVE = "%s/ErrorViewer/button/save";
/** The BUTTO n_ close. */
String BUTTON_CLOSE = "%s/ErrorViewer/button/close"; String BUTTON_CLOSE = "%s/ErrorViewer/button/close";
/** The BUTTO n_ exit. */
String BUTTON_EXIT = "%s/ErrorViewer/button/exit"; String BUTTON_EXIT = "%s/ErrorViewer/button/exit";
/**
* The Interface ERRORS.
*/
public static interface ERRORS { public static interface ERRORS {
/** The SAV e_ message. */
String SAVE_MESSAGE = "%s/ErrorViewer/errors/save/message"; String SAVE_MESSAGE = "%s/ErrorViewer/errors/save/message";
/** The SHO w_ message. */
String SHOW_MESSAGE = "%s/ErrorViewer/errors/show/message"; String SHOW_MESSAGE = "%s/ErrorViewer/errors/show/message";
} }
} }
/**
* The Interface Gui_BoosterDraft.
*/
public static interface Gui_BoosterDraft { public static interface Gui_BoosterDraft {
/** The CLOS e_ message. */
String CLOSE_MESSAGE = "%s/BoosterDraft/close/message"; String CLOSE_MESSAGE = "%s/BoosterDraft/close/message";
/** The SAV e_ message. */
String SAVE_MESSAGE = "%s/BoosterDraft/save/message"; String SAVE_MESSAGE = "%s/BoosterDraft/save/message";
/** The SAV e_ title. */
String SAVE_TITLE = "%s/BoosterDraft/save/title"; String SAVE_TITLE = "%s/BoosterDraft/save/title";
/** The RENAM e_ message. */
String RENAME_MESSAGE = "%s/BoosterDraft/rename/message"; String RENAME_MESSAGE = "%s/BoosterDraft/rename/message";
/** The RENAM e_ title. */
String RENAME_TITLE = "%s/BoosterDraft/rename/title"; String RENAME_TITLE = "%s/BoosterDraft/rename/title";
/** The SAV e_ draf t_ message. */
String SAVE_DRAFT_MESSAGE = "%s/BoosterDraft/saveDraft/message"; String SAVE_DRAFT_MESSAGE = "%s/BoosterDraft/saveDraft/message";
/** The SAV e_ draf t_ title. */
String SAVE_DRAFT_TITLE = "%s/BoosterDraft/saveDraft/title"; String SAVE_DRAFT_TITLE = "%s/BoosterDraft/saveDraft/title";
} }
/**
* The Interface GuiDisplay.
*/
public static interface GuiDisplay { public static interface GuiDisplay {
/**
* The Interface MENU_BAR.
*/
public static interface MENU_BAR { public static interface MENU_BAR {
/**
* The Interface MENU.
*/
public static interface MENU { public static interface MENU {
/** The TITLE. */
String TITLE = "%s/Display/menu/title"; String TITLE = "%s/Display/menu/title";
} }
/**
* The Interface PHASE.
*/
public static interface PHASE { public static interface PHASE {
/** The TITLE. */
String TITLE = "%s/Display/phase/title"; String TITLE = "%s/Display/phase/title";
} }
/**
* The Interface DEV.
*/
public static interface DEV { public static interface DEV {
/** The TITLE. */
String TITLE = "%s/Display/dev/title"; String TITLE = "%s/Display/dev/title";
} }
} }
/** The HUMA n_ title. */
String HUMAN_TITLE = "%s/Display/human/title"; String HUMAN_TITLE = "%s/Display/human/title";
/** The HUMA n_ decklist. */
String HUMAN_DECKLIST = "%s/Display/human/decklist"; String HUMAN_DECKLIST = "%s/Display/human/decklist";
/**
* The Interface HUMAN_HAND.
*/
public static interface HUMAN_HAND { public static interface HUMAN_HAND {
/** The TITLE. */
String TITLE = "%s/Display/human/hand/title"; String TITLE = "%s/Display/human/hand/title";
} }
/**
* The Interface HUMAN_LIBRARY.
*/
public static interface HUMAN_LIBRARY { public static interface HUMAN_LIBRARY {
/** The BASE. */
String BASE = "%s/Display/human/library"; String BASE = "%s/Display/human/library";
/** The TITLE. */
String TITLE = "%s/Display/human/library/title"; String TITLE = "%s/Display/human/library/title";
/** The MENU. */
String MENU = "%s/Display/human/library/menu"; String MENU = "%s/Display/human/library/menu";
/** The BUTTON. */
String BUTTON = "%s/Display/human/library/button"; String BUTTON = "%s/Display/human/library/button";
} }
/** The HUMA n_ graveyard. */
String HUMAN_GRAVEYARD = "%s/Display/human/graveyard"; String HUMAN_GRAVEYARD = "%s/Display/human/graveyard";
/**
* The Interface HUMAN_GRAVEYARD.
*/
public static interface HUMAN_GRAVEYARD { public static interface HUMAN_GRAVEYARD {
/** The TITLE. */
String TITLE = "%s/Display/human/graveyard/title"; String TITLE = "%s/Display/human/graveyard/title";
/** The BUTTON. */
String BUTTON = "%s/Display/human/graveyard/button"; String BUTTON = "%s/Display/human/graveyard/button";
/** The MENU. */
String MENU = "%s/Display/human/graveyard/menu"; String MENU = "%s/Display/human/graveyard/menu";
} }
/** The HUMA n_ removed. */
String HUMAN_REMOVED = "%s/Display/human/removed"; String HUMAN_REMOVED = "%s/Display/human/removed";
/**
* The Interface HUMAN_REMOVED.
*/
public static interface HUMAN_REMOVED { public static interface HUMAN_REMOVED {
/** The TITLE. */
String TITLE = "%s/Display/human/removed/title"; String TITLE = "%s/Display/human/removed/title";
/** The BUTTON. */
String BUTTON = "%s/Display/human/removed/button"; String BUTTON = "%s/Display/human/removed/button";
/** The MENU. */
String MENU = "%s/Display/human/removed/menu"; String MENU = "%s/Display/human/removed/menu";
} }
/** The COMBAT. */
String COMBAT = "%s/Display/combat/title"; String COMBAT = "%s/Display/combat/title";
/** The HUMA n_ flashback. */
String HUMAN_FLASHBACK = "%s/Display/human/flashback"; String HUMAN_FLASHBACK = "%s/Display/human/flashback";
/**
* The Interface HUMAN_FLASHBACK.
*/
public static interface HUMAN_FLASHBACK { public static interface HUMAN_FLASHBACK {
/** The TITLE. */
String TITLE = "%s/Display/human/flashback/title"; String TITLE = "%s/Display/human/flashback/title";
/** The BUTTON. */
String BUTTON = "%s/Display/human/flashback/button"; String BUTTON = "%s/Display/human/flashback/button";
/** The MENU. */
String MENU = "%s/Display/human/flashback/menu"; String MENU = "%s/Display/human/flashback/menu";
} }
/** The COMPUTE r_ title. */
String COMPUTER_TITLE = "%s/Display/computer/title"; String COMPUTER_TITLE = "%s/Display/computer/title";
/**
* The Interface COMPUTER_HAND.
*/
public static interface COMPUTER_HAND { public static interface COMPUTER_HAND {
/** The BASE. */
String BASE = "%s/Display/computer/hand"; String BASE = "%s/Display/computer/hand";
/** The TITLE. */
String TITLE = "%s/Display/computer/hand/title"; String TITLE = "%s/Display/computer/hand/title";
/** The BUTTON. */
String BUTTON = "%s/Display/computer/hand/button"; String BUTTON = "%s/Display/computer/hand/button";
/** The MENU. */
String MENU = "%s/Display/computer/hand/menu"; String MENU = "%s/Display/computer/hand/menu";
} }
/**
* The Interface COMPUTER_LIBRARY.
*/
public static interface COMPUTER_LIBRARY { public static interface COMPUTER_LIBRARY {
/** The BASE. */
String BASE = "%s/Display/computer/library"; String BASE = "%s/Display/computer/library";
/** The TITLE. */
String TITLE = "%s/Display/computer/library/title"; String TITLE = "%s/Display/computer/library/title";
/** The BUTTON. */
String BUTTON = "%s/Display/computer/library/button"; String BUTTON = "%s/Display/computer/library/button";
/** The MENU. */
String MENU = "%s/Display/computer/library/menu"; String MENU = "%s/Display/computer/library/menu";
} }
/** The COMPUTE r_ graveyard. */
String COMPUTER_GRAVEYARD = "%s/Display/computer/graveyard"; String COMPUTER_GRAVEYARD = "%s/Display/computer/graveyard";
/**
* The Interface COMPUTER_GRAVEYARD.
*/
public static interface COMPUTER_GRAVEYARD { public static interface COMPUTER_GRAVEYARD {
/** The TITLE. */
String TITLE = "%s/Display/computer/graveyard/title"; String TITLE = "%s/Display/computer/graveyard/title";
/** The BUTTON. */
String BUTTON = "%s/Display/computer/graveyard/button"; String BUTTON = "%s/Display/computer/graveyard/button";
/** The MENU. */
String MENU = "%s/Display/computer/graveyard/menu"; String MENU = "%s/Display/computer/graveyard/menu";
} }
/** The COMPUTE r_ removed. */
String COMPUTER_REMOVED = "%s/Display/computer/removed"; String COMPUTER_REMOVED = "%s/Display/computer/removed";
/**
* The Interface COMPUTER_REMOVED.
*/
public static interface COMPUTER_REMOVED { public static interface COMPUTER_REMOVED {
/** The TITLE. */
String TITLE = "%s/Display/computer/removed/title"; String TITLE = "%s/Display/computer/removed/title";
/** The BUTTON. */
String BUTTON = "%s/Display/computer/removed/button"; String BUTTON = "%s/Display/computer/removed/button";
/** The MENU. */
String MENU = "%s/Display/computer/removed/menu"; String MENU = "%s/Display/computer/removed/menu";
} }
/** The CONCEDE. */
String CONCEDE = "%s/Display/concede"; String CONCEDE = "%s/Display/concede";
/**
* The Interface CONCEDE.
*/
public static interface CONCEDE { public static interface CONCEDE {
/** The BUTTON. */
String BUTTON = "%s/Display/concede/button"; String BUTTON = "%s/Display/concede/button";
/** The MENU. */
String MENU = "%s/Display/concede/menu"; String MENU = "%s/Display/concede/menu";
} }
/** The MANAGEN. */
String MANAGEN = "%s/Display/managen"; String MANAGEN = "%s/Display/managen";
/**
* The Interface MANAGEN.
*/
public static interface MANAGEN { public static interface MANAGEN {
/** The BUTTON. */
String BUTTON = "%s/Display/managen/button"; String BUTTON = "%s/Display/managen/button";
/** The MENU. */
String MENU = "%s/Display/managen/menu"; String MENU = "%s/Display/managen/menu";
} }
/** The SETUPBATTLEFIELD. */
String SETUPBATTLEFIELD = "%s/Display/setupbattlefield"; String SETUPBATTLEFIELD = "%s/Display/setupbattlefield";
/**
* The Interface SETUPBATTLEFIELD.
*/
public static interface SETUPBATTLEFIELD { public static interface SETUPBATTLEFIELD {
/** The BUTTON. */
String BUTTON = "%s/Display/setupbattlefield/button"; String BUTTON = "%s/Display/setupbattlefield/button";
/** The MENU. */
String MENU = "%s/Display/setupbattlefield/menu"; String MENU = "%s/Display/setupbattlefield/menu";
} }
/** The TUTOR. */
String TUTOR = "%s/Display/tutor"; String TUTOR = "%s/Display/tutor";
/**
* The Interface TUTOR.
*/
public static interface TUTOR { public static interface TUTOR {
/** The BUTTON. */
String BUTTON = "%s/Display/tutor/button"; String BUTTON = "%s/Display/tutor/button";
/** The MENU. */
String MENU = "%s/Display/tutor/menu"; String MENU = "%s/Display/tutor/menu";
} }
/** The ADDCOUNTER. */
String ADDCOUNTER = "%s/Display/addcounter"; String ADDCOUNTER = "%s/Display/addcounter";
/**
* The Interface ADDCOUNTER.
*/
public static interface ADDCOUNTER { public static interface ADDCOUNTER {
/** The BUTTON. */
String BUTTON = "%s/Display/addcounter/button"; String BUTTON = "%s/Display/addcounter/button";
/** The MENU. */
String MENU = "%s/Display/addcounter/menu"; String MENU = "%s/Display/addcounter/menu";
} }
/** The TAPPERM. */
String TAPPERM = "%s/Display/tapperm"; String TAPPERM = "%s/Display/tapperm";
/**
* The Interface TAPPERM.
*/
public static interface TAPPERM { public static interface TAPPERM {
/** The BUTTON. */
String BUTTON = "%s/Display/tapperm/button"; String BUTTON = "%s/Display/tapperm/button";
/** The MENU. */
String MENU = "%s/Display/tapperm/menu"; String MENU = "%s/Display/tapperm/menu";
} }
/** The UNTAPPERM. */
String UNTAPPERM = "%s/Display/untapperm"; String UNTAPPERM = "%s/Display/untapperm";
/**
* The Interface UNTAPPERM.
*/
public static interface UNTAPPERM { public static interface UNTAPPERM {
/** The BUTTON. */
String BUTTON = "%s/Display/untapperm/button"; String BUTTON = "%s/Display/untapperm/button";
/** The MENU. */
String MENU = "%s/Display/untapperm/menu"; String MENU = "%s/Display/untapperm/menu";
} }
/** The NOLANDLIMIT. */
String NOLANDLIMIT = "%s/Display/nolandlimit"; String NOLANDLIMIT = "%s/Display/nolandlimit";
/**
* The Interface NOLANDLIMIT.
*/
public static interface NOLANDLIMIT { public static interface NOLANDLIMIT {
/** The BUTTON. */
String BUTTON = "%s/Display/nolandlimit/button"; String BUTTON = "%s/Display/nolandlimit/button";
/** The MENU. */
String MENU = "%s/Display/nolandlimit/menu"; String MENU = "%s/Display/nolandlimit/menu";
} }
/** The SETLIFE. */
String SETLIFE = "%s/Display/setlife"; String SETLIFE = "%s/Display/setlife";
/**
* The Interface SETLIFE.
*/
public static interface SETLIFE { public static interface SETLIFE {
/** The BUTTON. */
String BUTTON = "%s/Display/setlife/button"; String BUTTON = "%s/Display/setlife/button";
/** The MENU. */
String MENU = "%s/Display/setlife/menu"; String MENU = "%s/Display/setlife/menu";
} }
/**
* The Interface TRIGGER.
*/
public static interface TRIGGER { public static interface TRIGGER {
/** The ALWAYSACCEPT. */
String ALWAYSACCEPT = "%s/Display/alwaysaccept"; String ALWAYSACCEPT = "%s/Display/alwaysaccept";
/** The ALWAYSDECLINE. */
String ALWAYSDECLINE = "%s/Display/alwaysdecline"; String ALWAYSDECLINE = "%s/Display/alwaysdecline";
/** The ALWAYSASK. */
String ALWAYSASK = "%s/Display/alwaysask"; String ALWAYSASK = "%s/Display/alwaysask";
} }
} }
/**
* The Interface Gui_DownloadPictures.
*/
public static interface Gui_DownloadPictures { public static interface Gui_DownloadPictures {
/** The TITLE. */
String TITLE = "%s/DownloadPictures/title"; String TITLE = "%s/DownloadPictures/title";
/** The PROX y_ address. */
String PROXY_ADDRESS = "%s/DownloadPictures/proxy/address"; String PROXY_ADDRESS = "%s/DownloadPictures/proxy/address";
/** The PROX y_ port. */
String PROXY_PORT = "%s/DownloadPictures/proxy/port"; String PROXY_PORT = "%s/DownloadPictures/proxy/port";
/** The N o_ proxy. */
String NO_PROXY = "%s/DownloadPictures/proxy/type/none"; String NO_PROXY = "%s/DownloadPictures/proxy/type/none";
/** The HTT p_ proxy. */
String HTTP_PROXY = "%s/DownloadPictures/proxy/type/http"; String HTTP_PROXY = "%s/DownloadPictures/proxy/type/http";
/** The SOCK s_ proxy. */
String SOCKS_PROXY = "%s/DownloadPictures/proxy/type/socks"; String SOCKS_PROXY = "%s/DownloadPictures/proxy/type/socks";
/** The N o_ more. */
String NO_MORE = "%s/DownloadPictures/no-more"; String NO_MORE = "%s/DownloadPictures/no-more";
/** The BA r_ befor e_ start. */
String BAR_BEFORE_START = "%s/DownloadPictures/bar/before-start"; String BAR_BEFORE_START = "%s/DownloadPictures/bar/before-start";
/** The BA r_ wait. */
String BAR_WAIT = "%s/DownloadPictures/bar/wait"; String BAR_WAIT = "%s/DownloadPictures/bar/wait";
/** The BA r_ close. */
String BAR_CLOSE = "%s/DownloadPictures/bar/close"; String BAR_CLOSE = "%s/DownloadPictures/bar/close";
/**
* The Interface BUTTONS.
*/
public static interface BUTTONS { public static interface BUTTONS {
/** The START. */
String START = "%s/DownloadPictures/button/start"; String START = "%s/DownloadPictures/button/start";
/** The CANCEL. */
String CANCEL = "%s/DownloadPictures/button/cancel"; String CANCEL = "%s/DownloadPictures/button/cancel";
/** The CLOSE. */
String CLOSE = "%s/DownloadPictures/button/close"; String CLOSE = "%s/DownloadPictures/button/close";
} }
/**
* The Interface ERRORS.
*/
public static interface ERRORS { public static interface ERRORS {
/** The PROX y_ connect. */
String PROXY_CONNECT = "%s/DownloadPictures/errors/proxy/connect"; String PROXY_CONNECT = "%s/DownloadPictures/errors/proxy/connect";
/** The OTHER. */
String OTHER = "%s/DownloadPictures/errors/other"; String OTHER = "%s/DownloadPictures/errors/other";
} }
} }
/**
* The Interface OldGuiNewGame.
*/
public static interface OldGuiNewGame { public static interface OldGuiNewGame {
/**
* The Interface NEW_GAME_TEXT.
*/
public static interface NEW_GAME_TEXT { public static interface NEW_GAME_TEXT {
/** The GAMETYPE. */
String GAMETYPE = "%s/NewGame/gametype"; String GAMETYPE = "%s/NewGame/gametype";
/** The LIBRARY. */
String LIBRARY = "%s/NewGame/library"; String LIBRARY = "%s/NewGame/library";
/** The SETTINGS. */
String SETTINGS = "%s/NewGame/settings"; String SETTINGS = "%s/NewGame/settings";
/** The NE w_ game. */
String NEW_GAME = "%s/NewGame/new_game"; String NEW_GAME = "%s/NewGame/new_game";
/** The CONSTRUCTE d_ text. */
String CONSTRUCTED_TEXT = "%s/NewGame/constructed_text"; String CONSTRUCTED_TEXT = "%s/NewGame/constructed_text";
/** The SEALE d_ text. */
String SEALED_TEXT = "%s/NewGame/sealed_text"; String SEALED_TEXT = "%s/NewGame/sealed_text";
/** The BOOSTE r_ text. */
String BOOSTER_TEXT = "%s/NewGame/booster_text"; String BOOSTER_TEXT = "%s/NewGame/booster_text";
/** The YOURDECK. */
String YOURDECK = "%s/NewGame/yourdeck"; String YOURDECK = "%s/NewGame/yourdeck";
/** The OPPONENT. */
String OPPONENT = "%s/NewGame/opponent"; String OPPONENT = "%s/NewGame/opponent";
/** The DEC k_ editor. */
String DECK_EDITOR = "%s/NewGame/deckeditor"; String DECK_EDITOR = "%s/NewGame/deckeditor";
/** The NE w_ gui. */
String NEW_GUI = "%s/NewGame/newgui"; String NEW_GUI = "%s/NewGame/newgui";
/** The A i_ land. */
String AI_LAND = "%s/NewGame/ailand"; String AI_LAND = "%s/NewGame/ailand";
/** The DE v_ mode. */
String DEV_MODE = "%s/NewGame/devmode"; String DEV_MODE = "%s/NewGame/devmode";
/** The QUES t_ mode. */
String QUEST_MODE = "%s/NewGame/questmode"; String QUEST_MODE = "%s/NewGame/questmode";
/** The STAR t_ game. */
String START_GAME = "%s/NewGame/startgame"; String START_GAME = "%s/NewGame/startgame";
/** The SAV e_ seale d_ msg. */
String SAVE_SEALED_MSG = "%s/NewGame/savesealed_msg"; String SAVE_SEALED_MSG = "%s/NewGame/savesealed_msg";
/** The SAV e_ seale d_ ttl. */
String SAVE_SEALED_TTL = "%s/NewGame/savesealed_ttl"; String SAVE_SEALED_TTL = "%s/NewGame/savesealed_ttl";
} }
/**
* The Interface MENU_BAR.
*/
public static interface MENU_BAR { public static interface MENU_BAR {
/**
* The Interface MENU.
*/
public static interface MENU { public static interface MENU {
/** The TITLE. */
String TITLE = "%s/NewGame/menu/title"; String TITLE = "%s/NewGame/menu/title";
/** The LF. */
String LF = "%s/NewGame/menu/lookAndFeel"; String LF = "%s/NewGame/menu/lookAndFeel";
/** The DOWNLOADPRICE. */
String DOWNLOADPRICE = "%s/NewGame/menu/downloadPrice"; String DOWNLOADPRICE = "%s/NewGame/menu/downloadPrice";
/** The DOWNLOAD. */
String DOWNLOAD = "%s/NewGame/menu/download"; String DOWNLOAD = "%s/NewGame/menu/download";
/** The DOWNLOADLQ. */
String DOWNLOADLQ = "%s/NewGame/menu/downloadlq"; String DOWNLOADLQ = "%s/NewGame/menu/downloadlq";
/** The DOWNLOADSETLQ. */
String DOWNLOADSETLQ = "%s/NewGame/menu/downloadsetlq"; String DOWNLOADSETLQ = "%s/NewGame/menu/downloadsetlq";
/** The DOWNLOADQUESTIMG. */
String DOWNLOADQUESTIMG = "%s/NewGame/menu/downloadquest"; String DOWNLOADQUESTIMG = "%s/NewGame/menu/downloadquest";
/** The IMPORTPICTURE. */
String IMPORTPICTURE = "%s/NewGame/menu/importPicture"; String IMPORTPICTURE = "%s/NewGame/menu/importPicture";
/** The CAR d_ sizes. */
String CARD_SIZES = "%s/NewGame/menu/cardSizes"; String CARD_SIZES = "%s/NewGame/menu/cardSizes";
/** The CAR d_ stack. */
String CARD_STACK = "%s/NewGame/menu/cardStack"; String CARD_STACK = "%s/NewGame/menu/cardStack";
/** The CAR d_ stac k_ offset. */
String CARD_STACK_OFFSET = "%s/NewGame/menu/cardStackOffset"; String CARD_STACK_OFFSET = "%s/NewGame/menu/cardStackOffset";
/** The ABOUT. */
String ABOUT = "%s/NewGame/menu/about"; String ABOUT = "%s/NewGame/menu/about";
/** The EXIT. */
String EXIT = "%s/NewGame/menu/exit"; String EXIT = "%s/NewGame/menu/exit";
} }
/**
* The Interface OPTIONS.
*/
public static interface OPTIONS { public static interface OPTIONS {
/** The TITLE. */
String TITLE = "%s/NewGame/options/title"; String TITLE = "%s/NewGame/options/title";
/** The FONT. */
String FONT = "%s/NewGame/options/font"; String FONT = "%s/NewGame/options/font";
/** The CAR d_ overlay. */
String CARD_OVERLAY = "%s/NewGame/options/cardOverlay"; String CARD_OVERLAY = "%s/NewGame/options/cardOverlay";
/** The CAR d_ scale. */
String CARD_SCALE = "%s/NewGame/options/cardScale"; String CARD_SCALE = "%s/NewGame/options/cardScale";
/**
* The Interface GENERATE.
*/
public static interface GENERATE { public static interface GENERATE {
/** The TITLE. */
String TITLE = "%s/NewGame/options/generate/title"; String TITLE = "%s/NewGame/options/generate/title";
/** The REMOV e_ small. */
String REMOVE_SMALL = "%s/NewGame/options/generate/removeSmall"; String REMOVE_SMALL = "%s/NewGame/options/generate/removeSmall";
/** The REMOV e_ artifacts. */
String REMOVE_ARTIFACTS = "%s/NewGame/options/generate/removeArtifacts"; String REMOVE_ARTIFACTS = "%s/NewGame/options/generate/removeArtifacts";
} }
} }
/**
* The Interface HELP.
*/
public static interface HELP { public static interface HELP {
/** The TITLE. */
String TITLE = "%s/NewGame/help/title"; String TITLE = "%s/NewGame/help/title";
} }
} }
/**
* The Interface ERRORS.
*/
public static interface ERRORS { public static interface ERRORS {
} }
} }
/**
* The Interface WinLoseFrame.
*/
public static interface WinLoseFrame { public static interface WinLoseFrame {
/**
* The Interface WINLOSETEXT.
*/
public static interface WINLOSETEXT { public static interface WINLOSETEXT {
/** The WON. */
String WON = "%s/WinLose/won"; String WON = "%s/WinLose/won";
/** The LOST. */
String LOST = "%s/WinLose/lost"; String LOST = "%s/WinLose/lost";
/** The WIN. */
String WIN = "%s/WinLose/win"; String WIN = "%s/WinLose/win";
/** The LOSE. */
String LOSE = "%s/WinLose/lose"; String LOSE = "%s/WinLose/lose";
/** The CONTINUE. */
String CONTINUE = "%s/WinLose/continue"; String CONTINUE = "%s/WinLose/continue";
/** The RESTART. */
String RESTART = "%s/WinLose/restart"; String RESTART = "%s/WinLose/restart";
String QUIT = "%s/WinLose/quit";
} /** The 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";
String QUIT = "%s/WinLose/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 { public static interface Gui_DownloadPrices {
/**
* The Interface DOWNLOADPRICES.
*/
public static interface DOWNLOADPRICES { public static interface DOWNLOADPRICES {
/** The TITLE. */
String TITLE = "%s/DownloadPrices/title"; String TITLE = "%s/DownloadPrices/title";
/** The STAR t_ update. */
String START_UPDATE = "%s/DownloadPrices/startupdate"; String START_UPDATE = "%s/DownloadPrices/startupdate";
/** The DOWNLOADING. */
String DOWNLOADING = "%s/DownloadPrices/downloading"; String DOWNLOADING = "%s/DownloadPrices/downloading";
/** The COMPILING. */
String COMPILING = "%s/DownloadPrices/compiling"; String COMPILING = "%s/DownloadPrices/compiling";
} }
} }
/**
* The Interface GameAction.
*/
public static 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";
} }
} }
} }
} }

View File

@@ -1,44 +1,55 @@
package forge.properties; package forge.properties;
import java.io.FileInputStream; import java.io.FileInputStream;
import java.io.FileOutputStream; import java.io.FileOutputStream;
import java.io.IOException; 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. * A collection of name/value pairs with sorted keys and utility methods.
* *
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class Preferences { public class Preferences {
/** The props. */
protected Properties props; protected Properties props;
/** /**
* <p>Constructor for Preferences.</p> * <p>
* Constructor for Preferences.
* </p>
*/ */
public Preferences() { public Preferences() {
props = new Properties(); props = new Properties();
} }
/** /**
* <p>Constructor for Preferences.</p> * <p>
* * Constructor for Preferences.
* @param prefs a {@link forge.properties.Preferences} object. * </p>
*
* @param prefs
* a {@link forge.properties.Preferences} object.
*/ */
public Preferences(Preferences prefs) { public Preferences(final Preferences prefs) {
props = prefs.props; props = prefs.props;
} }
/** /**
* <p>keys.</p> * <p>
* * keys.
* </p>
*
* @return a {@link java.util.Enumeration} object. * @return a {@link java.util.Enumeration} object.
*/ */
public synchronized Enumeration<String> keys() { public final synchronized Enumeration<String> keys() {
@SuppressWarnings({"unchecked", "rawtypes"}) @SuppressWarnings({ "unchecked", "rawtypes" })
Set<String> keysEnum = (Set) props.keySet(); Set<String> keysEnum = (Set) props.keySet();
Vector<String> keyList = new Vector<String>(); Vector<String> keyList = new Vector<String>();
keyList.addAll(keysEnum); keyList.addAll(keysEnum);
@@ -47,15 +58,21 @@ public class Preferences {
} }
/** /**
* <p>getInt.</p> * <p>
* * getInt.
* @param name a {@link java.lang.String} object. * </p>
* @param defaultValue a int. *
* @param name
* a {@link java.lang.String} object.
* @param defaultValue
* a int.
* @return 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); String value = props.getProperty(name);
if (value == null) return defaultValue; if (value == null) {
return defaultValue;
}
try { try {
return Integer.parseInt(value); return Integer.parseInt(value);
} catch (NumberFormatException ex) { } catch (NumberFormatException ex) {
@@ -64,72 +81,103 @@ public class Preferences {
} }
/** /**
* <p>getBoolean.</p> * <p>
* * getBoolean.
* @param name a {@link java.lang.String} object. * </p>
* @param defaultValue a boolean. *
* @param name
* a {@link java.lang.String} object.
* @param defaultValue
* a boolean.
* @return 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); String value = props.getProperty(name);
if (value == null) return defaultValue; if (value == null) {
return defaultValue;
}
return Boolean.parseBoolean(value); return Boolean.parseBoolean(value);
} }
/** /**
* <p>getLong.</p> * <p>
* * getLong.
* @param name a {@link java.lang.String} object. * </p>
* @param defaultValue a long. *
* @param name
* a {@link java.lang.String} object.
* @param defaultValue
* a long.
* @return 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); String value = props.getProperty(name);
if (value == null) return defaultValue; if (value == null) {
return defaultValue;
}
return Long.parseLong(value); return Long.parseLong(value);
} }
/** /**
* <p>set.</p> * <p>
* * set.
* @param key a {@link java.lang.String} object. * </p>
* @param value a {@link java.lang.Object} object. *
* @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)); props.setProperty(key, String.valueOf(value));
} }
/** /**
* <p>get.</p> * <p>
* * get.
* @param key a {@link java.lang.String} object. * </p>
* @param value a {@link java.lang.Object} object. *
* @param key
* a {@link java.lang.String} object.
* @param value
* a {@link java.lang.Object} object.
* @return a {@link java.lang.String} 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; String string = null;
if (value != null) string = String.valueOf(value); if (value != null) {
string = String.valueOf(value);
}
return props.getProperty(key, string); return props.getProperty(key, string);
} }
/** /**
* <p>load.</p> * <p>
* * load.
* @param stream a {@link java.io.FileInputStream} object. * </p>
* @throws java.io.IOException if any. *
* @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); props.load(stream);
} }
/** /**
* <p>store.</p> * <p>
* * store.
* @param stream a {@link java.io.FileOutputStream} object. * </p>
* @param comments a {@link java.lang.String} object. *
* @throws java.io.IOException if any. * @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); props.store(stream, comments);
} }
} }

View File

@@ -1,14 +1,18 @@
package forge.properties; package forge.properties;
/** /**
* <p>SavePreferencesListener interface.</p> * <p>
* * SavePreferencesListener interface.
* </p>
*
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public interface SavePreferencesListener { public interface SavePreferencesListener {
/** /**
* <p>savePreferences.</p> * <p>
* savePreferences.
* </p>
*/ */
public void savePreferences(); void savePreferences();
} }

View File

@@ -1,2 +1,2 @@
/** Forge Card Game */ /** Forge Card Game. */
package forge.properties; package forge.properties;

View File

@@ -1,5 +1,11 @@
package forge.quest.data; 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.MyRandom;
import forge.SetUtils; import forge.SetUtils;
import forge.deck.Deck; import forge.deck.Deck;
@@ -12,114 +18,138 @@ import forge.properties.NewConstants;
import forge.quest.data.item.QuestInventory; import forge.quest.data.item.QuestInventory;
import forge.quest.data.pet.QuestPetManager; import forge.quest.data.pet.QuestPetManager;
import java.util.ArrayList; // TODO: Auto-generated Javadoc
import java.util.HashMap;
import java.util.List;
import java.util.Map;
import net.slightlymagic.maxmtg.Predicate;
//when you create QuestDataOld and AFTER you copy the AI decks over //when you create QuestDataOld and AFTER you copy the AI decks over
//you have to call one of these two methods below //you have to call one of these two methods below
//see Gui_QuestOptions for more details //see Gui_QuestOptions for more details
/** /**
* <p>QuestData class.</p> * <p>
* * QuestData class.
* </p>
*
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public final class QuestData { public final class QuestData {
//This field holds the version of the Quest Data // This field holds the version of the Quest Data
/** Constant <code>CURRENT_VERSION_NUMBER=2</code> */ /** Constant <code>CURRENT_VERSION_NUMBER=2</code>. */
public static final int CURRENT_VERSION_NUMBER = 2; public static final int CURRENT_VERSION_NUMBER = 2;
//This field places the version number into QD instance, // This field places the version number into QD instance,
//but only when the object is created through the constructor // but only when the object is created through the constructor
//DO NOT RENAME THIS FIELD // DO NOT RENAME THIS FIELD
/** The version number. */
int versionNumber = CURRENT_VERSION_NUMBER; int versionNumber = CURRENT_VERSION_NUMBER;
/** The rank index. */
int rankIndex; // level int rankIndex; // level
/** The win. */
int win; // number of wins int win; // number of wins
/** The lost. */
int lost; int lost;
/** The credits. */
long credits; // this money is good for all modes 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 // Diffuculty - they store both index and title
/** The diff index. */
int diffIndex; int diffIndex;
/** The difficulty. */
String difficulty; String difficulty;
// Quest mode - there should be an enum :( // Quest mode - there should be an enum :(
/** The mode. */
String mode = ""; String mode = "";
/** The Constant FANTASY. */
public static final String FANTASY = "Fantasy"; public static final String FANTASY = "Fantasy";
/** The Constant REALISTIC. */
public static final String REALISTIC = "Realistic"; public static final String REALISTIC = "Realistic";
// Decks collected by player // Decks collected by player
/** The my decks. */
Map<String, Deck> myDecks = new HashMap<String, Deck>(); Map<String, Deck> myDecks = new HashMap<String, Deck>();
// Cards associated with quest // Cards associated with quest
ItemPool<InventoryItem> cardPool = new ItemPool<InventoryItem>(InventoryItem.class); // player's belonging /** The card pool. */
ItemPool<InventoryItem> shopList = new ItemPool<InventoryItem>(InventoryItem.class); // the current shop list ItemPool<InventoryItem> cardPool = new ItemPool<InventoryItem>(InventoryItem.class); // player's
ItemPool<InventoryItem> newCardList = new ItemPool<InventoryItem>(InventoryItem.class); // cards acquired since last game-win/loss // belonging
/** The shop list. */
ItemPool<InventoryItem> shopList = new ItemPool<InventoryItem>(InventoryItem.class); // the
// current
// shop
// list
/** The new card list. */
ItemPool<InventoryItem> newCardList = new ItemPool<InventoryItem>(InventoryItem.class); // cards
// acquired
// since
// last
// game-win/loss
// Challenge history // Challenge history
/** The challenges played. */
int challengesPlayed = 0; int challengesPlayed = 0;
/** The available challenges. */
List<Integer> availableChallenges = new ArrayList<Integer>(); List<Integer> availableChallenges = new ArrayList<Integer>();
/** The completed challenges. */
List<Integer> completedChallenges = new ArrayList<Integer>(); List<Integer> completedChallenges = new ArrayList<Integer>();
// Challenges used to be called quests. During the renaming, // Challenges used to be called quests. During the renaming,
// files could be corrupted. These fields ensure old files still work. // files could be corrupted. These fields ensure old files still work.
// These fields should be phased out after a little while. // 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; int questsPlayed = -1;
/** The available quests. */
List<Integer> availableQuests = null; List<Integer> availableQuests = null;
/** The completed quests. */
List<Integer> completedQuests = null; List<Integer> completedQuests = null;
// own randomizer seed // own randomizer seed
private long randomSeed = 0; private long randomSeed = 0;
// Utility class to access cards, has access to private fields // 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; private transient QuestUtilCards myCards;
public static final String[] RANK_TITLES = new String[]{ /** The Constant RANK_TITLES. */
"Level 0 - Confused Wizard", public static final String[] RANK_TITLES = new String[] {"Level 0 - Confused Wizard", "Level 1 - Mana Mage",
"Level 1 - Mana Mage", "Level 2 - Death by Megrim", "Level 3 - Shattered the Competition", "Level 4 - Black Knighted",
"Level 2 - Death by Megrim", "Level 5 - Shockingly Good", "Level 6 - Regressed into Timmy", "Level 7 - Loves Blue Control",
"Level 3 - Shattered the Competition", "Level 8 - Immobilized by Fear", "Level 9 - Lands = Friends", "Level 10 - Forging new paths",
"Level 4 - Black Knighted", "Level 11 - Infect-o-tron", "Level 12 - Great Balls of Fire", "Level 13 - Artifact Schmartifact",
"Level 5 - Shockingly Good", "Level 14 - Mike Mulligan's The Name", "Level 15 - Fresh Air: Good For The Health",
"Level 6 - Regressed into Timmy", "Level 16 - In It For The Love", "Level 17 - Sticks, Stones, Bones", "Level 18 - Credits For Breakfast",
"Level 7 - Loves Blue Control", "Level 19 - Millasaurus", "Level 20 - One-turn Wonder", "Teaching Gandalf a Lesson",
"Level 8 - Immobilized by Fear", "What Do You Do With The Other Hand?", "Freelance Sorcerer, Works Weekends",
"Level 9 - Lands = Friends", "Should We Hire Commentators?", "Saltblasted For Your Talent", "Serra Angel Is Your Girlfriend", };
"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",
};
/** /**
* <p>Constructor for QuestData.</p> * <p>
* Constructor for QuestData.
* </p>
*/ */
public QuestData() { public QuestData() {
initTransients(); initTransients();
@@ -132,15 +162,30 @@ public final class QuestData {
myCards = new QuestUtilCards(this); myCards = new QuestUtilCards(this);
// to avoid NPE some pools will be created here if they are null // to avoid NPE some pools will be created here if they are null
if (null == newCardList) { newCardList = new ItemPool<InventoryItem>(InventoryItem.class); } if (null == newCardList) {
if (null == shopList) { shopList = new ItemPool<InventoryItem>(InventoryItem.class); } newCardList = new ItemPool<InventoryItem>(InventoryItem.class);
}
if (null == shopList) {
shopList = new ItemPool<InventoryItem>(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) { public void newGame(final int diff, final String m0de, final boolean standardStart) {
setDifficulty(diff); setDifficulty(diff);
Predicate<CardPrinted> filter = standardStart ? SetUtils.getStandard().getFilterPrinted() : CardPrinted.Predicates.Presets.isTrue; Predicate<CardPrinted> filter = standardStart ? SetUtils.getStandard().getFilterPrinted()
: CardPrinted.Predicates.Presets.isTrue;
myCards.setupNewGameCardPool(filter, diff); myCards.setupNewGameCardPool(filter, diff);
credits = QuestPreferences.getStartingCredits(); credits = QuestPreferences.getStartingCredits();
@@ -150,102 +195,267 @@ public final class QuestData {
} }
// All belongings // 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 // Cards - class uses data from here
public QuestUtilCards getCards() { return myCards; } /**
* Gets the cards.
*
* @return the cards
*/
public QuestUtilCards getCards() {
return myCards;
}
// Challenge performance // Challenge performance
/**
* Gets the challenges played.
*
* @return the challenges played
*/
public int getChallengesPlayed() { public int getChallengesPlayed() {
// This should be phased out after a while, when // This should be phased out after a while, when
// old quest decks have been updated. (changes made 19-9-11) // old quest decks have been updated. (changes made 19-9-11)
if(questsPlayed!=-1) { if (questsPlayed != -1) {
challengesPlayed = questsPlayed; challengesPlayed = questsPlayed;
questsPlayed = -1; questsPlayed = -1;
} }
return challengesPlayed; return challengesPlayed;
} }
public void addChallengesPlayed() { challengesPlayed++; }
public List<Integer> getAvailableChallenges() { /**
* Adds the challenges played.
*/
public void addChallengesPlayed() {
challengesPlayed++;
}
/**
* Gets the available challenges.
*
* @return the available challenges
*/
public List<Integer> getAvailableChallenges() {
// This should be phased out after a while, when // This should be phased out after a while, when
// old quest decks have been updated. (changes made 19-9-11) // old quest decks have been updated. (changes made 19-9-11)
if(availableQuests != null) { if (availableQuests != null) {
availableChallenges = availableQuests; availableChallenges = availableQuests;
availableQuests = null; availableQuests = null;
} }
return availableChallenges != null ? new ArrayList<Integer>(availableChallenges) : null; return availableChallenges != null ? new ArrayList<Integer>(availableChallenges) : null;
} }
public void setAvailableChallenges(final List<Integer> list) { availableChallenges = list; }
public void clearAvailableChallenges() { availableChallenges.clear(); }
/** /**
* <p>getCompletedChallenges.</p> * Sets the available challenges.
*
* @param list
* the new available challenges
*/
public void setAvailableChallenges(final List<Integer> list) {
availableChallenges = list;
}
/**
* Clear available challenges.
*/
public void clearAvailableChallenges() {
availableChallenges.clear();
}
/**
* <p>
* getCompletedChallenges.
* </p>
* Returns stored list of non-repeatable challenge IDs. * Returns stored list of non-repeatable challenge IDs.
* *
* @return List<Integer> * @return List<Integer>
*/ */
public List<Integer> getCompletedChallenges() { public List<Integer> getCompletedChallenges() {
// This should be phased out after a while, when // This should be phased out after a while, when
// old quest decks have been updated. (changes made 19-9-11) // old quest decks have been updated. (changes made 19-9-11)
// Also, poorly named - this should be "getLockedChalleneges" or similar. // Also, poorly named - this should be "getLockedChalleneges" or
if(completedQuests != null) { // similar.
if (completedQuests != null) {
completedChallenges = completedQuests; completedChallenges = completedQuests;
completedQuests = null; completedQuests = null;
} }
return completedChallenges != null ? new ArrayList<Integer>(completedChallenges) : null; return completedChallenges != null ? new ArrayList<Integer>(completedChallenges) : null;
} }
/** /**
* <p>addCompletedChallenge.</p> * <p>
* addCompletedChallenge.
* </p>
* Add non-repeatable challenge ID to list. * Add non-repeatable challenge ID to list.
* *
* @param int i * @param i
* the i
*/ */
// Poorly named - this should be "setLockedChalleneges" or similar. // Poorly named - this should be "setLockedChalleneges" or similar.
public void addCompletedChallenge(int i) { public void addCompletedChallenge(final int i) {
completedChallenges.add(i); completedChallenges.add(i);
} }
// Wins & Losses // Wins & Losses
public int getLost() { return lost; } /**
public void addLost() { lost++; } * Gets the lost.
public int getWin() { return win; } *
public void addWin() { //changes getRank() * @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++; win++;
int winsToLvlUp = QuestPreferences.getWinsForRankIncrease(diffIndex); int winsToLvlUp = QuestPreferences.getWinsForRankIncrease(diffIndex);
if (win % winsToLvlUp == 0) { rankIndex++; } if (win % winsToLvlUp == 0) {
rankIndex++;
}
} }
// Life (only fantasy) // 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 // Credits
public void addCredits(final long c) { credits += c; } /**
public void subtractCredits(final long c) { credits = credits > c ? credits - c : 0; } * Adds the credits.
public long getCredits() { return 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 // 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 // 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) { public void setDifficulty(final int i) {
diffIndex = i; diffIndex = i;
difficulty = QuestPreferences.getDifficulty(i); difficulty = QuestPreferences.getDifficulty(i);
} }
/**
* Guess difficulty index.
*/
public void guessDifficultyIndex() { public void guessDifficultyIndex() {
String[] diffStr = QuestPreferences.getDifficulty(); String[] diffStr = QuestPreferences.getDifficulty();
for (int i = 0; i < diffStr.length; i++) { for (int i = 0; i < diffStr.length; i++) {
@@ -256,21 +466,64 @@ public final class QuestData {
} }
// Level, read-only ( note: it increments in addWin() ) // Level, read-only ( note: it increments in addWin() )
public int getLevel() { return rankIndex; } /**
public String getRank() { * Gets the level.
if (rankIndex >= RANK_TITLES.length) { rankIndex = RANK_TITLES.length - 1; } *
* @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]; return RANK_TITLES[rankIndex];
} }
// decks management // decks management
public List<String> getDeckNames() { return new ArrayList<String>(myDecks.keySet()); } /**
public void removeDeck(final String deckName) { myDecks.remove(deckName); } * Gets the deck names.
public void addDeck(final Deck d) { myDecks.put(d.getName(), d); } *
* @return the deck names
*/
public List<String> getDeckNames() {
return new ArrayList<String>(myDecks.keySet());
}
/** /**
* <p>getDeck.</p> * Removes the deck.
* *
* @param deckName a {@link java.lang.String} object. * @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);
}
/**
* <p>
* getDeck.
* </p>
*
* @param deckName
* a {@link java.lang.String} object.
* @return a {@link forge.deck.Deck} object. * @return a {@link forge.deck.Deck} object.
*/ */
public Deck getDeck(final String deckName) { public Deck getDeck(final String deckName) {
@@ -284,7 +537,14 @@ public final class QuestData {
} }
// randomizer - related // 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. * This method should be called whenever the opponents should change.
@@ -296,15 +556,30 @@ public final class QuestData {
// SERIALIZATION - related things // SERIALIZATION - related things
// This must be called by XML-serializer via reflection // This must be called by XML-serializer via reflection
/**
* Read resolve.
*
* @return the object
*/
public Object readResolve() { public Object readResolve() {
initTransients(); initTransients();
return this; return this;
} }
/**
* Checks for save file.
*
* @return true, if successful
*/
public boolean hasSaveFile() { public boolean hasSaveFile() {
return ForgeProps.getFile(NewConstants.QUEST.DATA).exists() || return ForgeProps.getFile(NewConstants.QUEST.DATA).exists()
ForgeProps.getFile(NewConstants.QUEST.XMLDATA).exists(); || ForgeProps.getFile(NewConstants.QUEST.XMLDATA).exists();
} }
public void saveData() { QuestDataIO.saveData(this); } /**
* Save data.
*/
public void saveData() {
QuestDataIO.saveData(this);
}
} }

View File

@@ -1,12 +1,32 @@
package forge.quest.data; 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.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.Converter;
import com.thoughtworks.xstream.converters.MarshallingContext; import com.thoughtworks.xstream.converters.MarshallingContext;
import com.thoughtworks.xstream.converters.UnmarshallingContext; 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.error.ErrorViewer;
import forge.game.GameType; import forge.game.GameType;
@@ -19,54 +39,47 @@ import forge.properties.ForgeProps;
import forge.properties.NewConstants; import forge.properties.NewConstants;
import forge.quest.data.item.QuestInventory; 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;
/** /**
* <p>QuestDataIO class.</p> * <p>
* * QuestDataIO class.
* </p>
*
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class QuestDataIO { public class QuestDataIO {
/** /**
* <p>Constructor for QuestDataIO.</p> * <p>
* Constructor for QuestDataIO.
* </p>
*/ */
public QuestDataIO() { public QuestDataIO() {
} }
/** /**
* <p>loadData.</p> * <p>
* * loadData.
* </p>
*
* @return a {@link forge.quest.data.QuestData} object. * @return a {@link forge.quest.data.QuestData} object.
*/ */
public static QuestData loadData() { public static QuestData loadData() {
try { try {
//read file "questData" // read file "questData"
QuestData data = null; QuestData data = null;
File xmlSaveFile = ForgeProps.getFile(NewConstants.QUEST.XMLDATA); File xmlSaveFile = ForgeProps.getFile(NewConstants.QUEST.XMLDATA);
GZIPInputStream zin = GZIPInputStream zin = new GZIPInputStream(new FileInputStream(xmlSaveFile));
new GZIPInputStream(new FileInputStream(xmlSaveFile));
StringBuilder xml = new StringBuilder(); StringBuilder xml = new StringBuilder();
char[] buf = new char[1024]; char[] buf = new char[1024];
InputStreamReader reader = new InputStreamReader(zin); InputStreamReader reader = new InputStreamReader(zin);
while (reader.ready()) { while (reader.ready()) {
int len = reader.read(buf); 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); xml.append(buf, 0, len);
} }
@@ -75,7 +88,7 @@ public class QuestDataIO {
xStream.registerConverter(new GameTypeToXml()); xStream.registerConverter(new GameTypeToXml());
xStream.alias("CardPool", ItemPool.class); xStream.alias("CardPool", ItemPool.class);
data = (QuestData) xStream.fromXML(xml.toString()); data = (QuestData) xStream.fromXML(xml.toString());
if (data.versionNumber != QuestData.CURRENT_VERSION_NUMBER) { if (data.versionNumber != QuestData.CURRENT_VERSION_NUMBER) {
updateSaveFile(data, xml.toString()); updateSaveFile(data, xml.toString());
} }
@@ -90,52 +103,54 @@ public class QuestDataIO {
} }
/** /**
* <p>updateSaveFile.</p> * <p>
* * updateSaveFile.
* @param newData a {@link forge.quest.data.QuestData} object. * </p>
* @param input a {@link java.lang.String} object. *
* @param newData
* a {@link forge.quest.data.QuestData} object.
* @param input
* a {@link java.lang.String} object.
*/ */
private static void updateSaveFile( private static void updateSaveFile(final QuestData newData, final String input) {
final QuestData newData, final String input) {
try { try {
DocumentBuilder builder = DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
DocumentBuilderFactory.newInstance().newDocumentBuilder();
InputSource is = new InputSource(); InputSource is = new InputSource();
is.setCharacterStream(new StringReader(input)); is.setCharacterStream(new StringReader(input));
Document document = builder.parse(is); Document document = builder.parse(is);
switch (newData.versionNumber) { 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 // version's changes get applied progressively
case 0: case 0:
// First beta release with new file format, // First beta release with new file format,
// inventory needs to be migrated // inventory needs to be migrated
newData.inventory = new QuestInventory(); newData.inventory = new QuestInventory();
NodeList elements = document.getElementsByTagName("estatesLevel"); NodeList elements = document.getElementsByTagName("estatesLevel");
newData.getInventory().setItemLevel("Estates", Integer.parseInt(elements.item(0).getTextContent())); newData.getInventory().setItemLevel("Estates", Integer.parseInt(elements.item(0).getTextContent()));
elements = document.getElementsByTagName("luckyCoinLevel"); elements = document.getElementsByTagName("luckyCoinLevel");
newData.getInventory().setItemLevel("Lucky Coin", Integer.parseInt(elements.item(0).getTextContent())); newData.getInventory().setItemLevel("Lucky Coin", Integer.parseInt(elements.item(0).getTextContent()));
elements = document.getElementsByTagName("sleightOfHandLevel"); elements = document.getElementsByTagName("sleightOfHandLevel");
newData.getInventory().setItemLevel("Sleight", Integer.parseInt(elements.item(0).getTextContent())); newData.getInventory().setItemLevel("Sleight", Integer.parseInt(elements.item(0).getTextContent()));
elements = document.getElementsByTagName("gearLevel"); elements = document.getElementsByTagName("gearLevel");
int gearLevel = Integer.parseInt(elements.item(0).getTextContent()); int gearLevel = Integer.parseInt(elements.item(0).getTextContent());
if (gearLevel >= 1) { if (gearLevel >= 1) {
newData.inventory.setItemLevel("Map", 1); newData.inventory.setItemLevel("Map", 1);
} }
if (gearLevel == 2) { if (gearLevel == 2) {
newData.inventory.setItemLevel("Zeppelin", 1); newData.inventory.setItemLevel("Zeppelin", 1);
} }
// fall-through // fall-through
case 1: case 1:
// nothing to do here, everything is managed by CardPoolToXml deserializer // nothing to do here, everything is managed by CardPoolToXml
break; // deserializer
default: break;
break; default:
break;
} }
//mark the QD as the latest version // mark the QD as the latest version
newData.versionNumber = QuestData.CURRENT_VERSION_NUMBER; newData.versionNumber = QuestData.CURRENT_VERSION_NUMBER;
} catch (Exception e) { } catch (Exception e) {
@@ -144,9 +159,12 @@ public class QuestDataIO {
} }
/** /**
* <p>saveData.</p> * <p>
* * saveData.
* @param qd a {@link forge.quest.data.QuestData} object. * </p>
*
* @param qd
* a {@link forge.quest.data.QuestData} object.
*/ */
public static void saveData(final QuestData qd) { public static void saveData(final QuestData qd) {
try { try {
@@ -161,10 +179,11 @@ public class QuestDataIO {
zout.flush(); zout.flush();
zout.close(); zout.close();
//BufferedOutputStream boutUnp = new BufferedOutputStream(new FileOutputStream(f + ".xml")); // BufferedOutputStream boutUnp = new BufferedOutputStream(new
//xStream.toXML(qd, boutUnp); // FileOutputStream(f + ".xml"));
//boutUnp.flush(); // xStream.toXML(qd, boutUnp);
//boutUnp.close(); // boutUnp.flush();
// boutUnp.close();
} catch (Exception ex) { } catch (Exception ex) {
ErrorViewer.showError(ex, "Error saving Quest Data."); 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. * Xstream subclass that ignores fields that are present in the save but not
* This one is intended to skip fields defined in Object class (but are there any fields?) * 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 { private static class IgnoringXStream extends XStream {
List<String> ignoredFields = new ArrayList<String>(); List<String> ignoredFields = new ArrayList<String>();
@@ -183,9 +203,7 @@ public class QuestDataIO {
protected MapperWrapper wrapMapper(MapperWrapper next) { protected MapperWrapper wrapMapper(MapperWrapper next) {
return new MapperWrapper(next) { return new MapperWrapper(next) {
@Override @Override
public boolean shouldSerializeMember( public boolean shouldSerializeMember(@SuppressWarnings("rawtypes") Class definedIn, String fieldName) {
@SuppressWarnings("rawtypes") Class definedIn,
String fieldName) {
if (definedIn == Object.class) { if (definedIn == Object.class) {
ignoredFields.add(fieldName); ignoredFields.add(fieldName);
return false; return false;
@@ -196,7 +214,6 @@ public class QuestDataIO {
} }
} }
private static class GameTypeToXml implements Converter { private static class GameTypeToXml implements Converter {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@Override @Override
@@ -214,9 +231,9 @@ public class QuestDataIO {
String value = reader.getValue(); String value = reader.getValue();
return GameType.smartValueOf(value); return GameType.smartValueOf(value);
} }
} }
private static class CardPoolToXml implements Converter { private static class CardPoolToXml implements Converter {
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
@Override @Override
@@ -224,40 +241,41 @@ public class QuestDataIO {
return clasz.equals(ItemPool.class); 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.startNode("card");
writer.addAttribute("c", cref.getName()); writer.addAttribute("c", cref.getName());
writer.addAttribute("s", cref.getSet()); writer.addAttribute("s", cref.getSet());
if (cref.isFoil()) { writer.addAttribute("foil", "1"); } if (cref.isFoil()) {
if (cref.getArtIndex() > 0) { writer.addAttribute("i", Integer.toString(cref.getArtIndex())); } writer.addAttribute("foil", "1");
}
if (cref.getArtIndex() > 0) {
writer.addAttribute("i", Integer.toString(cref.getArtIndex()));
}
writer.addAttribute("n", count.toString()); writer.addAttribute("n", count.toString());
writer.endNode(); writer.endNode();
} }
private void write(BoosterPack booster, Integer count, HierarchicalStreamWriter writer) private void write(BoosterPack booster, Integer count, HierarchicalStreamWriter writer) {
{
writer.startNode("booster"); writer.startNode("booster");
writer.addAttribute("s", booster.getSet()); writer.addAttribute("s", booster.getSet());
writer.addAttribute("n", count.toString()); writer.addAttribute("n", count.toString());
writer.endNode(); writer.endNode();
} }
@Override @Override
public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) { public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
ItemPool<InventoryItem> pool = (ItemPool<InventoryItem>) source; ItemPool<InventoryItem> pool = (ItemPool<InventoryItem>) source;
for (Entry<InventoryItem, Integer> e : pool) { for (Entry<InventoryItem, Integer> e : pool) {
InventoryItem item = e.getKey(); InventoryItem item = e.getKey();
Integer count = e.getValue(); Integer count = e.getValue();
if (item instanceof CardPrinted) { if (item instanceof CardPrinted) {
write((CardPrinted) item, count, writer); write((CardPrinted) item, count, writer);
} else if (item instanceof BoosterPack) { } else if (item instanceof BoosterPack) {
write((BoosterPack) item, count, writer); write((BoosterPack) item, count, writer);
} }
} }
} }
@Override @Override
@@ -269,7 +287,7 @@ public class QuestDataIO {
int cnt = StringUtils.isNumeric(sCnt) ? Integer.parseInt(sCnt) : 1; int cnt = StringUtils.isNumeric(sCnt) ? Integer.parseInt(sCnt) : 1;
String nodename = reader.getNodeName(); String nodename = reader.getNodeName();
if("string".equals(nodename)) { if ("string".equals(nodename)) {
result.add(CardDb.instance().getCard(reader.getValue())); result.add(CardDb.instance().getCard(reader.getValue()));
} else if ("card".equals(nodename)) { // new format } else if ("card".equals(nodename)) { // new format
result.add(readCardPrinted(reader), cnt); result.add(readCardPrinted(reader), cnt);
@@ -280,15 +298,13 @@ public class QuestDataIO {
} }
return result; return result;
} }
private BoosterPack readBooster(final HierarchicalStreamReader reader) private BoosterPack readBooster(final HierarchicalStreamReader reader) {
{
String set = reader.getAttribute("s"); String set = reader.getAttribute("s");
return new BoosterPack(set); return new BoosterPack(set);
} }
private CardPrinted readCardPrinted(final HierarchicalStreamReader reader) private CardPrinted readCardPrinted(final HierarchicalStreamReader reader) {
{
String name = reader.getAttribute("c"); String name = reader.getAttribute("c");
String set = reader.getAttribute("s"); String set = reader.getAttribute("s");
String sIndex = reader.getAttribute("i"); String sIndex = reader.getAttribute("i");

View File

@@ -7,39 +7,72 @@ import java.util.Map;
import forge.game.GameSummary; import forge.game.GameSummary;
/** /**
* <p>QuestMatchState class.</p> * <p>
* * QuestMatchState class.
* </p>
*
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class QuestMatchState { public class QuestMatchState {
/** The Constant GAMES_PER_MATCH. */
public static final int GAMES_PER_MATCH = 3; 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; public static final int MIN_GAMES_TO_WIN_MATCH = 2;
private List<GameSummary> gamesPlayed = new ArrayList<GameSummary>(); private List<GameSummary> gamesPlayed = new ArrayList<GameSummary>();
//ArrayList<GameSpecialConditions>
// ArrayList<GameSpecialConditions>
/**
* Adds the game played.
*
* @param completedGame
* the completed game
*/
public final void addGamePlayed(final GameSummary completedGame) { public final void addGamePlayed(final GameSummary completedGame) {
gamesPlayed.add(completedGame); gamesPlayed.add(completedGame);
} }
/**
* Gets the games played.
*
* @return the games played
*/
public final GameSummary[] getGamesPlayed() { public final GameSummary[] getGamesPlayed() {
return gamesPlayed.toArray(new GameSummary[gamesPlayed.size()]); return gamesPlayed.toArray(new GameSummary[gamesPlayed.size()]);
} }
/**
* Gets the games played count.
*
* @return the games played count
*/
public final int getGamesPlayedCount() { public final int getGamesPlayedCount() {
return gamesPlayed.size(); 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; int iLastGame = gamesPlayed.size() - 1;
return iLastGame >= 0 ? gamesPlayed.get(iLastGame).isWinner(playerName) : false; return iLastGame >= 0 ? gamesPlayed.get(iLastGame).isWinner(playerName) : false;
} }
/**
* Checks if is match over.
*
* @return true, if is match over
*/
public final boolean isMatchOver() { public final boolean isMatchOver() {
int totalGames = 0; int totalGames = 0;
@@ -51,8 +84,8 @@ public class QuestMatchState {
winsCount.put(winner, wins + 1); winsCount.put(winner, wins + 1);
totalGames++; totalGames++;
} }
int maxWins = 0; int maxWins = 0;
for (Integer win : winsCount.values()) { for (Integer win : winsCount.values()) {
maxWins = Math.max(maxWins, win); maxWins = Math.max(maxWins, win);
} }
@@ -60,18 +93,37 @@ public class QuestMatchState {
return maxWins >= MIN_GAMES_TO_WIN_MATCH || totalGames >= GAMES_PER_MATCH; 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) { public final int countGamesWonBy(String name) {
int wins = 0; int wins = 0;
for (GameSummary game : gamesPlayed) { for (GameSummary game : gamesPlayed) {
if (game.isWinner(name)) { wins++; } if (game.isWinner(name)) {
wins++;
}
} }
return 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) { public final boolean isMatchWonBy(String name) {
return countGamesWonBy(name) >= MIN_GAMES_TO_WIN_MATCH; return countGamesWonBy(name) >= MIN_GAMES_TO_WIN_MATCH;
} }
/**
* Reset.
*/
public final void reset() { public final void reset() {
gamesPlayed.clear(); gamesPlayed.clear();
} }

File diff suppressed because it is too large Load Diff

View File

@@ -1,31 +1,36 @@
package forge.quest.data; package forge.quest.data;
import java.util.List;
import forge.AllZone; import forge.AllZone;
import forge.Card; import forge.Card;
import forge.CardList; import forge.CardList;
import forge.CardUtil; import forge.CardUtil;
import forge.Constant; import forge.Constant;
import forge.Player; import forge.Player;
import forge.card.CardRarity;
import forge.card.BoosterUtils; import forge.card.BoosterUtils;
import forge.card.CardRarity;
import forge.item.CardPrinted; import forge.item.CardPrinted;
import forge.quest.gui.main.QuestChallenge; import forge.quest.gui.main.QuestChallenge;
import forge.quest.gui.main.QuestEvent; import forge.quest.gui.main.QuestEvent;
import java.util.List;
/** /**
* <p>QuestUtil class.</p> * <p>
* QuestUtil class.
* </p>
* MODEL - Static utility methods to help with minor tasks around Quest. * MODEL - Static utility methods to help with minor tasks around Quest.
* *
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class QuestUtil { public class QuestUtil {
/** /**
* <p>getComputerStartingCards.</p> * <p>
* * getComputerStartingCards.
* @param qd a {@link forge.quest.data.QuestData} object. * </p>
*
* @param qd
* a {@link forge.quest.data.QuestData} object.
* @return a {@link forge.CardList} object. * @return a {@link forge.CardList} object.
*/ */
public static CardList getComputerStartingCards(final QuestData qd) { public static CardList getComputerStartingCards(final QuestData qd) {
@@ -33,32 +38,39 @@ public class QuestUtil {
} }
/** /**
* <p>getComputerStartingCards.</p> * <p>
* getComputerStartingCards.
* </p>
* Returns new card instances of extra AI cards in play at start of event. * Returns new card instances of extra AI cards in play at start of event.
* *
* @param qd a {@link forge.quest.data.QuestData} object. * @param qd
* @param qe a {@link forge.quest.gui.main.QuestEvent} object. * a {@link forge.quest.data.QuestData} object.
* @param qe
* a {@link forge.quest.gui.main.QuestEvent} object.
* @return a {@link forge.CardList} 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(); CardList list = new CardList();
if(qe.getEventType().equals("challenge")) { if (qe.getEventType().equals("challenge")) {
List<String> extras = ((QuestChallenge)qe).getAIExtraCards(); List<String> extras = ((QuestChallenge) qe).getAIExtraCards();
for(String s : extras) { for (String s : extras) {
list.add(readExtraCard(s, AllZone.getComputerPlayer())); list.add(readExtraCard(s, AllZone.getComputerPlayer()));
} }
} }
return list; return list;
} }
/** /**
* <p>getHumanStartingCards.</p> * <p>
* getHumanStartingCards.
* </p>
* Returns list of current plant/pet configuration only. * 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. * @return a {@link forge.CardList} object.
*/ */
public static CardList getHumanStartingCards(final QuestData qd) { public static CardList getHumanStartingCards(final QuestData qd) {
@@ -76,119 +88,121 @@ public class QuestUtil {
} }
/** /**
* <p>getHumanStartingCards.</p> * <p>
* Returns new card instances of extra human cards, * getHumanStartingCards.
* including current plant/pet configuration, * </p>
* and cards in play at start of quest. * 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. * @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. * @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); CardList list = getHumanStartingCards(qd);
if(qe.getEventType().equals("challenge")) { if (qe.getEventType().equals("challenge")) {
List<String> extras = ((QuestChallenge)qe).getHumanExtraCards(); List<String> extras = ((QuestChallenge) qe).getHumanExtraCards();
for(String s : extras) { for (String s : extras) {
list.add(readExtraCard(s, AllZone.getHumanPlayer())); list.add(readExtraCard(s, AllZone.getHumanPlayer()));
} }
} }
return list; return list;
} }
/** /**
* <p>createToken.</p> * <p>
* createToken.
* </p>
* Creates a card instance for token defined by property string. * 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 * @return token Card
*/ */
public static Card createToken(String s) { public static Card createToken(final String s) {
String[] properties = s.split(";");; String[] properties = s.split(";");
Card c = new Card(); Card c = new Card();
c.setToken(true); c.setToken(true);
//c.setManaCost(properties[1]); // c.setManaCost(properties[1]);
c.addColor(properties[1]); c.addColor(properties[1]);
c.setBaseAttack(Integer.parseInt(properties[2])); c.setBaseAttack(Integer.parseInt(properties[2]));
c.setBaseDefense(Integer.parseInt(properties[3])); c.setBaseDefense(Integer.parseInt(properties[3]));
c.setName(properties[4]); c.setName(properties[4]);
c.setImageName( c.setImageName(properties[1] + " " + properties[2] + " " + properties[3] + " " + properties[4]);
properties[1]+" "+
properties[2]+" "+
properties[3]+" "+
properties[4]
);
int x = 5; int x = 5;
while(x != properties.length) { while (x != properties.length) {
c.addType(properties[x++]); c.addType(properties[x++]);
} }
return c; return c;
} }
/** /**
* <p>generateCardRewardList.</p> * <p>
* generateCardRewardList.
* </p>
* Takes a reward list string, parses, and returns list of cards rewarded. * 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 * @return CardList
*/ */
public static List<CardPrinted> generateCardRewardList(String s) { public static List<CardPrinted> generateCardRewardList(final String s) {
String[] temp = s.split(" "); String[] temp = s.split(" ");
int qty = Integer.parseInt(temp[0]); int qty = Integer.parseInt(temp[0]);
// Determine rarity // Determine rarity
CardRarity rar = CardRarity.Uncommon; 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; rar = CardRarity.Rare;
} }
// Determine color ("random" defaults to null color) // Determine color ("random" defaults to null color)
String col = null; String col = null;
if(temp[1].equalsIgnoreCase("black")) { if (temp[1].equalsIgnoreCase("black")) {
col = Constant.Color.Black; col = Constant.Color.Black;
} } else if (temp[1].equalsIgnoreCase("blue")) {
else if(temp[1].equalsIgnoreCase("blue")) {
col = Constant.Color.Blue; col = Constant.Color.Blue;
} } else if (temp[1].equalsIgnoreCase("colorless")) {
else if(temp[1].equalsIgnoreCase("colorless")) {
col = Constant.Color.Colorless; col = Constant.Color.Colorless;
} } else if (temp[1].equalsIgnoreCase("green")) {
else if(temp[1].equalsIgnoreCase("green")) {
col = Constant.Color.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?? col = "Multicolor"; // Note: No constant color for this??
} } else if (temp[1].equalsIgnoreCase("red")) {
else if(temp[1].equalsIgnoreCase("red")) {
col = Constant.Color.Red; col = Constant.Color.Red;
} } else if (temp[1].equalsIgnoreCase("white")) {
else if(temp[1].equalsIgnoreCase("white")) {
col = Constant.Color.White; col = Constant.Color.White;
} }
return BoosterUtils.generateCards(qty, rar, col); return BoosterUtils.generateCards(qty, rar, col);
} }
/** /**
* <p>readExtraCard.</p> * <p>
* readExtraCard.
* </p>
* Creates single card for a string read from unique event properties. * Creates single card for a string read from unique event properties.
* *
* @param name * @param name
* the name
* @param owner * @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 // Token card creation
Card tempcard; Card tempcard;
if(name.startsWith("TOKEN")) { if (name.startsWith("TOKEN")) {
tempcard = QuestUtil.createToken(name); tempcard = QuestUtil.createToken(name);
tempcard.addController(owner); tempcard.addController(owner);
tempcard.setOwner(owner); tempcard.setOwner(owner);
@@ -202,4 +216,4 @@ public class QuestUtil {
return tempcard; return tempcard;
} }
} //QuestUtil } // QuestUtil

View File

@@ -6,12 +6,11 @@ import java.util.Map.Entry;
import net.slightlymagic.braids.util.lambda.Lambda1; import net.slightlymagic.braids.util.lambda.Lambda1;
import net.slightlymagic.maxmtg.Predicate; import net.slightlymagic.maxmtg.Predicate;
import forge.MyRandom; import forge.MyRandom;
import forge.SetUtils; import forge.SetUtils;
import forge.card.BoosterGenerator; import forge.card.BoosterGenerator;
import forge.card.CardRarity;
import forge.card.BoosterUtils; import forge.card.BoosterUtils;
import forge.card.CardRarity;
import forge.card.CardSet; import forge.card.CardSet;
import forge.deck.Deck; import forge.deck.Deck;
import forge.item.BoosterPack; import forge.item.BoosterPack;
@@ -21,15 +20,34 @@ import forge.item.InventoryItem;
import forge.item.ItemPool; import forge.item.ItemPool;
import forge.item.ItemPoolView; import forge.item.ItemPoolView;
/** /**
* This is a helper class to execute operations on QuestData. * This is a helper class to execute operations on QuestData. It has been
* It has been created to decrease complexity of questData class * created to decrease complexity of questData class
*/ */
public final class QuestUtilCards { public final class QuestUtilCards {
private QuestData q; private QuestData q;
public QuestUtilCards(final QuestData qd) { q = qd; }
public void addBasicLands(ItemPool<InventoryItem> 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<InventoryItem> pool, final int nBasic, final int nSnow) {
CardDb db = CardDb.instance(); CardDb db = CardDb.instance();
pool.add(db.getCard("Forest", "M10"), nBasic); pool.add(db.getCard("Forest", "M10"), nBasic);
pool.add(db.getCard("Mountain", "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); pool.add(db.getCard("Snow-Covered Plains", "ICE"), nSnow);
} }
//adds 11 cards, to the current card pool // adds 11 cards, to the current card pool
//(I chose 11 cards instead of 15 in order to make things more challenging) // (I chose 11 cards instead of 15 in order to make things more challenging)
/** /**
* <p>addCards.</p> * <p>
* addCards.
* </p>
*
* @param fSets
* the f sets
* @return the array list
*/ */
public ArrayList<CardPrinted> addCards(final Predicate<CardPrinted> fSets) { public ArrayList<CardPrinted> addCards(final Predicate<CardPrinted> fSets) {
int nCommon = QuestPreferences.getNumCommon(); int nCommon = QuestPreferences.getNumCommon();
@@ -64,13 +88,25 @@ public final class QuestUtilCards {
return newCards; return newCards;
} }
/**
* Adds the all cards.
*
* @param newCards
* the new cards
*/
public void addAllCards(final Iterable<CardPrinted> newCards) { public void addAllCards(final Iterable<CardPrinted> newCards) {
for (CardPrinted card : newCards) { for (CardPrinted card : newCards) {
addSingleCard(card); 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); q.cardPool.add(card);
// register card into that list so that it would appear as a new one. // 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<CardPrinted> rarePredicate = CardPrinted.Predicates.Presets.isRareOrMythic; private static final Predicate<CardPrinted> rarePredicate = CardPrinted.Predicates.Presets.isRareOrMythic;
/**
* Adds the random rare.
*
* @return the card printed
*/
public CardPrinted addRandomRare() { public CardPrinted addRandomRare() {
CardPrinted card = rarePredicate.random(CardDb.instance().getAllCards()); CardPrinted card = rarePredicate.random(CardDb.instance().getAllCards());
addSingleCard(card); addSingleCard(card);
return card; return card;
} }
/**
* Adds the random rare.
*
* @param n
* the n
* @return the list
*/
public List<CardPrinted> addRandomRare(final int n) { public List<CardPrinted> addRandomRare(final int n) {
List<CardPrinted> newCards = rarePredicate.random(CardDb.instance().getAllCards(), n); List<CardPrinted> newCards = rarePredicate.random(CardDb.instance().getAllCards(), n);
addAllCards(newCards); addAllCards(newCards);
return newCards; return newCards;
} }
public void setupNewGameCardPool(final Predicate<CardPrinted> filter, final int idxDifficulty) /**
{ * Setup new game card pool.
*
* @param filter
* the filter
* @param idxDifficulty
* the idx difficulty
*/
public void setupNewGameCardPool(final Predicate<CardPrinted> filter, final int idxDifficulty) {
int nC = QuestPreferences.getStartingCommons(idxDifficulty); int nC = QuestPreferences.getStartingCommons(idxDifficulty);
int nU = QuestPreferences.getStartingUncommons(idxDifficulty); int nU = QuestPreferences.getStartingUncommons(idxDifficulty);
int nR = QuestPreferences.getStartingRares(idxDifficulty); int nR = QuestPreferences.getStartingRares(idxDifficulty);
@@ -98,6 +155,14 @@ public final class QuestUtilCards {
addAllCards(BoosterUtils.getQuestStarterDeck(filter, nC, nU, nR)); 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) { public void buyCard(final CardPrinted card, final int value) {
if (q.credits >= value) { if (q.credits >= value) {
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) { public void buyBooster(final BoosterPack booster, final int value) {
if (q.credits >= value) { if (q.credits >= value) {
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) { 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.cardPool.remove(card);
q.shopList.add(card); q.shopList.add(card);
@@ -127,10 +210,20 @@ public final class QuestUtilCards {
} }
} }
/**
* Clear shop list.
*/
public void clearShopList() { 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() { public double getSellMutliplier() {
double multi = 0.20 + (0.001 * q.getWin()); double multi = 0.20 + (0.001 * q.getWin());
if (multi > 0.6) { if (multi > 0.6) {
@@ -139,19 +232,34 @@ public final class QuestUtilCards {
int lvlEstates = q.isFantasy() ? q.inventory.getItemLevel("Estates") : 0; int lvlEstates = q.isFantasy() ? q.inventory.getItemLevel("Estates") : 0;
switch (lvlEstates) { switch (lvlEstates) {
case 1: multi += 0.01; break; case 1:
case 2: multi += 0.0175; break; multi += 0.01;
case 3: multi += 0.025; break; break;
default: break; case 2:
multi += 0.0175;
break;
case 3:
multi += 0.025;
break;
default:
break;
} }
return multi; return multi;
} }
/**
* Gets the sell price limit.
*
* @return the sell price limit
*/
public int getSellPriceLimit() { public int getSellPriceLimit() {
return q.getWin() <= 50 ? 1000 : Integer.MAX_VALUE; return q.getWin() <= 50 ? 1000 : Integer.MAX_VALUE;
} }
/**
* Generate cards in shop.
*/
public void generateCardsInShop() { public void generateCardsInShop() {
BoosterGenerator pack = new BoosterGenerator(CardDb.instance().getAllCards()); BoosterGenerator pack = new BoosterGenerator(CardDb.instance().getAllCards());
@@ -160,28 +268,41 @@ public final class QuestUtilCards {
int totalPacks = Math.min(levelPacks + winPacks, 6); int totalPacks = Math.min(levelPacks + winPacks, 6);
final Predicate<CardSet> filterExt = CardSet.Predicates.Presets.setsInExt; final Predicate<CardSet> filterExt = CardSet.Predicates.Presets.setsInExt;
final Predicate<CardSet> filterT2booster = Predicate.and(CardSet.Predicates.canMakeBooster, CardSet.Predicates.Presets.setsInT2); final Predicate<CardSet> filterT2booster = Predicate.and(CardSet.Predicates.canMakeBooster,
final Predicate<CardSet> filterExtButT2 = Predicate.and(CardSet.Predicates.canMakeBooster, Predicate.and(filterExt, Predicate.not(CardSet.Predicates.Presets.setsInT2))); CardSet.Predicates.Presets.setsInT2);
final Predicate<CardSet> filterNotExt = Predicate.and(CardSet.Predicates.canMakeBooster, Predicate.not(filterExt)); final Predicate<CardSet> filterExtButT2 = Predicate.and(CardSet.Predicates.canMakeBooster,
Predicate.and(filterExt, Predicate.not(CardSet.Predicates.Presets.setsInT2)));
final Predicate<CardSet> filterNotExt = Predicate.and(CardSet.Predicates.canMakeBooster,
Predicate.not(filterExt));
q.shopList.clear(); q.shopList.clear();
for (int i = 0; i < totalPacks; i++) { for (int i = 0; i < totalPacks; i++) {
q.shopList.addAllCards(pack.getBoosterPack(7, 3, 1, 0, 0, 0, 0, 0, 0)); q.shopList.addAllCards(pack.getBoosterPack(7, 3, 1, 0, 0, 0, 0, 0, 0));
// add some boosters // add some boosters
int rollD100 = MyRandom.random.nextInt(100); int rollD100 = MyRandom.random.nextInt(100);
Predicate<CardSet> filter = rollD100 < 40 ? filterT2booster : (rollD100 < 75 ? filterExtButT2 : filterNotExt); Predicate<CardSet> filter = rollD100 < 40 ? filterT2booster : (rollD100 < 75 ? filterExtButT2
: filterNotExt);
q.shopList.addAllCards(filter.random(SetUtils.getAllSets(), 1, BoosterPack.fnFromSet)); q.shopList.addAllCards(filter.random(SetUtils.getAllSets(), 1, BoosterPack.fnFromSet));
} }
addBasicLands(q.shopList, 10, 5); addBasicLands(q.shopList, 10, 5);
} }
/**
* Gets the cardpool.
*
* @return the cardpool
*/
public ItemPool<InventoryItem> getCardpool() { public ItemPool<InventoryItem> getCardpool() {
return q.cardPool; return q.cardPool;
} }
/**
* Gets the shop list.
*
* @return the shop list
*/
public ItemPoolView<InventoryItem> getShopList() { public ItemPoolView<InventoryItem> getShopList() {
if (q.shopList.isEmpty()) { if (q.shopList.isEmpty()) {
generateCardsInShop(); generateCardsInShop();
@@ -189,26 +310,41 @@ public final class QuestUtilCards {
return q.shopList; return q.shopList;
} }
/**
* Gets the new cards.
*
* @return the new cards
*/
public ItemPoolView<InventoryItem> getNewCards() { public ItemPoolView<InventoryItem> getNewCards() {
return q.newCardList; return q.newCardList;
} }
/**
* Reset new list.
*/
public void resetNewList() { public void resetNewList() {
q.newCardList.clear(); q.newCardList.clear();
} }
// These functions provide a way to sort and compare cards in a table according to their new-ness // These functions provide a way to sort and compare cards in a table
// It might be a good idea to store them in a base class for both quest-mode deck editors // 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 // Maybe we should consider doing so later
/** The fn new compare. */
@SuppressWarnings("rawtypes") @SuppressWarnings("rawtypes")
public final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnNewCompare = public final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnNewCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
new Lambda1<Comparable, Entry<InventoryItem, Integer>>() { @Override @Override
public Comparable apply(final Entry<InventoryItem, Integer> from) { public Comparable apply(final Entry<InventoryItem, Integer> from) {
return q.newCardList.contains(from.getKey()) ? Integer.valueOf(1) : Integer.valueOf(0); return q.newCardList.contains(from.getKey()) ? Integer.valueOf(1) : Integer.valueOf(0);
} }; }
public final Lambda1<Object, Entry<InventoryItem, Integer>> fnNewGet = };
new Lambda1<Object, Entry<InventoryItem, Integer>>() { @Override
public Object apply(final Entry<InventoryItem, Integer> from) { /** The fn new get. */
return q.newCardList.contains(from.getKey()) ? "NEW" : ""; public final Lambda1<Object, Entry<InventoryItem, Integer>> fnNewGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
} }; @Override
public Object apply(final Entry<InventoryItem, Integer> from) {
return q.newCardList.contains(from.getKey()) ? "NEW" : "";
}
};
} }

View File

@@ -1,13 +1,5 @@
package forge.quest.data; 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.BufferedReader;
import java.io.File; import java.io.File;
import java.io.FileReader; import java.io.FileReader;
@@ -15,43 +7,58 @@ import java.util.HashMap;
import java.util.Map; import java.util.Map;
import java.util.Random; import java.util.Random;
import com.esotericsoftware.minlog.Log;
import forge.MyRandom;
import forge.error.ErrorViewer;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
/** /**
* <p>ReadPriceList class.</p> * <p>
* * ReadPriceList class.
* </p>
*
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class ReadPriceList implements NewConstants { public class ReadPriceList implements NewConstants {
/** Constant <code>comment="//"</code> */ /** Constant <code>comment="//"</code>. */
final private static String comment = "//"; private static final String comment = "//";
private HashMap<String, Integer> priceMap; private HashMap<String, Integer> priceMap;
/** /**
* <p>Constructor for ReadPriceList.</p> * <p>
* Constructor for ReadPriceList.
* </p>
*/ */
public ReadPriceList() { public ReadPriceList() {
setup(); setup();
} }
/** /**
* <p>setup.</p> * <p>
* setup.
* </p>
*/ */
private void setup() { private void setup() {
priceMap = readFile(ForgeProps.getFile(QUEST.PRICE)); priceMap = readFile(ForgeProps.getFile(QUEST.PRICE));
priceMap.putAll(readFile(ForgeProps.getFile(QUEST.BOOSTER_PRICE))); priceMap.putAll(readFile(ForgeProps.getFile(QUEST.BOOSTER_PRICE)));
}//setup() } // setup()
/** /**
* <p>readFile.</p> * <p>
* * readFile.
* @param file a {@link java.io.File} object. * </p>
*
* @param file
* a {@link java.io.File} object.
* @return a {@link java.util.HashMap} object. * @return a {@link java.util.HashMap} object.
*/ */
private HashMap<String, Integer> readFile(File file) { private HashMap<String, Integer> readFile(final File file) {
BufferedReader in; BufferedReader in;
HashMap<String, Integer> map = new HashMap<String, Integer>(); HashMap<String, Integer> map = new HashMap<String, Integer>();
Random r = MyRandom.random; Random r = MyRandom.random;
@@ -60,30 +67,38 @@ public class ReadPriceList implements NewConstants {
in = new BufferedReader(new FileReader(file)); in = new BufferedReader(new FileReader(file));
String line = in.readLine(); 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)) { while (line != null && (line.trim().length() != 0)) {
if (!line.startsWith(comment)) { if (!line.startsWith(comment)) {
String s[] = line.split("="); String[] s = line.split("=");
String name = s[0].trim(); String name = s[0].trim();
String price = s[1].trim(); String price = s[1].trim();
//System.out.println("Name: " + name + ", Price: " + price); // System.out.println("Name: " + name + ", Price: " +
// price);
try { try {
int val = Integer.parseInt(price.trim()); int val = Integer.parseInt(price.trim());
if (!(name.equals("Plains") || name.equals("Island") || name.equals("Swamp") || name.equals("Mountain") || name.equals("Forest") || if (!(name.equals("Plains") || name.equals("Island") || name.equals("Swamp")
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"))) { || 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; float ff = 0;
if (r.nextInt(100) < 90) // +/- 10% if (r.nextInt(100) < 90) {
ff = (float) r.nextInt(10) * (float) .01; ff = (float) r.nextInt(10) * (float) .01;
else // +/- 50% } else {
// +/- 50%
ff = (float) r.nextInt(50) * (float) .01; 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)); val = (int) ((float) val * ((float) 1 - ff));
else // +ff% } else {
// +ff%
val = (int) ((float) val * ((float) 1 + ff)); val = (int) ((float) val * ((float) 1 + ff));
}
} }
map.put(name, val); map.put(name, val);
@@ -92,7 +107,7 @@ public class ReadPriceList implements NewConstants {
} }
} }
line = in.readLine(); line = in.readLine();
}//if } // if
} catch (Exception ex) { } catch (Exception ex) {
ErrorViewer.showError(ex); ErrorViewer.showError(ex);
@@ -100,14 +115,16 @@ public class ReadPriceList implements NewConstants {
} }
return map; return map;
}//readFile() } // readFile()
/** /**
* <p>getPriceList.</p> * <p>
* * getPriceList.
* </p>
*
* @return a {@link java.util.Map} object. * @return a {@link java.util.Map} object.
*/ */
public Map<String, Integer> getPriceList() { public final Map<String, Integer> getPriceList() {
return priceMap; return priceMap;
} }
} }

View File

@@ -1,26 +1,42 @@
package forge.quest.data.bazaar; package forge.quest.data.bazaar;
/** /**
* <p>QuestStallDefinition class.</p> * <p>
* * QuestStallDefinition class.
* </p>
*
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class QuestStallDefinition { public class QuestStallDefinition {
/** The name. */
public String name; public String name;
/** The display name. */
public String displayName; public String displayName;
/** The icon name. */
public String iconName; public String iconName;
/** The fluff. */
public String fluff; public String fluff;
/** /**
* <p>Constructor for QuestStallDefinition.</p> * <p>
* * Constructor for QuestStallDefinition.
* @param name a {@link java.lang.String} object. * </p>
* @param displayName a {@link java.lang.String} object. *
* @param fluff a {@link java.lang.String} object. * @param name
* @param iconName a {@link java.lang.String} object. * 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.name = name;
this.displayName = displayName; this.displayName = displayName;
this.fluff = fluff; this.fluff = fluff;

View File

@@ -1,63 +1,60 @@
package forge.quest.data.bazaar; 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 forge.AllZone;
import java.util.*;
/** /**
* <p>QuestStallManager class.</p> * <p>
* * QuestStallManager class.
* </p>
*
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class QuestStallManager { public class QuestStallManager {
/** Constant <code>stalls</code> */ /** Constant <code>stalls</code>. */
static Map<String, QuestStallDefinition> stalls; static Map<String, QuestStallDefinition> stalls;
/** Constant <code>items</code> */ /** Constant <code>items</code>. */
static Map<String, SortedSet<QuestStallPurchasable>> items; static Map<String, SortedSet<QuestStallPurchasable>> items;
/** /**
* <p>buildStalls.</p> * <p>
* buildStalls.
* </p>
*/ */
public static void buildStalls() { public static void buildStalls() {
stalls = new HashMap<String, QuestStallDefinition>(); stalls = new HashMap<String, QuestStallDefinition>();
stalls.put(ALCHEMIST, stalls.put(ALCHEMIST, new QuestStallDefinition(ALCHEMIST, "Alchemist",
new QuestStallDefinition(ALCHEMIST, "The walls of this alchemist's stall are covered with shelves with potions, oils, "
"Alchemist", + "powders, poultices and elixirs, each meticulously labeled.", "BottlesIconSmall.png"));
"The walls of this alchemist's stall are covered with shelves with potions, oils, " + stalls.put(BANKER, new QuestStallDefinition(BANKER, "Banker",
"powders, poultices and elixirs, each meticulously labeled.", "A large book large enough to be seen from the outside rests on the Banker's desk.",
"BottlesIconSmall.png")); "CoinIconSmall.png"));
stalls.put(BANKER, stalls.put(BOOKSTORE, new QuestStallDefinition(BOOKSTORE, "Bookstore",
new QuestStallDefinition(BANKER, "Tomes of different sizes are stacked in man-high towers.", "BookIconSmall.png"));
"Banker", stalls.put(GEAR, new QuestStallDefinition(GEAR, "Adventuring Gear",
"A large book large enough to be seen from the outside rests on the Banker's desk.", "This adventurer's market has a tool for every need ... or so the plaque on the wall claims.",
"CoinIconSmall.png")); "GearIconSmall.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, stalls.put(NURSERY,
new QuestStallDefinition(NURSERY, new QuestStallDefinition(NURSERY, "Nursery",
"Nursery",
"The smells of the one hundred and one different plants forms a unique fragrance.", "The smells of the one hundred and one different plants forms a unique fragrance.",
"LeafIconSmall.png")); "LeafIconSmall.png"));
stalls.put(PET_SHOP, stalls.put(PET_SHOP, new QuestStallDefinition(PET_SHOP, "Pet Shop",
new QuestStallDefinition(PET_SHOP, "This large stall echoes with a multitude of animal noises.", "FoxIconSmall.png"));
"Pet Shop",
"This large stall echoes with a multitude of animal noises.",
"FoxIconSmall.png"));
} }
/** /**
* <p>getStallNames.</p> * <p>
* * getStallNames.
* </p>
*
* @return a {@link java.util.List} object. * @return a {@link java.util.List} object.
*/ */
public static List<String> getStallNames() { public static List<String> getStallNames() {
@@ -72,12 +69,15 @@ public class QuestStallManager {
} }
/** /**
* <p>getStall.</p> * <p>
* * getStall.
* @param stallName a {@link java.lang.String} object. * </p>
*
* @param stallName
* a {@link java.lang.String} object.
* @return a {@link forge.quest.data.bazaar.QuestStallDefinition} 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) { if (stalls == null) {
buildStalls(); buildStalls();
} }
@@ -86,7 +86,9 @@ public class QuestStallManager {
} }
/** /**
* <p>buildItems.</p> * <p>
* buildItems.
* </p>
*/ */
public static void buildItems() { public static void buildItems() {
SortedSet<QuestStallPurchasable> itemSet = new TreeSet<QuestStallPurchasable>(); SortedSet<QuestStallPurchasable> itemSet = new TreeSet<QuestStallPurchasable>();
@@ -107,9 +109,12 @@ public class QuestStallManager {
} }
/** /**
* <p>Getter for the field <code>items</code>.</p> * <p>
* * Getter for the field <code>items</code>.
* @param stallName a {@link java.lang.String} object. * </p>
*
* @param stallName
* a {@link java.lang.String} object.
* @return a {@link java.util.List} object. * @return a {@link java.util.List} object.
*/ */
public static List<QuestStallPurchasable> getItems(String stallName) { public static List<QuestStallPurchasable> getItems(String stallName) {
@@ -127,17 +132,22 @@ public class QuestStallManager {
return ret; return ret;
} }
/** Constant <code>ALCHEMIST="Alchemist"</code> */ /** Constant <code>ALCHEMIST="Alchemist"</code>. */
public static final String ALCHEMIST = "Alchemist"; public static final String ALCHEMIST = "Alchemist";
/** Constant <code>BANKER="Banker"</code> */
/** Constant <code>BANKER="Banker"</code>. */
public static final String BANKER = "Banker"; public static final String BANKER = "Banker";
/** Constant <code>BOOKSTORE="Bookstore"</code> */
/** Constant <code>BOOKSTORE="Bookstore"</code>. */
public static final String BOOKSTORE = "Bookstore"; public static final String BOOKSTORE = "Bookstore";
/** Constant <code>GEAR="Gear"</code> */
/** Constant <code>GEAR="Gear"</code>. */
public static final String GEAR = "Gear"; public static final String GEAR = "Gear";
/** Constant <code>NURSERY="Nursery"</code> */
/** Constant <code>NURSERY="Nursery"</code>. */
public static final String NURSERY = "Nursery"; public static final String NURSERY = "Nursery";
/** Constant <code>PET_SHOP="Pet Shop"</code> */
/** Constant <code>PET_SHOP="Pet Shop"</code>. */
public static final String PET_SHOP = "Pet Shop"; public static final String PET_SHOP = "Pet Shop";
} }

View File

@@ -1,57 +1,68 @@
package forge.quest.data.bazaar; 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 * @author Forge
* @version $Id$ * @version $Id$
*/ */
public interface QuestStallPurchasable extends Comparable<Object> { public interface QuestStallPurchasable extends Comparable<Object> {
/** /**
* <p>getPurchaseName.</p> * <p>
* * getPurchaseName.
* </p>
*
* @return The Name of the item * @return The Name of the item
*/ */
public String getPurchaseName(); String getPurchaseName();
/** /**
* <p>getPurchaseDescription.</p> * <p>
* * getPurchaseDescription.
* </p>
*
* @return an HTML formatted item description * @return an HTML formatted item description
*/ */
public String getPurchaseDescription(); String getPurchaseDescription();
/** /**
* <p>getImageName.</p> * <p>
* * getImageName.
* </p>
*
* @return the name of the image that is displayed in the bazaar * @return the name of the image that is displayed in the bazaar
*/ */
public String getImageName(); String getImageName();
/** /**
* <p>getPrice.</p> * <p>
* * getPrice.
* </p>
*
* @return the cost of the item in credits * @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 <code>true</code> if the item can be displayed in a store * @return <code>true</code> if the item can be displayed in a store
* <code>false</code> if the item should not be displayed in store since, for example, prerequisites are not met * <code>false</code> 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();
/** /**
* <p>getStallName.</p> * <p>
* * getStallName.
* </p>
*
* @return the name of the stall form which this item can be purchased * @return the name of the stall form which this item can be purchased
*/ */
public String getStallName(); String getStallName();
} }

View File

@@ -1,2 +1,2 @@
/** Forge Card Game */ /** Forge Card Game. */
package forge.quest.data.bazaar; package forge.quest.data.bazaar;

View File

@@ -1,18 +1,29 @@
package forge.quest.data.item; 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;
/** /**
* <p>QuestInventory class.</p> * <p>
* * QuestInventory class.
* </p>
*
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class QuestInventory { public class QuestInventory {
/** The inventory. */
Map<String, QuestItemAbstract> inventory = new HashMap<String, QuestItemAbstract>(); Map<String, QuestItemAbstract> inventory = new HashMap<String, QuestItemAbstract>();
/** /**
* <p>Constructor for QuestInventory.</p> * <p>
* Constructor for QuestInventory.
* </p>
*/ */
public QuestInventory() { public QuestInventory() {
Set<QuestItemAbstract> allItems = getAllItems(); Set<QuestItemAbstract> allItems = getAllItems();
@@ -22,31 +33,40 @@ public class QuestInventory {
} }
/** /**
* <p>hasItem.</p> * <p>
* * hasItem.
* @param itemName a {@link java.lang.String} object. * </p>
*
* @param itemName
* a {@link java.lang.String} object.
* @return a boolean. * @return a boolean.
*/ */
public boolean hasItem(String itemName) { public final boolean hasItem(final String itemName) {
return inventory.containsKey(itemName) && inventory.get(itemName).getLevel() > 0; return inventory.containsKey(itemName) && inventory.get(itemName).getLevel() > 0;
} }
/** /**
* <p>addItem.</p> * <p>
* * addItem.
* @param item a {@link forge.quest.data.item.QuestItemAbstract} object. * </p>
*
* @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); inventory.put(item.getName(), item);
} }
/** /**
* <p>getItemLevel.</p> * <p>
* * getItemLevel.
* @param itemName a {@link java.lang.String} object. * </p>
*
* @param itemName
* a {@link java.lang.String} object.
* @return a int. * @return a int.
*/ */
public int getItemLevel(String itemName) { public final int getItemLevel(final String itemName) {
QuestItemAbstract item = inventory.get(itemName); QuestItemAbstract item = inventory.get(itemName);
if (item == null) { if (item == null) {
return 0; return 0;
@@ -55,19 +75,24 @@ public class QuestInventory {
} }
/** /**
* <p>setItemLevel.</p> * <p>
* * setItemLevel.
* @param itemName a {@link java.lang.String} object. * </p>
* @param level a int. *
* @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); inventory.get(itemName).setLevel(level);
} }
/** /**
* <p>getAllItems.</p> * <p>
* * getAllItems.
* </p>
*
* @return a {@link java.util.Set} object. * @return a {@link java.util.Set} object.
*/ */
private static Set<QuestItemAbstract> getAllItems() { private static Set<QuestItemAbstract> getAllItems() {
@@ -83,10 +108,12 @@ public class QuestInventory {
return set; return set;
} }
//Magic to support added pet types when reading saves. // Magic to support added pet types when reading saves.
/** /**
* <p>readResolve.</p> * <p>
* * readResolve.
* </p>
*
* @return a {@link java.lang.Object} object. * @return a {@link java.lang.Object} object.
*/ */
private Object readResolve() { private Object readResolve() {
@@ -98,10 +125,11 @@ public class QuestInventory {
return this; return this;
} }
/** /**
* <p>getItems.</p> * <p>
* * getItems.
* </p>
*
* @return a {@link java.util.Collection} object. * @return a {@link java.util.Collection} object.
*/ */
public Collection<QuestItemAbstract> getItems() { public Collection<QuestItemAbstract> getItems() {
@@ -109,9 +137,12 @@ public class QuestInventory {
} }
/** /**
* <p>getItem.</p> * <p>
* * getItem.
* @param itemName a {@link java.lang.String} object. * </p>
*
* @param itemName
* a {@link java.lang.String} object.
* @return a {@link forge.quest.data.item.QuestItemAbstract} object. * @return a {@link forge.quest.data.item.QuestItemAbstract} object.
*/ */
public QuestItemAbstract getItem(String itemName) { public QuestItemAbstract getItem(String itemName) {

View File

@@ -4,8 +4,10 @@ import forge.AllZone;
import forge.quest.data.bazaar.QuestStallPurchasable; import forge.quest.data.bazaar.QuestStallPurchasable;
/** /**
* <p>Abstract QuestItemAbstract class.</p> * <p>
* * Abstract QuestItemAbstract class.
* </p>
*
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
@@ -15,34 +17,42 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
private String shopName; private String shopName;
private int maxLevel = 1; private int maxLevel = 1;
/** /**
* <p>Constructor for QuestItemAbstract.</p> * <p>
* * Constructor for QuestItemAbstract.
* @param name a {@link java.lang.String} object. * </p>
* @param shopName a {@link java.lang.String} object. *
* @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.name = name;
this.shopName = shopName; this.shopName = shopName;
} }
/** /**
* <p>Constructor for QuestItemAbstract.</p> * <p>
* * Constructor for QuestItemAbstract.
* @param name a {@link java.lang.String} object. * </p>
* @param shopName a {@link java.lang.String} object. *
* @param maxLevel a int. * @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.name = name;
this.shopName = shopName; this.shopName = shopName;
this.maxLevel = maxLevel; 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. * @return a {@link java.lang.String} object.
*/ */
public final String getName() { 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. * @return a {@link java.lang.String} object.
*/ */
public String getPurchaseName() { public String getPurchaseName() {
@@ -59,15 +69,16 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
} }
/** /**
* <p>getStallName.</p> * <p>
* * getStallName.
* </p>
*
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public String getStallName() { public final String getStallName() {
return shopName; return shopName;
} }
/** /**
* This method will be invoked when an item is bought in a shop. * 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); AllZone.getQuestData().getInventory().setItemLevel(name, currentLevel + 1);
} }
/** /**
* <p>isAvailableForPurchase.</p> * <p>
* * isAvailableForPurchase.
* </p>
*
* @return a boolean. * @return a boolean.
*/ */
public boolean isAvailableForPurchase() { public boolean isAvailableForPurchase() {
@@ -87,64 +99,79 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
} }
/** /**
* <p>Getter for the field <code>level</code>.</p> * <p>
* * Getter for the field <code>level</code>.
* </p>
*
* @return a int. * @return a int.
*/ */
public int getLevel() { public final int getLevel() {
return level; return level;
} }
/** /**
* <p>Setter for the field <code>level</code>.</p> * <p>
* * Setter for the field <code>level</code>.
* @param level a int. * </p>
*
* @param level
* a int.
*/ */
public void setLevel(int level) { public final void setLevel(final int level) {
this.level = level; this.level = level;
} }
/** /**
* <p>Getter for the field <code>maxLevel</code>.</p> * <p>
* * Getter for the field <code>maxLevel</code>.
* </p>
*
* @return a int. * @return a int.
*/ */
public int getMaxLevel() { public final int getMaxLevel() {
return maxLevel; return maxLevel;
} }
/** /**
* <p>isLeveledItem.</p> * <p>
* * isLeveledItem.
* </p>
*
* @return a boolean. * @return a boolean.
*/ */
public boolean isLeveledItem() { public final boolean isLeveledItem() {
return maxLevel == 1; return maxLevel == 1;
} }
/** /**
* <p>getPurchaseDescription.</p> * <p>
* * getPurchaseDescription.
* </p>
*
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public abstract String getPurchaseDescription(); public abstract String getPurchaseDescription();
/** /**
* <p>getImageName.</p> * <p>
* * getImageName.
* </p>
*
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public abstract String getImageName(); public abstract String getImageName();
/** /**
* <p>getPrice.</p> * <p>
* * getPrice.
* </p>
*
* @return a int. * @return a int.
*/ */
public abstract int getPrice(); public abstract int getPrice();
/** {@inheritDoc} */ /** {@inheritDoc} */
public int compareTo(Object o) { public final int compareTo(final Object o) {
QuestStallPurchasable q = (QuestStallPurchasable) o; QuestStallPurchasable q = (QuestStallPurchasable) o;
return this.getPurchaseName().compareTo(q.getPurchaseName()); return this.getPurchaseName().compareTo(q.getPurchaseName());
} }

View File

@@ -4,15 +4,17 @@ import forge.AllZone;
import forge.quest.data.bazaar.QuestStallManager; import forge.quest.data.bazaar.QuestStallManager;
/** /**
* This item has special coding because of the * This item has special coding.
* *
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class QuestItemElixir extends QuestItemAbstract { public class QuestItemElixir extends QuestItemAbstract {
/** /**
* <p>Constructor for QuestItemElixir.</p> * <p>
* Constructor for QuestItemElixir.
* </p>
*/ */
QuestItemElixir() { QuestItemElixir() {
super("Elixir of Life", QuestStallManager.ALCHEMIST, 15); super("Elixir of Life", QuestStallManager.ALCHEMIST, 15);
@@ -20,19 +22,19 @@ public class QuestItemElixir extends QuestItemAbstract {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getPurchaseDescription() { public final String getPurchaseDescription() {
return "Gives +1 to maximum life<br>Current Life: " + AllZone.getQuestData().getLife(); return "Gives +1 to maximum life<br>Current Life: " + AllZone.getQuestData().getLife();
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getImageName() { public final String getImageName() {
return "ElixirIcon.png"; return "ElixirIcon.png";
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public int getPrice() { public final int getPrice() {
if (getLevel() < 5) { if (getLevel() < 5) {
return 250; return 250;
} else if (getLevel() < 10) { } else if (getLevel() < 10) {
@@ -44,7 +46,7 @@ public class QuestItemElixir extends QuestItemAbstract {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public void onPurchase() { public final void onPurchase() {
AllZone.getQuestData().addLife(1); AllZone.getQuestData().addLife(1);
} }

View File

@@ -3,14 +3,18 @@ package forge.quest.data.item;
import forge.quest.data.bazaar.QuestStallManager; import forge.quest.data.bazaar.QuestStallManager;
/** /**
* <p>QuestItemEstates class.</p> * <p>
* * QuestItemEstates class.
* </p>
*
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class QuestItemEstates extends QuestItemAbstract { public class QuestItemEstates extends QuestItemAbstract {
/** /**
* <p>Constructor for QuestItemEstates.</p> * <p>
* Constructor for QuestItemEstates.
* </p>
*/ */
QuestItemEstates() { QuestItemEstates() {
super("Estates", QuestStallManager.BANKER, 3); super("Estates", QuestStallManager.BANKER, 3);
@@ -18,20 +22,20 @@ public class QuestItemEstates extends QuestItemAbstract {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getPurchaseDescription() { public final String getPurchaseDescription() {
return String.format("Gives a bonus of <b>%d%%</b> to match winnings.<br>" + return String.format("Gives a bonus of <b>%d%%</b> to match winnings.<br>"
"Improves sell percentage by <b>%.2f%%</b>.", (10 + getLevel() * 5), (1 + getLevel() * 0.75)); + "Improves sell percentage by <b>%.2f%%</b>.", (10 + getLevel() * 5), (1 + getLevel() * 0.75));
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getImageName() { public final String getImageName() {
return "GoldIconLarge.png"; return "GoldIconLarge.png";
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public int getPrice() { public final int getPrice() {
if (getLevel() == 0) { if (getLevel() == 0) {
return 500; return 500;
} else if (getLevel() == 1) { } else if (getLevel() == 1) {
@@ -41,5 +45,4 @@ public class QuestItemEstates extends QuestItemAbstract {
} }
} }
} }

View File

@@ -3,14 +3,18 @@ package forge.quest.data.item;
import forge.quest.data.bazaar.QuestStallManager; import forge.quest.data.bazaar.QuestStallManager;
/** /**
* <p>QuestItemLuckyCoin class.</p> * <p>
* * QuestItemLuckyCoin class.
* </p>
*
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class QuestItemLuckyCoin extends QuestItemAbstract { public class QuestItemLuckyCoin extends QuestItemAbstract {
/** /**
* <p>Constructor for QuestItemLuckyCoin.</p> * <p>
* Constructor for QuestItemLuckyCoin.
* </p>
*/ */
QuestItemLuckyCoin() { QuestItemLuckyCoin() {
super("Lucky Coin", QuestStallManager.BANKER); super("Lucky Coin", QuestStallManager.BANKER);
@@ -18,22 +22,21 @@ public class QuestItemLuckyCoin extends QuestItemAbstract {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getPurchaseDescription() { public final String getPurchaseDescription() {
return "This coin is believed to give good luck to its owner.<br>" + return "This coin is believed to give good luck to its owner.<br>"
"Improves the chance of getting a random <br>rare after each match by <b>15%</b>."; + "Improves the chance of getting a random <br>rare after each match by <b>15%</b>.";
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getImageName() { public final String getImageName() {
return "CoinIcon.png"; return "CoinIcon.png";
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public int getPrice() { public final int getPrice() {
return 2000; return 2000;
} }
} }

View File

@@ -3,14 +3,18 @@ package forge.quest.data.item;
import forge.quest.data.bazaar.QuestStallManager; import forge.quest.data.bazaar.QuestStallManager;
/** /**
* <p>QuestItemMap class.</p> * <p>
* * QuestItemMap class.
* </p>
*
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class QuestItemMap extends QuestItemAbstract { public class QuestItemMap extends QuestItemAbstract {
/** /**
* <p>Constructor for QuestItemMap.</p> * <p>
* Constructor for QuestItemMap.
* </p>
*/ */
QuestItemMap() { QuestItemMap() {
super("Map", QuestStallManager.GEAR); super("Map", QuestStallManager.GEAR);
@@ -18,26 +22,26 @@ public class QuestItemMap extends QuestItemAbstract {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getPurchaseName() { public final String getPurchaseName() {
return "Adventurer's Map"; return "Adventurer's Map";
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getPurchaseDescription() { public final String getPurchaseDescription() {
return "These ancient charts should facilitate navigation during your travels significantly.<br>" + return "These ancient charts should facilitate navigation during your travels significantly.<br>"
"<em>Effect: </em>Quest assignments become available more frequently."; + "<em>Effect: </em>Quest assignments become available more frequently.";
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getImageName() { public final String getImageName() {
return "MapIconLarge.png"; return "MapIconLarge.png";
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public int getPrice() { public final int getPrice() {
return 2000; return 2000;
} }
} }

View File

@@ -3,14 +3,18 @@ package forge.quest.data.item;
import forge.quest.data.bazaar.QuestStallManager; import forge.quest.data.bazaar.QuestStallManager;
/** /**
* <p>QuestItemSleight class.</p> * <p>
* * QuestItemSleight class.
* </p>
*
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class QuestItemSleight extends QuestItemAbstract { public class QuestItemSleight extends QuestItemAbstract {
/** /**
* <p>Constructor for QuestItemSleight.</p> * <p>
* Constructor for QuestItemSleight.
* </p>
*/ */
QuestItemSleight() { QuestItemSleight() {
super("Sleight", QuestStallManager.BOOKSTORE); super("Sleight", QuestStallManager.BOOKSTORE);
@@ -19,26 +23,26 @@ public class QuestItemSleight extends QuestItemAbstract {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getImageName() { public final String getImageName() {
return "BookIcon.png"; return "BookIcon.png";
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public int getPrice() { public final int getPrice() {
return 2000; return 2000;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getPurchaseName() { public final String getPurchaseName() {
return "Sleight of Hand Vol. I"; return "Sleight of Hand Vol. I";
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getPurchaseDescription() { public final String getPurchaseDescription() {
return "These volumes explain how to perform the most difficult of sleights.<br>" + return "These volumes explain how to perform the most difficult of sleights.<br>"
"<em>Effect: </em>Your first mulligan is <b>free</b>"; + "<em>Effect: </em>Your first mulligan is <b>free</b>";
} }
} }

View File

@@ -3,17 +3,24 @@ package forge.quest.data.item;
import forge.AllZone; import forge.AllZone;
import forge.quest.data.bazaar.QuestStallManager; import forge.quest.data.bazaar.QuestStallManager;
// TODO: Auto-generated Javadoc
/** /**
* <p>QuestItemZeppelin class.</p> * <p>
* * QuestItemZeppelin class.
* </p>
*
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class QuestItemZeppelin extends QuestItemAbstract { public class QuestItemZeppelin extends QuestItemAbstract {
/** The zeppelin used. */
boolean zeppelinUsed = false; boolean zeppelinUsed = false;
/** /**
* <p>Constructor for QuestItemZeppelin.</p> * <p>
* Constructor for QuestItemZeppelin.
* </p>
*/ */
QuestItemZeppelin() { QuestItemZeppelin() {
super("Zeppelin", QuestStallManager.GEAR); super("Zeppelin", QuestStallManager.GEAR);
@@ -21,52 +28,57 @@ public class QuestItemZeppelin extends QuestItemAbstract {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getPurchaseName() { public final String getPurchaseName() {
return "Zeppelin"; return "Zeppelin";
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getPurchaseDescription() { public final String getPurchaseDescription() {
return "This extremely comfortable airship allows for more efficient and safe travel<br>to faraway destinations. <br>" + return "This extremely comfortable airship allows for more efficient and safe travel<br>to faraway destinations. <br>"
"<em>Effect: </em>Quest assignments become available more frequently<br>" + + "<em>Effect: </em>Quest assignments become available more frequently<br>"
"<em>Effect: </em>Adds +3 to max life during quest games.<br>" + + "<em>Effect: </em>Adds +3 to max life during quest games.<br>"
"<em>Effect: </em>Allows travel to far places, allowing you to see a new set of opponents"; + "<em>Effect: </em>Allows travel to far places, allowing you to see a new set of opponents";
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public String getImageName() { public final String getImageName() {
return "ZeppelinIcon.png"; return "ZeppelinIcon.png";
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public int getPrice() { public final int getPrice() {
return 5000; return 5000;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public boolean isAvailableForPurchase() { public final boolean isAvailableForPurchase() {
return super.isAvailableForPurchase() && AllZone.getQuestData().getInventory().hasItem("Map"); return super.isAvailableForPurchase() && AllZone.getQuestData().getInventory().hasItem("Map");
} }
/** /**
* <p>hasBeenUsed.</p> * <p>
* * hasBeenUsed.
* </p>
*
* @return a boolean. * @return a boolean.
*/ */
public boolean hasBeenUsed() { public final boolean hasBeenUsed() {
return zeppelinUsed; return zeppelinUsed;
} }
/** /**
* <p>Setter for the field <code>zeppelinUsed</code>.</p> * <p>
* * Setter for the field <code>zeppelinUsed</code>.
* @param used a boolean. * </p>
*
* @param used
* a boolean.
*/ */
public void setZeppelinUsed(boolean used) { public final void setZeppelinUsed(final boolean used) {
this.zeppelinUsed = used; this.zeppelinUsed = used;
} }
} }

View File

@@ -1,2 +1,2 @@
/** Forge Card Game */ /** Forge Card Game. */
package forge.quest.data.item; package forge.quest.data.item;

View File

@@ -1,2 +1,2 @@
/** Forge Card Game */ /** Forge Card Game. */
package forge.quest.data; package forge.quest.data;

View File

@@ -1,2 +1,2 @@
/** Forge Card Game */ /** Forge Card Game. */
package forge.quest; package forge.quest;