QuestAssignment. */
- private static Quest_Assignment questAssignment = null;
+ private static QuestQuest questquest = null;
/** Constant NAME_CHANGER. */
private static final NameChanger NAME_CHANGER = new NameChanger();
@@ -136,8 +137,8 @@ public final class AllZone implements NewConstants {
* @return a {@link forge.Quest_Assignment} object.
* @since 1.0.15
*/
- public static Quest_Assignment getQuestAssignment() {
- return questAssignment;
+ public static QuestQuest getQuestQuest() {
+ return questquest;
}
/**
@@ -146,8 +147,8 @@ public final class AllZone implements NewConstants {
* @param assignment a {@link forge.Quest_Assignment} object.
* @since 1.0.15
*/
- public static void setQuestAssignment(final Quest_Assignment assignment) {
- questAssignment = assignment;
+ public static void setQuestQuest(final QuestQuest q) {
+ questquest = q;
}
/**
diff --git a/src/main/java/forge/GameAction.java b/src/main/java/forge/GameAction.java
index 53f5725ca70..de603e648c2 100644
--- a/src/main/java/forge/GameAction.java
+++ b/src/main/java/forge/GameAction.java
@@ -29,6 +29,7 @@ import forge.gui.input.Input_PayManaCost_Ability;
import forge.item.CardPrinted;
import forge.properties.ForgeProps;
import forge.properties.NewConstants.LANG.GameAction.GAMEACTION_TEXT;
+import forge.quest.gui.main.QuestQuest;
import java.util.ArrayList;
import java.util.Comparator;
@@ -653,7 +654,7 @@ public class GameAction {
AllZone.getDisplay().savePrefs();
frame.setEnabled(false);
//frame.dispose();
- Gui_WinLose gwl = new Gui_WinLose(AllZone.getMatchState(), AllZone.getQuestData(), AllZone.getQuestAssignment());
+ Gui_WinLose gwl = new Gui_WinLose(AllZone.getMatchState(), AllZone.getQuestData(), AllZone.getQuestQuest());
//gwl.setAlwaysOnTop(true);
gwl.toFront();
canShowWinLose = false;
@@ -1074,15 +1075,15 @@ public class GameAction {
* @param computer a {@link forge.CardList} object.
*/
public final void newGame(final Deck humanDeck, final Deck computerDeck, final CardList human,
- final CardList computer, final int humanLife, final int computerLife, final Quest_Assignment qa)
+ final CardList computer, final int humanLife, final int computerLife, final QuestQuest qq)
{
this.newGame(humanDeck, computerDeck);
AllZone.getComputerPlayer().setLife(computerLife, null);
AllZone.getHumanPlayer().setLife(humanLife, null);
- if (qa != null) {
- computer.addAll(forge.quest.data.QuestUtil.getComputerStartingCards(AllZone.getQuestData(), AllZone.getQuestAssignment()));
+ if (qq != null) {
+ computer.addAll(forge.quest.data.QuestUtil.getComputerStartingCards(AllZone.getQuestData(), AllZone.getQuestQuest()));
}
for (Card c : human) {
diff --git a/src/main/java/forge/Gui_WinLose.java b/src/main/java/forge/Gui_WinLose.java
index e31613c67e7..43b48e13f1f 100644
--- a/src/main/java/forge/Gui_WinLose.java
+++ b/src/main/java/forge/Gui_WinLose.java
@@ -17,6 +17,7 @@ import forge.quest.data.QuestData;
import forge.quest.data.QuestMatchState;
import forge.quest.data.QuestPreferences;
import forge.quest.gui.QuestFrame;
+import forge.quest.gui.main.QuestQuest;
import forge.view.swing.OldGuiNewGame;
import net.miginfocom.swing.MigLayout;
@@ -65,7 +66,7 @@ public class Gui_WinLose extends JFrame implements NewConstants {
private class WinLoseModel {
public QuestMatchState match;
public QuestData quest;
- public Quest_Assignment qa;
+ public QuestQuest qq;
}
private WinLoseModel model;
@@ -77,11 +78,11 @@ public class Gui_WinLose extends JFrame implements NewConstants {
* @param quest a QuestData object
* @param qa a Quest_Assignment object
*/
- public Gui_WinLose(final QuestMatchState matchState, final QuestData quest, final Quest_Assignment qa) {
+ public Gui_WinLose(final QuestMatchState matchState, final QuestData quest, final QuestQuest qq) {
model = new WinLoseModel();
model.match = matchState;
model.quest = quest;
- model.qa = qa;
+ model.qq = qq;
try {
jbInit();
@@ -186,25 +187,25 @@ public class Gui_WinLose extends JFrame implements NewConstants {
void prepareForNextRound() {
if (Constant.Quest.fantasyQuest[0]) {
int extraLife = 0;
- if (model.qa != null) {
+ if (model.qq != null) {
if (model.quest.getInventory().hasItem("Zeppelin")) {
extraLife = 3;
}
}
//AllZone.getGameAction().newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0],
//humanList, computerList, humanLife, computerLife);
- CardList humanList = forge.quest.data.QuestUtil.getHumanStartingCards(model.quest, model.qa);
+ CardList humanList = forge.quest.data.QuestUtil.getHumanStartingCards(model.quest, model.qq);
CardList computerList = new CardList();
int humanLife = model.quest.getLife() + extraLife;
int computerLife = 20;
- if (model.qa != null) {
- computerLife = model.qa.getComputerLife();
+ if (model.qq != null) {
+ computerLife = model.qq.getAILife();
}
AllZone.getGameAction().newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0],
- humanList, computerList, humanLife, computerLife, model.qa);
+ humanList, computerList, humanLife, computerLife, model.qq);
} else {
AllZone.getGameAction().newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0]);
}
@@ -362,7 +363,7 @@ public class Gui_WinLose extends JFrame implements NewConstants {
giveQuestRewards(wonMatch);
model.match.reset();
- AllZone.setQuestAssignment(null);
+ AllZone.setQuestQuest(null);
model.quest.saveData();
@@ -440,11 +441,11 @@ public class Gui_WinLose extends JFrame implements NewConstants {
}
// Rewards from QuestAssignment
- if (wonMatch && model.qa != null) {
+ if (wonMatch && model.qq != null) {
model.quest.addQuestsPlayed();
- ListQuest_Assignment class.
- * An instance of a single quest assignment. Holds values that aren't defined in - * Deck class, such as credit reward. - * - * @author Forge - * @version $Id$ - */ -public class Quest_Assignment { - // ID (default -1, should be explicitly set at later time.) - private int id = -1; - - // Default vals if none provided for this ID in quests.txt. - private int requiredNumberWins = 20; - private int computerLife = 25; - private long creditsReward = 100; - private String name = "Mystery Quest"; - private String desc = ""; - private String difficulty = "Medium"; - private String cardReward = "1 colorless rare"; - private String iconName = "Unknown.jpg"; - private boolean repeatable = false; - - // Other cards used in assignment: starting, and reward. - private CardList humanExtraCards = new CardList(); - private CardList aiExtraCards = new CardList(); - private ListSetter for the field aiExtraCards.
Getter for the field aiExtraCards.
Setter for the field cardReward.
Getter for the field cardReward.
Setter for the field cardRewardList.
Getter for the field cardRewardList.
Setter for the field computerLife.
Getter for the field computerLife.
Setter for the field creditsReward.
Getter for the field creditsReward.
Setter for the field desc.
Getter for the field desc.
Setter for the field difficulty.
Setter for the field humanExtraCards.
Getter for the field humanExtraCards.
Getter for the field difficulty.
Setter for the field id.
Getter for the field id.
Setter for the field iconName.
Getter for the field iconName.
Setter for the field name.
Getter for the field name.
Setter for the field repeatable.
isRepeatable.
- * - * @return a boolean. - */ - public final boolean isRepeatable() { - return repeatable; - } - - /** - *Setter for the field requiredNumberWins.
Getter for the field requiredNumberWins.
ReadQuest_Assignment class.
- * - * @author Forge - * @version $Id$ - */ -public class ReadQuest_Assignment implements Runnable, NewConstants { - - ArrayListConstructor for ReadQuest_Assignment.
- * Sets parameters for available quests and prepares buffered reader for quests.txt. - * - * @param filename a {@link java.lang.String} object. - * @param questData a {@link forge.quest.data.QuestData} object. - */ - public ReadQuest_Assignment(String filename, forge.quest.data.QuestData questData) { - this(new File(filename), questData); - } - - /** - *Constructor for ReadQuest_Assignment.
- * Sets parameters for available quests and prepares buffered reader for quests.txt. - * - * @param file a {@link java.io.File} object. - * @param questData a {@link forge.quest.data.QuestData} object. - */ - public ReadQuest_Assignment(File file, forge.quest.data.QuestData questData) { - if (questData != null) { - totalWins = questData.getWin(); - if (questData.getCompletedQuests() != null) { - completedQuests = questData.getCompletedQuests(); - } - else { - completedQuests = new ArrayListgetAvailableQuests.
- * Returns list of currently available quest objects. - * - * @return a {@link java.util.List} object. - */ - public ListgetQuests.
- * Returns complete list of all quest objects. - * - * @return a {@link java.util.List} object. - */ - public ListgetQuestsByIds.
- * - * @param availableQuestIds a {@link java.util.List} object. - * @return a {@link java.util.List} object. - */ - public ListgetQuestById.
- * - * @param i a int. - * @return a {@link forge.Quest_Assignment} object. - */ - public Quest_Assignment getQuestById(int id) { - // Error handling for OOB ID? - return allQuests.get(id); - } - - /** - *run.
- * Assembles Quest_Assignment instances into allQuests. - */ - public void run() { - Quest_Assignment qa = null; - String line; - int i; - String[] linedata; - - try { - while ((line = br.readLine()) != null) { - if(line.equals("[quest]")) { - qa = new Quest_Assignment(); - allQuests.add(qa); - } - else if(!line.equals("") && qa != null) { - linedata = line.split("=", 2); - linedata[1] = linedata[1].trim(); - - // If empty data, ignore the line (assignment will use default). - if(linedata[1].equals("")) { - continue; - } - - // Data OK. - if(linedata[0].equals(ID)) { - i = Integer.parseInt(linedata[1]); - - // Duplicate ID check - if(ids.contains(i)) { - throw new RuntimeException("ReadQuest_Assignment > run() error: duplicate quest ID ("+i+")"); - } - // Non-sequential ID check - else if(i != allQuests.size()) { - throw new RuntimeException("ReadQuest_Assignment > run() error: non-sequential quest ID ("+i+")"); - } - // ID OK. - else { - ids.add(i); - qa.setId(i); - } - } - else if(linedata[0].equals(ICON)) { - qa.setIconName(linedata[1]); - } - else if(linedata[0].equals(TITLE)) { - qa.setName(linedata[1]); - } - else if(linedata[0].equals(DESC)) { - qa.setDesc(linedata[1]); - } - else if(linedata[0].equals(DIFF)) { - qa.setDifficulty(linedata[1]); - } - else if(linedata[0].equals(REPEAT)) { - qa.setRepeatable(Boolean.parseBoolean(linedata[1])); - } - else if(linedata[0].equals(AILIFE)) { - qa.setComputerLife(Integer.parseInt(linedata[1])); - } - else if(linedata[0].equals(WINS)) { - qa.setRequiredNumberWins(Integer.parseInt(linedata[1])); - } - else if(linedata[0].equals(CREDITS)) { - qa.setCreditsReward(Integer.parseInt(linedata[1])); - } - // Card reward list assembled here. - else if(linedata[0].equals(CARDS)) { - qa.setCardReward(linedata[1]); - qa.setCardRewardList(QuestUtil.generateCardRewardList(linedata[1])); - } - // Human extra card list assembled here. - else if(linedata[0].equals(HUMANEXTRAS)) { - String[] names = linedata[1].split("\\|"); - CardList templist = new CardList(); - Card tempcard; - - for(String s : names) { - // Token card creation - if(s.substring(0,5).equals("TOKEN")) { - tempcard = QuestUtil.createToken(s); - tempcard.addController(AllZone.getHumanPlayer()); - tempcard.setOwner(AllZone.getHumanPlayer()); - templist.add(tempcard); - } - // Standard card creation - else { - tempcard = AllZone.getCardFactory().getCard(s, AllZone.getHumanPlayer()); - tempcard.setCurSetCode(tempcard.getMostRecentSet()); - tempcard.setImageFilename(CardUtil.buildFilename(tempcard)); - templist.add(tempcard); - } - } - - qa.setHumanExtraCards(templist); - } - // AI extra card list assembled here. - else if(linedata[0].equals(AIEXTRAS)) { - String[] names = linedata[1].split("\\|"); - CardList templist = new CardList(); - Card tempcard; - - for(String s : names) { - // Token card creation - if(s.substring(0,5).equals("TOKEN")) { - tempcard = QuestUtil.createToken(s); - tempcard.addController(AllZone.getComputerPlayer()); - tempcard.setOwner(AllZone.getComputerPlayer()); - templist.add(tempcard); - } - // Standard card creation - else { - tempcard = AllZone.getCardFactory().getCard(s, AllZone.getComputerPlayer()); - tempcard.setCurSetCode(tempcard.getMostRecentSet()); - tempcard.setImageFilename(CardUtil.buildFilename(tempcard)); - templist.add(tempcard); - } - } - - qa.setAIExtraCards(templist); - } - } // else if() - } // while() - - br.close(); - } - catch (IOException e) { - e.printStackTrace(); - } - - // Confirm that all quests have IDs. - for(Quest_Assignment q : allQuests) { - if(q.getId()==-1) { - throw new RuntimeException("ReadQuest_Assignment > getQuests() error: "+ - "Quest ID missing for '"+q.getName()+"'."); - } - } - - } // run() -} diff --git a/src/main/java/forge/card/BoosterUtils.java b/src/main/java/forge/card/BoosterUtils.java index ba8883071a6..7d6b8df9c95 100644 --- a/src/main/java/forge/card/BoosterUtils.java +++ b/src/main/java/forge/card/BoosterUtils.java @@ -53,7 +53,7 @@ public final class BoosterUtils { int nRares = numRare, nMythics = 0; PredicateQuestBattleManager class.
- * - * @author Forge - * @version $Id$ - */ -public class QuestBattleManager { - /** ConstanteasyAIDecks */
- private static transient ListmediumAIDecks */
- private static transient ListhardAIDecks */
- private static transient ListveryHardAIDecks */
- private static transient ListgetOpponent.
- * - * Badly named; AllZoneUtil already has a method called getOpponents. - * ????? - * - * @param aiDeck a {@link java.util.List} object. - * @param number a int. - * @return a {@link java.lang.String} object. - */ - public static String getOpponent(ListgenerateBattles.
- * Generates an array of new opponents based on current win conditions. - * - * @return an array of {@link java.lang.String} objects. - */ - public static String[] generateBattles() { - int index = AllZone.getQuestData().getDifficultyIndex(); - - if (AllZone.getQuestData().getWin() < QuestPreferences.getWinsForMediumAI(index)) { - return new String[]{ - getOpponent(easyAIDecks, 0), - getOpponent(easyAIDecks, 1), - getOpponent(easyAIDecks, 2)}; - } - - if (AllZone.getQuestData().getWin() == QuestPreferences.getWinsForMediumAI(index)) { - return new String[]{ - getOpponent(easyAIDecks, 0), - getOpponent(mediumAIDecks, 0), - getOpponent(mediumAIDecks, 1)}; - } - - if (AllZone.getQuestData().getWin() < QuestPreferences.getWinsForHardAI(index)) { - return new String[]{ - getOpponent(mediumAIDecks, 0), - getOpponent(mediumAIDecks, 1), - getOpponent(mediumAIDecks, 2)}; - } - - if (AllZone.getQuestData().getWin() == QuestPreferences.getWinsForHardAI(index)) { - return new String[]{ - getOpponent(mediumAIDecks, 0), - getOpponent(hardAIDecks, 0), - getOpponent(hardAIDecks, 1)}; - } - - if (AllZone.getQuestData().getWin() >= QuestPreferences.getWinsForVeryHardAI(index)) { - return new String[]{ - getOpponent(hardAIDecks, 0), - getOpponent(hardAIDecks, 1), - getOpponent(veryHardAIDecks, 0)}; - } - - return new String[]{ - getOpponent(hardAIDecks, 0), - getOpponent(hardAIDecks, 1), - getOpponent(hardAIDecks, 2)}; - } - - /** - *getDeckFromFile.
- * Returns a deck object built from a file name. - * - * @param deckName a {@link java.lang.String} object. - * @return a {@link forge.deck.Deck} object. - */ - public static Deck getAIDeckFromFile(String deckName) { - final File file = ForgeProps.getFile(NewConstants.QUEST.DECKS); - final DeckManager manager = new DeckManager(file); - return manager.getDeck(deckName); - } - - /** - *getQuestEventFromFile.
- * Returns QuestEvent data for the challenge stored in that file name. - * - * @param deckName a {@link java.lang.String} object. - * @return a {@link forge.deck.Deck} object. - */ - public static QuestEvent getQuestEventFromFile(String deckName) { - final File deckPath = ForgeProps.getFile(NewConstants.QUEST.DECKS); - File deckFile = new File(deckPath, deckName + ".dck"); - - QuestEvent result = readQuestBattleMetadataFromDeckFile(deckFile); - return result; - } - - /** - *readFile.
- * A reader util for accessing the AI deck list text files. - * - * @param file a {@link java.io.File} object. - * @param aiDecks a {@link java.util.List} object. - * @return a {@link java.util.List} object. - */ - private static ListQuestUtil class.
+ * MODEL - Static utility methods to help with minor tasks around Quest. * * @author Forge * @version $Id$ */ public class QuestUtil { - /** *getComputerStartingCards.
* @@ -36,11 +36,11 @@ public class QuestUtil { * @param qa a {@link forge.Quest_Assignment} object. * @return a {@link forge.CardList} object. */ - public static CardList getComputerStartingCards(final QuestData qd, Quest_Assignment qa) { + public static CardList getComputerStartingCards(final QuestData qd, QuestQuest qq) { CardList list = new CardList(); - if (qa != null) { - list.addAll(qa.getAIExtraCards()); + if (qq != null) { + list.addAll(qq.getAIExtraCards()); } return list; } @@ -75,11 +75,11 @@ public class QuestUtil { * @param qa a {@link forge.Quest_Assignment} object. * @return a {@link forge.CardList} object. */ - public static CardList getHumanStartingCards(final QuestData qd, Quest_Assignment qa) { + public static CardList getHumanStartingCards(final QuestData qd, QuestQuest qq) { CardList list = getHumanStartingCards(qd); - if (qa != null) { - list.addAll(qa.getHumanExtraCards()); + if (qq != null) { + list.addAll(qq.getHumanExtraCards()); } return list; @@ -163,17 +163,5 @@ public class QuestUtil { return BoosterUtils.generateCards(qty, rar, col); } - - /** - *setupQuest.
- * Assembled hard-coded quest options. - * All non-deck-specific handling now takes place in quests.txt. - * - * @deprecated - * @param qa - */ - public static void setupQuest(Quest_Assignment qa) { - - } } //QuestUtil diff --git a/src/main/java/forge/quest/gui/QuestFrame.java b/src/main/java/forge/quest/gui/QuestFrame.java index d72750139ce..fea70f40e95 100644 --- a/src/main/java/forge/quest/gui/QuestFrame.java +++ b/src/main/java/forge/quest/gui/QuestFrame.java @@ -3,7 +3,7 @@ package forge.quest.gui; import forge.AllZone; import forge.gui.GuiUtils; import forge.quest.gui.bazaar.QuestBazaarPanel; -import forge.quest.gui.main.QuestMainPanel; +import forge.quest.gui.main.QuestEventManager; import forge.view.swing.OldGuiNewGame; import javax.swing.*; @@ -24,6 +24,7 @@ public class QuestFrame extends JFrame { JPanel visiblePanel; CardLayout questLayout; + QuestEventManager qem = new QuestEventManager(); /** ConstantMAIN_PANEL="Main" */
public static final String MAIN_PANEL = "Main";
@@ -39,7 +40,14 @@ public class QuestFrame extends JFrame {
*/
public QuestFrame() throws HeadlessException {
this.setTitle("Quest Mode");
-
+ // DOUBLESTRIKE SEZ - this assembles all events, once.
+ // Unfortunately, QuestFrame is called several times.
+ // This is THE WRONG PLACE for this method, feel free to move,
+ // I'll do it very soon anyways, this is only a temporary thing.
+ if(qem.getAllDuels()==null) {
+ qem.assembleAllEvents();
+ }
+
visiblePanel = new JPanel(new BorderLayout());
visiblePanel.setBorder(new EmptyBorder(2, 2, 2, 2));
questLayout = new CardLayout();
@@ -53,7 +61,6 @@ public class QuestFrame extends JFrame {
visiblePanel.add(newPanel, BAZAAR_PANEL);
subPanelMap.put(BAZAAR_PANEL, newPanel);
-
this.getContentPane().setLayout(new BorderLayout());
this.getContentPane().add(visiblePanel, BorderLayout.CENTER);
this.setPreferredSize(new Dimension(1024, 768));
diff --git a/src/main/java/forge/quest/gui/main/QuestMainPanel.java b/src/main/java/forge/quest/gui/QuestMainPanel.java
similarity index 86%
rename from src/main/java/forge/quest/gui/main/QuestMainPanel.java
rename to src/main/java/forge/quest/gui/QuestMainPanel.java
index 22552117de4..89227f85cd9 100644
--- a/src/main/java/forge/quest/gui/main/QuestMainPanel.java
+++ b/src/main/java/forge/quest/gui/QuestMainPanel.java
@@ -1,804 +1,811 @@
-package forge.quest.gui.main;
-
-
-import forge.*;
-import forge.deck.Deck;
-import forge.gui.GuiUtils;
-import forge.gui.deckeditor.DeckEditorShop;
-import forge.gui.deckeditor.DeckEditorQuest;
-import forge.quest.data.QuestBattleManager;
-import forge.quest.data.QuestData;
-import forge.quest.data.item.QuestItemZeppelin;
-import forge.quest.gui.QuestAbstractPanel;
-import forge.quest.gui.QuestFrame;
-
-import javax.swing.*;
-import javax.swing.border.EmptyBorder;
-import javax.swing.border.EtchedBorder;
-import javax.swing.border.TitledBorder;
-import java.awt.*;
-import java.awt.event.ActionEvent;
-import java.awt.event.ActionListener;
-import java.awt.event.MouseAdapter;
-import java.awt.event.MouseEvent;
-import java.util.*;
-import java.util.List;
-
-
-/**
- * QuestMainPanel class.
- * - * @author Forge - * @version $Id$ - */ -public class QuestMainPanel extends QuestAbstractPanel { - /** ConstantserialVersionUID=6142934729724012402L */
- private static final long serialVersionUID = 6142934729724012402L;
-
- private forge.quest.data.QuestData questData;
-
- JLabel creditsLabel = new JLabel();
- JLabel lifeLabel = new JLabel();
- JLabel statsLabel = new JLabel();
- JLabel titleLabel = new JLabel();
- JLabel nextQuestLabel = new JLabel();
-
- JComboBox petComboBox = new JComboBox();
- JComboBox deckComboBox = new JComboBox();
-
- JButton questButton = new JButton("Quests");
- JButton playButton = new JButton("Play");
-
- private QuestSelectablePanel selectedOpponent;
-
- JPanel nextMatchPanel = new JPanel();
- CardLayout nextMatchLayout;
-
- boolean isShowingQuests = false;
- private 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 JCheckBox plantBox = new JCheckBox("Summon Plant");
- /** Constant NO_DECKS_AVAILABLE="No decks available" */
- private static final String NO_DECKS_AVAILABLE = "No decks available";
- /** Constant BATTLES="Battles" */
- private static final String BATTLES = "Battles";
- /** Constant QUESTS="Quests" */
- private static final String QUESTS = "Quests";
-
- //TODO: Make this ordering permanent
- /** Constant lastUsedDeck="//TODO: Make this ordering permanent" */
- private static String lastUsedDeck;
- private JButton zeppelinButton = new JButton("LaunchConstructor for QuestMainPanel.
- * - * @param mainFrame a {@link forge.quest.gui.QuestFrame} object. - */ - public QuestMainPanel(QuestFrame mainFrame) { - super(mainFrame); - questData = AllZone.getQuestData(); - - initUI(); - } - - /** - *initUI.
- */ - private void initUI() { - refresh(); - this.setLayout(new BorderLayout(5, 5)); - JPanel centerPanel = new JPanel(new BorderLayout()); - this.add(centerPanel, BorderLayout.CENTER); - - JPanel northPanel = createStatusPanel(); - this.add(northPanel, BorderLayout.NORTH); - - JPanel eastPanel = createSidePanel(); - this.add(eastPanel, BorderLayout.EAST); - - JPanel matchSettingsPanel = createMatchSettingsPanel(); - centerPanel.add(matchSettingsPanel, BorderLayout.SOUTH); - - centerPanel.add(nextMatchPanel, BorderLayout.CENTER); - this.setBorder(new EmptyBorder(5, 5, 5, 5)); - - } - - /** - *createStatusPanel.
- * - * @return a {@link javax.swing.JPanel} object. - */ - private JPanel createStatusPanel() { - 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); - northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.Y_AXIS)); - northPanel.add(titleLabel); - - northPanel.add(Box.createVerticalStrut(5)); - - JPanel statusPanel = new JPanel(); - statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS)); - statusPanel.setAlignmentX(LEFT_ALIGNMENT); - - modeLabel = new JLabel(questData.getMode()); - statusPanel.add(modeLabel); - statusPanel.add(Box.createHorizontalGlue()); - - difficultyLabel = new JLabel(questData.getDifficulty()); - statusPanel.add(difficultyLabel); - statusPanel.add(Box.createHorizontalGlue()); - - statusPanel.add(statsLabel); - - northPanel.add(statusPanel); - return northPanel; - } - - /** - *createSidePanel.
- * - * @return a {@link javax.swing.JPanel} object. - */ - private JPanel createSidePanel() { - JPanel panel = new JPanel(); - JPanel optionsPanel; //Create options checkbox list - optionsPanel = createOptionsPanel(); - - ListcreateOptionsPanel.
- * - * @return a {@link javax.swing.JPanel} object. - */ - private JPanel createOptionsPanel() { - JPanel optionsPanel; - optionsPanel = new JPanel(); - optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.Y_AXIS)); - - //optionsPanel.add(this.newGUICheckbox); - optionsPanel.add(Box.createVerticalStrut(5)); - optionsPanel.add(this.smoothLandCheckBox); - optionsPanel.add(Box.createVerticalStrut(5)); - optionsPanel.add(this.devModeCheckBox); - optionsPanel.setBorder(new TitledBorder(new EtchedBorder(), "Options")); - return optionsPanel; - } - - /** - *createMatchSettingsPanel.
- * - * @return a {@link javax.swing.JPanel} object. - */ - private JPanel createMatchSettingsPanel() { - - JPanel matchPanel = new JPanel(); - matchPanel.setLayout(new BoxLayout(matchPanel, BoxLayout.Y_AXIS)); - - JPanel deckPanel = new JPanel(); - deckPanel.setLayout(new BoxLayout(deckPanel, BoxLayout.X_AXIS)); - - JLabel deckLabel = new JLabel("Use Deck"); - deckPanel.add(deckLabel); - GuiUtils.addGap(deckPanel); - - this.deckComboBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent actionEvent) { - playButton.setEnabled(canGameBeLaunched()); - lastUsedDeck = (String) deckComboBox.getSelectedItem(); - } - }); - - deckPanel.add(this.deckComboBox); - GuiUtils.addGap(deckPanel); - - JButton editDeckButton = new JButton("Deck Editor"); - editDeckButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent actionEvent) { - showDeckEditor(); - } - }); - deckPanel.add(editDeckButton); - deckPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, deckPanel.getPreferredSize().height)); - deckPanel.setAlignmentX(LEFT_ALIGNMENT); - matchPanel.add(deckPanel); - - - GuiUtils.addGap(matchPanel); - - if (questData.getMode().equals(forge.quest.data.QuestData.FANTASY)) { - JPanel fantasyPanel = new JPanel(); - fantasyPanel.setLayout(new BorderLayout()); - - JPanel petPanel = new JPanel(); - petPanel.setLayout(new BoxLayout(petPanel, BoxLayout.X_AXIS)); - - this.petCheckBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent actionEvent) { - if (petCheckBox.isSelected()) { - questData.getPetManager().setSelectedPet((String) petComboBox.getSelectedItem()); - } else { - questData.getPetManager().setSelectedPet(null); - } - - petComboBox.setEnabled(petCheckBox.isSelected()); - } - }); - - petPanel.add(this.petCheckBox); - GuiUtils.addGap(petPanel); - this.petComboBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent actionEvent) { - if (petCheckBox.isSelected()) { - questData.getPetManager().setSelectedPet((String) petComboBox.getSelectedItem()); - } else { - questData.getPetManager().setSelectedPet(null); - } - } - }); - this.petComboBox.setMaximumSize( - new Dimension(Integer.MAX_VALUE, - (int) this.petCheckBox.getPreferredSize().getHeight())); - petPanel.add(this.petComboBox); - - this.plantBox.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent actionEvent) { - questData.getPetManager().usePlant = plantBox.isSelected(); - } - }); - - GuiUtils.addGap(petPanel, 10); - petPanel.add(this.plantBox); - petPanel.setMaximumSize(petPanel.getPreferredSize()); - petPanel.setAlignmentX(LEFT_ALIGNMENT); - - fantasyPanel.add(petPanel, BorderLayout.WEST); - - zeppelinButton.addActionListener(new ActionListener() { - public void actionPerformed(ActionEvent actionEvent) { - questData.randomizeOpponents(); - refreshNextMatchPanel(); - QuestItemZeppelin zeppelin = (QuestItemZeppelin) questData.getInventory().getItem("Zeppelin"); - zeppelin.setZeppelinUsed(true); - zeppelinButton.setEnabled(false); - } - }); - - zeppelinButton.setMaximumSize(zeppelinButton.getPreferredSize()); - zeppelinPanel.setLayout(new BorderLayout()); - - fantasyPanel.add(zeppelinPanel, BorderLayout.EAST); - fantasyPanel.setAlignmentX(Component.LEFT_ALIGNMENT); - matchPanel.add(fantasyPanel); - } - return matchPanel; - } - - /** - *createBattlePanel.
- * - * @return a {@link javax.swing.JPanel} object. - */ - private JPanel createBattlePanel() { - JPanel BattlePanel = new JPanel(); - BattlePanel.setLayout(new BoxLayout(BattlePanel, BoxLayout.Y_AXIS)); - BattlePanel.setBorder(new TitledBorder(new EtchedBorder(), "Available Battles")); - - ListcreateQuestPanel.
- * - * @return a {@link javax.swing.JPanel} object. - */ - private JPanel createQuestPanel() { - JPanel questPanel = new JPanel(); - questPanel.setLayout(new BoxLayout(questPanel, BoxLayout.Y_AXIS)); - questPanel.setBorder(new TitledBorder(new EtchedBorder(), "Available Quests")); - - - Listrefresh.
- */ - void refresh() { - AllZone.getQuestData().saveData(); - - devModeCheckBox.setSelected(Constant.Runtime.DevMode[0]); - smoothLandCheckBox.setSelected(Constant.Runtime.Smooth[0]); - //newGUICheckbox.setSelected(OldGuiNewGame.preferences.newGui); - - creditsLabel.setText(" " + questData.getCredits()); - statsLabel.setText(questData.getWin() + " wins / " + questData.getLost() + " losses"); - titleLabel.setText(questData.getRank()); - - //copy lastUsedDeck as removal triggers selection change. - String lastUsedDeck = QuestMainPanel.lastUsedDeck; - deckComboBox.removeAllItems(); - - if (questData.getDeckNames().size() > 0) { - deckComboBox.setEnabled(true); - - ListrefreshNextMatchPanel.
- */ - private void refreshNextMatchPanel() { - nextMatchPanel.removeAll(); - nextMatchLayout = new CardLayout(); - nextMatchPanel.setLayout(nextMatchLayout); - nextMatchPanel.add(createBattlePanel(), BATTLES); - nextMatchPanel.add(createQuestPanel(), QUESTS); - if (isShowingQuests) { - this.nextMatchLayout.show(nextMatchPanel, QUESTS); - } else { - this.nextMatchLayout.show(nextMatchPanel, BATTLES); - } - } - - /** - *nextQuestInWins.
- * - * @return a int. - */ - private int nextQuestInWins() { - - // Number of wins was 25, lowereing the number to 20 to help short term questers. - if (questData.getWin() < 20) { - return 20 - questData.getWin(); - } - - // The int mul has been lowered by one, should face special opps more frequently. - int questsPlayed = questData.getQuestsPlayed(); - int mul = 5; - - if (questData.getInventory().hasItem("Zeppelin")) { - mul = 3; - } else if (questData.getInventory().hasItem("Map")) { - mul = 4; - } - - int delta = (questsPlayed * mul) - questData.getWin(); - - return (delta > 0) ? delta : 0; - } - - - /** - *showDeckEditor.
- */ - void showDeckEditor() { - Command exit = new Command() { - private static final long serialVersionUID = -5110231879431074581L; - - public void execute() { - //saves all deck data - AllZone.getQuestData().saveData(); - - new QuestFrame(); - } - }; - - DeckEditorQuest g = new DeckEditorQuest(AllZone.getQuestData()); - - g.show(exit); - g.setVisible(true); - mainFrame.dispose(); - }//deck editor button - - /** - *showBazaar.
- */ - void showBazaar() { - mainFrame.showBazaarPane(); - } - - /** - *showCardShop.
- */ - void showCardShop() { - Command exit = new Command() { - private static final long serialVersionUID = 8567193482568076362L; - - public void execute() { - //saves all deck data - AllZone.getQuestData().saveData(); - - new QuestFrame(); - } - }; - - DeckEditorShop g = new DeckEditorShop(questData); - - g.show(exit); - g.setVisible(true); - - this.mainFrame.dispose(); - - }//card shop button - - /** - *launchGame.
- */ - private void launchGame() { - - //TODO: This is a temporary hack to see if the image cache affects the heap usage significantly. - ImageCache.clear(); - - QuestItemZeppelin zeppelin = (QuestItemZeppelin) questData.getInventory().getItem("Zeppelin"); - zeppelin.setZeppelinUsed(false); - questData.randomizeOpponents(); - - String humanDeckName = (String) deckComboBox.getSelectedItem(); - Deck humanDeck = questData.getDeck(humanDeckName); - Constant.Runtime.HumanDeck[0] = humanDeck; - moveDeckToTop(humanDeckName); - - Constant.Quest.oppIconName[0] = getMatchIcon(); - - // Dev Mode occurs before Display - Constant.Runtime.DevMode[0] = devModeCheckBox.isSelected(); - - //DO NOT CHANGE THIS ORDER, GuiDisplay needs to be created before cards are added - //if (newGUICheckbox.isSelected()) { - AllZone.setDisplay(new GuiDisplay4()); - //} else { - // AllZone.setDisplay(new GuiDisplay3()); - //} - - //OldGuiNewGame.preferences.newGui = newGUICheckbox.isSelected(); - - Constant.Runtime.Smooth[0] = smoothLandCheckBox.isSelected(); - - AllZone.getMatchState().reset(); - if (isShowingQuests) { - setupQuest(humanDeck); - } else { - setupBattle(humanDeck); - } - - AllZone.getQuestData().saveData(); - - AllZone.getDisplay().setVisible(true); - mainFrame.dispose(); - } - - - /** - *setupBattle.
- * - * @param humanDeck a {@link forge.deck.Deck} object. - */ - void setupBattle(Deck humanDeck) { - - Deck computer = QuestBattleManager.getAIDeckFromFile((selectedOpponent).getName()); - Constant.Runtime.ComputerDeck[0] = computer; - - AllZone.getGameAction().newGame(humanDeck, computer, forge.quest.data.QuestUtil.getHumanStartingCards(questData), - new CardList(), questData.getLife(), 20, null); - } - - /** - *setupQuest.
- * - * @param humanDeck a {@link forge.deck.Deck} object. - */ - private void setupQuest(Deck humanDeck) { - Quest_Assignment selectedQuest = ((QuestQuest) selectedOpponent).getQuestAssignment(); - - Deck computerDeck = QuestBattleManager.getAIDeckFromFile("quest" + selectedQuest.getId()); - Constant.Runtime.ComputerDeck[0] = computerDeck; - - AllZone.setQuestAssignment(selectedQuest); - - int extraLife = 0; - - if (questData.getInventory().getItemLevel("Gear") == 2) { - extraLife = 3; - } - - AllZone.getGameAction().newGame(humanDeck, computerDeck, - forge.quest.data.QuestUtil.getHumanStartingCards(questData, selectedQuest), new CardList(), - questData.getLife() + extraLife, selectedQuest.getComputerLife(), selectedQuest); - - } - - /** - *getMatchIcon.
- * - * @return a {@link java.lang.String} object. - */ - String getMatchIcon() { - String oppIconName; - - if (isShowingQuests) { - Quest_Assignment selectedQuest = ((QuestQuest) selectedOpponent).getQuestAssignment(); - oppIconName = selectedQuest.getIconName(); - } else { - oppIconName = selectedOpponent.getName(); - oppIconName = oppIconName.substring(0, oppIconName.length() - 1).trim() + ".jpg"; - } - return oppIconName; - } - - /** - *showQuests.
- */ - void showQuests() { - if (isShowingQuests) { - isShowingQuests = false; - questButton.setText("Quests"); - } else { - isShowingQuests = true; - questButton.setText("Battles"); - } - - if (selectedOpponent != null) { - selectedOpponent.setSelected(false); - } - - selectedOpponent = null; - - refresh(); - } - - class SelectionAdapter extends MouseAdapter { - QuestSelectablePanel selectablePanel; - - SelectionAdapter(QuestSelectablePanel selectablePanel) { - super(); - this.selectablePanel = selectablePanel; - } - - @Override - public void mouseClicked(MouseEvent mouseEvent) { - - if (selectedOpponent != null) { - selectedOpponent.setSelected(false); - } - - selectablePanel.setSelected(true); - - selectedOpponent = selectablePanel; - playButton.setEnabled(canGameBeLaunched()); - } - - } - - /** - *moveDeckToTop.
- * - * @param humanDeckName a {@link java.lang.String} object. - */ - private void moveDeckToTop(String humanDeckName) { - QuestMainPanel.lastUsedDeck = humanDeckName; - } - - - /** - *canGameBeLaunched.
- * - * @return a boolean. - */ - boolean canGameBeLaunched() { - return !(NO_DECKS_AVAILABLE.equals(deckComboBox.getSelectedItem()) || selectedOpponent == null); - } - - /** {@inheritDoc} */ - @Override - public void refreshState() { - this.refresh(); - } - -} +package forge.quest.gui; + + +import forge.*; +import forge.deck.Deck; +import forge.gui.GuiUtils; +import forge.gui.deckeditor.DeckEditorShop; +import forge.gui.deckeditor.DeckEditorQuest; +import forge.quest.data.QuestData; +import forge.quest.data.item.QuestItemZeppelin; +import forge.quest.gui.main.QuestDuel; +import forge.quest.gui.main.QuestDuelPanel; +import forge.quest.gui.main.QuestQuest; +import forge.quest.gui.main.QuestQuestPanel; +import forge.quest.gui.main.QuestSelectablePanel; + +import javax.swing.*; +import javax.swing.border.EmptyBorder; +import javax.swing.border.EtchedBorder; +import javax.swing.border.TitledBorder; +import java.awt.*; +import java.awt.event.ActionEvent; +import java.awt.event.ActionListener; +import java.awt.event.MouseAdapter; +import java.awt.event.MouseEvent; +import java.util.*; +import java.util.List; + + +/** + *QuestMainPanel class.
+ * VIEW - lays out swing components for duel and quest events. + * + * @author Forge + * @version $Id: QuestMainPanel.java 10358 2011-09-11 05:20:13Z Doublestrike $ + */ +public class QuestMainPanel extends QuestAbstractPanel { + /** ConstantserialVersionUID=6142934729724012402L */
+ private static final long serialVersionUID = 6142934729724012402L;
+
+ private forge.quest.data.QuestData questData;
+
+ JLabel creditsLabel = new JLabel();
+ JLabel lifeLabel = new JLabel();
+ JLabel statsLabel = new JLabel();
+ JLabel titleLabel = new JLabel();
+ JLabel nextQuestLabel = new JLabel();
+
+ JComboBox petComboBox = new JComboBox();
+ JComboBox deckComboBox = new JComboBox();
+
+ JButton questButton = new JButton("Quests");
+ JButton playButton = new JButton("Play");
+
+ private QuestSelectablePanel selectedOpponent;
+
+ JPanel nextMatchPanel = new JPanel();
+ CardLayout nextMatchLayout;
+
+ boolean isShowingQuests = false;
+ private 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 JCheckBox plantBox = new JCheckBox("Summon Plant");
+ /** Constant NO_DECKS_AVAILABLE="No decks available" */
+ private static final String NO_DECKS_AVAILABLE = "No decks available";
+ /** Constant BATTLES="Battles" */
+ private static final String BATTLES = "Battles";
+ /** Constant QUESTS="Quests" */
+ private static final String QUESTS = "Quests";
+
+ //TODO: Make this ordering permanent
+ /** Constant lastUsedDeck="//TODO: Make this ordering permanent" */
+ private static String lastUsedDeck;
+ private JButton zeppelinButton = new JButton("LaunchConstructor for QuestMainPanel.
+ * + * @param mainFrame a {@link forge.quest.gui.QuestFrame} object. + */ + public QuestMainPanel(QuestFrame mainFrame) { + super(mainFrame); + questData = AllZone.getQuestData(); + + TEST = mainFrame; + + initUI(); + } + + /** + *initUI.
+ */ + private void initUI() { + refresh(); + this.setLayout(new BorderLayout(5, 5)); + JPanel centerPanel = new JPanel(new BorderLayout()); + this.add(centerPanel, BorderLayout.CENTER); + + JPanel northPanel = createStatusPanel(); + this.add(northPanel, BorderLayout.NORTH); + + JPanel eastPanel = createSidePanel(); + this.add(eastPanel, BorderLayout.EAST); + + JPanel matchSettingsPanel = createMatchSettingsPanel(); + centerPanel.add(matchSettingsPanel, BorderLayout.SOUTH); + + centerPanel.add(nextMatchPanel, BorderLayout.CENTER); + this.setBorder(new EmptyBorder(5, 5, 5, 5)); + + } + + /** + *createStatusPanel.
+ * + * @return a {@link javax.swing.JPanel} object. + */ + private JPanel createStatusPanel() { + 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); + northPanel.setLayout(new BoxLayout(northPanel, BoxLayout.Y_AXIS)); + northPanel.add(titleLabel); + + northPanel.add(Box.createVerticalStrut(5)); + + JPanel statusPanel = new JPanel(); + statusPanel.setLayout(new BoxLayout(statusPanel, BoxLayout.X_AXIS)); + statusPanel.setAlignmentX(LEFT_ALIGNMENT); + + modeLabel = new JLabel(questData.getMode()); + statusPanel.add(modeLabel); + statusPanel.add(Box.createHorizontalGlue()); + + difficultyLabel = new JLabel(questData.getDifficulty()); + statusPanel.add(difficultyLabel); + statusPanel.add(Box.createHorizontalGlue()); + + statusPanel.add(statsLabel); + + northPanel.add(statusPanel); + return northPanel; + } + + /** + *createSidePanel.
+ * + * @return a {@link javax.swing.JPanel} object. + */ + private JPanel createSidePanel() { + JPanel panel = new JPanel(); + JPanel optionsPanel; //Create options checkbox list + optionsPanel = createOptionsPanel(); + + ListcreateOptionsPanel.
+ * + * @return a {@link javax.swing.JPanel} object. + */ + private JPanel createOptionsPanel() { + JPanel optionsPanel; + optionsPanel = new JPanel(); + optionsPanel.setLayout(new BoxLayout(optionsPanel, BoxLayout.Y_AXIS)); + + //optionsPanel.add(this.newGUICheckbox); + optionsPanel.add(Box.createVerticalStrut(5)); + optionsPanel.add(this.smoothLandCheckBox); + optionsPanel.add(Box.createVerticalStrut(5)); + optionsPanel.add(this.devModeCheckBox); + optionsPanel.setBorder(new TitledBorder(new EtchedBorder(), "Options")); + return optionsPanel; + } + + /** + *createMatchSettingsPanel.
+ * + * @return a {@link javax.swing.JPanel} object. + */ + private JPanel createMatchSettingsPanel() { + + JPanel matchPanel = new JPanel(); + matchPanel.setLayout(new BoxLayout(matchPanel, BoxLayout.Y_AXIS)); + + JPanel deckPanel = new JPanel(); + deckPanel.setLayout(new BoxLayout(deckPanel, BoxLayout.X_AXIS)); + + JLabel deckLabel = new JLabel("Use Deck"); + deckPanel.add(deckLabel); + GuiUtils.addGap(deckPanel); + + this.deckComboBox.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionEvent) { + playButton.setEnabled(canGameBeLaunched()); + lastUsedDeck = (String) deckComboBox.getSelectedItem(); + } + }); + + deckPanel.add(this.deckComboBox); + GuiUtils.addGap(deckPanel); + + JButton editDeckButton = new JButton("Deck Editor"); + editDeckButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionEvent) { + showDeckEditor(); + } + }); + deckPanel.add(editDeckButton); + deckPanel.setMaximumSize(new Dimension(Integer.MAX_VALUE, deckPanel.getPreferredSize().height)); + deckPanel.setAlignmentX(LEFT_ALIGNMENT); + matchPanel.add(deckPanel); + + + GuiUtils.addGap(matchPanel); + + if (questData.getMode().equals(forge.quest.data.QuestData.FANTASY)) { + JPanel fantasyPanel = new JPanel(); + fantasyPanel.setLayout(new BorderLayout()); + + JPanel petPanel = new JPanel(); + petPanel.setLayout(new BoxLayout(petPanel, BoxLayout.X_AXIS)); + + this.petCheckBox.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionEvent) { + if (petCheckBox.isSelected()) { + questData.getPetManager().setSelectedPet((String) petComboBox.getSelectedItem()); + } else { + questData.getPetManager().setSelectedPet(null); + } + + petComboBox.setEnabled(petCheckBox.isSelected()); + } + }); + + petPanel.add(this.petCheckBox); + GuiUtils.addGap(petPanel); + this.petComboBox.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionEvent) { + if (petCheckBox.isSelected()) { + questData.getPetManager().setSelectedPet((String) petComboBox.getSelectedItem()); + } else { + questData.getPetManager().setSelectedPet(null); + } + } + }); + this.petComboBox.setMaximumSize( + new Dimension(Integer.MAX_VALUE, + (int) this.petCheckBox.getPreferredSize().getHeight())); + petPanel.add(this.petComboBox); + + this.plantBox.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionEvent) { + questData.getPetManager().usePlant = plantBox.isSelected(); + } + }); + + GuiUtils.addGap(petPanel, 10); + petPanel.add(this.plantBox); + petPanel.setMaximumSize(petPanel.getPreferredSize()); + petPanel.setAlignmentX(LEFT_ALIGNMENT); + + fantasyPanel.add(petPanel, BorderLayout.WEST); + + zeppelinButton.addActionListener(new ActionListener() { + public void actionPerformed(ActionEvent actionEvent) { + questData.randomizeOpponents(); + refreshNextMatchPanel(); + QuestItemZeppelin zeppelin = (QuestItemZeppelin) questData.getInventory().getItem("Zeppelin"); + zeppelin.setZeppelinUsed(true); + zeppelinButton.setEnabled(false); + } + }); + + zeppelinButton.setMaximumSize(zeppelinButton.getPreferredSize()); + zeppelinPanel.setLayout(new BorderLayout()); + + fantasyPanel.add(zeppelinPanel, BorderLayout.EAST); + fantasyPanel.setAlignmentX(Component.LEFT_ALIGNMENT); + matchPanel.add(fantasyPanel); + } + return matchPanel; + } + + /** + *createDuelPanel.
+ * Makes a parent panel, then selectable panel instances for all available duels. + * + * @return a {@link javax.swing.JPanel} object. + */ + private JPanel createDuelPanel() { + JPanel DuelPanel = new JPanel(); + QuestDuelPanel duelEvent; + DuelPanel.setLayout(new BoxLayout(DuelPanel, BoxLayout.Y_AXIS)); + DuelPanel.setBorder(new TitledBorder(new EtchedBorder(), "Available Battles")); + + ListcreateQuestPanel.
+ * Makes a parent panel, then selectable panel instances for all available battles. + * + * @return a {@link javax.swing.JPanel} object. + */ + private JPanel createQuestPanel() { + JPanel QuestPanel = new JPanel(); + + QuestSelectablePanel selpan; + QuestPanel.setLayout(new BoxLayout(QuestPanel, BoxLayout.Y_AXIS)); + QuestPanel.setBorder(new TitledBorder(new EtchedBorder(), "Available Quests")); + + Listrefresh.
+ */ + void refresh() { + AllZone.getQuestData().saveData(); + + devModeCheckBox.setSelected(Constant.Runtime.DevMode[0]); + smoothLandCheckBox.setSelected(Constant.Runtime.Smooth[0]); + //newGUICheckbox.setSelected(OldGuiNewGame.preferences.newGui); + + creditsLabel.setText(" " + questData.getCredits()); + statsLabel.setText(questData.getWin() + " wins / " + questData.getLost() + " losses"); + titleLabel.setText(questData.getRank()); + + //copy lastUsedDeck as removal triggers selection change. + String lastUsedDeck = QuestMainPanel.lastUsedDeck; + deckComboBox.removeAllItems(); + + if (questData.getDeckNames().size() > 0) { + deckComboBox.setEnabled(true); + + ListrefreshNextMatchPanel.
+ */ + private void refreshNextMatchPanel() { + nextMatchPanel.removeAll(); + nextMatchLayout = new CardLayout(); + nextMatchPanel.setLayout(nextMatchLayout); + nextMatchPanel.add(createDuelPanel(), BATTLES); + nextMatchPanel.add(createQuestPanel(), QUESTS); + if (isShowingQuests) { + this.nextMatchLayout.show(nextMatchPanel, QUESTS); + } else { + this.nextMatchLayout.show(nextMatchPanel, BATTLES); + } + } + + /** + *nextQuestInWins.
+ * + * @return a int. + */ + private int nextQuestInWins() { + + // Number of wins was 25, lowereing the number to 20 to help short term questers. + if (questData.getWin() < 20) { + return 20 - questData.getWin(); + } + + // The int mul has been lowered by one, should face special opps more frequently. + int questsPlayed = questData.getQuestsPlayed(); + int mul = 5; + + if (questData.getInventory().hasItem("Zeppelin")) { + mul = 3; + } else if (questData.getInventory().hasItem("Map")) { + mul = 4; + } + + int delta = (questsPlayed * mul) - questData.getWin(); + + return (delta > 0) ? delta : 0; + } + + + /** + *showDeckEditor.
+ */ + void showDeckEditor() { + Command exit = new Command() { + private static final long serialVersionUID = -5110231879431074581L; + + public void execute() { + //saves all deck data + AllZone.getQuestData().saveData(); + + new QuestFrame(); + } + }; + + DeckEditorQuest g = new DeckEditorQuest(AllZone.getQuestData()); + + g.show(exit); + g.setVisible(true); + mainFrame.dispose(); + }//deck editor button + + /** + *showBazaar.
+ */ + void showBazaar() { + mainFrame.showBazaarPane(); + } + + /** + *showCardShop.
+ */ + void showCardShop() { + Command exit = new Command() { + private static final long serialVersionUID = 8567193482568076362L; + + public void execute() { + //saves all deck data + AllZone.getQuestData().saveData(); + + new QuestFrame(); + } + }; + + DeckEditorShop g = new DeckEditorShop(questData); + + g.show(exit); + g.setVisible(true); + + this.mainFrame.dispose(); + + }//card shop button + + /** + *launchGame.
+ */ + private void launchGame() { + //TODO: This is a temporary hack to see if the image cache affects the heap usage significantly. + ImageCache.clear(); + + QuestItemZeppelin zeppelin = (QuestItemZeppelin) questData.getInventory().getItem("Zeppelin"); + zeppelin.setZeppelinUsed(false); + questData.randomizeOpponents(); + + String humanDeckName = (String) deckComboBox.getSelectedItem(); + + Deck humanDeck = questData.getDeck(humanDeckName); + + Constant.Runtime.HumanDeck[0] = humanDeck; + moveDeckToTop(humanDeckName); + + Constant.Quest.oppIconName[0] = getEventIconFilename(); + + // Dev Mode occurs before Display + Constant.Runtime.DevMode[0] = devModeCheckBox.isSelected(); + + //DO NOT CHANGE THIS ORDER, GuiDisplay needs to be created before cards are added + //if (newGUICheckbox.isSelected()) { + AllZone.setDisplay(new GuiDisplay4()); + //} else { + // AllZone.setDisplay(new GuiDisplay3()); + //} + + //OldGuiNewGame.preferences.newGui = newGUICheckbox.isSelected(); + + Constant.Runtime.Smooth[0] = smoothLandCheckBox.isSelected(); + + AllZone.getMatchState().reset(); + if (isShowingQuests) { + setupQuest(humanDeck); + } else { + setupDuel(humanDeck); + } + + AllZone.getQuestData().saveData(); + + AllZone.getDisplay().setVisible(true); + mainFrame.dispose(); + } + + + /** + *setupDuel.
+ * + * @param humanDeck a {@link forge.deck.Deck} object. + */ + void setupDuel(Deck humanDeck) { + Deck computer = selectedOpponent.getEvent().getEventDeck(); + Constant.Runtime.ComputerDeck[0] = computer; + + AllZone.getGameAction().newGame(humanDeck, computer, forge.quest.data.QuestUtil.getHumanStartingCards(questData), + new CardList(), questData.getLife(), 20, null); + } + + /** + *setupQuest.
+ * + * @param humanDeck a {@link forge.deck.Deck} object. + */ + private void setupQuest(Deck humanDeck) { + QuestQuest selectedQuest = (QuestQuest)selectedOpponent.getEvent(); + + Deck computer = selectedOpponent.getEvent().getEventDeck(); + Constant.Runtime.ComputerDeck[0] = computer; + + AllZone.setQuestQuest(selectedQuest); + + int extraLife = 0; + + if (questData.getInventory().getItemLevel("Gear") == 2) { + extraLife = 3; + } + + AllZone.getGameAction().newGame(humanDeck, computer, + forge.quest.data.QuestUtil.getHumanStartingCards(questData, selectedQuest), new CardList(), + questData.getLife() + extraLife, selectedQuest.getAILife(), selectedQuest); + + } + + /** + *getEventIconFilename.
+ * + * @return a {@link java.lang.String} object. + */ + private String getEventIconFilename() { + return selectedOpponent.getIconFilename(); + } + + /** + *showQuests.
+ */ + void showQuests() { + if (isShowingQuests) { + isShowingQuests = false; + questButton.setText("Quests"); + } else { + isShowingQuests = true; + questButton.setText("Battles"); + } + + if (selectedOpponent != null) { + selectedOpponent.setSelected(false); + } + + selectedOpponent = null; + + refresh(); + } + + class SelectionAdapter extends MouseAdapter { + QuestSelectablePanel selectablePanel; + + SelectionAdapter(QuestSelectablePanel selectablePanel) { + super(); + this.selectablePanel = selectablePanel; + } + + @Override + public void mouseClicked(MouseEvent mouseEvent) { + + if (selectedOpponent != null) { + selectedOpponent.setSelected(false); + } + + selectablePanel.setSelected(true); + + selectedOpponent = selectablePanel; + playButton.setEnabled(canGameBeLaunched()); + } + + } + + /** + *moveDeckToTop.
+ * + * @param humanDeckName a {@link java.lang.String} object. + */ + private void moveDeckToTop(String humanDeckName) { + QuestMainPanel.lastUsedDeck = humanDeckName; + } + + + /** + *canGameBeLaunched.
+ * + * @return a boolean. + */ + boolean canGameBeLaunched() { + return !(NO_DECKS_AVAILABLE.equals(deckComboBox.getSelectedItem()) || selectedOpponent == null); + } + + /** {@inheritDoc} */ + @Override + public void refreshState() { + this.refresh(); + } + +} diff --git a/src/main/java/forge/quest/gui/main/QuestBattle.java b/src/main/java/forge/quest/gui/main/QuestBattle.java deleted file mode 100644 index 2ca8e212e10..00000000000 --- a/src/main/java/forge/quest/gui/main/QuestBattle.java +++ /dev/null @@ -1,90 +0,0 @@ -package forge.quest.gui.main; - - -import forge.gui.GuiUtils; -import forge.quest.data.QuestBattleManager; -import forge.quest.data.QuestEvent; - -import javax.swing.*; - -import org.apache.commons.lang3.StringUtils; - -import java.util.ArrayList; -import java.util.List; - -/** - *QuestBattle class.
- * Manages QuestSelectablePanel instances for "battle" style matches. - * - * @author Forge - * @version $Id$ - */ -public class QuestBattle extends QuestSelectablePanel { - /** ConstantserialVersionUID=3112668476017792084L */
- private static final long serialVersionUID = 3112668476017792084L;
-
- private String deckName;
-
-
-
- /**
- * Constructor for QuestBattle.
- * - * @param name a {@link java.lang.String}, stores display name of opponent. - * @param diff a {@link java.lang.String} stores difficulty of opponent. - * @param description a {@link java.lang.String} stores description of opponent's deck. - * @param icon a {@link javax.swing.ImageIcon} stores opponent's icon. - */ - private QuestBattle(String name, String deck, String diff, String desc, ImageIcon icon) { - super(name, diff, desc, icon); - this.deckName = deck; - } - - /** - *getBattles.
- * - * Returns list of QuestBattle objects storing data - * of the battles currently available. - * - * @return a {@link java.util.List} object. - */ - - // There's got to be a better place for this method. - public static ListQuestDuel class.
+ * MODEL - A single duel event data instance, including meta and deck. + * + */ +public class QuestDuel extends QuestEvent { + + // [QuestDuel has no unique properties yet.] + +} diff --git a/src/main/java/forge/quest/gui/main/QuestDuelPanel.java b/src/main/java/forge/quest/gui/main/QuestDuelPanel.java new file mode 100644 index 00000000000..ca20ef0bcb7 --- /dev/null +++ b/src/main/java/forge/quest/gui/main/QuestDuelPanel.java @@ -0,0 +1,20 @@ +package forge.quest.gui.main; + + +/** + *QuestDuelPanel.
+ * VIEW - Creates a QuestSelectablePanel instance for a "battle" style event. + */ +@SuppressWarnings("serial") +public class QuestDuelPanel extends QuestSelectablePanel { + + /**QuestDuelPanel.
+ * Constructor, using duel data instance. + * + * @param {@link forge.quest.gui.main.QuestDuel} + */ + public QuestDuelPanel(QuestDuel d) { + super(d); + } + +} diff --git a/src/main/java/forge/quest/gui/main/QuestEvent.java b/src/main/java/forge/quest/gui/main/QuestEvent.java new file mode 100644 index 00000000000..adeb6f5bba5 --- /dev/null +++ b/src/main/java/forge/quest/gui/main/QuestEvent.java @@ -0,0 +1,73 @@ +package forge.quest.gui.main; + +import forge.deck.Deck; + +/** + *QuestEvent.
+ * + * MODEL - A basic event instance in Quest mode. Can be extended for use in + * unique event types: battles, quests, and others. + */ +public class QuestEvent { + // Default vals if none provided in the event file. + public Deck eventDeck = null; + public String title = "Mystery Event"; + public String description = ""; + public String difficulty = "Medium"; + public String icon = "Unknown.jpg"; + public String name = "Noname"; + + /** + *getTitle.
+ * + * @return a {@link java.lang.String}. + */ + public final String getTitle() { + return title; + } + + /** + *getDifficulty.
+ * + * @return a {@link java.lang.String}. + */ + public final String getDifficulty() { + return difficulty; + } + + /** + *getDescription.
+ * + * @return a {@link java.lang.String}. + */ + public final String getDescription() { + return description; + } + + /** + *getEventDeck.
+ * + * @return {@link forge.deck.Deck} + */ + public final Deck getEventDeck() { + return eventDeck; + } + + /** + *getIcon.
+ * + * @return a {@link java.lang.String}. + */ + public final String getIcon() { + return icon; + } + + /** + *getName.
+ * + * @return a {@link java.lang.String}. + */ + public final String getName() { + return name; + } +} diff --git a/src/main/java/forge/quest/gui/main/QuestEventManager.java b/src/main/java/forge/quest/gui/main/QuestEventManager.java new file mode 100644 index 00000000000..e335cd15082 --- /dev/null +++ b/src/main/java/forge/quest/gui/main/QuestEventManager.java @@ -0,0 +1,406 @@ +package forge.quest.gui.main; + +import forge.AllZone; +import forge.Card; +import forge.CardList; +import forge.CardUtil; +import forge.FileUtil; +import forge.deck.DeckManager; +import forge.properties.ForgeProps; +import forge.properties.NewConstants; +import forge.quest.data.QuestPreferences; +import forge.quest.data.QuestUtil; + +import java.io.File; +import java.util.*; + +/** + *QuestEventManager.
+ * MODEL - Manages collections of quest events (duelsquests, etc.) + * + * @author Forge + * @version $Id$ + */ +public class QuestEventManager { + public ListassembleAllEvents.
* + * Reads all quest and battle files to extract quest data. + * Instantiates all duel and quest events, and difficulty lists accordingly. + * Should be used sparingly. + */ + public void assembleAllEvents() { + this.allDuels = new ArrayListassembleDuelUniqueData.
+ * Handler for any unique data contained in duel files. + * + * @param contents + * @param qd + */ + private void assembleDuelUniquedata(ListassembleQuestUniquedata.
+ * Handler for any unique data contained in quest files. + * + * @param contents + * @param qq + */ + private void assembleQuestUniquedata(ListassembleEventMetadata.
+ * Handler for metadata contained in event files. + * + * @param contents + * @param qe + */ + private void assembleEventMetadata(ListgetAllDuels.
+ * Returns complete list of all duel objects. + * + * @return a {@link java.util.List} object. + */ + public ListgetAllQuests.
+ * Returns complete list of all quest objects. + * + * @return a {@link java.util.List} object. + */ + public ListassembleDuelDifficultyLists.
+ * Assemble duel deck difficulty lists + */ + private void assembleDuelDifficultyLists() { + easyAIduels = new ArrayListgetDuelOpponent.
+ * Returns specific duel opponent from current shuffle of available duels. + * This is to make sure that the opponents do not change + * when the deck editor is launched. + * + * @param aiDeck a {@link java.util.List} object. + * @param number a int. + * @return a {@link java.lang.String} object. + */ + private static QuestDuel getDuelOpponentByNumber(ListgenerateDuels.
+ * Generates an array of new duel opponents based on current win conditions. + * + * @return an array of {@link java.lang.String} objects. + */ + public ListgenerateQuests.
+ * Generates an array of new quest opponents based on current win conditions. + * + * @return a {@link java.util.List} object. + */ + public ListQuestQuest class.
* - * Manages QuestSelectablePanel instances for "quest" style matches. - * - * @author Forge - * @version $Id$ + * MODEL - A single quest event data instance, including meta, + * deck, and quest-specific properties. + * */ -public class QuestQuest extends QuestSelectablePanel { - /** ConstantserialVersionUID=-162817410327650160L */
- private static final long serialVersionUID = -162817410327650160L;
+public class QuestQuest extends QuestEvent {
+ // ID (default -1, should be explicitly set at later time.)
+ public int id = -1;
+
+ // Default vals if none provided for this ID
+ public int aiLife = 25;
+ public int creditsReward = 100;
+ public String cardReward = "1 colorless rare";
+ public boolean repeatable = false;
+ public int winsReqd = 20;
- Quest_Assignment assignment;
+ // Other cards used in assignment: starting, and reward.
+ public CardList humanExtraCards = new CardList();
+ public CardList aiExtraCards = new CardList();
+ public ListConstructor for QuestQuest.
+ *getAILife.
* - * @param assignment a {@link forge.Quest_Assignment} object. + * @return {@link java.lang.Integer}. */ - public QuestQuest(Quest_Assignment assignment) { - super(assignment.getName(), assignment.getDifficulty(), assignment.getDesc(), GuiUtils.getIconFromFile(assignment.getIconName())); - this.assignment = assignment; - - JLabel repeatabilityLabel; - if (assignment.isRepeatable()) { - repeatabilityLabel = new JLabel("This quest is repeatable"); - } else { - repeatabilityLabel = new JLabel("This quest is not repeatable"); - } - - GuiUtils.addGap(centerPanel); - this.centerPanel.add(repeatabilityLabel); + public final int getAILife() { + return aiLife; } - + /** - *getQuests.
+ *getCardReward.
* - * @return a {@link java.util.List} object. + * @return {@link java.lang.String}. */ - public static ListreadQuests.
+ *getCreditsReward.
* - * @return a {@link java.util.List} object. + * @return {@link java.lang.Integer}. */ - private static ListgetQuestAssignment.
+ *getId.
* - * @return a {@link forge.Quest_Assignment} object. + * @return {@link java.lang.Integer}. */ - public Quest_Assignment getQuestAssignment() { - return assignment; + public final int getId() { + return id; + } + + /** + *getRepeatable.
+ * + * @return {@link java.lang.Boolean}. + */ + public final boolean getRepeatable() { + return repeatable; + } + + /** + *getWinsReqd.
+ * + * @return {@link java.lang.Integer}. + */ + public final int getWinsReqd() { + return winsReqd; + } + + /** + *getAIExtraCards.
+ * Retrieves list of cards AI has in play at the beginning of this quest. + * + * @return + */ + public final CardList getAIExtraCards() { + return aiExtraCards; + } + + /** + *getHumanExtraCards.
+ * Retrieves list of cards human has in play at the beginning of this quest. + * + * @return + */ + public final CardList getHumanExtraCards() { + return humanExtraCards; + } + + /** + *getCardRewardList.
+ * + * @return + */ + public final ListQuestQuestPanel.
+ * VIEW - Creates a QuestSelectablePanel instance for a "quest" style event. + */ + +@SuppressWarnings("serial") +public class QuestQuestPanel extends QuestSelectablePanel { + + //private JLabel repeatabilityLabel; + + /**QuestQuestPanel.
+ * Constructor, using quest data instance. + * + * @param {@link forge.quest.gui.main.QuestDuel} + */ + public QuestQuestPanel(QuestQuest q) { + super(q); + + // Repeatability is currently meaningless. + // Can be added here later if necessary. + /* + * if (q.getRepeatable()) { + repeatabilityLabel = new JLabel("This quest is repeatable"); + } else { + repeatabilityLabel = new JLabel("This quest is not repeatable"); + } + + super.rootPanel.add(repeatabilityLabel); + */ + } +} diff --git a/src/main/java/forge/quest/gui/main/QuestSelectablePanel.java b/src/main/java/forge/quest/gui/main/QuestSelectablePanel.java index a711628577d..9567459c3a1 100644 --- a/src/main/java/forge/quest/gui/main/QuestSelectablePanel.java +++ b/src/main/java/forge/quest/gui/main/QuestSelectablePanel.java @@ -1,15 +1,19 @@ package forge.quest.gui.main; import forge.gui.GuiUtils; +import forge.properties.ForgeProps; +import forge.properties.NewConstants; import javax.swing.*; import javax.swing.border.CompoundBorder; import javax.swing.border.EmptyBorder; import javax.swing.border.LineBorder; import java.awt.*; +import java.io.File; /** *QuestSelectablePanel class.
+ * VIEW - Creates a selectable panel, used for picking events. * * @author Forge * @version $Id$ @@ -20,35 +24,38 @@ public class QuestSelectablePanel extends JPanel { protected Color backgroundColor; private boolean selected; - - ImageIcon icon; - String name; - String description; - String difficulty; - JPanel centerPanel = new JPanel(); + private QuestEvent event; + private String iconfilename; + public JPanel rootPanel = new JPanel(); /** *Constructor for QuestSelectablePanel.
+ * VIEW - A JPanel for selecting quest events. * * @param name a {@link java.lang.String} object. * @param difficulty a {@link java.lang.String} object. * @param description a {@link java.lang.String} object. * @param icon a {@link javax.swing.ImageIcon} object. */ - public QuestSelectablePanel(String name, String difficulty, String description, ImageIcon icon) { + public QuestSelectablePanel(QuestEvent qe) { + this.event = qe; + this.iconfilename = qe.icon; + File base = ForgeProps.getFile(NewConstants.IMAGE_ICON); + File file = new File(base, iconfilename); + + if(!file.exists()) { + file = new File(base,"Unknown.jpg"); + this.iconfilename = "Unknown.jpg"; + } + + ImageIcon icon = new ImageIcon(file.toString()); + this.backgroundColor = getBackground(); - - this.name = name; - this.difficulty = difficulty; - this.description = description; - this.icon = icon; - this.setLayout(new BorderLayout(5, 5)); - JLabel iconLabel; - if (icon == null) { + if (icon.getIconHeight() == -1) { iconLabel = new JLabel(GuiUtils.getEmptyIcon(40, 40)); } else { iconLabel = new JLabel(GuiUtils.getResizedIcon(icon, 40, 40)); @@ -62,32 +69,32 @@ public class QuestSelectablePanel extends JPanel { iconPanel.add(iconLabel, BorderLayout.NORTH); this.add(iconPanel, BorderLayout.WEST); - centerPanel.setOpaque(false); - centerPanel.setLayout(new BoxLayout(centerPanel, BoxLayout.Y_AXIS)); - this.add(centerPanel, BorderLayout.CENTER); + rootPanel.setOpaque(false); + rootPanel.setLayout(new BoxLayout(rootPanel, BoxLayout.Y_AXIS)); + this.add(rootPanel, BorderLayout.CENTER); JPanel centerTopPanel = new JPanel(); centerTopPanel.setOpaque(false); centerTopPanel.setAlignmentX(LEFT_ALIGNMENT); centerTopPanel.setLayout(new BoxLayout(centerTopPanel, BoxLayout.X_AXIS)); - JLabel nameLabel = new JLabel(this.name); + JLabel nameLabel = new JLabel(qe.getTitle()); GuiUtils.setFontSize(nameLabel, 20); nameLabel.setAlignmentY(BOTTOM_ALIGNMENT); centerTopPanel.add(nameLabel); GuiUtils.addExpandingHorizontalSpace(centerTopPanel); - JLabel difficultyLabel = new JLabel(this.difficulty); + JLabel difficultyLabel = new JLabel(qe.getDifficulty()); difficultyLabel.setAlignmentY(BOTTOM_ALIGNMENT); centerTopPanel.add(difficultyLabel); - centerPanel.add(centerTopPanel); + rootPanel.add(centerTopPanel); - GuiUtils.addGap(centerPanel); + GuiUtils.addGap(rootPanel); - JLabel descriptionLabel = new JLabel(description); + JLabel descriptionLabel = new JLabel(qe.getDescription()); descriptionLabel.setAlignmentX(LEFT_ALIGNMENT); - centerPanel.add(descriptionLabel); + 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))); @@ -117,9 +124,21 @@ public class QuestSelectablePanel extends JPanel { this.selected = selected; } - /** {@inheritDoc} */ - @Override - public String getName() { - return name; + /** + *getIconFilename.
+ * + * @return String + */ + public String getIconFilename() { + return this.iconfilename; + } + + /** + *getEvent.
+ * + * @return QuestEvent + */ + public QuestEvent getEvent() { + return this.event; } } diff --git a/src/test/java/forge/ReadQuestAssignmentTest.java b/src/test/java/forge/ReadQuestAssignmentTest.java deleted file mode 100644 index 9e426d40bbd..00000000000 --- a/src/test/java/forge/ReadQuestAssignmentTest.java +++ /dev/null @@ -1,41 +0,0 @@ -package forge; - -import forge.error.ErrorViewer; -import forge.properties.ForgeProps; -import forge.properties.NewConstants; -import org.testng.annotations.Test; - -/** - * Created by IntelliJ IDEA. - * User: dhudson - */ -@Test(groups = {"UnitTest"}, timeOut = 1000) -public class ReadQuestAssignmentTest implements NewConstants { - /** - * - * - */ - @Test(groups = {"UnitTest", "fast"}, timeOut = 1000) - public void ReadQuestAssignmentTest1() { - try { - ReadQuest_Assignment read = new ReadQuest_Assignment(ForgeProps.getFile(QUEST.QUESTS), null); - - javax.swing.SwingUtilities.invokeAndWait(read); - // read.run(); - - Quest_Assignment qa[] = new Quest_Assignment[read.allQuests.size()]; - read.allQuests.toArray(qa); - for (int i = 0; i < qa.length; i++) { - System.out.println(qa[i].getId()); - System.out.println(qa[i].getName()); - System.out.println(qa[i].getDesc()); - System.out.println(qa[i].getDifficulty()); - System.out.println(qa[i].isRepeatable()); - System.out.println(qa[i].getRequiredNumberWins()); - } - } catch (Exception ex) { - ErrorViewer.showError(ex); - System.out.println("Error reading file " + ex); - } - } -}