diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorQuest.java b/src/main/java/forge/gui/deckeditor/DeckEditorQuest.java
index 35a2869b827..654fc387acd 100644
--- a/src/main/java/forge/gui/deckeditor/DeckEditorQuest.java
+++ b/src/main/java/forge/gui/deckeditor/DeckEditorQuest.java
@@ -144,8 +144,8 @@ public final class DeckEditorQuest extends DeckEditorBase implements NewConstant
PresetColumns.FN_RARITY_GET));
columns.add(new TableColumnInfo("Set", 40, PresetColumns.FN_SET_COMPARE,
PresetColumns.FN_SET_GET));
- columns.add(new TableColumnInfo("New", 30, this.questData.getCards().fnNewCompare,
- this.questData.getCards().fnNewGet));
+ columns.add(new TableColumnInfo("New", 30, this.questData.getCards().getFnNewCompare(),
+ this.questData.getCards().getFnNewGet()));
columns.get(2).setCellRenderer(new ManaCostRenderer());
diff --git a/src/main/java/forge/gui/deckeditor/DeckEditorShop.java b/src/main/java/forge/gui/deckeditor/DeckEditorShop.java
index 8520523b764..fe3287afdc2 100644
--- a/src/main/java/forge/gui/deckeditor/DeckEditorShop.java
+++ b/src/main/java/forge/gui/deckeditor/DeckEditorShop.java
@@ -163,8 +163,8 @@ public final class DeckEditorShop extends DeckEditorBase {
this.getTopTableWithCards().setup(columns, this.getCardView());
columnsBelow.add(new TableColumnInfo("Dks", 30, this.fnDeckCompare, this.fnDeckGet));
- columnsBelow.add(new TableColumnInfo("New", 35, this.questData.getCards().fnNewCompare,
- this.questData.getCards().fnNewGet));
+ columnsBelow.add(new TableColumnInfo("New", 35, this.questData.getCards().getFnNewCompare(),
+ this.questData.getCards().getFnNewGet()));
columnsBelow.add(new TableColumnInfo("Price", 36, this.fnPriceCompare, this.fnPriceSellGet));
this.getBottomTableWithCards().setup(columnsBelow, this.getCardView());
diff --git a/src/main/java/forge/quest/data/QuestData.java b/src/main/java/forge/quest/data/QuestData.java
index d2f595e1a50..c0b1bda55a3 100644
--- a/src/main/java/forge/quest/data/QuestData.java
+++ b/src/main/java/forge/quest/data/QuestData.java
@@ -40,40 +40,40 @@ public final class QuestData {
// but only when the object is created through the constructor
// DO NOT RENAME THIS FIELD
/** The version number. */
- int versionNumber = CURRENT_VERSION_NUMBER;
+ private int versionNumber = QuestData.CURRENT_VERSION_NUMBER;
/** The rank index. */
- int rankIndex; // level
+ private int rankIndex; // level
/** The win. */
- int win; // number of wins
+ private int win; // number of wins
/** The lost. */
- int lost;
+ private int lost;
/** The credits. */
- long credits; // this money is good for all modes
+ private long credits; // this money is good for all modes
/** The life. */
- int life; // for fantasy mode, how much life bought at shop to start game
+ private int life; // for fantasy mode, how much life bought at shop to start game
// with
/** The inventory. */
- QuestInventory inventory = new QuestInventory(); // different gadgets
+ private QuestInventory inventory = new QuestInventory(); // different gadgets
/** The pet manager. */
- QuestPetManager petManager = new QuestPetManager(); // pets that start match
+ private QuestPetManager petManager = new QuestPetManager(); // pets that start match
// with you
// Diffuculty - they store both index and title
/** The diff index. */
- int diffIndex;
+ private int diffIndex;
/** The difficulty. */
- String difficulty;
+ private String difficulty;
// Quest mode - there should be an enum :(
/** The mode. */
- String mode = "";
+ private String mode = "";
/** The Constant FANTASY. */
public static final String FANTASY = "Fantasy";
@@ -83,19 +83,19 @@ public final class QuestData {
// Decks collected by player
/** The my decks. */
- Map myDecks = new HashMap();
+ private Map myDecks = new HashMap();
// Cards associated with quest
/** The card pool. */
- ItemPool cardPool = new ItemPool(InventoryItem.class); // player's
+ private ItemPool cardPool = new ItemPool(InventoryItem.class); // player's
// belonging
/** The shop list. */
- ItemPool shopList = new ItemPool(InventoryItem.class); // the
+ private ItemPool shopList = new ItemPool(InventoryItem.class); // the
// current
// shop
// list
/** The new card list. */
- ItemPool newCardList = new ItemPool(InventoryItem.class); // cards
+ private ItemPool newCardList = new ItemPool(InventoryItem.class); // cards
// acquired
// since
// last
@@ -103,13 +103,13 @@ public final class QuestData {
// Challenge history
/** The challenges played. */
- int challengesPlayed = 0;
+ private int challengesPlayed = 0;
/** The available challenges. */
- List availableChallenges = new ArrayList();
+ private List availableChallenges = new ArrayList();
/** The completed challenges. */
- List completedChallenges = new ArrayList();
+ private List completedChallenges = new ArrayList();
// Challenges used to be called quests. During the renaming,
// files could be corrupted. These fields ensure old files still work.
@@ -117,13 +117,13 @@ public final class QuestData {
// The old files, if played once, are updated automatically to the new
// system.
/** The quests played. */
- int questsPlayed = -1;
+ private int questsPlayed = -1;
/** The available quests. */
- List availableQuests = null;
+ private List availableQuests = null;
/** The completed quests. */
- List completedQuests = null;
+ private List completedQuests = null;
// own randomizer seed
private long randomSeed = 0;
@@ -134,7 +134,7 @@ public final class QuestData {
private transient QuestUtilCards myCards;
/** The Constant RANK_TITLES. */
- public static final String[] RANK_TITLES = new String[] {"Level 0 - Confused Wizard", "Level 1 - Mana Mage",
+ public static final String[] RANK_TITLES = new String[] { "Level 0 - Confused Wizard", "Level 1 - Mana Mage",
"Level 2 - Death by Megrim", "Level 3 - Shattered the Competition", "Level 4 - Black Knighted",
"Level 5 - Shockingly Good", "Level 6 - Regressed into Timmy", "Level 7 - Loves Blue Control",
"Level 8 - Immobilized by Fear", "Level 9 - Lands = Friends", "Level 10 - Forging new paths",
@@ -151,21 +151,22 @@ public final class QuestData {
*
*/
public QuestData() {
- initTransients();
- myCards.addBasicLands(cardPool, QuestPreferences.getStartingBasic(), QuestPreferences.getStartingSnowBasic());
- randomizeOpponents();
+ this.initTransients();
+ this.myCards.addBasicLands(this.getCardPool(), QuestPreferences.getStartingBasic(),
+ QuestPreferences.getStartingSnowBasic());
+ this.randomizeOpponents();
}
private void initTransients() {
// These are helper classes that hold no data.
- myCards = new QuestUtilCards(this);
+ this.myCards = new QuestUtilCards(this);
// to avoid NPE some pools will be created here if they are null
- if (null == newCardList) {
- newCardList = new ItemPool(InventoryItem.class);
+ if (null == this.getNewCardList()) {
+ this.setNewCardList(new ItemPool(InventoryItem.class));
}
- if (null == shopList) {
- shopList = new ItemPool(InventoryItem.class);
+ if (null == this.getShopList()) {
+ this.setShopList(new ItemPool(InventoryItem.class));
}
}
@@ -181,16 +182,16 @@ public final class QuestData {
* the standard start
*/
public void newGame(final int diff, final String m0de, final boolean standardStart) {
- setDifficulty(diff);
+ this.setDifficulty(diff);
- Predicate filter = Predicate.and(standardStart ? SetUtils.getStandard().getFilterPrinted()
+ final Predicate filter = Predicate.and(standardStart ? SetUtils.getStandard().getFilterPrinted()
: CardPrinted.Predicates.Presets.IS_TRUE, CardPrinted.Predicates.Presets.NON_ALTERNATE);
- myCards.setupNewGameCardPool(filter, diff);
- credits = QuestPreferences.getStartingCredits();
+ this.myCards.setupNewGameCardPool(filter, diff);
+ this.setCredits(QuestPreferences.getStartingCredits());
- mode = m0de;
- life = mode.equals(FANTASY) ? 15 : 20;
+ this.mode = m0de;
+ this.life = this.mode.equals(QuestData.FANTASY) ? 15 : 20;
}
// All belongings
@@ -200,7 +201,7 @@ public final class QuestData {
* @return the inventory
*/
public QuestInventory getInventory() {
- return inventory;
+ return this.inventory;
}
/**
@@ -209,7 +210,7 @@ public final class QuestData {
* @return the pet manager
*/
public QuestPetManager getPetManager() {
- return petManager;
+ return this.petManager;
}
// Cards - class uses data from here
@@ -219,7 +220,7 @@ public final class QuestData {
* @return the cards
*/
public QuestUtilCards getCards() {
- return myCards;
+ return this.myCards;
}
// Challenge performance
@@ -231,19 +232,19 @@ public final class QuestData {
public int getChallengesPlayed() {
// This should be phased out after a while, when
// old quest decks have been updated. (changes made 19-9-11)
- if (questsPlayed != -1) {
- challengesPlayed = questsPlayed;
- questsPlayed = -1;
+ if (this.questsPlayed != -1) {
+ this.challengesPlayed = this.questsPlayed;
+ this.questsPlayed = -1;
}
- return challengesPlayed;
+ return this.challengesPlayed;
}
/**
* Adds the challenges played.
*/
public void addChallengesPlayed() {
- challengesPlayed++;
+ this.challengesPlayed++;
}
/**
@@ -254,12 +255,12 @@ public final class QuestData {
public List getAvailableChallenges() {
// This should be phased out after a while, when
// old quest decks have been updated. (changes made 19-9-11)
- if (availableQuests != null) {
- availableChallenges = availableQuests;
- availableQuests = null;
+ if (this.availableQuests != null) {
+ this.availableChallenges = this.availableQuests;
+ this.availableQuests = null;
}
- return availableChallenges != null ? new ArrayList(availableChallenges) : null;
+ return this.availableChallenges != null ? new ArrayList(this.availableChallenges) : null;
}
/**
@@ -269,14 +270,14 @@ public final class QuestData {
* the new available challenges
*/
public void setAvailableChallenges(final List list) {
- availableChallenges = list;
+ this.availableChallenges = list;
}
/**
* Clear available challenges.
*/
public void clearAvailableChallenges() {
- availableChallenges.clear();
+ this.availableChallenges.clear();
}
/**
@@ -292,12 +293,12 @@ public final class QuestData {
// old quest decks have been updated. (changes made 19-9-11)
// Also, poorly named - this should be "getLockedChalleneges" or
// similar.
- if (completedQuests != null) {
- completedChallenges = completedQuests;
- completedQuests = null;
+ if (this.completedQuests != null) {
+ this.completedChallenges = this.completedQuests;
+ this.completedQuests = null;
}
- return completedChallenges != null ? new ArrayList(completedChallenges) : null;
+ return this.completedChallenges != null ? new ArrayList(this.completedChallenges) : null;
}
/**
@@ -312,7 +313,7 @@ public final class QuestData {
// Poorly named - this should be "setLockedChalleneges" or similar.
public void addCompletedChallenge(final int i) {
- completedChallenges.add(i);
+ this.completedChallenges.add(i);
}
// Wins & Losses
@@ -322,14 +323,14 @@ public final class QuestData {
* @return the lost
*/
public int getLost() {
- return lost;
+ return this.lost;
}
/**
* Adds the lost.
*/
public void addLost() {
- lost++;
+ this.lost++;
}
/**
@@ -338,18 +339,18 @@ public final class QuestData {
* @return the win
*/
public int getWin() {
- return win;
+ return this.win;
}
/**
* Adds the win.
*/
public void addWin() { // changes getRank()
- win++;
+ this.win++;
- int winsToLvlUp = QuestPreferences.getWinsForRankIncrease(diffIndex);
- if (win % winsToLvlUp == 0) {
- rankIndex++;
+ final int winsToLvlUp = QuestPreferences.getWinsForRankIncrease(this.diffIndex);
+ if ((this.win % winsToLvlUp) == 0) {
+ this.rankIndex++;
}
}
@@ -360,7 +361,7 @@ public final class QuestData {
* @return the life
*/
public int getLife() {
- return isFantasy() ? life : 20;
+ return this.isFantasy() ? this.life : 20;
}
/**
@@ -370,7 +371,7 @@ public final class QuestData {
* the n
*/
public void addLife(final int n) {
- life += n;
+ this.life += n;
}
// Credits
@@ -381,7 +382,7 @@ public final class QuestData {
* the c
*/
public void addCredits(final long c) {
- credits += c;
+ this.setCredits(this.getCredits() + c);
}
/**
@@ -391,7 +392,7 @@ public final class QuestData {
* the c
*/
public void subtractCredits(final long c) {
- credits = credits > c ? credits - c : 0;
+ this.setCredits(this.getCredits() > c ? this.getCredits() - c : 0);
}
/**
@@ -400,7 +401,7 @@ public final class QuestData {
* @return the credits
*/
public long getCredits() {
- return credits;
+ return this.credits;
}
// Quest mode
@@ -410,7 +411,7 @@ public final class QuestData {
* @return true, if is fantasy
*/
public boolean isFantasy() {
- return mode.equals(FANTASY);
+ return this.mode.equals(QuestData.FANTASY);
}
/**
@@ -419,7 +420,7 @@ public final class QuestData {
* @return the mode
*/
public String getMode() {
- return mode == null ? "" : mode;
+ return this.mode == null ? "" : this.mode;
}
// Difficulty
@@ -429,7 +430,7 @@ public final class QuestData {
* @return the difficulty
*/
public String getDifficulty() {
- return difficulty;
+ return this.difficulty;
}
/**
@@ -438,7 +439,7 @@ public final class QuestData {
* @return the difficulty index
*/
public int getDifficultyIndex() {
- return diffIndex;
+ return this.diffIndex;
}
/**
@@ -448,18 +449,18 @@ public final class QuestData {
* the new difficulty
*/
public void setDifficulty(final int i) {
- diffIndex = i;
- difficulty = QuestPreferences.getDifficulty(i);
+ this.diffIndex = i;
+ this.difficulty = QuestPreferences.getDifficulty(i);
}
/**
* Guess difficulty index.
*/
public void guessDifficultyIndex() {
- String[] diffStr = QuestPreferences.getDifficulty();
+ final String[] diffStr = QuestPreferences.getDifficulty();
for (int i = 0; i < diffStr.length; i++) {
- if (difficulty.equals(diffStr[i])) {
- diffIndex = i;
+ if (this.difficulty.equals(diffStr[i])) {
+ this.diffIndex = i;
}
}
}
@@ -471,7 +472,7 @@ public final class QuestData {
* @return the level
*/
public int getLevel() {
- return rankIndex;
+ return this.rankIndex;
}
/**
@@ -480,10 +481,10 @@ public final class QuestData {
* @return the rank
*/
public String getRank() {
- if (rankIndex >= RANK_TITLES.length) {
- rankIndex = RANK_TITLES.length - 1;
+ if (this.rankIndex >= QuestData.RANK_TITLES.length) {
+ this.rankIndex = QuestData.RANK_TITLES.length - 1;
}
- return RANK_TITLES[rankIndex];
+ return QuestData.RANK_TITLES[this.rankIndex];
}
// decks management
@@ -493,7 +494,7 @@ public final class QuestData {
* @return the deck names
*/
public List getDeckNames() {
- return new ArrayList(myDecks.keySet());
+ return new ArrayList(this.getMyDecks().keySet());
}
/**
@@ -503,7 +504,7 @@ public final class QuestData {
* the deck name
*/
public void removeDeck(final String deckName) {
- myDecks.remove(deckName);
+ this.getMyDecks().remove(deckName);
}
/**
@@ -513,7 +514,7 @@ public final class QuestData {
* the d
*/
public void addDeck(final Deck d) {
- myDecks.put(d.getName(), d);
+ this.getMyDecks().put(d.getName(), d);
}
/**
@@ -526,11 +527,11 @@ public final class QuestData {
* @return a {@link forge.deck.Deck} object.
*/
public Deck getDeck(final String deckName) {
- if (!myDecks.containsKey(deckName)) {
+ if (!this.getMyDecks().containsKey(deckName)) {
ErrorViewer.showError(new Exception(),
"QuestData : getDeckFromMap(String deckName) error, deck name not found - %s", deckName);
}
- Deck d = myDecks.get(deckName);
+ final Deck d = this.getMyDecks().get(deckName);
d.clearSideboard();
return d;
}
@@ -542,14 +543,14 @@ public final class QuestData {
* @return the random seed
*/
public long getRandomSeed() {
- return randomSeed;
+ return this.randomSeed;
}
/**
* This method should be called whenever the opponents should change.
*/
public void randomizeOpponents() {
- randomSeed = MyRandom.getRandom().nextLong();
+ this.randomSeed = MyRandom.getRandom().nextLong();
}
// SERIALIZATION - related things
@@ -561,7 +562,7 @@ public final class QuestData {
* @return the object
*/
public Object readResolve() {
- initTransients();
+ this.initTransients();
return this;
}
@@ -581,4 +582,88 @@ public final class QuestData {
public void saveData() {
QuestDataIO.saveData(this);
}
+
+ /**
+ * @return the cardPool
+ */
+ public ItemPool getCardPool() {
+ return cardPool;
+ }
+
+ /**
+ * @param cardPool the cardPool to set
+ */
+ public void setCardPool(ItemPool cardPool) {
+ this.cardPool = cardPool; // TODO: Add 0 to parameter's name.
+ }
+
+ /**
+ * @return the shopList
+ */
+ public ItemPool getShopList() {
+ return shopList;
+ }
+
+ /**
+ * @param shopList the shopList to set
+ */
+ public void setShopList(ItemPool shopList) {
+ this.shopList = shopList; // TODO: Add 0 to parameter's name.
+ }
+
+ /**
+ * @return the newCardList
+ */
+ public ItemPool getNewCardList() {
+ return newCardList;
+ }
+
+ /**
+ * @param newCardList the newCardList to set
+ */
+ public void setNewCardList(ItemPool newCardList) {
+ this.newCardList = newCardList; // TODO: Add 0 to parameter's name.
+ }
+
+ /**
+ * @return the myDecks
+ */
+ public Map getMyDecks() {
+ return myDecks;
+ }
+
+ /**
+ * @param myDecks the myDecks to set
+ */
+ public void setMyDecks(Map myDecks) {
+ this.myDecks = myDecks; // TODO: Add 0 to parameter's name.
+ }
+
+ /**
+ * @param inventory the inventory to set
+ */
+ public void setInventory(QuestInventory inventory) {
+ this.inventory = inventory; // TODO: Add 0 to parameter's name.
+ }
+
+ /**
+ * @param credits the credits to set
+ */
+ public void setCredits(long credits) {
+ this.credits = credits; // TODO: Add 0 to parameter's name.
+ }
+
+ /**
+ * @return the versionNumber
+ */
+ public int getVersionNumber() {
+ return versionNumber;
+ }
+
+ /**
+ * @param versionNumber the versionNumber to set
+ */
+ public void setVersionNumber(int versionNumber) {
+ this.versionNumber = versionNumber; // TODO: Add 0 to parameter's name.
+ }
}
diff --git a/src/main/java/forge/quest/data/QuestDataIO.java b/src/main/java/forge/quest/data/QuestDataIO.java
index b05db4aabe1..684fde33422 100644
--- a/src/main/java/forge/quest/data/QuestDataIO.java
+++ b/src/main/java/forge/quest/data/QuestDataIO.java
@@ -68,35 +68,35 @@ public class QuestDataIO {
// read file "questData"
QuestData data = null;
- File xmlSaveFile = ForgeProps.getFile(NewConstants.Quest.XMLDATA);
+ final File xmlSaveFile = ForgeProps.getFile(NewConstants.Quest.XMLDATA);
- GZIPInputStream zin = new GZIPInputStream(new FileInputStream(xmlSaveFile));
+ final GZIPInputStream zin = new GZIPInputStream(new FileInputStream(xmlSaveFile));
- StringBuilder xml = new StringBuilder();
- char[] buf = new char[1024];
- InputStreamReader reader = new InputStreamReader(zin);
+ final StringBuilder xml = new StringBuilder();
+ final char[] buf = new char[1024];
+ final InputStreamReader reader = new InputStreamReader(zin);
while (reader.ready()) {
- int len = reader.read(buf);
+ final int len = reader.read(buf);
if (len == -1) {
break;
} // when end of stream was reached
xml.append(buf, 0, len);
}
- IgnoringXStream xStream = new IgnoringXStream();
+ final IgnoringXStream xStream = new IgnoringXStream();
xStream.registerConverter(new CardPoolToXml());
xStream.registerConverter(new GameTypeToXml());
xStream.alias("CardPool", ItemPool.class);
data = (QuestData) xStream.fromXML(xml.toString());
- if (data.versionNumber != QuestData.CURRENT_VERSION_NUMBER) {
- updateSaveFile(data, xml.toString());
+ if (data.getVersionNumber() != QuestData.CURRENT_VERSION_NUMBER) {
+ QuestDataIO.updateSaveFile(data, xml.toString());
}
zin.close();
return data;
- } catch (Exception ex) {
+ } catch (final Exception ex) {
ErrorViewer.showError(ex, "Error loading Quest Data");
throw new RuntimeException(ex);
}
@@ -114,18 +114,18 @@ public class QuestDataIO {
*/
private static void updateSaveFile(final QuestData newData, final String input) {
try {
- DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
- InputSource is = new InputSource();
+ final DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
+ final InputSource is = new InputSource();
is.setCharacterStream(new StringReader(input));
- Document document = builder.parse(is);
+ final Document document = builder.parse(is);
- switch (newData.versionNumber) {
+ switch (newData.getVersionNumber()) {
// There should be a fall-through b/w the cases so that each
// version's changes get applied progressively
case 0:
// First beta release with new file format,
// inventory needs to be migrated
- newData.inventory = new QuestInventory();
+ newData.setInventory(new QuestInventory());
NodeList elements = document.getElementsByTagName("estatesLevel");
newData.getInventory().setItemLevel("Estates", Integer.parseInt(elements.item(0).getTextContent()));
elements = document.getElementsByTagName("luckyCoinLevel");
@@ -134,12 +134,12 @@ public class QuestDataIO {
newData.getInventory().setItemLevel("Sleight", Integer.parseInt(elements.item(0).getTextContent()));
elements = document.getElementsByTagName("gearLevel");
- int gearLevel = Integer.parseInt(elements.item(0).getTextContent());
+ final int gearLevel = Integer.parseInt(elements.item(0).getTextContent());
if (gearLevel >= 1) {
- newData.inventory.setItemLevel("Map", 1);
+ newData.getInventory().setItemLevel("Map", 1);
}
if (gearLevel == 2) {
- newData.inventory.setItemLevel("Zeppelin", 1);
+ newData.getInventory().setItemLevel("Zeppelin", 1);
}
// fall-through
case 1:
@@ -151,9 +151,9 @@ public class QuestDataIO {
}
// mark the QD as the latest version
- newData.versionNumber = QuestData.CURRENT_VERSION_NUMBER;
+ newData.setVersionNumber(QuestData.CURRENT_VERSION_NUMBER);
- } catch (Exception e) {
+ } catch (final Exception e) {
forge.error.ErrorViewer.showError(e);
}
}
@@ -168,13 +168,13 @@ public class QuestDataIO {
*/
public static void saveData(final QuestData qd) {
try {
- XStream xStream = new XStream();
+ final XStream xStream = new XStream();
xStream.registerConverter(new CardPoolToXml());
xStream.alias("CardPool", ItemPool.class);
- File f = ForgeProps.getFile(NewConstants.Quest.XMLDATA);
- BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream(f));
- GZIPOutputStream zout = new GZIPOutputStream(bout);
+ final File f = ForgeProps.getFile(NewConstants.Quest.XMLDATA);
+ final BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream(f));
+ final GZIPOutputStream zout = new GZIPOutputStream(bout);
xStream.toXML(qd, zout);
zout.flush();
zout.close();
@@ -185,7 +185,7 @@ public class QuestDataIO {
// boutUnp.flush();
// boutUnp.close();
- } catch (Exception ex) {
+ } catch (final Exception ex) {
ErrorViewer.showError(ex, "Error saving Quest Data.");
throw new RuntimeException(ex);
}
@@ -197,15 +197,16 @@ public class QuestDataIO {
* (but are there any fields?)
*/
private static class IgnoringXStream extends XStream {
- List ignoredFields = new ArrayList();
+ private List ignoredFields = new ArrayList();
@Override
- protected MapperWrapper wrapMapper(MapperWrapper next) {
+ protected MapperWrapper wrapMapper(final MapperWrapper next) {
return new MapperWrapper(next) {
@Override
- public boolean shouldSerializeMember(@SuppressWarnings("rawtypes") Class definedIn, String fieldName) {
+ public boolean shouldSerializeMember(@SuppressWarnings("rawtypes") final Class definedIn,
+ final String fieldName) {
if (definedIn == Object.class) {
- ignoredFields.add(fieldName);
+ IgnoringXStream.this.ignoredFields.add(fieldName);
return false;
}
return super.shouldSerializeMember(definedIn, fieldName);
@@ -217,18 +218,18 @@ public class QuestDataIO {
private static class GameTypeToXml implements Converter {
@SuppressWarnings("rawtypes")
@Override
- public boolean canConvert(Class clasz) {
+ public boolean canConvert(final Class clasz) {
return clasz.equals(GameType.class);
}
@Override
- public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
+ public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) {
// not used
}
@Override
- public Object unmarshal(HierarchicalStreamReader reader, UnmarshallingContext context) {
- String value = reader.getValue();
+ public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
+ final String value = reader.getValue();
return GameType.smartValueOf(value);
}
@@ -237,11 +238,11 @@ public class QuestDataIO {
private static class CardPoolToXml implements Converter {
@SuppressWarnings("rawtypes")
@Override
- public boolean canConvert(Class clasz) {
+ public boolean canConvert(final Class clasz) {
return clasz.equals(ItemPool.class);
}
- private void write(CardPrinted cref, Integer count, HierarchicalStreamWriter writer) {
+ private void write(final CardPrinted cref, final Integer count, final HierarchicalStreamWriter writer) {
writer.startNode("card");
writer.addAttribute("c", cref.getName());
writer.addAttribute("s", cref.getSet());
@@ -255,7 +256,7 @@ public class QuestDataIO {
writer.endNode();
}
- private void write(BoosterPack booster, Integer count, HierarchicalStreamWriter writer) {
+ private void write(final BoosterPack booster, final Integer count, final HierarchicalStreamWriter writer) {
writer.startNode("booster");
writer.addAttribute("s", booster.getSet());
writer.addAttribute("n", count.toString());
@@ -263,16 +264,16 @@ public class QuestDataIO {
}
@Override
- public void marshal(Object source, HierarchicalStreamWriter writer, MarshallingContext context) {
+ public void marshal(final Object source, final HierarchicalStreamWriter writer, final MarshallingContext context) {
@SuppressWarnings("unchecked")
- ItemPool pool = (ItemPool) source;
- for (Entry e : pool) {
- InventoryItem item = e.getKey();
- Integer count = e.getValue();
+ final ItemPool pool = (ItemPool) source;
+ for (final Entry e : pool) {
+ final InventoryItem item = e.getKey();
+ final Integer count = e.getValue();
if (item instanceof CardPrinted) {
- write((CardPrinted) item, count, writer);
+ this.write((CardPrinted) item, count, writer);
} else if (item instanceof BoosterPack) {
- write((BoosterPack) item, count, writer);
+ this.write((BoosterPack) item, count, writer);
}
}
@@ -280,19 +281,19 @@ public class QuestDataIO {
@Override
public Object unmarshal(final HierarchicalStreamReader reader, final UnmarshallingContext context) {
- ItemPool result = new ItemPool(InventoryItem.class);
+ final ItemPool result = new ItemPool(InventoryItem.class);
while (reader.hasMoreChildren()) {
reader.moveDown();
- String sCnt = reader.getAttribute("n");
- int cnt = StringUtils.isNumeric(sCnt) ? Integer.parseInt(sCnt) : 1;
- String nodename = reader.getNodeName();
+ final String sCnt = reader.getAttribute("n");
+ final int cnt = StringUtils.isNumeric(sCnt) ? Integer.parseInt(sCnt) : 1;
+ final String nodename = reader.getNodeName();
if ("string".equals(nodename)) {
result.add(CardDb.instance().getCard(reader.getValue()));
} else if ("card".equals(nodename)) { // new format
- result.add(readCardPrinted(reader), cnt);
+ result.add(this.readCardPrinted(reader), cnt);
} else if ("booster".equals(nodename)) {
- result.add(readBooster(reader), cnt);
+ result.add(this.readBooster(reader), cnt);
}
reader.moveUp();
}
@@ -300,17 +301,17 @@ public class QuestDataIO {
}
private BoosterPack readBooster(final HierarchicalStreamReader reader) {
- String set = reader.getAttribute("s");
+ final String set = reader.getAttribute("s");
return new BoosterPack(set);
}
private CardPrinted readCardPrinted(final HierarchicalStreamReader reader) {
- String name = reader.getAttribute("c");
- String set = reader.getAttribute("s");
- String sIndex = reader.getAttribute("i");
- short index = StringUtils.isNumeric(sIndex) ? Short.parseShort(sIndex) : 0;
- boolean foil = "1".equals(reader.getAttribute("foil"));
- CardPrinted card = CardDb.instance().getCard(name, set, index);
+ final String name = reader.getAttribute("c");
+ final String set = reader.getAttribute("s");
+ final String sIndex = reader.getAttribute("i");
+ final short index = StringUtils.isNumeric(sIndex) ? Short.parseShort(sIndex) : 0;
+ final boolean foil = "1".equals(reader.getAttribute("foil"));
+ final CardPrinted card = CardDb.instance().getCard(name, set, index);
return foil ? CardPrinted.makeFoiled(card) : card;
}
}
diff --git a/src/main/java/forge/quest/data/QuestMatchState.java b/src/main/java/forge/quest/data/QuestMatchState.java
index 45c8c1109fe..e1ebfddd190 100644
--- a/src/main/java/forge/quest/data/QuestMatchState.java
+++ b/src/main/java/forge/quest/data/QuestMatchState.java
@@ -24,7 +24,7 @@ public class QuestMatchState {
/** The Constant MIN_GAMES_TO_WIN_MATCH. */
public static final int MIN_GAMES_TO_WIN_MATCH = 2;
- private List gamesPlayed = new ArrayList();
+ private final List gamesPlayed = new ArrayList();
// ArrayList
@@ -35,7 +35,7 @@ public class QuestMatchState {
* the completed game
*/
public final void addGamePlayed(final GameSummary completedGame) {
- gamesPlayed.add(completedGame);
+ this.gamesPlayed.add(completedGame);
}
/**
@@ -44,7 +44,7 @@ public class QuestMatchState {
* @return the games played
*/
public final GameSummary[] getGamesPlayed() {
- return gamesPlayed.toArray(new GameSummary[gamesPlayed.size()]);
+ return this.gamesPlayed.toArray(new GameSummary[this.gamesPlayed.size()]);
}
/**
@@ -53,7 +53,7 @@ public class QuestMatchState {
* @return the games played count
*/
public final int getGamesPlayedCount() {
- return gamesPlayed.size();
+ return this.gamesPlayed.size();
}
/**
@@ -64,8 +64,8 @@ public class QuestMatchState {
* @return true, if successful
*/
public final boolean hasWonLastGame(final String playerName) {
- int iLastGame = gamesPlayed.size() - 1;
- return iLastGame >= 0 ? gamesPlayed.get(iLastGame).isWinner(playerName) : false;
+ final int iLastGame = this.gamesPlayed.size() - 1;
+ return iLastGame >= 0 ? this.gamesPlayed.get(iLastGame).isWinner(playerName) : false;
}
/**
@@ -76,21 +76,21 @@ public class QuestMatchState {
public final boolean isMatchOver() {
int totalGames = 0;
- Map winsCount = new HashMap();
- for (GameSummary game : gamesPlayed) {
- String winner = game.getWinner();
- Integer boxedWins = winsCount.get(winner);
- int wins = boxedWins == null ? 0 : boxedWins.intValue();
+ final Map winsCount = new HashMap();
+ for (final GameSummary game : this.gamesPlayed) {
+ final String winner = game.getWinner();
+ final Integer boxedWins = winsCount.get(winner);
+ final int wins = boxedWins == null ? 0 : boxedWins.intValue();
winsCount.put(winner, wins + 1);
totalGames++;
}
int maxWins = 0;
- for (Integer win : winsCount.values()) {
+ for (final Integer win : winsCount.values()) {
maxWins = Math.max(maxWins, win);
}
- return maxWins >= MIN_GAMES_TO_WIN_MATCH || totalGames >= GAMES_PER_MATCH;
+ return (maxWins >= QuestMatchState.MIN_GAMES_TO_WIN_MATCH) || (totalGames >= QuestMatchState.GAMES_PER_MATCH);
}
/**
@@ -100,9 +100,9 @@ public class QuestMatchState {
* the name
* @return the int
*/
- public final int countGamesWonBy(String name) {
+ public final int countGamesWonBy(final String name) {
int wins = 0;
- for (GameSummary game : gamesPlayed) {
+ for (final GameSummary game : this.gamesPlayed) {
if (game.isWinner(name)) {
wins++;
}
@@ -117,15 +117,15 @@ public class QuestMatchState {
* the name
* @return true, if is match won by
*/
- public final boolean isMatchWonBy(String name) {
- return countGamesWonBy(name) >= MIN_GAMES_TO_WIN_MATCH;
+ public final boolean isMatchWonBy(final String name) {
+ return this.countGamesWonBy(name) >= QuestMatchState.MIN_GAMES_TO_WIN_MATCH;
}
/**
* Reset.
*/
public final void reset() {
- gamesPlayed.clear();
+ this.gamesPlayed.clear();
}
}
diff --git a/src/main/java/forge/quest/data/QuestPreferences.java b/src/main/java/forge/quest/data/QuestPreferences.java
index 3bdb8fcd5a4..18f21989e4e 100644
--- a/src/main/java/forge/quest/data/QuestPreferences.java
+++ b/src/main/java/forge/quest/data/QuestPreferences.java
@@ -24,7 +24,7 @@ public class QuestPreferences implements Serializable {
// Descriptive difficulty names
/** Constant sDifficulty="{Easy, Normal, Hard, Very Hard}". */
- private static String[] sDifficulty = {"Easy", "Normal", "Hard", "Very Hard"};
+ private static String[] sDifficulty = { "Easy", "Normal", "Hard", "Very Hard" };
// Default match wins it takes to gain a booster
/** Constant winsForBooster={1, 1, 2, 2}. */
@@ -89,7 +89,7 @@ public class QuestPreferences implements Serializable {
static {
// if quest.prefs exists
- grabPrefsFromFile();
+ QuestPreferences.grabPrefsFromFile();
}
/**
@@ -99,67 +99,67 @@ public class QuestPreferences implements Serializable {
*/
public static void grabPrefsFromFile() {
try {
- BufferedReader input = new BufferedReader(new FileReader(ForgeProps.getFile(Quest.PREFS)));
+ final BufferedReader input = new BufferedReader(new FileReader(ForgeProps.getFile(Quest.PREFS)));
String line = null;
while ((line = input.readLine()) != null) {
- if (line.startsWith("#") || line.length() == 0) {
+ if (line.startsWith("#") || (line.length() == 0)) {
continue;
}
- String[] split = line.split("=");
+ final String[] split = line.split("=");
if (split[0].equals("difficultyString")) {
- setDifficulty(split[1]);
+ QuestPreferences.setDifficulty(split[1]);
} else if (split[0].equals("winsForBooster")) {
- setWinsForBooster(split[1]);
+ QuestPreferences.setWinsForBooster(split[1]);
} else if (split[0].equals("winsForRankIncrease")) {
- setWinsForRank(split[1]);
+ QuestPreferences.setWinsForRank(split[1]);
} else if (split[0].equals("winsForMediumAI")) {
- setWinsForMediumAI(split[1]);
+ QuestPreferences.setWinsForMediumAI(split[1]);
} else if (split[0].equals("winsForHardAI")) {
- setWinsForHardAI(split[1]);
+ QuestPreferences.setWinsForHardAI(split[1]);
} else if (split[0].equals("startingBasicLand")) {
- setStartingBasic(split[1]);
+ QuestPreferences.setStartingBasic(split[1]);
} else if (split[0].equals("startingSnowBasicLand")) {
- setStartingSnowBasic(split[1]);
+ QuestPreferences.setStartingSnowBasic(split[1]);
} else if (split[0].equals("startingCommons")) {
- setStartingCommons(split[1]);
+ QuestPreferences.setStartingCommons(split[1]);
} else if (split[0].equals("startingUncommons")) {
- setStartingUncommons(split[1]);
+ QuestPreferences.setStartingUncommons(split[1]);
} else if (split[0].equals("startingRares")) {
- setStartingRares(split[1]);
+ QuestPreferences.setStartingRares(split[1]);
} else if (split[0].equals("startingCredits")) {
- setStartingCredits(split[1]);
+ QuestPreferences.setStartingCredits(split[1]);
} else if (split[0].equals("boosterPackCommon")) {
- setNumCommon(split[1]);
+ QuestPreferences.setNumCommon(split[1]);
} else if (split[0].equals("boosterPackUncommon")) {
- setNumUncommon(split[1]);
+ QuestPreferences.setNumUncommon(split[1]);
} else if (split[0].equals("boosterPackRare")) {
- setNumRares(split[1]);
+ QuestPreferences.setNumRares(split[1]);
} else if (split[0].equals("matchRewardBase")) {
- setMatchRewardBase(split[1]);
+ QuestPreferences.setMatchRewardBase(split[1]);
} else if (split[0].equals("matchRewardTotalWins")) {
- setMatchRewardTotalWins(split[1]);
+ QuestPreferences.setMatchRewardTotalWins(split[1]);
} else if (split[0].equals("matchRewardNoLosses")) {
- setMatchRewardNoLosses(split[1]);
+ QuestPreferences.setMatchRewardNoLosses(split[1]);
} else if (split[0].equals("matchRewardMilledWinBonus")) {
- setMatchRewardMilledWinBonus(split[1]);
+ QuestPreferences.setMatchRewardMilledWinBonus(split[1]);
} else if (split[0].equals("matchRewardPoisonWinBonus")) {
- setMatchRewardPoisonWinBonus(split[1]);
+ QuestPreferences.setMatchRewardPoisonWinBonus(split[1]);
} else if (split[0].equals("matchRewardAltWinBonus")) {
- setMatchRewardAltWinBonus(split[1]);
+ QuestPreferences.setMatchRewardAltWinBonus(split[1]);
} else if (split[0].equals("matchRewardWinOnFirstTurn")) {
- setMatchRewardWinFirst(split[1]);
+ QuestPreferences.setMatchRewardWinFirst(split[1]);
} else if (split[0].equals("matchRewardWinByTurnFive")) {
- setMatchRewardWinByFifth(split[1]);
+ QuestPreferences.setMatchRewardWinByFifth(split[1]);
} else if (split[0].equals("matchRewardWinByTurnTen")) {
- setMatchRewardWinByTen(split[1]);
+ QuestPreferences.setMatchRewardWinByTen(split[1]);
} else if (split[0].equals("matchRewardWinByTurnFifteen")) {
- setMatchRewardWinByFifteen(split[1]);
+ QuestPreferences.setMatchRewardWinByFifteen(split[1]);
} else if (split[0].equals("matchRewardMullToZero")) {
- setMatchMullToZero(split[1]);
+ QuestPreferences.setMatchMullToZero(split[1]);
}
}
- } catch (Exception e) {
+ } catch (final Exception e) {
System.out.println("Trouble grabbing quest data preferences. Using default values.");
}
}
@@ -172,7 +172,7 @@ public class QuestPreferences implements Serializable {
* @return an array of {@link java.lang.String} objects.
*/
public static String[] getDifficulty() {
- return sDifficulty;
+ return QuestPreferences.sDifficulty;
}
/**
@@ -185,7 +185,7 @@ public class QuestPreferences implements Serializable {
* @return a {@link java.lang.String} object.
*/
public static String getDifficulty(final int index) {
- return sDifficulty[index];
+ return QuestPreferences.sDifficulty[index];
}
/**
@@ -198,7 +198,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getWinsForBooster(final int index) {
- return winsForBooster[index];
+ return QuestPreferences.winsForBooster[index];
}
/**
@@ -211,7 +211,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getWinsForRankIncrease(final int index) {
- return winsForRankIncrease[index];
+ return QuestPreferences.winsForRankIncrease[index];
}
/**
@@ -224,7 +224,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getWinsForMediumAI(final int index) {
- return winsForMediumAI[index];
+ return QuestPreferences.winsForMediumAI[index];
}
/**
@@ -237,7 +237,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getWinsForHardAI(final int index) {
- return winsForHardAI[index];
+ return QuestPreferences.winsForHardAI[index];
}
/**
@@ -250,7 +250,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getWinsForVeryHardAI(final int index) {
- return winsForVeryHardAI[index];
+ return QuestPreferences.winsForVeryHardAI[index];
}
/**
@@ -261,7 +261,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getStartingBasic() {
- return startingBasicLand;
+ return QuestPreferences.startingBasicLand;
}
/**
@@ -272,7 +272,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getStartingSnowBasic() {
- return startingSnowBasicLand;
+ return QuestPreferences.startingSnowBasicLand;
}
/**
@@ -285,7 +285,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getStartingCommons(final int index) {
- return startingCommons[index];
+ return QuestPreferences.startingCommons[index];
}
/**
@@ -298,7 +298,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getStartingUncommons(final int index) {
- return startingUncommons[index];
+ return QuestPreferences.startingUncommons[index];
}
/**
@@ -311,7 +311,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getStartingRares(final int index) {
- return startingRares[index];
+ return QuestPreferences.startingRares[index];
}
/**
@@ -322,7 +322,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getStartingCredits() {
- return startingCredits;
+ return QuestPreferences.startingCredits;
}
/**
@@ -333,7 +333,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getNumCommon() {
- return boosterPackCommon;
+ return QuestPreferences.boosterPackCommon;
}
/**
@@ -344,7 +344,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getNumUncommon() {
- return boosterPackUncommon;
+ return QuestPreferences.boosterPackUncommon;
}
/**
@@ -355,7 +355,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getNumRare() {
- return boosterPackRare;
+ return QuestPreferences.boosterPackRare;
}
/**
@@ -366,7 +366,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getMatchRewardBase() {
- return matchRewardBase;
+ return QuestPreferences.matchRewardBase;
}
/**
@@ -377,7 +377,7 @@ public class QuestPreferences implements Serializable {
* @return a double.
*/
public static double getMatchRewardTotalWins() {
- return matchRewardTotalWins;
+ return QuestPreferences.matchRewardTotalWins;
}
/**
@@ -388,7 +388,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getMatchRewardNoLosses() {
- return matchRewardNoLosses;
+ return QuestPreferences.matchRewardNoLosses;
}
/**
@@ -399,7 +399,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getMatchRewardPoisonWinBonus() {
- return matchRewardPoisonWinBonus;
+ return QuestPreferences.matchRewardPoisonWinBonus;
}
/**
@@ -410,7 +410,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getMatchRewardMilledWinBonus() {
- return matchRewardMilledWinBonus;
+ return QuestPreferences.matchRewardMilledWinBonus;
}
/**
@@ -421,7 +421,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getMatchRewardAltWinBonus() {
- return matchRewardAltWinBonus;
+ return QuestPreferences.matchRewardAltWinBonus;
}
/**
@@ -432,7 +432,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getMatchRewardWinFirst() {
- return matchRewardWinOnFirstTurn;
+ return QuestPreferences.matchRewardWinOnFirstTurn;
}
/**
@@ -443,7 +443,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getMatchRewardWinByFifth() {
- return matchRewardWinByTurnFive;
+ return QuestPreferences.matchRewardWinByTurnFive;
}
/**
@@ -454,7 +454,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getMatchRewardWinByTen() {
- return matchRewardWinByTurnTen;
+ return QuestPreferences.matchRewardWinByTurnTen;
}
/**
@@ -465,7 +465,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getMatchRewardWinByFifteen() {
- return matchRewardWinByTurnFifteen;
+ return QuestPreferences.matchRewardWinByTurnFifteen;
}
/**
@@ -476,7 +476,7 @@ public class QuestPreferences implements Serializable {
* @return a int.
*/
public static int getMatchMullToZero() {
- return matchRewardMullToZero;
+ return QuestPreferences.matchRewardMullToZero;
}
// setters
@@ -489,7 +489,7 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setDifficulty(final String diff) {
- sDifficulty = diff.split(",");
+ QuestPreferences.sDifficulty = diff.split(",");
}
/**
@@ -501,10 +501,10 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setWinsForBooster(final String wins) {
- String[] winsStr = wins.split(",");
+ final String[] winsStr = wins.split(",");
- for (int i = 0; i < numDiff; i++) {
- winsForBooster[i] = Integer.parseInt(winsStr[i]);
+ for (int i = 0; i < QuestPreferences.numDiff; i++) {
+ QuestPreferences.winsForBooster[i] = Integer.parseInt(winsStr[i]);
}
}
@@ -517,10 +517,10 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setWinsForRank(final String wins) {
- String[] winsStr = wins.split(",");
+ final String[] winsStr = wins.split(",");
- for (int i = 0; i < numDiff; i++) {
- winsForRankIncrease[i] = Integer.parseInt(winsStr[i]);
+ for (int i = 0; i < QuestPreferences.numDiff; i++) {
+ QuestPreferences.winsForRankIncrease[i] = Integer.parseInt(winsStr[i]);
}
}
@@ -533,10 +533,10 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setWinsForMediumAI(final String wins) {
- String[] winsStr = wins.split(",");
+ final String[] winsStr = wins.split(",");
- for (int i = 0; i < numDiff; i++) {
- winsForMediumAI[i] = Integer.parseInt(winsStr[i]);
+ for (int i = 0; i < QuestPreferences.numDiff; i++) {
+ QuestPreferences.winsForMediumAI[i] = Integer.parseInt(winsStr[i]);
}
}
@@ -549,10 +549,10 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setWinsForHardAI(final String wins) {
- String[] winsStr = wins.split(",");
+ final String[] winsStr = wins.split(",");
- for (int i = 0; i < numDiff; i++) {
- winsForHardAI[i] = Integer.parseInt(winsStr[i]);
+ for (int i = 0; i < QuestPreferences.numDiff; i++) {
+ QuestPreferences.winsForHardAI[i] = Integer.parseInt(winsStr[i]);
}
}
@@ -565,7 +565,7 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setStartingBasic(final String land) {
- startingBasicLand = Integer.parseInt(land);
+ QuestPreferences.startingBasicLand = Integer.parseInt(land);
}
/**
@@ -577,7 +577,7 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setStartingSnowBasic(final String land) {
- startingSnowBasicLand = Integer.parseInt(land);
+ QuestPreferences.startingSnowBasicLand = Integer.parseInt(land);
}
/**
@@ -589,10 +589,10 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setStartingCommons(final String rarity) {
- String[] splitStr = rarity.split(",");
+ final String[] splitStr = rarity.split(",");
- for (int i = 0; i < numDiff; i++) {
- startingCommons[i] = Integer.parseInt(splitStr[i]);
+ for (int i = 0; i < QuestPreferences.numDiff; i++) {
+ QuestPreferences.startingCommons[i] = Integer.parseInt(splitStr[i]);
}
}
@@ -605,10 +605,10 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setStartingUncommons(final String rarity) {
- String[] splitStr = rarity.split(",");
+ final String[] splitStr = rarity.split(",");
- for (int i = 0; i < numDiff; i++) {
- startingUncommons[i] = Integer.parseInt(splitStr[i]);
+ for (int i = 0; i < QuestPreferences.numDiff; i++) {
+ QuestPreferences.startingUncommons[i] = Integer.parseInt(splitStr[i]);
}
}
@@ -621,10 +621,10 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setStartingRares(final String rarity) {
- String[] splitStr = rarity.split(",");
+ final String[] splitStr = rarity.split(",");
- for (int i = 0; i < numDiff; i++) {
- startingRares[i] = Integer.parseInt(splitStr[i]);
+ for (int i = 0; i < QuestPreferences.numDiff; i++) {
+ QuestPreferences.startingRares[i] = Integer.parseInt(splitStr[i]);
}
}
@@ -637,7 +637,7 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setStartingCredits(final String credits) {
- startingCredits = Integer.parseInt(credits);
+ QuestPreferences.startingCredits = Integer.parseInt(credits);
}
/**
@@ -649,7 +649,7 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setNumCommon(final String pack) {
- boosterPackCommon = Integer.parseInt(pack);
+ QuestPreferences.boosterPackCommon = Integer.parseInt(pack);
}
/**
@@ -661,7 +661,7 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setNumUncommon(final String pack) {
- boosterPackUncommon = Integer.parseInt(pack);
+ QuestPreferences.boosterPackUncommon = Integer.parseInt(pack);
}
/**
@@ -673,7 +673,7 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setNumRares(final String pack) {
- boosterPackRare = Integer.parseInt(pack);
+ QuestPreferences.boosterPackRare = Integer.parseInt(pack);
}
/**
@@ -685,7 +685,7 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setMatchRewardBase(final String match) {
- matchRewardBase = Integer.parseInt(match);
+ QuestPreferences.matchRewardBase = Integer.parseInt(match);
}
/**
@@ -697,7 +697,7 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setMatchRewardTotalWins(final String match) {
- matchRewardTotalWins = Double.parseDouble(match);
+ QuestPreferences.matchRewardTotalWins = Double.parseDouble(match);
}
/**
@@ -709,7 +709,7 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setMatchRewardNoLosses(final String match) {
- matchRewardNoLosses = Integer.parseInt(match);
+ QuestPreferences.matchRewardNoLosses = Integer.parseInt(match);
}
/**
@@ -721,7 +721,7 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setMatchRewardPoisonWinBonus(final String match) {
- matchRewardPoisonWinBonus = Integer.parseInt(match);
+ QuestPreferences.matchRewardPoisonWinBonus = Integer.parseInt(match);
}
/**
@@ -733,7 +733,7 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setMatchRewardMilledWinBonus(final String match) {
- matchRewardMilledWinBonus = Integer.parseInt(match);
+ QuestPreferences.matchRewardMilledWinBonus = Integer.parseInt(match);
}
/**
@@ -745,7 +745,7 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setMatchRewardAltWinBonus(final String match) {
- matchRewardAltWinBonus = Integer.parseInt(match);
+ QuestPreferences.matchRewardAltWinBonus = Integer.parseInt(match);
}
/**
@@ -757,7 +757,7 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setMatchRewardWinFirst(final String match) {
- matchRewardWinOnFirstTurn = Integer.parseInt(match);
+ QuestPreferences.matchRewardWinOnFirstTurn = Integer.parseInt(match);
}
/**
@@ -769,7 +769,7 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setMatchRewardWinByFifth(final String match) {
- matchRewardWinByTurnFive = Integer.parseInt(match);
+ QuestPreferences.matchRewardWinByTurnFive = Integer.parseInt(match);
}
/**
@@ -781,7 +781,7 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setMatchRewardWinByTen(final String match) {
- matchRewardWinByTurnTen = Integer.parseInt(match);
+ QuestPreferences.matchRewardWinByTurnTen = Integer.parseInt(match);
}
/**
@@ -793,7 +793,7 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setMatchRewardWinByFifteen(final String match) {
- matchRewardWinByTurnFifteen = Integer.parseInt(match);
+ QuestPreferences.matchRewardWinByTurnFifteen = Integer.parseInt(match);
}
/**
@@ -805,6 +805,6 @@ public class QuestPreferences implements Serializable {
* a {@link java.lang.String} object.
*/
public static void setMatchMullToZero(final String match) {
- matchRewardMullToZero = Integer.parseInt(match);
+ QuestPreferences.matchRewardMullToZero = Integer.parseInt(match);
}
}
diff --git a/src/main/java/forge/quest/data/QuestUtil.java b/src/main/java/forge/quest/data/QuestUtil.java
index 8588fe92836..e6e05ca13c3 100644
--- a/src/main/java/forge/quest/data/QuestUtil.java
+++ b/src/main/java/forge/quest/data/QuestUtil.java
@@ -50,13 +50,13 @@ public class QuestUtil {
* @return a {@link forge.CardList} object.
*/
public static CardList getComputerStartingCards(final QuestData qd, final QuestEvent qe) {
- CardList list = new CardList();
+ final CardList list = new CardList();
if (qe.getEventType().equals("challenge")) {
- List extras = ((QuestChallenge) qe).getAIExtraCards();
+ final List extras = ((QuestChallenge) qe).getAIExtraCards();
- for (String s : extras) {
- list.add(readExtraCard(s, AllZone.getComputerPlayer()));
+ for (final String s : extras) {
+ list.add(QuestUtil.readExtraCard(s, AllZone.getComputerPlayer()));
}
}
@@ -74,7 +74,7 @@ public class QuestUtil {
* @return a {@link forge.CardList} object.
*/
public static CardList getHumanStartingCards(final QuestData qd) {
- CardList list = new CardList();
+ final CardList list = new CardList();
if (qd.getPetManager().shouldPetBeUsed()) {
list.add(qd.getPetManager().getSelectedPet().getPetCard());
@@ -101,13 +101,13 @@ public class QuestUtil {
* @return a {@link forge.CardList} object.
*/
public static CardList getHumanStartingCards(final QuestData qd, final QuestEvent qe) {
- CardList list = getHumanStartingCards(qd);
+ final CardList list = QuestUtil.getHumanStartingCards(qd);
if (qe.getEventType().equals("challenge")) {
- List extras = ((QuestChallenge) qe).getHumanExtraCards();
+ final List extras = ((QuestChallenge) qe).getHumanExtraCards();
- for (String s : extras) {
- list.add(readExtraCard(s, AllZone.getHumanPlayer()));
+ for (final String s : extras) {
+ list.add(QuestUtil.readExtraCard(s, AllZone.getHumanPlayer()));
}
}
@@ -126,8 +126,8 @@ public class QuestUtil {
* @return token Card
*/
public static Card createToken(final String s) {
- String[] properties = s.split(";");
- Card c = new Card();
+ final String[] properties = s.split(";");
+ final Card c = new Card();
c.setToken(true);
// c.setManaCost(properties[1]);
@@ -157,9 +157,9 @@ public class QuestUtil {
* @return CardList
*/
public static List generateCardRewardList(final String s) {
- String[] temp = s.split(" ");
+ final String[] temp = s.split(" ");
- int qty = Integer.parseInt(temp[0]);
+ final int qty = Integer.parseInt(temp[0]);
// Determine rarity
CardRarity rar = CardRarity.Uncommon;
if (temp[2].equalsIgnoreCase("rare") || temp[2].equalsIgnoreCase("rares")) {
diff --git a/src/main/java/forge/quest/data/QuestUtilCards.java b/src/main/java/forge/quest/data/QuestUtilCards.java
index a7a7c7ca560..f017bc6d4a7 100644
--- a/src/main/java/forge/quest/data/QuestUtilCards.java
+++ b/src/main/java/forge/quest/data/QuestUtilCards.java
@@ -25,7 +25,7 @@ import forge.item.ItemPoolView;
* created to decrease complexity of questData class
*/
public final class QuestUtilCards {
- private QuestData q;
+ private final QuestData q;
/**
* Instantiates a new quest util cards.
@@ -34,7 +34,7 @@ public final class QuestUtilCards {
* the qd
*/
public QuestUtilCards(final QuestData qd) {
- q = qd;
+ this.q = qd;
}
/**
@@ -48,7 +48,7 @@ public final class QuestUtilCards {
* the n snow
*/
public void addBasicLands(final ItemPool pool, final int nBasic, final int nSnow) {
- CardDb db = CardDb.instance();
+ final CardDb db = CardDb.instance();
pool.add(db.getCard("Forest", "M10"), nBasic);
pool.add(db.getCard("Mountain", "M10"), nBasic);
pool.add(db.getCard("Swamp", "M10"), nBasic);
@@ -75,16 +75,16 @@ public final class QuestUtilCards {
* @return the array list
*/
public ArrayList addCards(final Predicate fSets) {
- int nCommon = QuestPreferences.getNumCommon();
- int nUncommon = QuestPreferences.getNumUncommon();
- int nRare = QuestPreferences.getNumRare();
+ final int nCommon = QuestPreferences.getNumCommon();
+ final int nUncommon = QuestPreferences.getNumUncommon();
+ final int nRare = QuestPreferences.getNumRare();
- ArrayList newCards = new ArrayList();
+ final ArrayList newCards = new ArrayList();
newCards.addAll(BoosterUtils.generateCards(fSets, nCommon, CardRarity.Common, null));
newCards.addAll(BoosterUtils.generateCards(fSets, nUncommon, CardRarity.Uncommon, null));
newCards.addAll(BoosterUtils.generateCards(fSets, nRare, CardRarity.Rare, null));
- addAllCards(newCards);
+ this.addAllCards(newCards);
return newCards;
}
@@ -95,8 +95,8 @@ public final class QuestUtilCards {
* the new cards
*/
public void addAllCards(final Iterable newCards) {
- for (CardPrinted card : newCards) {
- addSingleCard(card);
+ for (final CardPrinted card : newCards) {
+ this.addSingleCard(card);
}
}
@@ -107,13 +107,13 @@ public final class QuestUtilCards {
* the card
*/
public void addSingleCard(final CardPrinted card) {
- q.cardPool.add(card);
+ this.q.getCardPool().add(card);
// register card into that list so that it would appear as a new one.
- q.newCardList.add(card);
+ this.q.getNewCardList().add(card);
}
- private static final Predicate rarePredicate = CardPrinted.Predicates.Presets.IS_RARE_OR_MYTHIC;
+ private static final Predicate RARE_PREDICATE = CardPrinted.Predicates.Presets.IS_RARE_OR_MYTHIC;
/**
* Adds the random rare.
@@ -121,8 +121,8 @@ public final class QuestUtilCards {
* @return the card printed
*/
public CardPrinted addRandomRare() {
- CardPrinted card = rarePredicate.random(CardDb.instance().getAllCards());
- addSingleCard(card);
+ final CardPrinted card = QuestUtilCards.RARE_PREDICATE.random(CardDb.instance().getAllCards());
+ this.addSingleCard(card);
return card;
}
@@ -134,8 +134,8 @@ public final class QuestUtilCards {
* @return the list
*/
public List addRandomRare(final int n) {
- List newCards = rarePredicate.random(CardDb.instance().getAllCards(), n);
- addAllCards(newCards);
+ final List newCards = QuestUtilCards.RARE_PREDICATE.random(CardDb.instance().getAllCards(), n);
+ this.addAllCards(newCards);
return newCards;
}
@@ -148,11 +148,11 @@ public final class QuestUtilCards {
* the idx difficulty
*/
public void setupNewGameCardPool(final Predicate filter, final int idxDifficulty) {
- int nC = QuestPreferences.getStartingCommons(idxDifficulty);
- int nU = QuestPreferences.getStartingUncommons(idxDifficulty);
- int nR = QuestPreferences.getStartingRares(idxDifficulty);
+ final int nC = QuestPreferences.getStartingCommons(idxDifficulty);
+ final int nU = QuestPreferences.getStartingUncommons(idxDifficulty);
+ final int nR = QuestPreferences.getStartingRares(idxDifficulty);
- addAllCards(BoosterUtils.getQuestStarterDeck(filter, nC, nU, nR));
+ this.addAllCards(BoosterUtils.getQuestStarterDeck(filter, nC, nU, nR));
}
/**
@@ -164,10 +164,10 @@ public final class QuestUtilCards {
* the value
*/
public void buyCard(final CardPrinted card, final int value) {
- if (q.credits >= value) {
- q.credits -= value;
- q.shopList.remove(card);
- addSingleCard(card);
+ if (this.q.getCredits() >= value) {
+ this.q.setCredits(this.q.getCredits() - value);
+ this.q.getShopList().remove(card);
+ this.addSingleCard(card);
}
}
@@ -180,10 +180,10 @@ public final class QuestUtilCards {
* the value
*/
public void buyBooster(final BoosterPack booster, final int value) {
- if (q.credits >= value) {
- q.credits -= value;
- q.shopList.remove(booster);
- addAllCards(booster.getCards());
+ if (this.q.getCredits() >= value) {
+ this.q.setCredits(this.q.getCredits() - value);
+ this.q.getShopList().remove(booster);
+ this.addAllCards(booster.getCards());
}
}
@@ -197,15 +197,15 @@ public final class QuestUtilCards {
*/
public void sellCard(final CardPrinted card, final int price) {
if (price > 0) {
- q.credits += price;
+ this.q.setCredits(this.q.getCredits() + price);
}
- q.cardPool.remove(card);
- q.shopList.add(card);
+ this.q.getCardPool().remove(card);
+ this.q.getShopList().add(card);
// remove card being sold from all decks
- int leftInPool = q.cardPool.count(card);
+ final int leftInPool = this.q.getCardPool().count(card);
// remove sold cards from all decks:
- for (Deck deck : q.myDecks.values()) {
+ for (final Deck deck : this.q.getMyDecks().values()) {
deck.removeMain(card, deck.getMain().count(card) - leftInPool);
}
}
@@ -214,8 +214,8 @@ public final class QuestUtilCards {
* Clear shop list.
*/
public void clearShopList() {
- if (null != q.shopList) {
- q.shopList.clear();
+ if (null != this.q.getShopList()) {
+ this.q.getShopList().clear();
}
}
@@ -225,12 +225,12 @@ public final class QuestUtilCards {
* @return the sell mutliplier
*/
public double getSellMutliplier() {
- double multi = 0.20 + (0.001 * q.getWin());
+ double multi = 0.20 + (0.001 * this.q.getWin());
if (multi > 0.6) {
multi = 0.6;
}
- int lvlEstates = q.isFantasy() ? q.inventory.getItemLevel("Estates") : 0;
+ final int lvlEstates = this.q.isFantasy() ? this.q.getInventory().getItemLevel("Estates") : 0;
switch (lvlEstates) {
case 1:
multi += 0.01;
@@ -254,18 +254,18 @@ public final class QuestUtilCards {
* @return the sell price limit
*/
public int getSellPriceLimit() {
- return q.getWin() <= 50 ? 1000 : Integer.MAX_VALUE;
+ return this.q.getWin() <= 50 ? 1000 : Integer.MAX_VALUE;
}
/**
* Generate cards in shop.
*/
public void generateCardsInShop() {
- BoosterGenerator pack = new BoosterGenerator(CardDb.instance().getAllCards());
+ final BoosterGenerator pack = new BoosterGenerator(CardDb.instance().getAllCards());
- int levelPacks = q.getLevel() > 0 ? 4 / q.getLevel() : 4;
- int winPacks = q.getWin() / 10;
- int totalPacks = Math.min(levelPacks + winPacks, 6);
+ final int levelPacks = this.q.getLevel() > 0 ? 4 / this.q.getLevel() : 4;
+ final int winPacks = this.q.getWin() / 10;
+ final int totalPacks = Math.min(levelPacks + winPacks, 6);
final Predicate filterExt = CardSet.Predicates.Presets.SETS_IN_EXT;
final Predicate filterT2booster = Predicate.and(CardSet.Predicates.CAN_MAKE_BOOSTER,
@@ -275,18 +275,18 @@ public final class QuestUtilCards {
final Predicate filterNotExt = Predicate.and(CardSet.Predicates.CAN_MAKE_BOOSTER,
Predicate.not(filterExt));
- q.shopList.clear();
+ this.q.getShopList().clear();
for (int i = 0; i < totalPacks; i++) {
- q.shopList.addAllCards(pack.getBoosterPack(7, 3, 1, 0, 0, 0, 0, 0, 0));
+ this.q.getShopList().addAllCards(pack.getBoosterPack(7, 3, 1, 0, 0, 0, 0, 0, 0));
// add some boosters
- int rollD100 = MyRandom.getRandom().nextInt(100);
- Predicate filter = rollD100 < 40 ? filterT2booster : (rollD100 < 75 ? filterExtButT2
+ final int rollD100 = MyRandom.getRandom().nextInt(100);
+ final Predicate filter = rollD100 < 40 ? filterT2booster : (rollD100 < 75 ? filterExtButT2
: filterNotExt);
- q.shopList.addAllCards(filter.random(SetUtils.getAllSets(), 1, BoosterPack.FN_FROM_SET));
+ this.q.getShopList().addAllCards(filter.random(SetUtils.getAllSets(), 1, BoosterPack.FN_FROM_SET));
}
- addBasicLands(q.shopList, 10, 5);
+ this.addBasicLands(this.q.getShopList(), 10, 5);
}
/**
@@ -295,7 +295,7 @@ public final class QuestUtilCards {
* @return the cardpool
*/
public ItemPool getCardpool() {
- return q.cardPool;
+ return this.q.getCardPool();
}
/**
@@ -304,10 +304,10 @@ public final class QuestUtilCards {
* @return the shop list
*/
public ItemPoolView getShopList() {
- if (q.shopList.isEmpty()) {
- generateCardsInShop();
+ if (this.q.getShopList().isEmpty()) {
+ this.generateCardsInShop();
}
- return q.shopList;
+ return this.q.getShopList();
}
/**
@@ -316,14 +316,28 @@ public final class QuestUtilCards {
* @return the new cards
*/
public ItemPoolView getNewCards() {
- return q.newCardList;
+ return this.q.getNewCardList();
}
/**
* Reset new list.
*/
public void resetNewList() {
- q.newCardList.clear();
+ this.q.getNewCardList().clear();
+ }
+
+ /**
+ * @return the fnNewCompare
+ */
+ public Lambda1> getFnNewCompare() {
+ return fnNewCompare;
+ }
+
+ /**
+ * @return the fnNewGet
+ */
+ public Lambda1