mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-18 19:58:00 +00:00
NOTE: A commit with errors was apparently pushed previous to mine. As a result, my work has been broken also, and will unfortunately take some time to fix. The functionality described below will eventually work.
===== Big commit: Restructured Quest quests to use dck files. This required changes in many places. Among other things: - Model and view separated for quest main panel items - Quests and battles all generated from dck files - dck files all updated to contain metadata, main, sideboard - Quest dck files updated to contain [ai_extra_cards] and [human_extra_cards]
This commit is contained in:
@@ -17,6 +17,7 @@ import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants;
|
||||
import forge.quest.data.QuestMatchState;
|
||||
import forge.quest.data.QuestData;
|
||||
import forge.quest.data.DeckSingleQuest;
|
||||
|
||||
/**
|
||||
* Please use public getters and setters instead of direct field access.
|
||||
@@ -40,9 +41,9 @@ public final class AllZone implements NewConstants {
|
||||
|
||||
/** Global <code>questData</code>. */
|
||||
private static forge.quest.data.QuestData questData = null;
|
||||
|
||||
/** Global <code>QuestAssignment</code>. */
|
||||
private static Quest_Assignment questAssignment = null;
|
||||
|
||||
/** Global <code>currentQuest</code>. */
|
||||
private static forge.quest.data.DeckSingleQuest currentQuest = null;
|
||||
|
||||
/** Constant <code>NAME_CHANGER</code>. */
|
||||
private static final NameChanger NAME_CHANGER = new NameChanger();
|
||||
@@ -129,25 +130,25 @@ public final class AllZone implements NewConstants {
|
||||
public static void setQuestData(final QuestData questData0) {
|
||||
questData = questData0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getQuestAssignment.</p>
|
||||
* <p>getCurrentQuest.</p>
|
||||
*
|
||||
* @return a {@link forge.Quest_Assignment} object.
|
||||
* @since 1.0.15
|
||||
* @return a {@link forge.quest.data.QuestData} object.
|
||||
*
|
||||
*/
|
||||
public static Quest_Assignment getQuestAssignment() {
|
||||
return questAssignment;
|
||||
public static forge.quest.data.DeckSingleQuest getCurrentQuest() {
|
||||
return currentQuest;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>setQuestAssignment.</p>
|
||||
* <p>setCurrentQuest.</p>
|
||||
*
|
||||
* @param assignment a {@link forge.Quest_Assignment} object.
|
||||
* @since 1.0.15
|
||||
* @param a DeckSingleQuest object.
|
||||
*
|
||||
*/
|
||||
public static void setQuestAssignment(final Quest_Assignment assignment) {
|
||||
questAssignment = assignment;
|
||||
public static void setCurrentQuest(final DeckSingleQuest qq) {
|
||||
currentQuest = qq;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
43
src/main/java/forge/gui/SelectablePanel.java
Normal file
43
src/main/java/forge/gui/SelectablePanel.java
Normal file
@@ -0,0 +1,43 @@
|
||||
package forge.gui;
|
||||
|
||||
import java.awt.Color;
|
||||
|
||||
import javax.swing.JPanel;
|
||||
|
||||
|
||||
/**
|
||||
* <p>SelectablePanel</p>
|
||||
* VIEW - Standard selectable JPanel used for many places in the GUI.
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public abstract class SelectablePanel extends JPanel {
|
||||
|
||||
private boolean selected = false;
|
||||
protected Color backgroundColor = this.getBackground();
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>selected</code></p>
|
||||
*
|
||||
* @return boolean.
|
||||
*/
|
||||
public boolean getSelected() {
|
||||
return selected;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Setter for the field <code>selected</code></p>
|
||||
* Sets selected field and visual effect.
|
||||
*
|
||||
* @param boolean.
|
||||
*/
|
||||
public void setSelected(boolean selected) {
|
||||
if (selected) {
|
||||
this.setBackground(backgroundColor.darker());
|
||||
} else {
|
||||
this.setBackground(backgroundColor);
|
||||
}
|
||||
|
||||
this.selected = selected;
|
||||
}
|
||||
}
|
||||
116
src/main/java/forge/quest/data/DeckSingleBattle.java
Normal file
116
src/main/java/forge/quest/data/DeckSingleBattle.java
Normal file
@@ -0,0 +1,116 @@
|
||||
package forge.quest.data;
|
||||
|
||||
import javax.swing.ImageIcon;
|
||||
import forge.deck.Deck;
|
||||
import forge.gui.GuiUtils;
|
||||
|
||||
/**
|
||||
* <p>DeckSingleBattle</p>
|
||||
* MODEL - Assembles and stores information from a battle deck.
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DeckSingleBattle {
|
||||
private String deckName;
|
||||
private String displayName;
|
||||
private String diff;
|
||||
private String desc;
|
||||
private String iconFilename;
|
||||
private ImageIcon icon;
|
||||
private Deck deckObj;
|
||||
|
||||
/**
|
||||
* <p>Constructor for DeckSingleBattle.</p>
|
||||
*
|
||||
* @param {@link java.lang.String} storing name of AI deck for this battle
|
||||
*/
|
||||
public DeckSingleBattle(Deck d) {
|
||||
// Get deck object and properties for this opponent.
|
||||
this.deckObj = d;
|
||||
this.deckName = d.getName();
|
||||
this.displayName = deckObj.getMetadata("DisplayName");
|
||||
this.diff = deckObj.getMetadata("Difficulty");
|
||||
this.desc = deckObj.getMetadata("Description");
|
||||
this.iconFilename = deckObj.getMetadata("Icon");
|
||||
|
||||
// Default icon
|
||||
this.icon = GuiUtils.getIconFromFile(displayName + ".jpg");
|
||||
|
||||
// If non-default icon defined, use it. Any filetype accepted.
|
||||
if(!iconFilename.equals("")) {
|
||||
this.icon = GuiUtils.getIconFromFile(iconFilename);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDifficulty()</p>
|
||||
* Retrieve rated difficulty of this battle deck.
|
||||
*
|
||||
* @return {@link java.lang.String}
|
||||
*/
|
||||
public String getDifficulty() {
|
||||
return this.diff;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDescription()</p>
|
||||
* Retrieve description of this battle deck.
|
||||
*
|
||||
* @return {@link java.lang.String}
|
||||
*/
|
||||
public String getDescription() {
|
||||
return this.desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDisplayName()</p>
|
||||
* Retrieve display name of this battle deck.
|
||||
*
|
||||
* @return {@link java.lang.String}
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDeckName()</p>
|
||||
* Retrieve file name of this battle deck.
|
||||
*
|
||||
* @return {@link java.lang.String}
|
||||
*/
|
||||
public String getDeckName() {
|
||||
return this.deckName;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getIconFilename()</p>
|
||||
* Retrieve file name of preferred icon
|
||||
*
|
||||
* @return {@link java.lang.String}
|
||||
*/
|
||||
public String getIconFilename() {
|
||||
return this.iconFilename;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDeck()</p>
|
||||
* Retrieve this battle deck.
|
||||
*
|
||||
* @return {@link java.lang.String}
|
||||
*/
|
||||
public Deck getDeck() {
|
||||
return this.deckObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getIcon()</p>
|
||||
* Retrieve the icon used with this battle deck.
|
||||
*
|
||||
* @return {@link java.lang.String}
|
||||
*/
|
||||
public ImageIcon getIcon() {
|
||||
return this.icon;
|
||||
}
|
||||
|
||||
}
|
||||
270
src/main/java/forge/quest/data/DeckSingleQuest.java
Normal file
270
src/main/java/forge/quest/data/DeckSingleQuest.java
Normal file
@@ -0,0 +1,270 @@
|
||||
package forge.quest.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import javax.swing.ImageIcon;
|
||||
|
||||
import com.google.code.jyield.Generator;
|
||||
import com.google.code.jyield.YieldUtils;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.Card;
|
||||
import forge.Constant;
|
||||
import forge.deck.Deck;
|
||||
import forge.gui.GuiUtils;
|
||||
|
||||
/**
|
||||
* <p>DeckSingleQuest</p>
|
||||
* MODEL - Assembles and stores information from a quest deck.
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class DeckSingleQuest {
|
||||
private String deckName;
|
||||
private String displayName;
|
||||
private String diff;
|
||||
private String desc;
|
||||
private String iconFilename;
|
||||
private String cardReward;
|
||||
|
||||
private int creditsReward;
|
||||
private int numberWinsRequired;
|
||||
private int AILife;
|
||||
private int id;
|
||||
|
||||
private boolean repeatable;
|
||||
private ImageIcon icon;
|
||||
private Deck deckObj;
|
||||
|
||||
/**
|
||||
* <p>Constructor for DeckSingleQuest</p>
|
||||
*
|
||||
* @param {@link java.lang.String} storing name of AI deck for this quest
|
||||
*/
|
||||
public DeckSingleQuest(Deck d) {
|
||||
// Get deck object and properties for this opponent.
|
||||
this.deckObj = d;
|
||||
this.deckName = d.getName();
|
||||
this.id = Integer.parseInt(deckObj.getMetadata("ID"));
|
||||
this.displayName = deckObj.getMetadata("DisplayName");
|
||||
this.diff = deckObj.getMetadata("Difficulty");
|
||||
this.desc = deckObj.getMetadata("Description");
|
||||
this.iconFilename = deckObj.getMetadata("Icon");
|
||||
this.cardReward = deckObj.getMetadata("CardReward");
|
||||
this.creditsReward = Integer.parseInt(deckObj.getMetadata("CreditsReward"));
|
||||
this.numberWinsRequired = Integer.parseInt(deckObj.getMetadata("NumberWinsRequired"));
|
||||
this.AILife = Integer.parseInt(deckObj.getMetadata("AILife"));
|
||||
|
||||
// Default icon
|
||||
this.icon = GuiUtils.getIconFromFile(displayName + ".jpg");
|
||||
|
||||
// If non-default icon defined, use it. Any filetype accepted.
|
||||
if(!iconFilename.equals("")) {
|
||||
this.icon = GuiUtils.getIconFromFile(iconFilename);
|
||||
}
|
||||
|
||||
// Repeatability test
|
||||
if(deckObj.getMetadata("Repeatable").equals("true")) {
|
||||
this.repeatable = true;
|
||||
}
|
||||
else {
|
||||
this.repeatable = false;
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getID()</p>
|
||||
* Retrieve ID number of this quest deck for recordkeeping.
|
||||
*
|
||||
* @return {@link java.lang.int}
|
||||
*/
|
||||
public int getID() {
|
||||
return this.id;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDifficulty()</p>
|
||||
* Retrieve rated difficulty of this quest deck.
|
||||
*
|
||||
* @return {@link java.lang.String}
|
||||
*/
|
||||
public String getDifficulty() {
|
||||
return this.diff;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDescription()</p>
|
||||
* Retrieve description of this quest deck.
|
||||
*
|
||||
* @return {@link java.lang.String}
|
||||
*/
|
||||
public String getDescription() {
|
||||
return this.desc;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDisplayName()</p>
|
||||
* Retrieve display name of this quest deck.
|
||||
*
|
||||
* @return {@link java.lang.String}
|
||||
*/
|
||||
public String getDisplayName() {
|
||||
return this.displayName;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDeckName()</p>
|
||||
* Retrieve file name of this quest deck.
|
||||
*
|
||||
* @return {@link java.lang.String}
|
||||
*/
|
||||
public String getDeckName() {
|
||||
return this.deckName;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getCardReward()</p>
|
||||
* Retrieve cards rewarded after a win with this quest deck.
|
||||
*
|
||||
* @return {@link java.lang.String}
|
||||
*/
|
||||
private String getCardReward() {
|
||||
return this.cardReward;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getCardRewardList()</p>
|
||||
* Retrieve cards rewarded after a win with this quest deck.
|
||||
*
|
||||
* @return String[]
|
||||
*/
|
||||
public ArrayList<String> getCardRewardList() {
|
||||
ArrayList<String> cardRewardList = new ArrayList<String>();
|
||||
|
||||
String[] details = this.getCardReward().split(" ");
|
||||
|
||||
// Set quantity, color and rarity from file meta.
|
||||
String cardscolor;
|
||||
Constant.Rarity rarity;
|
||||
int quantity = Integer.parseInt(details[0]);
|
||||
|
||||
// Color
|
||||
if(details[1].toLowerCase().equals("random")) {
|
||||
cardscolor = null;
|
||||
}
|
||||
else if(details[1].toLowerCase().equals("blue")) {
|
||||
cardscolor = Constant.Color.Blue;
|
||||
}
|
||||
else if(details[1].toLowerCase().equals("black")) {
|
||||
cardscolor = Constant.Color.Black;
|
||||
}
|
||||
else if(details[1].toLowerCase().equals("green")) {
|
||||
cardscolor = Constant.Color.Green;
|
||||
}
|
||||
else if(details[1].toLowerCase().equals("red")) {
|
||||
cardscolor = Constant.Color.Red;
|
||||
}
|
||||
else if(details[1].toLowerCase().equals("white")) {
|
||||
cardscolor = Constant.Color.White;
|
||||
}
|
||||
else if(details[1].toLowerCase().equals("multi-color") ||
|
||||
details[1].toLowerCase().equals("multi-colored")) {
|
||||
cardscolor = "Multicolor";
|
||||
}
|
||||
else if(details[1].toLowerCase().equals("colorless")) {
|
||||
cardscolor = Constant.Color.Colorless;
|
||||
}
|
||||
else {
|
||||
cardscolor = null;
|
||||
System.err.println("DeckSingleQuest > getCardRewardList() reports "+
|
||||
"a badly formed card reward for quest "+
|
||||
this.getID()+".\n The color "+details[1]+" is not permitted.\n"+
|
||||
"Random colors have been substituted.");
|
||||
}
|
||||
|
||||
// Rarity
|
||||
if(details[2].toLowerCase().equals("rares")) {
|
||||
rarity = Constant.Rarity.Rare;
|
||||
}
|
||||
else {
|
||||
rarity = Constant.Rarity.Common;
|
||||
}
|
||||
|
||||
// Generate deck list.
|
||||
QuestBoosterPack pack = new QuestBoosterPack();
|
||||
pack.generateCards(quantity, rarity, cardscolor);
|
||||
|
||||
return cardRewardList;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getNumberWinsRequired()</p>
|
||||
* Retrieve number of wins required to play against this quest deck.
|
||||
*
|
||||
* @return {@link java.lang.int}
|
||||
*/
|
||||
public int getNumberWinsRequired() {
|
||||
return this.numberWinsRequired;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getAILife()</p>
|
||||
* Retrieve starting value of life for the AI playing this quest deck.
|
||||
*
|
||||
* @return {@link java.lang.int}
|
||||
*/
|
||||
public int getAILife() {
|
||||
return this.AILife;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getCreditsReward()</p>
|
||||
* Retrieve number of credits rewarded after a win against this quest deck.
|
||||
*
|
||||
* @return {@link java.lang.int}
|
||||
*/
|
||||
public int getCreditsReward() {
|
||||
return this.creditsReward;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDeck()</p>
|
||||
* Retrieve this quest deck.
|
||||
*
|
||||
* @return {@link forge.deck.Deck}
|
||||
*/
|
||||
public Deck getDeck() {
|
||||
return this.deckObj;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getIconFilename()</p>
|
||||
* Retrieve file name of preferred icon
|
||||
*
|
||||
* @return {@link java.lang.String}
|
||||
*/
|
||||
public String getIconFilename() {
|
||||
return this.iconFilename;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getIcon()</p>
|
||||
* Retrieve the icon used with this quest deck.
|
||||
*
|
||||
* @return {@link javax.swing.ImageIcon}
|
||||
*/
|
||||
public ImageIcon getIcon() {
|
||||
return this.icon;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getRepeatable.</p>
|
||||
* Retrieve boolean indicating if this quest is repeatable.
|
||||
*
|
||||
*/
|
||||
public boolean getRepeatable() {
|
||||
return this.repeatable;
|
||||
}
|
||||
|
||||
}
|
||||
237
src/main/java/forge/quest/data/ManagerBattle.java
Normal file
237
src/main/java/forge/quest/data/ManagerBattle.java
Normal file
@@ -0,0 +1,237 @@
|
||||
package forge.quest.data;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.FileUtil;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckManager;
|
||||
import forge.error.ErrorViewer;
|
||||
import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>QuestBattleManager</p>
|
||||
* MODEL - Provides static methods to accomplish two key tasks:
|
||||
* 1. Stores various AI difficulty decks and generates opponent list based on quest record.
|
||||
*
|
||||
* 2. Can instantiate a DeckSingleBattle for each opponent in the list.
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
|
||||
// This could be combined with BattleManager and moved into QuestUtil.
|
||||
public class ManagerBattle {
|
||||
/** Constant <code>aiDecks</code> */
|
||||
private static transient Map<String, Deck> aiDecks = new HashMap<String, Deck>();
|
||||
/** Constant <code>easyAIDecks</code> */
|
||||
private static transient List<String> easyAIDecks;
|
||||
/** Constant <code>mediumAIDecks</code> */
|
||||
private static transient List<String> mediumAIDecks;
|
||||
/** Constant <code>hardAIDecks</code> */
|
||||
private static transient List<String> hardAIDecks;
|
||||
/** Constant <code>veryHardAIDecks</code> */
|
||||
private static transient List<String> veryHardAIDecks;
|
||||
|
||||
static {
|
||||
List<String> aiDeckNames = getAIDeckNames();
|
||||
easyAIDecks = readFile(ForgeProps.getFile(NewConstants.QUEST.EASY), aiDeckNames);
|
||||
mediumAIDecks = readFile(ForgeProps.getFile(NewConstants.QUEST.MEDIUM), aiDeckNames);
|
||||
hardAIDecks = readFile(ForgeProps.getFile(NewConstants.QUEST.HARD), aiDeckNames);
|
||||
veryHardAIDecks = readFile(ForgeProps.getFile(NewConstants.QUEST.VERYHARD), aiDeckNames);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>removeAIDeck.</p>
|
||||
* Removes a deck object stored in the
|
||||
*{@link forge.quest.gui.main.aiDecks} map.
|
||||
*
|
||||
* @param deckName a {@link java.lang.String} object.
|
||||
*/
|
||||
public static void removeAIDeck(String deckName) {
|
||||
aiDecks.remove(deckName);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>addAIDeck.</p>
|
||||
* Adds a deck object stored in the
|
||||
*{@link forge.quest.gui.main.aiDecks} map.
|
||||
*
|
||||
* @param d a {@link forge.deck.Deck} object.
|
||||
*/
|
||||
public static void addAIDeck(Deck d) {
|
||||
aiDecks.put(d.getName(), d);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getAIDeckFromMap.</p>
|
||||
* Returns a deck object stored in the
|
||||
*{@link forge.quest.gui.main.aiDecks} map.
|
||||
*
|
||||
* @param deckName a {@link java.lang.String} object.
|
||||
* @return a {@link forge.deck.Deck} object.
|
||||
*/
|
||||
public static Deck getAIDeckFromMap(String deckName) {
|
||||
if (!aiDecks.containsKey(deckName)) {
|
||||
ErrorViewer.showError(new Exception(),
|
||||
"QuestData : getAIDeckFromMap(String deckName) error, deck name not found - %s", deckName);
|
||||
}
|
||||
|
||||
return aiDecks.get(deckName);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getAIDeckNames.</p>
|
||||
* Returns a list of decks stored in the
|
||||
* {@link forge.quest.gui.main.aiDecks} map.
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public static List<String> getAIDeckNames() {
|
||||
return new ArrayList<String>(aiDecks.keySet());
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDeckFromFile.</p>
|
||||
* Returns a deck object built from a file name.
|
||||
* Req'd because NewConstants.QUEST.DECKS must be used.
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getOpponent.</p>
|
||||
*
|
||||
* Poorly named; AllZoneUtil already has a method called getOpponents.
|
||||
* ????? Mechanics of this still a mystery ?????
|
||||
*
|
||||
* @param aiDeck a {@link java.util.List} object.
|
||||
* @param number a int.
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public static String getOpponent(List<String> aiDeck, int number) {
|
||||
//This is to make sure that the opponents do not change when the deck editor is launched.
|
||||
List<String> deckListCopy = new ArrayList<String>(aiDeck);
|
||||
Collections.shuffle(deckListCopy, new Random(AllZone.getQuestData().getRandomSeed()));
|
||||
|
||||
return deckListCopy.get(number);
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>generateBattles.</p>
|
||||
* 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)};
|
||||
} // End generateBattles()
|
||||
|
||||
/**
|
||||
* <p>readFile.</p>
|
||||
* 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 List<String> readFile(File file, List<String> aiDecks) {
|
||||
ArrayList<String> list = FileUtil.readFile(file);
|
||||
|
||||
//remove any blank lines
|
||||
ArrayList<String> noBlankLines = new ArrayList<String>();
|
||||
String s;
|
||||
for (String aList : list) {
|
||||
s = aList.trim();
|
||||
if (!s.equals("")) {
|
||||
noBlankLines.add(s);
|
||||
}
|
||||
}
|
||||
list = noBlankLines;
|
||||
|
||||
if (list.size() < 3) {
|
||||
ErrorViewer.showError(new Exception(),
|
||||
"QuestData : readFile() error, file %s is too short, it must contain at least 3 ai deck names",
|
||||
file);
|
||||
}
|
||||
|
||||
for (String aList : list) {
|
||||
if (!aiDecks.contains(aList)) {
|
||||
aiDecks.add(aList);
|
||||
}
|
||||
}
|
||||
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getBattles.</p>
|
||||
*
|
||||
* Returns list of DeckSingleBattle objects storing data
|
||||
* of the battles currently available.
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public static List<DeckSingleBattle> getBattles() {
|
||||
List<DeckSingleBattle> battlesAvailable = new ArrayList<DeckSingleBattle>();
|
||||
|
||||
String[] oppDecks = ManagerBattle.generateBattles();
|
||||
|
||||
for (String oppDeckName : oppDecks) {
|
||||
battlesAvailable.add(new DeckSingleBattle(getAIDeckFromFile(oppDeckName)));
|
||||
}
|
||||
|
||||
return battlesAvailable;
|
||||
}
|
||||
|
||||
}
|
||||
104
src/main/java/forge/quest/data/ManagerQuest.java
Normal file
104
src/main/java/forge/quest/data/ManagerQuest.java
Normal file
@@ -0,0 +1,104 @@
|
||||
package forge.quest.data;
|
||||
|
||||
import java.io.File;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.List;
|
||||
|
||||
import forge.AllZone;
|
||||
import forge.deck.Deck;
|
||||
import forge.deck.DeckManager;
|
||||
import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants;
|
||||
|
||||
|
||||
/**
|
||||
* <p>ManagerQuest</p>
|
||||
* MODEL - Provides static methods to work with quest-related tasks.
|
||||
*
|
||||
*/
|
||||
|
||||
// This could be combined with BattleManager and moved into QuestUtil?
|
||||
public class ManagerQuest {
|
||||
/**
|
||||
* <p>getQuests</p>
|
||||
*
|
||||
* Returns list of DeckSingleQuest objects storing data
|
||||
* of the quests currently available.
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
|
||||
public static List<DeckSingleQuest> getQuests() {
|
||||
QuestData questData = AllZone.getQuestData();
|
||||
|
||||
List<Integer> idsCompleted = questData.getCompletedQuests();
|
||||
List<Integer> idsAvailable = new ArrayList<Integer>();
|
||||
List<DeckSingleQuest> allQuests = new ArrayList<DeckSingleQuest>();
|
||||
List<DeckSingleQuest> questsAvailable = new ArrayList<DeckSingleQuest>();
|
||||
|
||||
// Generate DeckSingleQuest objects for available quest IDs.
|
||||
// If there are quests IDs available, use them.
|
||||
if (questData.getAvailableQuests() != null && questData.getAvailableQuests().size() > 0) {
|
||||
idsAvailable = questData.getAvailableQuests();
|
||||
for (int id : idsAvailable) {
|
||||
questsAvailable.add(new DeckSingleQuest(getAIDeckFromFile("quest"+id)));
|
||||
}
|
||||
}
|
||||
// Otherwise, re-generate list.
|
||||
// To do this, each quest file must be opened and metadata examined.
|
||||
// DeckSingleQuest objects are grabbed directly from opened list.
|
||||
else {
|
||||
File[] files = ForgeProps.getFile(NewConstants.QUEST.DECKS).listFiles();
|
||||
|
||||
for(File f : files) {
|
||||
if(!f.isDirectory() && f.getName().substring(0,5).equals("quest")) {
|
||||
DeckSingleQuest temp = new DeckSingleQuest(getAIDeckFromFile(
|
||||
f.getName().substring(0, f.getName().lastIndexOf('.'))));
|
||||
|
||||
idsAvailable.add(temp.getID());
|
||||
if (temp.getNumberWinsRequired() <= questData.getWin() &&
|
||||
!idsCompleted.contains(temp.getID())) {
|
||||
allQuests.add(temp);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Limit available IDs.
|
||||
int maxQuests = questData.getWin() / 10;
|
||||
if (maxQuests > 5) {
|
||||
maxQuests = 5;
|
||||
}
|
||||
if (idsAvailable.size() < maxQuests) {
|
||||
maxQuests = idsAvailable.size();
|
||||
}
|
||||
|
||||
Collections.shuffle(idsAvailable);
|
||||
idsAvailable = idsAvailable.subList(0,maxQuests);
|
||||
|
||||
questData.setAvailableQuests(idsAvailable);
|
||||
questData.saveData();
|
||||
|
||||
for (int id : idsAvailable) {
|
||||
questsAvailable.add(allQuests.get(id));
|
||||
}
|
||||
}
|
||||
|
||||
return questsAvailable;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getDeckFromFile.</p>
|
||||
* Returns a deck object built from a file name.
|
||||
* Req'd because NewConstants.QUEST.DECKS must be used.
|
||||
*
|
||||
* @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);
|
||||
}
|
||||
}
|
||||
100
src/main/java/forge/quest/gui/PanelSingleBattle.java
Normal file
100
src/main/java/forge/quest/gui/PanelSingleBattle.java
Normal file
@@ -0,0 +1,100 @@
|
||||
package forge.quest.gui;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.CompoundBorder;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.border.LineBorder;
|
||||
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.gui.SelectablePanel;
|
||||
import forge.quest.data.DeckSingleBattle;
|
||||
|
||||
/**
|
||||
* <p>PanelSingleBattle</p>
|
||||
* VIEW - A selectable panel for battles available in Quest mode.
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class PanelSingleBattle extends SelectablePanel {
|
||||
|
||||
private final DeckSingleBattle battle;
|
||||
|
||||
public PanelSingleBattle(DeckSingleBattle b) {
|
||||
battle = b;
|
||||
final JPanel centerPanel = new JPanel();
|
||||
|
||||
this.setLayout(new BorderLayout(5, 5));
|
||||
|
||||
// Icon stuff
|
||||
JLabel iconLabel;
|
||||
|
||||
if (battle.getIcon() == null) {
|
||||
iconLabel = new JLabel(GuiUtils.getEmptyIcon(40, 40));
|
||||
} else {
|
||||
iconLabel = new JLabel(GuiUtils.getResizedIcon(battle.getIcon(), 40, 40));
|
||||
}
|
||||
|
||||
iconLabel.setBorder(new LineBorder(Color.BLACK));
|
||||
iconLabel.setAlignmentY(TOP_ALIGNMENT);
|
||||
|
||||
JPanel iconPanel = new JPanel(new BorderLayout());
|
||||
iconPanel.setOpaque(false);
|
||||
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);
|
||||
|
||||
JPanel centerTopPanel = new JPanel();
|
||||
centerTopPanel.setOpaque(false);
|
||||
centerTopPanel.setAlignmentX(LEFT_ALIGNMENT);
|
||||
centerTopPanel.setLayout(new BoxLayout(centerTopPanel, BoxLayout.X_AXIS));
|
||||
|
||||
JLabel nameLabel = new JLabel(battle.getDisplayName());
|
||||
GuiUtils.setFontSize(nameLabel, 20);
|
||||
nameLabel.setAlignmentY(BOTTOM_ALIGNMENT);
|
||||
centerTopPanel.add(nameLabel);
|
||||
|
||||
GuiUtils.addExpandingHorizontalSpace(centerTopPanel);
|
||||
|
||||
JLabel difficultyLabel = new JLabel(battle.getDifficulty());
|
||||
difficultyLabel.setAlignmentY(BOTTOM_ALIGNMENT);
|
||||
centerTopPanel.add(difficultyLabel);
|
||||
centerPanel.add(centerTopPanel);
|
||||
|
||||
GuiUtils.addGap(centerPanel);
|
||||
|
||||
JLabel descriptionLabel = new JLabel(battle.getDescription());
|
||||
descriptionLabel.setAlignmentX(LEFT_ALIGNMENT);
|
||||
centerPanel.add(descriptionLabel);
|
||||
|
||||
this.setMaximumSize(new Dimension(Integer.MAX_VALUE, 80));
|
||||
this.setBorder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder(5, 5, 5, 5)));
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getIconFilename()</p>
|
||||
* Retrieves filename of icon used in this panel's display.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getIconFilename() {
|
||||
return this.battle.getIconFilename();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getQuest()</p>
|
||||
*
|
||||
* @return the DeckSingleBattle model associated with this panel.
|
||||
*/
|
||||
public DeckSingleBattle getBattle() {
|
||||
return this.battle;
|
||||
}
|
||||
}
|
||||
110
src/main/java/forge/quest/gui/PanelSingleQuest.java
Normal file
110
src/main/java/forge/quest/gui/PanelSingleQuest.java
Normal file
@@ -0,0 +1,110 @@
|
||||
package forge.quest.gui;
|
||||
|
||||
import java.awt.BorderLayout;
|
||||
import java.awt.Color;
|
||||
import java.awt.Dimension;
|
||||
|
||||
import javax.swing.BoxLayout;
|
||||
import javax.swing.JLabel;
|
||||
import javax.swing.JPanel;
|
||||
import javax.swing.border.CompoundBorder;
|
||||
import javax.swing.border.EmptyBorder;
|
||||
import javax.swing.border.LineBorder;
|
||||
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.gui.SelectablePanel;
|
||||
import forge.quest.data.DeckSingleQuest;
|
||||
|
||||
/**
|
||||
* <p>PanelSingleQuest</p>
|
||||
* VIEW - A selectable panel for quests available in Quest mode.
|
||||
*
|
||||
*/
|
||||
@SuppressWarnings("serial")
|
||||
public class PanelSingleQuest extends SelectablePanel {
|
||||
|
||||
private final DeckSingleQuest quest;
|
||||
|
||||
public PanelSingleQuest(DeckSingleQuest q) {
|
||||
quest = q;
|
||||
final JPanel centerPanel = new JPanel();
|
||||
|
||||
this.setLayout(new BorderLayout(5, 5));
|
||||
|
||||
JLabel iconLabel;
|
||||
|
||||
if (quest.getIcon() == null) {
|
||||
iconLabel = new JLabel(GuiUtils.getEmptyIcon(40, 40));
|
||||
} else {
|
||||
iconLabel = new JLabel(GuiUtils.getResizedIcon(quest.getIcon(), 40, 40));
|
||||
}
|
||||
|
||||
iconLabel.setBorder(new LineBorder(Color.BLACK));
|
||||
iconLabel.setAlignmentY(TOP_ALIGNMENT);
|
||||
|
||||
JPanel iconPanel = new JPanel(new BorderLayout());
|
||||
iconPanel.setOpaque(false);
|
||||
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);
|
||||
|
||||
JPanel centerTopPanel = new JPanel();
|
||||
centerTopPanel.setOpaque(false);
|
||||
centerTopPanel.setAlignmentX(LEFT_ALIGNMENT);
|
||||
centerTopPanel.setLayout(new BoxLayout(centerTopPanel, BoxLayout.X_AXIS));
|
||||
|
||||
JLabel nameLabel = new JLabel(quest.getDisplayName());
|
||||
GuiUtils.setFontSize(nameLabel, 20);
|
||||
nameLabel.setAlignmentY(BOTTOM_ALIGNMENT);
|
||||
centerTopPanel.add(nameLabel);
|
||||
|
||||
GuiUtils.addExpandingHorizontalSpace(centerTopPanel);
|
||||
|
||||
JLabel difficultyLabel = new JLabel(quest.getDifficulty());
|
||||
difficultyLabel.setAlignmentY(BOTTOM_ALIGNMENT);
|
||||
centerTopPanel.add(difficultyLabel);
|
||||
centerPanel.add(centerTopPanel);
|
||||
|
||||
GuiUtils.addGap(centerPanel);
|
||||
|
||||
JLabel descriptionLabel = new JLabel(quest.getDescription());
|
||||
descriptionLabel.setAlignmentX(LEFT_ALIGNMENT);
|
||||
centerPanel.add(descriptionLabel);
|
||||
|
||||
// Temporarily removed; no meaning yet (all quests repeat anyway)
|
||||
/*JLabel repeatabilityLabel;
|
||||
if (quest.getRepeatable()) {
|
||||
repeatabilityLabel = new JLabel("This quest is repeatable");
|
||||
} else {
|
||||
repeatabilityLabel = new JLabel("This quest is not repeatable");
|
||||
}
|
||||
|
||||
GuiUtils.addGap(centerPanel);
|
||||
centerPanel.add(repeatabilityLabel);*/
|
||||
|
||||
this.setMaximumSize(new Dimension(Integer.MAX_VALUE, 80));
|
||||
this.setBorder(new CompoundBorder(new LineBorder(Color.BLACK), new EmptyBorder(5, 5, 5, 5)));
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getIconFilename()</p>
|
||||
* Retrieves filename of icon used in this panel's display.
|
||||
*
|
||||
* @return
|
||||
*/
|
||||
public String getIconFilename() {
|
||||
return this.quest.getIconFilename();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getQuest()</p>
|
||||
*
|
||||
* @return the DeckSingleQuest model associated with this panel.
|
||||
*/
|
||||
public DeckSingleQuest getQuest() {
|
||||
return this.quest;
|
||||
}
|
||||
}
|
||||
@@ -3,7 +3,6 @@ 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.view.swing.OldGuiNewGame;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
817
src/main/java/forge/quest/gui/QuestMainPanel.java
Normal file
817
src/main/java/forge/quest/gui/QuestMainPanel.java
Normal file
@@ -0,0 +1,817 @@
|
||||
package forge.quest.gui;
|
||||
|
||||
|
||||
import forge.*;
|
||||
import forge.deck.Deck;
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.gui.SelectablePanel;
|
||||
import forge.quest.data.DeckSingleBattle;
|
||||
import forge.quest.data.ManagerBattle;
|
||||
import forge.quest.data.QuestData;
|
||||
import forge.quest.data.DeckSingleQuest;
|
||||
import forge.quest.data.ManagerQuest;
|
||||
import forge.quest.data.item.QuestItemZeppelin;
|
||||
|
||||
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;
|
||||
|
||||
|
||||
/**
|
||||
* <p>QuestMainPanel class.</p>
|
||||
* VIEW - handler for main screen of Quest GUI.
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public class QuestMainPanel extends QuestAbstractPanel {
|
||||
/** Constant <code>serialVersionUID=6142934729724012402L</code> */
|
||||
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 SelectablePanel lastPanelSelected;
|
||||
|
||||
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 <code>NO_DECKS_AVAILABLE="No decks available"</code> */
|
||||
private static final String NO_DECKS_AVAILABLE = "No decks available";
|
||||
/** Constant <code>BATTLES="Battles"</code> */
|
||||
private static final String BATTLES = "Battles";
|
||||
/** Constant <code>QUESTS="Quests"</code> */
|
||||
private static final String QUESTS = "Quests";
|
||||
|
||||
//TODO: Make this ordering permanent
|
||||
/** Constant <code>lastUsedDeck="//TODO: Make this ordering permanent"</code> */
|
||||
private static String lastUsedDeck;
|
||||
private JButton zeppelinButton = new JButton("<html>Launch<br>Zeppelin</html>",
|
||||
GuiUtils.getResizedIcon(GuiUtils.getIconFromFile("ZeppelinIcon.png"), 40, 40));
|
||||
private JPanel zeppelinPanel = new JPanel();
|
||||
|
||||
/**
|
||||
* <p>Constructor for QuestMainPanel.</p>
|
||||
*
|
||||
* @param mainFrame a {@link forge.quest.gui.QuestFrame} object.
|
||||
*/
|
||||
public QuestMainPanel(QuestFrame mainFrame) {
|
||||
super(mainFrame);
|
||||
questData = AllZone.getQuestData();
|
||||
|
||||
initUI();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>initUI.</p>
|
||||
*/
|
||||
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));
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>createStatusPanel.</p>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>createSidePanel.</p>
|
||||
*
|
||||
* @return a {@link javax.swing.JPanel} object.
|
||||
*/
|
||||
private JPanel createSidePanel() {
|
||||
JPanel panel = new JPanel();
|
||||
JPanel optionsPanel; //Create options checkbox list
|
||||
optionsPanel = createOptionsPanel();
|
||||
|
||||
List<Component> eastComponents = new ArrayList<Component>();
|
||||
//Create buttons
|
||||
|
||||
JButton mainMenuButton = new JButton("Return to Main Menu");
|
||||
mainMenuButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
mainFrame.returnToMainMenu();
|
||||
}
|
||||
});
|
||||
eastComponents.add(mainMenuButton);
|
||||
|
||||
JButton cardShopButton = new JButton("Card Shop");
|
||||
cardShopButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
QuestMainPanel.this.showCardShop();
|
||||
}
|
||||
});
|
||||
eastComponents.add(cardShopButton);
|
||||
cardShopButton.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 20));
|
||||
|
||||
JButton bazaarButton = null;
|
||||
if (questData.getMode().equals(forge.quest.data.QuestData.FANTASY)) {
|
||||
|
||||
bazaarButton = new JButton("Bazaar");
|
||||
bazaarButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
QuestMainPanel.this.showBazaar();
|
||||
}
|
||||
});
|
||||
eastComponents.add(bazaarButton);
|
||||
bazaarButton.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 20));
|
||||
}
|
||||
|
||||
|
||||
questButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
QuestMainPanel.this.toggleBattleQuest();
|
||||
}
|
||||
});
|
||||
eastComponents.add(questButton);
|
||||
questButton.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 18));
|
||||
questButton.setPreferredSize(new Dimension(0, 60));
|
||||
|
||||
|
||||
playButton.addActionListener(new ActionListener() {
|
||||
public void actionPerformed(ActionEvent actionEvent) {
|
||||
QuestMainPanel.this.launchGame();
|
||||
}
|
||||
});
|
||||
|
||||
playButton.setFont(new Font(Font.DIALOG, Font.BOLD, 28));
|
||||
playButton.setPreferredSize(new Dimension(0, 100));
|
||||
|
||||
|
||||
eastComponents.add(playButton);
|
||||
eastComponents.add(optionsPanel);
|
||||
|
||||
GuiUtils.setWidthToMax(eastComponents);
|
||||
|
||||
panel.add(mainMenuButton);
|
||||
GuiUtils.addGap(panel);
|
||||
panel.add(optionsPanel);
|
||||
panel.add(Box.createVerticalGlue());
|
||||
panel.add(Box.createVerticalGlue());
|
||||
|
||||
if (questData.getMode().equals(forge.quest.data.QuestData.FANTASY)) {
|
||||
panel.add(this.lifeLabel);
|
||||
this.lifeLabel.setFont(new Font(Font.DIALOG, Font.BOLD, 14));
|
||||
this.lifeLabel.setIcon(GuiUtils.getResizedIcon(GuiUtils.getIconFromFile("Life.png"), 30, 30));
|
||||
}
|
||||
|
||||
GuiUtils.addGap(panel);
|
||||
panel.add(this.creditsLabel);
|
||||
this.creditsLabel.setIcon(GuiUtils.getResizedIcon(GuiUtils.getIconFromFile("CoinStack.png"), 30, 30));
|
||||
this.creditsLabel.setFont(new Font(Font.DIALOG, Font.BOLD, 14));
|
||||
GuiUtils.addGap(panel, 10);
|
||||
panel.add(cardShopButton);
|
||||
|
||||
if (questData.getMode().equals(forge.quest.data.QuestData.FANTASY)) {
|
||||
GuiUtils.addGap(panel);
|
||||
panel.add(bazaarButton);
|
||||
}
|
||||
|
||||
panel.add(Box.createVerticalGlue());
|
||||
|
||||
panel.add(questButton);
|
||||
this.nextQuestLabel.setFont(new Font(Font.DIALOG, Font.PLAIN, 11));
|
||||
panel.add(nextQuestLabel);
|
||||
GuiUtils.addGap(panel);
|
||||
|
||||
panel.add(playButton);
|
||||
|
||||
panel.setLayout(new BoxLayout(panel, BoxLayout.Y_AXIS));
|
||||
return panel;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>createOptionsPanel.</p>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>createMatchSettingsPanel.</p>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>createBattlePanel</p>
|
||||
* Returns a JPanel containing PanelSingleBattle instances for each battle.
|
||||
*
|
||||
* @return a {@link javax.swing.JPanel} object.
|
||||
*/
|
||||
private JPanel createBattlePanel() {
|
||||
JPanel pan = new JPanel();
|
||||
pan.setLayout(new BoxLayout(pan, BoxLayout.Y_AXIS));
|
||||
pan.setBorder(new TitledBorder(new EtchedBorder(), "Available Battles"));
|
||||
PanelSingleBattle pb;
|
||||
|
||||
List<DeckSingleBattle> Battles = ManagerBattle.getBattles();
|
||||
|
||||
for (DeckSingleBattle Battle : Battles) {
|
||||
pb = new PanelSingleBattle(Battle);
|
||||
|
||||
pan.add(pb);
|
||||
pb.addMouseListener(new SelectionAdapter(pb));
|
||||
|
||||
GuiUtils.addGap(pan, 3);
|
||||
}
|
||||
|
||||
pan.setAlignmentX(LEFT_ALIGNMENT);
|
||||
|
||||
return pan;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>createQuestPanel.</p>
|
||||
* Returns a JPanel containing PanelSingleQuest instances for each battle.
|
||||
*
|
||||
* @return a {@link javax.swing.JPanel} object.
|
||||
*/
|
||||
private JPanel createQuestPanel() {
|
||||
JPanel pan = new JPanel();
|
||||
pan.setLayout(new BoxLayout(pan, BoxLayout.Y_AXIS));
|
||||
pan.setBorder(new TitledBorder(new EtchedBorder(), "Available Quests"));
|
||||
PanelSingleQuest pq;
|
||||
|
||||
List<DeckSingleQuest> Quests = ManagerQuest.getQuests();
|
||||
|
||||
for (DeckSingleQuest Quest : Quests) {
|
||||
pq = new PanelSingleQuest(Quest);
|
||||
|
||||
pan.add(pq);
|
||||
pq.addMouseListener(new SelectionAdapter(pq));
|
||||
|
||||
GuiUtils.addGap(pan, 3);
|
||||
}
|
||||
|
||||
pan.setAlignmentX(LEFT_ALIGNMENT);
|
||||
|
||||
return pan;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>refresh.</p>
|
||||
*/
|
||||
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);
|
||||
|
||||
List<String> deckNames = new ArrayList<String>(questData.getDeckNames());
|
||||
|
||||
Collections.sort(deckNames, new Comparator<String>() {
|
||||
public int compare(String s, String s1) {
|
||||
return s.compareToIgnoreCase(s1);
|
||||
}
|
||||
});
|
||||
|
||||
if (deckNames.contains(lastUsedDeck)) {
|
||||
deckNames.remove(lastUsedDeck);
|
||||
deckNames.add(0, lastUsedDeck);
|
||||
}
|
||||
|
||||
for (String deckName : deckNames) {
|
||||
deckComboBox.addItem(deckName);
|
||||
}
|
||||
} else {
|
||||
deckComboBox.addItem(NO_DECKS_AVAILABLE);
|
||||
deckComboBox.setEnabled(false);
|
||||
}
|
||||
deckComboBox.setMinimumSize(new Dimension(150, 0));
|
||||
|
||||
questButton.setEnabled(nextQuestInWins() == 0);
|
||||
|
||||
playButton.setEnabled(canGameBeLaunched());
|
||||
|
||||
if (questData.getMode().equals(QuestData.FANTASY)) {
|
||||
lifeLabel.setText(" " + questData.getLife());
|
||||
|
||||
petComboBox.removeAllItems();
|
||||
|
||||
Set<String> petList = questData.getPetManager().getAvailablePetNames();
|
||||
|
||||
if (petList.size() > 0) {
|
||||
petComboBox.setEnabled(true);
|
||||
petCheckBox.setEnabled(true);
|
||||
for (String aPetList : petList) {
|
||||
petComboBox.addItem(aPetList);
|
||||
}
|
||||
} else {
|
||||
petComboBox.addItem("No pets available");
|
||||
petComboBox.setEnabled(false);
|
||||
petCheckBox.setEnabled(false);
|
||||
}
|
||||
|
||||
if (!questData.getPetManager().shouldPetBeUsed()) {
|
||||
petCheckBox.setSelected(false);
|
||||
petComboBox.setEnabled(false);
|
||||
} else {
|
||||
petCheckBox.setSelected(true);
|
||||
petComboBox.setSelectedItem(questData.getPetManager().getSelectedPet().getName());
|
||||
}
|
||||
|
||||
|
||||
this.plantBox.setEnabled(questData.getPetManager().getPlant().getLevel() > 0);
|
||||
this.plantBox.setSelected(questData.getPetManager().shouldPlantBeUsed());
|
||||
|
||||
QuestItemZeppelin zeppelin = (QuestItemZeppelin) questData.getInventory().getItem("Zeppelin");
|
||||
|
||||
if (zeppelin.getLevel() > 0) {
|
||||
zeppelinPanel.removeAll();
|
||||
zeppelinPanel.add(zeppelinButton, BorderLayout.CENTER);
|
||||
}
|
||||
|
||||
if (!zeppelin.hasBeenUsed()) {
|
||||
zeppelinButton.setEnabled(true);
|
||||
} else {
|
||||
zeppelinButton.setEnabled(false);
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
|
||||
if (nextQuestInWins() > 0) {
|
||||
nextQuestLabel.setText("Next Quest in " + nextQuestInWins() + " Wins.");
|
||||
} else {
|
||||
nextQuestLabel.setText("Next Quest available now.");
|
||||
}
|
||||
|
||||
nextMatchLayout = new CardLayout();
|
||||
|
||||
refreshNextMatchPanel();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>refreshNextMatchPanel.</p>
|
||||
*/
|
||||
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);
|
||||
}
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>nextQuestInWins.</p>
|
||||
*
|
||||
* @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;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>showDeckEditor.</p>
|
||||
*/
|
||||
void showDeckEditor() {
|
||||
Command exit = new Command() {
|
||||
private static final long serialVersionUID = -5110231879431074581L;
|
||||
|
||||
public void execute() {
|
||||
//saves all deck data
|
||||
AllZone.getQuestData().saveData();
|
||||
|
||||
new QuestFrame();
|
||||
}
|
||||
};
|
||||
|
||||
Gui_Quest_DeckEditor g = new Gui_Quest_DeckEditor();
|
||||
|
||||
g.show(exit);
|
||||
g.setVisible(true);
|
||||
mainFrame.dispose();
|
||||
}//deck editor button
|
||||
|
||||
/**
|
||||
* <p>showBazaar.</p>
|
||||
*/
|
||||
void showBazaar() {
|
||||
mainFrame.showBazaarPane();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>showCardShop.</p>
|
||||
*/
|
||||
void showCardShop() {
|
||||
Command exit = new Command() {
|
||||
private static final long serialVersionUID = 8567193482568076362L;
|
||||
|
||||
public void execute() {
|
||||
//saves all deck data
|
||||
AllZone.getQuestData().saveData();
|
||||
|
||||
new QuestFrame();
|
||||
}
|
||||
};
|
||||
|
||||
Gui_CardShop g = new Gui_CardShop(questData);
|
||||
|
||||
g.show(exit);
|
||||
g.setVisible(true);
|
||||
|
||||
this.mainFrame.dispose();
|
||||
|
||||
}//card shop button
|
||||
|
||||
/**
|
||||
* <p>launchGame.</p>
|
||||
*/
|
||||
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();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>setupBattle.</p>
|
||||
*
|
||||
* @param humanDeck a {@link forge.deck.Deck} object.
|
||||
*/
|
||||
void setupBattle(Deck humanDeck) {
|
||||
Deck computer = ((PanelSingleBattle) lastPanelSelected).getBattle().getDeck();
|
||||
Constant.Runtime.ComputerDeck[0] = computer;
|
||||
|
||||
AllZone.getGameAction().newGame(humanDeck, computer, forge.quest.data.QuestUtil.getHumanExtraCards(questData),
|
||||
new CardList(), questData.getLife(), 20, null);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>setupQuest.</p>
|
||||
*
|
||||
* @param humanDeck a {@link forge.deck.Deck} object.
|
||||
*/
|
||||
private void setupQuest(Deck humanDeck) {
|
||||
DeckSingleQuest selectedQuest = ((PanelSingleQuest) lastPanelSelected).getQuest();
|
||||
AllZone.setCurrentQuest(selectedQuest);
|
||||
|
||||
Deck computerDeck = ManagerBattle.getAIDeckFromFile("quest" + selectedQuest.getID());
|
||||
Constant.Runtime.ComputerDeck[0] = computerDeck;
|
||||
|
||||
int extraLife = 0;
|
||||
|
||||
if (questData.getInventory().getItemLevel("Gear") == 2) {
|
||||
extraLife = 3;
|
||||
}
|
||||
|
||||
AllZone.getGameAction().newGame(humanDeck, computerDeck,
|
||||
forge.quest.data.QuestUtil.getHumanExtraCards(questData, selectedQuest), new CardList(),
|
||||
questData.getLife() + extraLife, selectedQuest.getAILife(), selectedQuest);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getMatchIcon.</p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
String getMatchIcon() {
|
||||
String oppIconName;
|
||||
|
||||
if (isShowingQuests) {
|
||||
PanelSingleQuest selectedQuest = (PanelSingleQuest) lastPanelSelected;
|
||||
oppIconName = selectedQuest.getIconFilename();
|
||||
} else {
|
||||
PanelSingleBattle selectedBattle = (PanelSingleBattle) lastPanelSelected;
|
||||
oppIconName = selectedBattle.getIconFilename();
|
||||
}
|
||||
return oppIconName;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>toggleBattleQuest.</p>
|
||||
* Toggles view between battle and quest screen.
|
||||
*/
|
||||
void toggleBattleQuest() {
|
||||
if (isShowingQuests) {
|
||||
isShowingQuests = false;
|
||||
questButton.setText("Quests");
|
||||
} else {
|
||||
isShowingQuests = true;
|
||||
questButton.setText("Battles");
|
||||
}
|
||||
|
||||
if (lastPanelSelected != null) {
|
||||
lastPanelSelected.setSelected(false);
|
||||
}
|
||||
|
||||
lastPanelSelected = null;
|
||||
|
||||
refresh();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>SelectionAdapter</p>
|
||||
* Handles (de)selection of various SelectablePanel instances using lastPanelSelected field.
|
||||
* Also toggles launch button after (de)selection.
|
||||
*
|
||||
*/
|
||||
class SelectionAdapter extends MouseAdapter {
|
||||
SelectablePanel targetPanel;
|
||||
|
||||
SelectionAdapter(SelectablePanel sp) {
|
||||
super();
|
||||
this.targetPanel = sp;
|
||||
}
|
||||
|
||||
@Override
|
||||
public void mouseClicked(MouseEvent mouseEvent) {
|
||||
// Deselect previous
|
||||
if (lastPanelSelected != null) {
|
||||
lastPanelSelected.setSelected(false);
|
||||
}
|
||||
|
||||
targetPanel.setSelected(true);
|
||||
|
||||
lastPanelSelected = targetPanel;
|
||||
playButton.setEnabled(canGameBeLaunched());
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>moveDeckToTop.</p>
|
||||
*
|
||||
* @param humanDeckName a {@link java.lang.String} object.
|
||||
*/
|
||||
private void moveDeckToTop(String humanDeckName) {
|
||||
QuestMainPanel.lastUsedDeck = humanDeckName;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>canGameBeLaunched.</p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
boolean canGameBeLaunched() {
|
||||
return !(NO_DECKS_AVAILABLE.equals(deckComboBox.getSelectedItem()) || lastPanelSelected == null);
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public void refreshState() {
|
||||
this.refresh();
|
||||
}
|
||||
|
||||
}
|
||||
Reference in New Issue
Block a user