mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-20 20:58:03 +00:00
checkstyle and refactor
This commit is contained in:
@@ -11,16 +11,16 @@ package forge.quest.data.bazaar;
|
||||
public class QuestStallDefinition {
|
||||
|
||||
/** The name. */
|
||||
public String name;
|
||||
private String name;
|
||||
|
||||
/** The display name. */
|
||||
public String displayName;
|
||||
private String displayName;
|
||||
|
||||
/** The icon name. */
|
||||
public String iconName;
|
||||
private String iconName;
|
||||
|
||||
/** The fluff. */
|
||||
public String fluff;
|
||||
private String fluff;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -36,11 +36,68 @@ public class QuestStallDefinition {
|
||||
* @param iconName
|
||||
* a {@link java.lang.String} object.
|
||||
*/
|
||||
public QuestStallDefinition(final String name,
|
||||
final String displayName, final String fluff, final String iconName) {
|
||||
this.name = name;
|
||||
this.displayName = displayName;
|
||||
this.fluff = fluff;
|
||||
this.iconName = iconName;
|
||||
public QuestStallDefinition(final String name, final String displayName, final String fluff, final String iconName) {
|
||||
this.setName(name);
|
||||
this.setDisplayName(displayName);
|
||||
this.setFluff(fluff);
|
||||
this.setIconName(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.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -20,9 +20,9 @@ import forge.AllZone;
|
||||
public class QuestStallManager {
|
||||
|
||||
/** Constant <code>stalls</code>. */
|
||||
static Map<String, QuestStallDefinition> stalls;
|
||||
private static Map<String, QuestStallDefinition> stalls;
|
||||
/** Constant <code>items</code>. */
|
||||
static Map<String, SortedSet<QuestStallPurchasable>> items;
|
||||
private static Map<String, SortedSet<QuestStallPurchasable>> items;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -30,24 +30,24 @@ public class QuestStallManager {
|
||||
* </p>
|
||||
*/
|
||||
public static void buildStalls() {
|
||||
stalls = new HashMap<String, QuestStallDefinition>();
|
||||
stalls.put(ALCHEMIST, new QuestStallDefinition(ALCHEMIST, "Alchemist",
|
||||
"The walls of this alchemist's stall are covered with shelves with potions, oils, "
|
||||
QuestStallManager.stalls = new HashMap<String, QuestStallDefinition>();
|
||||
QuestStallManager.stalls.put(QuestStallManager.ALCHEMIST, new QuestStallDefinition(QuestStallManager.ALCHEMIST,
|
||||
"Alchemist", "The walls of this alchemist's stall are covered with shelves with potions, oils, "
|
||||
+ "powders, poultices and elixirs, each meticulously labeled.", "BottlesIconSmall.png"));
|
||||
stalls.put(BANKER, new QuestStallDefinition(BANKER, "Banker",
|
||||
"A large book large enough to be seen from the outside rests on the Banker's desk.",
|
||||
QuestStallManager.stalls.put(QuestStallManager.BANKER, new QuestStallDefinition(QuestStallManager.BANKER,
|
||||
"Banker", "A large book large enough to be seen from the outside rests on the Banker's desk.",
|
||||
"CoinIconSmall.png"));
|
||||
stalls.put(BOOKSTORE, new QuestStallDefinition(BOOKSTORE, "Bookstore",
|
||||
"Tomes of different sizes are stacked in man-high towers.", "BookIconSmall.png"));
|
||||
stalls.put(GEAR, new QuestStallDefinition(GEAR, "Adventuring Gear",
|
||||
QuestStallManager.stalls.put(QuestStallManager.BOOKSTORE, new QuestStallDefinition(QuestStallManager.BOOKSTORE,
|
||||
"Bookstore", "Tomes of different sizes are stacked in man-high towers.", "BookIconSmall.png"));
|
||||
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.",
|
||||
"GearIconSmall.png"));
|
||||
stalls.put(NURSERY,
|
||||
new QuestStallDefinition(NURSERY, "Nursery",
|
||||
"The smells of the one hundred and one different plants forms a unique fragrance.",
|
||||
QuestStallManager.stalls.put(QuestStallManager.NURSERY, new QuestStallDefinition(QuestStallManager.NURSERY,
|
||||
"Nursery", "The smells of the one hundred and one different plants forms a unique fragrance.",
|
||||
"LeafIconSmall.png"));
|
||||
stalls.put(PET_SHOP, new QuestStallDefinition(PET_SHOP, "Pet Shop",
|
||||
"This large stall echoes with a multitude of animal noises.", "FoxIconSmall.png"));
|
||||
QuestStallManager.stalls.put(QuestStallManager.PET_SHOP, new QuestStallDefinition(QuestStallManager.PET_SHOP,
|
||||
"Pet Shop", "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.
|
||||
*/
|
||||
public static List<String> getStallNames() {
|
||||
List<String> ret = new ArrayList<String>();
|
||||
ret.add(ALCHEMIST);
|
||||
ret.add(BANKER);
|
||||
ret.add(BOOKSTORE);
|
||||
ret.add(GEAR);
|
||||
ret.add(NURSERY);
|
||||
ret.add(PET_SHOP);
|
||||
final List<String> ret = new ArrayList<String>();
|
||||
ret.add(QuestStallManager.ALCHEMIST);
|
||||
ret.add(QuestStallManager.BANKER);
|
||||
ret.add(QuestStallManager.BOOKSTORE);
|
||||
ret.add(QuestStallManager.GEAR);
|
||||
ret.add(QuestStallManager.NURSERY);
|
||||
ret.add(QuestStallManager.PET_SHOP);
|
||||
return ret;
|
||||
}
|
||||
|
||||
@@ -78,11 +78,11 @@ public class QuestStallManager {
|
||||
* @return a {@link forge.quest.data.bazaar.QuestStallDefinition} object.
|
||||
*/
|
||||
public static QuestStallDefinition getStall(final String stallName) {
|
||||
if (stalls == null) {
|
||||
buildStalls();
|
||||
if (QuestStallManager.stalls == null) {
|
||||
QuestStallManager.buildStalls();
|
||||
}
|
||||
|
||||
return stalls.get(stallName);
|
||||
return QuestStallManager.stalls.get(stallName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -91,19 +91,19 @@ public class QuestStallManager {
|
||||
* </p>
|
||||
*/
|
||||
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().getPetManager().getPetsAndPlants());
|
||||
|
||||
items = new HashMap<String, SortedSet<QuestStallPurchasable>>();
|
||||
QuestStallManager.items = new HashMap<String, SortedSet<QuestStallPurchasable>>();
|
||||
|
||||
for (String stallName : getStallNames()) {
|
||||
items.put(stallName, new TreeSet<QuestStallPurchasable>());
|
||||
for (final String stallName : QuestStallManager.getStallNames()) {
|
||||
QuestStallManager.items.put(stallName, new TreeSet<QuestStallPurchasable>());
|
||||
}
|
||||
|
||||
for (QuestStallPurchasable purchasable : itemSet) {
|
||||
items.get(purchasable.getStallName()).add(purchasable);
|
||||
for (final QuestStallPurchasable purchasable : itemSet) {
|
||||
QuestStallManager.items.get(purchasable.getStallName()).add(purchasable);
|
||||
}
|
||||
|
||||
}
|
||||
@@ -118,13 +118,13 @@ public class QuestStallManager {
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public static List<QuestStallPurchasable> getItems(final String stallName) {
|
||||
if (items == null) {
|
||||
buildItems();
|
||||
if (QuestStallManager.items == null) {
|
||||
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()) {
|
||||
ret.add(purchasable);
|
||||
}
|
||||
|
||||
@@ -18,7 +18,7 @@ import java.util.TreeSet;
|
||||
public class QuestInventory {
|
||||
|
||||
/** The inventory. */
|
||||
Map<String, QuestItemAbstract> inventory = new HashMap<String, QuestItemAbstract>();
|
||||
private Map<String, QuestItemAbstract> inventory = new HashMap<String, QuestItemAbstract>();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -26,9 +26,9 @@ public class QuestInventory {
|
||||
* </p>
|
||||
*/
|
||||
public QuestInventory() {
|
||||
Set<QuestItemAbstract> allItems = getAllItems();
|
||||
for (QuestItemAbstract item : allItems) {
|
||||
inventory.put(item.getName(), item);
|
||||
final Set<QuestItemAbstract> allItems = QuestInventory.getAllItems();
|
||||
for (final QuestItemAbstract item : allItems) {
|
||||
this.inventory.put(item.getName(), item);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -42,7 +42,7 @@ public class QuestInventory {
|
||||
* @return a boolean.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public final int getItemLevel(final String itemName) {
|
||||
QuestItemAbstract item = inventory.get(itemName);
|
||||
final QuestItemAbstract item = this.inventory.get(itemName);
|
||||
if (item == null) {
|
||||
return 0;
|
||||
}
|
||||
@@ -85,7 +85,7 @@ public class QuestInventory {
|
||||
* a int.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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 QuestItemEstates());
|
||||
@@ -117,9 +117,9 @@ public class QuestInventory {
|
||||
* @return a {@link java.lang.Object} object.
|
||||
*/
|
||||
private Object readResolve() {
|
||||
for (QuestItemAbstract item : getAllItems()) {
|
||||
if (!inventory.containsKey(item.getName())) {
|
||||
inventory.put(item.getName(), item);
|
||||
for (final QuestItemAbstract item : QuestInventory.getAllItems()) {
|
||||
if (!this.inventory.containsKey(item.getName())) {
|
||||
this.inventory.put(item.getName(), item);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
@@ -133,7 +133,7 @@ public class QuestInventory {
|
||||
* @return a {@link java.util.Collection} object.
|
||||
*/
|
||||
public Collection<QuestItemAbstract> getItems() {
|
||||
return inventory.values();
|
||||
return this.inventory.values();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -145,7 +145,7 @@ public class QuestInventory {
|
||||
* a {@link java.lang.String} object.
|
||||
* @return a {@link forge.quest.data.item.QuestItemAbstract} object.
|
||||
*/
|
||||
public QuestItemAbstract getItem(String itemName) {
|
||||
return inventory.get(itemName);
|
||||
public QuestItemAbstract getItem(final String itemName) {
|
||||
return this.inventory.get(itemName);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,8 +13,8 @@ import forge.quest.data.bazaar.QuestStallPurchasable;
|
||||
*/
|
||||
public abstract class QuestItemAbstract implements QuestStallPurchasable {
|
||||
private int level = 0;
|
||||
private String name;
|
||||
private String shopName;
|
||||
private final String name;
|
||||
private final String shopName;
|
||||
private int maxLevel = 1;
|
||||
|
||||
/**
|
||||
@@ -56,7 +56,7 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public final String getStallName() {
|
||||
return shopName;
|
||||
return this.shopName;
|
||||
}
|
||||
|
||||
/**
|
||||
* This method will be invoked when an item is bought in a shop.
|
||||
*/
|
||||
@Override
|
||||
public void onPurchase() {
|
||||
int currentLevel = AllZone.getQuestData().getInventory().getItemLevel(name);
|
||||
AllZone.getQuestData().getInventory().setItemLevel(name, currentLevel + 1);
|
||||
final int currentLevel = AllZone.getQuestData().getInventory().getItemLevel(this.name);
|
||||
AllZone.getQuestData().getInventory().setItemLevel(this.name, currentLevel + 1);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,8 +97,9 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
@Override
|
||||
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.
|
||||
*/
|
||||
public final int getLevel() {
|
||||
return level;
|
||||
return this.level;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -129,7 +133,7 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
|
||||
* @return a int.
|
||||
*/
|
||||
public final int getMaxLevel() {
|
||||
return maxLevel;
|
||||
return this.maxLevel;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,7 +144,7 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
|
||||
* @return a boolean.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public abstract String getPurchaseDescription();
|
||||
|
||||
/**
|
||||
@@ -159,6 +164,7 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
@Override
|
||||
public abstract String getImageName();
|
||||
|
||||
/**
|
||||
@@ -168,11 +174,13 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
@Override
|
||||
public abstract int getPrice();
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final int compareTo(final Object o) {
|
||||
QuestStallPurchasable q = (QuestStallPurchasable) o;
|
||||
final QuestStallPurchasable q = (QuestStallPurchasable) o;
|
||||
return this.getPurchaseName().compareTo(q.getPurchaseName());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -35,9 +35,9 @@ public class QuestItemElixir extends QuestItemAbstract {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final int getPrice() {
|
||||
if (getLevel() < 5) {
|
||||
if (this.getLevel() < 5) {
|
||||
return 250;
|
||||
} else if (getLevel() < 10) {
|
||||
} else if (this.getLevel() < 10) {
|
||||
return 500;
|
||||
} else {
|
||||
return 750;
|
||||
|
||||
@@ -24,7 +24,8 @@ public class QuestItemEstates extends QuestItemAbstract {
|
||||
@Override
|
||||
public final String getPurchaseDescription() {
|
||||
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} */
|
||||
@@ -36,9 +37,9 @@ public class QuestItemEstates extends QuestItemAbstract {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final int getPrice() {
|
||||
if (getLevel() == 0) {
|
||||
if (this.getLevel() == 0) {
|
||||
return 500;
|
||||
} else if (getLevel() == 1) {
|
||||
} else if (this.getLevel() == 1) {
|
||||
return 750;
|
||||
} else {
|
||||
return 1000;
|
||||
|
||||
@@ -14,7 +14,7 @@ import forge.quest.data.bazaar.QuestStallManager;
|
||||
public class QuestItemZeppelin extends QuestItemAbstract {
|
||||
|
||||
/** The zeppelin used. */
|
||||
boolean zeppelinUsed = false;
|
||||
private boolean zeppelinUsed = false;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -66,7 +66,7 @@ public class QuestItemZeppelin extends QuestItemAbstract {
|
||||
* @return a boolean.
|
||||
*/
|
||||
public final boolean hasBeenUsed() {
|
||||
return zeppelinUsed;
|
||||
return this.zeppelinUsed;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
/** Forge Card Game. */
|
||||
package forge.quest.data.item;
|
||||
|
||||
|
||||
@@ -16,11 +16,11 @@ import forge.quest.data.bazaar.QuestStallPurchasable;
|
||||
public abstract class QuestPetAbstract implements QuestStallPurchasable {
|
||||
|
||||
/** The level. */
|
||||
int level;
|
||||
private int maxLevel;
|
||||
private int level;
|
||||
private final int maxLevel;
|
||||
// transient here ?
|
||||
private String name;
|
||||
private String description;
|
||||
private final String name;
|
||||
private final String description;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -47,8 +47,9 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
@Override
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public final int getLevel() {
|
||||
return level;
|
||||
return this.level;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -139,8 +141,8 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
|
||||
* </p>
|
||||
*/
|
||||
public final void incrementLevel() {
|
||||
if (level < maxLevel) {
|
||||
level++;
|
||||
if (this.level < this.maxLevel) {
|
||||
this.level++;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -152,7 +154,7 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
|
||||
* @return a int.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public final String getPurchaseDescription() {
|
||||
return "<em>" + getDescription() + "</em><br>" + getUpgradeDescription() + "<br><br><u>Current stats:</u> "
|
||||
+ getStats() + "<br><u>Upgraded stats:</u> " + getUpgradedStats();
|
||||
return "<em>" + this.getDescription() + "</em><br>" + this.getUpgradeDescription()
|
||||
+ "<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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public final String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final String toString() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
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.
|
||||
*/
|
||||
@Override
|
||||
public String getStallName() {
|
||||
return QuestStallManager.PET_SHOP;
|
||||
}
|
||||
@@ -260,8 +267,9 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
@Override
|
||||
public boolean isAvailableForPurchase() {
|
||||
QuestPetAbstract pet = AllZone.getQuestData().getPetManager().getPet(name);
|
||||
final QuestPetAbstract pet = AllZone.getQuestData().getPetManager().getPet(this.name);
|
||||
if (pet == null) {
|
||||
return true;
|
||||
}
|
||||
@@ -273,7 +281,8 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
|
||||
* onPurchase.
|
||||
* </p>
|
||||
*/
|
||||
@Override
|
||||
public void onPurchase() {
|
||||
AllZone.getQuestData().getPetManager().addPetLevel(name);
|
||||
AllZone.getQuestData().getPetManager().addPetLevel(this.name);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class QuestPetBird extends QuestPetAbstract {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final Card getPetCard() {
|
||||
Card petCard = new Card();
|
||||
final Card petCard = new Card();
|
||||
|
||||
petCard.setName("Bird Pet");
|
||||
petCard.addController(AllZone.getHumanPlayer());
|
||||
@@ -30,19 +30,19 @@ public class QuestPetBird extends QuestPetAbstract {
|
||||
|
||||
petCard.addIntrinsicKeyword("Flying");
|
||||
|
||||
if (level == 1) {
|
||||
if (this.getLevel() == 1) {
|
||||
petCard.setImageName("W 0 1 Bird Pet");
|
||||
petCard.setBaseAttack(0);
|
||||
petCard.setBaseDefense(1);
|
||||
} else if (level == 2) {
|
||||
} else if (this.getLevel() == 2) {
|
||||
petCard.setImageName("W 1 1 Bird Pet");
|
||||
petCard.setBaseAttack(1);
|
||||
petCard.setBaseDefense(1);
|
||||
} else if (level == 3) {
|
||||
} else if (this.getLevel() == 3) {
|
||||
petCard.setImageName("W 2 1 Bird Pet");
|
||||
petCard.setBaseAttack(2);
|
||||
petCard.setBaseDefense(1);
|
||||
} else if (level == 4) {
|
||||
} else if (this.getLevel() == 4) {
|
||||
petCard.setImageName("W 2 1 Bird Pet First Strike");
|
||||
petCard.setBaseAttack(2);
|
||||
petCard.setBaseDefense(1);
|
||||
|
||||
@@ -15,7 +15,7 @@ public class QuestPetCrocodile extends QuestPetAbstract {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final Card getPetCard() {
|
||||
Card petCard = new Card();
|
||||
final Card petCard = new Card();
|
||||
petCard.setName("Crocodile Pet");
|
||||
petCard.addController(AllZone.getHumanPlayer());
|
||||
petCard.setOwner(AllZone.getHumanPlayer());
|
||||
@@ -27,19 +27,19 @@ public class QuestPetCrocodile extends QuestPetAbstract {
|
||||
petCard.addType("Crocodile");
|
||||
petCard.addType("Pet");
|
||||
|
||||
if (level == 1) {
|
||||
if (this.getLevel() == 1) {
|
||||
petCard.setImageName("B 1 1 Crocodile Pet");
|
||||
petCard.setBaseAttack(1);
|
||||
petCard.setBaseDefense(1);
|
||||
} else if (level == 2) {
|
||||
} else if (this.getLevel() == 2) {
|
||||
petCard.setImageName("B 2 1 Crocodile Pet");
|
||||
petCard.setBaseAttack(2);
|
||||
petCard.setBaseDefense(1);
|
||||
} else if (level == 3) {
|
||||
} else if (this.getLevel() == 3) {
|
||||
petCard.setImageName("B 3 1 Crocodile Pet");
|
||||
petCard.setBaseAttack(3);
|
||||
petCard.setBaseDefense(1);
|
||||
} else if (level == 4) {
|
||||
} else if (this.getLevel() == 4) {
|
||||
petCard.setImageName("B 3 1 Crocodile Pet Swampwalk");
|
||||
petCard.setBaseAttack(3);
|
||||
petCard.setBaseDefense(1);
|
||||
|
||||
@@ -27,7 +27,7 @@ public class QuestPetHound extends QuestPetAbstract {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final Card getPetCard() {
|
||||
Card petCard = new Card();
|
||||
final Card petCard = new Card();
|
||||
|
||||
petCard.setName("Hound Pet");
|
||||
petCard.addController(AllZone.getHumanPlayer());
|
||||
@@ -40,22 +40,22 @@ public class QuestPetHound extends QuestPetAbstract {
|
||||
petCard.addType("Hound");
|
||||
petCard.addType("Pet");
|
||||
|
||||
if (level == 1) {
|
||||
if (this.getLevel() == 1) {
|
||||
petCard.setImageName("R 1 1 Hound Pet");
|
||||
petCard.setBaseAttack(1);
|
||||
petCard.setBaseDefense(1);
|
||||
} else if (level == 2) {
|
||||
} else if (this.getLevel() == 2) {
|
||||
petCard.setImageName("R 1 1 Hound Pet Haste");
|
||||
petCard.setBaseAttack(1);
|
||||
petCard.setBaseDefense(1);
|
||||
petCard.addIntrinsicKeyword("Haste");
|
||||
} else if (level == 3) {
|
||||
} else if (this.getLevel() == 3) {
|
||||
petCard.setImageName("R 2 1 Hound Pet");
|
||||
petCard.setBaseAttack(2);
|
||||
petCard.setBaseDefense(1);
|
||||
petCard.addIntrinsicKeyword("Haste");
|
||||
|
||||
} else if (level == 4) {
|
||||
} else if (this.getLevel() == 4) {
|
||||
petCard.setImageName("R 2 1 Hound Pet Alone");
|
||||
petCard.setBaseAttack(2);
|
||||
petCard.setBaseDefense(1);
|
||||
@@ -65,7 +65,7 @@ public class QuestPetHound extends QuestPetAbstract {
|
||||
.parseTrigger(
|
||||
"Mode$ Attacks | ValidCard$ Card.Self | Alone$ True | TriggerDescription$ Whenever CARDNAME attacks alone, it gets +2/+0 until end of turn.",
|
||||
petCard, true);
|
||||
AbilityFactory af = new AbilityFactory();
|
||||
final AbilityFactory af = new AbilityFactory();
|
||||
myTrigger.setOverridingAbility(af.getAbility("AB$Pump | Cost$ 0 | Defined$ Self | NumAtt$ 2", petCard));
|
||||
petCard.addTrigger(myTrigger);
|
||||
}
|
||||
|
||||
@@ -36,9 +36,9 @@ public class QuestPetManager {
|
||||
* </p>
|
||||
*/
|
||||
public QuestPetManager() {
|
||||
plant = new QuestPetPlant();
|
||||
for (QuestPetAbstract pet : getAllPets()) {
|
||||
addPet(pet);
|
||||
this.plant = new QuestPetPlant();
|
||||
for (final QuestPetAbstract pet : QuestPetManager.getAllPets()) {
|
||||
this.addPet(pet);
|
||||
}
|
||||
}
|
||||
|
||||
@@ -51,7 +51,7 @@ public class QuestPetManager {
|
||||
* a {@link java.lang.String} object.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public final QuestPetAbstract getPlant() {
|
||||
return plant;
|
||||
return this.plant;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -82,10 +82,10 @@ public class QuestPetManager {
|
||||
* </p>
|
||||
*/
|
||||
public final void addPlantLevel() {
|
||||
if (plant == null) {
|
||||
plant = new QuestPetPlant();
|
||||
if (this.plant == null) {
|
||||
this.plant = new QuestPetPlant();
|
||||
} else {
|
||||
plant.incrementLevel();
|
||||
this.plant.incrementLevel();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -100,7 +100,7 @@ public class QuestPetManager {
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public final boolean shouldPlantBeUsed() {
|
||||
return usePlant;
|
||||
return this.usePlant;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -157,7 +157,7 @@ public class QuestPetManager {
|
||||
* @return a boolean.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
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 QuestPetCrocodile());
|
||||
@@ -186,8 +186,8 @@ public class QuestPetManager {
|
||||
* @return a {@link java.util.Set} object.
|
||||
*/
|
||||
public final Set<String> getAvailablePetNames() {
|
||||
SortedSet<String> set = new TreeSet<String>();
|
||||
for (Map.Entry<String, QuestPetAbstract> pet : pets.entrySet()) {
|
||||
final SortedSet<String> set = new TreeSet<String>();
|
||||
for (final Map.Entry<String, QuestPetAbstract> pet : this.pets.entrySet()) {
|
||||
if (pet.getValue().getLevel() > 0) {
|
||||
set.add(pet.getKey());
|
||||
}
|
||||
@@ -203,8 +203,8 @@ public class QuestPetManager {
|
||||
* @return a {@link java.util.Collection} object.
|
||||
*/
|
||||
public final Collection<QuestPetAbstract> getPetsAndPlants() {
|
||||
Set<QuestPetAbstract> petsAndPlants = new HashSet<QuestPetAbstract>(pets.values());
|
||||
petsAndPlants.add(plant);
|
||||
final Set<QuestPetAbstract> petsAndPlants = new HashSet<QuestPetAbstract>(this.pets.values());
|
||||
petsAndPlants.add(this.plant);
|
||||
|
||||
return petsAndPlants;
|
||||
}
|
||||
@@ -218,9 +218,9 @@ public class QuestPetManager {
|
||||
* @return a {@link java.lang.Object} object.
|
||||
*/
|
||||
private Object readResolve() {
|
||||
for (QuestPetAbstract pet : getAllPets()) {
|
||||
if (!pets.containsKey(pet.getName())) {
|
||||
addPet(pet);
|
||||
for (final QuestPetAbstract pet : QuestPetManager.getAllPets()) {
|
||||
if (!this.pets.containsKey(pet.getName())) {
|
||||
this.addPet(pet);
|
||||
}
|
||||
}
|
||||
return this;
|
||||
|
||||
@@ -17,7 +17,9 @@ import forge.quest.data.bazaar.QuestStallManager;
|
||||
* @version $Id$
|
||||
*/
|
||||
public class QuestPetPlant extends QuestPetAbstract {
|
||||
/** {@inheritDoc} */
|
||||
/** QuestPetPlant.
|
||||
* @return Card
|
||||
*/
|
||||
@Override
|
||||
public final Card getPetCard() {
|
||||
final Card petCard = new Card();
|
||||
@@ -36,35 +38,35 @@ public class QuestPetPlant extends QuestPetAbstract {
|
||||
|
||||
petCard.addIntrinsicKeyword("Defender");
|
||||
|
||||
if (level == 1) {
|
||||
if (this.getLevel() == 1) {
|
||||
petCard.setImageName("G 0 1 Plant Wall");
|
||||
petCard.setBaseAttack(0);
|
||||
petCard.setBaseDefense(1);
|
||||
} else if (level == 2) {
|
||||
} else if (this.getLevel() == 2) {
|
||||
petCard.setImageName("G 0 2 Plant Wall");
|
||||
petCard.setBaseAttack(0);
|
||||
petCard.setBaseDefense(2);
|
||||
} else if (level == 3) {
|
||||
} else if (this.getLevel() == 3) {
|
||||
petCard.setImageName("G 0 3 Plant Wall");
|
||||
petCard.setBaseAttack(0);
|
||||
petCard.setBaseDefense(3);
|
||||
} else if (level == 4) {
|
||||
} else if (this.getLevel() == 4) {
|
||||
petCard.setImageName("G 1 3 Plant Wall");
|
||||
petCard.setBaseAttack(1);
|
||||
petCard.setBaseDefense(3);
|
||||
// petCard.addIntrinsicKeyword("First Strike");
|
||||
} else if (level == 5) {
|
||||
} else if (this.getLevel() == 5) {
|
||||
petCard.setImageName("G 1 3 Plant Wall Deathtouch");
|
||||
petCard.setBaseAttack(1);
|
||||
petCard.setBaseDefense(3);
|
||||
petCard.addIntrinsicKeyword("Deathtouch");
|
||||
} else if (level == 6) {
|
||||
} else if (this.getLevel() == 6) {
|
||||
petCard.setImageName("G 1 4 Plant Wall");
|
||||
petCard.setBaseAttack(1);
|
||||
petCard.setBaseDefense(4);
|
||||
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) {
|
||||
private static final long serialVersionUID = 7546242087593613719L;
|
||||
|
||||
@@ -81,7 +83,7 @@ public class QuestPetPlant extends QuestPetAbstract {
|
||||
petCard.addSpellAbility(ability);
|
||||
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.");
|
||||
ability.setStackDescription(sb.toString());
|
||||
|
||||
@@ -149,8 +151,8 @@ public class QuestPetPlant extends QuestPetAbstract {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
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());
|
||||
}
|
||||
}
|
||||
|
||||
@@ -15,7 +15,7 @@ public class QuestPetWolf extends QuestPetAbstract {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final Card getPetCard() {
|
||||
Card petCard = new Card();
|
||||
final Card petCard = new Card();
|
||||
|
||||
petCard.setName("Wolf Pet");
|
||||
petCard.addController(AllZone.getHumanPlayer());
|
||||
@@ -28,19 +28,19 @@ public class QuestPetWolf extends QuestPetAbstract {
|
||||
petCard.addType("Wolf");
|
||||
petCard.addType("Pet");
|
||||
|
||||
if (level == 1) {
|
||||
if (this.getLevel() == 1) {
|
||||
petCard.setImageName("G 1 1 Wolf Pet");
|
||||
petCard.setBaseAttack(1);
|
||||
petCard.setBaseDefense(1);
|
||||
} else if (level == 2) {
|
||||
} else if (this.getLevel() == 2) {
|
||||
petCard.setImageName("G 1 2 Wolf Pet");
|
||||
petCard.setBaseAttack(1);
|
||||
petCard.setBaseDefense(2);
|
||||
} else if (level == 3) {
|
||||
} else if (this.getLevel() == 3) {
|
||||
petCard.setImageName("G 2 2 Wolf Pet");
|
||||
petCard.setBaseAttack(2);
|
||||
petCard.setBaseDefense(2);
|
||||
} else if (level == 4) {
|
||||
} else if (this.getLevel() == 4) {
|
||||
petCard.setImageName("G 2 2 Wolf Pet Flanking");
|
||||
petCard.setBaseAttack(2);
|
||||
petCard.setBaseDefense(2);
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
/** Forge Card Game. */
|
||||
package forge.quest.data.pet;
|
||||
|
||||
|
||||
@@ -15,7 +15,7 @@ public abstract class QuestAbstractPanel extends JPanel {
|
||||
private static final long serialVersionUID = -6378675010346615367L;
|
||||
|
||||
/** The main frame. */
|
||||
public QuestFrame mainFrame;
|
||||
private QuestFrame mainFrame;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -26,7 +26,7 @@ public abstract class QuestAbstractPanel extends JPanel {
|
||||
* a {@link forge.quest.gui.QuestFrame} object.
|
||||
*/
|
||||
protected QuestAbstractPanel(final QuestFrame mainFrame) {
|
||||
this.mainFrame = mainFrame;
|
||||
this.setMainFrame(mainFrame);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -35,4 +35,18 @@ public abstract class QuestAbstractPanel extends JPanel {
|
||||
* </p>
|
||||
*/
|
||||
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.
|
||||
}
|
||||
}
|
||||
|
||||
@@ -3,12 +3,12 @@ package forge.quest.gui;
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.CardLayout;
|
||||
import java.awt.Dimension;
|
||||
import java.awt.HeadlessException;
|
||||
import java.util.HashMap;
|
||||
import java.util.Map;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.WindowConstants;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
|
||||
import forge.AllZone;
|
||||
@@ -30,10 +30,10 @@ public class QuestFrame extends JFrame {
|
||||
private static final long serialVersionUID = -2832625381531838412L;
|
||||
|
||||
/** The visible panel. */
|
||||
JPanel visiblePanel;
|
||||
private JPanel visiblePanel;
|
||||
|
||||
/** The quest layout. */
|
||||
CardLayout questLayout;
|
||||
private CardLayout questLayout;
|
||||
|
||||
/** Constant <code>MAIN_PANEL="Main"</code>. */
|
||||
public static final String MAIN_PANEL = "Main";
|
||||
@@ -42,40 +42,40 @@ public class QuestFrame extends JFrame {
|
||||
public static final String BAZAAR_PANEL = "Bazaar";
|
||||
|
||||
/** The sub panel map. */
|
||||
Map<String, QuestAbstractPanel> subPanelMap = new HashMap<String, QuestAbstractPanel>();
|
||||
private Map<String, QuestAbstractPanel> subPanelMap = new HashMap<String, QuestAbstractPanel>();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
* Constructor for QuestFrame.
|
||||
* </p>
|
||||
*
|
||||
* @throws HeadlessException
|
||||
*
|
||||
* the headless exception
|
||||
*/
|
||||
public QuestFrame() throws HeadlessException {
|
||||
public QuestFrame() {
|
||||
this.setTitle("Quest Mode");
|
||||
|
||||
visiblePanel = new JPanel(new BorderLayout());
|
||||
visiblePanel.setBorder(new EmptyBorder(2, 2, 2, 2));
|
||||
questLayout = new CardLayout();
|
||||
visiblePanel.setLayout(questLayout);
|
||||
this.visiblePanel = new JPanel(new BorderLayout());
|
||||
this.visiblePanel.setBorder(new EmptyBorder(2, 2, 2, 2));
|
||||
this.questLayout = new CardLayout();
|
||||
this.visiblePanel.setLayout(this.questLayout);
|
||||
|
||||
QuestAbstractPanel newPanel = new QuestMainPanel(this);
|
||||
visiblePanel.add(newPanel, MAIN_PANEL);
|
||||
subPanelMap.put(MAIN_PANEL, newPanel);
|
||||
this.visiblePanel.add(newPanel, QuestFrame.MAIN_PANEL);
|
||||
this.subPanelMap.put(QuestFrame.MAIN_PANEL, newPanel);
|
||||
|
||||
newPanel = new QuestBazaarPanel(this);
|
||||
visiblePanel.add(newPanel, BAZAAR_PANEL);
|
||||
subPanelMap.put(BAZAAR_PANEL, newPanel);
|
||||
this.visiblePanel.add(newPanel, QuestFrame.BAZAAR_PANEL);
|
||||
this.subPanelMap.put(QuestFrame.BAZAAR_PANEL, newPanel);
|
||||
|
||||
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.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.setVisible(true);
|
||||
|
||||
@@ -92,8 +92,8 @@ public class QuestFrame extends JFrame {
|
||||
* a {@link java.lang.String} object.
|
||||
*/
|
||||
private void showPane(final String paneName) {
|
||||
subPanelMap.get(paneName).refreshState();
|
||||
questLayout.show(visiblePanel, paneName);
|
||||
this.subPanelMap.get(paneName).refreshState();
|
||||
this.questLayout.show(this.visiblePanel, paneName);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -102,7 +102,7 @@ public class QuestFrame extends JFrame {
|
||||
* </p>
|
||||
*/
|
||||
public final void showMainPane() {
|
||||
showPane(MAIN_PANEL);
|
||||
this.showPane(QuestFrame.MAIN_PANEL);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -111,7 +111,7 @@ public class QuestFrame extends JFrame {
|
||||
* </p>
|
||||
*/
|
||||
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").equalsIgnoreCase("true")) {
|
||||
String[] argz = {};
|
||||
final String[] argz = {};
|
||||
Gui_HomeScreen.main(argz);
|
||||
} else {
|
||||
new OldGuiNewGame();
|
||||
|
||||
@@ -58,52 +58,52 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
/** Constant <code>serialVersionUID=6142934729724012402L</code>. */
|
||||
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;
|
||||
|
||||
/** The credits label. */
|
||||
JLabel creditsLabel = new JLabel();
|
||||
private JLabel creditsLabel = new JLabel();
|
||||
|
||||
/** The life label. */
|
||||
JLabel lifeLabel = new JLabel();
|
||||
private JLabel lifeLabel = new JLabel();
|
||||
|
||||
/** The stats label. */
|
||||
JLabel statsLabel = new JLabel();
|
||||
private JLabel statsLabel = new JLabel();
|
||||
|
||||
/** The title label. */
|
||||
JLabel titleLabel = new JLabel();
|
||||
private JLabel titleLabel = new JLabel();
|
||||
|
||||
/** The next quest label. */
|
||||
JLabel nextQuestLabel = new JLabel();
|
||||
private JLabel nextQuestLabel = new JLabel();
|
||||
|
||||
/** The pet combo box. */
|
||||
JComboBox petComboBox = new JComboBox();
|
||||
private JComboBox petComboBox = new JComboBox();
|
||||
|
||||
/** The deck combo box. */
|
||||
JComboBox deckComboBox = new JComboBox();
|
||||
private JComboBox deckComboBox = new JComboBox();
|
||||
|
||||
/** The event button. */
|
||||
JButton eventButton = new JButton("Challenges");
|
||||
private JButton eventButton = new JButton("Challenges");
|
||||
|
||||
/** The play button. */
|
||||
JButton playButton = new JButton("Play");
|
||||
private JButton playButton = new JButton("Play");
|
||||
|
||||
private QuestSelectablePanel selectedOpponent;
|
||||
|
||||
/** The next match panel. */
|
||||
JPanel nextMatchPanel = new JPanel();
|
||||
private JPanel nextMatchPanel = new JPanel();
|
||||
|
||||
/** The next match layout. */
|
||||
CardLayout nextMatchLayout;
|
||||
private CardLayout nextMatchLayout;
|
||||
|
||||
/** The is showing challenges. */
|
||||
boolean isShowingChallenges = false;
|
||||
private JCheckBox devModeCheckBox = new JCheckBox("Developer Mode");
|
||||
private boolean isShowingChallenges = false;
|
||||
private final JCheckBox devModeCheckBox = new JCheckBox("Developer Mode");
|
||||
// private JCheckBox newGUICheckbox = new JCheckBox("Use new UI", true);
|
||||
private JCheckBox smoothLandCheckBox = new JCheckBox("Adjust AI Land");
|
||||
private JCheckBox petCheckBox = new JCheckBox("Summon Pet");
|
||||
private final JCheckBox smoothLandCheckBox = new JCheckBox("Adjust AI Land");
|
||||
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>. */
|
||||
private static final String NO_DECKS_AVAILABLE = "No decks available";
|
||||
/** Constant <code>DUELS="Duels"</code>. */
|
||||
@@ -112,11 +112,14 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
private static final String CHALLENGES = "Challenges";
|
||||
|
||||
// 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 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));
|
||||
private JPanel zeppelinPanel = new JPanel();
|
||||
private final JPanel zeppelinPanel = new JPanel();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -128,18 +131,18 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
*/
|
||||
public QuestMainPanel(final QuestFrame mainFrame) {
|
||||
super(mainFrame);
|
||||
questData = AllZone.getQuestData();
|
||||
qem = AllZone.getQuestEventManager();
|
||||
this.questData = AllZone.getQuestData();
|
||||
this.qem = AllZone.getQuestEventManager();
|
||||
|
||||
// QuestEventManager is the MODEL for this VIEW.
|
||||
// All quest events are generated here, the first time the VIEW is made.
|
||||
if (qem == null) {
|
||||
qem = new QuestEventManager();
|
||||
qem.assembleAllEvents();
|
||||
AllZone.setQuestEventManager(qem);
|
||||
if (this.qem == null) {
|
||||
this.qem = new QuestEventManager();
|
||||
this.qem.assembleAllEvents();
|
||||
AllZone.setQuestEventManager(this.qem);
|
||||
}
|
||||
|
||||
initUI();
|
||||
this.initUI();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -148,21 +151,21 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
* </p>
|
||||
*/
|
||||
private void initUI() {
|
||||
refresh();
|
||||
this.refresh();
|
||||
this.setLayout(new BorderLayout(5, 5));
|
||||
JPanel centerPanel = new JPanel(new BorderLayout());
|
||||
final JPanel centerPanel = new JPanel(new BorderLayout());
|
||||
this.add(centerPanel, BorderLayout.CENTER);
|
||||
|
||||
JPanel northPanel = createStatusPanel();
|
||||
final JPanel northPanel = this.createStatusPanel();
|
||||
this.add(northPanel, BorderLayout.NORTH);
|
||||
|
||||
JPanel eastPanel = createSidePanel();
|
||||
final JPanel eastPanel = this.createSidePanel();
|
||||
this.add(eastPanel, BorderLayout.EAST);
|
||||
|
||||
JPanel matchSettingsPanel = createMatchSettingsPanel();
|
||||
final JPanel matchSettingsPanel = this.createMatchSettingsPanel();
|
||||
centerPanel.add(matchSettingsPanel, BorderLayout.SOUTH);
|
||||
|
||||
centerPanel.add(nextMatchPanel, BorderLayout.CENTER);
|
||||
centerPanel.add(this.nextMatchPanel, BorderLayout.CENTER);
|
||||
this.setBorder(new EmptyBorder(5, 5, 5, 5));
|
||||
|
||||
}
|
||||
@@ -175,29 +178,29 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
* @return a {@link javax.swing.JPanel} object.
|
||||
*/
|
||||
private JPanel createStatusPanel() {
|
||||
JPanel northPanel = new JPanel();
|
||||
final JPanel northPanel = new JPanel();
|
||||
JLabel modeLabel;
|
||||
JLabel difficultyLabel; // Create labels at the top
|
||||
titleLabel.setFont(new Font(Font.DIALOG, Font.PLAIN, 28));
|
||||
titleLabel.setAlignmentX(LEFT_ALIGNMENT);
|
||||
this.titleLabel.setFont(new Font(Font.DIALOG, Font.PLAIN, 28));
|
||||
this.titleLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.Y_AXIS));
|
||||
northPanel.add(titleLabel);
|
||||
northPanel.add(this.titleLabel);
|
||||
|
||||
northPanel.add(Box.createVerticalStrut(5));
|
||||
|
||||
JPanel statusPanel = new JPanel();
|
||||
final JPanel statusPanel = new JPanel();
|
||||
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(Box.createHorizontalGlue());
|
||||
|
||||
difficultyLabel = new JLabel(questData.getDifficulty());
|
||||
difficultyLabel = new JLabel(this.questData.getDifficulty());
|
||||
statusPanel.add(difficultyLabel);
|
||||
statusPanel.add(Box.createHorizontalGlue());
|
||||
|
||||
statusPanel.add(statsLabel);
|
||||
statusPanel.add(this.statsLabel);
|
||||
|
||||
northPanel.add(statusPanel);
|
||||
return northPanel;
|
||||
@@ -211,23 +214,25 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
* @return a {@link javax.swing.JPanel} object.
|
||||
*/
|
||||
private JPanel createSidePanel() {
|
||||
JPanel panel = new JPanel();
|
||||
final JPanel panel = new JPanel();
|
||||
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
|
||||
|
||||
JButton mainMenuButton = new JButton("Return to Main Menu");
|
||||
final JButton mainMenuButton = new JButton("Return to Main Menu");
|
||||
mainMenuButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent actionEvent) {
|
||||
mainFrame.returnToMainMenu();
|
||||
QuestMainPanel.this.getMainFrame().returnToMainMenu();
|
||||
}
|
||||
});
|
||||
eastComponents.add(mainMenuButton);
|
||||
|
||||
JButton cardShopButton = new JButton("Card Shop");
|
||||
final JButton cardShopButton = new JButton("Card Shop");
|
||||
cardShopButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent actionEvent) {
|
||||
QuestMainPanel.this.showCardShop();
|
||||
}
|
||||
@@ -236,10 +241,11 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
cardShopButton.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 20));
|
||||
|
||||
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.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent actionEvent) {
|
||||
QuestMainPanel.this.showBazaar();
|
||||
}
|
||||
@@ -248,25 +254,27 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
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) {
|
||||
QuestMainPanel.this.showChallenges();
|
||||
}
|
||||
});
|
||||
eastComponents.add(eventButton);
|
||||
eventButton.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 18));
|
||||
eventButton.setPreferredSize(new Dimension(0, 60));
|
||||
eastComponents.add(this.eventButton);
|
||||
this.eventButton.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 18));
|
||||
this.eventButton.setPreferredSize(new Dimension(0, 60));
|
||||
|
||||
playButton.addActionListener(new ActionListener() {
|
||||
this.playButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent actionEvent) {
|
||||
QuestMainPanel.this.launchGame();
|
||||
}
|
||||
});
|
||||
|
||||
playButton.setFont(new Font(Font.DIALOG, Font.BOLD, 28));
|
||||
playButton.setPreferredSize(new Dimension(0, 100));
|
||||
this.playButton.setFont(new Font(Font.DIALOG, Font.BOLD, 28));
|
||||
this.playButton.setPreferredSize(new Dimension(0, 100));
|
||||
|
||||
eastComponents.add(playButton);
|
||||
eastComponents.add(this.playButton);
|
||||
eastComponents.add(optionsPanel);
|
||||
|
||||
GuiUtils.setWidthToMax(eastComponents);
|
||||
@@ -277,7 +285,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
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);
|
||||
this.lifeLabel.setFont(new Font(Font.DIALOG, Font.BOLD, 14));
|
||||
this.lifeLabel.setIcon(GuiUtils.getResizedIcon(GuiUtils.getIconFromFile("Life.png"), 30, 30));
|
||||
@@ -290,19 +298,19 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
GuiUtils.addGap(panel, 10);
|
||||
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);
|
||||
panel.add(bazaarButton);
|
||||
}
|
||||
|
||||
panel.add(Box.createVerticalGlue());
|
||||
|
||||
panel.add(eventButton);
|
||||
panel.add(this.eventButton);
|
||||
this.nextQuestLabel.setFont(new Font(Font.DIALOG, Font.PLAIN, 11));
|
||||
panel.add(nextQuestLabel);
|
||||
panel.add(this.nextQuestLabel);
|
||||
GuiUtils.addGap(panel);
|
||||
|
||||
panel.add(playButton);
|
||||
panel.add(this.playButton);
|
||||
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||
return panel;
|
||||
@@ -338,66 +346,72 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
*/
|
||||
private JPanel createMatchSettingsPanel() {
|
||||
|
||||
JPanel matchPanel = new JPanel();
|
||||
final JPanel matchPanel = new JPanel();
|
||||
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));
|
||||
|
||||
JLabel deckLabel = new JLabel("Use Deck");
|
||||
final JLabel deckLabel = new JLabel("Use Deck");
|
||||
deckPanel.add(deckLabel);
|
||||
GuiUtils.addGap(deckPanel);
|
||||
|
||||
this.deckComboBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent actionEvent) {
|
||||
playButton.setEnabled(canGameBeLaunched());
|
||||
lastUsedDeck = (String) deckComboBox.getSelectedItem();
|
||||
QuestMainPanel.this.playButton.setEnabled(QuestMainPanel.this.canGameBeLaunched());
|
||||
QuestMainPanel.lastUsedDeck = (String) QuestMainPanel.this.deckComboBox.getSelectedItem();
|
||||
}
|
||||
});
|
||||
|
||||
deckPanel.add(this.deckComboBox);
|
||||
GuiUtils.addGap(deckPanel);
|
||||
|
||||
JButton editDeckButton = new JButton("Deck Editor");
|
||||
final JButton editDeckButton = new JButton("Deck Editor");
|
||||
editDeckButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent actionEvent) {
|
||||
showDeckEditor();
|
||||
QuestMainPanel.this.showDeckEditor();
|
||||
}
|
||||
});
|
||||
deckPanel.add(editDeckButton);
|
||||
deckPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, deckPanel.getPreferredSize().height));
|
||||
deckPanel.setAlignmentX(LEFT_ALIGNMENT);
|
||||
deckPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
matchPanel.add(deckPanel);
|
||||
|
||||
GuiUtils.addGap(matchPanel);
|
||||
|
||||
if (questData.getMode().equals(forge.quest.data.QuestData.FANTASY)) {
|
||||
JPanel fantasyPanel = new JPanel();
|
||||
if (this.questData.getMode().equals(forge.quest.data.QuestData.FANTASY)) {
|
||||
final JPanel fantasyPanel = new JPanel();
|
||||
fantasyPanel.setLayout(new BorderLayout());
|
||||
|
||||
JPanel petPanel = new JPanel();
|
||||
final JPanel petPanel = new JPanel();
|
||||
petPanel.setLayout(new BoxLayout(petPanel, BoxLayout.X_AXIS));
|
||||
|
||||
this.petCheckBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent actionEvent) {
|
||||
if (petCheckBox.isSelected()) {
|
||||
questData.getPetManager().setSelectedPet((String) petComboBox.getSelectedItem());
|
||||
if (QuestMainPanel.this.petCheckBox.isSelected()) {
|
||||
QuestMainPanel.this.questData.getPetManager().setSelectedPet(
|
||||
(String) QuestMainPanel.this.petComboBox.getSelectedItem());
|
||||
} 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);
|
||||
GuiUtils.addGap(petPanel);
|
||||
this.petComboBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent actionEvent) {
|
||||
if (petCheckBox.isSelected()) {
|
||||
questData.getPetManager().setSelectedPet((String) petComboBox.getSelectedItem());
|
||||
if (QuestMainPanel.this.petCheckBox.isSelected()) {
|
||||
QuestMainPanel.this.questData.getPetManager().setSelectedPet(
|
||||
(String) QuestMainPanel.this.petComboBox.getSelectedItem());
|
||||
} else {
|
||||
questData.getPetManager().setSelectedPet(null);
|
||||
QuestMainPanel.this.questData.getPetManager().setSelectedPet(null);
|
||||
}
|
||||
}
|
||||
});
|
||||
@@ -406,32 +420,35 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
petPanel.add(this.petComboBox);
|
||||
|
||||
this.plantBox.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent actionEvent) {
|
||||
questData.getPetManager().usePlant = plantBox.isSelected();
|
||||
QuestMainPanel.this.questData.getPetManager().usePlant = QuestMainPanel.this.plantBox.isSelected();
|
||||
}
|
||||
});
|
||||
|
||||
GuiUtils.addGap(petPanel, 10);
|
||||
petPanel.add(this.plantBox);
|
||||
petPanel.setMaximumSize(petPanel.getPreferredSize());
|
||||
petPanel.setAlignmentX(LEFT_ALIGNMENT);
|
||||
petPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
|
||||
fantasyPanel.add(petPanel, BorderLayout.WEST);
|
||||
|
||||
zeppelinButton.addActionListener(new ActionListener() {
|
||||
this.zeppelinButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent actionEvent) {
|
||||
questData.randomizeOpponents();
|
||||
refreshNextMatchPanel();
|
||||
QuestItemZeppelin zeppelin = (QuestItemZeppelin) questData.getInventory().getItem("Zeppelin");
|
||||
QuestMainPanel.this.questData.randomizeOpponents();
|
||||
QuestMainPanel.this.refreshNextMatchPanel();
|
||||
final QuestItemZeppelin zeppelin = (QuestItemZeppelin) QuestMainPanel.this.questData.getInventory()
|
||||
.getItem("Zeppelin");
|
||||
zeppelin.setZeppelinUsed(true);
|
||||
zeppelinButton.setEnabled(false);
|
||||
QuestMainPanel.this.zeppelinButton.setEnabled(false);
|
||||
}
|
||||
});
|
||||
|
||||
zeppelinButton.setMaximumSize(zeppelinButton.getPreferredSize());
|
||||
zeppelinPanel.setLayout(new BorderLayout());
|
||||
this.zeppelinButton.setMaximumSize(this.zeppelinButton.getPreferredSize());
|
||||
this.zeppelinPanel.setLayout(new BorderLayout());
|
||||
|
||||
fantasyPanel.add(zeppelinPanel, BorderLayout.EAST);
|
||||
fantasyPanel.add(this.zeppelinPanel, BorderLayout.EAST);
|
||||
fantasyPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
matchPanel.add(fantasyPanel);
|
||||
}
|
||||
@@ -448,24 +465,24 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
* @return a {@link javax.swing.JPanel} object.
|
||||
*/
|
||||
private JPanel createDuelPanel() {
|
||||
JPanel DuelPanel = new JPanel();
|
||||
final JPanel duelPanel = new JPanel();
|
||||
QuestDuelPanel duelEvent;
|
||||
DuelPanel.setLayout(new BoxLayout(DuelPanel, BoxLayout.Y_AXIS));
|
||||
DuelPanel.setBorder(new TitledBorder(new EtchedBorder(), "Available Duels"));
|
||||
duelPanel.setLayout(new BoxLayout(duelPanel, BoxLayout.Y_AXIS));
|
||||
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);
|
||||
DuelPanel.add(duelEvent);
|
||||
duelPanel.add(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.
|
||||
*/
|
||||
private JPanel createChallengePanel() {
|
||||
JPanel ChallengePanel = new JPanel();
|
||||
final JPanel challengePanel = new JPanel();
|
||||
|
||||
QuestSelectablePanel selpan;
|
||||
ChallengePanel.setLayout(new BoxLayout(ChallengePanel, BoxLayout.Y_AXIS));
|
||||
ChallengePanel.setBorder(new TitledBorder(new EtchedBorder(), "Available Challenges"));
|
||||
challengePanel.setLayout(new BoxLayout(challengePanel, BoxLayout.Y_AXIS));
|
||||
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);
|
||||
ChallengePanel.add(selpan);
|
||||
challengePanel.add(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() {
|
||||
AllZone.getQuestData().saveData();
|
||||
|
||||
devModeCheckBox.setSelected(Constant.Runtime.DEV_MODE[0]);
|
||||
smoothLandCheckBox.setSelected(Constant.Runtime.SMOOTH[0]);
|
||||
this.devModeCheckBox.setSelected(Constant.Runtime.DEV_MODE[0]);
|
||||
this.smoothLandCheckBox.setSelected(Constant.Runtime.SMOOTH[0]);
|
||||
|
||||
creditsLabel.setText(" " + questData.getCredits());
|
||||
statsLabel.setText(questData.getWin() + " wins / " + questData.getLost() + " losses");
|
||||
titleLabel.setText(questData.getRank());
|
||||
this.creditsLabel.setText(" " + this.questData.getCredits());
|
||||
this.statsLabel.setText(this.questData.getWin() + " wins / " + this.questData.getLost() + " losses");
|
||||
this.titleLabel.setText(this.questData.getRank());
|
||||
|
||||
// copy lastUsedDeck as removal triggers selection change.
|
||||
String lastUsedDeck = QuestMainPanel.lastUsedDeck;
|
||||
deckComboBox.removeAllItems();
|
||||
final String lastUsedDeck = QuestMainPanel.lastUsedDeck;
|
||||
this.deckComboBox.removeAllItems();
|
||||
|
||||
if (questData.getDeckNames().size() > 0) {
|
||||
deckComboBox.setEnabled(true);
|
||||
if (this.questData.getDeckNames().size() > 0) {
|
||||
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>() {
|
||||
@Override
|
||||
public int compare(final String s, final String s1) {
|
||||
return s.compareToIgnoreCase(s1);
|
||||
}
|
||||
@@ -532,73 +550,73 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
deckNames.add(0, lastUsedDeck);
|
||||
}
|
||||
|
||||
for (String deckName : deckNames) {
|
||||
deckComboBox.addItem(deckName);
|
||||
for (final String deckName : deckNames) {
|
||||
this.deckComboBox.addItem(deckName);
|
||||
}
|
||||
} else {
|
||||
deckComboBox.addItem(NO_DECKS_AVAILABLE);
|
||||
deckComboBox.setEnabled(false);
|
||||
this.deckComboBox.addItem(QuestMainPanel.NO_DECKS_AVAILABLE);
|
||||
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)) {
|
||||
lifeLabel.setText(" " + questData.getLife());
|
||||
if (this.questData.getMode().equals(QuestData.FANTASY)) {
|
||||
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) {
|
||||
petComboBox.setEnabled(true);
|
||||
petCheckBox.setEnabled(true);
|
||||
for (String aPetList : petList) {
|
||||
petComboBox.addItem(aPetList);
|
||||
this.petComboBox.setEnabled(true);
|
||||
this.petCheckBox.setEnabled(true);
|
||||
for (final String aPetList : petList) {
|
||||
this.petComboBox.addItem(aPetList);
|
||||
}
|
||||
} else {
|
||||
petComboBox.addItem("No pets available");
|
||||
petComboBox.setEnabled(false);
|
||||
petCheckBox.setEnabled(false);
|
||||
this.petComboBox.addItem("No pets available");
|
||||
this.petComboBox.setEnabled(false);
|
||||
this.petCheckBox.setEnabled(false);
|
||||
}
|
||||
|
||||
if (!questData.getPetManager().shouldPetBeUsed()) {
|
||||
petCheckBox.setSelected(false);
|
||||
petComboBox.setEnabled(false);
|
||||
if (!this.questData.getPetManager().shouldPetBeUsed()) {
|
||||
this.petCheckBox.setSelected(false);
|
||||
this.petComboBox.setEnabled(false);
|
||||
} else {
|
||||
petCheckBox.setSelected(true);
|
||||
petComboBox.setSelectedItem(questData.getPetManager().getSelectedPet().getName());
|
||||
this.petCheckBox.setSelected(true);
|
||||
this.petComboBox.setSelectedItem(this.questData.getPetManager().getSelectedPet().getName());
|
||||
}
|
||||
|
||||
this.plantBox.setEnabled(questData.getPetManager().getPlant().getLevel() > 0);
|
||||
this.plantBox.setSelected(questData.getPetManager().shouldPlantBeUsed());
|
||||
this.plantBox.setEnabled(this.questData.getPetManager().getPlant().getLevel() > 0);
|
||||
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) {
|
||||
zeppelinPanel.removeAll();
|
||||
zeppelinPanel.add(zeppelinButton, BorderLayout.CENTER);
|
||||
this.zeppelinPanel.removeAll();
|
||||
this.zeppelinPanel.add(this.zeppelinButton, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
if (!zeppelin.hasBeenUsed()) {
|
||||
zeppelinButton.setEnabled(true);
|
||||
this.zeppelinButton.setEnabled(true);
|
||||
} else {
|
||||
zeppelinButton.setEnabled(false);
|
||||
this.zeppelinButton.setEnabled(false);
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
if (nextChallengeInWins() > 0) {
|
||||
nextQuestLabel.setText("Next challenge in " + nextChallengeInWins() + " Wins.");
|
||||
if (this.nextChallengeInWins() > 0) {
|
||||
this.nextQuestLabel.setText("Next challenge in " + this.nextChallengeInWins() + " Wins.");
|
||||
} 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>
|
||||
*/
|
||||
private void refreshNextMatchPanel() {
|
||||
nextMatchPanel.removeAll();
|
||||
nextMatchLayout = new CardLayout();
|
||||
nextMatchPanel.setLayout(nextMatchLayout);
|
||||
nextMatchPanel.add(createDuelPanel(), DUELS);
|
||||
nextMatchPanel.add(createChallengePanel(), CHALLENGES);
|
||||
if (isShowingChallenges) {
|
||||
this.nextMatchLayout.show(nextMatchPanel, CHALLENGES);
|
||||
this.nextMatchPanel.removeAll();
|
||||
this.nextMatchLayout = new CardLayout();
|
||||
this.nextMatchPanel.setLayout(this.nextMatchLayout);
|
||||
this.nextMatchPanel.add(this.createDuelPanel(), QuestMainPanel.DUELS);
|
||||
this.nextMatchPanel.add(this.createChallengePanel(), QuestMainPanel.CHALLENGES);
|
||||
if (this.isShowingChallenges) {
|
||||
this.nextMatchLayout.show(this.nextMatchPanel, QuestMainPanel.CHALLENGES);
|
||||
} 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
|
||||
// questers.
|
||||
if (questData.getWin() < 20) {
|
||||
return 20 - questData.getWin();
|
||||
if (this.questData.getWin() < 20) {
|
||||
return 20 - this.questData.getWin();
|
||||
}
|
||||
|
||||
// The int mul has been lowered by one, should face special opps more
|
||||
// frequently.
|
||||
int challengesPlayed = questData.getChallengesPlayed();
|
||||
final int challengesPlayed = this.questData.getChallengesPlayed();
|
||||
int mul = 5;
|
||||
|
||||
if (questData.getInventory().hasItem("Zeppelin")) {
|
||||
if (this.questData.getInventory().hasItem("Zeppelin")) {
|
||||
mul = 3;
|
||||
} else if (questData.getInventory().hasItem("Map")) {
|
||||
} else if (this.questData.getInventory().hasItem("Map")) {
|
||||
mul = 4;
|
||||
}
|
||||
|
||||
int delta = (challengesPlayed * mul) - questData.getWin();
|
||||
final int delta = (challengesPlayed * mul) - this.questData.getWin();
|
||||
|
||||
return (delta > 0) ? delta : 0;
|
||||
}
|
||||
@@ -656,9 +674,10 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
* </p>
|
||||
*/
|
||||
final void showDeckEditor() {
|
||||
Command exit = new Command() {
|
||||
final Command exit = new Command() {
|
||||
private static final long serialVersionUID = -5110231879431074581L;
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
// saves all deck data
|
||||
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.setVisible(true);
|
||||
mainFrame.dispose();
|
||||
this.getMainFrame().dispose();
|
||||
} // deck editor button
|
||||
|
||||
/**
|
||||
@@ -680,7 +699,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
* </p>
|
||||
*/
|
||||
final void showBazaar() {
|
||||
mainFrame.showBazaarPane();
|
||||
this.getMainFrame().showBazaarPane();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -689,9 +708,10 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
* </p>
|
||||
*/
|
||||
final void showCardShop() {
|
||||
Command exit = new Command() {
|
||||
final Command exit = new Command() {
|
||||
private static final long serialVersionUID = 8567193482568076362L;
|
||||
|
||||
@Override
|
||||
public void execute() {
|
||||
// saves all deck data
|
||||
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.setVisible(true);
|
||||
|
||||
this.mainFrame.dispose();
|
||||
this.getMainFrame().dispose();
|
||||
|
||||
} // card shop button
|
||||
|
||||
@@ -719,21 +739,21 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
// heap usage significantly.
|
||||
ImageCache.clear();
|
||||
|
||||
QuestItemZeppelin zeppelin = (QuestItemZeppelin) questData.getInventory().getItem("Zeppelin");
|
||||
final QuestItemZeppelin zeppelin = (QuestItemZeppelin) this.questData.getInventory().getItem("Zeppelin");
|
||||
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;
|
||||
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
|
||||
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
|
||||
// are added
|
||||
@@ -743,19 +763,19 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
// AllZone.setDisplay(new GuiDisplay3());
|
||||
// }
|
||||
|
||||
Constant.Runtime.SMOOTH[0] = smoothLandCheckBox.isSelected();
|
||||
Constant.Runtime.SMOOTH[0] = this.smoothLandCheckBox.isSelected();
|
||||
|
||||
AllZone.getMatchState().reset();
|
||||
if (isShowingChallenges) {
|
||||
setupChallenge(humanDeck);
|
||||
if (this.isShowingChallenges) {
|
||||
this.setupChallenge(humanDeck);
|
||||
} else {
|
||||
setupDuel(humanDeck);
|
||||
this.setupDuel(humanDeck);
|
||||
}
|
||||
|
||||
AllZone.getQuestData().saveData();
|
||||
|
||||
AllZone.getDisplay().setVisible(true);
|
||||
mainFrame.dispose();
|
||||
this.getMainFrame().dispose();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -767,14 +787,14 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
* a {@link forge.deck.Deck} object.
|
||||
*/
|
||||
final void setupDuel(final Deck humanDeck) {
|
||||
Deck computer = selectedOpponent.getEvent().getEventDeck();
|
||||
final Deck computer = this.selectedOpponent.getEvent().getEventDeck();
|
||||
Constant.Runtime.COMPUTER_DECK[0] = computer;
|
||||
|
||||
QuestDuel selectedDuel = (QuestDuel) selectedOpponent.getEvent();
|
||||
final QuestDuel selectedDuel = (QuestDuel) this.selectedOpponent.getEvent();
|
||||
AllZone.setQuestEvent(selectedDuel);
|
||||
|
||||
AllZone.getGameAction().newGame(humanDeck, computer, QuestUtil.getHumanStartingCards(questData),
|
||||
QuestUtil.getComputerStartingCards(questData), questData.getLife(), 20, null);
|
||||
AllZone.getGameAction().newGame(humanDeck, computer, QuestUtil.getHumanStartingCards(this.questData),
|
||||
QuestUtil.getComputerStartingCards(this.questData), this.questData.getLife(), 20, null);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -786,23 +806,23 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
* a {@link forge.deck.Deck} object.
|
||||
*/
|
||||
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;
|
||||
|
||||
AllZone.setQuestEvent(selectedChallenge);
|
||||
|
||||
int extraLife = 0;
|
||||
|
||||
if (questData.getInventory().getItemLevel("Gear") == 2) {
|
||||
if (this.questData.getInventory().getItemLevel("Gear") == 2) {
|
||||
extraLife = 3;
|
||||
}
|
||||
|
||||
AllZone.getGameAction().newGame(humanDeck, computer,
|
||||
QuestUtil.getHumanStartingCards(questData, selectedChallenge),
|
||||
QuestUtil.getComputerStartingCards(questData, selectedChallenge), questData.getLife() + extraLife,
|
||||
selectedChallenge.getAILife(), selectedChallenge);
|
||||
QuestUtil.getHumanStartingCards(this.questData, selectedChallenge),
|
||||
QuestUtil.getComputerStartingCards(this.questData, selectedChallenge),
|
||||
this.questData.getLife() + extraLife, selectedChallenge.getAILife(), selectedChallenge);
|
||||
|
||||
}
|
||||
|
||||
@@ -814,7 +834,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
private String getEventIconFilename() {
|
||||
return selectedOpponent.getIconFilename();
|
||||
return this.selectedOpponent.getIconFilename();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -823,21 +843,21 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
* </p>
|
||||
*/
|
||||
final void showChallenges() {
|
||||
if (isShowingChallenges) {
|
||||
isShowingChallenges = false;
|
||||
eventButton.setText("Challenges");
|
||||
if (this.isShowingChallenges) {
|
||||
this.isShowingChallenges = false;
|
||||
this.eventButton.setText("Challenges");
|
||||
} else {
|
||||
isShowingChallenges = true;
|
||||
eventButton.setText("Duels");
|
||||
this.isShowingChallenges = true;
|
||||
this.eventButton.setText("Duels");
|
||||
}
|
||||
|
||||
if (selectedOpponent != null) {
|
||||
selectedOpponent.setSelected(false);
|
||||
if (this.selectedOpponent != null) {
|
||||
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 {
|
||||
|
||||
/** The selectable panel. */
|
||||
QuestSelectablePanel selectablePanel;
|
||||
private QuestSelectablePanel selectablePanel;
|
||||
|
||||
/**
|
||||
* Instantiates a new selection adapter.
|
||||
@@ -868,14 +888,14 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
@Override
|
||||
public void mouseClicked(final MouseEvent mouseEvent) {
|
||||
|
||||
if (selectedOpponent != null) {
|
||||
selectedOpponent.setSelected(false);
|
||||
if (QuestMainPanel.this.selectedOpponent != null) {
|
||||
QuestMainPanel.this.selectedOpponent.setSelected(false);
|
||||
}
|
||||
|
||||
selectablePanel.setSelected(true);
|
||||
this.selectablePanel.setSelected(true);
|
||||
|
||||
selectedOpponent = selectablePanel;
|
||||
playButton.setEnabled(canGameBeLaunched());
|
||||
QuestMainPanel.this.selectedOpponent = this.selectablePanel;
|
||||
QuestMainPanel.this.playButton.setEnabled(QuestMainPanel.this.canGameBeLaunched());
|
||||
}
|
||||
|
||||
}
|
||||
@@ -900,7 +920,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
|
||||
* @return a boolean.
|
||||
*/
|
||||
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} */
|
||||
|
||||
@@ -42,29 +42,29 @@ public class QuestOptions extends JFrame {
|
||||
/** Constant <code>serialVersionUID=2018518804206822235L</code>. */
|
||||
private static final long serialVersionUID = 2018518804206822235L;
|
||||
|
||||
private QuestData questData = new QuestData();
|
||||
private final QuestData questData = new QuestData();
|
||||
|
||||
private JLabel jLabel1 = new JLabel();
|
||||
private JButton continueQuestButton = new JButton();
|
||||
private JPanel jPanel1 = new JPanel();
|
||||
private JPanel jPanel2 = new JPanel();
|
||||
private GridLayout gridLayout1 = new GridLayout();
|
||||
private final JLabel jLabel1 = new JLabel();
|
||||
private final JButton continueQuestButton = new JButton();
|
||||
private final JPanel jPanel1 = new JPanel();
|
||||
private final JPanel jPanel2 = new JPanel();
|
||||
private final GridLayout gridLayout1 = new GridLayout();
|
||||
|
||||
private JRadioButton easyRadio = new JRadioButton();
|
||||
private JRadioButton hardRadio = new JRadioButton();
|
||||
private JRadioButton mediumRadio = new JRadioButton();
|
||||
private JRadioButton veryHardRadio = new JRadioButton();
|
||||
private final JRadioButton easyRadio = new JRadioButton();
|
||||
private final JRadioButton hardRadio = new JRadioButton();
|
||||
private final JRadioButton mediumRadio = new JRadioButton();
|
||||
private final JRadioButton veryHardRadio = new JRadioButton();
|
||||
|
||||
private JRadioButton fantasyRadio = new JRadioButton();
|
||||
private JRadioButton realisticRadio = new JRadioButton();
|
||||
private final JRadioButton fantasyRadio = 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 JTextArea jTextArea1 = new JTextArea();
|
||||
private ButtonGroup buttonGroup1 = new ButtonGroup();
|
||||
private ButtonGroup buttonGroup2 = new ButtonGroup();
|
||||
private JPanel jPanel3 = new JPanel();
|
||||
private final JButton newQuestButton = new JButton();
|
||||
private final JTextArea jTextArea1 = new JTextArea();
|
||||
private final ButtonGroup buttonGroup1 = new ButtonGroup();
|
||||
private final ButtonGroup buttonGroup2 = new ButtonGroup();
|
||||
private final JPanel jPanel3 = new JPanel();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -73,17 +73,17 @@ public class QuestOptions extends JFrame {
|
||||
*/
|
||||
public QuestOptions() {
|
||||
try {
|
||||
jbInit();
|
||||
} catch (Exception ex) {
|
||||
this.jbInit();
|
||||
} catch (final Exception ex) {
|
||||
ErrorViewer.showError(ex);
|
||||
}
|
||||
|
||||
setup();
|
||||
setupRadioButtonText();
|
||||
this.setup();
|
||||
this.setupRadioButtonText();
|
||||
|
||||
this.setSize(540, 555);
|
||||
GuiUtils.centerFrame(this);
|
||||
setVisible(true);
|
||||
this.setVisible(true);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -93,7 +93,7 @@ public class QuestOptions extends JFrame {
|
||||
*/
|
||||
private void setup() {
|
||||
// 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
|
||||
this.addWindowListener(new WindowAdapter() {
|
||||
@@ -103,7 +103,7 @@ public class QuestOptions extends JFrame {
|
||||
|
||||
if (System.getenv("NG2") != null) {
|
||||
if (System.getenv("NG2").equalsIgnoreCase("true")) {
|
||||
String argz[] = {};
|
||||
final String[] argz = {};
|
||||
Gui_HomeScreen.main(argz);
|
||||
} else {
|
||||
new OldGuiNewGame();
|
||||
@@ -116,8 +116,8 @@ public class QuestOptions extends JFrame {
|
||||
});
|
||||
|
||||
// is there any saved data?
|
||||
if (!questData.hasSaveFile()) {
|
||||
continueQuestButton.setEnabled(false);
|
||||
if (!this.questData.hasSaveFile()) {
|
||||
this.continueQuestButton.setEnabled(false);
|
||||
}
|
||||
} // setup()
|
||||
|
||||
@@ -128,13 +128,13 @@ public class QuestOptions extends JFrame {
|
||||
* </p>
|
||||
*/
|
||||
private void setupRadioButtonText() {
|
||||
String[] diff = QuestPreferences.getDifficulty();
|
||||
JRadioButton[] b = {easyRadio, mediumRadio, hardRadio, veryHardRadio};
|
||||
final String[] diff = QuestPreferences.getDifficulty();
|
||||
final JRadioButton[] b = { this.easyRadio, this.mediumRadio, this.hardRadio, this.veryHardRadio };
|
||||
|
||||
for (int i = 0; i < diff.length; i++) {
|
||||
// -2 because you start a level 1, and the last level is secret
|
||||
int numberLevels = QuestData.RANK_TITLES.length - 2;
|
||||
int numGames = numberLevels * QuestPreferences.getWinsForRankIncrease(i);
|
||||
final int numberLevels = QuestData.RANK_TITLES.length - 2;
|
||||
final int numGames = numberLevels * QuestPreferences.getWinsForRankIncrease(i);
|
||||
|
||||
b[i].setText(String.format("%s - %d", diff[i], numGames));
|
||||
}
|
||||
@@ -150,56 +150,58 @@ public class QuestOptions extends JFrame {
|
||||
* if any.
|
||||
*/
|
||||
private void jbInit() throws Exception {
|
||||
TitledBorder titledBorder1 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white, new Color(148, 145,
|
||||
140)), "Quest Length");
|
||||
Border border2 = BorderFactory.createEtchedBorder(Color.white, new Color(148, 145, 140));
|
||||
TitledBorder titledBorder2 = new TitledBorder(border2, "Continue");
|
||||
jLabel1.setFont(new java.awt.Font("Dialog", 0, 25));
|
||||
jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
jLabel1.setText("Quest Options");
|
||||
jLabel1.setBounds(new Rectangle(1, 0, 539, 63));
|
||||
final TitledBorder titledBorder1 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white, new Color(
|
||||
148, 145, 140)), "Quest Length");
|
||||
final Border border2 = BorderFactory.createEtchedBorder(Color.white, new Color(148, 145, 140));
|
||||
final TitledBorder titledBorder2 = new TitledBorder(border2, "Continue");
|
||||
this.jLabel1.setFont(new java.awt.Font("Dialog", 0, 25));
|
||||
this.jLabel1.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
this.jLabel1.setText("Quest Options");
|
||||
this.jLabel1.setBounds(new Rectangle(1, 0, 539, 63));
|
||||
this.setTitle("Quest Options");
|
||||
this.getContentPane().setLayout(null);
|
||||
continueQuestButton.setBounds(new Rectangle(69, 28, 179, 35));
|
||||
continueQuestButton.setFont(new java.awt.Font("Dialog", 0, 18));
|
||||
continueQuestButton.setText("Continue Quest");
|
||||
continueQuestButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
this.continueQuestButton.setBounds(new Rectangle(69, 28, 179, 35));
|
||||
this.continueQuestButton.setFont(new java.awt.Font("Dialog", 0, 18));
|
||||
this.continueQuestButton.setText("Continue Quest");
|
||||
this.continueQuestButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
continueQuestButton_actionPerformed(e);
|
||||
QuestOptions.this.continueQuestButtonActionPerformed(e);
|
||||
}
|
||||
});
|
||||
jPanel1.setBorder(titledBorder1);
|
||||
jPanel1.setBounds(new Rectangle(20, 63, 500, 353));
|
||||
jPanel1.setLayout(null);
|
||||
this.jPanel1.setBorder(titledBorder1);
|
||||
this.jPanel1.setBounds(new Rectangle(20, 63, 500, 353));
|
||||
this.jPanel1.setLayout(null);
|
||||
|
||||
jPanel2.setBounds(new Rectangle(20, 27, 460, 101));
|
||||
jPanel2.setLayout(gridLayout1);
|
||||
this.jPanel2.setBounds(new Rectangle(20, 27, 460, 101));
|
||||
this.jPanel2.setLayout(this.gridLayout1);
|
||||
|
||||
gridLayout1.setColumns(2);
|
||||
gridLayout1.setRows(4);
|
||||
this.gridLayout1.setColumns(2);
|
||||
this.gridLayout1.setRows(4);
|
||||
|
||||
easyRadio.setText("Easy - 50 games");
|
||||
mediumRadio.setText("Medium - 100 games");
|
||||
hardRadio.setText("Hard - 200 games");
|
||||
veryHardRadio.setText("Very Hard - 300 games");
|
||||
realisticRadio.setText("Realistic");
|
||||
fantasyRadio.setText("Fantasy");
|
||||
this.easyRadio.setText("Easy - 50 games");
|
||||
this.mediumRadio.setText("Medium - 100 games");
|
||||
this.hardRadio.setText("Hard - 200 games");
|
||||
this.veryHardRadio.setText("Very Hard - 300 games");
|
||||
this.realisticRadio.setText("Realistic");
|
||||
this.fantasyRadio.setText("Fantasy");
|
||||
|
||||
easyRadio.setSelected(true);
|
||||
realisticRadio.setSelected(true);
|
||||
this.easyRadio.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));
|
||||
newQuestButton.setFont(new java.awt.Font("Dialog", 0, 16));
|
||||
newQuestButton.setText("New Quest");
|
||||
newQuestButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
this.newQuestButton.setBounds(new Rectangle(179, 292, 140, 38));
|
||||
this.newQuestButton.setFont(new java.awt.Font("Dialog", 0, 16));
|
||||
this.newQuestButton.setText("New Quest");
|
||||
this.newQuestButton.addActionListener(new java.awt.event.ActionListener() {
|
||||
@Override
|
||||
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("Continue Quest will allow you to continue a quest that you started at an earlier time.");
|
||||
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("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)));
|
||||
jTextArea1.setEnabled(false);
|
||||
jTextArea1.setFont(new java.awt.Font("Dialog", 0, 12));
|
||||
jTextArea1.setDisabledTextColor(Color.black);
|
||||
jTextArea1.setEditable(false);
|
||||
this.jTextArea1.setBorder(BorderFactory.createEtchedBorder(Color.white, new Color(148, 145, 140)));
|
||||
this.jTextArea1.setEnabled(false);
|
||||
this.jTextArea1.setFont(new java.awt.Font("Dialog", 0, 12));
|
||||
this.jTextArea1.setDisabledTextColor(Color.black);
|
||||
this.jTextArea1.setEditable(false);
|
||||
// jTextArea1.setText("Note: Starting a new quest will delete your current quest data");
|
||||
jTextArea1.setText(sb.toString());
|
||||
jTextArea1.setLineWrap(true);
|
||||
jTextArea1.setWrapStyleWord(true);
|
||||
jTextArea1.setBounds(new Rectangle(86, 145, 327, 128));
|
||||
this.jTextArea1.setText(sb.toString());
|
||||
this.jTextArea1.setLineWrap(true);
|
||||
this.jTextArea1.setWrapStyleWord(true);
|
||||
this.jTextArea1.setBounds(new Rectangle(86, 145, 327, 128));
|
||||
|
||||
jPanel3.setBorder(titledBorder2);
|
||||
jPanel3.setBounds(new Rectangle(110, 427, 323, 86));
|
||||
jPanel3.setLayout(null);
|
||||
this.jPanel3.setBorder(titledBorder2);
|
||||
this.jPanel3.setBounds(new Rectangle(110, 427, 323, 86));
|
||||
this.jPanel3.setLayout(null);
|
||||
|
||||
jPanel2.add(easyRadio, null);
|
||||
jPanel2.add(realisticRadio, null);
|
||||
jPanel2.add(mediumRadio, null);
|
||||
jPanel2.add(fantasyRadio, null);
|
||||
jPanel2.add(hardRadio, null);
|
||||
jPanel2.add(new JLabel("")); // for empty cell
|
||||
jPanel2.add(veryHardRadio, null);
|
||||
jPanel2.add(cbStandardStart, null);
|
||||
this.jPanel2.add(this.easyRadio, null);
|
||||
this.jPanel2.add(this.realisticRadio, null);
|
||||
this.jPanel2.add(this.mediumRadio, null);
|
||||
this.jPanel2.add(this.fantasyRadio, null);
|
||||
this.jPanel2.add(this.hardRadio, null);
|
||||
this.jPanel2.add(new JLabel("")); // for empty cell
|
||||
this.jPanel2.add(this.veryHardRadio, null);
|
||||
this.jPanel2.add(this.cbStandardStart, null);
|
||||
|
||||
jPanel1.add(newQuestButton, null);
|
||||
jPanel1.add(jTextArea1, null);
|
||||
this.getContentPane().add(jPanel1, null);
|
||||
this.getContentPane().add(jPanel3, null);
|
||||
jPanel3.add(continueQuestButton, null);
|
||||
this.getContentPane().add(jLabel1, null);
|
||||
jPanel1.add(jPanel2, null);
|
||||
buttonGroup1.add(easyRadio);
|
||||
buttonGroup1.add(mediumRadio);
|
||||
buttonGroup1.add(hardRadio);
|
||||
buttonGroup1.add(veryHardRadio);
|
||||
this.jPanel1.add(this.newQuestButton, null);
|
||||
this.jPanel1.add(this.jTextArea1, null);
|
||||
this.getContentPane().add(this.jPanel1, null);
|
||||
this.getContentPane().add(this.jPanel3, null);
|
||||
this.jPanel3.add(this.continueQuestButton, null);
|
||||
this.getContentPane().add(this.jLabel1, null);
|
||||
this.jPanel1.add(this.jPanel2, null);
|
||||
this.buttonGroup1.add(this.easyRadio);
|
||||
this.buttonGroup1.add(this.mediumRadio);
|
||||
this.buttonGroup1.add(this.hardRadio);
|
||||
this.buttonGroup1.add(this.veryHardRadio);
|
||||
|
||||
buttonGroup2.add(realisticRadio);
|
||||
buttonGroup2.add(fantasyRadio);
|
||||
this.buttonGroup2.add(this.realisticRadio);
|
||||
this.buttonGroup2.add(this.fantasyRadio);
|
||||
|
||||
}
|
||||
|
||||
@@ -256,11 +258,11 @@ public class QuestOptions extends JFrame {
|
||||
* @param e
|
||||
* a {@link java.awt.event.ActionEvent} object.
|
||||
*/
|
||||
final void continueQuestButton_actionPerformed(final ActionEvent e) {
|
||||
final void continueQuestButtonActionPerformed(final ActionEvent e) {
|
||||
// set global variable
|
||||
AllZone.setQuestData(QuestDataIO.loadData());
|
||||
AllZone.getQuestData().guessDifficultyIndex();
|
||||
dispose();
|
||||
this.dispose();
|
||||
|
||||
new QuestFrame();
|
||||
|
||||
@@ -274,29 +276,29 @@ public class QuestOptions extends JFrame {
|
||||
* @param e
|
||||
* a {@link java.awt.event.ActionEvent} object.
|
||||
*/
|
||||
final void newQuestButton_actionPerformed(final ActionEvent e) {
|
||||
final void newQuestButtonActionPerformed(final ActionEvent e) {
|
||||
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;
|
||||
|
||||
if (easyRadio.isSelected()) {
|
||||
if (this.easyRadio.isSelected()) {
|
||||
difficulty = 0;
|
||||
} else if (mediumRadio.isSelected()) {
|
||||
} else if (this.mediumRadio.isSelected()) {
|
||||
difficulty = 1;
|
||||
} else if (hardRadio.isSelected()) {
|
||||
} else if (this.hardRadio.isSelected()) {
|
||||
difficulty = 2;
|
||||
} else if (veryHardRadio.isSelected()) {
|
||||
} else if (this.veryHardRadio.isSelected()) {
|
||||
difficulty = 3;
|
||||
} else {
|
||||
// user didn't select a difficulty{
|
||||
return;
|
||||
}
|
||||
|
||||
if (questData.hasSaveFile()) {
|
||||
if (this.questData.hasSaveFile()) {
|
||||
// this will overwrite your save file!
|
||||
Object[] possibleValues = {"Yes", "No"};
|
||||
Object choice = JOptionPane.showOptionDialog(null,
|
||||
final Object[] possibleValues = { "Yes", "No" };
|
||||
final Object choice = JOptionPane.showOptionDialog(null,
|
||||
"Starting a new quest will overwrite your current quest. Continue?", "Start New Quest?",
|
||||
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
|
||||
questData.newGame(difficulty, mode, cbStandardStart.isSelected());
|
||||
this.questData.newGame(difficulty, mode, this.cbStandardStart.isSelected());
|
||||
|
||||
questData.saveData();
|
||||
this.questData.saveData();
|
||||
|
||||
// set global variable
|
||||
AllZone.setQuestData(questData);
|
||||
AllZone.setQuestData(this.questData);
|
||||
|
||||
dispose();
|
||||
this.dispose();
|
||||
new QuestFrame();
|
||||
}
|
||||
|
||||
|
||||
@@ -1,7 +1,6 @@
|
||||
package forge.quest.gui;
|
||||
|
||||
import static java.util.Collections.unmodifiableList;
|
||||
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import javax.swing.AbstractListModel;
|
||||
@@ -28,12 +27,12 @@ import forge.item.CardPrinted;
|
||||
public class QuestWinLoseCardViewer extends JPanel {
|
||||
|
||||
// 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
|
||||
private JList jList;
|
||||
private CardDetailPanel detail;
|
||||
private CardPicturePanel picture;
|
||||
private final JList jList;
|
||||
private final CardDetailPanel detail;
|
||||
private final CardPicturePanel picture;
|
||||
|
||||
/**
|
||||
* Instantiates a new quest win lose card viewer.
|
||||
@@ -42,57 +41,60 @@ public class QuestWinLoseCardViewer extends JPanel {
|
||||
* the list
|
||||
*/
|
||||
public QuestWinLoseCardViewer(final List<CardPrinted> list) {
|
||||
this.list = unmodifiableList(list);
|
||||
jList = new JList(new ChooserListModel());
|
||||
detail = new CardDetailPanel(null);
|
||||
picture = new CardPicturePanel(null);
|
||||
this.list = Collections.unmodifiableList(list);
|
||||
this.jList = new JList(new ChooserListModel());
|
||||
this.detail = new CardDetailPanel(null);
|
||||
this.picture = new CardPicturePanel(null);
|
||||
|
||||
this.add(new JScrollPane(jList));
|
||||
this.add(picture);
|
||||
this.add(detail);
|
||||
this.add(new JScrollPane(this.jList));
|
||||
this.add(this.picture);
|
||||
this.add(this.detail);
|
||||
this.setLayout(new java.awt.GridLayout(1, 3, 6, 0));
|
||||
|
||||
// selection is here
|
||||
jList.getSelectionModel().addListSelectionListener(new SelListener());
|
||||
jList.setSelectedIndex(0);
|
||||
this.jList.getSelectionModel().addListSelectionListener(new SelListener());
|
||||
this.jList.setSelectedIndex(0);
|
||||
}
|
||||
|
||||
private class ChooserListModel extends AbstractListModel {
|
||||
|
||||
private static final long serialVersionUID = 3871965346333840556L;
|
||||
|
||||
@Override
|
||||
public int getSize() {
|
||||
return list.size();
|
||||
return QuestWinLoseCardViewer.this.list.size();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Object getElementAt(final int index) {
|
||||
return list.get(index);
|
||||
return QuestWinLoseCardViewer.this.list.get(index);
|
||||
}
|
||||
}
|
||||
|
||||
private class SelListener implements ListSelectionListener {
|
||||
private Card[] cache = null;
|
||||
|
||||
@Override
|
||||
public void valueChanged(final ListSelectionEvent e) {
|
||||
int row = jList.getSelectedIndex();
|
||||
final int row = QuestWinLoseCardViewer.this.jList.getSelectedIndex();
|
||||
// (String) jList.getSelectedValue();
|
||||
if (row >= 0 && row < list.size()) {
|
||||
CardPrinted cp = list.get(row);
|
||||
ensureCacheHas(row, cp);
|
||||
detail.setCard(cache[row]);
|
||||
picture.setCard(cp);
|
||||
if ((row >= 0) && (row < QuestWinLoseCardViewer.this.list.size())) {
|
||||
final CardPrinted cp = QuestWinLoseCardViewer.this.list.get(row);
|
||||
this.ensureCacheHas(row, cp);
|
||||
QuestWinLoseCardViewer.this.detail.setCard(this.cache[row]);
|
||||
QuestWinLoseCardViewer.this.picture.setCard(cp);
|
||||
}
|
||||
}
|
||||
|
||||
private void ensureCacheHas(final int row, final CardPrinted cp) {
|
||||
if (cache == null) {
|
||||
cache = new Card[list.size()];
|
||||
if (this.cache == null) {
|
||||
this.cache = new Card[QuestWinLoseCardViewer.this.list.size()];
|
||||
}
|
||||
if (null == cache[row]) {
|
||||
Card card = AllZone.getCardFactory().getCard(cp.getName(), null);
|
||||
if (null == this.cache[row]) {
|
||||
final Card card = AllZone.getCardFactory().getCard(cp.getName(), null);
|
||||
card.setCurSetCode(cp.getSet());
|
||||
card.setImageFilename(CardUtil.buildFilename(card));
|
||||
cache[row] = card;
|
||||
this.cache[row] = card;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -44,32 +44,32 @@ import forge.view.swing.WinLoseModeHandler;
|
||||
*
|
||||
*/
|
||||
public class QuestWinLoseHandler extends WinLoseModeHandler {
|
||||
private boolean wonMatch;
|
||||
private final boolean wonMatch;
|
||||
private ImageIcon icoTemp;
|
||||
private JLabel lblTemp1;
|
||||
private JLabel lblTemp2;
|
||||
|
||||
/** The spacer. */
|
||||
int spacer = 50;
|
||||
private int spacer = 50;
|
||||
|
||||
private class CommonObjects {
|
||||
public QuestMatchState qMatchState;
|
||||
public QuestData qData;
|
||||
public QuestEvent qEvent;
|
||||
private QuestMatchState qMatchState;
|
||||
private QuestData qData;
|
||||
private QuestEvent qEvent;
|
||||
}
|
||||
|
||||
private CommonObjects model;
|
||||
private final CommonObjects model;
|
||||
|
||||
/**
|
||||
* Instantiates a new quest win lose handler.
|
||||
*/
|
||||
public QuestWinLoseHandler() {
|
||||
super();
|
||||
model = new CommonObjects();
|
||||
model.qMatchState = AllZone.getMatchState();
|
||||
model.qData = AllZone.getQuestData();
|
||||
model.qEvent = AllZone.getQuestEvent();
|
||||
wonMatch = model.qMatchState.isMatchWonBy(AllZone.getHumanPlayer().getName());
|
||||
this.model = new CommonObjects();
|
||||
this.model.qMatchState = AllZone.getMatchState();
|
||||
this.model.qData = AllZone.getQuestData();
|
||||
this.model.qEvent = AllZone.getQuestEvent();
|
||||
this.wonMatch = this.model.qMatchState.isMatchWonBy(AllZone.getHumanPlayer().getName());
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -84,23 +84,23 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
||||
if (Constant.Quest.FANTASY_QUEST[0]) {
|
||||
int extraLife = 0;
|
||||
|
||||
if (model.qEvent.getEventType().equals("challenge")) {
|
||||
if (model.qData.getInventory().hasItem("Zeppelin")) {
|
||||
if (this.model.qEvent.getEventType().equals("challenge")) {
|
||||
if (this.model.qData.getInventory().hasItem("Zeppelin")) {
|
||||
extraLife = 3;
|
||||
}
|
||||
}
|
||||
|
||||
CardList humanList = QuestUtil.getHumanStartingCards(model.qData, model.qEvent);
|
||||
CardList computerList = QuestUtil.getComputerStartingCards(model.qData, model.qEvent);
|
||||
final CardList humanList = QuestUtil.getHumanStartingCards(this.model.qData, this.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;
|
||||
if (model.qEvent.getEventType().equals("challenge")) {
|
||||
computerLife = ((QuestChallenge) model.qEvent).getAILife();
|
||||
if (this.model.qEvent.getEventType().equals("challenge")) {
|
||||
computerLife = ((QuestChallenge) this.model.qEvent).getAILife();
|
||||
}
|
||||
|
||||
AllZone.getGameAction().newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0], humanList,
|
||||
computerList, humanLife, computerLife, model.qEvent);
|
||||
AllZone.getGameAction().newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0],
|
||||
humanList, computerList, humanLife, computerLife, this.model.qEvent);
|
||||
} else {
|
||||
super.startNextRound();
|
||||
}
|
||||
@@ -117,57 +117,57 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
||||
*/
|
||||
@Override
|
||||
public final boolean populateCustomPanel() {
|
||||
view.btnRestart.setVisible(false);
|
||||
model.qData.getCards().resetNewList();
|
||||
this.view.btnRestart.setVisible(false);
|
||||
this.model.qData.getCards().resetNewList();
|
||||
|
||||
if (!model.qMatchState.isMatchOver()) {
|
||||
view.btnQuit.setText("Quit (15 Credits)");
|
||||
if (!this.model.qMatchState.isMatchOver()) {
|
||||
this.view.btnQuit.setText("Quit (15 Credits)");
|
||||
return false;
|
||||
} else {
|
||||
view.btnContinue.setVisible(false);
|
||||
if (wonMatch) {
|
||||
view.btnQuit.setText("Great!");
|
||||
this.view.btnContinue.setVisible(false);
|
||||
if (this.wonMatch) {
|
||||
this.view.btnQuit.setText("Great!");
|
||||
} else {
|
||||
view.btnQuit.setText("OK");
|
||||
this.view.btnQuit.setText("OK");
|
||||
}
|
||||
}
|
||||
|
||||
// Win case
|
||||
if (wonMatch) {
|
||||
if (this.wonMatch) {
|
||||
// Standard event reward credits
|
||||
awardEventCredits();
|
||||
this.awardEventCredits();
|
||||
|
||||
// Challenge reward credits
|
||||
if (model.qEvent.getEventType().equals("challenge")) {
|
||||
awardChallengeWin();
|
||||
if (this.model.qEvent.getEventType().equals("challenge")) {
|
||||
this.awardChallengeWin();
|
||||
}
|
||||
|
||||
// Random rare given at 50% chance (65% with luck upgrade)
|
||||
if (getLuckyCoinResult()) {
|
||||
awardRandomRare("You've won a random rare.");
|
||||
if (this.getLuckyCoinResult()) {
|
||||
this.awardRandomRare("You've won a random rare.");
|
||||
}
|
||||
|
||||
// Random rare for winning against a very hard deck
|
||||
if (model.qData.getDifficultyIndex() == 4) {
|
||||
awardRandomRare("You've won a random rare for winning against a very hard deck.");
|
||||
if (this.model.qData.getDifficultyIndex() == 4) {
|
||||
this.awardRandomRare("You've won a random rare for winning against a very hard deck.");
|
||||
}
|
||||
|
||||
// Award jackpot every 80 games won (currently 10 rares)
|
||||
int wins = model.qData.getWin();
|
||||
if (wins > 0 && wins % 80 == 0) {
|
||||
awardJackpot();
|
||||
final int wins = this.model.qData.getWin();
|
||||
if ((wins > 0) && ((wins % 80) == 0)) {
|
||||
this.awardJackpot();
|
||||
}
|
||||
}
|
||||
// Lose case
|
||||
else {
|
||||
penalizeLoss();
|
||||
this.penalizeLoss();
|
||||
}
|
||||
|
||||
// Win or lose, still a chance to win a booster, frequency set in
|
||||
// preferences
|
||||
int outcome = wonMatch ? model.qData.getWin() : model.qData.getLost();
|
||||
if (outcome % QuestPreferences.getWinsForBooster(model.qData.getDifficultyIndex()) == 0) {
|
||||
awardBooster();
|
||||
final int outcome = this.wonMatch ? this.model.qData.getWin() : this.model.qData.getLost();
|
||||
if ((outcome % QuestPreferences.getWinsForBooster(this.model.qData.getDifficultyIndex())) == 0) {
|
||||
this.awardBooster();
|
||||
}
|
||||
|
||||
return true;
|
||||
@@ -184,23 +184,23 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
||||
@Override
|
||||
public final void actionOnQuit() {
|
||||
// Record win/loss in quest data
|
||||
if (wonMatch) {
|
||||
model.qData.addWin();
|
||||
if (this.wonMatch) {
|
||||
this.model.qData.addWin();
|
||||
} else {
|
||||
model.qData.addLost();
|
||||
model.qData.subtractCredits(15);
|
||||
this.model.qData.addLost();
|
||||
this.model.qData.subtractCredits(15);
|
||||
}
|
||||
|
||||
model.qData.getCards().clearShopList();
|
||||
this.model.qData.getCards().clearShopList();
|
||||
|
||||
if (model.qData.getAvailableChallenges() != null) {
|
||||
model.qData.clearAvailableChallenges();
|
||||
if (this.model.qData.getAvailableChallenges() != null) {
|
||||
this.model.qData.clearAvailableChallenges();
|
||||
}
|
||||
|
||||
model.qMatchState.reset();
|
||||
this.model.qMatchState.reset();
|
||||
AllZone.setQuestEvent(null);
|
||||
|
||||
model.qData.saveData();
|
||||
this.model.qData.saveData();
|
||||
|
||||
new QuestFrame();
|
||||
}
|
||||
@@ -214,7 +214,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
||||
*/
|
||||
private void awardEventCredits() {
|
||||
// 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 credBase = 0;
|
||||
@@ -223,7 +223,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
||||
int credEstates = 0;
|
||||
|
||||
// Basic win bonus
|
||||
int base = QuestPreferences.getMatchRewardBase();
|
||||
final int base = QuestPreferences.getMatchRewardBase();
|
||||
double multiplier = 1;
|
||||
|
||||
String diff = AllZone.getQuestEvent().getDifficulty();
|
||||
@@ -238,21 +238,22 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
||||
} else if (diff.equalsIgnoreCase("expert")) {
|
||||
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>");
|
||||
// Gameplay bonuses (for each game win)
|
||||
boolean hasNeverLost = true;
|
||||
Player computer = AllZone.getComputerPlayer();
|
||||
for (GameSummary game : model.qMatchState.getGamesPlayed()) {
|
||||
final Player computer = AllZone.getComputerPlayer();
|
||||
for (final GameSummary game : this.model.qMatchState.getGamesPlayed()) {
|
||||
if (game.isWinner(computer.getName())) {
|
||||
hasNeverLost = false;
|
||||
continue; // no rewards for losing a game
|
||||
}
|
||||
// Alternate win
|
||||
GamePlayerRating aiRating = game.getPlayerRating(computer.getName());
|
||||
GamePlayerRating humanRating = game.getPlayerRating(AllZone.getHumanPlayer().getName());
|
||||
GameLossReason whyAiLost = aiRating.getLossReason();
|
||||
int altReward = getCreditsRewardForAltWin(whyAiLost);
|
||||
final GamePlayerRating aiRating = game.getPlayerRating(computer.getName());
|
||||
final GamePlayerRating humanRating = game.getPlayerRating(AllZone.getHumanPlayer().getName());
|
||||
final GameLossReason whyAiLost = aiRating.getLossReason();
|
||||
final int altReward = this.getCreditsRewardForAltWin(whyAiLost);
|
||||
|
||||
if (altReward > 0) {
|
||||
String winConditionName = "Unknown (bug)";
|
||||
@@ -279,8 +280,8 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
||||
winConditionName, 50));
|
||||
}
|
||||
// Mulligan to zero
|
||||
int cntCardsHumanStartedWith = humanRating.getOpeningHandSize();
|
||||
int mulliganReward = QuestPreferences.getMatchMullToZero();
|
||||
final int cntCardsHumanStartedWith = humanRating.getOpeningHandSize();
|
||||
final int mulliganReward = QuestPreferences.getMatchMullToZero();
|
||||
|
||||
if (0 == cntCardsHumanStartedWith) {
|
||||
credGameplay += mulliganReward;
|
||||
@@ -289,8 +290,8 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
||||
}
|
||||
|
||||
// Early turn bonus
|
||||
int winTurn = game.getTurnGameEnded();
|
||||
int turnCredits = getCreditsRewardForWinByTurn(winTurn);
|
||||
final int winTurn = game.getTurnGameEnded();
|
||||
final int turnCredits = this.getCreditsRewardForWinByTurn(winTurn);
|
||||
|
||||
if (winTurn == 0) {
|
||||
System.err.println("QuestWinLoseHandler > " + "turn calculation error: Zero turn win");
|
||||
@@ -313,13 +314,13 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
||||
// Undefeated bonus
|
||||
if (hasNeverLost) {
|
||||
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));
|
||||
}
|
||||
|
||||
// Estates bonus
|
||||
credTotal = credBase + credGameplay + credUndefeated;
|
||||
switch (model.qData.getInventory().getItemLevel("Estates")) {
|
||||
switch (this.model.qData.getInventory().getItemLevel("Estates")) {
|
||||
case 1:
|
||||
credEstates = (int) 0.1 * credTotal;
|
||||
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("</body></html>");
|
||||
model.qData.addCredits(credTotal);
|
||||
this.model.qData.addCredits(credTotal);
|
||||
|
||||
// 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());
|
||||
lblTemp2.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblTemp2.setFont(AllZone.getSkin().getFont2().deriveFont(Font.PLAIN, 14));
|
||||
lblTemp2.setForeground(Color.white);
|
||||
lblTemp2.setIcon(icoTemp);
|
||||
lblTemp2.setIconTextGap(50);
|
||||
this.lblTemp2 = new JLabel(sb.toString());
|
||||
this.lblTemp2.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
this.lblTemp2.setFont(AllZone.getSkin().getFont2().deriveFont(Font.PLAIN, 14));
|
||||
this.lblTemp2.setForeground(Color.white);
|
||||
this.lblTemp2.setIcon(this.icoTemp);
|
||||
this.lblTemp2.setIconTextGap(50);
|
||||
|
||||
view.pnlCustom.add(lblTemp1, "align center, width 95%!");
|
||||
view.pnlCustom.add(lblTemp2, "align center, width 95%!, gaptop 10");
|
||||
this.view.pnlCustom.add(this.lblTemp1, "align center, width 95%!");
|
||||
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) {
|
||||
CardPrinted c = model.qData.getCards().addRandomRare();
|
||||
List<CardPrinted> cardsWon = new ArrayList<CardPrinted>();
|
||||
final CardPrinted c = this.model.qData.getCards().addRandomRare();
|
||||
final List<CardPrinted> cardsWon = new ArrayList<CardPrinted>();
|
||||
cardsWon.add(c);
|
||||
|
||||
// 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");
|
||||
view.pnlCustom.add(cv, "align center, width 95%!");
|
||||
this.view.pnlCustom.add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer
|
||||
+ ", gapbottom 10");
|
||||
this.view.pnlCustom.add(cv, "align center, width 95%!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -403,14 +405,15 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
||||
*
|
||||
*/
|
||||
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.
|
||||
lblTemp1 = new TitleLabel("You just won 10 random rares!");
|
||||
QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon);
|
||||
this.lblTemp1 = new TitleLabel("You just won 10 random rares!");
|
||||
final QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon);
|
||||
|
||||
view.pnlCustom.add(lblTemp1, "align center, width 95%!, " + "gaptop " + spacer + ", gapbottom 10");
|
||||
view.pnlCustom.add(cv, "align center, width 95%!");
|
||||
this.view.pnlCustom.add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer
|
||||
+ ", gapbottom 10");
|
||||
this.view.pnlCustom.add(cv, "align center, width 95%!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -421,20 +424,21 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
||||
*
|
||||
*/
|
||||
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());
|
||||
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));
|
||||
|
||||
// Generate Swing components and attach.
|
||||
lblTemp1 = new TitleLabel("Bonus booster pack from the \"" + selected.getName() + "\" format!");
|
||||
QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon);
|
||||
this.lblTemp1 = new TitleLabel("Bonus booster pack from the \"" + selected.getName() + "\" format!");
|
||||
final QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon);
|
||||
|
||||
view.pnlCustom.add(lblTemp1, "align center, width 95%!, " + "gaptop " + spacer + ", gapbottom 10");
|
||||
view.pnlCustom.add(cv, "align center, width 95%!");
|
||||
this.view.pnlCustom.add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer
|
||||
+ ", gapbottom 10");
|
||||
this.view.pnlCustom.add(cv, "align center, width 95%!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -445,58 +449,59 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
||||
*
|
||||
*/
|
||||
private void awardChallengeWin() {
|
||||
if (!((QuestChallenge) model.qEvent).getRepeatable()) {
|
||||
model.qData.addCompletedChallenge(((QuestChallenge) model.qEvent).getId());
|
||||
if (!((QuestChallenge) this.model.qEvent).getRepeatable()) {
|
||||
this.model.qData.addCompletedChallenge(((QuestChallenge) this.model.qEvent).getId());
|
||||
}
|
||||
|
||||
// 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
|
||||
model.qData.addChallengesPlayed();
|
||||
this.model.qData.addChallengesPlayed();
|
||||
|
||||
List<CardPrinted> cardsWon = ((QuestChallenge) model.qEvent).getCardRewardList();
|
||||
long questRewardCredits = ((QuestChallenge) model.qEvent).getCreditsReward();
|
||||
final List<CardPrinted> cardsWon = ((QuestChallenge) this.model.qEvent).getCardRewardList();
|
||||
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("Challenge bounty: <b>" + questRewardCredits + " credits.</b></html>");
|
||||
|
||||
model.qData.addCredits(questRewardCredits);
|
||||
this.model.qData.addCredits(questRewardCredits);
|
||||
|
||||
// Generate Swing components and attach.
|
||||
icoTemp = GuiUtils.getResizedIcon("BoxIcon.png", 0.5);
|
||||
lblTemp1 = new TitleLabel("Challenge Rewards for \"" + ((QuestChallenge) model.qEvent).getTitle() + "\"");
|
||||
this.icoTemp = GuiUtils.getResizedIcon("BoxIcon.png", 0.5);
|
||||
this.lblTemp1 = new TitleLabel("Challenge Rewards for \"" + ((QuestChallenge) this.model.qEvent).getTitle()
|
||||
+ "\"");
|
||||
|
||||
lblTemp2 = new JLabel(sb.toString());
|
||||
lblTemp2.setFont(AllZone.getSkin().getFont2().deriveFont(Font.PLAIN, 14));
|
||||
lblTemp2.setForeground(Color.white);
|
||||
lblTemp2.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblTemp2.setIconTextGap(50);
|
||||
lblTemp2.setIcon(icoTemp);
|
||||
this.lblTemp2 = new JLabel(sb.toString());
|
||||
this.lblTemp2.setFont(AllZone.getSkin().getFont2().deriveFont(Font.PLAIN, 14));
|
||||
this.lblTemp2.setForeground(Color.white);
|
||||
this.lblTemp2.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
this.lblTemp2.setIconTextGap(50);
|
||||
this.lblTemp2.setIcon(this.icoTemp);
|
||||
|
||||
view.pnlCustom.add(lblTemp1, "align center, width 95%!, " + "gaptop " + spacer);
|
||||
view.pnlCustom.add(lblTemp2, "align center, width 95%!, height 80!, gapbottom 10");
|
||||
this.view.pnlCustom.add(this.lblTemp1, "align center, width 95%!, " + "gaptop " + this.spacer);
|
||||
this.view.pnlCustom.add(this.lblTemp2, "align center, width 95%!, height 80!, gapbottom 10");
|
||||
|
||||
if (cardsWon != null) {
|
||||
QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon);
|
||||
view.pnlCustom.add(cv, "align center, width 95%!");
|
||||
model.qData.getCards().addAllCards(cardsWon);
|
||||
final QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon);
|
||||
this.view.pnlCustom.add(cv, "align center, width 95%!");
|
||||
this.model.qData.getCards().addAllCards(cardsWon);
|
||||
}
|
||||
}
|
||||
|
||||
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.");
|
||||
lblTemp2.setFont(AllZone.getSkin().getFont2().deriveFont(Font.PLAIN, 14));
|
||||
lblTemp2.setForeground(Color.white);
|
||||
lblTemp2.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
lblTemp2.setIconTextGap(50);
|
||||
lblTemp2.setIcon(icoTemp);
|
||||
this.lblTemp2 = new JLabel("You lose! You have lost 15 credits.");
|
||||
this.lblTemp2.setFont(AllZone.getSkin().getFont2().deriveFont(Font.PLAIN, 14));
|
||||
this.lblTemp2.setForeground(Color.white);
|
||||
this.lblTemp2.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
this.lblTemp2.setIconTextGap(50);
|
||||
this.lblTemp2.setIcon(this.icoTemp);
|
||||
|
||||
view.pnlCustom.add(lblTemp1, "align center, width 95%!");
|
||||
view.pnlCustom.add(lblTemp2, "align center, width 95%!, height 80!");
|
||||
this.view.pnlCustom.add(this.lblTemp1, "align center, width 95%!");
|
||||
this.view.pnlCustom.add(this.lblTemp2, "align center, width 95%!, height 80!");
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -508,7 +513,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
|
||||
* @return boolean
|
||||
*/
|
||||
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);
|
||||
}
|
||||
|
||||
@@ -34,7 +34,7 @@ import forge.quest.data.bazaar.QuestStallPurchasable;
|
||||
public class QuestBazaarItem {
|
||||
|
||||
/** The item. */
|
||||
QuestStallPurchasable item;
|
||||
private QuestStallPurchasable item;
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -54,7 +54,7 @@ public class QuestBazaarItem {
|
||||
* item should not be deducted here.
|
||||
*/
|
||||
public final void purchaseItem() {
|
||||
item.onPurchase();
|
||||
this.item.onPurchase();
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -65,7 +65,7 @@ public class QuestBazaarItem {
|
||||
* @return a {@link javax.swing.JPanel} object.
|
||||
*/
|
||||
protected final JPanel getItemPanel() {
|
||||
ImageIcon icon = GuiUtils.getIconFromFile(item.getImageName());
|
||||
ImageIcon icon = GuiUtils.getIconFromFile(this.item.getImageName());
|
||||
if (icon == null) {
|
||||
// The original size was only 40 x 40 pixels.
|
||||
// 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.
|
||||
// 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));
|
||||
JPanel iconPanel = new JPanel(new BorderLayout());
|
||||
final JPanel iconPanel = new JPanel(new BorderLayout());
|
||||
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));
|
||||
|
||||
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));
|
||||
|
||||
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));
|
||||
|
||||
JButton purchaseButton = new JButton("Buy");
|
||||
final JButton purchaseButton = new JButton("Buy");
|
||||
purchaseButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
AllZone.getQuestData().subtractCredits(item.getPrice());
|
||||
purchaseItem();
|
||||
AllZone.getQuestData().subtractCredits(QuestBazaarItem.this.item.getPrice());
|
||||
QuestBazaarItem.this.purchaseItem();
|
||||
AllZone.getQuestData().saveData();
|
||||
QuestBazaarPanel.refreshLastInstance();
|
||||
}
|
||||
});
|
||||
|
||||
if (AllZone.getQuestData().getCredits() < item.getPrice()) {
|
||||
if (AllZone.getQuestData().getCredits() < this.item.getPrice()) {
|
||||
purchaseButton.setEnabled(false);
|
||||
}
|
||||
|
||||
JPanel itemPanel = new JPanel() {
|
||||
final JPanel itemPanel = new JPanel() {
|
||||
private static final long serialVersionUID = -5182857296365949682L;
|
||||
|
||||
@Override
|
||||
public Dimension getPreferredSize() {
|
||||
Dimension realSize = super.getPreferredSize();
|
||||
final Dimension realSize = super.getPreferredSize();
|
||||
realSize.width = 100;
|
||||
return realSize;
|
||||
}
|
||||
};
|
||||
GridBagLayout layout = new GridBagLayout();
|
||||
final GridBagLayout layout = new GridBagLayout();
|
||||
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);
|
||||
|
||||
constraints.gridheight = GridBagConstraints.REMAINDER;
|
||||
|
||||
@@ -31,22 +31,22 @@ public class QuestBazaarPanel extends QuestAbstractPanel {
|
||||
private static final long serialVersionUID = 1418913010051869222L;
|
||||
|
||||
/** Constant <code>stallList</code>. */
|
||||
static List<QuestBazaarStall> stallList = new ArrayList<QuestBazaarStall>();
|
||||
private static List<QuestBazaarStall> stallList = new ArrayList<QuestBazaarStall>();
|
||||
|
||||
/** The button panel. */
|
||||
JPanel buttonPanel = new JPanel(new BorderLayout());
|
||||
private final JPanel buttonPanel = new JPanel(new BorderLayout());
|
||||
|
||||
/** The button panel main. */
|
||||
JPanel buttonPanelMain = new JPanel();
|
||||
private final JPanel buttonPanelMain = new JPanel();
|
||||
|
||||
/** The stall panel. */
|
||||
JPanel stallPanel = new JPanel();
|
||||
private final JPanel stallPanel = new JPanel();
|
||||
|
||||
/** The selected stall. */
|
||||
JToggleButton selectedStall = null;
|
||||
private JToggleButton selectedStall = null;
|
||||
|
||||
/** The stall layout. */
|
||||
CardLayout stallLayout = new CardLayout();
|
||||
private final CardLayout stallLayout = new CardLayout();
|
||||
|
||||
/**
|
||||
* <p>
|
||||
@@ -60,23 +60,24 @@ public class QuestBazaarPanel extends QuestAbstractPanel {
|
||||
super(mainFrame);
|
||||
this.setLayout(new BorderLayout());
|
||||
|
||||
stallList = new ArrayList<QuestBazaarStall>();
|
||||
QuestBazaarPanel.stallList = new ArrayList<QuestBazaarStall>();
|
||||
|
||||
for (String stallName : QuestStallManager.getStallNames()) {
|
||||
stallList.add(new QuestBazaarStall(QuestStallManager.getStall(stallName)));
|
||||
for (final String stallName : QuestStallManager.getStallNames()) {
|
||||
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);
|
||||
List<JToggleButton> buttonList = new LinkedList<JToggleButton>();
|
||||
this.stallPanel.setLayout(this.stallLayout);
|
||||
final List<JToggleButton> buttonList = new LinkedList<JToggleButton>();
|
||||
|
||||
double maxWidth = 0;
|
||||
double maxHeight = 0;
|
||||
|
||||
for (QuestBazaarStall stall : stallList) {
|
||||
JToggleButton stallButton = new JToggleButton(stall.getStallName(), stall.getStallIcon());
|
||||
for (final QuestBazaarStall stall : QuestBazaarPanel.stallList) {
|
||||
final JToggleButton stallButton = new JToggleButton(stall.getStallName(), stall.getStallIcon());
|
||||
stallButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
public void actionPerformed(final ActionEvent e) {
|
||||
|
||||
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) {
|
||||
maxWidth = preferredSize.getWidth();
|
||||
@@ -105,32 +106,33 @@ public class QuestBazaarPanel extends QuestAbstractPanel {
|
||||
|
||||
buttonList.add(stallButton);
|
||||
|
||||
buttonPanelMain.add(stallButton);
|
||||
stallPanel.add(stall, stall.getStallName());
|
||||
this.buttonPanelMain.add(stallButton);
|
||||
this.stallPanel.add(stall, stall.getStallName());
|
||||
}
|
||||
|
||||
buttonList.get(0).setSelected(true);
|
||||
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);
|
||||
}
|
||||
|
||||
buttonPanel.add(buttonPanelMain, BorderLayout.NORTH);
|
||||
JButton quitButton = new JButton("Leave Bazaar");
|
||||
this.buttonPanel.add(this.buttonPanelMain, BorderLayout.NORTH);
|
||||
final JButton quitButton = new JButton("Leave Bazaar");
|
||||
quitButton.setSize(max);
|
||||
quitButton.addActionListener(new ActionListener() {
|
||||
@Override
|
||||
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(stallPanel, BorderLayout.CENTER);
|
||||
this.add(this.buttonPanel, BorderLayout.WEST);
|
||||
this.add(this.stallPanel, BorderLayout.CENTER);
|
||||
|
||||
}
|
||||
|
||||
@@ -143,14 +145,14 @@ public class QuestBazaarPanel extends QuestAbstractPanel {
|
||||
* a {@link java.lang.String} object.
|
||||
*/
|
||||
private void showStall(final String source) {
|
||||
stallLayout.show(stallPanel, source);
|
||||
this.stallLayout.show(this.stallPanel, source);
|
||||
}
|
||||
|
||||
/**
|
||||
* Slightly hackish, but should work.
|
||||
*/
|
||||
static void refreshLastInstance() {
|
||||
for (QuestBazaarStall stall : stallList) {
|
||||
for (final QuestBazaarStall stall : QuestBazaarPanel.stallList) {
|
||||
stall.updateItems();
|
||||
}
|
||||
}
|
||||
@@ -158,6 +160,6 @@ public class QuestBazaarPanel extends QuestAbstractPanel {
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public final void refreshState() {
|
||||
refreshLastInstance();
|
||||
QuestBazaarPanel.refreshLastInstance();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -1,5 +1,22 @@
|
||||
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.gui.GuiUtils;
|
||||
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.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
|
||||
* @version $Id$
|
||||
*/
|
||||
public class QuestBazaarStall extends JPanel implements NewConstants {
|
||||
/** Constant <code>serialVersionUID=-4147745071116906043L</code> */
|
||||
/** Constant <code>serialVersionUID=-4147745071116906043L</code>. */
|
||||
private static final long serialVersionUID = -4147745071116906043L;
|
||||
|
||||
/** The name. */
|
||||
String name;
|
||||
private final String name;
|
||||
|
||||
/** The stall name. */
|
||||
String stallName;
|
||||
private final String stallName;
|
||||
|
||||
/** The fluff. */
|
||||
String fluff;
|
||||
private final String fluff;
|
||||
|
||||
/** The icon. */
|
||||
ImageIcon icon;
|
||||
private final ImageIcon icon;
|
||||
|
||||
|
||||
private JLabel creditLabel = new JLabel();
|
||||
private JPanel inventoryPanel = new JPanel();
|
||||
private final JLabel creditLabel = new JLabel();
|
||||
private final JPanel inventoryPanel = new JPanel();
|
||||
|
||||
/** 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 stallName a {@link java.lang.String} object.
|
||||
* @param iconName a {@link java.lang.String} object.
|
||||
* @param fluff a {@link java.lang.String} object.
|
||||
* @param name
|
||||
* a {@link java.lang.String} object.
|
||||
* @param stallName
|
||||
* 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.fluff = fluff;
|
||||
this.icon = GuiUtils.getIconFromFile(iconName);
|
||||
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) {
|
||||
this.fluff = definition.fluff;
|
||||
this.icon = GuiUtils.getIconFromFile(definition.iconName);
|
||||
this.stallName = definition.displayName;
|
||||
this.name = definition.name;
|
||||
initUI();
|
||||
protected QuestBazaarStall(final QuestStallDefinition definition) {
|
||||
this.fluff = definition.getFluff();
|
||||
this.icon = GuiUtils.getIconFromFile(definition.getIconName());
|
||||
this.stallName = definition.getDisplayName();
|
||||
this.name = definition.getName();
|
||||
this.initUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>initUI.</p>
|
||||
* <p>
|
||||
* initUI.
|
||||
* </p>
|
||||
*/
|
||||
private void initUI() {
|
||||
this.removeAll();
|
||||
|
||||
JLabel stallNameLabel;
|
||||
|
||||
GridBagLayout layout = new GridBagLayout();
|
||||
final GridBagLayout layout = new GridBagLayout();
|
||||
this.setLayout(layout);
|
||||
|
||||
stallNameLabel = new JLabel(stallName);
|
||||
stallNameLabel = new JLabel(this.stallName);
|
||||
stallNameLabel.setFont(new Font("sserif", Font.BOLD, 22));
|
||||
stallNameLabel.setHorizontalAlignment(SwingConstants.CENTER);
|
||||
|
||||
creditLabel.setText("Credits: " + questData.getCredits());
|
||||
creditLabel.setFont(new Font("sserif", 0, 14));
|
||||
this.creditLabel.setText("Credits: " + this.questData.getCredits());
|
||||
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.setLineWrap(true);
|
||||
fluffArea.setWrapStyleWord(true);
|
||||
@@ -99,17 +123,8 @@ public class QuestBazaarStall extends JPanel implements NewConstants {
|
||||
fluffArea.setEditable(false);
|
||||
fluffArea.setFocusable(false);
|
||||
fluffArea.setPreferredSize(new Dimension(fluffArea.getPreferredSize().width, 40));
|
||||
GridBagConstraints constraints = new GridBagConstraints(0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
GridBagConstraints.CENTER,
|
||||
GridBagConstraints.NONE,
|
||||
new Insets(2, 2, 2, 2),
|
||||
0,
|
||||
0);
|
||||
final GridBagConstraints constraints = new GridBagConstraints(0, 0, 1, 1, 1, 0, GridBagConstraints.CENTER,
|
||||
GridBagConstraints.NONE, new Insets(2, 2, 2, 2), 0, 0);
|
||||
layout.setConstraints(stallNameLabel, constraints);
|
||||
this.add(stallNameLabel);
|
||||
|
||||
@@ -120,8 +135,8 @@ public class QuestBazaarStall extends JPanel implements NewConstants {
|
||||
this.add(fluffArea);
|
||||
|
||||
constraints.gridy = 2;
|
||||
layout.setConstraints(creditLabel, constraints);
|
||||
this.add(creditLabel);
|
||||
layout.setConstraints(this.creditLabel, constraints);
|
||||
this.add(this.creditLabel);
|
||||
|
||||
constraints.gridy = 3;
|
||||
constraints.anchor = GridBagConstraints.NORTHWEST;
|
||||
@@ -130,10 +145,10 @@ public class QuestBazaarStall extends JPanel implements NewConstants {
|
||||
constraints.weighty = 1;
|
||||
constraints.weightx = GridBagConstraints.REMAINDER;
|
||||
|
||||
populateInventory(populateItems());
|
||||
this.populateInventory(this.populateItems());
|
||||
|
||||
JScrollPane scrollPane = new JScrollPane(inventoryPanel);
|
||||
scrollPane.setHorizontalScrollBarPolicy(JScrollPane.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
final JScrollPane scrollPane = new JScrollPane(this.inventoryPanel);
|
||||
scrollPane.setHorizontalScrollBarPolicy(ScrollPaneConstants.HORIZONTAL_SCROLLBAR_NEVER);
|
||||
scrollPane.setBorder(new EmptyBorder(0, 0, 0, 0));
|
||||
layout.setConstraints(scrollPane, constraints);
|
||||
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) {
|
||||
inventoryPanel.removeAll();
|
||||
private void populateInventory(final java.util.List<QuestBazaarItem> stallItems) {
|
||||
this.inventoryPanel.removeAll();
|
||||
|
||||
GridBagLayout innerLayout = new GridBagLayout();
|
||||
inventoryPanel.setLayout(innerLayout);
|
||||
GridBagConstraints innerConstraints =
|
||||
new GridBagConstraints(0,
|
||||
0,
|
||||
1,
|
||||
1,
|
||||
1,
|
||||
0,
|
||||
GridBagConstraints.NORTHWEST,
|
||||
GridBagConstraints.HORIZONTAL,
|
||||
new Insets(2, 2, 2, 2),
|
||||
0,
|
||||
0);
|
||||
final GridBagLayout innerLayout = new GridBagLayout();
|
||||
this.inventoryPanel.setLayout(innerLayout);
|
||||
final GridBagConstraints innerConstraints = new GridBagConstraints(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) {
|
||||
|
||||
purchaseLabel.setText("The merchant does not have anything useful for sale");
|
||||
inventoryPanel.add(purchaseLabel);
|
||||
this.inventoryPanel.add(purchaseLabel);
|
||||
innerConstraints.gridy++;
|
||||
} else {
|
||||
|
||||
innerConstraints.insets = new Insets(5, 20, 5, 5);
|
||||
for (QuestBazaarItem item : stallItems) {
|
||||
JPanel itemPanel = item.getItemPanel();
|
||||
for (final QuestBazaarItem item : stallItems) {
|
||||
final JPanel itemPanel = item.getItemPanel();
|
||||
|
||||
innerLayout.setConstraints(itemPanel, innerConstraints);
|
||||
inventoryPanel.add(itemPanel);
|
||||
this.inventoryPanel.add(itemPanel);
|
||||
innerConstraints.gridy++;
|
||||
}
|
||||
}
|
||||
innerConstraints.weighty = 1;
|
||||
JLabel fillLabel = new JLabel();
|
||||
final JLabel fillLabel = new JLabel();
|
||||
|
||||
innerLayout.setConstraints(fillLabel, innerConstraints);
|
||||
inventoryPanel.add(fillLabel);
|
||||
this.inventoryPanel.add(fillLabel);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>populateItems.</p>
|
||||
* <p>
|
||||
* populateItems.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
protected java.util.List<QuestBazaarItem> populateItems() {
|
||||
java.util.List<QuestBazaarItem> ret = new ArrayList<QuestBazaarItem>();
|
||||
java.util.List<QuestStallPurchasable> purchasables = QuestStallManager.getItems(name);
|
||||
final java.util.List<QuestBazaarItem> ret = new ArrayList<QuestBazaarItem>();
|
||||
final java.util.List<QuestStallPurchasable> purchasables = QuestStallManager.getItems(this.name);
|
||||
|
||||
for (QuestStallPurchasable purchasable : purchasables) {
|
||||
for (final QuestStallPurchasable purchasable : purchasables) {
|
||||
ret.add(new QuestBazaarItem(purchasable));
|
||||
}
|
||||
|
||||
return ret;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getStallIcon.</p>
|
||||
* <p>
|
||||
* getStallIcon.
|
||||
* </p>
|
||||
*
|
||||
* @return a {@link javax.swing.ImageIcon} object.
|
||||
*/
|
||||
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.
|
||||
*/
|
||||
public String getStallName() {
|
||||
return stallName;
|
||||
return this.stallName;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>updateItems.</p>
|
||||
* <p>
|
||||
* updateItems.
|
||||
* </p>
|
||||
*/
|
||||
public void updateItems() {
|
||||
SwingUtilities.invokeLater(new Runnable() {
|
||||
@Override
|
||||
public void run() {
|
||||
populateInventory(populateItems());
|
||||
creditLabel.setText("Credits: " + questData.getCredits());
|
||||
inventoryPanel.invalidate();
|
||||
inventoryPanel.repaint();
|
||||
QuestBazaarStall.this.populateInventory(QuestBazaarStall.this.populateItems());
|
||||
QuestBazaarStall.this.creditLabel.setText("Credits: " + QuestBazaarStall.this.questData.getCredits());
|
||||
QuestBazaarStall.this.inventoryPanel.invalidate();
|
||||
QuestBazaarStall.this.inventoryPanel.repaint();
|
||||
}
|
||||
});
|
||||
}
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
/** Forge Card Game. */
|
||||
package forge.quest.gui.bazaar;
|
||||
|
||||
|
||||
@@ -50,7 +50,7 @@ public class QuestChallenge extends QuestEvent {
|
||||
*/
|
||||
public QuestChallenge() {
|
||||
super();
|
||||
eventType = "challenge";
|
||||
this.eventType = "challenge";
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -61,7 +61,7 @@ public class QuestChallenge extends QuestEvent {
|
||||
* @return {@link java.lang.Integer}.
|
||||
*/
|
||||
public final int getAILife() {
|
||||
return aiLife;
|
||||
return this.aiLife;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -72,7 +72,7 @@ public class QuestChallenge extends QuestEvent {
|
||||
* @return {@link java.lang.String}.
|
||||
*/
|
||||
public final String getCardReward() {
|
||||
return cardReward;
|
||||
return this.cardReward;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -83,7 +83,7 @@ public class QuestChallenge extends QuestEvent {
|
||||
* @return {@link java.lang.Integer}.
|
||||
*/
|
||||
public final int getCreditsReward() {
|
||||
return creditsReward;
|
||||
return this.creditsReward;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -94,7 +94,7 @@ public class QuestChallenge extends QuestEvent {
|
||||
* @return {@link java.lang.Integer}.
|
||||
*/
|
||||
public final int getId() {
|
||||
return id;
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -105,7 +105,7 @@ public class QuestChallenge extends QuestEvent {
|
||||
* @return {@link java.lang.Boolean}.
|
||||
*/
|
||||
public final boolean getRepeatable() {
|
||||
return repeatable;
|
||||
return this.repeatable;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -116,7 +116,7 @@ public class QuestChallenge extends QuestEvent {
|
||||
* @return {@link java.lang.Integer}.
|
||||
*/
|
||||
public final int getWinsReqd() {
|
||||
return winsReqd;
|
||||
return this.winsReqd;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -128,7 +128,7 @@ public class QuestChallenge extends QuestEvent {
|
||||
* @return the aI extra cards
|
||||
*/
|
||||
public final List<String> getAIExtraCards() {
|
||||
return aiExtraCards;
|
||||
return this.aiExtraCards;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -140,7 +140,7 @@ public class QuestChallenge extends QuestEvent {
|
||||
* @return the human extra cards
|
||||
*/
|
||||
public final List<String> getHumanExtraCards() {
|
||||
return humanExtraCards;
|
||||
return this.humanExtraCards;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -151,6 +151,6 @@ public class QuestChallenge extends QuestEvent {
|
||||
* @return the card reward list
|
||||
*/
|
||||
public final List<CardPrinted> getCardRewardList() {
|
||||
return cardRewardList;
|
||||
return this.cardRewardList;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -31,12 +31,12 @@ public class QuestChallengePanel extends QuestSelectablePanel {
|
||||
GuiUtils.addGap(super.rootPanel, 7);
|
||||
|
||||
if (q.getRepeatable()) {
|
||||
repeatabilityLabel = new JLabel("This challenge is repeatable");
|
||||
this.repeatabilityLabel = new JLabel("This challenge is repeatable");
|
||||
} 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);
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
@@ -14,7 +14,7 @@ public class QuestDuel extends QuestEvent {
|
||||
*/
|
||||
public QuestDuel() {
|
||||
super();
|
||||
eventType = "duel";
|
||||
this.eventType = "duel";
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
@@ -41,7 +41,7 @@ public class QuestEvent {
|
||||
* @return a {@link java.lang.String}.
|
||||
*/
|
||||
public final String getTitle() {
|
||||
return title;
|
||||
return this.title;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -52,7 +52,7 @@ public class QuestEvent {
|
||||
* @return a {@link java.lang.String}.
|
||||
*/
|
||||
public final String getDifficulty() {
|
||||
return difficulty;
|
||||
return this.difficulty;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -63,7 +63,7 @@ public class QuestEvent {
|
||||
* @return a {@link java.lang.String}.
|
||||
*/
|
||||
public final String getDescription() {
|
||||
return description;
|
||||
return this.description;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -74,7 +74,7 @@ public class QuestEvent {
|
||||
* @return {@link forge.deck.Deck}
|
||||
*/
|
||||
public final Deck getEventDeck() {
|
||||
return eventDeck;
|
||||
return this.eventDeck;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -85,7 +85,7 @@ public class QuestEvent {
|
||||
* @return {@link forge.deck.Deck}
|
||||
*/
|
||||
public final String getEventType() {
|
||||
return eventType;
|
||||
return this.eventType;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -96,7 +96,7 @@ public class QuestEvent {
|
||||
* @return a {@link java.lang.String}.
|
||||
*/
|
||||
public final String getIcon() {
|
||||
return icon;
|
||||
return this.icon;
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -107,6 +107,6 @@ public class QuestEvent {
|
||||
* @return a {@link java.lang.String}.
|
||||
*/
|
||||
public final String getName() {
|
||||
return name;
|
||||
return this.name;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -57,32 +57,32 @@ public class QuestEventManager {
|
||||
List<String> contents;
|
||||
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);
|
||||
|
||||
if (contents.get(0).trim().equals("[quest]")) {
|
||||
tempEvent = new QuestChallenge();
|
||||
assembleChallengeUniquedata(contents, (QuestChallenge) tempEvent);
|
||||
allChallenges.add((QuestChallenge) tempEvent);
|
||||
this.assembleChallengeUniquedata(contents, (QuestChallenge) tempEvent);
|
||||
this.allChallenges.add((QuestChallenge) tempEvent);
|
||||
} // End if([quest])
|
||||
else {
|
||||
tempEvent = new QuestDuel();
|
||||
assembleDuelUniquedata(contents, (QuestDuel) tempEvent);
|
||||
allDuels.add((QuestDuel) tempEvent);
|
||||
this.assembleDuelUniquedata(contents, (QuestDuel) tempEvent);
|
||||
this.allDuels.add((QuestDuel) tempEvent);
|
||||
}
|
||||
|
||||
// Assemble metadata (may not be necessary later) and deck object.
|
||||
assembleEventMetadata(contents, tempEvent);
|
||||
this.assembleEventMetadata(contents, tempEvent);
|
||||
tempEvent.eventDeck = manager.getDeck(tempEvent.getName());
|
||||
} // End for(allFiles)
|
||||
|
||||
assembleDuelDifficultyLists();
|
||||
this.assembleDuelDifficultyLists();
|
||||
|
||||
} // End assembleAllEvents()
|
||||
|
||||
@@ -99,7 +99,7 @@ public class QuestEventManager {
|
||||
int eqpos;
|
||||
String key, value;
|
||||
|
||||
for (String s : contents) {
|
||||
for (final String s : contents) {
|
||||
if (s.equals("[metadata]")) {
|
||||
break;
|
||||
}
|
||||
@@ -137,7 +137,7 @@ public class QuestEventManager {
|
||||
String key, value;
|
||||
|
||||
// Unique properties
|
||||
for (String s : contents) {
|
||||
for (final String s : contents) {
|
||||
if (s.equals("[metadata]")) {
|
||||
break;
|
||||
}
|
||||
@@ -168,10 +168,10 @@ public class QuestEventManager {
|
||||
}
|
||||
// Human extra card list assembled here.
|
||||
else if (key.equalsIgnoreCase("HumanExtras") && !value.equals("")) {
|
||||
String[] names = value.split("\\|");
|
||||
List<String> templist = new ArrayList<String>();
|
||||
final String[] names = value.split("\\|");
|
||||
final List<String> templist = new ArrayList<String>();
|
||||
|
||||
for (String n : names) {
|
||||
for (final String n : names) {
|
||||
templist.add(n);
|
||||
}
|
||||
|
||||
@@ -179,10 +179,10 @@ public class QuestEventManager {
|
||||
}
|
||||
// AI extra card list assembled here.
|
||||
else if (key.equalsIgnoreCase("AIExtras") && !value.equals("")) {
|
||||
String[] names = value.split("\\|");
|
||||
List<String> templist = new ArrayList<String>();
|
||||
final String[] names = value.split("\\|");
|
||||
final List<String> templist = new ArrayList<String>();
|
||||
|
||||
for (String n : names) {
|
||||
for (final String n : names) {
|
||||
templist.add(n);
|
||||
}
|
||||
|
||||
@@ -274,22 +274,22 @@ public class QuestEventManager {
|
||||
* Assemble duel deck difficulty lists
|
||||
*/
|
||||
private void assembleDuelDifficultyLists() {
|
||||
easyAIduels = new ArrayList<QuestDuel>();
|
||||
mediumAIduels = new ArrayList<QuestDuel>();
|
||||
hardAIduels = new ArrayList<QuestDuel>();
|
||||
veryHardAIduels = new ArrayList<QuestDuel>();
|
||||
this.easyAIduels = new ArrayList<QuestDuel>();
|
||||
this.mediumAIduels = new ArrayList<QuestDuel>();
|
||||
this.hardAIduels = new ArrayList<QuestDuel>();
|
||||
this.veryHardAIduels = new ArrayList<QuestDuel>();
|
||||
String s;
|
||||
|
||||
for (QuestDuel qd : allDuels) {
|
||||
for (final QuestDuel qd : this.allDuels) {
|
||||
s = qd.getDifficulty();
|
||||
if (s.equalsIgnoreCase("easy")) {
|
||||
easyAIduels.add(qd);
|
||||
this.easyAIduels.add(qd);
|
||||
} else if (s.equalsIgnoreCase("medium")) {
|
||||
mediumAIduels.add(qd);
|
||||
this.mediumAIduels.add(qd);
|
||||
} else if (s.equalsIgnoreCase("hard")) {
|
||||
hardAIduels.add(qd);
|
||||
this.hardAIduels.add(qd);
|
||||
} 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.
|
||||
*/
|
||||
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()));
|
||||
|
||||
return deckListCopy.get(n);
|
||||
@@ -326,7 +326,7 @@ public class QuestEventManager {
|
||||
* @return
|
||||
*/
|
||||
private QuestChallenge getChallengeEventByNumber(final int n) {
|
||||
for (QuestChallenge qc : allChallenges) {
|
||||
for (final QuestChallenge qc : this.allChallenges) {
|
||||
if (qc.getId() == n) {
|
||||
return qc;
|
||||
}
|
||||
@@ -344,37 +344,37 @@ public class QuestEventManager {
|
||||
*/
|
||||
public final List<QuestDuel> generateDuels() {
|
||||
|
||||
int index = AllZone.getQuestData().getDifficultyIndex();
|
||||
List<QuestDuel> duelOpponents = new ArrayList<QuestDuel>();
|
||||
final int index = AllZone.getQuestData().getDifficultyIndex();
|
||||
final List<QuestDuel> duelOpponents = new ArrayList<QuestDuel>();
|
||||
|
||||
if (AllZone.getQuestData().getWin() < QuestPreferences.getWinsForMediumAI(index)) {
|
||||
duelOpponents.add(getDuelOpponentByNumber(easyAIduels, 0));
|
||||
duelOpponents.add(getDuelOpponentByNumber(easyAIduels, 1));
|
||||
duelOpponents.add(getDuelOpponentByNumber(easyAIduels, 2));
|
||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.easyAIduels, 0));
|
||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.easyAIduels, 1));
|
||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.easyAIduels, 2));
|
||||
} else if (AllZone.getQuestData().getWin() == QuestPreferences.getWinsForMediumAI(index)) {
|
||||
duelOpponents.add(getDuelOpponentByNumber(easyAIduels, 0));
|
||||
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 0));
|
||||
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 1));
|
||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.easyAIduels, 0));
|
||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.mediumAIduels, 0));
|
||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.mediumAIduels, 1));
|
||||
} else if (AllZone.getQuestData().getWin() < QuestPreferences.getWinsForHardAI(index)) {
|
||||
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 0));
|
||||
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 1));
|
||||
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 2));
|
||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.mediumAIduels, 0));
|
||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.mediumAIduels, 1));
|
||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.mediumAIduels, 2));
|
||||
}
|
||||
|
||||
else if (AllZone.getQuestData().getWin() == QuestPreferences.getWinsForHardAI(index)) {
|
||||
duelOpponents.add(getDuelOpponentByNumber(mediumAIduels, 0));
|
||||
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 0));
|
||||
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 1));
|
||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.mediumAIduels, 0));
|
||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.hardAIduels, 0));
|
||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.hardAIduels, 1));
|
||||
}
|
||||
|
||||
else if (AllZone.getQuestData().getWin() < QuestPreferences.getWinsForVeryHardAI(index)) {
|
||||
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 0));
|
||||
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 1));
|
||||
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 2));
|
||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.hardAIduels, 0));
|
||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.hardAIduels, 1));
|
||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.hardAIduels, 2));
|
||||
} else {
|
||||
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 0));
|
||||
duelOpponents.add(getDuelOpponentByNumber(hardAIduels, 1));
|
||||
duelOpponents.add(getDuelOpponentByNumber(veryHardAIduels, 2));
|
||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.hardAIduels, 0));
|
||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.hardAIduels, 1));
|
||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(this.veryHardAIduels, 2));
|
||||
}
|
||||
|
||||
return duelOpponents;
|
||||
@@ -390,9 +390,9 @@ public class QuestEventManager {
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
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;
|
||||
if (maxChallenges > 5) {
|
||||
@@ -400,15 +400,14 @@ public class QuestEventManager {
|
||||
}
|
||||
|
||||
// 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>();
|
||||
List<Integer> availableChallengeIds = new ArrayList<Integer>();
|
||||
final List<Integer> unlockedChallengeIds = new ArrayList<Integer>();
|
||||
final List<Integer> availableChallengeIds = new ArrayList<Integer>();
|
||||
|
||||
for (QuestChallenge qc : allChallenges) {
|
||||
if (qc.getWinsReqd() <= questData.getWin()
|
||||
&& !questData.getCompletedChallenges().contains(qc.getId()))
|
||||
{
|
||||
for (final QuestChallenge qc : this.allChallenges) {
|
||||
if ((qc.getWinsReqd() <= questData.getWin())
|
||||
&& !questData.getCompletedChallenges().contains(qc.getId())) {
|
||||
unlockedChallengeIds.add(qc.getId());
|
||||
}
|
||||
}
|
||||
@@ -426,8 +425,8 @@ public class QuestEventManager {
|
||||
}
|
||||
|
||||
// Finally, pull challenge events from available IDs and return.
|
||||
for (int i : questData.getAvailableChallenges()) {
|
||||
challengeOpponents.add(getChallengeEventByNumber(i));
|
||||
for (final int i : questData.getAvailableChallenges()) {
|
||||
challengeOpponents.add(this.getChallengeEventByNumber(i));
|
||||
}
|
||||
|
||||
return challengeOpponents;
|
||||
|
||||
@@ -2,6 +2,7 @@ package forge.quest.gui.main;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Component;
|
||||
import java.awt.Dimension;
|
||||
import java.io.File;
|
||||
|
||||
@@ -33,7 +34,7 @@ public class QuestSelectablePanel extends JPanel {
|
||||
/** The background color. */
|
||||
protected Color backgroundColor;
|
||||
private boolean selected;
|
||||
private QuestEvent event;
|
||||
private final QuestEvent event;
|
||||
private String iconfilename;
|
||||
|
||||
/** The root panel. */
|
||||
@@ -51,17 +52,17 @@ public class QuestSelectablePanel extends JPanel {
|
||||
public QuestSelectablePanel(final QuestEvent qe) {
|
||||
this.event = qe;
|
||||
this.iconfilename = qe.icon;
|
||||
File base = ForgeProps.getFile(NewConstants.IMAGE_ICON);
|
||||
File file = new File(base, iconfilename);
|
||||
final File base = ForgeProps.getFile(NewConstants.IMAGE_ICON);
|
||||
File file = new File(base, this.iconfilename);
|
||||
|
||||
if (!file.exists()) {
|
||||
file = new File(base, "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));
|
||||
|
||||
JLabel iconLabel;
|
||||
@@ -73,39 +74,39 @@ public class QuestSelectablePanel extends JPanel {
|
||||
}
|
||||
|
||||
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.add(iconLabel, BorderLayout.NORTH);
|
||||
this.add(iconPanel, BorderLayout.WEST);
|
||||
|
||||
rootPanel.setOpaque(false);
|
||||
rootPanel.setLayout(new BoxLayout(rootPanel, BoxLayout.Y_AXIS));
|
||||
this.add(rootPanel, BorderLayout.CENTER);
|
||||
this.rootPanel.setOpaque(false);
|
||||
this.rootPanel.setLayout(new BoxLayout(this.rootPanel, BoxLayout.Y_AXIS));
|
||||
this.add(this.rootPanel, BorderLayout.CENTER);
|
||||
|
||||
JPanel centerTopPanel = new JPanel();
|
||||
final JPanel centerTopPanel = new JPanel();
|
||||
centerTopPanel.setOpaque(false);
|
||||
centerTopPanel.setAlignmentX(LEFT_ALIGNMENT);
|
||||
centerTopPanel.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
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);
|
||||
nameLabel.setAlignmentY(BOTTOM_ALIGNMENT);
|
||||
nameLabel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
|
||||
centerTopPanel.add(nameLabel);
|
||||
|
||||
GuiUtils.addExpandingHorizontalSpace(centerTopPanel);
|
||||
|
||||
JLabel difficultyLabel = new JLabel(qe.getDifficulty());
|
||||
difficultyLabel.setAlignmentY(BOTTOM_ALIGNMENT);
|
||||
final JLabel difficultyLabel = new JLabel(qe.getDifficulty());
|
||||
difficultyLabel.setAlignmentY(Component.BOTTOM_ALIGNMENT);
|
||||
centerTopPanel.add(difficultyLabel);
|
||||
rootPanel.add(centerTopPanel);
|
||||
this.rootPanel.add(centerTopPanel);
|
||||
|
||||
GuiUtils.addGap(rootPanel);
|
||||
GuiUtils.addGap(this.rootPanel);
|
||||
|
||||
JLabel descriptionLabel = new JLabel(qe.getDescription());
|
||||
descriptionLabel.setAlignmentX(LEFT_ALIGNMENT);
|
||||
rootPanel.add(descriptionLabel);
|
||||
final JLabel descriptionLabel = new JLabel(qe.getDescription());
|
||||
descriptionLabel.setAlignmentX(Component.LEFT_ALIGNMENT);
|
||||
this.rootPanel.add(descriptionLabel);
|
||||
|
||||
this.setMaximumSize(new Dimension(Integer.MAX_VALUE, 80));
|
||||
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.
|
||||
*/
|
||||
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) {
|
||||
if (selected) {
|
||||
this.setBackground(backgroundColor.darker());
|
||||
this.setBackground(this.backgroundColor.darker());
|
||||
} else {
|
||||
this.setBackground(backgroundColor);
|
||||
this.setBackground(this.backgroundColor);
|
||||
}
|
||||
|
||||
this.selected = selected;
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
/** Forge Card Game. */
|
||||
package forge.quest.gui.main;
|
||||
|
||||
|
||||
@@ -1,2 +1,3 @@
|
||||
/** Forge Card Game. */
|
||||
package forge.quest.gui;
|
||||
|
||||
|
||||
Reference in New Issue
Block a user