mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-17 03:08:02 +00:00
reverting sources to revision 10193
changes from r10200 were kept (not reverted)
This commit is contained in:
13
.gitattributes
vendored
13
.gitattributes
vendored
@@ -9754,8 +9754,8 @@ src/main/java/forge/card/trigger/Trigger_TurnFaceUp.java svneol=native#text/plai
|
||||
src/main/java/forge/card/trigger/Trigger_Unequip.java svneol=native#text/plain
|
||||
src/main/java/forge/card/trigger/Trigger_Untaps.java svneol=native#text/plain
|
||||
src/main/java/forge/card/trigger/package-info.java svneol=native#text/plain
|
||||
src/main/java/forge/deck/Deck.java -text
|
||||
src/main/java/forge/deck/DeckManager.java -text
|
||||
src/main/java/forge/deck/Deck.java svneol=native#text/plain
|
||||
src/main/java/forge/deck/DeckManager.java svneol=native#text/plain
|
||||
src/main/java/forge/deck/DownloadDeck.java svneol=native#text/plain
|
||||
src/main/java/forge/deck/generate/Generate2ColorDeck.java svneol=native#text/plain
|
||||
src/main/java/forge/deck/generate/Generate3ColorDeck.java svneol=native#text/plain
|
||||
@@ -9783,7 +9783,6 @@ src/main/java/forge/gui/ListChooser.java svneol=native#text/plain
|
||||
src/main/java/forge/gui/MultiLineLabel.java svneol=native#text/plain
|
||||
src/main/java/forge/gui/MultiLineLabelUI.java svneol=native#text/plain
|
||||
src/main/java/forge/gui/MultiPhaseProgressMonitorWithETA.java svneol=native#text/plain
|
||||
src/main/java/forge/gui/SelectablePanel.java -text
|
||||
src/main/java/forge/gui/deckeditor/CardPanelBase.java -text
|
||||
src/main/java/forge/gui/deckeditor/CardPanelHeavy.java -text
|
||||
src/main/java/forge/gui/deckeditor/CardPanelLite.java -text
|
||||
@@ -9832,10 +9831,6 @@ src/main/java/forge/properties/NewConstants.java svneol=native#text/plain
|
||||
src/main/java/forge/properties/Preferences.java svneol=native#text/plain
|
||||
src/main/java/forge/properties/SavePreferencesListener.java svneol=native#text/plain
|
||||
src/main/java/forge/properties/package-info.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/data/DeckSingleBattle.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/data/DeckSingleQuest.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/data/ManagerBattle.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/data/ManagerQuest.java -text
|
||||
src/main/java/forge/quest/data/QuestBattleManager.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/data/QuestBoosterPack.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/data/QuestData.java svneol=native#text/plain
|
||||
@@ -9867,11 +9862,8 @@ src/main/java/forge/quest/data/pet/QuestPetManager.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/data/pet/QuestPetPlant.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/data/pet/QuestPetWolf.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/data/pet/package-info.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/gui/PanelSingleBattle.java -text
|
||||
src/main/java/forge/quest/gui/PanelSingleQuest.java -text
|
||||
src/main/java/forge/quest/gui/QuestAbstractPanel.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/gui/QuestFrame.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/gui/QuestMainPanel.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/gui/QuestOptions.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/gui/bazaar/QuestBazaarItem.java svneol=native#text/plain
|
||||
src/main/java/forge/quest/gui/bazaar/QuestBazaarPanel.java svneol=native#text/plain
|
||||
@@ -9940,6 +9932,7 @@ src/test/java/forge/GuiWinLoseTest.java svneol=native#text/plain
|
||||
src/test/java/forge/PanelTest.java svneol=native#text/plain
|
||||
src/test/java/forge/PhaseTest.java svneol=native#text/plain
|
||||
src/test/java/forge/ReadBoosterPackTest.java svneol=native#text/plain
|
||||
src/test/java/forge/ReadQuestAssignmentTest.java svneol=native#text/plain
|
||||
src/test/java/forge/RunTest.java svneol=native#text/plain
|
||||
src/test/java/forge/TinyTest.java svneol=native#text/plain
|
||||
src/test/java/forge/card/cardFactory/CardFactoryTest.java svneol=native#text/plain
|
||||
|
||||
@@ -17,7 +17,6 @@ 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.
|
||||
@@ -41,9 +40,9 @@ public final class AllZone implements NewConstants {
|
||||
|
||||
/** Global <code>questData</code>. */
|
||||
private static forge.quest.data.QuestData questData = null;
|
||||
|
||||
/** Global <code>currentQuest</code>. */
|
||||
private static forge.quest.data.DeckSingleQuest currentQuest = null;
|
||||
|
||||
/** Global <code>QuestAssignment</code>. */
|
||||
private static Quest_Assignment questAssignment = null;
|
||||
|
||||
/** Constant <code>NAME_CHANGER</code>. */
|
||||
private static final NameChanger NAME_CHANGER = new NameChanger();
|
||||
@@ -130,25 +129,25 @@ public final class AllZone implements NewConstants {
|
||||
public static void setQuestData(final QuestData questData0) {
|
||||
questData = questData0;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getCurrentQuest.</p>
|
||||
* <p>getQuestAssignment.</p>
|
||||
*
|
||||
* @return a {@link forge.quest.data.QuestData} object.
|
||||
*
|
||||
* @return a {@link forge.Quest_Assignment} object.
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public static forge.quest.data.DeckSingleQuest getCurrentQuest() {
|
||||
return currentQuest;
|
||||
public static Quest_Assignment getQuestAssignment() {
|
||||
return questAssignment;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>setCurrentQuest.</p>
|
||||
* <p>setQuestAssignment.</p>
|
||||
*
|
||||
* @param a DeckSingleQuest object.
|
||||
*
|
||||
* @param assignment a {@link forge.Quest_Assignment} object.
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public static void setCurrentQuest(final DeckSingleQuest qq) {
|
||||
currentQuest = qq;
|
||||
public static void setQuestAssignment(final Quest_Assignment assignment) {
|
||||
questAssignment = assignment;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -1,392 +1,346 @@
|
||||
package forge.deck;
|
||||
|
||||
import forge.Constant;
|
||||
import forge.card.CardDb;
|
||||
import forge.card.CardPool;
|
||||
import forge.card.CardPoolView;
|
||||
import forge.card.CardPrinted;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>Deck class.</p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id: Deck.java 10183 2011-09-02 22:51:47Z Max mtg $
|
||||
*/
|
||||
public final class Deck implements Comparable<Deck>, Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7478025567887481994L;
|
||||
|
||||
//gameType is from Constant.GameType, like Constant.GameType.Regular
|
||||
|
||||
private Map<String, String> metadata = new HashMap<String, String>();
|
||||
|
||||
private CardPool main;
|
||||
private CardPool sideboard;
|
||||
private CardPool humanExtraCards;
|
||||
private CardPool aiExtraCards;
|
||||
|
||||
/** Constant <code>NAME="Name"</code> */
|
||||
public static final String NAME = "Name";
|
||||
/** Constant <code>DECK_TYPE="Deck Type"</code> */
|
||||
public static final String DECK_TYPE = "Deck Type";
|
||||
/** Constant <code>COMMENT="Comment"</code> */
|
||||
public static final String COMMENT = "Comment";
|
||||
/** Constant <code>DESCRIPTION="Description"</code> */
|
||||
public static final String DESCRIPTION = "Description";
|
||||
/** Constant <code>DIFFICULTY="Difficulty"</code> */
|
||||
public static final String DIFFICULTY = "Difficulty";
|
||||
|
||||
|
||||
//gameType is from Constant.GameType, like Constant.GameType.Regular
|
||||
/**
|
||||
* <p>Constructor for Deck.</p>
|
||||
*/
|
||||
public Deck() {
|
||||
main = new CardPool();
|
||||
sideboard = new CardPool();
|
||||
humanExtraCards = new CardPool();
|
||||
aiExtraCards = new CardPool();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Constructor for Deck.</p>
|
||||
*
|
||||
* @param deckType a {@link java.lang.String} object.
|
||||
* @param main a {@link java.util.List} object.
|
||||
* @param sideboard a {@link java.util.List} object.
|
||||
* @param name a {@link java.lang.String} object.
|
||||
*/
|
||||
public Deck(String deckType, List<String> main, List<String> sideboard, String name) {
|
||||
setDeckType(deckType);
|
||||
setName(name);
|
||||
|
||||
this.main = new CardPool(main);
|
||||
this.sideboard = new CardPool(sideboard);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Constructor for Deck.</p>
|
||||
*
|
||||
* @param type a {@link java.lang.String} object.
|
||||
*/
|
||||
public Deck(final String type) {
|
||||
this();
|
||||
setDeckType(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>main</code>.</p>
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public CardPoolView getMain() {
|
||||
return main.getView();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>sideboard</code>.</p>
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public CardPoolView getSideboard() {
|
||||
return sideboard.getView();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>humanExtraCards</code>.</p>
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public CardPoolView getHumanExtraCards() {
|
||||
return humanExtraCards.getView();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>aiExtraCards</code>.</p>
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public CardPoolView getAIExtraCards() {
|
||||
return aiExtraCards.getView();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDeckType.</p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String getDeckType() {
|
||||
return metadata.get(DECK_TYPE);
|
||||
}
|
||||
|
||||
//can only call this method ONCE
|
||||
/**
|
||||
* <p>setDeckType.</p>
|
||||
*
|
||||
* @param deckType a {@link java.lang.String} object.
|
||||
*/
|
||||
void setDeckType(String deckType) {
|
||||
if (this.getDeckType() != null) {
|
||||
throw new IllegalStateException(
|
||||
"Deck : setDeckType() error, deck type has already been set");
|
||||
}
|
||||
|
||||
if (!Constant.GameType.GameTypes.contains(deckType)) {
|
||||
throw new RuntimeException(
|
||||
"Deck : setDeckType() error, invalid deck type - " + deckType);
|
||||
}
|
||||
|
||||
metadata.put(DECK_TYPE, deckType);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>setName.</p>
|
||||
*
|
||||
* @param s a {@link java.lang.String} object.
|
||||
*/
|
||||
public void setName(String s) {
|
||||
metadata.put(NAME, s);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getName.</p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String getName() {
|
||||
return metadata.get(NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>setComment.</p>
|
||||
*
|
||||
* @param comment a {@link java.lang.String} object.
|
||||
*/
|
||||
public void setComment(String comment) {
|
||||
metadata.put(COMMENT, comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getComment.</p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String getComment() {
|
||||
return metadata.get(COMMENT);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>addMain.</p>
|
||||
*
|
||||
* @param cardName a {@link java.lang.String} object.
|
||||
*/
|
||||
public void addMain(final String cardName) { addMain(CardDb.instance().getCard(cardName)); }
|
||||
public void addMain(final CardPrinted card) { main.add(card); }
|
||||
public void addMain(final CardPoolView list) { main.addAll(list); }
|
||||
public void removeMain(final CardPrinted card) { main.remove(card); }
|
||||
public void removeMain(final CardPrinted card, final int amount) { main.remove(card, amount); }
|
||||
public int countMain() { return main.countAll(); }
|
||||
|
||||
/**
|
||||
* <p>addSideboard.</p>
|
||||
*
|
||||
* @param cardName a {@link java.lang.String} object.
|
||||
*/
|
||||
public final void addSideboard(final String cardName) { addSideboard(CardDb.instance().getCard(cardName)); }
|
||||
public final void addSideboard(final CardPrinted card) { sideboard.add(card); }
|
||||
public final void addSideboard(final CardPrinted card, final int amount) { sideboard.add(card, amount); }
|
||||
public final void addSideboard(final CardPoolView cards) { sideboard.addAll(cards); }
|
||||
|
||||
/**
|
||||
* <p>countSideboard.</p>
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
public int countSideboard() {
|
||||
return sideboard.countAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>removeSideboard.</p>
|
||||
*
|
||||
* @param index a int.
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public void removeFromSideboard(CardPrinted card) {
|
||||
sideboard.remove(card);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>addHumanExtraCards.</p>
|
||||
*
|
||||
* @param cardName a {@link java.lang.String} object.
|
||||
*/
|
||||
public void addHumanExtraCards(final String cardName) { addHumanExtraCards(CardDb.instance().getCard(cardName)); }
|
||||
public void addHumanExtraCards(final CardPrinted card) { humanExtraCards.add(card); }
|
||||
public void addHumanExtraCards(final CardPoolView list) { humanExtraCards.addAll(list); }
|
||||
public void removeHumanExtraCards(final CardPrinted card) { humanExtraCards.remove(card); }
|
||||
public void removeHumanExtraCards(final CardPrinted card, final int amount) { humanExtraCards.remove(card, amount); }
|
||||
public int countHumanExtraCards() { return main.countAll(); }
|
||||
|
||||
/**
|
||||
* <p>addAIExtraCards.</p>
|
||||
*
|
||||
* @param cardName a {@link java.lang.String} object.
|
||||
*/
|
||||
public void addAIExtraCards(final String cardName) { addAIExtraCards(CardDb.instance().getCard(cardName)); }
|
||||
public void addAIExtraCards(final CardPrinted card) { aiExtraCards.add(card); }
|
||||
public void addAIExtraCards(final CardPoolView list) { aiExtraCards.addAll(list); }
|
||||
public void removeAIExtraCards(final CardPrinted card) { aiExtraCards.remove(card); }
|
||||
public void removeAIExtraCards(final CardPrinted card, final int amount) { aiExtraCards.remove(card, amount); }
|
||||
public int countAIExtraCards() { return aiExtraCards.countAll(); }
|
||||
|
||||
/**
|
||||
* <p>isDraft.</p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean isDraft() {
|
||||
return getDeckType().equals(Constant.GameType.Draft);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>isSealed.</p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean isSealed() {
|
||||
return getDeckType().equals(Constant.GameType.Sealed);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>isRegular.</p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean isRegular() {
|
||||
return getDeckType().equals(Constant.GameType.Constructed);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>hashCode.</p>
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return getName().hashCode();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
|
||||
// The setters and getters below are for Quest decks
|
||||
/**
|
||||
* <p>setDifficulty.</p>
|
||||
*
|
||||
* @param s a {@link java.lang.String} object.
|
||||
*/
|
||||
public void setDifficulty(String s) {
|
||||
metadata.put(DIFFICULTY, s);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDifficulty.</p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String getDifficulty() {
|
||||
return metadata.get(DIFFICULTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>setDescription.</p>
|
||||
*
|
||||
* @param s a {@link java.lang.String} object.
|
||||
*/
|
||||
public void setDescription(String s) {
|
||||
metadata.put(DESCRIPTION, s);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDescription.</p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String getDescription() {
|
||||
return metadata.get(DESCRIPTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>compareTo.</p>
|
||||
*
|
||||
* @param d a {@link forge.deck.Deck} object.
|
||||
* @return a int.
|
||||
*/
|
||||
public int compareTo(Deck d) {
|
||||
return getName().compareTo(d.getName());
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof Deck) {
|
||||
Deck d = (Deck) o;
|
||||
return getName().equals(d.getName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>metadata</code>.</p>
|
||||
*
|
||||
* @return a {@link java.util.Set} object.
|
||||
*/
|
||||
public Set<Map.Entry<String, String>> getMetadata() {
|
||||
return metadata.entrySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>metadata</code>.</p>
|
||||
*
|
||||
* @param key a {@link java.lang.String} object.
|
||||
* @return a {@link java.lang.String} object.
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public String getMetadata(String key) {
|
||||
if (metadata.containsKey(key))
|
||||
return metadata.get(key);
|
||||
|
||||
System.err.println("In forge.deck/Deck.java, getMetadata() failed "+
|
||||
"for property '"+key+"' in deck '"+getName()+"'.");
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>addMetaData.</p>
|
||||
*
|
||||
* @param key a {@link java.lang.String} object.
|
||||
* @param value a {@link java.lang.String} object.
|
||||
*/
|
||||
public void addMetaData(String key, String value) {
|
||||
metadata.put(key, value);
|
||||
}
|
||||
|
||||
public void clearSideboard() {
|
||||
sideboard.clear();
|
||||
}
|
||||
|
||||
public void clearMain() {
|
||||
main.clear();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
package forge.deck;
|
||||
|
||||
import forge.Constant;
|
||||
import forge.card.CardDb;
|
||||
import forge.card.CardPool;
|
||||
import forge.card.CardPoolView;
|
||||
import forge.card.CardPrinted;
|
||||
|
||||
import java.io.Serializable;
|
||||
import java.util.*;
|
||||
|
||||
/**
|
||||
* <p>Deck class.</p>
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
*/
|
||||
public final class Deck implements Comparable<Deck>, Serializable {
|
||||
/**
|
||||
*
|
||||
*/
|
||||
private static final long serialVersionUID = -7478025567887481994L;
|
||||
|
||||
//gameType is from Constant.GameType, like Constant.GameType.Regular
|
||||
|
||||
private Map<String, String> metadata = new HashMap<String, String>();
|
||||
|
||||
private CardPool main;
|
||||
private CardPool sideboard;
|
||||
|
||||
/** Constant <code>NAME="Name"</code> */
|
||||
public static final String NAME = "Name";
|
||||
/** Constant <code>DECK_TYPE="Deck Type"</code> */
|
||||
public static final String DECK_TYPE = "Deck Type";
|
||||
/** Constant <code>COMMENT="Comment"</code> */
|
||||
public static final String COMMENT = "Comment";
|
||||
/** Constant <code>DESCRIPTION="Description"</code> */
|
||||
public static final String DESCRIPTION = "Description";
|
||||
/** Constant <code>DIFFICULTY="Difficulty"</code> */
|
||||
public static final String DIFFICULTY = "Difficulty";
|
||||
|
||||
|
||||
//gameType is from Constant.GameType, like Constant.GameType.Regular
|
||||
/**
|
||||
* <p>Constructor for Deck.</p>
|
||||
*/
|
||||
public Deck() {
|
||||
main = new CardPool();
|
||||
sideboard = new CardPool();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Constructor for Deck.</p>
|
||||
*
|
||||
* @param deckType a {@link java.lang.String} object.
|
||||
* @param main a {@link java.util.List} object.
|
||||
* @param sideboard a {@link java.util.List} object.
|
||||
* @param name a {@link java.lang.String} object.
|
||||
*/
|
||||
public Deck(String deckType, List<String> main, List<String> sideboard, String name) {
|
||||
setDeckType(deckType);
|
||||
setName(name);
|
||||
|
||||
this.main = new CardPool(main);
|
||||
this.sideboard = new CardPool(sideboard);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Constructor for Deck.</p>
|
||||
*
|
||||
* @param type a {@link java.lang.String} object.
|
||||
*/
|
||||
public Deck(final String type) {
|
||||
this();
|
||||
setDeckType(type);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>main</code>.</p>
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public CardPoolView getMain() {
|
||||
return main.getView();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>sideboard</code>.</p>
|
||||
*
|
||||
* @return a {@link java.util.List} object.
|
||||
*/
|
||||
public CardPoolView getSideboard() {
|
||||
return sideboard.getView();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDeckType.</p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String getDeckType() {
|
||||
return metadata.get(DECK_TYPE);
|
||||
}
|
||||
|
||||
//can only call this method ONCE
|
||||
/**
|
||||
* <p>setDeckType.</p>
|
||||
*
|
||||
* @param deckType a {@link java.lang.String} object.
|
||||
*/
|
||||
void setDeckType(String deckType) {
|
||||
if (this.getDeckType() != null) {
|
||||
throw new IllegalStateException(
|
||||
"Deck : setDeckType() error, deck type has already been set");
|
||||
}
|
||||
|
||||
if (!Constant.GameType.GameTypes.contains(deckType)) {
|
||||
throw new RuntimeException(
|
||||
"Deck : setDeckType() error, invalid deck type - " + deckType);
|
||||
}
|
||||
|
||||
metadata.put(DECK_TYPE, deckType);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>setName.</p>
|
||||
*
|
||||
* @param s a {@link java.lang.String} object.
|
||||
*/
|
||||
public void setName(String s) {
|
||||
metadata.put(NAME, s);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getName.</p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String getName() {
|
||||
return metadata.get(NAME);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>setComment.</p>
|
||||
*
|
||||
* @param comment a {@link java.lang.String} object.
|
||||
*/
|
||||
public void setComment(String comment) {
|
||||
metadata.put(COMMENT, comment);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getComment.</p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String getComment() {
|
||||
return metadata.get(COMMENT);
|
||||
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>addMain.</p>
|
||||
*
|
||||
* @param cardName a {@link java.lang.String} object.
|
||||
*/
|
||||
public void addMain(final String cardName) { addMain(CardDb.instance().getCard(cardName)); }
|
||||
public void addMain(final CardPrinted card) { main.add(card); }
|
||||
public void addMain(final CardPoolView list) { main.addAll(list); }
|
||||
public void removeMain(final CardPrinted card) { main.remove(card); }
|
||||
public void removeMain(final CardPrinted card, final int amount) { main.remove(card, amount); }
|
||||
public int countMain() { return main.countAll(); }
|
||||
|
||||
/**
|
||||
* <p>addSideboard.</p>
|
||||
*
|
||||
* @param cardName a {@link java.lang.String} object.
|
||||
*/
|
||||
public final void addSideboard(final String cardName) { addSideboard(CardDb.instance().getCard(cardName)); }
|
||||
public final void addSideboard(final CardPrinted card) { sideboard.add(card); }
|
||||
public final void addSideboard(final CardPrinted card, final int amount) { sideboard.add(card, amount); }
|
||||
public final void addSideboard(final CardPoolView cards) { sideboard.addAll(cards); }
|
||||
|
||||
/**
|
||||
* <p>countSideboard.</p>
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
public int countSideboard() {
|
||||
return sideboard.countAll();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>removeSideboard.</p>
|
||||
*
|
||||
* @param index a int.
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public void removeFromSideboard(CardPrinted card) {
|
||||
sideboard.remove(card);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>isDraft.</p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean isDraft() {
|
||||
return getDeckType().equals(Constant.GameType.Draft);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>isSealed.</p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean isSealed() {
|
||||
return getDeckType().equals(Constant.GameType.Sealed);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>isRegular.</p>
|
||||
*
|
||||
* @return a boolean.
|
||||
*/
|
||||
public boolean isRegular() {
|
||||
return getDeckType().equals(Constant.GameType.Constructed);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>hashCode.</p>
|
||||
*
|
||||
* @return a int.
|
||||
*/
|
||||
public int hashCode() {
|
||||
return getName().hashCode();
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
@Override
|
||||
public String toString() {
|
||||
return getName();
|
||||
}
|
||||
|
||||
|
||||
// The setters and getters below are for Quest decks
|
||||
/**
|
||||
* <p>setDifficulty.</p>
|
||||
*
|
||||
* @param s a {@link java.lang.String} object.
|
||||
*/
|
||||
public void setDifficulty(String s) {
|
||||
metadata.put(DIFFICULTY, s);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDifficulty.</p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String getDifficulty() {
|
||||
return metadata.get(DIFFICULTY);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>setDescription.</p>
|
||||
*
|
||||
* @param s a {@link java.lang.String} object.
|
||||
*/
|
||||
public void setDescription(String s) {
|
||||
metadata.put(DESCRIPTION, s);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>getDescription.</p>
|
||||
*
|
||||
* @return a {@link java.lang.String} object.
|
||||
*/
|
||||
public String getDescription() {
|
||||
return metadata.get(DESCRIPTION);
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>compareTo.</p>
|
||||
*
|
||||
* @param d a {@link forge.deck.Deck} object.
|
||||
* @return a int.
|
||||
*/
|
||||
public int compareTo(Deck d) {
|
||||
return getName().compareTo(d.getName());
|
||||
}
|
||||
|
||||
/** {@inheritDoc} */
|
||||
public boolean equals(Object o) {
|
||||
if (o instanceof Deck) {
|
||||
Deck d = (Deck) o;
|
||||
return getName().equals(d.getName());
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>metadata</code>.</p>
|
||||
*
|
||||
* @return a {@link java.util.Set} object.
|
||||
*/
|
||||
public Set<Map.Entry<String, String>> getMetadata() {
|
||||
return metadata.entrySet();
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>Getter for the field <code>metadata</code>.</p>
|
||||
*
|
||||
* @param key a {@link java.lang.String} object.
|
||||
* @return a {@link java.lang.String} object.
|
||||
* @since 1.0.15
|
||||
*/
|
||||
public String getMetadata(String key) {
|
||||
if (metadata.containsKey(key))
|
||||
return metadata.get(key);
|
||||
|
||||
System.err.println("In forge.deck/Deck.java, getMetadata() failed "+
|
||||
"for property '"+key+"' in deck '"+getName()+"'.");
|
||||
return "";
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>addMetaData.</p>
|
||||
*
|
||||
* @param key a {@link java.lang.String} object.
|
||||
* @param value a {@link java.lang.String} object.
|
||||
*/
|
||||
public void addMetaData(String key, String value) {
|
||||
metadata.put(key, value);
|
||||
}
|
||||
|
||||
public void clearSideboard() {
|
||||
sideboard.clear();
|
||||
}
|
||||
|
||||
public void clearMain() {
|
||||
main.clear();
|
||||
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
File diff suppressed because it is too large
Load Diff
@@ -1,43 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,116 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,272 +0,0 @@
|
||||
package forge.quest.data;
|
||||
|
||||
import java.util.ArrayList;
|
||||
import java.util.List;
|
||||
|
||||
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.card.CardPrinted;
|
||||
import forge.card.CardRarity;
|
||||
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 List<CardPrinted> getCardRewardList() {
|
||||
List<CardPrinted> cardRewardList = new ArrayList<CardPrinted>();
|
||||
|
||||
String[] details = this.getCardReward().split(" ");
|
||||
|
||||
// Set quantity, color and rarity from file meta.
|
||||
String cardscolor;
|
||||
CardRarity 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 = CardRarity.Rare;
|
||||
}
|
||||
else {
|
||||
rarity = CardRarity.Common;
|
||||
}
|
||||
|
||||
// Generate deck list.
|
||||
QuestBoosterPack pack = new QuestBoosterPack();
|
||||
return pack.generateCards(quantity, rarity, cardscolor);
|
||||
}
|
||||
|
||||
/**
|
||||
* <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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,237 +0,0 @@
|
||||
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;
|
||||
}
|
||||
|
||||
}
|
||||
@@ -1,104 +0,0 @@
|
||||
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);
|
||||
}
|
||||
}
|
||||
@@ -1,15 +1,12 @@
|
||||
package forge.quest.data;
|
||||
|
||||
import java.util.List;
|
||||
import java.util.Map.Entry;
|
||||
|
||||
import forge.*;
|
||||
import forge.card.CardPoolView;
|
||||
import forge.card.CardPrinted;
|
||||
import forge.card.CardRarity;
|
||||
|
||||
import java.util.ArrayList;
|
||||
|
||||
/**
|
||||
* <p>QuestUtil class.</p>
|
||||
* General utility class for quest tasks.
|
||||
*
|
||||
* @author Forge
|
||||
* @version $Id$
|
||||
@@ -22,43 +19,41 @@ public class QuestUtil {
|
||||
* @param qd a {@link forge.quest.data.QuestData} object.
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
public static CardList getAIExtraCards(QuestData qd) {
|
||||
public static CardList getComputerCreatures(final QuestData qd) {
|
||||
return new CardList();
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getComputerCreatures.</p>
|
||||
* Assembles extra cards computer will have in play.
|
||||
*
|
||||
* @param qd a {@link forge.quest.data.QuestData} object.
|
||||
* @param qa a {@link forge.Quest_Assignment} object.
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
public static CardList getAIExtraCards(QuestData qd, DeckSingleQuest sq) {
|
||||
public static CardList getComputerCreatures(final QuestData qd, Quest_Assignment qa) {
|
||||
CardList list = new CardList();
|
||||
if (sq != null) {
|
||||
CardPoolView compCards = sq.getDeck().getAIExtraCards();
|
||||
if (qa != null) {
|
||||
ArrayList<String> compCards = qa.getCompy();
|
||||
|
||||
/*for (String s : compCards) {
|
||||
Card c = extraCardBuilder(s);
|
||||
if(c!=null) {
|
||||
list.add(c);
|
||||
}
|
||||
}*/
|
||||
for (String s : compCards) {
|
||||
Card c = AllZone.getCardFactory().getCard(s, AllZone.getComputerPlayer());
|
||||
|
||||
c.setCurSetCode(c.getMostRecentSet());
|
||||
c.setImageFilename(CardUtil.buildFilename(c));
|
||||
|
||||
list.add(c);
|
||||
}
|
||||
}
|
||||
return list;
|
||||
}
|
||||
|
||||
|
||||
/**
|
||||
* <p>getHumanPlantAndPet.</p>
|
||||
* Starts up empty list of extra cards for human.
|
||||
* Adds plant and pet as appropriate.
|
||||
*
|
||||
* @param qd a {@link forge.quest.data.QuestData} object.
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
public static CardList getHumanExtraCards(QuestData qd) {
|
||||
System.out.println("LOOKATME");
|
||||
public static CardList getHumanPlantAndPet(final QuestData qd) {
|
||||
CardList list = new CardList();
|
||||
|
||||
if (qd.getPetManager().shouldPetBeUsed()) {
|
||||
@@ -74,115 +69,38 @@ public class QuestUtil {
|
||||
|
||||
/**
|
||||
* <p>getHumanPlantAndPet.</p>
|
||||
* Checks for plant and pet, then adds extra cards for human from quest deck.
|
||||
* Assembles extra cards human will have in play.
|
||||
*
|
||||
* @param qd a {@link forge.quest.data.QuestData} object.
|
||||
* @param qq a DeckSingleQuest object.
|
||||
* @param qa a {@link forge.Quest_Assignment} object.
|
||||
* @return a {@link forge.CardList} object.
|
||||
*/
|
||||
public static CardList getHumanExtraCards(QuestData qd, DeckSingleQuest sq) {
|
||||
CardList list = getHumanExtraCards(qd);
|
||||
public static CardList getHumanPlantAndPet(final QuestData qd, Quest_Assignment qa) {
|
||||
CardList list = getHumanPlantAndPet(qd);
|
||||
|
||||
/*if (sq != null) {
|
||||
List<Entry<CardPrinted, Integer>> humanCards =
|
||||
sq.getDeck().getHumanExtraCards().getOrderedList();
|
||||
if (qa != null) {
|
||||
list.addAll(qa.getHuman());
|
||||
}
|
||||
|
||||
for (String s : humanCards) {
|
||||
Card c = extraCardBuilder(s);
|
||||
if(c!=null) {
|
||||
list.add(c);
|
||||
}
|
||||
}
|
||||
}*/
|
||||
return list;
|
||||
}
|
||||
|
||||
/**
|
||||
* <p>extraCardBuilder.</p>
|
||||
* Assembles card objects for extra cards and tokens for AI and human.
|
||||
*
|
||||
* @param String card name
|
||||
* @return Card object.
|
||||
*/
|
||||
public static Card extraCardBuilder(String s) {
|
||||
Card c = null;
|
||||
int i;
|
||||
|
||||
if(s.substring(0,5).equals("TOKEN")) {
|
||||
String[] tokenProps = s.split("\\|");
|
||||
|
||||
if(tokenProps.length < 6) {
|
||||
System.err.println("QuestUtil > extraCardBuilder() reports an " +
|
||||
"incomplete token in the current deck.\n"+
|
||||
"Token should follow the form:\n"+
|
||||
"TOKEN|color|attack|defense|name|type|type...\n"+
|
||||
"For example: TOKEN|G|0|1|sheep|Creature");
|
||||
return c;
|
||||
}
|
||||
else {
|
||||
c = new Card();
|
||||
|
||||
c.setManaCost("0");
|
||||
c.addColor(tokenProps[1]);
|
||||
c.setBaseAttack(Integer.parseInt(tokenProps[2]));
|
||||
c.setBaseDefense(Integer.parseInt(tokenProps[3]));
|
||||
|
||||
// Uppercase each word in name
|
||||
StringBuilder name = new StringBuilder(tokenProps[4]);
|
||||
i = 0;
|
||||
do {
|
||||
name.replace(i, i + 1, name.substring(i,i + 1).toUpperCase());
|
||||
i = name.indexOf(" ", i) + 1;
|
||||
} while (i > 0 && i < name.length());
|
||||
c.setName(name.toString());
|
||||
|
||||
i = 4;
|
||||
while(i<tokenProps.length) {
|
||||
c.addType(tokenProps[i++]);
|
||||
}
|
||||
|
||||
// Example image name: G 0 1 sheep
|
||||
c.setImageName(tokenProps[1]+" "+tokenProps[2]+" "+tokenProps[3]+" "+tokenProps[4]);
|
||||
|
||||
c.setToken(true);
|
||||
c.addController(AllZone.getHumanPlayer());
|
||||
c.setOwner(AllZone.getHumanPlayer());
|
||||
}
|
||||
}
|
||||
else if(!s.equals("")) {
|
||||
c = AllZone.getCardFactory().getCard(s, AllZone.getComputerPlayer());
|
||||
|
||||
c.setCurSetCode(c.getMostRecentSet());
|
||||
c.setImageFilename(CardUtil.buildFilename(c));
|
||||
}
|
||||
|
||||
return c;
|
||||
}
|
||||
|
||||
|
||||
|
||||
// THIS INFORMATION WILL BE STORED IN THE DCK FILE.
|
||||
/**
|
||||
* <p>setupQuest.</p>
|
||||
*
|
||||
* @param qa a {@link forge.Quest_Assignment} object.
|
||||
*/
|
||||
|
||||
/*
|
||||
public static void setupQuest(Quest_Assignment qa) {
|
||||
QuestBoosterPack pack = new QuestBoosterPack();
|
||||
qa.clearCompy();
|
||||
|
||||
int id = qa.getId();
|
||||
|
||||
Generator<Card> cards = YieldUtils.toGenerator(AllZone.getCardFactory());
|
||||
|
||||
if (id == 1) //White Dungeon
|
||||
{
|
||||
qa.addCompy("Divine Presence");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(cards, 3, Constant.Rarity.Rare, Constant.Color.White));
|
||||
qa.setCardRewardList(pack.generateCards(3, CardRarity.Rare, Constant.Color.White));
|
||||
} else if (id == 2) //Blue Dungeon
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
@@ -197,17 +115,17 @@ public class QuestUtil {
|
||||
|
||||
qa.addCompy("Forced Fruition");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(cards, 3, Constant.Rarity.Rare, Constant.Color.Blue));
|
||||
qa.setCardRewardList(pack.generateCards(3, CardRarity.Rare, Constant.Color.Blue));
|
||||
} else if (id == 3) //Black Dungeon
|
||||
{
|
||||
qa.addCompy("Infernal Genesis");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(cards, 3, Constant.Rarity.Rare, Constant.Color.Black));
|
||||
qa.setCardRewardList(pack.generateCards(3, CardRarity.Rare, Constant.Color.Black));
|
||||
} else if (id == 4) //Red Dungeon
|
||||
{
|
||||
qa.addCompy("Furnace of Rath");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(cards, 3, Constant.Rarity.Rare, Constant.Color.Red));
|
||||
qa.setCardRewardList(pack.generateCards(3, CardRarity.Rare, Constant.Color.Red));
|
||||
} else if (id == 5) //Green Dungeon
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
@@ -223,17 +141,17 @@ public class QuestUtil {
|
||||
qa.addCompy("Eladamri's Vineyard");
|
||||
qa.addCompy("Upwelling");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(cards, 3, Constant.Rarity.Rare, Constant.Color.Green));
|
||||
qa.setCardRewardList(pack.generateCards(3, CardRarity.Rare, Constant.Color.Green));
|
||||
} else if (id == 6) //Colorless Dungeon
|
||||
{
|
||||
for (int i = 0; i < 3; i++)
|
||||
qa.addCompy("Eon Hub");
|
||||
qa.setCardRewardList(pack.generateCards(cards, 3, Constant.Rarity.Rare, Constant.Color.Colorless));
|
||||
qa.setCardRewardList(pack.generateCards(3, CardRarity.Rare, Constant.Color.Colorless));
|
||||
} else if (id == 7) //Gold Dungeon
|
||||
{
|
||||
qa.addCompy("Darksteel Ingot");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(cards, 3, Constant.Rarity.Rare, "Multicolor"));
|
||||
qa.setCardRewardList(pack.generateCards(3, CardRarity.Rare, "Multicolor"));
|
||||
} else if (id == 8) {
|
||||
CardList humanList = new CardList();
|
||||
for (int i = 0; i < 3; i++) {
|
||||
@@ -258,7 +176,7 @@ public class QuestUtil {
|
||||
humanList.add(c);
|
||||
}
|
||||
qa.setHuman(humanList);
|
||||
qa.setCardRewardList(pack.generateCards(cards, 3, Constant.Rarity.Rare, null));
|
||||
qa.setCardRewardList(pack.generateCards(3, CardRarity.Rare, null));
|
||||
} else if (id == 9) {
|
||||
CardList humanList = new CardList();
|
||||
Card c = AllZone.getCardFactory().getCard("Trusty Machete", AllZone.getHumanPlayer());
|
||||
@@ -273,7 +191,7 @@ public class QuestUtil {
|
||||
for (int i = 0; i < 3; i++)
|
||||
qa.addCompy("Wall of Wood");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(cards, 4, Constant.Rarity.Rare, Constant.Color.Green));
|
||||
qa.setCardRewardList(pack.generateCards(4, CardRarity.Rare, Constant.Color.Green));
|
||||
} else if (id == 10) {
|
||||
CardList humanList = new CardList();
|
||||
|
||||
@@ -311,7 +229,7 @@ public class QuestUtil {
|
||||
qa.addCompy("Scathe Zombies");
|
||||
qa.addCompy("Mass of Ghouls");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(cards, 4, Constant.Rarity.Rare, Constant.Color.Black));
|
||||
qa.setCardRewardList(pack.generateCards(4, CardRarity.Rare, Constant.Color.Black));
|
||||
} else if (id == 11) // The King's Contest
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
@@ -326,7 +244,7 @@ public class QuestUtil {
|
||||
|
||||
qa.addCompy("Loyal Retainers");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(cards, 3, Constant.Rarity.Rare, null));
|
||||
qa.setCardRewardList(pack.generateCards(3, CardRarity.Rare, null));
|
||||
} else if (id == 12) // Barroom Brawl
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
@@ -357,7 +275,7 @@ public class QuestUtil {
|
||||
|
||||
qa.addCompy("Lowland Giant");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(cards, 4, Constant.Rarity.Rare, null));
|
||||
qa.setCardRewardList(pack.generateCards(4, CardRarity.Rare, null));
|
||||
} else if (id == 13) // The Court Jester
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
@@ -372,7 +290,7 @@ public class QuestUtil {
|
||||
|
||||
qa.addCompy("Teferi's Puzzle Box");
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(cards, 4, Constant.Rarity.Rare, "Multicolor"));
|
||||
qa.setCardRewardList(pack.generateCards(4, CardRarity.Rare, "Multicolor"));
|
||||
} else if (id == 14) // Ancient Battlefield
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
@@ -394,7 +312,7 @@ public class QuestUtil {
|
||||
qa.addCompy(compySetupCards[i]);
|
||||
}
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(cards, 4, Constant.Rarity.Rare, null));
|
||||
qa.setCardRewardList(pack.generateCards(4, CardRarity.Rare, null));
|
||||
} else if (id == 15) // Don't Play With Matches
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
@@ -416,11 +334,11 @@ public class QuestUtil {
|
||||
qa.addCompy(compySetupCards[i]);
|
||||
}
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(cards, 4, Constant.Rarity.Rare, Constant.Color.Red));
|
||||
qa.setCardRewardList(pack.generateCards(4, CardRarity.Rare, Constant.Color.Red));
|
||||
} else if (id == 16) // Mines of Kazum Durl
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
String humanSetupCards[] = {"Dwarven Demolition Team", "Dwarven Pony", "Dwarven Trader"};
|
||||
String[] humanSetupCards = {"Dwarven Demolition Team", "Dwarven Pony", "Dwarven Trader"};
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Card c = AllZone.getCardFactory().getCard(humanSetupCards[i], AllZone.getHumanPlayer());
|
||||
@@ -432,18 +350,18 @@ public class QuestUtil {
|
||||
}
|
||||
qa.setHuman(humanList);
|
||||
|
||||
String compySetupCards[] =
|
||||
String[] compySetupCards =
|
||||
{"Wall of Earth", "Wall of Air", "Wall of Ice", "Wall of Light", "Carrion Wall", "Steel Wall"};
|
||||
|
||||
for (int i = 0; i < 6; i++) {
|
||||
qa.addCompy(compySetupCards[i]);
|
||||
}
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(cards, 4, Constant.Rarity.Rare, Constant.Color.Green));
|
||||
qa.setCardRewardList(pack.generateCards(4, CardRarity.Rare, Constant.Color.Green));
|
||||
} else if (id == 17) // House Party
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
String humanSetupCards[] = {"Hopping Automaton", "Honden of Life's Web", "Forbidden Orchard"};
|
||||
String[] humanSetupCards = {"Hopping Automaton", "Honden of Life's Web", "Forbidden Orchard"};
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Card c = AllZone.getCardFactory().getCard(humanSetupCards[i], AllZone.getHumanPlayer());
|
||||
@@ -455,17 +373,17 @@ public class QuestUtil {
|
||||
}
|
||||
qa.setHuman(humanList);
|
||||
|
||||
String compySetupCards[] = {"Honden of Infinite Rage", "Mikokoro, Center of the Sea", "Tidehollow Strix"};
|
||||
String[] compySetupCards = {"Honden of Infinite Rage", "Mikokoro, Center of the Sea", "Tidehollow Strix"};
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
qa.addCompy(compySetupCards[i]);
|
||||
}
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(cards, 4, Constant.Rarity.Rare, Constant.Color.Colorless));
|
||||
qa.setCardRewardList(pack.generateCards(4, CardRarity.Rare, Constant.Color.Colorless));
|
||||
} else if (id == 18) // Crows in the Field
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
String humanSetupCards[] = {"Straw Soldiers", "Femeref Archers", "Moonglove Extract"};
|
||||
String[] humanSetupCards = {"Straw Soldiers", "Femeref Archers", "Moonglove Extract"};
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Card c = AllZone.getCardFactory().getCard(humanSetupCards[i], AllZone.getHumanPlayer());
|
||||
@@ -477,17 +395,17 @@ public class QuestUtil {
|
||||
}
|
||||
qa.setHuman(humanList);
|
||||
|
||||
String compySetupCards[] = {"Defiant Falcon", "Soulcatcher", "Storm Crow", "Hypnotic Specter"};
|
||||
String[] compySetupCards = {"Defiant Falcon", "Soulcatcher", "Storm Crow", "Hypnotic Specter"};
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
qa.addCompy(compySetupCards[i]);
|
||||
}
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(cards, 5, Constant.Rarity.Rare, null));
|
||||
qa.setCardRewardList(pack.generateCards(5, CardRarity.Rare, null));
|
||||
} else if (id == 19) // The Desert Caravan
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
String humanSetupCards[] = {"Spidersilk Net", "Dromad Purebred"};
|
||||
String[] humanSetupCards = {"Spidersilk Net", "Dromad Purebred"};
|
||||
|
||||
for (int i = 0; i < 2; i++) {
|
||||
Card c = AllZone.getCardFactory().getCard(humanSetupCards[i], AllZone.getHumanPlayer());
|
||||
@@ -499,17 +417,17 @@ public class QuestUtil {
|
||||
}
|
||||
qa.setHuman(humanList);
|
||||
|
||||
String compySetupCards[] = {"Ambush Party", "Ambush Party", "Gnat Alley Creeper", "Ambush Party", "Ambush Party"};
|
||||
String[] compySetupCards = {"Ambush Party", "Ambush Party", "Gnat Alley Creeper", "Ambush Party", "Ambush Party"};
|
||||
|
||||
for (int i = 0; i < 5; i++) {
|
||||
qa.addCompy(compySetupCards[i]);
|
||||
}
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(cards, 5, Constant.Rarity.Rare, null));
|
||||
qa.setCardRewardList(pack.generateCards(5, CardRarity.Rare, null));
|
||||
} else if (id == 20) // Blood Oath
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
String humanSetupCards[] = {"Counterbalance", "Hatching Plans", "Ley Druid"};
|
||||
String[] humanSetupCards = {"Counterbalance", "Hatching Plans", "Ley Druid"};
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
Card c = AllZone.getCardFactory().getCard(humanSetupCards[i], AllZone.getHumanPlayer());
|
||||
@@ -521,13 +439,13 @@ public class QuestUtil {
|
||||
}
|
||||
qa.setHuman(humanList);
|
||||
|
||||
String compySetupCards[] = {"Ior Ruin Expedition", "Oversold Cemetery", "Trapjaw Kelpie"};
|
||||
String[] compySetupCards = {"Ior Ruin Expedition", "Oversold Cemetery", "Trapjaw Kelpie"};
|
||||
|
||||
for (int i = 0; i < 3; i++) {
|
||||
qa.addCompy(compySetupCards[i]);
|
||||
}
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(cards, 5, Constant.Rarity.Rare, Constant.Color.Colorless));
|
||||
qa.setCardRewardList(pack.generateCards(5, CardRarity.Rare, Constant.Color.Colorless));
|
||||
} else if (id == 21) // Private Domain
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
@@ -541,16 +459,17 @@ public class QuestUtil {
|
||||
|
||||
qa.setHuman(humanList);
|
||||
|
||||
String compySetupCards[] = {"Plains", "Island", "Swamp", "Mountain", "Forest"};
|
||||
String[] compySetupCards = {"Plains", "Island", "Swamp", "Mountain", "Forest"};
|
||||
|
||||
for (int i = 0; i < 5; i++)
|
||||
for (int i = 0; i < 5; i++) {
|
||||
qa.addCompy(compySetupCards[i]);
|
||||
}
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(cards, 6, Constant.Rarity.Rare, null));
|
||||
qa.setCardRewardList(pack.generateCards(6, CardRarity.Rare, null));
|
||||
} else if (id == 22) // Pied Piper
|
||||
{
|
||||
CardList humanList = new CardList();
|
||||
String humanSetupCards[] = {"Volunteer Militia", "Land Tax", "Elvish Farmer", "An-Havva Township"};
|
||||
String[] humanSetupCards = {"Volunteer Militia", "Land Tax", "Elvish Farmer", "An-Havva Township"};
|
||||
|
||||
for (int i = 0; i < 4; i++) {
|
||||
Card c = AllZone.getCardFactory().getCard(humanSetupCards[i], AllZone.getHumanPlayer());
|
||||
@@ -562,15 +481,15 @@ public class QuestUtil {
|
||||
}
|
||||
qa.setHuman(humanList);
|
||||
|
||||
String compySetupCards[] = {"Darksteel Citadel", "Relentless Rats"};
|
||||
String[] compySetupCards = {"Darksteel Citadel", "Relentless Rats"};
|
||||
|
||||
for (int i = 0; i < 2; i++)
|
||||
for (int i = 0; i < 2; i++) {
|
||||
qa.addCompy(compySetupCards[i]);
|
||||
}
|
||||
|
||||
qa.setCardRewardList(pack.generateCards(cards, 3, Constant.Rarity.Rare, null));
|
||||
qa.setCardRewardList(pack.generateCards(3, CardRarity.Rare, null));
|
||||
}
|
||||
|
||||
}
|
||||
*/
|
||||
|
||||
}//QuestUtil
|
||||
} //QuestUtil
|
||||
|
||||
@@ -1,100 +0,0 @@
|
||||
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;
|
||||
}
|
||||
}
|
||||
@@ -1,110 +0,0 @@
|
||||
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,6 +3,7 @@ package forge.quest.gui;
|
||||
import forge.AllZone;
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.quest.gui.bazaar.QuestBazaarPanel;
|
||||
import forge.quest.gui.main.QuestMainPanel;
|
||||
import forge.view.swing.OldGuiNewGame;
|
||||
|
||||
import javax.swing.*;
|
||||
|
||||
@@ -1,819 +0,0 @@
|
||||
package forge.quest.gui;
|
||||
|
||||
|
||||
import forge.*;
|
||||
import forge.deck.Deck;
|
||||
import forge.gui.GuiUtils;
|
||||
import forge.gui.SelectablePanel;
|
||||
import forge.gui.deckeditor.DeckEditorQuest;
|
||||
import forge.gui.deckeditor.DeckEditorShop;
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
||||
DeckEditorQuest g = new DeckEditorQuest();
|
||||
|
||||
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();
|
||||
}
|
||||
};
|
||||
|
||||
DeckEditorShop g = new DeckEditorShop(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();
|
||||
}
|
||||
|
||||
}
|
||||
41
src/test/java/forge/ReadQuestAssignmentTest.java
Normal file
41
src/test/java/forge/ReadQuestAssignmentTest.java
Normal file
@@ -0,0 +1,41 @@
|
||||
package forge;
|
||||
|
||||
import forge.error.ErrorViewer;
|
||||
import forge.properties.ForgeProps;
|
||||
import forge.properties.NewConstants;
|
||||
import org.testng.annotations.Test;
|
||||
|
||||
/**
|
||||
* Created by IntelliJ IDEA.
|
||||
* User: dhudson
|
||||
*/
|
||||
@Test(groups = {"UnitTest"}, timeOut = 1000)
|
||||
public class ReadQuestAssignmentTest implements NewConstants {
|
||||
/**
|
||||
*
|
||||
*
|
||||
*/
|
||||
@Test(groups = {"UnitTest", "fast"}, timeOut = 1000)
|
||||
public void ReadQuestAssignmentTest1() {
|
||||
try {
|
||||
ReadQuest_Assignment read = new ReadQuest_Assignment(ForgeProps.getFile(QUEST.QUESTS), null);
|
||||
|
||||
javax.swing.SwingUtilities.invokeAndWait(read);
|
||||
// read.run();
|
||||
|
||||
Quest_Assignment qa[] = new Quest_Assignment[read.allQuests.size()];
|
||||
read.allQuests.toArray(qa);
|
||||
for (int i = 0; i < qa.length; i++) {
|
||||
System.out.println(qa[i].getId());
|
||||
System.out.println(qa[i].getName());
|
||||
System.out.println(qa[i].getDesc());
|
||||
System.out.println(qa[i].getDifficulty());
|
||||
System.out.println(qa[i].isRepeatable());
|
||||
System.out.println(qa[i].getRequiredNumberWins());
|
||||
}
|
||||
} catch (Exception ex) {
|
||||
ErrorViewer.showError(ex);
|
||||
System.out.println("Error reading file " + ex);
|
||||
}
|
||||
}
|
||||
}
|
||||
Reference in New Issue
Block a user