checkstyle and refactor

This commit is contained in:
jendave
2011-11-01 18:05:57 +00:00
parent 4d25421af8
commit 8523d78fce
34 changed files with 1080 additions and 936 deletions

View File

@@ -11,16 +11,16 @@ package forge.quest.data.bazaar;
public class QuestStallDefinition { public class QuestStallDefinition {
/** The name. */ /** The name. */
public String name; private String name;
/** The display name. */ /** The display name. */
public String displayName; private String displayName;
/** The icon name. */ /** The icon name. */
public String iconName; private String iconName;
/** The fluff. */ /** The fluff. */
public String fluff; private String fluff;
/** /**
* <p> * <p>
@@ -36,11 +36,68 @@ public class QuestStallDefinition {
* @param iconName * @param iconName
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
*/ */
public QuestStallDefinition(final String name, public QuestStallDefinition(final String name, final String displayName, final String fluff, final String iconName) {
final String displayName, final String fluff, final String iconName) { this.setName(name);
this.name = name; this.setDisplayName(displayName);
this.displayName = displayName; this.setFluff(fluff);
this.fluff = fluff; this.setIconName(iconName);
this.iconName = iconName; }
/**
* @return the fluff
*/
public String getFluff() {
return fluff;
}
/**
* @param fluff
* the fluff to set
*/
public void setFluff(String fluff) {
this.fluff = fluff; // TODO: Add 0 to parameter's name.
}
/**
* @return the iconName
*/
public String getIconName() {
return iconName;
}
/**
* @param iconName
* the iconName to set
*/
public void setIconName(String iconName) {
this.iconName = iconName; // TODO: Add 0 to parameter's name.
}
/**
* @return the displayName
*/
public String getDisplayName() {
return displayName;
}
/**
* @param displayName the displayName to set
*/
public void setDisplayName(String displayName) {
this.displayName = displayName; // TODO: Add 0 to parameter's name.
}
/**
* @return the name
*/
public String getName() {
return name;
}
/**
* @param name the name to set
*/
public void setName(String name) {
this.name = name; // TODO: Add 0 to parameter's name.
} }
} }

View File

@@ -20,9 +20,9 @@ import forge.AllZone;
public class QuestStallManager { public class QuestStallManager {
/** Constant <code>stalls</code>. */ /** Constant <code>stalls</code>. */
static Map<String, QuestStallDefinition> stalls; private static Map<String, QuestStallDefinition> stalls;
/** Constant <code>items</code>. */ /** Constant <code>items</code>. */
static Map<String, SortedSet<QuestStallPurchasable>> items; private static Map<String, SortedSet<QuestStallPurchasable>> items;
/** /**
* <p> * <p>
@@ -30,24 +30,24 @@ public class QuestStallManager {
* </p> * </p>
*/ */
public static void buildStalls() { public static void buildStalls() {
stalls = new HashMap<String, QuestStallDefinition>(); QuestStallManager.stalls = new HashMap<String, QuestStallDefinition>();
stalls.put(ALCHEMIST, new QuestStallDefinition(ALCHEMIST, "Alchemist", QuestStallManager.stalls.put(QuestStallManager.ALCHEMIST, new QuestStallDefinition(QuestStallManager.ALCHEMIST,
"The walls of this alchemist's stall are covered with shelves with potions, oils, " "Alchemist", "The walls of this alchemist's stall are covered with shelves with potions, oils, "
+ "powders, poultices and elixirs, each meticulously labeled.", "BottlesIconSmall.png")); + "powders, poultices and elixirs, each meticulously labeled.", "BottlesIconSmall.png"));
stalls.put(BANKER, new QuestStallDefinition(BANKER, "Banker", QuestStallManager.stalls.put(QuestStallManager.BANKER, new QuestStallDefinition(QuestStallManager.BANKER,
"A large book large enough to be seen from the outside rests on the Banker's desk.", "Banker", "A large book large enough to be seen from the outside rests on the Banker's desk.",
"CoinIconSmall.png")); "CoinIconSmall.png"));
stalls.put(BOOKSTORE, new QuestStallDefinition(BOOKSTORE, "Bookstore", QuestStallManager.stalls.put(QuestStallManager.BOOKSTORE, new QuestStallDefinition(QuestStallManager.BOOKSTORE,
"Tomes of different sizes are stacked in man-high towers.", "BookIconSmall.png")); "Bookstore", "Tomes of different sizes are stacked in man-high towers.", "BookIconSmall.png"));
stalls.put(GEAR, new QuestStallDefinition(GEAR, "Adventuring Gear", QuestStallManager.stalls.put(QuestStallManager.GEAR, new QuestStallDefinition(QuestStallManager.GEAR,
"Adventuring Gear",
"This adventurer's market has a tool for every need ... or so the plaque on the wall claims.", "This adventurer's market has a tool for every need ... or so the plaque on the wall claims.",
"GearIconSmall.png")); "GearIconSmall.png"));
stalls.put(NURSERY, QuestStallManager.stalls.put(QuestStallManager.NURSERY, new QuestStallDefinition(QuestStallManager.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")); QuestStallManager.stalls.put(QuestStallManager.PET_SHOP, new QuestStallDefinition(QuestStallManager.PET_SHOP,
stalls.put(PET_SHOP, new QuestStallDefinition(PET_SHOP, "Pet Shop", "Pet Shop", "This large stall echoes with a multitude of animal noises.", "FoxIconSmall.png"));
"This large stall echoes with a multitude of animal noises.", "FoxIconSmall.png"));
} }
/** /**
@@ -58,13 +58,13 @@ public class QuestStallManager {
* @return a {@link java.util.List} object. * @return a {@link java.util.List} object.
*/ */
public static List<String> getStallNames() { public static List<String> getStallNames() {
List<String> ret = new ArrayList<String>(); final List<String> ret = new ArrayList<String>();
ret.add(ALCHEMIST); ret.add(QuestStallManager.ALCHEMIST);
ret.add(BANKER); ret.add(QuestStallManager.BANKER);
ret.add(BOOKSTORE); ret.add(QuestStallManager.BOOKSTORE);
ret.add(GEAR); ret.add(QuestStallManager.GEAR);
ret.add(NURSERY); ret.add(QuestStallManager.NURSERY);
ret.add(PET_SHOP); ret.add(QuestStallManager.PET_SHOP);
return ret; return ret;
} }
@@ -78,11 +78,11 @@ public class QuestStallManager {
* @return a {@link forge.quest.data.bazaar.QuestStallDefinition} object. * @return a {@link forge.quest.data.bazaar.QuestStallDefinition} object.
*/ */
public static QuestStallDefinition getStall(final String stallName) { public static QuestStallDefinition getStall(final String stallName) {
if (stalls == null) { if (QuestStallManager.stalls == null) {
buildStalls(); QuestStallManager.buildStalls();
} }
return stalls.get(stallName); return QuestStallManager.stalls.get(stallName);
} }
/** /**
@@ -91,19 +91,19 @@ public class QuestStallManager {
* </p> * </p>
*/ */
public static void buildItems() { public static void buildItems() {
SortedSet<QuestStallPurchasable> itemSet = new TreeSet<QuestStallPurchasable>(); final SortedSet<QuestStallPurchasable> itemSet = new TreeSet<QuestStallPurchasable>();
itemSet.addAll(AllZone.getQuestData().getInventory().getItems()); itemSet.addAll(AllZone.getQuestData().getInventory().getItems());
itemSet.addAll(AllZone.getQuestData().getPetManager().getPetsAndPlants()); itemSet.addAll(AllZone.getQuestData().getPetManager().getPetsAndPlants());
items = new HashMap<String, SortedSet<QuestStallPurchasable>>(); QuestStallManager.items = new HashMap<String, SortedSet<QuestStallPurchasable>>();
for (String stallName : getStallNames()) { for (final String stallName : QuestStallManager.getStallNames()) {
items.put(stallName, new TreeSet<QuestStallPurchasable>()); QuestStallManager.items.put(stallName, new TreeSet<QuestStallPurchasable>());
} }
for (QuestStallPurchasable purchasable : itemSet) { for (final QuestStallPurchasable purchasable : itemSet) {
items.get(purchasable.getStallName()).add(purchasable); QuestStallManager.items.get(purchasable.getStallName()).add(purchasable);
} }
} }
@@ -118,13 +118,13 @@ public class QuestStallManager {
* @return a {@link java.util.List} object. * @return a {@link java.util.List} object.
*/ */
public static List<QuestStallPurchasable> getItems(final String stallName) { public static List<QuestStallPurchasable> getItems(final String stallName) {
if (items == null) { if (QuestStallManager.items == null) {
buildItems(); QuestStallManager.buildItems();
} }
List<QuestStallPurchasable> ret = new ArrayList<QuestStallPurchasable>(); final List<QuestStallPurchasable> ret = new ArrayList<QuestStallPurchasable>();
for (QuestStallPurchasable purchasable : items.get(stallName)) { for (final QuestStallPurchasable purchasable : QuestStallManager.items.get(stallName)) {
if (purchasable.isAvailableForPurchase()) { if (purchasable.isAvailableForPurchase()) {
ret.add(purchasable); ret.add(purchasable);
} }

View File

@@ -18,7 +18,7 @@ import java.util.TreeSet;
public class QuestInventory { public class QuestInventory {
/** The inventory. */ /** The inventory. */
Map<String, QuestItemAbstract> inventory = new HashMap<String, QuestItemAbstract>(); private Map<String, QuestItemAbstract> inventory = new HashMap<String, QuestItemAbstract>();
/** /**
* <p> * <p>
@@ -26,9 +26,9 @@ public class QuestInventory {
* </p> * </p>
*/ */
public QuestInventory() { public QuestInventory() {
Set<QuestItemAbstract> allItems = getAllItems(); final Set<QuestItemAbstract> allItems = QuestInventory.getAllItems();
for (QuestItemAbstract item : allItems) { for (final QuestItemAbstract item : allItems) {
inventory.put(item.getName(), item); this.inventory.put(item.getName(), item);
} }
} }
@@ -42,7 +42,7 @@ public class QuestInventory {
* @return a boolean. * @return a boolean.
*/ */
public final boolean hasItem(final String itemName) { public final boolean hasItem(final String itemName) {
return inventory.containsKey(itemName) && inventory.get(itemName).getLevel() > 0; return this.inventory.containsKey(itemName) && (this.inventory.get(itemName).getLevel() > 0);
} }
/** /**
@@ -54,7 +54,7 @@ public class QuestInventory {
* a {@link forge.quest.data.item.QuestItemAbstract} object. * a {@link forge.quest.data.item.QuestItemAbstract} object.
*/ */
public final void addItem(final QuestItemAbstract item) { public final void addItem(final QuestItemAbstract item) {
inventory.put(item.getName(), item); this.inventory.put(item.getName(), item);
} }
/** /**
@@ -67,7 +67,7 @@ public class QuestInventory {
* @return a int. * @return a int.
*/ */
public final int getItemLevel(final String itemName) { public final int getItemLevel(final String itemName) {
QuestItemAbstract item = inventory.get(itemName); final QuestItemAbstract item = this.inventory.get(itemName);
if (item == null) { if (item == null) {
return 0; return 0;
} }
@@ -85,7 +85,7 @@ public class QuestInventory {
* a int. * a int.
*/ */
public final void setItemLevel(final String itemName, final int level) { public final void setItemLevel(final String itemName, final int level) {
inventory.get(itemName).setLevel(level); this.inventory.get(itemName).setLevel(level);
} }
/** /**
@@ -96,7 +96,7 @@ public class QuestInventory {
* @return a {@link java.util.Set} object. * @return a {@link java.util.Set} object.
*/ */
private static Set<QuestItemAbstract> getAllItems() { private static Set<QuestItemAbstract> getAllItems() {
SortedSet<QuestItemAbstract> set = new TreeSet<QuestItemAbstract>(); final SortedSet<QuestItemAbstract> set = new TreeSet<QuestItemAbstract>();
set.add(new QuestItemElixir()); set.add(new QuestItemElixir());
set.add(new QuestItemEstates()); set.add(new QuestItemEstates());
@@ -117,9 +117,9 @@ public class QuestInventory {
* @return a {@link java.lang.Object} object. * @return a {@link java.lang.Object} object.
*/ */
private Object readResolve() { private Object readResolve() {
for (QuestItemAbstract item : getAllItems()) { for (final QuestItemAbstract item : QuestInventory.getAllItems()) {
if (!inventory.containsKey(item.getName())) { if (!this.inventory.containsKey(item.getName())) {
inventory.put(item.getName(), item); this.inventory.put(item.getName(), item);
} }
} }
return this; return this;
@@ -133,7 +133,7 @@ public class QuestInventory {
* @return a {@link java.util.Collection} object. * @return a {@link java.util.Collection} object.
*/ */
public Collection<QuestItemAbstract> getItems() { public Collection<QuestItemAbstract> getItems() {
return inventory.values(); return this.inventory.values();
} }
/** /**
@@ -145,7 +145,7 @@ public class QuestInventory {
* a {@link java.lang.String} object. * 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(final String itemName) {
return inventory.get(itemName); return this.inventory.get(itemName);
} }
} }

View File

@@ -13,8 +13,8 @@ import forge.quest.data.bazaar.QuestStallPurchasable;
*/ */
public abstract class QuestItemAbstract implements QuestStallPurchasable { public abstract class QuestItemAbstract implements QuestStallPurchasable {
private int level = 0; private int level = 0;
private String name; private final String name;
private String shopName; private final String shopName;
private int maxLevel = 1; private int maxLevel = 1;
/** /**
@@ -56,7 +56,7 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public final String getName() { public final String getName() {
return name; return this.name;
} }
/** /**
@@ -64,8 +64,9 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
* *
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
@Override
public String getPurchaseName() { public String getPurchaseName() {
return name; return this.name;
} }
/** /**
@@ -75,16 +76,18 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
* *
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
@Override
public final String getStallName() { public final String getStallName() {
return shopName; return this.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.
*/ */
@Override
public void onPurchase() { public void onPurchase() {
int currentLevel = AllZone.getQuestData().getInventory().getItemLevel(name); final int currentLevel = AllZone.getQuestData().getInventory().getItemLevel(this.name);
AllZone.getQuestData().getInventory().setItemLevel(name, currentLevel + 1); AllZone.getQuestData().getInventory().setItemLevel(this.name, currentLevel + 1);
} }
/** /**
@@ -94,8 +97,9 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
* *
* @return a boolean. * @return a boolean.
*/ */
@Override
public boolean isAvailableForPurchase() { public boolean isAvailableForPurchase() {
return AllZone.getQuestData().getInventory().getItemLevel(name) < maxLevel; return AllZone.getQuestData().getInventory().getItemLevel(this.name) < this.maxLevel;
} }
/** /**
@@ -106,7 +110,7 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
* @return a int. * @return a int.
*/ */
public final int getLevel() { public final int getLevel() {
return level; return this.level;
} }
/** /**
@@ -129,7 +133,7 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
* @return a int. * @return a int.
*/ */
public final int getMaxLevel() { public final int getMaxLevel() {
return maxLevel; return this.maxLevel;
} }
/** /**
@@ -140,7 +144,7 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
* @return a boolean. * @return a boolean.
*/ */
public final boolean isLeveledItem() { public final boolean isLeveledItem() {
return maxLevel == 1; return this.maxLevel == 1;
} }
/** /**
@@ -150,6 +154,7 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
* *
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
@Override
public abstract String getPurchaseDescription(); public abstract String getPurchaseDescription();
/** /**
@@ -159,6 +164,7 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
* *
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
@Override
public abstract String getImageName(); public abstract String getImageName();
/** /**
@@ -168,11 +174,13 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
* *
* @return a int. * @return a int.
*/ */
@Override
public abstract int getPrice(); public abstract int getPrice();
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public final int compareTo(final Object o) { public final int compareTo(final Object o) {
QuestStallPurchasable q = (QuestStallPurchasable) o; final QuestStallPurchasable q = (QuestStallPurchasable) o;
return this.getPurchaseName().compareTo(q.getPurchaseName()); return this.getPurchaseName().compareTo(q.getPurchaseName());
} }
} }

View File

@@ -35,9 +35,9 @@ public class QuestItemElixir extends QuestItemAbstract {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final int getPrice() { public final int getPrice() {
if (getLevel() < 5) { if (this.getLevel() < 5) {
return 250; return 250;
} else if (getLevel() < 10) { } else if (this.getLevel() < 10) {
return 500; return 500;
} else { } else {
return 750; return 750;

View File

@@ -24,7 +24,8 @@ public class QuestItemEstates extends QuestItemAbstract {
@Override @Override
public final 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 + (this.getLevel() * 5)),
(1 + (this.getLevel() * 0.75)));
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@@ -36,9 +37,9 @@ public class QuestItemEstates extends QuestItemAbstract {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final int getPrice() { public final int getPrice() {
if (getLevel() == 0) { if (this.getLevel() == 0) {
return 500; return 500;
} else if (getLevel() == 1) { } else if (this.getLevel() == 1) {
return 750; return 750;
} else { } else {
return 1000; return 1000;

View File

@@ -14,7 +14,7 @@ import forge.quest.data.bazaar.QuestStallManager;
public class QuestItemZeppelin extends QuestItemAbstract { public class QuestItemZeppelin extends QuestItemAbstract {
/** The zeppelin used. */ /** The zeppelin used. */
boolean zeppelinUsed = false; private boolean zeppelinUsed = false;
/** /**
* <p> * <p>
@@ -66,7 +66,7 @@ public class QuestItemZeppelin extends QuestItemAbstract {
* @return a boolean. * @return a boolean.
*/ */
public final boolean hasBeenUsed() { public final boolean hasBeenUsed() {
return zeppelinUsed; return this.zeppelinUsed;
} }
/** /**

View File

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

View File

@@ -16,11 +16,11 @@ import forge.quest.data.bazaar.QuestStallPurchasable;
public abstract class QuestPetAbstract implements QuestStallPurchasable { public abstract class QuestPetAbstract implements QuestStallPurchasable {
/** The level. */ /** The level. */
int level; private int level;
private int maxLevel; private final int maxLevel;
// transient here ? // transient here ?
private String name; private final String name;
private String description; private final String description;
/** /**
* <p> * <p>
@@ -47,8 +47,9 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
* *
* @return a int. * @return a int.
*/ */
@Override
public final int getPrice() { public final int getPrice() {
return getAllUpgradePrices()[level]; return this.getAllUpgradePrices()[this.level];
} }
/** /**
@@ -68,7 +69,7 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public final String getUpgradeDescription() { public final String getUpgradeDescription() {
return getAllUpgradeDescriptions()[level]; return this.getAllUpgradeDescriptions()[this.level];
} }
/** /**
@@ -87,8 +88,9 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
* *
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
@Override
public final String getImageName() { public final String getImageName() {
return getAllImageNames()[level]; return this.getAllImageNames()[this.level];
} }
/** /**
@@ -108,7 +110,7 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public final String getStats() { public final String getStats() {
return getAllStats()[level]; return this.getAllStats()[this.level];
} }
/** /**
@@ -119,7 +121,7 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public final String getUpgradedStats() { public final String getUpgradedStats() {
return getAllStats()[level + 1]; return this.getAllStats()[this.level + 1];
} }
/** /**
@@ -130,7 +132,7 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
* @return a int. * @return a int.
*/ */
public final int getLevel() { public final int getLevel() {
return level; return this.level;
} }
/** /**
@@ -139,8 +141,8 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
* </p> * </p>
*/ */
public final void incrementLevel() { public final void incrementLevel() {
if (level < maxLevel) { if (this.level < this.maxLevel) {
level++; this.level++;
} }
} }
@@ -152,7 +154,7 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
* @return a int. * @return a int.
*/ */
public final int getMaxLevel() { public final int getMaxLevel() {
return maxLevel; return this.maxLevel;
} }
/** /**
@@ -192,9 +194,11 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
* *
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
@Override
public final String getPurchaseDescription() { public final String getPurchaseDescription() {
return "<em>" + getDescription() + "</em><br>" + getUpgradeDescription() + "<br><br><u>Current stats:</u> " return "<em>" + this.getDescription() + "</em><br>" + this.getUpgradeDescription()
+ getStats() + "<br><u>Upgraded stats:</u> " + getUpgradedStats(); + "<br><br><u>Current stats:</u> " + this.getStats() + "<br><u>Upgraded stats:</u> "
+ this.getUpgradedStats();
} }
@@ -206,7 +210,7 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public final String getDescription() { public final String getDescription() {
return description; return this.description;
} }
/** /**
@@ -217,18 +221,19 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public final String getName() { public final String getName() {
return name; return this.name;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final String toString() { public final String toString() {
return name; return this.name;
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override
public final int compareTo(final Object o) { public final int compareTo(final Object o) {
return name.compareTo(o.toString()); return this.name.compareTo(o.toString());
} }
/** /**
@@ -238,8 +243,9 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
* *
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
@Override
public final String getPurchaseName() { public final String getPurchaseName() {
return name; return this.name;
} }
/** /**
@@ -249,6 +255,7 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
* *
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
@Override
public String getStallName() { public String getStallName() {
return QuestStallManager.PET_SHOP; return QuestStallManager.PET_SHOP;
} }
@@ -260,8 +267,9 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
* *
* @return a boolean. * @return a boolean.
*/ */
@Override
public boolean isAvailableForPurchase() { public boolean isAvailableForPurchase() {
QuestPetAbstract pet = AllZone.getQuestData().getPetManager().getPet(name); final QuestPetAbstract pet = AllZone.getQuestData().getPetManager().getPet(this.name);
if (pet == null) { if (pet == null) {
return true; return true;
} }
@@ -273,7 +281,8 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
* onPurchase. * onPurchase.
* </p> * </p>
*/ */
@Override
public void onPurchase() { public void onPurchase() {
AllZone.getQuestData().getPetManager().addPetLevel(name); AllZone.getQuestData().getPetManager().addPetLevel(this.name);
} }
} }

View File

@@ -15,7 +15,7 @@ public class QuestPetBird extends QuestPetAbstract {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final Card getPetCard() { public final Card getPetCard() {
Card petCard = new Card(); final Card petCard = new Card();
petCard.setName("Bird Pet"); petCard.setName("Bird Pet");
petCard.addController(AllZone.getHumanPlayer()); petCard.addController(AllZone.getHumanPlayer());
@@ -30,19 +30,19 @@ public class QuestPetBird extends QuestPetAbstract {
petCard.addIntrinsicKeyword("Flying"); petCard.addIntrinsicKeyword("Flying");
if (level == 1) { if (this.getLevel() == 1) {
petCard.setImageName("W 0 1 Bird Pet"); petCard.setImageName("W 0 1 Bird Pet");
petCard.setBaseAttack(0); petCard.setBaseAttack(0);
petCard.setBaseDefense(1); petCard.setBaseDefense(1);
} else if (level == 2) { } else if (this.getLevel() == 2) {
petCard.setImageName("W 1 1 Bird Pet"); petCard.setImageName("W 1 1 Bird Pet");
petCard.setBaseAttack(1); petCard.setBaseAttack(1);
petCard.setBaseDefense(1); petCard.setBaseDefense(1);
} else if (level == 3) { } else if (this.getLevel() == 3) {
petCard.setImageName("W 2 1 Bird Pet"); petCard.setImageName("W 2 1 Bird Pet");
petCard.setBaseAttack(2); petCard.setBaseAttack(2);
petCard.setBaseDefense(1); petCard.setBaseDefense(1);
} else if (level == 4) { } else if (this.getLevel() == 4) {
petCard.setImageName("W 2 1 Bird Pet First Strike"); petCard.setImageName("W 2 1 Bird Pet First Strike");
petCard.setBaseAttack(2); petCard.setBaseAttack(2);
petCard.setBaseDefense(1); petCard.setBaseDefense(1);
@@ -70,22 +70,22 @@ public class QuestPetBird extends QuestPetAbstract {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final String[] getAllUpgradeDescriptions() { public final String[] getAllUpgradeDescriptions() {
return new String[] {"Purchase Bird", "Improve the attack power of your bird.", return new String[] { "Purchase Bird", "Improve the attack power of your bird.",
"Improve the attack power of your bird.", "Give First Strike to your bird.", "Improve the attack power of your bird.", "Give First Strike to your bird.",
"You cannot train your bird any further"}; "You cannot train your bird any further" };
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final String[] getAllStats() { public final String[] getAllStats() {
return new String[] {"You do not own a bird", "0/1, W, Flying", "1/1, W, Flying", "2/1, W, Flying", return new String[] { "You do not own a bird", "0/1, W, Flying", "1/1, W, Flying", "2/1, W, Flying",
"2/1, W, Flying, First Strike"}; "2/1, W, Flying, First Strike" };
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final String[] getAllImageNames() { public final String[] getAllImageNames() {
return new String[] {"", "w_0_1_bird_pet_small.jpg", "w_1_1_bird_pet_small.jpg", "w_2_1_bird_pet_small.jpg", return new String[] { "", "w_0_1_bird_pet_small.jpg", "w_1_1_bird_pet_small.jpg", "w_2_1_bird_pet_small.jpg",
"w_2_1_bird_pet_first_strike_small.jpg"}; "w_2_1_bird_pet_first_strike_small.jpg" };
} }
} }

View File

@@ -15,7 +15,7 @@ public class QuestPetCrocodile extends QuestPetAbstract {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final Card getPetCard() { public final Card getPetCard() {
Card petCard = new Card(); final Card petCard = new Card();
petCard.setName("Crocodile Pet"); petCard.setName("Crocodile Pet");
petCard.addController(AllZone.getHumanPlayer()); petCard.addController(AllZone.getHumanPlayer());
petCard.setOwner(AllZone.getHumanPlayer()); petCard.setOwner(AllZone.getHumanPlayer());
@@ -27,19 +27,19 @@ public class QuestPetCrocodile extends QuestPetAbstract {
petCard.addType("Crocodile"); petCard.addType("Crocodile");
petCard.addType("Pet"); petCard.addType("Pet");
if (level == 1) { if (this.getLevel() == 1) {
petCard.setImageName("B 1 1 Crocodile Pet"); petCard.setImageName("B 1 1 Crocodile Pet");
petCard.setBaseAttack(1); petCard.setBaseAttack(1);
petCard.setBaseDefense(1); petCard.setBaseDefense(1);
} else if (level == 2) { } else if (this.getLevel() == 2) {
petCard.setImageName("B 2 1 Crocodile Pet"); petCard.setImageName("B 2 1 Crocodile Pet");
petCard.setBaseAttack(2); petCard.setBaseAttack(2);
petCard.setBaseDefense(1); petCard.setBaseDefense(1);
} else if (level == 3) { } else if (this.getLevel() == 3) {
petCard.setImageName("B 3 1 Crocodile Pet"); petCard.setImageName("B 3 1 Crocodile Pet");
petCard.setBaseAttack(3); petCard.setBaseAttack(3);
petCard.setBaseDefense(1); petCard.setBaseDefense(1);
} else if (level == 4) { } else if (this.getLevel() == 4) {
petCard.setImageName("B 3 1 Crocodile Pet Swampwalk"); petCard.setImageName("B 3 1 Crocodile Pet Swampwalk");
petCard.setBaseAttack(3); petCard.setBaseAttack(3);
petCard.setBaseDefense(1); petCard.setBaseDefense(1);
@@ -67,21 +67,21 @@ public class QuestPetCrocodile extends QuestPetAbstract {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final String[] getAllUpgradeDescriptions() { public final String[] getAllUpgradeDescriptions() {
return new String[] {"Purchase Crocodile", "Improve the attack power of your crocodile.", return new String[] { "Purchase Crocodile", "Improve the attack power of your crocodile.",
"Improve the attack power of your crocodile.", "Give Swampwalking to your crocodile.", "Improve the attack power of your crocodile.", "Give Swampwalking to your crocodile.",
"You cannot train your crocodile any further"}; "You cannot train your crocodile any further" };
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final String[] getAllStats() { public final String[] getAllStats() {
return new String[] {"You do not own a crocodile", "1/1, B", "2/1, B", "3/1, B", "3/1, B, Swampwalking"}; return new String[] { "You do not own a crocodile", "1/1, B", "2/1, B", "3/1, B", "3/1, B, Swampwalking" };
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final String[] getAllImageNames() { public final String[] getAllImageNames() {
return new String[] {"", "b_1_1_crocodile_pet_small.jpg", "b_2_1_crocodile_pet_small.jpg", return new String[] { "", "b_1_1_crocodile_pet_small.jpg", "b_2_1_crocodile_pet_small.jpg",
"b_3_1_crocodile_pet_small.jpg", "b_3_1_crocodile_pet_swampwalk_small.jpg"}; "b_3_1_crocodile_pet_small.jpg", "b_3_1_crocodile_pet_swampwalk_small.jpg" };
} }
} }

View File

@@ -27,7 +27,7 @@ public class QuestPetHound extends QuestPetAbstract {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final Card getPetCard() { public final Card getPetCard() {
Card petCard = new Card(); final Card petCard = new Card();
petCard.setName("Hound Pet"); petCard.setName("Hound Pet");
petCard.addController(AllZone.getHumanPlayer()); petCard.addController(AllZone.getHumanPlayer());
@@ -40,22 +40,22 @@ public class QuestPetHound extends QuestPetAbstract {
petCard.addType("Hound"); petCard.addType("Hound");
petCard.addType("Pet"); petCard.addType("Pet");
if (level == 1) { if (this.getLevel() == 1) {
petCard.setImageName("R 1 1 Hound Pet"); petCard.setImageName("R 1 1 Hound Pet");
petCard.setBaseAttack(1); petCard.setBaseAttack(1);
petCard.setBaseDefense(1); petCard.setBaseDefense(1);
} else if (level == 2) { } else if (this.getLevel() == 2) {
petCard.setImageName("R 1 1 Hound Pet Haste"); petCard.setImageName("R 1 1 Hound Pet Haste");
petCard.setBaseAttack(1); petCard.setBaseAttack(1);
petCard.setBaseDefense(1); petCard.setBaseDefense(1);
petCard.addIntrinsicKeyword("Haste"); petCard.addIntrinsicKeyword("Haste");
} else if (level == 3) { } else if (this.getLevel() == 3) {
petCard.setImageName("R 2 1 Hound Pet"); petCard.setImageName("R 2 1 Hound Pet");
petCard.setBaseAttack(2); petCard.setBaseAttack(2);
petCard.setBaseDefense(1); petCard.setBaseDefense(1);
petCard.addIntrinsicKeyword("Haste"); petCard.addIntrinsicKeyword("Haste");
} else if (level == 4) { } else if (this.getLevel() == 4) {
petCard.setImageName("R 2 1 Hound Pet Alone"); petCard.setImageName("R 2 1 Hound Pet Alone");
petCard.setBaseAttack(2); petCard.setBaseAttack(2);
petCard.setBaseDefense(1); petCard.setBaseDefense(1);
@@ -65,7 +65,7 @@ public class QuestPetHound extends QuestPetAbstract {
.parseTrigger( .parseTrigger(
"Mode$ Attacks | ValidCard$ Card.Self | Alone$ True | TriggerDescription$ Whenever CARDNAME attacks alone, it gets +2/+0 until end of turn.", "Mode$ Attacks | ValidCard$ Card.Self | Alone$ True | TriggerDescription$ Whenever CARDNAME attacks alone, it gets +2/+0 until end of turn.",
petCard, true); petCard, true);
AbilityFactory af = new AbilityFactory(); final AbilityFactory af = new AbilityFactory();
myTrigger.setOverridingAbility(af.getAbility("AB$Pump | Cost$ 0 | Defined$ Self | NumAtt$ 2", petCard)); myTrigger.setOverridingAbility(af.getAbility("AB$Pump | Cost$ 0 | Defined$ Self | NumAtt$ 2", petCard));
petCard.addTrigger(myTrigger); petCard.addTrigger(myTrigger);
} }
@@ -82,22 +82,22 @@ public class QuestPetHound extends QuestPetAbstract {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final String[] getAllUpgradeDescriptions() { public final String[] getAllUpgradeDescriptions() {
return new String[] {"Purchase hound", "Give Haste to your hound.", "Improve the attack power of your hound.", return new String[] { "Purchase hound", "Give Haste to your hound.", "Improve the attack power of your hound.",
"Greatly improves your hound's attack power if it attacks alone.", "Greatly improves your hound's attack power if it attacks alone.",
"You cannot train your hound any further"}; "You cannot train your hound any further" };
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final String[] getAllStats() { public final String[] getAllStats() {
return new String[] {"You do not own a hound", "1/1, R", "1/1, R, Haste", "2/1, R, Haste", return new String[] { "You do not own a hound", "1/1, R", "1/1, R, Haste", "2/1, R, Haste",
"2/1, R, Haste, Whenever this creature attacks alone, it gets +2/+0 until end of turn."}; "2/1, R, Haste, Whenever this creature attacks alone, it gets +2/+0 until end of turn." };
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final String[] getAllImageNames() { public final String[] getAllImageNames() {
return new String[] {"", "r_1_1_hound_pet_small.jpg", "r_1_1_hound_pet_haste_small.jpg", return new String[] { "", "r_1_1_hound_pet_small.jpg", "r_1_1_hound_pet_haste_small.jpg",
"r_2_1_hound_pet_small.jpg", "r_2_1_hound_pet_alone_small.jpg"}; "r_2_1_hound_pet_small.jpg", "r_2_1_hound_pet_alone_small.jpg" };
} }
} }

View File

@@ -36,9 +36,9 @@ public class QuestPetManager {
* </p> * </p>
*/ */
public QuestPetManager() { public QuestPetManager() {
plant = new QuestPetPlant(); this.plant = new QuestPetPlant();
for (QuestPetAbstract pet : getAllPets()) { for (final QuestPetAbstract pet : QuestPetManager.getAllPets()) {
addPet(pet); this.addPet(pet);
} }
} }
@@ -51,7 +51,7 @@ public class QuestPetManager {
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
*/ */
public final void setSelectedPet(final String pet) { public final void setSelectedPet(final String pet) {
selectedPet = (pet == null) ? null : getPet(pet); this.selectedPet = (pet == null) ? null : this.getPet(pet);
} }
/** /**
@@ -62,7 +62,7 @@ public class QuestPetManager {
* @return a {@link forge.quest.data.pet.QuestPetAbstract} object. * @return a {@link forge.quest.data.pet.QuestPetAbstract} object.
*/ */
public final QuestPetAbstract getSelectedPet() { public final QuestPetAbstract getSelectedPet() {
return selectedPet; return this.selectedPet;
} }
/** /**
@@ -73,7 +73,7 @@ public class QuestPetManager {
* @return a {@link forge.quest.data.pet.QuestPetAbstract} object. * @return a {@link forge.quest.data.pet.QuestPetAbstract} object.
*/ */
public final QuestPetAbstract getPlant() { public final QuestPetAbstract getPlant() {
return plant; return this.plant;
} }
/** /**
@@ -82,10 +82,10 @@ public class QuestPetManager {
* </p> * </p>
*/ */
public final void addPlantLevel() { public final void addPlantLevel() {
if (plant == null) { if (this.plant == null) {
plant = new QuestPetPlant(); this.plant = new QuestPetPlant();
} else { } else {
plant.incrementLevel(); this.plant.incrementLevel();
} }
} }
@@ -100,7 +100,7 @@ public class QuestPetManager {
*/ */
public final QuestPetAbstract getPet(final String petName) { public final QuestPetAbstract getPet(final String petName) {
return pets.get(petName); return this.pets.get(petName);
} }
/** /**
@@ -112,7 +112,7 @@ public class QuestPetManager {
* a {@link forge.quest.data.pet.QuestPetAbstract} object. * a {@link forge.quest.data.pet.QuestPetAbstract} object.
*/ */
public final void addPet(final QuestPetAbstract newPet) { public final void addPet(final QuestPetAbstract newPet) {
pets.put(newPet.getName(), newPet); this.pets.put(newPet.getName(), newPet);
} }
/** /**
@@ -123,7 +123,7 @@ public class QuestPetManager {
* @return a {@link java.util.Set} object. * @return a {@link java.util.Set} object.
*/ */
public final Set<String> getPetNames() { public final Set<String> getPetNames() {
return pets.keySet(); return this.pets.keySet();
} }
/** /**
@@ -135,7 +135,7 @@ public class QuestPetManager {
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
*/ */
public final void addPetLevel(final String s) { public final void addPetLevel(final String s) {
pets.get(s).incrementLevel(); this.pets.get(s).incrementLevel();
} }
/** /**
@@ -146,7 +146,7 @@ public class QuestPetManager {
* @return a boolean. * @return a boolean.
*/ */
public final boolean shouldPlantBeUsed() { public final boolean shouldPlantBeUsed() {
return usePlant; return this.usePlant;
} }
/** /**
@@ -157,7 +157,7 @@ public class QuestPetManager {
* @return a boolean. * @return a boolean.
*/ */
public final boolean shouldPetBeUsed() { public final boolean shouldPetBeUsed() {
return selectedPet != null; return this.selectedPet != null;
} }
/** /**
@@ -168,7 +168,7 @@ public class QuestPetManager {
* @return a {@link java.util.Set} object. * @return a {@link java.util.Set} object.
*/ */
private static Set<QuestPetAbstract> getAllPets() { private static Set<QuestPetAbstract> getAllPets() {
SortedSet<QuestPetAbstract> set = new TreeSet<QuestPetAbstract>(); final SortedSet<QuestPetAbstract> set = new TreeSet<QuestPetAbstract>();
set.add(new QuestPetBird()); set.add(new QuestPetBird());
set.add(new QuestPetCrocodile()); set.add(new QuestPetCrocodile());
@@ -186,8 +186,8 @@ public class QuestPetManager {
* @return a {@link java.util.Set} object. * @return a {@link java.util.Set} object.
*/ */
public final Set<String> getAvailablePetNames() { public final Set<String> getAvailablePetNames() {
SortedSet<String> set = new TreeSet<String>(); final SortedSet<String> set = new TreeSet<String>();
for (Map.Entry<String, QuestPetAbstract> pet : pets.entrySet()) { for (final Map.Entry<String, QuestPetAbstract> pet : this.pets.entrySet()) {
if (pet.getValue().getLevel() > 0) { if (pet.getValue().getLevel() > 0) {
set.add(pet.getKey()); set.add(pet.getKey());
} }
@@ -203,8 +203,8 @@ public class QuestPetManager {
* @return a {@link java.util.Collection} object. * @return a {@link java.util.Collection} object.
*/ */
public final Collection<QuestPetAbstract> getPetsAndPlants() { public final Collection<QuestPetAbstract> getPetsAndPlants() {
Set<QuestPetAbstract> petsAndPlants = new HashSet<QuestPetAbstract>(pets.values()); final Set<QuestPetAbstract> petsAndPlants = new HashSet<QuestPetAbstract>(this.pets.values());
petsAndPlants.add(plant); petsAndPlants.add(this.plant);
return petsAndPlants; return petsAndPlants;
} }
@@ -218,9 +218,9 @@ public class QuestPetManager {
* @return a {@link java.lang.Object} object. * @return a {@link java.lang.Object} object.
*/ */
private Object readResolve() { private Object readResolve() {
for (QuestPetAbstract pet : getAllPets()) { for (final QuestPetAbstract pet : QuestPetManager.getAllPets()) {
if (!pets.containsKey(pet.getName())) { if (!this.pets.containsKey(pet.getName())) {
addPet(pet); this.addPet(pet);
} }
} }
return this; return this;

View File

@@ -17,7 +17,9 @@ import forge.quest.data.bazaar.QuestStallManager;
* @version $Id$ * @version $Id$
*/ */
public class QuestPetPlant extends QuestPetAbstract { public class QuestPetPlant extends QuestPetAbstract {
/** {@inheritDoc} */ /** QuestPetPlant.
* @return Card
*/
@Override @Override
public final Card getPetCard() { public final Card getPetCard() {
final Card petCard = new Card(); final Card petCard = new Card();
@@ -36,35 +38,35 @@ public class QuestPetPlant extends QuestPetAbstract {
petCard.addIntrinsicKeyword("Defender"); petCard.addIntrinsicKeyword("Defender");
if (level == 1) { if (this.getLevel() == 1) {
petCard.setImageName("G 0 1 Plant Wall"); petCard.setImageName("G 0 1 Plant Wall");
petCard.setBaseAttack(0); petCard.setBaseAttack(0);
petCard.setBaseDefense(1); petCard.setBaseDefense(1);
} else if (level == 2) { } else if (this.getLevel() == 2) {
petCard.setImageName("G 0 2 Plant Wall"); petCard.setImageName("G 0 2 Plant Wall");
petCard.setBaseAttack(0); petCard.setBaseAttack(0);
petCard.setBaseDefense(2); petCard.setBaseDefense(2);
} else if (level == 3) { } else if (this.getLevel() == 3) {
petCard.setImageName("G 0 3 Plant Wall"); petCard.setImageName("G 0 3 Plant Wall");
petCard.setBaseAttack(0); petCard.setBaseAttack(0);
petCard.setBaseDefense(3); petCard.setBaseDefense(3);
} else if (level == 4) { } else if (this.getLevel() == 4) {
petCard.setImageName("G 1 3 Plant Wall"); petCard.setImageName("G 1 3 Plant Wall");
petCard.setBaseAttack(1); petCard.setBaseAttack(1);
petCard.setBaseDefense(3); petCard.setBaseDefense(3);
// petCard.addIntrinsicKeyword("First Strike"); // petCard.addIntrinsicKeyword("First Strike");
} else if (level == 5) { } else if (this.getLevel() == 5) {
petCard.setImageName("G 1 3 Plant Wall Deathtouch"); petCard.setImageName("G 1 3 Plant Wall Deathtouch");
petCard.setBaseAttack(1); petCard.setBaseAttack(1);
petCard.setBaseDefense(3); petCard.setBaseDefense(3);
petCard.addIntrinsicKeyword("Deathtouch"); petCard.addIntrinsicKeyword("Deathtouch");
} else if (level == 6) { } else if (this.getLevel() == 6) {
petCard.setImageName("G 1 4 Plant Wall"); petCard.setImageName("G 1 4 Plant Wall");
petCard.setBaseAttack(1); petCard.setBaseAttack(1);
petCard.setBaseDefense(4); petCard.setBaseDefense(4);
petCard.addIntrinsicKeyword("Deathtouch"); petCard.addIntrinsicKeyword("Deathtouch");
Cost abCost = new Cost("T", petCard.getName(), true); final Cost abCost = new Cost("T", petCard.getName(), true);
final SpellAbility ability = new Ability_Activated(petCard, abCost, null) { final SpellAbility ability = new Ability_Activated(petCard, abCost, null) {
private static final long serialVersionUID = 7546242087593613719L; private static final long serialVersionUID = 7546242087593613719L;
@@ -81,7 +83,7 @@ public class QuestPetPlant extends QuestPetAbstract {
petCard.addSpellAbility(ability); petCard.addSpellAbility(ability);
ability.setDescription("tap: You gain 1 life."); ability.setDescription("tap: You gain 1 life.");
StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append("Plant Wall - ").append(petCard.getController()).append(" gains 1 life."); sb.append("Plant Wall - ").append(petCard.getController()).append(" gains 1 life.");
ability.setStackDescription(sb.toString()); ability.setStackDescription(sb.toString());
@@ -149,8 +151,8 @@ public class QuestPetPlant extends QuestPetAbstract {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final boolean isAvailableForPurchase() { public final boolean isAvailableForPurchase() {
QuestPetPlant plant = (QuestPetPlant) AllZone.getQuestData().getPetManager().getPlant(); final QuestPetPlant plant = (QuestPetPlant) AllZone.getQuestData().getPetManager().getPlant();
return plant == null || plant.getLevel() < plant.getMaxLevel(); return (plant == null) || (plant.getLevel() < plant.getMaxLevel());
} }
} }

View File

@@ -15,7 +15,7 @@ public class QuestPetWolf extends QuestPetAbstract {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final Card getPetCard() { public final Card getPetCard() {
Card petCard = new Card(); final Card petCard = new Card();
petCard.setName("Wolf Pet"); petCard.setName("Wolf Pet");
petCard.addController(AllZone.getHumanPlayer()); petCard.addController(AllZone.getHumanPlayer());
@@ -28,19 +28,19 @@ public class QuestPetWolf extends QuestPetAbstract {
petCard.addType("Wolf"); petCard.addType("Wolf");
petCard.addType("Pet"); petCard.addType("Pet");
if (level == 1) { if (this.getLevel() == 1) {
petCard.setImageName("G 1 1 Wolf Pet"); petCard.setImageName("G 1 1 Wolf Pet");
petCard.setBaseAttack(1); petCard.setBaseAttack(1);
petCard.setBaseDefense(1); petCard.setBaseDefense(1);
} else if (level == 2) { } else if (this.getLevel() == 2) {
petCard.setImageName("G 1 2 Wolf Pet"); petCard.setImageName("G 1 2 Wolf Pet");
petCard.setBaseAttack(1); petCard.setBaseAttack(1);
petCard.setBaseDefense(2); petCard.setBaseDefense(2);
} else if (level == 3) { } else if (this.getLevel() == 3) {
petCard.setImageName("G 2 2 Wolf Pet"); petCard.setImageName("G 2 2 Wolf Pet");
petCard.setBaseAttack(2); petCard.setBaseAttack(2);
petCard.setBaseDefense(2); petCard.setBaseDefense(2);
} else if (level == 4) { } else if (this.getLevel() == 4) {
petCard.setImageName("G 2 2 Wolf Pet Flanking"); petCard.setImageName("G 2 2 Wolf Pet Flanking");
petCard.setBaseAttack(2); petCard.setBaseAttack(2);
petCard.setBaseDefense(2); petCard.setBaseDefense(2);
@@ -68,21 +68,21 @@ public class QuestPetWolf extends QuestPetAbstract {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final String[] getAllUpgradeDescriptions() { public final String[] getAllUpgradeDescriptions() {
return new String[] {"Purchase Wolf", "Improve the attack power of your wolf.", return new String[] { "Purchase Wolf", "Improve the attack power of your wolf.",
"Improve the defense power of your wolf.", "Give Flanking to your wolf.", "Improve the defense power of your wolf.", "Give Flanking to your wolf.",
"You cannot train your wolf any further"}; "You cannot train your wolf any further" };
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final String[] getAllStats() { public final String[] getAllStats() {
return new String[] {"You do not own a wolf", "1/1, G", "1/2, G", "2/2, G", "2/2, G, Flanking"}; return new String[] { "You do not own a wolf", "1/1, G", "1/2, G", "2/2, G", "2/2, G, Flanking" };
} }
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final String[] getAllImageNames() { public final String[] getAllImageNames() {
return new String[] {"", "g_1_1_wolf_pet_small.jpg", "g_1_2_wolf_pet_small.jpg", "g_2_2_wolf_pet_small.jpg", return new String[] { "", "g_1_1_wolf_pet_small.jpg", "g_1_2_wolf_pet_small.jpg", "g_2_2_wolf_pet_small.jpg",
"g_2_2_wolf_pet_flanking_small.jpg"}; "g_2_2_wolf_pet_flanking_small.jpg" };
} }
} }

View File

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

View File

@@ -15,7 +15,7 @@ public abstract class QuestAbstractPanel extends JPanel {
private static final long serialVersionUID = -6378675010346615367L; private static final long serialVersionUID = -6378675010346615367L;
/** The main frame. */ /** The main frame. */
public QuestFrame mainFrame; private QuestFrame mainFrame;
/** /**
* <p> * <p>
@@ -26,7 +26,7 @@ public abstract class QuestAbstractPanel extends JPanel {
* a {@link forge.quest.gui.QuestFrame} object. * a {@link forge.quest.gui.QuestFrame} object.
*/ */
protected QuestAbstractPanel(final QuestFrame mainFrame) { protected QuestAbstractPanel(final QuestFrame mainFrame) {
this.mainFrame = mainFrame; this.setMainFrame(mainFrame);
} }
/** /**
@@ -35,4 +35,18 @@ public abstract class QuestAbstractPanel extends JPanel {
* </p> * </p>
*/ */
public abstract void refreshState(); public abstract void refreshState();
/**
* @return the mainFrame
*/
public QuestFrame getMainFrame() {
return mainFrame;
}
/**
* @param mainFrame the mainFrame to set
*/
public void setMainFrame(QuestFrame mainFrame) {
this.mainFrame = mainFrame; // TODO: Add 0 to parameter's name.
}
} }

View File

@@ -3,12 +3,12 @@ package forge.quest.gui;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.CardLayout; import java.awt.CardLayout;
import java.awt.Dimension; import java.awt.Dimension;
import java.awt.HeadlessException;
import java.util.HashMap; import java.util.HashMap;
import java.util.Map; import java.util.Map;
import javax.swing.JFrame; import javax.swing.JFrame;
import javax.swing.JPanel; import javax.swing.JPanel;
import javax.swing.WindowConstants;
import javax.swing.border.EmptyBorder; import javax.swing.border.EmptyBorder;
import forge.AllZone; import forge.AllZone;
@@ -30,10 +30,10 @@ public class QuestFrame extends JFrame {
private static final long serialVersionUID = -2832625381531838412L; private static final long serialVersionUID = -2832625381531838412L;
/** The visible panel. */ /** The visible panel. */
JPanel visiblePanel; private JPanel visiblePanel;
/** The quest layout. */ /** The quest layout. */
CardLayout questLayout; private CardLayout questLayout;
/** Constant <code>MAIN_PANEL="Main"</code>. */ /** Constant <code>MAIN_PANEL="Main"</code>. */
public static final String MAIN_PANEL = "Main"; public static final String MAIN_PANEL = "Main";
@@ -42,40 +42,40 @@ public class QuestFrame extends JFrame {
public static final String BAZAAR_PANEL = "Bazaar"; public static final String BAZAAR_PANEL = "Bazaar";
/** The sub panel map. */ /** The sub panel map. */
Map<String, QuestAbstractPanel> subPanelMap = new HashMap<String, QuestAbstractPanel>(); private Map<String, QuestAbstractPanel> subPanelMap = new HashMap<String, QuestAbstractPanel>();
/** /**
* <p> * <p>
* Constructor for QuestFrame. * Constructor for QuestFrame.
* </p> * </p>
* *
* @throws HeadlessException *
* the headless exception * the headless exception
*/ */
public QuestFrame() throws HeadlessException { public QuestFrame() {
this.setTitle("Quest Mode"); this.setTitle("Quest Mode");
visiblePanel = new JPanel(new BorderLayout()); this.visiblePanel = new JPanel(new BorderLayout());
visiblePanel.setBorder(new EmptyBorder(2, 2, 2, 2)); this.visiblePanel.setBorder(new EmptyBorder(2, 2, 2, 2));
questLayout = new CardLayout(); this.questLayout = new CardLayout();
visiblePanel.setLayout(questLayout); this.visiblePanel.setLayout(this.questLayout);
QuestAbstractPanel newPanel = new QuestMainPanel(this); QuestAbstractPanel newPanel = new QuestMainPanel(this);
visiblePanel.add(newPanel, MAIN_PANEL); this.visiblePanel.add(newPanel, QuestFrame.MAIN_PANEL);
subPanelMap.put(MAIN_PANEL, newPanel); this.subPanelMap.put(QuestFrame.MAIN_PANEL, newPanel);
newPanel = new QuestBazaarPanel(this); newPanel = new QuestBazaarPanel(this);
visiblePanel.add(newPanel, BAZAAR_PANEL); this.visiblePanel.add(newPanel, QuestFrame.BAZAAR_PANEL);
subPanelMap.put(BAZAAR_PANEL, newPanel); this.subPanelMap.put(QuestFrame.BAZAAR_PANEL, newPanel);
this.getContentPane().setLayout(new BorderLayout()); this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(visiblePanel, BorderLayout.CENTER); this.getContentPane().add(this.visiblePanel, BorderLayout.CENTER);
this.setPreferredSize(new Dimension(1024, 768)); this.setPreferredSize(new Dimension(1024, 768));
this.setMinimumSize(new Dimension(800, 600)); this.setMinimumSize(new Dimension(800, 600));
questLayout.show(visiblePanel, MAIN_PANEL); this.questLayout.show(this.visiblePanel, QuestFrame.MAIN_PANEL);
this.setDefaultCloseOperation(DO_NOTHING_ON_CLOSE); this.setDefaultCloseOperation(WindowConstants.DO_NOTHING_ON_CLOSE);
this.pack(); this.pack();
this.setVisible(true); this.setVisible(true);
@@ -92,8 +92,8 @@ public class QuestFrame extends JFrame {
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
*/ */
private void showPane(final String paneName) { private void showPane(final String paneName) {
subPanelMap.get(paneName).refreshState(); this.subPanelMap.get(paneName).refreshState();
questLayout.show(visiblePanel, paneName); this.questLayout.show(this.visiblePanel, paneName);
} }
/** /**
@@ -102,7 +102,7 @@ public class QuestFrame extends JFrame {
* </p> * </p>
*/ */
public final void showMainPane() { public final void showMainPane() {
showPane(MAIN_PANEL); this.showPane(QuestFrame.MAIN_PANEL);
} }
/** /**
@@ -111,7 +111,7 @@ public class QuestFrame extends JFrame {
* </p> * </p>
*/ */
public final void showBazaarPane() { public final void showBazaarPane() {
showPane(BAZAAR_PANEL); this.showPane(QuestFrame.BAZAAR_PANEL);
} }
/** /**
@@ -124,7 +124,7 @@ public class QuestFrame extends JFrame {
if (System.getenv("NG2") != null) { if (System.getenv("NG2") != null) {
if (System.getenv("NG2").equalsIgnoreCase("true")) { if (System.getenv("NG2").equalsIgnoreCase("true")) {
String[] argz = {}; final String[] argz = {};
Gui_HomeScreen.main(argz); Gui_HomeScreen.main(argz);
} else { } else {
new OldGuiNewGame(); new OldGuiNewGame();

View File

@@ -58,52 +58,52 @@ public class QuestMainPanel extends QuestAbstractPanel {
/** Constant <code>serialVersionUID=6142934729724012402L</code>. */ /** Constant <code>serialVersionUID=6142934729724012402L</code>. */
private static final long serialVersionUID = 6142934729724012402L; private static final long serialVersionUID = 6142934729724012402L;
private forge.quest.data.QuestData questData; private final forge.quest.data.QuestData questData;
private forge.quest.gui.main.QuestEventManager qem; private forge.quest.gui.main.QuestEventManager qem;
/** The credits label. */ /** The credits label. */
JLabel creditsLabel = new JLabel(); private JLabel creditsLabel = new JLabel();
/** The life label. */ /** The life label. */
JLabel lifeLabel = new JLabel(); private JLabel lifeLabel = new JLabel();
/** The stats label. */ /** The stats label. */
JLabel statsLabel = new JLabel(); private JLabel statsLabel = new JLabel();
/** The title label. */ /** The title label. */
JLabel titleLabel = new JLabel(); private JLabel titleLabel = new JLabel();
/** The next quest label. */ /** The next quest label. */
JLabel nextQuestLabel = new JLabel(); private JLabel nextQuestLabel = new JLabel();
/** The pet combo box. */ /** The pet combo box. */
JComboBox petComboBox = new JComboBox(); private JComboBox petComboBox = new JComboBox();
/** The deck combo box. */ /** The deck combo box. */
JComboBox deckComboBox = new JComboBox(); private JComboBox deckComboBox = new JComboBox();
/** The event button. */ /** The event button. */
JButton eventButton = new JButton("Challenges"); private JButton eventButton = new JButton("Challenges");
/** The play button. */ /** The play button. */
JButton playButton = new JButton("Play"); private JButton playButton = new JButton("Play");
private QuestSelectablePanel selectedOpponent; private QuestSelectablePanel selectedOpponent;
/** The next match panel. */ /** The next match panel. */
JPanel nextMatchPanel = new JPanel(); private JPanel nextMatchPanel = new JPanel();
/** The next match layout. */ /** The next match layout. */
CardLayout nextMatchLayout; private CardLayout nextMatchLayout;
/** The is showing challenges. */ /** The is showing challenges. */
boolean isShowingChallenges = false; private boolean isShowingChallenges = false;
private JCheckBox devModeCheckBox = new JCheckBox("Developer Mode"); private final JCheckBox devModeCheckBox = new JCheckBox("Developer Mode");
// private JCheckBox newGUICheckbox = new JCheckBox("Use new UI", true); // private JCheckBox newGUICheckbox = new JCheckBox("Use new UI", true);
private JCheckBox smoothLandCheckBox = new JCheckBox("Adjust AI Land"); private final JCheckBox smoothLandCheckBox = new JCheckBox("Adjust AI Land");
private JCheckBox petCheckBox = new JCheckBox("Summon Pet"); private final JCheckBox petCheckBox = new JCheckBox("Summon Pet");
private JCheckBox plantBox = new JCheckBox("Summon Plant"); private final JCheckBox plantBox = new JCheckBox("Summon Plant");
/** Constant <code>NO_DECKS_AVAILABLE="No decks available"</code>. */ /** Constant <code>NO_DECKS_AVAILABLE="No decks available"</code>. */
private static final String NO_DECKS_AVAILABLE = "No decks available"; private static final String NO_DECKS_AVAILABLE = "No decks available";
/** Constant <code>DUELS="Duels"</code>. */ /** Constant <code>DUELS="Duels"</code>. */
@@ -112,11 +112,14 @@ public class QuestMainPanel extends QuestAbstractPanel {
private static final String CHALLENGES = "Challenges"; private static final String CHALLENGES = "Challenges";
// TODO: Make this ordering permanent // TODO: Make this ordering permanent
/** Constant <code>lastUsedDeck="//TODO: Make this ordering permanent"</code>. */ /**
* Constant <code>lastUsedDeck="//TODO: Make this ordering permanent"</code>
* .
*/
private static String lastUsedDeck; private static String lastUsedDeck;
private JButton zeppelinButton = new JButton("<html>Launch<br>Zeppelin</html>", GuiUtils.getResizedIcon( private final JButton zeppelinButton = new JButton("<html>Launch<br>Zeppelin</html>", GuiUtils.getResizedIcon(
GuiUtils.getIconFromFile("ZeppelinIcon.png"), 40, 40)); GuiUtils.getIconFromFile("ZeppelinIcon.png"), 40, 40));
private JPanel zeppelinPanel = new JPanel(); private final JPanel zeppelinPanel = new JPanel();
/** /**
* <p> * <p>
@@ -128,18 +131,18 @@ public class QuestMainPanel extends QuestAbstractPanel {
*/ */
public QuestMainPanel(final QuestFrame mainFrame) { public QuestMainPanel(final QuestFrame mainFrame) {
super(mainFrame); super(mainFrame);
questData = AllZone.getQuestData(); this.questData = AllZone.getQuestData();
qem = AllZone.getQuestEventManager(); this.qem = AllZone.getQuestEventManager();
// QuestEventManager is the MODEL for this VIEW. // QuestEventManager is the MODEL for this VIEW.
// All quest events are generated here, the first time the VIEW is made. // All quest events are generated here, the first time the VIEW is made.
if (qem == null) { if (this.qem == null) {
qem = new QuestEventManager(); this.qem = new QuestEventManager();
qem.assembleAllEvents(); this.qem.assembleAllEvents();
AllZone.setQuestEventManager(qem); AllZone.setQuestEventManager(this.qem);
} }
initUI(); this.initUI();
} }
/** /**
@@ -148,21 +151,21 @@ public class QuestMainPanel extends QuestAbstractPanel {
* </p> * </p>
*/ */
private void initUI() { private void initUI() {
refresh(); this.refresh();
this.setLayout(new BorderLayout(5, 5)); this.setLayout(new BorderLayout(5, 5));
JPanel centerPanel = new JPanel(new BorderLayout()); final JPanel centerPanel = new JPanel(new BorderLayout());
this.add(centerPanel, BorderLayout.CENTER); this.add(centerPanel, BorderLayout.CENTER);
JPanel northPanel = createStatusPanel(); final JPanel northPanel = this.createStatusPanel();
this.add(northPanel, BorderLayout.NORTH); this.add(northPanel, BorderLayout.NORTH);
JPanel eastPanel = createSidePanel(); final JPanel eastPanel = this.createSidePanel();
this.add(eastPanel, BorderLayout.EAST); this.add(eastPanel, BorderLayout.EAST);
JPanel matchSettingsPanel = createMatchSettingsPanel(); final JPanel matchSettingsPanel = this.createMatchSettingsPanel();
centerPanel.add(matchSettingsPanel, BorderLayout.SOUTH); centerPanel.add(matchSettingsPanel, BorderLayout.SOUTH);
centerPanel.add(nextMatchPanel, BorderLayout.CENTER); centerPanel.add(this.nextMatchPanel, BorderLayout.CENTER);
this.setBorder(new EmptyBorder(5, 5, 5, 5)); this.setBorder(new EmptyBorder(5, 5, 5, 5));
} }
@@ -175,29 +178,29 @@ public class QuestMainPanel extends QuestAbstractPanel {
* @return a {@link javax.swing.JPanel} object. * @return a {@link javax.swing.JPanel} object.
*/ */
private JPanel createStatusPanel() { private JPanel createStatusPanel() {
JPanel northPanel = new JPanel(); final JPanel northPanel = new JPanel();
JLabel modeLabel; JLabel modeLabel;
JLabel difficultyLabel; // Create labels at the top JLabel difficultyLabel; // Create labels at the top
titleLabel.setFont(new Font(Font.DIALOG, Font.PLAIN, 28)); this.titleLabel.setFont(new Font(Font.DIALOG, Font.PLAIN, 28));
titleLabel.setAlignmentX(LEFT_ALIGNMENT); this.titleLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.Y_AXIS)); northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.Y_AXIS));
northPanel.add(titleLabel); northPanel.add(this.titleLabel);
northPanel.add(Box.createVerticalStrut(5)); northPanel.add(Box.createVerticalStrut(5));
JPanel statusPanel = new JPanel(); final JPanel statusPanel = new JPanel();
statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS)); statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS));
statusPanel.setAlignmentX(LEFT_ALIGNMENT); statusPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
modeLabel = new JLabel(questData.getMode()); modeLabel = new JLabel(this.questData.getMode());
statusPanel.add(modeLabel); statusPanel.add(modeLabel);
statusPanel.add(Box.createHorizontalGlue()); statusPanel.add(Box.createHorizontalGlue());
difficultyLabel = new JLabel(questData.getDifficulty()); difficultyLabel = new JLabel(this.questData.getDifficulty());
statusPanel.add(difficultyLabel); statusPanel.add(difficultyLabel);
statusPanel.add(Box.createHorizontalGlue()); statusPanel.add(Box.createHorizontalGlue());
statusPanel.add(statsLabel); statusPanel.add(this.statsLabel);
northPanel.add(statusPanel); northPanel.add(statusPanel);
return northPanel; return northPanel;
@@ -211,23 +214,25 @@ public class QuestMainPanel extends QuestAbstractPanel {
* @return a {@link javax.swing.JPanel} object. * @return a {@link javax.swing.JPanel} object.
*/ */
private JPanel createSidePanel() { private JPanel createSidePanel() {
JPanel panel = new JPanel(); final JPanel panel = new JPanel();
JPanel optionsPanel; // Create options checkbox list JPanel optionsPanel; // Create options checkbox list
optionsPanel = createOptionsPanel(); optionsPanel = this.createOptionsPanel();
List<Component> eastComponents = new ArrayList<Component>(); final List<Component> eastComponents = new ArrayList<Component>();
// Create buttons // Create buttons
JButton mainMenuButton = new JButton("Return to Main Menu"); final JButton mainMenuButton = new JButton("Return to Main Menu");
mainMenuButton.addActionListener(new ActionListener() { mainMenuButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent actionEvent) { public void actionPerformed(final ActionEvent actionEvent) {
mainFrame.returnToMainMenu(); QuestMainPanel.this.getMainFrame().returnToMainMenu();
} }
}); });
eastComponents.add(mainMenuButton); eastComponents.add(mainMenuButton);
JButton cardShopButton = new JButton("Card Shop"); final JButton cardShopButton = new JButton("Card Shop");
cardShopButton.addActionListener(new ActionListener() { cardShopButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent actionEvent) { public void actionPerformed(final ActionEvent actionEvent) {
QuestMainPanel.this.showCardShop(); QuestMainPanel.this.showCardShop();
} }
@@ -236,10 +241,11 @@ public class QuestMainPanel extends QuestAbstractPanel {
cardShopButton.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 20)); cardShopButton.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 20));
JButton bazaarButton = null; JButton bazaarButton = null;
if (questData.getMode().equals(forge.quest.data.QuestData.FANTASY)) { if (this.questData.getMode().equals(forge.quest.data.QuestData.FANTASY)) {
bazaarButton = new JButton("Bazaar"); bazaarButton = new JButton("Bazaar");
bazaarButton.addActionListener(new ActionListener() { bazaarButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent actionEvent) { public void actionPerformed(final ActionEvent actionEvent) {
QuestMainPanel.this.showBazaar(); QuestMainPanel.this.showBazaar();
} }
@@ -248,25 +254,27 @@ public class QuestMainPanel extends QuestAbstractPanel {
bazaarButton.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 20)); bazaarButton.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 20));
} }
eventButton.addActionListener(new ActionListener() { this.eventButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent actionEvent) { public void actionPerformed(final ActionEvent actionEvent) {
QuestMainPanel.this.showChallenges(); QuestMainPanel.this.showChallenges();
} }
}); });
eastComponents.add(eventButton); eastComponents.add(this.eventButton);
eventButton.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 18)); this.eventButton.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 18));
eventButton.setPreferredSize(new Dimension(0, 60)); this.eventButton.setPreferredSize(new Dimension(0, 60));
playButton.addActionListener(new ActionListener() { this.playButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent actionEvent) { public void actionPerformed(final ActionEvent actionEvent) {
QuestMainPanel.this.launchGame(); QuestMainPanel.this.launchGame();
} }
}); });
playButton.setFont(new Font(Font.DIALOG, Font.BOLD, 28)); this.playButton.setFont(new Font(Font.DIALOG, Font.BOLD, 28));
playButton.setPreferredSize(new Dimension(0, 100)); this.playButton.setPreferredSize(new Dimension(0, 100));
eastComponents.add(playButton); eastComponents.add(this.playButton);
eastComponents.add(optionsPanel); eastComponents.add(optionsPanel);
GuiUtils.setWidthToMax(eastComponents); GuiUtils.setWidthToMax(eastComponents);
@@ -277,7 +285,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
panel.add(Box.createVerticalGlue()); panel.add(Box.createVerticalGlue());
panel.add(Box.createVerticalGlue()); panel.add(Box.createVerticalGlue());
if (questData.getMode().equals(forge.quest.data.QuestData.FANTASY)) { if (this.questData.getMode().equals(forge.quest.data.QuestData.FANTASY)) {
panel.add(this.lifeLabel); panel.add(this.lifeLabel);
this.lifeLabel.setFont(new Font(Font.DIALOG, Font.BOLD, 14)); this.lifeLabel.setFont(new Font(Font.DIALOG, Font.BOLD, 14));
this.lifeLabel.setIcon(GuiUtils.getResizedIcon(GuiUtils.getIconFromFile("Life.png"), 30, 30)); this.lifeLabel.setIcon(GuiUtils.getResizedIcon(GuiUtils.getIconFromFile("Life.png"), 30, 30));
@@ -290,19 +298,19 @@ public class QuestMainPanel extends QuestAbstractPanel {
GuiUtils.addGap(panel, 10); GuiUtils.addGap(panel, 10);
panel.add(cardShopButton); panel.add(cardShopButton);
if (questData.getMode().equals(forge.quest.data.QuestData.FANTASY)) { if (this.questData.getMode().equals(forge.quest.data.QuestData.FANTASY)) {
GuiUtils.addGap(panel); GuiUtils.addGap(panel);
panel.add(bazaarButton); panel.add(bazaarButton);
} }
panel.add(Box.createVerticalGlue()); panel.add(Box.createVerticalGlue());
panel.add(eventButton); panel.add(this.eventButton);
this.nextQuestLabel.setFont(new Font(Font.DIALOG, Font.PLAIN, 11)); this.nextQuestLabel.setFont(new Font(Font.DIALOG, Font.PLAIN, 11));
panel.add(nextQuestLabel); panel.add(this.nextQuestLabel);
GuiUtils.addGap(panel); GuiUtils.addGap(panel);
panel.add(playButton); panel.add(this.playButton);
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS)); panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
return panel; return panel;
@@ -338,66 +346,72 @@ public class QuestMainPanel extends QuestAbstractPanel {
*/ */
private JPanel createMatchSettingsPanel() { private JPanel createMatchSettingsPanel() {
JPanel matchPanel = new JPanel(); final JPanel matchPanel = new JPanel();
matchPanel.setLayout(new BoxLayout(matchPanel, BoxLayout.Y_AXIS)); matchPanel.setLayout(new BoxLayout(matchPanel, BoxLayout.Y_AXIS));
JPanel deckPanel = new JPanel(); final JPanel deckPanel = new JPanel();
deckPanel.setLayout(new BoxLayout(deckPanel, BoxLayout.X_AXIS)); deckPanel.setLayout(new BoxLayout(deckPanel, BoxLayout.X_AXIS));
JLabel deckLabel = new JLabel("Use Deck"); final JLabel deckLabel = new JLabel("Use Deck");
deckPanel.add(deckLabel); deckPanel.add(deckLabel);
GuiUtils.addGap(deckPanel); GuiUtils.addGap(deckPanel);
this.deckComboBox.addActionListener(new ActionListener() { this.deckComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent actionEvent) { public void actionPerformed(final ActionEvent actionEvent) {
playButton.setEnabled(canGameBeLaunched()); QuestMainPanel.this.playButton.setEnabled(QuestMainPanel.this.canGameBeLaunched());
lastUsedDeck = (String) deckComboBox.getSelectedItem(); QuestMainPanel.lastUsedDeck = (String) QuestMainPanel.this.deckComboBox.getSelectedItem();
} }
}); });
deckPanel.add(this.deckComboBox); deckPanel.add(this.deckComboBox);
GuiUtils.addGap(deckPanel); GuiUtils.addGap(deckPanel);
JButton editDeckButton = new JButton("Deck Editor"); final JButton editDeckButton = new JButton("Deck Editor");
editDeckButton.addActionListener(new ActionListener() { editDeckButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent actionEvent) { public void actionPerformed(final ActionEvent actionEvent) {
showDeckEditor(); QuestMainPanel.this.showDeckEditor();
} }
}); });
deckPanel.add(editDeckButton); deckPanel.add(editDeckButton);
deckPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, deckPanel.getPreferredSize().height)); deckPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, deckPanel.getPreferredSize().height));
deckPanel.setAlignmentX(LEFT_ALIGNMENT); deckPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
matchPanel.add(deckPanel); matchPanel.add(deckPanel);
GuiUtils.addGap(matchPanel); GuiUtils.addGap(matchPanel);
if (questData.getMode().equals(forge.quest.data.QuestData.FANTASY)) { if (this.questData.getMode().equals(forge.quest.data.QuestData.FANTASY)) {
JPanel fantasyPanel = new JPanel(); final JPanel fantasyPanel = new JPanel();
fantasyPanel.setLayout(new BorderLayout()); fantasyPanel.setLayout(new BorderLayout());
JPanel petPanel = new JPanel(); final JPanel petPanel = new JPanel();
petPanel.setLayout(new BoxLayout(petPanel, BoxLayout.X_AXIS)); petPanel.setLayout(new BoxLayout(petPanel, BoxLayout.X_AXIS));
this.petCheckBox.addActionListener(new ActionListener() { this.petCheckBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent actionEvent) { public void actionPerformed(final ActionEvent actionEvent) {
if (petCheckBox.isSelected()) { if (QuestMainPanel.this.petCheckBox.isSelected()) {
questData.getPetManager().setSelectedPet((String) petComboBox.getSelectedItem()); QuestMainPanel.this.questData.getPetManager().setSelectedPet(
(String) QuestMainPanel.this.petComboBox.getSelectedItem());
} else { } else {
questData.getPetManager().setSelectedPet(null); QuestMainPanel.this.questData.getPetManager().setSelectedPet(null);
} }
petComboBox.setEnabled(petCheckBox.isSelected()); QuestMainPanel.this.petComboBox.setEnabled(QuestMainPanel.this.petCheckBox.isSelected());
} }
}); });
petPanel.add(this.petCheckBox); petPanel.add(this.petCheckBox);
GuiUtils.addGap(petPanel); GuiUtils.addGap(petPanel);
this.petComboBox.addActionListener(new ActionListener() { this.petComboBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent actionEvent) { public void actionPerformed(final ActionEvent actionEvent) {
if (petCheckBox.isSelected()) { if (QuestMainPanel.this.petCheckBox.isSelected()) {
questData.getPetManager().setSelectedPet((String) petComboBox.getSelectedItem()); QuestMainPanel.this.questData.getPetManager().setSelectedPet(
(String) QuestMainPanel.this.petComboBox.getSelectedItem());
} else { } else {
questData.getPetManager().setSelectedPet(null); QuestMainPanel.this.questData.getPetManager().setSelectedPet(null);
} }
} }
}); });
@@ -406,32 +420,35 @@ public class QuestMainPanel extends QuestAbstractPanel {
petPanel.add(this.petComboBox); petPanel.add(this.petComboBox);
this.plantBox.addActionListener(new ActionListener() { this.plantBox.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent actionEvent) { public void actionPerformed(final ActionEvent actionEvent) {
questData.getPetManager().usePlant = plantBox.isSelected(); QuestMainPanel.this.questData.getPetManager().usePlant = QuestMainPanel.this.plantBox.isSelected();
} }
}); });
GuiUtils.addGap(petPanel, 10); GuiUtils.addGap(petPanel, 10);
petPanel.add(this.plantBox); petPanel.add(this.plantBox);
petPanel.setMaximumSize(petPanel.getPreferredSize()); petPanel.setMaximumSize(petPanel.getPreferredSize());
petPanel.setAlignmentX(LEFT_ALIGNMENT); petPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
fantasyPanel.add(petPanel, BorderLayout.WEST); fantasyPanel.add(petPanel, BorderLayout.WEST);
zeppelinButton.addActionListener(new ActionListener() { this.zeppelinButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent actionEvent) { public void actionPerformed(final ActionEvent actionEvent) {
questData.randomizeOpponents(); QuestMainPanel.this.questData.randomizeOpponents();
refreshNextMatchPanel(); QuestMainPanel.this.refreshNextMatchPanel();
QuestItemZeppelin zeppelin = (QuestItemZeppelin) questData.getInventory().getItem("Zeppelin"); final QuestItemZeppelin zeppelin = (QuestItemZeppelin) QuestMainPanel.this.questData.getInventory()
.getItem("Zeppelin");
zeppelin.setZeppelinUsed(true); zeppelin.setZeppelinUsed(true);
zeppelinButton.setEnabled(false); QuestMainPanel.this.zeppelinButton.setEnabled(false);
} }
}); });
zeppelinButton.setMaximumSize(zeppelinButton.getPreferredSize()); this.zeppelinButton.setMaximumSize(this.zeppelinButton.getPreferredSize());
zeppelinPanel.setLayout(new BorderLayout()); this.zeppelinPanel.setLayout(new BorderLayout());
fantasyPanel.add(zeppelinPanel, BorderLayout.EAST); fantasyPanel.add(this.zeppelinPanel, BorderLayout.EAST);
fantasyPanel.setAlignmentX(Component.LEFT_ALIGNMENT); fantasyPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
matchPanel.add(fantasyPanel); matchPanel.add(fantasyPanel);
} }
@@ -448,24 +465,24 @@ public class QuestMainPanel extends QuestAbstractPanel {
* @return a {@link javax.swing.JPanel} object. * @return a {@link javax.swing.JPanel} object.
*/ */
private JPanel createDuelPanel() { private JPanel createDuelPanel() {
JPanel DuelPanel = new JPanel(); final JPanel duelPanel = new JPanel();
QuestDuelPanel duelEvent; QuestDuelPanel duelEvent;
DuelPanel.setLayout(new BoxLayout(DuelPanel, BoxLayout.Y_AXIS)); duelPanel.setLayout(new BoxLayout(duelPanel, BoxLayout.Y_AXIS));
DuelPanel.setBorder(new TitledBorder(new EtchedBorder(), "Available Duels")); duelPanel.setBorder(new TitledBorder(new EtchedBorder(), "Available Duels"));
List<QuestDuel> duels = qem.generateDuels(); final List<QuestDuel> duels = this.qem.generateDuels();
for (QuestDuel qd : duels) { for (final QuestDuel qd : duels) {
duelEvent = new QuestDuelPanel(qd); duelEvent = new QuestDuelPanel(qd);
DuelPanel.add(duelEvent); duelPanel.add(duelEvent);
duelEvent.addMouseListener(new SelectionAdapter(duelEvent)); duelEvent.addMouseListener(new SelectionAdapter(duelEvent));
GuiUtils.addGap(DuelPanel, 3); GuiUtils.addGap(duelPanel, 3);
} }
DuelPanel.setAlignmentX(LEFT_ALIGNMENT); duelPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
return DuelPanel; return duelPanel;
} }
/** /**
@@ -478,23 +495,23 @@ public class QuestMainPanel extends QuestAbstractPanel {
* @return a {@link javax.swing.JPanel} object. * @return a {@link javax.swing.JPanel} object.
*/ */
private JPanel createChallengePanel() { private JPanel createChallengePanel() {
JPanel ChallengePanel = new JPanel(); final JPanel challengePanel = new JPanel();
QuestSelectablePanel selpan; QuestSelectablePanel selpan;
ChallengePanel.setLayout(new BoxLayout(ChallengePanel, BoxLayout.Y_AXIS)); challengePanel.setLayout(new BoxLayout(challengePanel, BoxLayout.Y_AXIS));
ChallengePanel.setBorder(new TitledBorder(new EtchedBorder(), "Available Challenges")); challengePanel.setBorder(new TitledBorder(new EtchedBorder(), "Available Challenges"));
List<QuestChallenge> challenges = qem.generateChallenges(); final List<QuestChallenge> challenges = this.qem.generateChallenges();
for (QuestChallenge qc : challenges) { for (final QuestChallenge qc : challenges) {
selpan = new QuestChallengePanel(qc); selpan = new QuestChallengePanel(qc);
ChallengePanel.add(selpan); challengePanel.add(selpan);
selpan.addMouseListener(new SelectionAdapter(selpan)); selpan.addMouseListener(new SelectionAdapter(selpan));
GuiUtils.addGap(ChallengePanel, 3); GuiUtils.addGap(challengePanel, 3);
} }
return ChallengePanel; return challengePanel;
} }
/** /**
@@ -505,23 +522,24 @@ public class QuestMainPanel extends QuestAbstractPanel {
final void refresh() { final void refresh() {
AllZone.getQuestData().saveData(); AllZone.getQuestData().saveData();
devModeCheckBox.setSelected(Constant.Runtime.DEV_MODE[0]); this.devModeCheckBox.setSelected(Constant.Runtime.DEV_MODE[0]);
smoothLandCheckBox.setSelected(Constant.Runtime.SMOOTH[0]); this.smoothLandCheckBox.setSelected(Constant.Runtime.SMOOTH[0]);
creditsLabel.setText(" " + questData.getCredits()); this.creditsLabel.setText(" " + this.questData.getCredits());
statsLabel.setText(questData.getWin() + " wins / " + questData.getLost() + " losses"); this.statsLabel.setText(this.questData.getWin() + " wins / " + this.questData.getLost() + " losses");
titleLabel.setText(questData.getRank()); this.titleLabel.setText(this.questData.getRank());
// copy lastUsedDeck as removal triggers selection change. // copy lastUsedDeck as removal triggers selection change.
String lastUsedDeck = QuestMainPanel.lastUsedDeck; final String lastUsedDeck = QuestMainPanel.lastUsedDeck;
deckComboBox.removeAllItems(); this.deckComboBox.removeAllItems();
if (questData.getDeckNames().size() > 0) { if (this.questData.getDeckNames().size() > 0) {
deckComboBox.setEnabled(true); this.deckComboBox.setEnabled(true);
List<String> deckNames = new ArrayList<String>(questData.getDeckNames()); final List<String> deckNames = new ArrayList<String>(this.questData.getDeckNames());
Collections.sort(deckNames, new Comparator<String>() { Collections.sort(deckNames, new Comparator<String>() {
@Override
public int compare(final String s, final String s1) { public int compare(final String s, final String s1) {
return s.compareToIgnoreCase(s1); return s.compareToIgnoreCase(s1);
} }
@@ -532,73 +550,73 @@ public class QuestMainPanel extends QuestAbstractPanel {
deckNames.add(0, lastUsedDeck); deckNames.add(0, lastUsedDeck);
} }
for (String deckName : deckNames) { for (final String deckName : deckNames) {
deckComboBox.addItem(deckName); this.deckComboBox.addItem(deckName);
} }
} else { } else {
deckComboBox.addItem(NO_DECKS_AVAILABLE); this.deckComboBox.addItem(QuestMainPanel.NO_DECKS_AVAILABLE);
deckComboBox.setEnabled(false); this.deckComboBox.setEnabled(false);
} }
deckComboBox.setMinimumSize(new Dimension(150, 0)); this.deckComboBox.setMinimumSize(new Dimension(150, 0));
eventButton.setEnabled(nextChallengeInWins() == 0); this.eventButton.setEnabled(this.nextChallengeInWins() == 0);
playButton.setEnabled(canGameBeLaunched()); this.playButton.setEnabled(this.canGameBeLaunched());
if (questData.getMode().equals(QuestData.FANTASY)) { if (this.questData.getMode().equals(QuestData.FANTASY)) {
lifeLabel.setText(" " + questData.getLife()); this.lifeLabel.setText(" " + this.questData.getLife());
petComboBox.removeAllItems(); this.petComboBox.removeAllItems();
Set<String> petList = questData.getPetManager().getAvailablePetNames(); final Set<String> petList = this.questData.getPetManager().getAvailablePetNames();
if (petList.size() > 0) { if (petList.size() > 0) {
petComboBox.setEnabled(true); this.petComboBox.setEnabled(true);
petCheckBox.setEnabled(true); this.petCheckBox.setEnabled(true);
for (String aPetList : petList) { for (final String aPetList : petList) {
petComboBox.addItem(aPetList); this.petComboBox.addItem(aPetList);
} }
} else { } else {
petComboBox.addItem("No pets available"); this.petComboBox.addItem("No pets available");
petComboBox.setEnabled(false); this.petComboBox.setEnabled(false);
petCheckBox.setEnabled(false); this.petCheckBox.setEnabled(false);
} }
if (!questData.getPetManager().shouldPetBeUsed()) { if (!this.questData.getPetManager().shouldPetBeUsed()) {
petCheckBox.setSelected(false); this.petCheckBox.setSelected(false);
petComboBox.setEnabled(false); this.petComboBox.setEnabled(false);
} else { } else {
petCheckBox.setSelected(true); this.petCheckBox.setSelected(true);
petComboBox.setSelectedItem(questData.getPetManager().getSelectedPet().getName()); this.petComboBox.setSelectedItem(this.questData.getPetManager().getSelectedPet().getName());
} }
this.plantBox.setEnabled(questData.getPetManager().getPlant().getLevel() > 0); this.plantBox.setEnabled(this.questData.getPetManager().getPlant().getLevel() > 0);
this.plantBox.setSelected(questData.getPetManager().shouldPlantBeUsed()); this.plantBox.setSelected(this.questData.getPetManager().shouldPlantBeUsed());
QuestItemZeppelin zeppelin = (QuestItemZeppelin) questData.getInventory().getItem("Zeppelin"); final QuestItemZeppelin zeppelin = (QuestItemZeppelin) this.questData.getInventory().getItem("Zeppelin");
if (zeppelin.getLevel() > 0) { if (zeppelin.getLevel() > 0) {
zeppelinPanel.removeAll(); this.zeppelinPanel.removeAll();
zeppelinPanel.add(zeppelinButton, BorderLayout.CENTER); this.zeppelinPanel.add(this.zeppelinButton, BorderLayout.CENTER);
} }
if (!zeppelin.hasBeenUsed()) { if (!zeppelin.hasBeenUsed()) {
zeppelinButton.setEnabled(true); this.zeppelinButton.setEnabled(true);
} else { } else {
zeppelinButton.setEnabled(false); this.zeppelinButton.setEnabled(false);
} }
} }
if (nextChallengeInWins() > 0) { if (this.nextChallengeInWins() > 0) {
nextQuestLabel.setText("Next challenge in " + nextChallengeInWins() + " Wins."); this.nextQuestLabel.setText("Next challenge in " + this.nextChallengeInWins() + " Wins.");
} else { } else {
nextQuestLabel.setText("Next challenge available now."); this.nextQuestLabel.setText("Next challenge available now.");
} }
nextMatchLayout = new CardLayout(); this.nextMatchLayout = new CardLayout();
refreshNextMatchPanel(); this.refreshNextMatchPanel();
} }
/** /**
@@ -607,15 +625,15 @@ public class QuestMainPanel extends QuestAbstractPanel {
* </p> * </p>
*/ */
private void refreshNextMatchPanel() { private void refreshNextMatchPanel() {
nextMatchPanel.removeAll(); this.nextMatchPanel.removeAll();
nextMatchLayout = new CardLayout(); this.nextMatchLayout = new CardLayout();
nextMatchPanel.setLayout(nextMatchLayout); this.nextMatchPanel.setLayout(this.nextMatchLayout);
nextMatchPanel.add(createDuelPanel(), DUELS); this.nextMatchPanel.add(this.createDuelPanel(), QuestMainPanel.DUELS);
nextMatchPanel.add(createChallengePanel(), CHALLENGES); this.nextMatchPanel.add(this.createChallengePanel(), QuestMainPanel.CHALLENGES);
if (isShowingChallenges) { if (this.isShowingChallenges) {
this.nextMatchLayout.show(nextMatchPanel, CHALLENGES); this.nextMatchLayout.show(this.nextMatchPanel, QuestMainPanel.CHALLENGES);
} else { } else {
this.nextMatchLayout.show(nextMatchPanel, DUELS); this.nextMatchLayout.show(this.nextMatchPanel, QuestMainPanel.DUELS);
} }
} }
@@ -630,22 +648,22 @@ public class QuestMainPanel extends QuestAbstractPanel {
// Number of wins was 25, lowereing the number to 20 to help short term // Number of wins was 25, lowereing the number to 20 to help short term
// questers. // questers.
if (questData.getWin() < 20) { if (this.questData.getWin() < 20) {
return 20 - questData.getWin(); return 20 - this.questData.getWin();
} }
// The int mul has been lowered by one, should face special opps more // The int mul has been lowered by one, should face special opps more
// frequently. // frequently.
int challengesPlayed = questData.getChallengesPlayed(); final int challengesPlayed = this.questData.getChallengesPlayed();
int mul = 5; int mul = 5;
if (questData.getInventory().hasItem("Zeppelin")) { if (this.questData.getInventory().hasItem("Zeppelin")) {
mul = 3; mul = 3;
} else if (questData.getInventory().hasItem("Map")) { } else if (this.questData.getInventory().hasItem("Map")) {
mul = 4; mul = 4;
} }
int delta = (challengesPlayed * mul) - questData.getWin(); final int delta = (challengesPlayed * mul) - this.questData.getWin();
return (delta > 0) ? delta : 0; return (delta > 0) ? delta : 0;
} }
@@ -656,9 +674,10 @@ public class QuestMainPanel extends QuestAbstractPanel {
* </p> * </p>
*/ */
final void showDeckEditor() { final void showDeckEditor() {
Command exit = new Command() { final Command exit = new Command() {
private static final long serialVersionUID = -5110231879431074581L; private static final long serialVersionUID = -5110231879431074581L;
@Override
public void execute() { public void execute() {
// saves all deck data // saves all deck data
AllZone.getQuestData().saveData(); AllZone.getQuestData().saveData();
@@ -667,11 +686,11 @@ public class QuestMainPanel extends QuestAbstractPanel {
} }
}; };
DeckEditorQuest g = new DeckEditorQuest(AllZone.getQuestData()); final DeckEditorQuest g = new DeckEditorQuest(AllZone.getQuestData());
g.show(exit); g.show(exit);
g.setVisible(true); g.setVisible(true);
mainFrame.dispose(); this.getMainFrame().dispose();
} // deck editor button } // deck editor button
/** /**
@@ -680,7 +699,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
* </p> * </p>
*/ */
final void showBazaar() { final void showBazaar() {
mainFrame.showBazaarPane(); this.getMainFrame().showBazaarPane();
} }
/** /**
@@ -689,9 +708,10 @@ public class QuestMainPanel extends QuestAbstractPanel {
* </p> * </p>
*/ */
final void showCardShop() { final void showCardShop() {
Command exit = new Command() { final Command exit = new Command() {
private static final long serialVersionUID = 8567193482568076362L; private static final long serialVersionUID = 8567193482568076362L;
@Override
public void execute() { public void execute() {
// saves all deck data // saves all deck data
AllZone.getQuestData().saveData(); AllZone.getQuestData().saveData();
@@ -700,12 +720,12 @@ public class QuestMainPanel extends QuestAbstractPanel {
} }
}; };
DeckEditorShop g = new DeckEditorShop(questData); final DeckEditorShop g = new DeckEditorShop(this.questData);
g.show(exit); g.show(exit);
g.setVisible(true); g.setVisible(true);
this.mainFrame.dispose(); this.getMainFrame().dispose();
} // card shop button } // card shop button
@@ -719,21 +739,21 @@ public class QuestMainPanel extends QuestAbstractPanel {
// heap usage significantly. // heap usage significantly.
ImageCache.clear(); ImageCache.clear();
QuestItemZeppelin zeppelin = (QuestItemZeppelin) questData.getInventory().getItem("Zeppelin"); final QuestItemZeppelin zeppelin = (QuestItemZeppelin) this.questData.getInventory().getItem("Zeppelin");
zeppelin.setZeppelinUsed(false); zeppelin.setZeppelinUsed(false);
questData.randomizeOpponents(); this.questData.randomizeOpponents();
String humanDeckName = (String) deckComboBox.getSelectedItem(); final String humanDeckName = (String) this.deckComboBox.getSelectedItem();
Deck humanDeck = questData.getDeck(humanDeckName); final Deck humanDeck = this.questData.getDeck(humanDeckName);
Constant.Runtime.HUMAN_DECK[0] = humanDeck; Constant.Runtime.HUMAN_DECK[0] = humanDeck;
moveDeckToTop(humanDeckName); this.moveDeckToTop(humanDeckName);
Constant.Quest.OPP_ICON_NAME[0] = getEventIconFilename(); Constant.Quest.OPP_ICON_NAME[0] = this.getEventIconFilename();
// Dev Mode occurs before Display // Dev Mode occurs before Display
Constant.Runtime.DEV_MODE[0] = devModeCheckBox.isSelected(); Constant.Runtime.DEV_MODE[0] = this.devModeCheckBox.isSelected();
// DO NOT CHANGE THIS ORDER, GuiDisplay needs to be created before cards // DO NOT CHANGE THIS ORDER, GuiDisplay needs to be created before cards
// are added // are added
@@ -743,19 +763,19 @@ public class QuestMainPanel extends QuestAbstractPanel {
// AllZone.setDisplay(new GuiDisplay3()); // AllZone.setDisplay(new GuiDisplay3());
// } // }
Constant.Runtime.SMOOTH[0] = smoothLandCheckBox.isSelected(); Constant.Runtime.SMOOTH[0] = this.smoothLandCheckBox.isSelected();
AllZone.getMatchState().reset(); AllZone.getMatchState().reset();
if (isShowingChallenges) { if (this.isShowingChallenges) {
setupChallenge(humanDeck); this.setupChallenge(humanDeck);
} else { } else {
setupDuel(humanDeck); this.setupDuel(humanDeck);
} }
AllZone.getQuestData().saveData(); AllZone.getQuestData().saveData();
AllZone.getDisplay().setVisible(true); AllZone.getDisplay().setVisible(true);
mainFrame.dispose(); this.getMainFrame().dispose();
} }
/** /**
@@ -767,14 +787,14 @@ public class QuestMainPanel extends QuestAbstractPanel {
* a {@link forge.deck.Deck} object. * a {@link forge.deck.Deck} object.
*/ */
final void setupDuel(final Deck humanDeck) { final void setupDuel(final Deck humanDeck) {
Deck computer = selectedOpponent.getEvent().getEventDeck(); final Deck computer = this.selectedOpponent.getEvent().getEventDeck();
Constant.Runtime.COMPUTER_DECK[0] = computer; Constant.Runtime.COMPUTER_DECK[0] = computer;
QuestDuel selectedDuel = (QuestDuel) selectedOpponent.getEvent(); final QuestDuel selectedDuel = (QuestDuel) this.selectedOpponent.getEvent();
AllZone.setQuestEvent(selectedDuel); AllZone.setQuestEvent(selectedDuel);
AllZone.getGameAction().newGame(humanDeck, computer, QuestUtil.getHumanStartingCards(questData), AllZone.getGameAction().newGame(humanDeck, computer, QuestUtil.getHumanStartingCards(this.questData),
QuestUtil.getComputerStartingCards(questData), questData.getLife(), 20, null); QuestUtil.getComputerStartingCards(this.questData), this.questData.getLife(), 20, null);
} }
/** /**
@@ -786,23 +806,23 @@ public class QuestMainPanel extends QuestAbstractPanel {
* a {@link forge.deck.Deck} object. * a {@link forge.deck.Deck} object.
*/ */
private void setupChallenge(final Deck humanDeck) { private void setupChallenge(final Deck humanDeck) {
QuestChallenge selectedChallenge = (QuestChallenge) selectedOpponent.getEvent(); final QuestChallenge selectedChallenge = (QuestChallenge) this.selectedOpponent.getEvent();
Deck computer = selectedOpponent.getEvent().getEventDeck(); final Deck computer = this.selectedOpponent.getEvent().getEventDeck();
Constant.Runtime.COMPUTER_DECK[0] = computer; Constant.Runtime.COMPUTER_DECK[0] = computer;
AllZone.setQuestEvent(selectedChallenge); AllZone.setQuestEvent(selectedChallenge);
int extraLife = 0; int extraLife = 0;
if (questData.getInventory().getItemLevel("Gear") == 2) { if (this.questData.getInventory().getItemLevel("Gear") == 2) {
extraLife = 3; extraLife = 3;
} }
AllZone.getGameAction().newGame(humanDeck, computer, AllZone.getGameAction().newGame(humanDeck, computer,
QuestUtil.getHumanStartingCards(questData, selectedChallenge), QuestUtil.getHumanStartingCards(this.questData, selectedChallenge),
QuestUtil.getComputerStartingCards(questData, selectedChallenge), questData.getLife() + extraLife, QuestUtil.getComputerStartingCards(this.questData, selectedChallenge),
selectedChallenge.getAILife(), selectedChallenge); this.questData.getLife() + extraLife, selectedChallenge.getAILife(), selectedChallenge);
} }
@@ -814,7 +834,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
private String getEventIconFilename() { private String getEventIconFilename() {
return selectedOpponent.getIconFilename(); return this.selectedOpponent.getIconFilename();
} }
/** /**
@@ -823,21 +843,21 @@ public class QuestMainPanel extends QuestAbstractPanel {
* </p> * </p>
*/ */
final void showChallenges() { final void showChallenges() {
if (isShowingChallenges) { if (this.isShowingChallenges) {
isShowingChallenges = false; this.isShowingChallenges = false;
eventButton.setText("Challenges"); this.eventButton.setText("Challenges");
} else { } else {
isShowingChallenges = true; this.isShowingChallenges = true;
eventButton.setText("Duels"); this.eventButton.setText("Duels");
} }
if (selectedOpponent != null) { if (this.selectedOpponent != null) {
selectedOpponent.setSelected(false); this.selectedOpponent.setSelected(false);
} }
selectedOpponent = null; this.selectedOpponent = null;
refresh(); this.refresh();
} }
/** /**
@@ -846,7 +866,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
class SelectionAdapter extends MouseAdapter { class SelectionAdapter extends MouseAdapter {
/** The selectable panel. */ /** The selectable panel. */
QuestSelectablePanel selectablePanel; private QuestSelectablePanel selectablePanel;
/** /**
* Instantiates a new selection adapter. * Instantiates a new selection adapter.
@@ -868,14 +888,14 @@ public class QuestMainPanel extends QuestAbstractPanel {
@Override @Override
public void mouseClicked(final MouseEvent mouseEvent) { public void mouseClicked(final MouseEvent mouseEvent) {
if (selectedOpponent != null) { if (QuestMainPanel.this.selectedOpponent != null) {
selectedOpponent.setSelected(false); QuestMainPanel.this.selectedOpponent.setSelected(false);
} }
selectablePanel.setSelected(true); this.selectablePanel.setSelected(true);
selectedOpponent = selectablePanel; QuestMainPanel.this.selectedOpponent = this.selectablePanel;
playButton.setEnabled(canGameBeLaunched()); QuestMainPanel.this.playButton.setEnabled(QuestMainPanel.this.canGameBeLaunched());
} }
} }
@@ -900,7 +920,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
* @return a boolean. * @return a boolean.
*/ */
final boolean canGameBeLaunched() { final boolean canGameBeLaunched() {
return !(NO_DECKS_AVAILABLE.equals(deckComboBox.getSelectedItem()) || selectedOpponent == null); return !(QuestMainPanel.NO_DECKS_AVAILABLE.equals(this.deckComboBox.getSelectedItem()) || (this.selectedOpponent == null));
} }
/** {@inheritDoc} */ /** {@inheritDoc} */

View File

@@ -42,29 +42,29 @@ public class QuestOptions extends JFrame {
/** Constant <code>serialVersionUID=2018518804206822235L</code>. */ /** Constant <code>serialVersionUID=2018518804206822235L</code>. */
private static final long serialVersionUID = 2018518804206822235L; private static final long serialVersionUID = 2018518804206822235L;
private QuestData questData = new QuestData(); private final QuestData questData = new QuestData();
private JLabel jLabel1 = new JLabel(); private final JLabel jLabel1 = new JLabel();
private JButton continueQuestButton = new JButton(); private final JButton continueQuestButton = new JButton();
private JPanel jPanel1 = new JPanel(); private final JPanel jPanel1 = new JPanel();
private JPanel jPanel2 = new JPanel(); private final JPanel jPanel2 = new JPanel();
private GridLayout gridLayout1 = new GridLayout(); private final GridLayout gridLayout1 = new GridLayout();
private JRadioButton easyRadio = new JRadioButton(); private final JRadioButton easyRadio = new JRadioButton();
private JRadioButton hardRadio = new JRadioButton(); private final JRadioButton hardRadio = new JRadioButton();
private JRadioButton mediumRadio = new JRadioButton(); private final JRadioButton mediumRadio = new JRadioButton();
private JRadioButton veryHardRadio = new JRadioButton(); private final JRadioButton veryHardRadio = new JRadioButton();
private JRadioButton fantasyRadio = new JRadioButton(); private final JRadioButton fantasyRadio = new JRadioButton();
private JRadioButton realisticRadio = new JRadioButton(); private final JRadioButton realisticRadio = new JRadioButton();
private JCheckBox cbStandardStart = new JCheckBox(); private final JCheckBox cbStandardStart = new JCheckBox();
private JButton newQuestButton = new JButton(); private final JButton newQuestButton = new JButton();
private JTextArea jTextArea1 = new JTextArea(); private final JTextArea jTextArea1 = new JTextArea();
private ButtonGroup buttonGroup1 = new ButtonGroup(); private final ButtonGroup buttonGroup1 = new ButtonGroup();
private ButtonGroup buttonGroup2 = new ButtonGroup(); private final ButtonGroup buttonGroup2 = new ButtonGroup();
private JPanel jPanel3 = new JPanel(); private final JPanel jPanel3 = new JPanel();
/** /**
* <p> * <p>
@@ -73,17 +73,17 @@ public class QuestOptions extends JFrame {
*/ */
public QuestOptions() { public QuestOptions() {
try { try {
jbInit(); this.jbInit();
} catch (Exception ex) { } catch (final Exception ex) {
ErrorViewer.showError(ex); ErrorViewer.showError(ex);
} }
setup(); this.setup();
setupRadioButtonText(); this.setupRadioButtonText();
this.setSize(540, 555); this.setSize(540, 555);
GuiUtils.centerFrame(this); GuiUtils.centerFrame(this);
setVisible(true); this.setVisible(true);
} }
/** /**
@@ -93,7 +93,7 @@ public class QuestOptions extends JFrame {
*/ */
private void setup() { private void setup() {
// make the text look correct on the screen // make the text look correct on the screen
jTextArea1.setBackground(getBackground()); this.jTextArea1.setBackground(this.getBackground());
// if user closes this window, go back to "New Game" screen // if user closes this window, go back to "New Game" screen
this.addWindowListener(new WindowAdapter() { this.addWindowListener(new WindowAdapter() {
@@ -103,7 +103,7 @@ public class QuestOptions extends JFrame {
if (System.getenv("NG2") != null) { if (System.getenv("NG2") != null) {
if (System.getenv("NG2").equalsIgnoreCase("true")) { if (System.getenv("NG2").equalsIgnoreCase("true")) {
String argz[] = {}; final String[] argz = {};
Gui_HomeScreen.main(argz); Gui_HomeScreen.main(argz);
} else { } else {
new OldGuiNewGame(); new OldGuiNewGame();
@@ -116,8 +116,8 @@ public class QuestOptions extends JFrame {
}); });
// is there any saved data? // is there any saved data?
if (!questData.hasSaveFile()) { if (!this.questData.hasSaveFile()) {
continueQuestButton.setEnabled(false); this.continueQuestButton.setEnabled(false);
} }
} // setup() } // setup()
@@ -128,13 +128,13 @@ public class QuestOptions extends JFrame {
* </p> * </p>
*/ */
private void setupRadioButtonText() { private void setupRadioButtonText() {
String[] diff = QuestPreferences.getDifficulty(); final String[] diff = QuestPreferences.getDifficulty();
JRadioButton[] b = {easyRadio, mediumRadio, hardRadio, veryHardRadio}; final JRadioButton[] b = { this.easyRadio, this.mediumRadio, this.hardRadio, this.veryHardRadio };
for (int i = 0; i < diff.length; i++) { for (int i = 0; i < diff.length; i++) {
// -2 because you start a level 1, and the last level is secret // -2 because you start a level 1, and the last level is secret
int numberLevels = QuestData.RANK_TITLES.length - 2; final int numberLevels = QuestData.RANK_TITLES.length - 2;
int numGames = numberLevels * QuestPreferences.getWinsForRankIncrease(i); final int numGames = numberLevels * QuestPreferences.getWinsForRankIncrease(i);
b[i].setText(String.format("%s - %d", diff[i], numGames)); b[i].setText(String.format("%s - %d", diff[i], numGames));
} }
@@ -150,56 +150,58 @@ public class QuestOptions extends JFrame {
* if any. * if any.
*/ */
private void jbInit() throws Exception { private void jbInit() throws Exception {
TitledBorder titledBorder1 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white, new Color(148, 145, final TitledBorder titledBorder1 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white, new Color(
140)), "Quest Length"); 148, 145, 140)), "Quest Length");
Border border2 = BorderFactory.createEtchedBorder(Color.white, new Color(148, 145, 140)); final Border border2 = BorderFactory.createEtchedBorder(Color.white, new Color(148, 145, 140));
TitledBorder titledBorder2 = new TitledBorder(border2, "Continue"); final TitledBorder titledBorder2 = new TitledBorder(border2, "Continue");
jLabel1.setFont(new java.awt.Font("Dialog", 0, 25)); this.jLabel1.setFont(new java.awt.Font("Dialog", 0, 25));
jLabel1.setHorizontalAlignment(SwingConstants.CENTER); this.jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
jLabel1.setText("Quest Options"); this.jLabel1.setText("Quest Options");
jLabel1.setBounds(new Rectangle(1, 0, 539, 63)); this.jLabel1.setBounds(new Rectangle(1, 0, 539, 63));
this.setTitle("Quest Options"); this.setTitle("Quest Options");
this.getContentPane().setLayout(null); this.getContentPane().setLayout(null);
continueQuestButton.setBounds(new Rectangle(69, 28, 179, 35)); this.continueQuestButton.setBounds(new Rectangle(69, 28, 179, 35));
continueQuestButton.setFont(new java.awt.Font("Dialog", 0, 18)); this.continueQuestButton.setFont(new java.awt.Font("Dialog", 0, 18));
continueQuestButton.setText("Continue Quest"); this.continueQuestButton.setText("Continue Quest");
continueQuestButton.addActionListener(new java.awt.event.ActionListener() { this.continueQuestButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) { public void actionPerformed(final ActionEvent e) {
continueQuestButton_actionPerformed(e); QuestOptions.this.continueQuestButtonActionPerformed(e);
} }
}); });
jPanel1.setBorder(titledBorder1); this.jPanel1.setBorder(titledBorder1);
jPanel1.setBounds(new Rectangle(20, 63, 500, 353)); this.jPanel1.setBounds(new Rectangle(20, 63, 500, 353));
jPanel1.setLayout(null); this.jPanel1.setLayout(null);
jPanel2.setBounds(new Rectangle(20, 27, 460, 101)); this.jPanel2.setBounds(new Rectangle(20, 27, 460, 101));
jPanel2.setLayout(gridLayout1); this.jPanel2.setLayout(this.gridLayout1);
gridLayout1.setColumns(2); this.gridLayout1.setColumns(2);
gridLayout1.setRows(4); this.gridLayout1.setRows(4);
easyRadio.setText("Easy - 50 games"); this.easyRadio.setText("Easy - 50 games");
mediumRadio.setText("Medium - 100 games"); this.mediumRadio.setText("Medium - 100 games");
hardRadio.setText("Hard - 200 games"); this.hardRadio.setText("Hard - 200 games");
veryHardRadio.setText("Very Hard - 300 games"); this.veryHardRadio.setText("Very Hard - 300 games");
realisticRadio.setText("Realistic"); this.realisticRadio.setText("Realistic");
fantasyRadio.setText("Fantasy"); this.fantasyRadio.setText("Fantasy");
easyRadio.setSelected(true); this.easyRadio.setSelected(true);
realisticRadio.setSelected(true); this.realisticRadio.setSelected(true);
cbStandardStart.setText("Standard (Type 2) Starting Pool"); this.cbStandardStart.setText("Standard (Type 2) Starting Pool");
newQuestButton.setBounds(new Rectangle(179, 292, 140, 38)); this.newQuestButton.setBounds(new Rectangle(179, 292, 140, 38));
newQuestButton.setFont(new java.awt.Font("Dialog", 0, 16)); this.newQuestButton.setFont(new java.awt.Font("Dialog", 0, 16));
newQuestButton.setText("New Quest"); this.newQuestButton.setText("New Quest");
newQuestButton.addActionListener(new java.awt.event.ActionListener() { this.newQuestButton.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) { public void actionPerformed(final ActionEvent e) {
newQuestButton_actionPerformed(e); QuestOptions.this.newQuestButtonActionPerformed(e);
} }
}); });
StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append("New Quest will delete your current player decks, credits and win loss record. "); sb.append("New Quest will delete your current player decks, credits and win loss record. ");
sb.append("Continue Quest will allow you to continue a quest that you started at an earlier time."); sb.append("Continue Quest will allow you to continue a quest that you started at an earlier time.");
sb.append("\r\n"); sb.append("\r\n");
@@ -207,44 +209,44 @@ public class QuestOptions extends JFrame {
sb.append("Realistic is the original quest mode with a new feature, the Card Shop. "); sb.append("Realistic is the original quest mode with a new feature, the Card Shop. ");
sb.append("Fantasy adds a Bazaar and the occasional fantasy themed opponent for you to battle."); sb.append("Fantasy adds a Bazaar and the occasional fantasy themed opponent for you to battle.");
jTextArea1.setBorder(BorderFactory.createEtchedBorder(Color.white, new Color(148, 145, 140))); this.jTextArea1.setBorder(BorderFactory.createEtchedBorder(Color.white, new Color(148, 145, 140)));
jTextArea1.setEnabled(false); this.jTextArea1.setEnabled(false);
jTextArea1.setFont(new java.awt.Font("Dialog", 0, 12)); this.jTextArea1.setFont(new java.awt.Font("Dialog", 0, 12));
jTextArea1.setDisabledTextColor(Color.black); this.jTextArea1.setDisabledTextColor(Color.black);
jTextArea1.setEditable(false); this.jTextArea1.setEditable(false);
// jTextArea1.setText("Note: Starting a new quest will delete your current quest data"); // jTextArea1.setText("Note: Starting a new quest will delete your current quest data");
jTextArea1.setText(sb.toString()); this.jTextArea1.setText(sb.toString());
jTextArea1.setLineWrap(true); this.jTextArea1.setLineWrap(true);
jTextArea1.setWrapStyleWord(true); this.jTextArea1.setWrapStyleWord(true);
jTextArea1.setBounds(new Rectangle(86, 145, 327, 128)); this.jTextArea1.setBounds(new Rectangle(86, 145, 327, 128));
jPanel3.setBorder(titledBorder2); this.jPanel3.setBorder(titledBorder2);
jPanel3.setBounds(new Rectangle(110, 427, 323, 86)); this.jPanel3.setBounds(new Rectangle(110, 427, 323, 86));
jPanel3.setLayout(null); this.jPanel3.setLayout(null);
jPanel2.add(easyRadio, null); this.jPanel2.add(this.easyRadio, null);
jPanel2.add(realisticRadio, null); this.jPanel2.add(this.realisticRadio, null);
jPanel2.add(mediumRadio, null); this.jPanel2.add(this.mediumRadio, null);
jPanel2.add(fantasyRadio, null); this.jPanel2.add(this.fantasyRadio, null);
jPanel2.add(hardRadio, null); this.jPanel2.add(this.hardRadio, null);
jPanel2.add(new JLabel("")); // for empty cell this.jPanel2.add(new JLabel("")); // for empty cell
jPanel2.add(veryHardRadio, null); this.jPanel2.add(this.veryHardRadio, null);
jPanel2.add(cbStandardStart, null); this.jPanel2.add(this.cbStandardStart, null);
jPanel1.add(newQuestButton, null); this.jPanel1.add(this.newQuestButton, null);
jPanel1.add(jTextArea1, null); this.jPanel1.add(this.jTextArea1, null);
this.getContentPane().add(jPanel1, null); this.getContentPane().add(this.jPanel1, null);
this.getContentPane().add(jPanel3, null); this.getContentPane().add(this.jPanel3, null);
jPanel3.add(continueQuestButton, null); this.jPanel3.add(this.continueQuestButton, null);
this.getContentPane().add(jLabel1, null); this.getContentPane().add(this.jLabel1, null);
jPanel1.add(jPanel2, null); this.jPanel1.add(this.jPanel2, null);
buttonGroup1.add(easyRadio); this.buttonGroup1.add(this.easyRadio);
buttonGroup1.add(mediumRadio); this.buttonGroup1.add(this.mediumRadio);
buttonGroup1.add(hardRadio); this.buttonGroup1.add(this.hardRadio);
buttonGroup1.add(veryHardRadio); this.buttonGroup1.add(this.veryHardRadio);
buttonGroup2.add(realisticRadio); this.buttonGroup2.add(this.realisticRadio);
buttonGroup2.add(fantasyRadio); this.buttonGroup2.add(this.fantasyRadio);
} }
@@ -256,11 +258,11 @@ public class QuestOptions extends JFrame {
* @param e * @param e
* a {@link java.awt.event.ActionEvent} object. * a {@link java.awt.event.ActionEvent} object.
*/ */
final void continueQuestButton_actionPerformed(final ActionEvent e) { final void continueQuestButtonActionPerformed(final ActionEvent e) {
// set global variable // set global variable
AllZone.setQuestData(QuestDataIO.loadData()); AllZone.setQuestData(QuestDataIO.loadData());
AllZone.getQuestData().guessDifficultyIndex(); AllZone.getQuestData().guessDifficultyIndex();
dispose(); this.dispose();
new QuestFrame(); new QuestFrame();
@@ -274,29 +276,29 @@ public class QuestOptions extends JFrame {
* @param e * @param e
* a {@link java.awt.event.ActionEvent} object. * a {@link java.awt.event.ActionEvent} object.
*/ */
final void newQuestButton_actionPerformed(final ActionEvent e) { final void newQuestButtonActionPerformed(final ActionEvent e) {
int difficulty = 0; int difficulty = 0;
String mode = fantasyRadio.isSelected() ? forge.quest.data.QuestData.FANTASY final String mode = this.fantasyRadio.isSelected() ? forge.quest.data.QuestData.FANTASY
: forge.quest.data.QuestData.REALISTIC; : forge.quest.data.QuestData.REALISTIC;
if (easyRadio.isSelected()) { if (this.easyRadio.isSelected()) {
difficulty = 0; difficulty = 0;
} else if (mediumRadio.isSelected()) { } else if (this.mediumRadio.isSelected()) {
difficulty = 1; difficulty = 1;
} else if (hardRadio.isSelected()) { } else if (this.hardRadio.isSelected()) {
difficulty = 2; difficulty = 2;
} else if (veryHardRadio.isSelected()) { } else if (this.veryHardRadio.isSelected()) {
difficulty = 3; difficulty = 3;
} else { } else {
// user didn't select a difficulty{ // user didn't select a difficulty{
return; return;
} }
if (questData.hasSaveFile()) { if (this.questData.hasSaveFile()) {
// this will overwrite your save file! // this will overwrite your save file!
Object[] possibleValues = {"Yes", "No"}; final Object[] possibleValues = { "Yes", "No" };
Object choice = JOptionPane.showOptionDialog(null, final Object choice = JOptionPane.showOptionDialog(null,
"Starting a new quest will overwrite your current quest. Continue?", "Start New Quest?", "Starting a new quest will overwrite your current quest. Continue?", "Start New Quest?",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, possibleValues, possibleValues[1]); JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, possibleValues, possibleValues[1]);
@@ -306,14 +308,14 @@ public class QuestOptions extends JFrame {
} }
// give the user a few cards to build a deck // give the user a few cards to build a deck
questData.newGame(difficulty, mode, cbStandardStart.isSelected()); this.questData.newGame(difficulty, mode, this.cbStandardStart.isSelected());
questData.saveData(); this.questData.saveData();
// set global variable // set global variable
AllZone.setQuestData(questData); AllZone.setQuestData(this.questData);
dispose(); this.dispose();
new QuestFrame(); new QuestFrame();
} }

View File

@@ -1,7 +1,6 @@
package forge.quest.gui; package forge.quest.gui;
import static java.util.Collections.unmodifiableList; import java.util.Collections;
import java.util.List; import java.util.List;
import javax.swing.AbstractListModel; import javax.swing.AbstractListModel;
@@ -28,12 +27,12 @@ import forge.item.CardPrinted;
public class QuestWinLoseCardViewer extends JPanel { public class QuestWinLoseCardViewer extends JPanel {
// Data and number of choices for the list // Data and number of choices for the list
private List<CardPrinted> list; private final List<CardPrinted> list;
// initialized before; listeners may be added to it // initialized before; listeners may be added to it
private JList jList; private final JList jList;
private CardDetailPanel detail; private final CardDetailPanel detail;
private CardPicturePanel picture; private final CardPicturePanel picture;
/** /**
* Instantiates a new quest win lose card viewer. * Instantiates a new quest win lose card viewer.
@@ -42,57 +41,60 @@ public class QuestWinLoseCardViewer extends JPanel {
* the list * the list
*/ */
public QuestWinLoseCardViewer(final List<CardPrinted> list) { public QuestWinLoseCardViewer(final List<CardPrinted> list) {
this.list = unmodifiableList(list); this.list = Collections.unmodifiableList(list);
jList = new JList(new ChooserListModel()); this.jList = new JList(new ChooserListModel());
detail = new CardDetailPanel(null); this.detail = new CardDetailPanel(null);
picture = new CardPicturePanel(null); this.picture = new CardPicturePanel(null);
this.add(new JScrollPane(jList)); this.add(new JScrollPane(this.jList));
this.add(picture); this.add(this.picture);
this.add(detail); this.add(this.detail);
this.setLayout(new java.awt.GridLayout(1, 3, 6, 0)); this.setLayout(new java.awt.GridLayout(1, 3, 6, 0));
// selection is here // selection is here
jList.getSelectionModel().addListSelectionListener(new SelListener()); this.jList.getSelectionModel().addListSelectionListener(new SelListener());
jList.setSelectedIndex(0); this.jList.setSelectedIndex(0);
} }
private class ChooserListModel extends AbstractListModel { private class ChooserListModel extends AbstractListModel {
private static final long serialVersionUID = 3871965346333840556L; private static final long serialVersionUID = 3871965346333840556L;
@Override
public int getSize() { public int getSize() {
return list.size(); return QuestWinLoseCardViewer.this.list.size();
} }
@Override
public Object getElementAt(final int index) { public Object getElementAt(final int index) {
return list.get(index); return QuestWinLoseCardViewer.this.list.get(index);
} }
} }
private class SelListener implements ListSelectionListener { private class SelListener implements ListSelectionListener {
private Card[] cache = null; private Card[] cache = null;
@Override
public void valueChanged(final ListSelectionEvent e) { public void valueChanged(final ListSelectionEvent e) {
int row = jList.getSelectedIndex(); final int row = QuestWinLoseCardViewer.this.jList.getSelectedIndex();
// (String) jList.getSelectedValue(); // (String) jList.getSelectedValue();
if (row >= 0 && row < list.size()) { if ((row >= 0) && (row < QuestWinLoseCardViewer.this.list.size())) {
CardPrinted cp = list.get(row); final CardPrinted cp = QuestWinLoseCardViewer.this.list.get(row);
ensureCacheHas(row, cp); this.ensureCacheHas(row, cp);
detail.setCard(cache[row]); QuestWinLoseCardViewer.this.detail.setCard(this.cache[row]);
picture.setCard(cp); QuestWinLoseCardViewer.this.picture.setCard(cp);
} }
} }
private void ensureCacheHas(final int row, final CardPrinted cp) { private void ensureCacheHas(final int row, final CardPrinted cp) {
if (cache == null) { if (this.cache == null) {
cache = new Card[list.size()]; this.cache = new Card[QuestWinLoseCardViewer.this.list.size()];
} }
if (null == cache[row]) { if (null == this.cache[row]) {
Card card = AllZone.getCardFactory().getCard(cp.getName(), null); final Card card = AllZone.getCardFactory().getCard(cp.getName(), null);
card.setCurSetCode(cp.getSet()); card.setCurSetCode(cp.getSet());
card.setImageFilename(CardUtil.buildFilename(card)); card.setImageFilename(CardUtil.buildFilename(card));
cache[row] = card; this.cache[row] = card;
} }
} }
} }

View File

@@ -44,32 +44,32 @@ import forge.view.swing.WinLoseModeHandler;
* *
*/ */
public class QuestWinLoseHandler extends WinLoseModeHandler { public class QuestWinLoseHandler extends WinLoseModeHandler {
private boolean wonMatch; private final boolean wonMatch;
private ImageIcon icoTemp; private ImageIcon icoTemp;
private JLabel lblTemp1; private JLabel lblTemp1;
private JLabel lblTemp2; private JLabel lblTemp2;
/** The spacer. */ /** The spacer. */
int spacer = 50; private int spacer = 50;
private class CommonObjects { private class CommonObjects {
public QuestMatchState qMatchState; private QuestMatchState qMatchState;
public QuestData qData; private QuestData qData;
public QuestEvent qEvent; private QuestEvent qEvent;
} }
private CommonObjects model; private final CommonObjects model;
/** /**
* Instantiates a new quest win lose handler. * Instantiates a new quest win lose handler.
*/ */
public QuestWinLoseHandler() { public QuestWinLoseHandler() {
super(); super();
model = new CommonObjects(); this.model = new CommonObjects();
model.qMatchState = AllZone.getMatchState(); this.model.qMatchState = AllZone.getMatchState();
model.qData = AllZone.getQuestData(); this.model.qData = AllZone.getQuestData();
model.qEvent = AllZone.getQuestEvent(); this.model.qEvent = AllZone.getQuestEvent();
wonMatch = model.qMatchState.isMatchWonBy(AllZone.getHumanPlayer().getName()); this.wonMatch = this.model.qMatchState.isMatchWonBy(AllZone.getHumanPlayer().getName());
} }
/** /**
@@ -84,23 +84,23 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
if (Constant.Quest.FANTASY_QUEST[0]) { if (Constant.Quest.FANTASY_QUEST[0]) {
int extraLife = 0; int extraLife = 0;
if (model.qEvent.getEventType().equals("challenge")) { if (this.model.qEvent.getEventType().equals("challenge")) {
if (model.qData.getInventory().hasItem("Zeppelin")) { if (this.model.qData.getInventory().hasItem("Zeppelin")) {
extraLife = 3; extraLife = 3;
} }
} }
CardList humanList = QuestUtil.getHumanStartingCards(model.qData, model.qEvent); final CardList humanList = QuestUtil.getHumanStartingCards(this.model.qData, this.model.qEvent);
CardList computerList = QuestUtil.getComputerStartingCards(model.qData, model.qEvent); final CardList computerList = QuestUtil.getComputerStartingCards(this.model.qData, this.model.qEvent);
int humanLife = model.qData.getLife() + extraLife; final int humanLife = this.model.qData.getLife() + extraLife;
int computerLife = 20; int computerLife = 20;
if (model.qEvent.getEventType().equals("challenge")) { if (this.model.qEvent.getEventType().equals("challenge")) {
computerLife = ((QuestChallenge) model.qEvent).getAILife(); computerLife = ((QuestChallenge) this.model.qEvent).getAILife();
} }
AllZone.getGameAction().newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0], humanList, AllZone.getGameAction().newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0],
computerList, humanLife, computerLife, model.qEvent); humanList, computerList, humanLife, computerLife, this.model.qEvent);
} else { } else {
super.startNextRound(); super.startNextRound();
} }
@@ -117,57 +117,57 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
*/ */
@Override @Override
public final boolean populateCustomPanel() { public final boolean populateCustomPanel() {
view.btnRestart.setVisible(false); this.view.btnRestart.setVisible(false);
model.qData.getCards().resetNewList(); this.model.qData.getCards().resetNewList();
if (!model.qMatchState.isMatchOver()) { if (!this.model.qMatchState.isMatchOver()) {
view.btnQuit.setText("Quit (15 Credits)"); this.view.btnQuit.setText("Quit (15 Credits)");
return false; return false;
} else { } else {
view.btnContinue.setVisible(false); this.view.btnContinue.setVisible(false);
if (wonMatch) { if (this.wonMatch) {
view.btnQuit.setText("Great!"); this.view.btnQuit.setText("Great!");
} else { } else {
view.btnQuit.setText("OK"); this.view.btnQuit.setText("OK");
} }
} }
// Win case // Win case
if (wonMatch) { if (this.wonMatch) {
// Standard event reward credits // Standard event reward credits
awardEventCredits(); this.awardEventCredits();
// Challenge reward credits // Challenge reward credits
if (model.qEvent.getEventType().equals("challenge")) { if (this.model.qEvent.getEventType().equals("challenge")) {
awardChallengeWin(); this.awardChallengeWin();
} }
// Random rare given at 50% chance (65% with luck upgrade) // Random rare given at 50% chance (65% with luck upgrade)
if (getLuckyCoinResult()) { if (this.getLuckyCoinResult()) {
awardRandomRare("You've won a random rare."); this.awardRandomRare("You've won a random rare.");
} }
// Random rare for winning against a very hard deck // Random rare for winning against a very hard deck
if (model.qData.getDifficultyIndex() == 4) { if (this.model.qData.getDifficultyIndex() == 4) {
awardRandomRare("You've won a random rare for winning against a very hard deck."); this.awardRandomRare("You've won a random rare for winning against a very hard deck.");
} }
// Award jackpot every 80 games won (currently 10 rares) // Award jackpot every 80 games won (currently 10 rares)
int wins = model.qData.getWin(); final int wins = this.model.qData.getWin();
if (wins > 0 && wins % 80 == 0) { if ((wins > 0) && ((wins % 80) == 0)) {
awardJackpot(); this.awardJackpot();
} }
} }
// Lose case // Lose case
else { else {
penalizeLoss(); this.penalizeLoss();
} }
// Win or lose, still a chance to win a booster, frequency set in // Win or lose, still a chance to win a booster, frequency set in
// preferences // preferences
int outcome = wonMatch ? model.qData.getWin() : model.qData.getLost(); final int outcome = this.wonMatch ? this.model.qData.getWin() : this.model.qData.getLost();
if (outcome % QuestPreferences.getWinsForBooster(model.qData.getDifficultyIndex()) == 0) { if ((outcome % QuestPreferences.getWinsForBooster(this.model.qData.getDifficultyIndex())) == 0) {
awardBooster(); this.awardBooster();
} }
return true; return true;
@@ -184,23 +184,23 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
@Override @Override
public final void actionOnQuit() { public final void actionOnQuit() {
// Record win/loss in quest data // Record win/loss in quest data
if (wonMatch) { if (this.wonMatch) {
model.qData.addWin(); this.model.qData.addWin();
} else { } else {
model.qData.addLost(); this.model.qData.addLost();
model.qData.subtractCredits(15); this.model.qData.subtractCredits(15);
} }
model.qData.getCards().clearShopList(); this.model.qData.getCards().clearShopList();
if (model.qData.getAvailableChallenges() != null) { if (this.model.qData.getAvailableChallenges() != null) {
model.qData.clearAvailableChallenges(); this.model.qData.clearAvailableChallenges();
} }
model.qMatchState.reset(); this.model.qMatchState.reset();
AllZone.setQuestEvent(null); AllZone.setQuestEvent(null);
model.qData.saveData(); this.model.qData.saveData();
new QuestFrame(); new QuestFrame();
} }
@@ -214,7 +214,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
*/ */
private void awardEventCredits() { private void awardEventCredits() {
// TODO use q.qdPrefs to write bonus credits in prefs file // TODO use q.qdPrefs to write bonus credits in prefs file
StringBuilder sb = new StringBuilder("<html>"); final StringBuilder sb = new StringBuilder("<html>");
int credTotal = 0; int credTotal = 0;
int credBase = 0; int credBase = 0;
@@ -223,7 +223,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
int credEstates = 0; int credEstates = 0;
// Basic win bonus // Basic win bonus
int base = QuestPreferences.getMatchRewardBase(); final int base = QuestPreferences.getMatchRewardBase();
double multiplier = 1; double multiplier = 1;
String diff = AllZone.getQuestEvent().getDifficulty(); String diff = AllZone.getQuestEvent().getDifficulty();
@@ -238,21 +238,22 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
} else if (diff.equalsIgnoreCase("expert")) { } else if (diff.equalsIgnoreCase("expert")) {
multiplier = 3; multiplier = 3;
} }
credBase += (int) (base * multiplier + (QuestPreferences.getMatchRewardTotalWins() * model.qData.getWin())); credBase += (int) ((base * multiplier) + (QuestPreferences.getMatchRewardTotalWins() * this.model.qData
.getWin()));
sb.append(diff + " opponent: " + credBase + " credits.<br>"); sb.append(diff + " opponent: " + credBase + " credits.<br>");
// Gameplay bonuses (for each game win) // Gameplay bonuses (for each game win)
boolean hasNeverLost = true; boolean hasNeverLost = true;
Player computer = AllZone.getComputerPlayer(); final Player computer = AllZone.getComputerPlayer();
for (GameSummary game : model.qMatchState.getGamesPlayed()) { for (final GameSummary game : this.model.qMatchState.getGamesPlayed()) {
if (game.isWinner(computer.getName())) { if (game.isWinner(computer.getName())) {
hasNeverLost = false; hasNeverLost = false;
continue; // no rewards for losing a game continue; // no rewards for losing a game
} }
// Alternate win // Alternate win
GamePlayerRating aiRating = game.getPlayerRating(computer.getName()); final GamePlayerRating aiRating = game.getPlayerRating(computer.getName());
GamePlayerRating humanRating = game.getPlayerRating(AllZone.getHumanPlayer().getName()); final GamePlayerRating humanRating = game.getPlayerRating(AllZone.getHumanPlayer().getName());
GameLossReason whyAiLost = aiRating.getLossReason(); final GameLossReason whyAiLost = aiRating.getLossReason();
int altReward = getCreditsRewardForAltWin(whyAiLost); final int altReward = this.getCreditsRewardForAltWin(whyAiLost);
if (altReward > 0) { if (altReward > 0) {
String winConditionName = "Unknown (bug)"; String winConditionName = "Unknown (bug)";
@@ -279,8 +280,8 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
winConditionName, 50)); winConditionName, 50));
} }
// Mulligan to zero // Mulligan to zero
int cntCardsHumanStartedWith = humanRating.getOpeningHandSize(); final int cntCardsHumanStartedWith = humanRating.getOpeningHandSize();
int mulliganReward = QuestPreferences.getMatchMullToZero(); final int mulliganReward = QuestPreferences.getMatchMullToZero();
if (0 == cntCardsHumanStartedWith) { if (0 == cntCardsHumanStartedWith) {
credGameplay += mulliganReward; credGameplay += mulliganReward;
@@ -289,8 +290,8 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
} }
// Early turn bonus // Early turn bonus
int winTurn = game.getTurnGameEnded(); final int winTurn = game.getTurnGameEnded();
int turnCredits = getCreditsRewardForWinByTurn(winTurn); final int turnCredits = this.getCreditsRewardForWinByTurn(winTurn);
if (winTurn == 0) { if (winTurn == 0) {
System.err.println("QuestWinLoseHandler > " + "turn calculation error: Zero turn win"); System.err.println("QuestWinLoseHandler > " + "turn calculation error: Zero turn win");
@@ -313,13 +314,13 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
// Undefeated bonus // Undefeated bonus
if (hasNeverLost) { if (hasNeverLost) {
credUndefeated += QuestPreferences.getMatchRewardNoLosses(); credUndefeated += QuestPreferences.getMatchRewardNoLosses();
int reward = QuestPreferences.getMatchRewardNoLosses(); final int reward = QuestPreferences.getMatchRewardNoLosses();
sb.append(String.format("You have not lost once! " + "Bonus: %d credits.<br>", reward)); sb.append(String.format("You have not lost once! " + "Bonus: %d credits.<br>", reward));
} }
// Estates bonus // Estates bonus
credTotal = credBase + credGameplay + credUndefeated; credTotal = credBase + credGameplay + credUndefeated;
switch (model.qData.getInventory().getItemLevel("Estates")) { switch (this.model.qData.getInventory().getItemLevel("Estates")) {
case 1: case 1:
credEstates = (int) 0.1 * credTotal; credEstates = (int) 0.1 * credTotal;
sb.append("Estates bonus: 10%.<br>"); sb.append("Estates bonus: 10%.<br>");
@@ -356,22 +357,22 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
sb.append(String.format("%s <b>%d credits</b> in total.</h3>", congrats, credTotal)); sb.append(String.format("%s <b>%d credits</b> in total.</h3>", congrats, credTotal));
sb.append("</body></html>"); sb.append("</body></html>");
model.qData.addCredits(credTotal); this.model.qData.addCredits(credTotal);
// Generate Swing components and attach. // Generate Swing components and attach.
icoTemp = GuiUtils.getResizedIcon("GoldIcon.png", 0.5); this.icoTemp = GuiUtils.getResizedIcon("GoldIcon.png", 0.5);
lblTemp1 = new TitleLabel("Gameplay Results"); this.lblTemp1 = new TitleLabel("Gameplay Results");
lblTemp2 = new JLabel(sb.toString()); this.lblTemp2 = new JLabel(sb.toString());
lblTemp2.setHorizontalAlignment(SwingConstants.CENTER); this.lblTemp2.setHorizontalAlignment(SwingConstants.CENTER);
lblTemp2.setFont(AllZone.getSkin().getFont2().deriveFont(Font.PLAIN, 14)); this.lblTemp2.setFont(AllZone.getSkin().getFont2().deriveFont(Font.PLAIN, 14));
lblTemp2.setForeground(Color.white); this.lblTemp2.setForeground(Color.white);
lblTemp2.setIcon(icoTemp); this.lblTemp2.setIcon(this.icoTemp);
lblTemp2.setIconTextGap(50); this.lblTemp2.setIconTextGap(50);
view.pnlCustom.add(lblTemp1, "align center, width 95%!"); this.view.pnlCustom.add(this.lblTemp1, "align center, width 95%!");
view.pnlCustom.add(lblTemp2, "align center, width 95%!, gaptop 10"); this.view.pnlCustom.add(this.lblTemp2, "align center, width 95%!, gaptop 10");
} }
/** /**
@@ -382,17 +383,18 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
* *
*/ */
private void awardRandomRare(final String message) { private void awardRandomRare(final String message) {
CardPrinted c = model.qData.getCards().addRandomRare(); final CardPrinted c = this.model.qData.getCards().addRandomRare();
List<CardPrinted> cardsWon = new ArrayList<CardPrinted>(); final List<CardPrinted> cardsWon = new ArrayList<CardPrinted>();
cardsWon.add(c); cardsWon.add(c);
// Generate Swing components and attach. // Generate Swing components and attach.
lblTemp1 = new TitleLabel(message); this.lblTemp1 = new TitleLabel(message);
QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon); final QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon);
view.pnlCustom.add(lblTemp1, "align center, width 95%!, " + "gaptop " + spacer + ", gapbottom 10"); this.view.pnlCustom.add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer
view.pnlCustom.add(cv, "align center, width 95%!"); + ", gapbottom 10");
this.view.pnlCustom.add(cv, "align center, width 95%!");
} }
/** /**
@@ -403,14 +405,15 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
* *
*/ */
private void awardJackpot() { private void awardJackpot() {
List<CardPrinted> cardsWon = model.qData.getCards().addRandomRare(10); final List<CardPrinted> cardsWon = this.model.qData.getCards().addRandomRare(10);
// Generate Swing components and attach. // Generate Swing components and attach.
lblTemp1 = new TitleLabel("You just won 10 random rares!"); this.lblTemp1 = new TitleLabel("You just won 10 random rares!");
QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon); final QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon);
view.pnlCustom.add(lblTemp1, "align center, width 95%!, " + "gaptop " + spacer + ", gapbottom 10"); this.view.pnlCustom.add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer
view.pnlCustom.add(cv, "align center, width 95%!"); + ", gapbottom 10");
this.view.pnlCustom.add(cv, "align center, width 95%!");
} }
/** /**
@@ -421,20 +424,21 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
* *
*/ */
private void awardBooster() { private void awardBooster() {
ListChooser<GameFormat> ch = new ListChooser<GameFormat>("Choose bonus booster format", 1, final ListChooser<GameFormat> ch = new ListChooser<GameFormat>("Choose bonus booster format", 1,
SetUtils.getFormats()); SetUtils.getFormats());
ch.show(); ch.show();
GameFormat selected = ch.getSelectedValue(); final GameFormat selected = ch.getSelectedValue();
List<CardPrinted> cardsWon = model.qData.getCards().addCards( final List<CardPrinted> cardsWon = this.model.qData.getCards().addCards(
Predicate.and(selected.getFilterPrinted(), CardPrinted.Predicates.Presets.NON_ALTERNATE)); Predicate.and(selected.getFilterPrinted(), CardPrinted.Predicates.Presets.NON_ALTERNATE));
// Generate Swing components and attach. // Generate Swing components and attach.
lblTemp1 = new TitleLabel("Bonus booster pack from the \"" + selected.getName() + "\" format!"); this.lblTemp1 = new TitleLabel("Bonus booster pack from the \"" + selected.getName() + "\" format!");
QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon); final QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon);
view.pnlCustom.add(lblTemp1, "align center, width 95%!, " + "gaptop " + spacer + ", gapbottom 10"); this.view.pnlCustom.add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer
view.pnlCustom.add(cv, "align center, width 95%!"); + ", gapbottom 10");
this.view.pnlCustom.add(cv, "align center, width 95%!");
} }
/** /**
@@ -445,58 +449,59 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
* *
*/ */
private void awardChallengeWin() { private void awardChallengeWin() {
if (!((QuestChallenge) model.qEvent).getRepeatable()) { if (!((QuestChallenge) this.model.qEvent).getRepeatable()) {
model.qData.addCompletedChallenge(((QuestChallenge) model.qEvent).getId()); this.model.qData.addCompletedChallenge(((QuestChallenge) this.model.qEvent).getId());
} }
// Note: challenge only registers as "played" if it's won. // Note: challenge only registers as "played" if it's won.
// This doesn't seem right, but it's easy to fix. Doublestrike 01-10-11 // This doesn't seem right, but it's easy to fix. Doublestrike 01-10-11
model.qData.addChallengesPlayed(); this.model.qData.addChallengesPlayed();
List<CardPrinted> cardsWon = ((QuestChallenge) model.qEvent).getCardRewardList(); final List<CardPrinted> cardsWon = ((QuestChallenge) this.model.qEvent).getCardRewardList();
long questRewardCredits = ((QuestChallenge) model.qEvent).getCreditsReward(); final long questRewardCredits = ((QuestChallenge) this.model.qEvent).getCreditsReward();
StringBuilder sb = new StringBuilder(); final StringBuilder sb = new StringBuilder();
sb.append("<html>Challenge completed.<br><br>"); sb.append("<html>Challenge completed.<br><br>");
sb.append("Challenge bounty: <b>" + questRewardCredits + " credits.</b></html>"); sb.append("Challenge bounty: <b>" + questRewardCredits + " credits.</b></html>");
model.qData.addCredits(questRewardCredits); this.model.qData.addCredits(questRewardCredits);
// Generate Swing components and attach. // Generate Swing components and attach.
icoTemp = GuiUtils.getResizedIcon("BoxIcon.png", 0.5); this.icoTemp = GuiUtils.getResizedIcon("BoxIcon.png", 0.5);
lblTemp1 = new TitleLabel("Challenge Rewards for \"" + ((QuestChallenge) model.qEvent).getTitle() + "\""); this.lblTemp1 = new TitleLabel("Challenge Rewards for \"" + ((QuestChallenge) this.model.qEvent).getTitle()
+ "\"");
lblTemp2 = new JLabel(sb.toString()); this.lblTemp2 = new JLabel(sb.toString());
lblTemp2.setFont(AllZone.getSkin().getFont2().deriveFont(Font.PLAIN, 14)); this.lblTemp2.setFont(AllZone.getSkin().getFont2().deriveFont(Font.PLAIN, 14));
lblTemp2.setForeground(Color.white); this.lblTemp2.setForeground(Color.white);
lblTemp2.setHorizontalAlignment(SwingConstants.CENTER); this.lblTemp2.setHorizontalAlignment(SwingConstants.CENTER);
lblTemp2.setIconTextGap(50); this.lblTemp2.setIconTextGap(50);
lblTemp2.setIcon(icoTemp); this.lblTemp2.setIcon(this.icoTemp);
view.pnlCustom.add(lblTemp1, "align center, width 95%!, " + "gaptop " + spacer); this.view.pnlCustom.add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer);
view.pnlCustom.add(lblTemp2, "align center, width 95%!, height 80!, gapbottom 10"); this.view.pnlCustom.add(this.lblTemp2, "align center, width 95%!, height 80!, gapbottom 10");
if (cardsWon != null) { if (cardsWon != null) {
QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon); final QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon);
view.pnlCustom.add(cv, "align center, width 95%!"); this.view.pnlCustom.add(cv, "align center, width 95%!");
model.qData.getCards().addAllCards(cardsWon); this.model.qData.getCards().addAllCards(cardsWon);
} }
} }
private void penalizeLoss() { private void penalizeLoss() {
icoTemp = GuiUtils.getResizedIcon("HeartIcon.png", 0.5); this.icoTemp = GuiUtils.getResizedIcon("HeartIcon.png", 0.5);
lblTemp1 = new TitleLabel("Gameplay Results"); this.lblTemp1 = new TitleLabel("Gameplay Results");
lblTemp2 = new JLabel("You lose! You have lost 15 credits."); this.lblTemp2 = new JLabel("You lose! You have lost 15 credits.");
lblTemp2.setFont(AllZone.getSkin().getFont2().deriveFont(Font.PLAIN, 14)); this.lblTemp2.setFont(AllZone.getSkin().getFont2().deriveFont(Font.PLAIN, 14));
lblTemp2.setForeground(Color.white); this.lblTemp2.setForeground(Color.white);
lblTemp2.setHorizontalAlignment(SwingConstants.CENTER); this.lblTemp2.setHorizontalAlignment(SwingConstants.CENTER);
lblTemp2.setIconTextGap(50); this.lblTemp2.setIconTextGap(50);
lblTemp2.setIcon(icoTemp); this.lblTemp2.setIcon(this.icoTemp);
view.pnlCustom.add(lblTemp1, "align center, width 95%!"); this.view.pnlCustom.add(this.lblTemp1, "align center, width 95%!");
view.pnlCustom.add(lblTemp2, "align center, width 95%!, height 80!"); this.view.pnlCustom.add(this.lblTemp2, "align center, width 95%!, height 80!");
} }
/** /**
@@ -508,7 +513,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
* @return boolean * @return boolean
*/ */
private boolean getLuckyCoinResult() { private boolean getLuckyCoinResult() {
boolean hasCoin = model.qData.getInventory().getItemLevel("Lucky Coin") >= 1; final boolean hasCoin = this.model.qData.getInventory().getItemLevel("Lucky Coin") >= 1;
return MyRandom.getRandom().nextFloat() <= (hasCoin ? 0.65f : 0.5f); return MyRandom.getRandom().nextFloat() <= (hasCoin ? 0.65f : 0.5f);
} }

View File

@@ -34,7 +34,7 @@ import forge.quest.data.bazaar.QuestStallPurchasable;
public class QuestBazaarItem { public class QuestBazaarItem {
/** The item. */ /** The item. */
QuestStallPurchasable item; private QuestStallPurchasable item;
/** /**
* <p> * <p>
@@ -54,7 +54,7 @@ public class QuestBazaarItem {
* item should not be deducted here. * item should not be deducted here.
*/ */
public final void purchaseItem() { public final void purchaseItem() {
item.onPurchase(); this.item.onPurchase();
} }
/** /**
@@ -65,7 +65,7 @@ public class QuestBazaarItem {
* @return a {@link javax.swing.JPanel} object. * @return a {@link javax.swing.JPanel} object.
*/ */
protected final JPanel getItemPanel() { protected final JPanel getItemPanel() {
ImageIcon icon = GuiUtils.getIconFromFile(item.getImageName()); ImageIcon icon = GuiUtils.getIconFromFile(this.item.getImageName());
if (icon == null) { if (icon == null) {
// The original size was only 40 x 40 pixels. // The original size was only 40 x 40 pixels.
// Increased the size to give added pixels for more detail. // Increased the size to give added pixels for more detail.
@@ -73,50 +73,51 @@ public class QuestBazaarItem {
} }
// The original size was only 40 x 40 pixels. // The original size was only 40 x 40 pixels.
// Increased the size to give added pixels for more detail. // Increased the size to give added pixels for more detail.
ImageIcon resizedImage = GuiUtils.getResizedIcon(icon, 80, 80); final ImageIcon resizedImage = GuiUtils.getResizedIcon(icon, 80, 80);
JLabel iconLabel = new JLabel(resizedImage); final JLabel iconLabel = new JLabel(resizedImage);
iconLabel.setBorder(new LineBorder(Color.BLACK)); iconLabel.setBorder(new LineBorder(Color.BLACK));
JPanel iconPanel = new JPanel(new BorderLayout()); final JPanel iconPanel = new JPanel(new BorderLayout());
iconPanel.add(iconLabel, BorderLayout.NORTH); iconPanel.add(iconLabel, BorderLayout.NORTH);
JLabel nameLabel = new JLabel(item.getPurchaseName()); final JLabel nameLabel = new JLabel(this.item.getPurchaseName());
nameLabel.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 14)); nameLabel.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 14));
JLabel descriptionLabel = new MultiLineLabel("<html>" + item.getPurchaseDescription() + "</html>"); final JLabel descriptionLabel = new MultiLineLabel("<html>" + this.item.getPurchaseDescription() + "</html>");
descriptionLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12)); descriptionLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12));
JLabel priceLabel = new JLabel("<html><b>Cost:</b> " + item.getPrice() + " credits</html>"); final JLabel priceLabel = new JLabel("<html><b>Cost:</b> " + this.item.getPrice() + " credits</html>");
priceLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12)); priceLabel.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 12));
JButton purchaseButton = new JButton("Buy"); final JButton purchaseButton = new JButton("Buy");
purchaseButton.addActionListener(new ActionListener() { purchaseButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) { public void actionPerformed(final ActionEvent e) {
AllZone.getQuestData().subtractCredits(item.getPrice()); AllZone.getQuestData().subtractCredits(QuestBazaarItem.this.item.getPrice());
purchaseItem(); QuestBazaarItem.this.purchaseItem();
AllZone.getQuestData().saveData(); AllZone.getQuestData().saveData();
QuestBazaarPanel.refreshLastInstance(); QuestBazaarPanel.refreshLastInstance();
} }
}); });
if (AllZone.getQuestData().getCredits() < item.getPrice()) { if (AllZone.getQuestData().getCredits() < this.item.getPrice()) {
purchaseButton.setEnabled(false); purchaseButton.setEnabled(false);
} }
JPanel itemPanel = new JPanel() { final JPanel itemPanel = new JPanel() {
private static final long serialVersionUID = -5182857296365949682L; private static final long serialVersionUID = -5182857296365949682L;
@Override @Override
public Dimension getPreferredSize() { public Dimension getPreferredSize() {
Dimension realSize = super.getPreferredSize(); final Dimension realSize = super.getPreferredSize();
realSize.width = 100; realSize.width = 100;
return realSize; return realSize;
} }
}; };
GridBagLayout layout = new GridBagLayout(); final GridBagLayout layout = new GridBagLayout();
itemPanel.setLayout(layout); itemPanel.setLayout(layout);
GridBagConstraints constraints = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER, final GridBagConstraints constraints = new GridBagConstraints(0, 0, 1, 1, 0, 0, GridBagConstraints.CENTER,
GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0); GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0);
constraints.gridheight = GridBagConstraints.REMAINDER; constraints.gridheight = GridBagConstraints.REMAINDER;

View File

@@ -31,22 +31,22 @@ public class QuestBazaarPanel extends QuestAbstractPanel {
private static final long serialVersionUID = 1418913010051869222L; private static final long serialVersionUID = 1418913010051869222L;
/** Constant <code>stallList</code>. */ /** Constant <code>stallList</code>. */
static List<QuestBazaarStall> stallList = new ArrayList<QuestBazaarStall>(); private static List<QuestBazaarStall> stallList = new ArrayList<QuestBazaarStall>();
/** The button panel. */ /** The button panel. */
JPanel buttonPanel = new JPanel(new BorderLayout()); private final JPanel buttonPanel = new JPanel(new BorderLayout());
/** The button panel main. */ /** The button panel main. */
JPanel buttonPanelMain = new JPanel(); private final JPanel buttonPanelMain = new JPanel();
/** The stall panel. */ /** The stall panel. */
JPanel stallPanel = new JPanel(); private final JPanel stallPanel = new JPanel();
/** The selected stall. */ /** The selected stall. */
JToggleButton selectedStall = null; private JToggleButton selectedStall = null;
/** The stall layout. */ /** The stall layout. */
CardLayout stallLayout = new CardLayout(); private final CardLayout stallLayout = new CardLayout();
/** /**
* <p> * <p>
@@ -60,23 +60,24 @@ public class QuestBazaarPanel extends QuestAbstractPanel {
super(mainFrame); super(mainFrame);
this.setLayout(new BorderLayout()); this.setLayout(new BorderLayout());
stallList = new ArrayList<QuestBazaarStall>(); QuestBazaarPanel.stallList = new ArrayList<QuestBazaarStall>();
for (String stallName : QuestStallManager.getStallNames()) { for (final String stallName : QuestStallManager.getStallNames()) {
stallList.add(new QuestBazaarStall(QuestStallManager.getStall(stallName))); QuestBazaarPanel.stallList.add(new QuestBazaarStall(QuestStallManager.getStall(stallName)));
} }
buttonPanelMain.setLayout(new GridLayout(stallList.size(), 1)); this.buttonPanelMain.setLayout(new GridLayout(QuestBazaarPanel.stallList.size(), 1));
stallPanel.setLayout(stallLayout); this.stallPanel.setLayout(this.stallLayout);
List<JToggleButton> buttonList = new LinkedList<JToggleButton>(); final List<JToggleButton> buttonList = new LinkedList<JToggleButton>();
double maxWidth = 0; double maxWidth = 0;
double maxHeight = 0; double maxHeight = 0;
for (QuestBazaarStall stall : stallList) { for (final QuestBazaarStall stall : QuestBazaarPanel.stallList) {
JToggleButton stallButton = new JToggleButton(stall.getStallName(), stall.getStallIcon()); final JToggleButton stallButton = new JToggleButton(stall.getStallName(), stall.getStallIcon());
stallButton.addActionListener(new ActionListener() { stallButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) { public void actionPerformed(final ActionEvent e) {
if (QuestBazaarPanel.this.selectedStall == e.getSource()) { if (QuestBazaarPanel.this.selectedStall == e.getSource()) {
@@ -93,7 +94,7 @@ public class QuestBazaarPanel extends QuestAbstractPanel {
} }
}); });
Dimension preferredSize = stallButton.getPreferredSize(); final Dimension preferredSize = stallButton.getPreferredSize();
if (preferredSize.getWidth() > maxWidth) { if (preferredSize.getWidth() > maxWidth) {
maxWidth = preferredSize.getWidth(); maxWidth = preferredSize.getWidth();
@@ -105,32 +106,33 @@ public class QuestBazaarPanel extends QuestAbstractPanel {
buttonList.add(stallButton); buttonList.add(stallButton);
buttonPanelMain.add(stallButton); this.buttonPanelMain.add(stallButton);
stallPanel.add(stall, stall.getStallName()); this.stallPanel.add(stall, stall.getStallName());
} }
buttonList.get(0).setSelected(true); buttonList.get(0).setSelected(true);
this.selectedStall = buttonList.get(0); this.selectedStall = buttonList.get(0);
Dimension max = new Dimension((int) maxWidth, (int) maxHeight); final Dimension max = new Dimension((int) maxWidth, (int) maxHeight);
for (JToggleButton button : buttonList) { for (final JToggleButton button : buttonList) {
button.setMinimumSize(max); button.setMinimumSize(max);
} }
buttonPanel.add(buttonPanelMain, BorderLayout.NORTH); this.buttonPanel.add(this.buttonPanelMain, BorderLayout.NORTH);
JButton quitButton = new JButton("Leave Bazaar"); final JButton quitButton = new JButton("Leave Bazaar");
quitButton.setSize(max); quitButton.setSize(max);
quitButton.addActionListener(new ActionListener() { quitButton.addActionListener(new ActionListener() {
@Override
public void actionPerformed(final ActionEvent e) { public void actionPerformed(final ActionEvent e) {
QuestBazaarPanel.this.mainFrame.showMainPane(); QuestBazaarPanel.this.getMainFrame().showMainPane();
} }
}); });
buttonPanel.add(quitButton, BorderLayout.SOUTH); this.buttonPanel.add(quitButton, BorderLayout.SOUTH);
this.add(buttonPanel, BorderLayout.WEST); this.add(this.buttonPanel, BorderLayout.WEST);
this.add(stallPanel, BorderLayout.CENTER); this.add(this.stallPanel, BorderLayout.CENTER);
} }
@@ -143,14 +145,14 @@ public class QuestBazaarPanel extends QuestAbstractPanel {
* a {@link java.lang.String} object. * a {@link java.lang.String} object.
*/ */
private void showStall(final String source) { private void showStall(final String source) {
stallLayout.show(stallPanel, source); this.stallLayout.show(this.stallPanel, source);
} }
/** /**
* Slightly hackish, but should work. * Slightly hackish, but should work.
*/ */
static void refreshLastInstance() { static void refreshLastInstance() {
for (QuestBazaarStall stall : stallList) { for (final QuestBazaarStall stall : QuestBazaarPanel.stallList) {
stall.updateItems(); stall.updateItems();
} }
} }
@@ -158,6 +160,6 @@ public class QuestBazaarPanel extends QuestAbstractPanel {
/** {@inheritDoc} */ /** {@inheritDoc} */
@Override @Override
public final void refreshState() { public final void refreshState() {
refreshLastInstance(); QuestBazaarPanel.refreshLastInstance();
} }
} }

View File

@@ -1,5 +1,22 @@
package forge.quest.gui.bazaar; package forge.quest.gui.bazaar;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.GridBagConstraints;
import java.awt.GridBagLayout;
import java.awt.Insets;
import java.util.ArrayList;
import javax.swing.ImageIcon;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.border.EmptyBorder;
import forge.AllZone; import forge.AllZone;
import forge.gui.GuiUtils; import forge.gui.GuiUtils;
import forge.properties.NewConstants; import forge.properties.NewConstants;
@@ -8,90 +25,97 @@ import forge.quest.data.bazaar.QuestStallDefinition;
import forge.quest.data.bazaar.QuestStallManager; import forge.quest.data.bazaar.QuestStallManager;
import forge.quest.data.bazaar.QuestStallPurchasable; import forge.quest.data.bazaar.QuestStallPurchasable;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.util.ArrayList;
/** /**
* <p>QuestBazaarStall class.</p> * <p>
* QuestBazaarStall class.
* </p>
* *
* @author Forge * @author Forge
* @version $Id$ * @version $Id$
*/ */
public class QuestBazaarStall extends JPanel implements NewConstants { public class QuestBazaarStall extends JPanel implements NewConstants {
/** Constant <code>serialVersionUID=-4147745071116906043L</code> */ /** Constant <code>serialVersionUID=-4147745071116906043L</code>. */
private static final long serialVersionUID = -4147745071116906043L; private static final long serialVersionUID = -4147745071116906043L;
/** The name. */ /** The name. */
String name; private final String name;
/** The stall name. */ /** The stall name. */
String stallName; private final String stallName;
/** The fluff. */ /** The fluff. */
String fluff; private final String fluff;
/** The icon. */ /** The icon. */
ImageIcon icon; private final ImageIcon icon;
private final JLabel creditLabel = new JLabel();
private JLabel creditLabel = new JLabel(); private final JPanel inventoryPanel = new JPanel();
private JPanel inventoryPanel = new JPanel();
/** The quest data. */ /** The quest data. */
protected QuestData questData = AllZone.getQuestData(); private final QuestData questData = AllZone.getQuestData();
/** /**
* <p>Constructor for QuestBazaarStall.</p> * <p>
* Constructor for QuestBazaarStall.
* </p>
* *
* @param name a {@link java.lang.String} object. * @param name
* @param stallName a {@link java.lang.String} object. * a {@link java.lang.String} object.
* @param iconName a {@link java.lang.String} object. * @param stallName
* @param fluff a {@link java.lang.String} object. * a {@link java.lang.String} object.
* @param iconName
* a {@link java.lang.String} object.
* @param fluff
* a {@link java.lang.String} object.
*/ */
protected QuestBazaarStall(String name, String stallName, String iconName, String fluff) { protected QuestBazaarStall(final String name, final String stallName, final String iconName, final String fluff) {
this.name = name; this.name = name;
this.fluff = fluff; this.fluff = fluff;
this.icon = GuiUtils.getIconFromFile(iconName); this.icon = GuiUtils.getIconFromFile(iconName);
this.stallName = stallName; this.stallName = stallName;
initUI(); this.initUI();
} }
/** /**
* <p>Constructor for QuestBazaarStall.</p> * <p>
* Constructor for QuestBazaarStall.
* </p>
* *
* @param definition a {@link forge.quest.data.bazaar.QuestStallDefinition} object. * @param definition
* a {@link forge.quest.data.bazaar.QuestStallDefinition} object.
*/ */
protected QuestBazaarStall(QuestStallDefinition definition) { protected QuestBazaarStall(final QuestStallDefinition definition) {
this.fluff = definition.fluff; this.fluff = definition.getFluff();
this.icon = GuiUtils.getIconFromFile(definition.iconName); this.icon = GuiUtils.getIconFromFile(definition.getIconName());
this.stallName = definition.displayName; this.stallName = definition.getDisplayName();
this.name = definition.name; this.name = definition.getName();
initUI(); this.initUI();
} }
/** /**
* <p>initUI.</p> * <p>
* initUI.
* </p>
*/ */
private void initUI() { private void initUI() {
this.removeAll(); this.removeAll();
JLabel stallNameLabel; JLabel stallNameLabel;
GridBagLayout layout = new GridBagLayout(); final GridBagLayout layout = new GridBagLayout();
this.setLayout(layout); this.setLayout(layout);
stallNameLabel = new JLabel(stallName); stallNameLabel = new JLabel(this.stallName);
stallNameLabel.setFont(new Font("sserif", Font.BOLD, 22)); stallNameLabel.setFont(new Font("sserif", Font.BOLD, 22));
stallNameLabel.setHorizontalAlignment(SwingConstants.CENTER); stallNameLabel.setHorizontalAlignment(SwingConstants.CENTER);
creditLabel.setText("Credits: " + questData.getCredits()); this.creditLabel.setText("Credits: " + this.questData.getCredits());
creditLabel.setFont(new Font("sserif", 0, 14)); this.creditLabel.setFont(new Font("sserif", 0, 14));
JTextArea fluffArea = new JTextArea(fluff); final JTextArea fluffArea = new JTextArea(this.fluff);
fluffArea.setFont(new Font("sserif", Font.ITALIC, 14)); fluffArea.setFont(new Font("sserif", Font.ITALIC, 14));
fluffArea.setLineWrap(true); fluffArea.setLineWrap(true);
fluffArea.setWrapStyleWord(true); fluffArea.setWrapStyleWord(true);
@@ -99,17 +123,8 @@ public class QuestBazaarStall extends JPanel implements NewConstants {
fluffArea.setEditable(false); fluffArea.setEditable(false);
fluffArea.setFocusable(false); fluffArea.setFocusable(false);
fluffArea.setPreferredSize(new Dimension(fluffArea.getPreferredSize().width, 40)); fluffArea.setPreferredSize(new Dimension(fluffArea.getPreferredSize().width, 40));
GridBagConstraints constraints = new GridBagConstraints(0, final GridBagConstraints constraints = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER,
0, GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0);
1,
1,
1,
0,
GridBagConstraints.CENTER,
GridBagConstraints.NONE,
new Insets(2, 2, 2, 2),
0,
0);
layout.setConstraints(stallNameLabel, constraints); layout.setConstraints(stallNameLabel, constraints);
this.add(stallNameLabel); this.add(stallNameLabel);
@@ -120,8 +135,8 @@ public class QuestBazaarStall extends JPanel implements NewConstants {
this.add(fluffArea); this.add(fluffArea);
constraints.gridy = 2; constraints.gridy = 2;
layout.setConstraints(creditLabel, constraints); layout.setConstraints(this.creditLabel, constraints);
this.add(creditLabel); this.add(this.creditLabel);
constraints.gridy = 3; constraints.gridy = 3;
constraints.anchor = GridBagConstraints.NORTHWEST; constraints.anchor = GridBagConstraints.NORTHWEST;
@@ -130,10 +145,10 @@ public class QuestBazaarStall extends JPanel implements NewConstants {
constraints.weighty = 1; constraints.weighty = 1;
constraints.weightx = GridBagConstraints.REMAINDER; constraints.weightx = GridBagConstraints.REMAINDER;
populateInventory(populateItems()); this.populateInventory(this.populateItems());
JScrollPane scrollPane = new JScrollPane(inventoryPanel); final JScrollPane scrollPane = new JScrollPane(this.inventoryPanel);
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER); scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0)); scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0));
layout.setConstraints(scrollPane, constraints); layout.setConstraints(scrollPane, constraints);
this.add(scrollPane); this.add(scrollPane);
@@ -142,98 +157,99 @@ public class QuestBazaarStall extends JPanel implements NewConstants {
} }
/** /**
* <p>populateInventory.</p> * <p>
* populateInventory.
* </p>
* *
* @param stallItems a {@link java.util.List} object. * @param stallItems
* a {@link java.util.List} object.
*/ */
private void populateInventory(java.util.List<QuestBazaarItem> stallItems) { private void populateInventory(final java.util.List<QuestBazaarItem> stallItems) {
inventoryPanel.removeAll(); this.inventoryPanel.removeAll();
GridBagLayout innerLayout = new GridBagLayout(); final GridBagLayout innerLayout = new GridBagLayout();
inventoryPanel.setLayout(innerLayout); this.inventoryPanel.setLayout(innerLayout);
GridBagConstraints innerConstraints = final GridBagConstraints innerConstraints = new GridBagConstraints(0, 0, 1, 1, 1, 0,
new GridBagConstraints(0, GridBagConstraints.NORTHWEST, GridBagConstraints.HORIZONTAL, new Insets(2, 2, 2, 2), 0, 0);
0,
1,
1,
1,
0,
GridBagConstraints.NORTHWEST,
GridBagConstraints.HORIZONTAL,
new Insets(2, 2, 2, 2),
0,
0);
JLabel purchaseLabel = new JLabel(); final JLabel purchaseLabel = new JLabel();
if (stallItems.size() == 0) { if (stallItems.size() == 0) {
purchaseLabel.setText("The merchant does not have anything useful for sale"); purchaseLabel.setText("The merchant does not have anything useful for sale");
inventoryPanel.add(purchaseLabel); this.inventoryPanel.add(purchaseLabel);
innerConstraints.gridy++; innerConstraints.gridy++;
} else { } else {
innerConstraints.insets = new Insets(5, 20, 5, 5); innerConstraints.insets = new Insets(5, 20, 5, 5);
for (QuestBazaarItem item : stallItems) { for (final QuestBazaarItem item : stallItems) {
JPanel itemPanel = item.getItemPanel(); final JPanel itemPanel = item.getItemPanel();
innerLayout.setConstraints(itemPanel, innerConstraints); innerLayout.setConstraints(itemPanel, innerConstraints);
inventoryPanel.add(itemPanel); this.inventoryPanel.add(itemPanel);
innerConstraints.gridy++; innerConstraints.gridy++;
} }
} }
innerConstraints.weighty = 1; innerConstraints.weighty = 1;
JLabel fillLabel = new JLabel(); final JLabel fillLabel = new JLabel();
innerLayout.setConstraints(fillLabel, innerConstraints); innerLayout.setConstraints(fillLabel, innerConstraints);
inventoryPanel.add(fillLabel); this.inventoryPanel.add(fillLabel);
} }
/** /**
* <p>populateItems.</p> * <p>
* populateItems.
* </p>
* *
* @return a {@link java.util.List} object. * @return a {@link java.util.List} object.
*/ */
protected java.util.List<QuestBazaarItem> populateItems() { protected java.util.List<QuestBazaarItem> populateItems() {
java.util.List<QuestBazaarItem> ret = new ArrayList<QuestBazaarItem>(); final java.util.List<QuestBazaarItem> ret = new ArrayList<QuestBazaarItem>();
java.util.List<QuestStallPurchasable> purchasables = QuestStallManager.getItems(name); final java.util.List<QuestStallPurchasable> purchasables = QuestStallManager.getItems(this.name);
for (QuestStallPurchasable purchasable : purchasables) { for (final QuestStallPurchasable purchasable : purchasables) {
ret.add(new QuestBazaarItem(purchasable)); ret.add(new QuestBazaarItem(purchasable));
} }
return ret; return ret;
} }
/** /**
* <p>getStallIcon.</p> * <p>
* getStallIcon.
* </p>
* *
* @return a {@link javax.swing.ImageIcon} object. * @return a {@link javax.swing.ImageIcon} object.
*/ */
public ImageIcon getStallIcon() { public ImageIcon getStallIcon() {
return icon; return this.icon;
} }
/** /**
* <p>Getter for the field <code>stallName</code>.</p> * <p>
* Getter for the field <code>stallName</code>.
* </p>
* *
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
public String getStallName() { public String getStallName() {
return stallName; return this.stallName;
} }
/** /**
* <p>updateItems.</p> * <p>
* updateItems.
* </p>
*/ */
public void updateItems() { public void updateItems() {
SwingUtilities.invokeLater(new Runnable() { SwingUtilities.invokeLater(new Runnable() {
@Override
public void run() { public void run() {
populateInventory(populateItems()); QuestBazaarStall.this.populateInventory(QuestBazaarStall.this.populateItems());
creditLabel.setText("Credits: " + questData.getCredits()); QuestBazaarStall.this.creditLabel.setText("Credits: " + QuestBazaarStall.this.questData.getCredits());
inventoryPanel.invalidate(); QuestBazaarStall.this.inventoryPanel.invalidate();
inventoryPanel.repaint(); QuestBazaarStall.this.inventoryPanel.repaint();
} }
}); });
} }

View File

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

View File

@@ -50,7 +50,7 @@ public class QuestChallenge extends QuestEvent {
*/ */
public QuestChallenge() { public QuestChallenge() {
super(); super();
eventType = "challenge"; this.eventType = "challenge";
} }
/** /**
@@ -61,7 +61,7 @@ public class QuestChallenge extends QuestEvent {
* @return {@link java.lang.Integer}. * @return {@link java.lang.Integer}.
*/ */
public final int getAILife() { public final int getAILife() {
return aiLife; return this.aiLife;
} }
/** /**
@@ -72,7 +72,7 @@ public class QuestChallenge extends QuestEvent {
* @return {@link java.lang.String}. * @return {@link java.lang.String}.
*/ */
public final String getCardReward() { public final String getCardReward() {
return cardReward; return this.cardReward;
} }
/** /**
@@ -83,7 +83,7 @@ public class QuestChallenge extends QuestEvent {
* @return {@link java.lang.Integer}. * @return {@link java.lang.Integer}.
*/ */
public final int getCreditsReward() { public final int getCreditsReward() {
return creditsReward; return this.creditsReward;
} }
/** /**
@@ -94,7 +94,7 @@ public class QuestChallenge extends QuestEvent {
* @return {@link java.lang.Integer}. * @return {@link java.lang.Integer}.
*/ */
public final int getId() { public final int getId() {
return id; return this.id;
} }
/** /**
@@ -105,7 +105,7 @@ public class QuestChallenge extends QuestEvent {
* @return {@link java.lang.Boolean}. * @return {@link java.lang.Boolean}.
*/ */
public final boolean getRepeatable() { public final boolean getRepeatable() {
return repeatable; return this.repeatable;
} }
/** /**
@@ -116,7 +116,7 @@ public class QuestChallenge extends QuestEvent {
* @return {@link java.lang.Integer}. * @return {@link java.lang.Integer}.
*/ */
public final int getWinsReqd() { public final int getWinsReqd() {
return winsReqd; return this.winsReqd;
} }
/** /**
@@ -128,7 +128,7 @@ public class QuestChallenge extends QuestEvent {
* @return the aI extra cards * @return the aI extra cards
*/ */
public final List<String> getAIExtraCards() { public final List<String> getAIExtraCards() {
return aiExtraCards; return this.aiExtraCards;
} }
/** /**
@@ -140,7 +140,7 @@ public class QuestChallenge extends QuestEvent {
* @return the human extra cards * @return the human extra cards
*/ */
public final List<String> getHumanExtraCards() { public final List<String> getHumanExtraCards() {
return humanExtraCards; return this.humanExtraCards;
} }
/** /**
@@ -151,6 +151,6 @@ public class QuestChallenge extends QuestEvent {
* @return the card reward list * @return the card reward list
*/ */
public final List<CardPrinted> getCardRewardList() { public final List<CardPrinted> getCardRewardList() {
return cardRewardList; return this.cardRewardList;
} }
} }

View File

@@ -31,12 +31,12 @@ public class QuestChallengePanel extends QuestSelectablePanel {
GuiUtils.addGap(super.rootPanel, 7); GuiUtils.addGap(super.rootPanel, 7);
if (q.getRepeatable()) { if (q.getRepeatable()) {
repeatabilityLabel = new JLabel("This challenge is repeatable"); this.repeatabilityLabel = new JLabel("This challenge is repeatable");
} else { } else {
repeatabilityLabel = new JLabel("This challenge is not repeatable"); this.repeatabilityLabel = new JLabel("This challenge is not repeatable");
} }
super.rootPanel.add(repeatabilityLabel); super.rootPanel.add(this.repeatabilityLabel);
} }
} }

View File

@@ -14,7 +14,7 @@ public class QuestDuel extends QuestEvent {
*/ */
public QuestDuel() { public QuestDuel() {
super(); super();
eventType = "duel"; this.eventType = "duel";
} }
} }

View File

@@ -41,7 +41,7 @@ public class QuestEvent {
* @return a {@link java.lang.String}. * @return a {@link java.lang.String}.
*/ */
public final String getTitle() { public final String getTitle() {
return title; return this.title;
} }
/** /**
@@ -52,7 +52,7 @@ public class QuestEvent {
* @return a {@link java.lang.String}. * @return a {@link java.lang.String}.
*/ */
public final String getDifficulty() { public final String getDifficulty() {
return difficulty; return this.difficulty;
} }
/** /**
@@ -63,7 +63,7 @@ public class QuestEvent {
* @return a {@link java.lang.String}. * @return a {@link java.lang.String}.
*/ */
public final String getDescription() { public final String getDescription() {
return description; return this.description;
} }
/** /**
@@ -74,7 +74,7 @@ public class QuestEvent {
* @return {@link forge.deck.Deck} * @return {@link forge.deck.Deck}
*/ */
public final Deck getEventDeck() { public final Deck getEventDeck() {
return eventDeck; return this.eventDeck;
} }
/** /**
@@ -85,7 +85,7 @@ public class QuestEvent {
* @return {@link forge.deck.Deck} * @return {@link forge.deck.Deck}
*/ */
public final String getEventType() { public final String getEventType() {
return eventType; return this.eventType;
} }
/** /**
@@ -96,7 +96,7 @@ public class QuestEvent {
* @return a {@link java.lang.String}. * @return a {@link java.lang.String}.
*/ */
public final String getIcon() { public final String getIcon() {
return icon; return this.icon;
} }
/** /**
@@ -107,6 +107,6 @@ public class QuestEvent {
* @return a {@link java.lang.String}. * @return a {@link java.lang.String}.
*/ */
public final String getName() { public final String getName() {
return name; return this.name;
} }
} }

View File

@@ -57,32 +57,32 @@ public class QuestEventManager {
List<String> contents; List<String> contents;
QuestEvent tempEvent; QuestEvent tempEvent;
File file = ForgeProps.getFile(NewConstants.Quest.DECKS); final File file = ForgeProps.getFile(NewConstants.Quest.DECKS);
DeckManager manager = new DeckManager(file); final DeckManager manager = new DeckManager(file);
File[] allFiles = ForgeProps.getFile(NewConstants.Quest.DECKS).listFiles(DeckManager.DCK_FILE_FILTER); final File[] allFiles = ForgeProps.getFile(NewConstants.Quest.DECKS).listFiles(DeckManager.DCK_FILE_FILTER);
for (File f : allFiles) { for (final File f : allFiles) {
contents = FileUtil.readFile(f); contents = FileUtil.readFile(f);
if (contents.get(0).trim().equals("[quest]")) { if (contents.get(0).trim().equals("[quest]")) {
tempEvent = new QuestChallenge(); tempEvent = new QuestChallenge();
assembleChallengeUniquedata(contents, (QuestChallenge) tempEvent); this.assembleChallengeUniquedata(contents, (QuestChallenge) tempEvent);
allChallenges.add((QuestChallenge) tempEvent); this.allChallenges.add((QuestChallenge) tempEvent);
} // End if([quest]) } // End if([quest])
else { else {
tempEvent = new QuestDuel(); tempEvent = new QuestDuel();
assembleDuelUniquedata(contents, (QuestDuel) tempEvent); this.assembleDuelUniquedata(contents, (QuestDuel) tempEvent);
allDuels.add((QuestDuel) tempEvent); this.allDuels.add((QuestDuel) tempEvent);
} }
// Assemble metadata (may not be necessary later) and deck object. // Assemble metadata (may not be necessary later) and deck object.
assembleEventMetadata(contents, tempEvent); this.assembleEventMetadata(contents, tempEvent);
tempEvent.eventDeck = manager.getDeck(tempEvent.getName()); tempEvent.eventDeck = manager.getDeck(tempEvent.getName());
} // End for(allFiles) } // End for(allFiles)
assembleDuelDifficultyLists(); this.assembleDuelDifficultyLists();
} // End assembleAllEvents() } // End assembleAllEvents()
@@ -99,7 +99,7 @@ public class QuestEventManager {
int eqpos; int eqpos;
String key, value; String key, value;
for (String s : contents) { for (final String s : contents) {
if (s.equals("[metadata]")) { if (s.equals("[metadata]")) {
break; break;
} }
@@ -137,7 +137,7 @@ public class QuestEventManager {
String key, value; String key, value;
// Unique properties // Unique properties
for (String s : contents) { for (final String s : contents) {
if (s.equals("[metadata]")) { if (s.equals("[metadata]")) {
break; break;
} }
@@ -168,10 +168,10 @@ public class QuestEventManager {
} }
// Human extra card list assembled here. // Human extra card list assembled here.
else if (key.equalsIgnoreCase("HumanExtras") && !value.equals("")) { else if (key.equalsIgnoreCase("HumanExtras") && !value.equals("")) {
String[] names = value.split("\\|"); final String[] names = value.split("\\|");
List<String> templist = new ArrayList<String>(); final List<String> templist = new ArrayList<String>();
for (String n : names) { for (final String n : names) {
templist.add(n); templist.add(n);
} }
@@ -179,10 +179,10 @@ public class QuestEventManager {
} }
// AI extra card list assembled here. // AI extra card list assembled here.
else if (key.equalsIgnoreCase("AIExtras") && !value.equals("")) { else if (key.equalsIgnoreCase("AIExtras") && !value.equals("")) {
String[] names = value.split("\\|"); final String[] names = value.split("\\|");
List<String> templist = new ArrayList<String>(); final List<String> templist = new ArrayList<String>();
for (String n : names) { for (final String n : names) {
templist.add(n); templist.add(n);
} }
@@ -274,22 +274,22 @@ public class QuestEventManager {
* Assemble duel deck difficulty lists * Assemble duel deck difficulty lists
*/ */
private void assembleDuelDifficultyLists() { private void assembleDuelDifficultyLists() {
easyAIduels = new ArrayList<QuestDuel>(); this.easyAIduels = new ArrayList<QuestDuel>();
mediumAIduels = new ArrayList<QuestDuel>(); this.mediumAIduels = new ArrayList<QuestDuel>();
hardAIduels = new ArrayList<QuestDuel>(); this.hardAIduels = new ArrayList<QuestDuel>();
veryHardAIduels = new ArrayList<QuestDuel>(); this.veryHardAIduels = new ArrayList<QuestDuel>();
String s; String s;
for (QuestDuel qd : allDuels) { for (final QuestDuel qd : this.allDuels) {
s = qd.getDifficulty(); s = qd.getDifficulty();
if (s.equalsIgnoreCase("easy")) { if (s.equalsIgnoreCase("easy")) {
easyAIduels.add(qd); this.easyAIduels.add(qd);
} else if (s.equalsIgnoreCase("medium")) { } else if (s.equalsIgnoreCase("medium")) {
mediumAIduels.add(qd); this.mediumAIduels.add(qd);
} else if (s.equalsIgnoreCase("hard")) { } else if (s.equalsIgnoreCase("hard")) {
hardAIduels.add(qd); this.hardAIduels.add(qd);
} else if (s.equalsIgnoreCase("very hard")) { } else if (s.equalsIgnoreCase("very hard")) {
veryHardAIduels.add(qd); this.veryHardAIduels.add(qd);
} }
} }
} }
@@ -309,7 +309,7 @@ public class QuestEventManager {
* @return a {@link java.lang.String} object. * @return a {@link java.lang.String} object.
*/ */
private static QuestDuel getDuelOpponentByNumber(final List<QuestDuel> aiDeck, final int n) { private static QuestDuel getDuelOpponentByNumber(final List<QuestDuel> aiDeck, final int n) {
List<QuestDuel> deckListCopy = new ArrayList<QuestDuel>(aiDeck); final List<QuestDuel> deckListCopy = new ArrayList<QuestDuel>(aiDeck);
Collections.shuffle(deckListCopy, new Random(AllZone.getQuestData().getRandomSeed())); Collections.shuffle(deckListCopy, new Random(AllZone.getQuestData().getRandomSeed()));
return deckListCopy.get(n); return deckListCopy.get(n);
@@ -326,7 +326,7 @@ public class QuestEventManager {
* @return * @return
*/ */
private QuestChallenge getChallengeEventByNumber(final int n) { private QuestChallenge getChallengeEventByNumber(final int n) {
for (QuestChallenge qc : allChallenges) { for (final QuestChallenge qc : this.allChallenges) {
if (qc.getId() == n) { if (qc.getId() == n) {
return qc; return qc;
} }
@@ -344,37 +344,37 @@ public class QuestEventManager {
*/ */
public final List<QuestDuel> generateDuels() { public final List<QuestDuel> generateDuels() {
int index = AllZone.getQuestData().getDifficultyIndex(); final int index = AllZone.getQuestData().getDifficultyIndex();
List<QuestDuel> duelOpponents = new ArrayList<QuestDuel>(); final List<QuestDuel> duelOpponents = new ArrayList<QuestDuel>();
if (AllZone.getQuestData().getWin() < QuestPreferences.getWinsForMediumAI(index)) { if (AllZone.getQuestData().getWin() < QuestPreferences.getWinsForMediumAI(index)) {
duelOpponents.add(getDuelOpponentByNumber(easyAIduels, 0)); duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.easyAIduels, 0));
duelOpponents.add(getDuelOpponentByNumber(easyAIduels, 1)); duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.easyAIduels, 1));
duelOpponents.add(getDuelOpponentByNumber(easyAIduels, 2)); duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.easyAIduels, 2));
} else if (AllZone.getQuestData().getWin() == QuestPreferences.getWinsForMediumAI(index)) { } else if (AllZone.getQuestData().getWin() == QuestPreferences.getWinsForMediumAI(index)) {
duelOpponents.add(getDuelOpponentByNumber(easyAIduels, 0)); duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.easyAIduels, 0));
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 0)); duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.mediumAIduels, 0));
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 1)); duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.mediumAIduels, 1));
} else if (AllZone.getQuestData().getWin() < QuestPreferences.getWinsForHardAI(index)) { } else if (AllZone.getQuestData().getWin() < QuestPreferences.getWinsForHardAI(index)) {
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 0)); duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.mediumAIduels, 0));
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 1)); duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.mediumAIduels, 1));
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 2)); duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.mediumAIduels, 2));
} }
else if (AllZone.getQuestData().getWin() == QuestPreferences.getWinsForHardAI(index)) { else if (AllZone.getQuestData().getWin() == QuestPreferences.getWinsForHardAI(index)) {
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 0)); duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.mediumAIduels, 0));
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 0)); duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.hardAIduels, 0));
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 1)); duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.hardAIduels, 1));
} }
else if (AllZone.getQuestData().getWin() < QuestPreferences.getWinsForVeryHardAI(index)) { else if (AllZone.getQuestData().getWin() < QuestPreferences.getWinsForVeryHardAI(index)) {
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 0)); duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.hardAIduels, 0));
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 1)); duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.hardAIduels, 1));
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 2)); duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.hardAIduels, 2));
} else { } else {
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 0)); duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.hardAIduels, 0));
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 1)); duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.hardAIduels, 1));
duelOpponents.add(getDuelOpponentByNumber(veryHardAIduels, 2)); duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.veryHardAIduels, 2));
} }
return duelOpponents; return duelOpponents;
@@ -390,9 +390,9 @@ public class QuestEventManager {
* @return a {@link java.util.List} object. * @return a {@link java.util.List} object.
*/ */
public final List<QuestChallenge> generateChallenges() { public final List<QuestChallenge> generateChallenges() {
forge.quest.data.QuestData questData = AllZone.getQuestData(); final forge.quest.data.QuestData questData = AllZone.getQuestData();
List<QuestChallenge> challengeOpponents = new ArrayList<QuestChallenge>(); final List<QuestChallenge> challengeOpponents = new ArrayList<QuestChallenge>();
int maxChallenges = questData.getWin() / 10; int maxChallenges = questData.getWin() / 10;
if (maxChallenges > 5) { if (maxChallenges > 5) {
@@ -400,15 +400,14 @@ public class QuestEventManager {
} }
// Generate IDs as needed. // Generate IDs as needed.
if (questData.getAvailableChallenges() == null || questData.getAvailableChallenges().size() < maxChallenges) { if ((questData.getAvailableChallenges() == null) || (questData.getAvailableChallenges().size() < maxChallenges)) {
List<Integer> unlockedChallengeIds = new ArrayList<Integer>(); final List<Integer> unlockedChallengeIds = new ArrayList<Integer>();
List<Integer> availableChallengeIds = new ArrayList<Integer>(); final List<Integer> availableChallengeIds = new ArrayList<Integer>();
for (QuestChallenge qc : allChallenges) { for (final QuestChallenge qc : this.allChallenges) {
if (qc.getWinsReqd() <= questData.getWin() if ((qc.getWinsReqd() <= questData.getWin())
&& !questData.getCompletedChallenges().contains(qc.getId())) && !questData.getCompletedChallenges().contains(qc.getId())) {
{
unlockedChallengeIds.add(qc.getId()); unlockedChallengeIds.add(qc.getId());
} }
} }
@@ -426,8 +425,8 @@ public class QuestEventManager {
} }
// Finally, pull challenge events from available IDs and return. // Finally, pull challenge events from available IDs and return.
for (int i : questData.getAvailableChallenges()) { for (final int i : questData.getAvailableChallenges()) {
challengeOpponents.add(getChallengeEventByNumber(i)); challengeOpponents.add(this.getChallengeEventByNumber(i));
} }
return challengeOpponents; return challengeOpponents;

View File

@@ -2,6 +2,7 @@ package forge.quest.gui.main;
import java.awt.BorderLayout; import java.awt.BorderLayout;
import java.awt.Color; import java.awt.Color;
import java.awt.Component;
import java.awt.Dimension; import java.awt.Dimension;
import java.io.File; import java.io.File;
@@ -33,7 +34,7 @@ public class QuestSelectablePanel extends JPanel {
/** The background color. */ /** The background color. */
protected Color backgroundColor; protected Color backgroundColor;
private boolean selected; private boolean selected;
private QuestEvent event; private final QuestEvent event;
private String iconfilename; private String iconfilename;
/** The root panel. */ /** The root panel. */
@@ -51,17 +52,17 @@ public class QuestSelectablePanel extends JPanel {
public QuestSelectablePanel(final QuestEvent qe) { public QuestSelectablePanel(final QuestEvent qe) {
this.event = qe; this.event = qe;
this.iconfilename = qe.icon; this.iconfilename = qe.icon;
File base = ForgeProps.getFile(NewConstants.IMAGE_ICON); final File base = ForgeProps.getFile(NewConstants.IMAGE_ICON);
File file = new File(base, iconfilename); File file = new File(base, this.iconfilename);
if (!file.exists()) { if (!file.exists()) {
file = new File(base, "Unknown.jpg"); file = new File(base, "Unknown.jpg");
this.iconfilename = "Unknown.jpg"; this.iconfilename = "Unknown.jpg";
} }
ImageIcon icon = new ImageIcon(file.toString()); final ImageIcon icon = new ImageIcon(file.toString());
this.backgroundColor = getBackground(); this.backgroundColor = this.getBackground();
this.setLayout(new BorderLayout(5, 5)); this.setLayout(new BorderLayout(5, 5));
JLabel iconLabel; JLabel iconLabel;
@@ -73,39 +74,39 @@ public class QuestSelectablePanel extends JPanel {
} }
iconLabel.setBorder(new LineBorder(Color.BLACK)); iconLabel.setBorder(new LineBorder(Color.BLACK));
iconLabel.setAlignmentY(TOP_ALIGNMENT); iconLabel.setAlignmentY(Component.TOP_ALIGNMENT);
JPanel iconPanel = new JPanel(new BorderLayout()); final JPanel iconPanel = new JPanel(new BorderLayout());
iconPanel.setOpaque(false); iconPanel.setOpaque(false);
iconPanel.add(iconLabel, BorderLayout.NORTH); iconPanel.add(iconLabel, BorderLayout.NORTH);
this.add(iconPanel, BorderLayout.WEST); this.add(iconPanel, BorderLayout.WEST);
rootPanel.setOpaque(false); this.rootPanel.setOpaque(false);
rootPanel.setLayout(new BoxLayout(rootPanel, BoxLayout.Y_AXIS)); this.rootPanel.setLayout(new BoxLayout(this.rootPanel, BoxLayout.Y_AXIS));
this.add(rootPanel, BorderLayout.CENTER); this.add(this.rootPanel, BorderLayout.CENTER);
JPanel centerTopPanel = new JPanel(); final JPanel centerTopPanel = new JPanel();
centerTopPanel.setOpaque(false); centerTopPanel.setOpaque(false);
centerTopPanel.setAlignmentX(LEFT_ALIGNMENT); centerTopPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
centerTopPanel.setLayout(new BoxLayout(centerTopPanel, BoxLayout.X_AXIS)); centerTopPanel.setLayout(new BoxLayout(centerTopPanel, BoxLayout.X_AXIS));
JLabel nameLabel = new JLabel(qe.getTitle()); final JLabel nameLabel = new JLabel(qe.getTitle());
GuiUtils.setFontSize(nameLabel, 20); GuiUtils.setFontSize(nameLabel, 20);
nameLabel.setAlignmentY(BOTTOM_ALIGNMENT); nameLabel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
centerTopPanel.add(nameLabel); centerTopPanel.add(nameLabel);
GuiUtils.addExpandingHorizontalSpace(centerTopPanel); GuiUtils.addExpandingHorizontalSpace(centerTopPanel);
JLabel difficultyLabel = new JLabel(qe.getDifficulty()); final JLabel difficultyLabel = new JLabel(qe.getDifficulty());
difficultyLabel.setAlignmentY(BOTTOM_ALIGNMENT); difficultyLabel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
centerTopPanel.add(difficultyLabel); centerTopPanel.add(difficultyLabel);
rootPanel.add(centerTopPanel); this.rootPanel.add(centerTopPanel);
GuiUtils.addGap(rootPanel); GuiUtils.addGap(this.rootPanel);
JLabel descriptionLabel = new JLabel(qe.getDescription()); final JLabel descriptionLabel = new JLabel(qe.getDescription());
descriptionLabel.setAlignmentX(LEFT_ALIGNMENT); descriptionLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
rootPanel.add(descriptionLabel); this.rootPanel.add(descriptionLabel);
this.setMaximumSize(new Dimension(Integer.MAX_VALUE, 80)); this.setMaximumSize(new Dimension(Integer.MAX_VALUE, 80));
this.setBorder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder(5, 5, 5, 5))); this.setBorder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder(5, 5, 5, 5)));
@@ -119,7 +120,7 @@ public class QuestSelectablePanel extends JPanel {
* @return a boolean. * @return a boolean.
*/ */
public final boolean isSelected() { public final boolean isSelected() {
return selected; return this.selected;
} }
/** /**
@@ -132,9 +133,9 @@ public class QuestSelectablePanel extends JPanel {
*/ */
public final void setSelected(final boolean selected) { public final void setSelected(final boolean selected) {
if (selected) { if (selected) {
this.setBackground(backgroundColor.darker()); this.setBackground(this.backgroundColor.darker());
} else { } else {
this.setBackground(backgroundColor); this.setBackground(this.backgroundColor);
} }
this.selected = selected; this.selected = selected;

View File

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

View File

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