In quest mode, "Quests" universally renamed to "Challenges".

Quest mode now features events, such as duels and challenges.
This commit is contained in:
Doublestrike
2011-09-18 11:28:27 +00:00
parent 1041925211
commit d1bf8a4b14
12 changed files with 189 additions and 206 deletions

4
.gitattributes vendored
View File

@@ -9872,12 +9872,12 @@ src/main/java/forge/quest/gui/bazaar/QuestBazaarItem.java svneol=native#text/pla
src/main/java/forge/quest/gui/bazaar/QuestBazaarPanel.java svneol=native#text/plain src/main/java/forge/quest/gui/bazaar/QuestBazaarPanel.java svneol=native#text/plain
src/main/java/forge/quest/gui/bazaar/QuestBazaarStall.java svneol=native#text/plain src/main/java/forge/quest/gui/bazaar/QuestBazaarStall.java svneol=native#text/plain
src/main/java/forge/quest/gui/bazaar/package-info.java svneol=native#text/plain src/main/java/forge/quest/gui/bazaar/package-info.java svneol=native#text/plain
src/main/java/forge/quest/gui/main/QuestChallenge.java svneol=native#text/plain
src/main/java/forge/quest/gui/main/QuestChallengePanel.java -text
src/main/java/forge/quest/gui/main/QuestDuel.java svneol=native#text/plain src/main/java/forge/quest/gui/main/QuestDuel.java svneol=native#text/plain
src/main/java/forge/quest/gui/main/QuestDuelPanel.java -text src/main/java/forge/quest/gui/main/QuestDuelPanel.java -text
src/main/java/forge/quest/gui/main/QuestEvent.java -text src/main/java/forge/quest/gui/main/QuestEvent.java -text
src/main/java/forge/quest/gui/main/QuestEventManager.java svneol=native#text/plain src/main/java/forge/quest/gui/main/QuestEventManager.java svneol=native#text/plain
src/main/java/forge/quest/gui/main/QuestQuest.java svneol=native#text/plain
src/main/java/forge/quest/gui/main/QuestQuestPanel.java -text
src/main/java/forge/quest/gui/main/QuestSelectablePanel.java -text src/main/java/forge/quest/gui/main/QuestSelectablePanel.java -text
src/main/java/forge/quest/gui/main/package-info.java svneol=native#text/plain src/main/java/forge/quest/gui/main/package-info.java svneol=native#text/plain
src/main/java/forge/quest/gui/package-info.java svneol=native#text/plain src/main/java/forge/quest/gui/package-info.java svneol=native#text/plain

View File

@@ -4,12 +4,6 @@ rare--file=rare.txt
price--file=all-prices.txt price--file=all-prices.txt
boosterprice--file=booster-prices.txt boosterprice--file=booster-prices.txt
quests--file=quests.txt
easy--file=easy.txt
medium--file=medium.txt
hard--file=hard.txt
veryhard--file=veryhard.txt
data-xml--file=questData.dat data-xml--file=questData.dat
data--file=questData data--file=questData

View File

@@ -17,7 +17,7 @@ import forge.properties.ForgeProps;
import forge.properties.NewConstants; import forge.properties.NewConstants;
import forge.quest.data.QuestMatchState; import forge.quest.data.QuestMatchState;
import forge.quest.data.QuestData; import forge.quest.data.QuestData;
import forge.quest.gui.main.QuestQuest; import forge.quest.gui.main.QuestChallenge;
/** /**
* Please use public getters and setters instead of direct field access. * Please use public getters and setters instead of direct field access.
@@ -42,8 +42,8 @@ public final class AllZone implements NewConstants {
/** Global <code>questData</code>. */ /** Global <code>questData</code>. */
private static forge.quest.data.QuestData questData = null; private static forge.quest.data.QuestData questData = null;
/** Global <code>QuestAssignment</code>. */ /** Global <code>QuestChallenge</code>. */
private static QuestQuest questquest = null; private static QuestChallenge questChallenge = null;
/** Constant <code>NAME_CHANGER</code>. */ /** Constant <code>NAME_CHANGER</code>. */
private static final NameChanger NAME_CHANGER = new NameChanger(); private static final NameChanger NAME_CHANGER = new NameChanger();
@@ -62,7 +62,7 @@ public final class AllZone implements NewConstants {
private static GameSummary gameInfo = new GameSummary(); private static GameSummary gameInfo = new GameSummary();
/** /**
* Match State for quests are stored in a <code>QuestMatchState</code> class instance. * Match State for challenges are stored in a <code>QuestMatchState</code> class instance.
* *
* @deprecated Variable 'matchState' must be private and have accessor methods. * @deprecated Variable 'matchState' must be private and have accessor methods.
*/ */
@@ -132,23 +132,22 @@ public final class AllZone implements NewConstants {
} }
/** /**
* <p>getQuestAssignment.</p> * <p>getQuestChallenge.</p>
* *
* @return a {@link forge.Quest_Assignment} object. * @return a {@link forge.Quest_Assignment} object.
* @since 1.0.15 * @since 1.0.15
*/ */
public static QuestQuest getQuestQuest() { public static QuestChallenge getQuestChallenge() {
return questquest; return questChallenge;
} }
/** /**
* <p>setQuestAssignment.</p> * <p>setQuestChallenge.</p>
* *
* @param assignment a {@link forge.Quest_Assignment} object. * @param q
* @since 1.0.15
*/ */
public static void setQuestQuest(final QuestQuest q) { public static void setQuestChallenge(final QuestChallenge q) {
questquest = q; questChallenge = q;
} }
/** /**

View File

@@ -29,7 +29,7 @@ import forge.gui.input.Input_PayManaCost_Ability;
import forge.item.CardPrinted; import forge.item.CardPrinted;
import forge.properties.ForgeProps; import forge.properties.ForgeProps;
import forge.properties.NewConstants.LANG.GameAction.GAMEACTION_TEXT; import forge.properties.NewConstants.LANG.GameAction.GAMEACTION_TEXT;
import forge.quest.gui.main.QuestQuest; import forge.quest.gui.main.QuestChallenge;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.Comparator; import java.util.Comparator;
@@ -654,7 +654,7 @@ public class GameAction {
AllZone.getDisplay().savePrefs(); AllZone.getDisplay().savePrefs();
frame.setEnabled(false); frame.setEnabled(false);
//frame.dispose(); //frame.dispose();
Gui_WinLose gwl = new Gui_WinLose(AllZone.getMatchState(), AllZone.getQuestData(), AllZone.getQuestQuest()); Gui_WinLose gwl = new Gui_WinLose(AllZone.getMatchState(), AllZone.getQuestData(), AllZone.getQuestChallenge());
//gwl.setAlwaysOnTop(true); //gwl.setAlwaysOnTop(true);
gwl.toFront(); gwl.toFront();
canShowWinLose = false; canShowWinLose = false;
@@ -1090,15 +1090,15 @@ public class GameAction {
* @param computer a {@link forge.CardList} object. * @param computer a {@link forge.CardList} object.
*/ */
public final void newGame(final Deck humanDeck, final Deck computerDeck, final CardList human, public final void newGame(final Deck humanDeck, final Deck computerDeck, final CardList human,
final CardList computer, final int humanLife, final int computerLife, final QuestQuest qq) final CardList computer, final int humanLife, final int computerLife, final QuestChallenge qc)
{ {
this.newGame(humanDeck, computerDeck); this.newGame(humanDeck, computerDeck);
AllZone.getComputerPlayer().setLife(computerLife, null); AllZone.getComputerPlayer().setLife(computerLife, null);
AllZone.getHumanPlayer().setLife(humanLife, null); AllZone.getHumanPlayer().setLife(humanLife, null);
if (qq != null) { if (qc != null) {
computer.addAll(forge.quest.data.QuestUtil.getComputerStartingCards(AllZone.getQuestData(), AllZone.getQuestQuest())); computer.addAll(forge.quest.data.QuestUtil.getComputerStartingCards(AllZone.getQuestData(), AllZone.getQuestChallenge()));
} }
for (Card c : human) { for (Card c : human) {

View File

@@ -17,7 +17,7 @@ import forge.quest.data.QuestData;
import forge.quest.data.QuestMatchState; import forge.quest.data.QuestMatchState;
import forge.quest.data.QuestPreferences; import forge.quest.data.QuestPreferences;
import forge.quest.gui.QuestFrame; import forge.quest.gui.QuestFrame;
import forge.quest.gui.main.QuestQuest; import forge.quest.gui.main.QuestChallenge;
import forge.view.swing.OldGuiNewGame; import forge.view.swing.OldGuiNewGame;
import net.miginfocom.swing.MigLayout; import net.miginfocom.swing.MigLayout;
@@ -66,7 +66,7 @@ public class Gui_WinLose extends JFrame implements NewConstants {
private class WinLoseModel { private class WinLoseModel {
public QuestMatchState match; public QuestMatchState match;
public QuestData quest; public QuestData quest;
public QuestQuest qq; public QuestChallenge qc;
} }
private WinLoseModel model; private WinLoseModel model;
@@ -76,13 +76,13 @@ public class Gui_WinLose extends JFrame implements NewConstants {
* *
* @param matchState a QuestMatchState * @param matchState a QuestMatchState
* @param quest a QuestData object * @param quest a QuestData object
* @param qa a Quest_Assignment object * @param chall a QuestChallenge object
*/ */
public Gui_WinLose(final QuestMatchState matchState, final QuestData quest, final QuestQuest qq) { public Gui_WinLose(final QuestMatchState matchState, final QuestData quest, final QuestChallenge chall) {
model = new WinLoseModel(); model = new WinLoseModel();
model.match = matchState; model.match = matchState;
model.quest = quest; model.quest = quest;
model.qq = qq; model.qc = chall;
try { try {
jbInit(); jbInit();
@@ -187,25 +187,25 @@ public class Gui_WinLose extends JFrame implements NewConstants {
void prepareForNextRound() { void prepareForNextRound() {
if (Constant.Quest.fantasyQuest[0]) { if (Constant.Quest.fantasyQuest[0]) {
int extraLife = 0; int extraLife = 0;
if (model.qq != null) { if (model.qc != null) {
if (model.quest.getInventory().hasItem("Zeppelin")) { if (model.quest.getInventory().hasItem("Zeppelin")) {
extraLife = 3; extraLife = 3;
} }
} }
//AllZone.getGameAction().newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0], //AllZone.getGameAction().newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0],
//humanList, computerList, humanLife, computerLife); //humanList, computerList, humanLife, computerLife);
CardList humanList = forge.quest.data.QuestUtil.getHumanStartingCards(model.quest, model.qq); CardList humanList = forge.quest.data.QuestUtil.getHumanStartingCards(model.quest, model.qc);
CardList computerList = new CardList(); CardList computerList = new CardList();
int humanLife = model.quest.getLife() + extraLife; int humanLife = model.quest.getLife() + extraLife;
int computerLife = 20; int computerLife = 20;
if (model.qq != null) { if (model.qc != null) {
computerLife = model.qq.getAILife(); computerLife = model.qc.getAILife();
} }
AllZone.getGameAction().newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0], AllZone.getGameAction().newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0],
humanList, computerList, humanLife, computerLife, model.qq); humanList, computerList, humanLife, computerLife, model.qc);
} else { } else {
AllZone.getGameAction().newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0]); AllZone.getGameAction().newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0]);
} }
@@ -355,15 +355,15 @@ public class Gui_WinLose extends JFrame implements NewConstants {
model.quest.getCards().clearShopList(); model.quest.getCards().clearShopList();
if (model.quest.getAvailableQuests() != null) { if (model.quest.getAvailableChallenges() != null) {
model.quest.clearAvailableQuests(); model.quest.clearAvailableChallenges();
} }
model.quest.getCards().resetNewList(); model.quest.getCards().resetNewList();
giveQuestRewards(wonMatch); giveQuestRewards(wonMatch);
model.match.reset(); model.match.reset();
AllZone.setQuestQuest(null); AllZone.setQuestChallenge(null);
model.quest.saveData(); model.quest.saveData();
@@ -441,32 +441,32 @@ public class Gui_WinLose extends JFrame implements NewConstants {
} }
// Rewards from QuestAssignment // Rewards from QuestAssignment
if (wonMatch && model.qq != null) { if (wonMatch && model.qc != null) {
model.quest.addQuestsPlayed(); model.quest.addChallengesPlayed();
List<CardPrinted> questRewardCards = model.qq.getCardRewardList(); List<CardPrinted> challengeRewardCards = model.qc.getCardRewardList();
long questRewardCredits = model.qq.getCreditsReward(); long questRewardCredits = model.qc.getCreditsReward();
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
sb.append("Quest Completed - \r\n"); sb.append("Challenge Completed - \r\n");
if (questRewardCards != null) { if (challengeRewardCards != null) {
sb.append("You won the following cards:\r\n\r\n"); sb.append("You won the following cards:\r\n\r\n");
for (CardPrinted cardName : questRewardCards) { for (CardPrinted cardName : challengeRewardCards) {
sb.append(cardName.getName()); sb.append(cardName.getName());
sb.append("\r\n"); sb.append("\r\n");
} }
model.quest.getCards().addAllCards(questRewardCards); model.quest.getCards().addAllCards(challengeRewardCards);
sb.append("\r\n"); sb.append("\r\n");
} }
sb.append("Quest Bounty: "); sb.append("Challenge Bounty: ");
sb.append(questRewardCredits); sb.append(questRewardCredits);
model.quest.addCredits(questRewardCredits); model.quest.addCredits(questRewardCredits);
String fileName = "BoxIcon.png"; String fileName = "BoxIcon.png";
ImageIcon icon = getIcon(fileName); ImageIcon icon = getIcon(fileName);
String title = "Quest Rewards for " + model.qq.getTitle(); String title = "Challenge Rewards for " + model.qc.getTitle();
JOptionPane.showMessageDialog(null, sb.toString(), title, JOptionPane.INFORMATION_MESSAGE, icon); JOptionPane.showMessageDialog(null, sb.toString(), title, JOptionPane.INFORMATION_MESSAGE, icon);
} }
/* /*

View File

@@ -148,21 +148,8 @@ public interface NewConstants {
/** Property path for a rare card. */ /** Property path for a rare card. */
String RARE = "quest/rare"; String RARE = "quest/rare";
/** Property path for price. */
String PRICE = "quest/price"; String PRICE = "quest/price";
/** Property path for price. */
String BOOSTER_PRICE= "quest/boosterprice"; String BOOSTER_PRICE= "quest/boosterprice";
/** Property path for quests. */
String QUESTS = "quest/quests";
/** Property path for easy quest difficulty. */
String EASY = "quest/easy";
/** Property path for medium quest difficulty. */
String MEDIUM = "quest/medium";
/** Property path for hard quest difficulty. */
String HARD = "quest/hard";
/** Property path for very hard quest difficulty. */
String VERYHARD = "quest/veryhard";
String DATA = "quest/data"; String DATA = "quest/data";
String PREFS = "quest/prefs"; String PREFS = "quest/prefs";

View File

@@ -23,10 +23,6 @@ import net.slightlymagic.maxmtg.Predicate;
//you have to call one of these two methods below //you have to call one of these two methods below
//see Gui_QuestOptions for more details //see Gui_QuestOptions for more details
//static readAIQuestDeckFiles(QuestDataOld data, ArrayList aiDeckNames)
//OR non-static readAIQuestDeckFiles()
//which reads the files "questDecks-easy", "questDecks-medium","questDecks-hard",
/** /**
* <p>QuestData class.</p> * <p>QuestData class.</p>
* *
@@ -72,10 +68,10 @@ public final class QuestData {
ItemPool<InventoryItem> shopList = new ItemPool<InventoryItem>(InventoryItem.class); // the current shop list ItemPool<InventoryItem> shopList = new ItemPool<InventoryItem>(InventoryItem.class); // the current shop list
ItemPool<InventoryItem> newCardList = new ItemPool<InventoryItem>(InventoryItem.class); // cards acquired since last game-win/loss ItemPool<InventoryItem> newCardList = new ItemPool<InventoryItem>(InventoryItem.class); // cards acquired since last game-win/loss
// Quests history // Challenge history
int questsPlayed; int challengesPlayed;
List<Integer> availableQuests = new ArrayList<Integer>(); List<Integer> availableChallenges = new ArrayList<Integer>();
List<Integer> completedQuests = new ArrayList<Integer>(); List<Integer> completedChallenges = new ArrayList<Integer>();
// own randomizer seed // own randomizer seed
private long randomSeed = 0; private long randomSeed = 0;
@@ -140,14 +136,14 @@ public final class QuestData {
public QuestUtilCards getCards() { return myCards; } public QuestUtilCards getCards() { return myCards; }
public QuestUtilRewards getRewards() { return myRewards; } public QuestUtilRewards getRewards() { return myRewards; }
// Quests performance // Challenge performance
public int getQuestsPlayed() { return questsPlayed; } public int getChallengesPlayed() { return challengesPlayed; }
public void addQuestsPlayed() { questsPlayed++; } public void addChallengesPlayed() { challengesPlayed++; }
public List<Integer> getAvailableQuests() { return availableQuests != null ? new ArrayList<Integer>(availableQuests) : null; } public List<Integer> getAvailableChallenges() { return availableChallenges != null ? new ArrayList<Integer>(availableChallenges) : null; }
public void setAvailableQuests(final List<Integer> list) { availableQuests = list; } public void setAvailableChallenges(final List<Integer> list) { availableChallenges = list; }
public void clearAvailableQuests() { availableQuests.clear(); } public void clearAvailableChallenges() { availableChallenges.clear(); }
public List<Integer> getCompletedQuests() { return completedQuests != null ? new ArrayList<Integer>(completedQuests) : null; } public List<Integer> getCompletedChallenges() { return completedChallenges != null ? new ArrayList<Integer>(completedChallenges) : null; }
// Wins & Losses // Wins & Losses
public int getLost() { return lost; } public int getLost() { return lost; }
@@ -229,7 +225,7 @@ public final class QuestData {
randomSeed = MyRandom.random.nextLong(); randomSeed = MyRandom.random.nextLong();
} }
// SERIALIZATION - relared things // SERIALIZATION - related things
// This must be called by XML-serializer via reflection // This must be called by XML-serializer via reflection
public Object readResolve() { public Object readResolve() {

View File

@@ -6,7 +6,7 @@ import forge.Constant;
import forge.card.CardRarity; import forge.card.CardRarity;
import forge.card.BoosterUtils; import forge.card.BoosterUtils;
import forge.item.CardPrinted; import forge.item.CardPrinted;
import forge.quest.gui.main.QuestQuest; import forge.quest.gui.main.QuestChallenge;
import java.util.List; import java.util.List;
@@ -33,14 +33,14 @@ public class QuestUtil {
* Returns extra AI cards in play at start of quest. * Returns extra AI cards in play at start of quest.
* *
* @param qd a {@link forge.quest.data.QuestData} object. * @param qd a {@link forge.quest.data.QuestData} object.
* @param qa a {@link forge.Quest_Assignment} object. * @param qc a QuestChallenge object.
* @return a {@link forge.CardList} object. * @return a {@link forge.CardList} object.
*/ */
public static CardList getComputerStartingCards(final QuestData qd, QuestQuest qq) { public static CardList getComputerStartingCards(final QuestData qd, QuestChallenge qc) {
CardList list = new CardList(); CardList list = new CardList();
if (qq != null) { if (qc != null) {
list.addAll(qq.getAIExtraCards()); list.addAll(qc.getAIExtraCards());
} }
return list; return list;
} }
@@ -72,14 +72,14 @@ public class QuestUtil {
* and cards in play at start of quest. * and cards in play at start of quest.
* *
* @param qd a {@link forge.quest.data.QuestData} object. * @param qd a {@link forge.quest.data.QuestData} object.
* @param qa a {@link forge.Quest_Assignment} object. * @param qc a QuestChallenge object.
* @return a {@link forge.CardList} object. * @return a {@link forge.CardList} object.
*/ */
public static CardList getHumanStartingCards(final QuestData qd, QuestQuest qq) { public static CardList getHumanStartingCards(final QuestData qd, QuestChallenge qc) {
CardList list = getHumanStartingCards(qd); CardList list = getHumanStartingCards(qd);
if (qq != null) { if (qc != null) {
list.addAll(qq.getHumanExtraCards()); list.addAll(qc.getHumanExtraCards());
} }
return list; return list;
@@ -160,7 +160,6 @@ public class QuestUtil {
col = Constant.Color.White; col = Constant.Color.White;
} }
System.out.println(rar+" "+col+" "+qty);
return BoosterUtils.generateCards(qty, rar, col); return BoosterUtils.generateCards(qty, rar, col);
} }

View File

@@ -10,8 +10,8 @@ import forge.quest.data.QuestData;
import forge.quest.data.item.QuestItemZeppelin; import forge.quest.data.item.QuestItemZeppelin;
import forge.quest.gui.main.QuestDuel; import forge.quest.gui.main.QuestDuel;
import forge.quest.gui.main.QuestDuelPanel; import forge.quest.gui.main.QuestDuelPanel;
import forge.quest.gui.main.QuestQuest; import forge.quest.gui.main.QuestChallenge;
import forge.quest.gui.main.QuestQuestPanel; import forge.quest.gui.main.QuestChallengePanel;
import forge.quest.gui.main.QuestSelectablePanel; import forge.quest.gui.main.QuestSelectablePanel;
import javax.swing.*; import javax.swing.*;
@@ -49,7 +49,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
JComboBox petComboBox = new JComboBox(); JComboBox petComboBox = new JComboBox();
JComboBox deckComboBox = new JComboBox(); JComboBox deckComboBox = new JComboBox();
JButton questButton = new JButton("Quests"); JButton eventButton = new JButton("Challenges");
JButton playButton = new JButton("Play"); JButton playButton = new JButton("Play");
private QuestSelectablePanel selectedOpponent; private QuestSelectablePanel selectedOpponent;
@@ -57,7 +57,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
JPanel nextMatchPanel = new JPanel(); JPanel nextMatchPanel = new JPanel();
CardLayout nextMatchLayout; CardLayout nextMatchLayout;
boolean isShowingQuests = false; boolean isShowingChallenges = false;
private JCheckBox devModeCheckBox = new JCheckBox("Developer Mode"); private JCheckBox devModeCheckBox = new JCheckBox("Developer Mode");
//private JCheckBox newGUICheckbox = new JCheckBox("Use new UI", true); //private JCheckBox newGUICheckbox = new JCheckBox("Use new UI", true);
private JCheckBox smoothLandCheckBox = new JCheckBox("Adjust AI Land"); private JCheckBox smoothLandCheckBox = new JCheckBox("Adjust AI Land");
@@ -66,10 +66,10 @@ public class QuestMainPanel extends QuestAbstractPanel {
private JCheckBox plantBox = new JCheckBox("Summon Plant"); private JCheckBox plantBox = new JCheckBox("Summon Plant");
/** Constant <code>NO_DECKS_AVAILABLE="No decks available"</code> */ /** Constant <code>NO_DECKS_AVAILABLE="No decks available"</code> */
private static final String NO_DECKS_AVAILABLE = "No decks available"; private static final String NO_DECKS_AVAILABLE = "No decks available";
/** Constant <code>BATTLES="Battles"</code> */ /** Constant <code>DUELS="Duels"</code> */
private static final String BATTLES = "Battles"; private static final String DUELS = "Duels";
/** Constant <code>QUESTS="Quests"</code> */ /** Constant <code>CHALLENGES="Challenges"</code> */
private static final String QUESTS = "Quests"; private static final String CHALLENGES = "Challenges";
//TODO: Make this ordering permanent //TODO: Make this ordering permanent
/** Constant <code>lastUsedDeck="//TODO: Make this ordering permanent"</code> */ /** Constant <code>lastUsedDeck="//TODO: Make this ordering permanent"</code> */
@@ -198,14 +198,14 @@ public class QuestMainPanel extends QuestAbstractPanel {
} }
questButton.addActionListener(new ActionListener() { eventButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) { public void actionPerformed(ActionEvent actionEvent) {
QuestMainPanel.this.showQuests(); QuestMainPanel.this.showChallenges();
} }
}); });
eastComponents.add(questButton); eastComponents.add(eventButton);
questButton.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 18)); eventButton.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 18));
questButton.setPreferredSize(new Dimension(0, 60)); eventButton.setPreferredSize(new Dimension(0, 60));
playButton.addActionListener(new ActionListener() { playButton.addActionListener(new ActionListener() {
@@ -249,7 +249,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
panel.add(Box.createVerticalGlue()); panel.add(Box.createVerticalGlue());
panel.add(questButton); panel.add(eventButton);
this.nextQuestLabel.setFont(new Font(Font.DIALOG, Font.PLAIN, 11)); this.nextQuestLabel.setFont(new Font(Font.DIALOG, Font.PLAIN, 11));
panel.add(nextQuestLabel); panel.add(nextQuestLabel);
GuiUtils.addGap(panel); GuiUtils.addGap(panel);
@@ -398,7 +398,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
JPanel DuelPanel = new JPanel(); JPanel DuelPanel = new JPanel();
QuestDuelPanel duelEvent; QuestDuelPanel duelEvent;
DuelPanel.setLayout(new BoxLayout(DuelPanel, BoxLayout.Y_AXIS)); DuelPanel.setLayout(new BoxLayout(DuelPanel, BoxLayout.Y_AXIS));
DuelPanel.setBorder(new TitledBorder(new EtchedBorder(), "Available Battles")); DuelPanel.setBorder(new TitledBorder(new EtchedBorder(), "Available Duels"));
List<QuestDuel> duels = TEST.qem.generateDuels(); List<QuestDuel> duels = TEST.qem.generateDuels();
@@ -416,30 +416,30 @@ public class QuestMainPanel extends QuestAbstractPanel {
} }
/** /**
* <p>createQuestPanel.</p> * <p>createChallengePanel.</p>
* Makes a parent panel, then selectable panel instances for all available battles. * Makes a parent panel, then selectable panel instances for all available challenges.
* *
* @return a {@link javax.swing.JPanel} object. * @return a {@link javax.swing.JPanel} object.
*/ */
private JPanel createQuestPanel() { private JPanel createChallengePanel() {
JPanel QuestPanel = new JPanel(); JPanel ChallengePanel = new JPanel();
QuestSelectablePanel selpan; QuestSelectablePanel selpan;
QuestPanel.setLayout(new BoxLayout(QuestPanel, BoxLayout.Y_AXIS)); ChallengePanel.setLayout(new BoxLayout(ChallengePanel, BoxLayout.Y_AXIS));
QuestPanel.setBorder(new TitledBorder(new EtchedBorder(), "Available Quests")); ChallengePanel.setBorder(new TitledBorder(new EtchedBorder(), "Available Challenges"));
List<QuestQuest> quests = TEST.qem.generateQuests(); List<QuestChallenge> challenges = TEST.qem.generateChallenges();
for (QuestQuest qq : quests) { for (QuestChallenge qc : challenges) {
selpan = new QuestQuestPanel(qq); selpan = new QuestChallengePanel(qc);
QuestPanel.add(selpan); ChallengePanel.add(selpan);
selpan.addMouseListener(new SelectionAdapter(selpan)); selpan.addMouseListener(new SelectionAdapter(selpan));
GuiUtils.addGap(QuestPanel, 3); GuiUtils.addGap(ChallengePanel, 3);
} }
return QuestPanel; return ChallengePanel;
} }
/** /**
@@ -485,7 +485,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
} }
deckComboBox.setMinimumSize(new Dimension(150, 0)); deckComboBox.setMinimumSize(new Dimension(150, 0));
questButton.setEnabled(nextQuestInWins() == 0); eventButton.setEnabled(nextChallengeInWins() == 0);
playButton.setEnabled(canGameBeLaunched()); playButton.setEnabled(canGameBeLaunched());
@@ -536,10 +536,10 @@ public class QuestMainPanel extends QuestAbstractPanel {
} }
if (nextQuestInWins() > 0) { if (nextChallengeInWins() > 0) {
nextQuestLabel.setText("Next Quest in " + nextQuestInWins() + " Wins."); nextQuestLabel.setText("Next challenge in " + nextChallengeInWins() + " Wins.");
} else { } else {
nextQuestLabel.setText("Next Quest available now."); nextQuestLabel.setText("Next challenge available now.");
} }
nextMatchLayout = new CardLayout(); nextMatchLayout = new CardLayout();
@@ -554,21 +554,21 @@ public class QuestMainPanel extends QuestAbstractPanel {
nextMatchPanel.removeAll(); nextMatchPanel.removeAll();
nextMatchLayout = new CardLayout(); nextMatchLayout = new CardLayout();
nextMatchPanel.setLayout(nextMatchLayout); nextMatchPanel.setLayout(nextMatchLayout);
nextMatchPanel.add(createDuelPanel(), BATTLES); nextMatchPanel.add(createDuelPanel(), DUELS);
nextMatchPanel.add(createQuestPanel(), QUESTS); nextMatchPanel.add(createChallengePanel(), CHALLENGES);
if (isShowingQuests) { if (isShowingChallenges) {
this.nextMatchLayout.show(nextMatchPanel, QUESTS); this.nextMatchLayout.show(nextMatchPanel, CHALLENGES);
} else { } else {
this.nextMatchLayout.show(nextMatchPanel, BATTLES); this.nextMatchLayout.show(nextMatchPanel, DUELS);
} }
} }
/** /**
* <p>nextQuestInWins.</p> * <p>nextChallengeInWins.</p>
* *
* @return a int. * @return a int.
*/ */
private int nextQuestInWins() { private int nextChallengeInWins() {
// Number of wins was 25, lowereing the number to 20 to help short term questers. // Number of wins was 25, lowereing the number to 20 to help short term questers.
if (questData.getWin() < 20) { if (questData.getWin() < 20) {
@@ -576,7 +576,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
} }
// The int mul has been lowered by one, should face special opps more frequently. // The int mul has been lowered by one, should face special opps more frequently.
int questsPlayed = questData.getQuestsPlayed(); int challengesPlayed = questData.getChallengesPlayed();
int mul = 5; int mul = 5;
if (questData.getInventory().hasItem("Zeppelin")) { if (questData.getInventory().hasItem("Zeppelin")) {
@@ -585,7 +585,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
mul = 4; mul = 4;
} }
int delta = (questsPlayed * mul) - questData.getWin(); int delta = (challengesPlayed * mul) - questData.getWin();
return (delta > 0) ? delta : 0; return (delta > 0) ? delta : 0;
} }
@@ -679,8 +679,8 @@ public class QuestMainPanel extends QuestAbstractPanel {
Constant.Runtime.Smooth[0] = smoothLandCheckBox.isSelected(); Constant.Runtime.Smooth[0] = smoothLandCheckBox.isSelected();
AllZone.getMatchState().reset(); AllZone.getMatchState().reset();
if (isShowingQuests) { if (isShowingChallenges) {
setupQuest(humanDeck); setupChallenge(humanDeck);
} else { } else {
setupDuel(humanDeck); setupDuel(humanDeck);
} }
@@ -706,17 +706,17 @@ public class QuestMainPanel extends QuestAbstractPanel {
} }
/** /**
* <p>setupQuest.</p> * <p>setupChallenge.</p>
* *
* @param humanDeck a {@link forge.deck.Deck} object. * @param humanDeck a {@link forge.deck.Deck} object.
*/ */
private void setupQuest(Deck humanDeck) { private void setupChallenge(Deck humanDeck) {
QuestQuest selectedQuest = (QuestQuest)selectedOpponent.getEvent(); QuestChallenge selectedChallenge = (QuestChallenge)selectedOpponent.getEvent();
Deck computer = selectedOpponent.getEvent().getEventDeck(); Deck computer = selectedOpponent.getEvent().getEventDeck();
Constant.Runtime.ComputerDeck[0] = computer; Constant.Runtime.ComputerDeck[0] = computer;
AllZone.setQuestQuest(selectedQuest); AllZone.setQuestChallenge(selectedChallenge);
int extraLife = 0; int extraLife = 0;
@@ -725,8 +725,8 @@ public class QuestMainPanel extends QuestAbstractPanel {
} }
AllZone.getGameAction().newGame(humanDeck, computer, AllZone.getGameAction().newGame(humanDeck, computer,
forge.quest.data.QuestUtil.getHumanStartingCards(questData, selectedQuest), new CardList(), forge.quest.data.QuestUtil.getHumanStartingCards(questData, selectedChallenge), new CardList(),
questData.getLife() + extraLife, selectedQuest.getAILife(), selectedQuest); questData.getLife() + extraLife, selectedChallenge.getAILife(), selectedChallenge);
} }
@@ -740,15 +740,15 @@ public class QuestMainPanel extends QuestAbstractPanel {
} }
/** /**
* <p>showQuests.</p> * <p>showChallenges.</p>
*/ */
void showQuests() { void showChallenges() {
if (isShowingQuests) { if (isShowingChallenges) {
isShowingQuests = false; isShowingChallenges = false;
questButton.setText("Quests"); eventButton.setText("Challenges");
} else { } else {
isShowingQuests = true; isShowingChallenges = true;
questButton.setText("Battles"); eventButton.setText("Duels");
} }
if (selectedOpponent != null) { if (selectedOpponent != null) {

View File

@@ -13,7 +13,7 @@ import java.util.List;
* deck, and quest-specific properties. * deck, and quest-specific properties.
* *
*/ */
public class QuestQuest extends QuestEvent { public class QuestChallenge extends QuestEvent {
// ID (default -1, should be explicitly set at later time.) // ID (default -1, should be explicitly set at later time.)
public int id = -1; public int id = -1;

View File

@@ -8,25 +8,25 @@ package forge.quest.gui.main;
*/ */
@SuppressWarnings("serial") @SuppressWarnings("serial")
public class QuestQuestPanel extends QuestSelectablePanel { public class QuestChallengePanel extends QuestSelectablePanel {
//private JLabel repeatabilityLabel; //private JLabel repeatabilityLabel;
/** <p>QuestQuestPanel.</p> /** <p>QuestChallengePanel.</p>
* Constructor, using quest data instance. * Constructor, using challenge data instance.
* *
* @param {@link forge.quest.gui.main.QuestDuel} * @param {@link forge.quest.gui.main.QuestChallenge}
*/ */
public QuestQuestPanel(QuestQuest q) { public QuestChallengePanel(QuestChallenge q) {
super(q); super(q);
// Repeatability is currently meaningless. // Repeatability is currently meaningless.
// Can be added here later if necessary. // Can be added here later if necessary.
/* /*
* if (q.getRepeatable()) { * if (q.getRepeatable()) {
repeatabilityLabel = new JLabel("This quest is repeatable"); repeatabilityLabel = new JLabel("This challenge is repeatable");
} else { } else {
repeatabilityLabel = new JLabel("This quest is not repeatable"); repeatabilityLabel = new JLabel("This challenge is not repeatable");
} }
super.rootPanel.add(repeatabilityLabel); super.rootPanel.add(repeatabilityLabel);

View File

@@ -28,17 +28,16 @@ public class QuestEventManager {
public List<QuestDuel> hardAIduels = null; public List<QuestDuel> hardAIduels = null;
public List<QuestDuel> veryHardAIduels = null; public List<QuestDuel> veryHardAIduels = null;
public List<QuestDuel> allDuels = null; public List<QuestDuel> allDuels = null;
public List<QuestQuest> allQuests = null; public List<QuestChallenge> allChallenges = null;
/**<p>assembleAllEvents.</p> * /**<p>assembleAllEvents.</p> *
* Reads all quest and battle files to extract quest data. * Reads all duel and challenge files and instantiates all events,
* Instantiates all duel and quest events, and difficulty lists accordingly. * and difficulty lists accordingly. Should be used sparingly.
* Should be used sparingly.
*/ */
public void assembleAllEvents() { public void assembleAllEvents() {
this.allDuels = new ArrayList<QuestDuel>(); this.allDuels = new ArrayList<QuestDuel>();
this.allQuests = new ArrayList<QuestQuest>(); this.allChallenges = new ArrayList<QuestChallenge>();
List<String> contents; List<String> contents;
QuestEvent tempEvent; QuestEvent tempEvent;
@@ -53,9 +52,9 @@ public class QuestEventManager {
contents = FileUtil.readFile(f); contents = FileUtil.readFile(f);
if(contents.get(0).trim().equals("[quest]")) { if(contents.get(0).trim().equals("[quest]")) {
tempEvent = new QuestQuest(); tempEvent = new QuestChallenge();
assembleQuestUniquedata(contents,(QuestQuest)tempEvent); assembleChallengeUniquedata(contents,(QuestChallenge)tempEvent);
allQuests.add((QuestQuest)tempEvent); allChallenges.add((QuestChallenge)tempEvent);
} // End if([quest]) } // End if([quest])
else { else {
tempEvent = new QuestDuel(); tempEvent = new QuestDuel();
@@ -99,13 +98,13 @@ public class QuestEventManager {
} }
/** /**
* <p>assembleQuestUniquedata.</p> * <p>assembleChallengeUniquedata.</p>
* Handler for any unique data contained in quest files. * Handler for any unique data contained in a challenge file.
* *
* @param contents * @param contents
* @param qq * @param qc
*/ */
private void assembleQuestUniquedata(List<String> contents, QuestQuest qq) { private void assembleChallengeUniquedata(List<String> contents, QuestChallenge qc) {
int eqpos; int eqpos;
String key, value; String key, value;
@@ -120,23 +119,23 @@ public class QuestEventManager {
value = s.substring(eqpos + 1).trim(); value = s.substring(eqpos + 1).trim();
if (key.equalsIgnoreCase("ID")) { if (key.equalsIgnoreCase("ID")) {
qq.id = Integer.parseInt(value); qc.id = Integer.parseInt(value);
} }
else if (key.equalsIgnoreCase("Repeat")) { else if (key.equalsIgnoreCase("Repeat")) {
qq.repeatable = Boolean.parseBoolean(value); qc.repeatable = Boolean.parseBoolean(value);
} }
else if (key.equalsIgnoreCase("AILife")) { else if (key.equalsIgnoreCase("AILife")) {
qq.aiLife = Integer.parseInt(value); qc.aiLife = Integer.parseInt(value);
} }
else if (key.equalsIgnoreCase("Wins")) { else if (key.equalsIgnoreCase("Wins")) {
qq.winsReqd = Integer.parseInt(value); qc.winsReqd = Integer.parseInt(value);
} }
else if (key.equalsIgnoreCase("Credit Reward")) { else if (key.equalsIgnoreCase("Credit Reward")) {
qq.creditsReward = Integer.parseInt(value); qc.creditsReward = Integer.parseInt(value);
} }
else if (key.equalsIgnoreCase("Card Reward")) { else if (key.equalsIgnoreCase("Card Reward")) {
qq.cardReward = value; qc.cardReward = value;
qq.cardRewardList = QuestUtil.generateCardRewardList(value); qc.cardRewardList = QuestUtil.generateCardRewardList(value);
} }
// Human extra card list assembled here. // Human extra card list assembled here.
else if(key.equalsIgnoreCase("HumanExtras") && !value.equals("")) { else if(key.equalsIgnoreCase("HumanExtras") && !value.equals("")) {
@@ -147,7 +146,7 @@ public class QuestEventManager {
templist.add(readExtraCard(n, AllZone.getHumanPlayer())); templist.add(readExtraCard(n, AllZone.getHumanPlayer()));
} }
qq.humanExtraCards = templist; qc.humanExtraCards = templist;
} }
// AI extra card list assembled here. // AI extra card list assembled here.
else if(key.equalsIgnoreCase("AIExtras") && !value.equals("")) { else if(key.equalsIgnoreCase("AIExtras") && !value.equals("")) {
@@ -158,12 +157,12 @@ public class QuestEventManager {
templist.add(readExtraCard(n, AllZone.getComputerPlayer())); templist.add(readExtraCard(n, AllZone.getComputerPlayer()));
} }
qq.aiExtraCards = templist; qc.aiExtraCards = templist;
} }
// Card reward list assembled here. // Card reward list assembled here.
else if(key.equalsIgnoreCase("Card Reward")) { else if(key.equalsIgnoreCase("Card Reward")) {
qq.cardReward = value; qc.cardReward = value;
qq.cardRewardList = QuestUtil.generateCardRewardList(value); qc.cardRewardList = QuestUtil.generateCardRewardList(value);
} }
} }
} }
@@ -246,13 +245,13 @@ public class QuestEventManager {
} }
/** /**
* <p>getAllQuests.</p> * <p>getAllChallenges.</p>
* Returns complete list of all quest objects. * Returns complete list of all challenge objects.
* *
* @return a {@link java.util.List} object. * @return a {@link java.util.List} object.
*/ */
public List<QuestQuest> getAllQuests() { public List<QuestChallenge> getAllChallenges() {
return this.allQuests; return this.allChallenges;
} }
/** /**
@@ -300,10 +299,19 @@ public class QuestEventManager {
return deckListCopy.get(n); return deckListCopy.get(n);
} }
private QuestQuest getQuestOpponentByNumber(int n) { /**
for(QuestQuest qq : allQuests) { * <p>getChallengeOpponentByNumber.</p>
if(qq.getId()==n) { * Returns specific challenge event using its ID.
return qq; * This is to make sure that the opponents do not change
* when the deck editor is launched.
*
* @param n
* @return
*/
private QuestChallenge getChallengeEventByNumber(int n) {
for(QuestChallenge qc : allChallenges) {
if(qc.getId()==n) {
return qc;
} }
} }
return null; return null;
@@ -358,51 +366,51 @@ public class QuestEventManager {
} }
/** /**
* <p>generateQuests.</p> * <p>generateChallenges.</p>
* Generates an array of new quest opponents based on current win conditions. * Generates an array of new challenge opponents based on current win conditions.
* *
* @return a {@link java.util.List} object. * @return a {@link java.util.List} object.
*/ */
public List<QuestQuest> generateQuests() { public List<QuestChallenge> generateChallenges() {
forge.quest.data.QuestData questData = AllZone.getQuestData(); forge.quest.data.QuestData questData = AllZone.getQuestData();
List<QuestQuest> questOpponents = new ArrayList<QuestQuest>(); List<QuestChallenge> challengeOpponents = new ArrayList<QuestChallenge>();
int maxQuests = questData.getWin() / 10; int maxChallenges = questData.getWin() / 10;
if (maxQuests > 5) { if (maxChallenges > 5) {
maxQuests = 5; maxChallenges = 5;
} }
// Generate IDs as needed. // Generate IDs as needed.
if (questData.getAvailableQuests() == null || if (questData.getAvailableChallenges() == null ||
questData.getAvailableQuests().size() < maxQuests) { questData.getAvailableChallenges().size() < maxChallenges) {
List<Integer> unlockedQuestIds = new ArrayList<Integer>(); List<Integer> unlockedChallengeIds = new ArrayList<Integer>();
List<Integer> availableQuestIds = new ArrayList<Integer>(); List<Integer> availableChallengeIds = new ArrayList<Integer>();
for(QuestQuest qq : allQuests) { for(QuestChallenge qc : allChallenges) {
if (qq.getWinsReqd() <= questData.getWin() && if (qc.getWinsReqd() <= questData.getWin() &&
!questData.getCompletedQuests().contains(qq.getId())) { !questData.getCompletedChallenges().contains(qc.getId())) {
unlockedQuestIds.add(qq.getId()); unlockedChallengeIds.add(qc.getId());
} }
} }
Collections.shuffle(unlockedQuestIds); Collections.shuffle(unlockedChallengeIds);
for (int i = 0; i < maxQuests; i++) { for (int i = 0; i < maxChallenges; i++) {
availableQuestIds.add(unlockedQuestIds.get(i)); availableChallengeIds.add(unlockedChallengeIds.get(i));
} }
questData.setAvailableQuests(availableQuestIds); questData.setAvailableChallenges(availableChallengeIds);
questData.saveData(); questData.saveData();
} }
// Finally, pull quest events from available IDs and return. // Finally, pull challenge events from available IDs and return.
for(int i : questData.getAvailableQuests()) { for(int i : questData.getAvailableChallenges()) {
questOpponents.add(getQuestOpponentByNumber(i)); challengeOpponents.add(getChallengeEventByNumber(i));
} }
return questOpponents; return challengeOpponents;
} }
} }