mirror of
https://github.com/Card-Forge/forge.git
synced 2025-11-19 12:18:00 +00:00
QuestController introduced, 1st stage of quest saves refactoring
This commit is contained in:
7
.gitattributes
vendored
7
.gitattributes
vendored
@@ -11571,20 +11571,25 @@ src/main/java/forge/quest/BoosterUtils.java svneol=native#text/plain
|
|||||||
src/main/java/forge/quest/ReadPriceList.java svneol=native#text/plain
|
src/main/java/forge/quest/ReadPriceList.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/SellRules.java -text
|
src/main/java/forge/quest/SellRules.java -text
|
||||||
src/main/java/forge/quest/data/PreconReader.java -text
|
src/main/java/forge/quest/data/PreconReader.java -text
|
||||||
|
src/main/java/forge/quest/data/QuestAchievements.java -text
|
||||||
|
src/main/java/forge/quest/data/QuestAssets.java -text
|
||||||
src/main/java/forge/quest/data/QuestChallenge.java svneol=native#text/plain
|
src/main/java/forge/quest/data/QuestChallenge.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/quest/data/QuestController.java -text
|
||||||
src/main/java/forge/quest/data/QuestData.java svneol=native#text/plain
|
src/main/java/forge/quest/data/QuestData.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/data/QuestDataIO.java svneol=native#text/plain
|
src/main/java/forge/quest/data/QuestDataIO.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/data/QuestDeckMap.java -text
|
src/main/java/forge/quest/data/QuestDeckMap.java -text
|
||||||
src/main/java/forge/quest/data/QuestDuel.java svneol=native#text/plain
|
src/main/java/forge/quest/data/QuestDuel.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/quest/data/QuestDuelDifficulty.java -text
|
||||||
src/main/java/forge/quest/data/QuestEvent.java -text
|
src/main/java/forge/quest/data/QuestEvent.java -text
|
||||||
src/main/java/forge/quest/data/QuestEventManager.java svneol=native#text/plain
|
src/main/java/forge/quest/data/QuestEventManager.java svneol=native#text/plain
|
||||||
|
src/main/java/forge/quest/data/QuestMode.java -text
|
||||||
src/main/java/forge/quest/data/QuestPreferences.java svneol=native#text/plain
|
src/main/java/forge/quest/data/QuestPreferences.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/data/QuestStartPool.java -text
|
src/main/java/forge/quest/data/QuestStartPool.java -text
|
||||||
src/main/java/forge/quest/data/QuestUtil.java svneol=native#text/plain
|
src/main/java/forge/quest/data/QuestUtil.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/data/QuestUtilCards.java -text
|
src/main/java/forge/quest/data/QuestUtilCards.java -text
|
||||||
|
src/main/java/forge/quest/data/bazaar/IQuestStallPurchasable.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/data/bazaar/QuestStallDefinition.java svneol=native#text/plain
|
src/main/java/forge/quest/data/bazaar/QuestStallDefinition.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/data/bazaar/QuestStallManager.java svneol=native#text/plain
|
src/main/java/forge/quest/data/bazaar/QuestStallManager.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/data/bazaar/QuestStallPurchasable.java svneol=native#text/plain
|
|
||||||
src/main/java/forge/quest/data/bazaar/package-info.java svneol=native#text/plain
|
src/main/java/forge/quest/data/bazaar/package-info.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/data/item/QuestInventory.java svneol=native#text/plain
|
src/main/java/forge/quest/data/item/QuestInventory.java svneol=native#text/plain
|
||||||
src/main/java/forge/quest/data/item/QuestItemAbstract.java svneol=native#text/plain
|
src/main/java/forge/quest/data/item/QuestItemAbstract.java svneol=native#text/plain
|
||||||
|
|||||||
@@ -30,7 +30,7 @@ import forge.control.input.InputControl;
|
|||||||
import forge.game.GameState;
|
import forge.game.GameState;
|
||||||
import forge.properties.ForgeProps;
|
import forge.properties.ForgeProps;
|
||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
import forge.quest.data.QuestData;
|
import forge.quest.data.QuestController;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Please use public getters and setters instead of direct field access.
|
* Please use public getters and setters instead of direct field access.
|
||||||
@@ -52,7 +52,7 @@ public final class AllZone {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** Global <code>questData</code>. */
|
/** Global <code>questData</code>. */
|
||||||
private static forge.quest.data.QuestData questData = null;
|
private static forge.quest.data.QuestController quest = null;
|
||||||
|
|
||||||
/** Constant <code>NAME_CHANGER</code>. */
|
/** Constant <code>NAME_CHANGER</code>. */
|
||||||
private static final NameChanger NAME_CHANGER = new NameChanger();
|
private static final NameChanger NAME_CHANGER = new NameChanger();
|
||||||
@@ -121,22 +121,13 @@ public final class AllZone {
|
|||||||
* @return a {@link forge.quest.data.QuestData} object.
|
* @return a {@link forge.quest.data.QuestData} object.
|
||||||
* @since 1.0.15
|
* @since 1.0.15
|
||||||
*/
|
*/
|
||||||
public static forge.quest.data.QuestData getQuestData() {
|
public static forge.quest.data.QuestController getQuest() {
|
||||||
return AllZone.questData;
|
if ( null == quest )
|
||||||
|
quest = new QuestController();
|
||||||
|
return AllZone.quest;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* setQuestData.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param questData0
|
|
||||||
* a {@link forge.quest.data.QuestData} object.
|
|
||||||
* @since 1.0.15
|
|
||||||
*/
|
|
||||||
public static void setQuestData(final QuestData questData0) {
|
|
||||||
AllZone.questData = questData0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -287,32 +287,6 @@ public final class Constant {
|
|||||||
public static final String[] BASIC_LANDS = { "Plains", "Island", "Swamp", "Mountain", "Forest" };
|
public static final String[] BASIC_LANDS = { "Plains", "Island", "Swamp", "Mountain", "Forest" };
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* The Interface Quest.
|
|
||||||
*/
|
|
||||||
public static class Quest {
|
|
||||||
|
|
||||||
/** The fantasy quest. */
|
|
||||||
public static final boolean[] FANTASY_QUEST = new boolean[1];
|
|
||||||
|
|
||||||
// public static final Quest_Assignment[] qa = new Quest_Assignment[1];
|
|
||||||
|
|
||||||
/** The human list. */
|
|
||||||
public static final CardList[] HUMAN_LIST = new CardList[1];
|
|
||||||
|
|
||||||
/** The computer list. */
|
|
||||||
public static final CardList[] COMPUTER_LIST = new CardList[1];
|
|
||||||
|
|
||||||
/** The human life. */
|
|
||||||
public static final int[] HUMAN_LIFE = new int[1];
|
|
||||||
|
|
||||||
/** The computer life. */
|
|
||||||
public static final int[] COMPUTER_LIFE = new int[1];
|
|
||||||
|
|
||||||
/** The opp icon name. */
|
|
||||||
public static final String[] OPP_ICON_NAME = new String[1];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* The Interface CardTypes.
|
* The Interface CardTypes.
|
||||||
*/
|
*/
|
||||||
|
|||||||
@@ -20,7 +20,6 @@ package forge.card.spellability;
|
|||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
|
||||||
import forge.Constant;
|
import forge.Constant;
|
||||||
import forge.Constant.Zone;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
|
|||||||
@@ -84,7 +84,7 @@ public class ControlMatchUI implements CardContainer {
|
|||||||
* Fires up controllers for each component of UI.
|
* Fires up controllers for each component of UI.
|
||||||
*
|
*
|
||||||
*/
|
*/
|
||||||
public void initMatch() {
|
public void initMatch(String iconEnemy) {
|
||||||
ControlMatchUI.this.showCombat("");
|
ControlMatchUI.this.showCombat("");
|
||||||
ControlMatchUI.this.showStack();
|
ControlMatchUI.this.showStack();
|
||||||
|
|
||||||
@@ -97,8 +97,8 @@ public class ControlMatchUI implements CardContainer {
|
|||||||
if (i != 1 && Constant.Runtime.getGameType() == GameType.Quest) {
|
if (i != 1 && Constant.Runtime.getGameType() == GameType.Quest) {
|
||||||
String filename = ForgeProps.getFile(NewConstants.IMAGE_ICON) + File.separator;
|
String filename = ForgeProps.getFile(NewConstants.IMAGE_ICON) + File.separator;
|
||||||
|
|
||||||
if (Constant.Quest.OPP_ICON_NAME[0] != null) {
|
if (iconEnemy != null) {
|
||||||
filename += Constant.Quest.OPP_ICON_NAME[0];
|
filename += iconEnemy;
|
||||||
final File f = new File(filename);
|
final File f = new File(filename);
|
||||||
img = (f.exists()
|
img = (f.exists()
|
||||||
? new ImageIcon(filename).getImage()
|
? new ImageIcon(filename).getImage()
|
||||||
|
|||||||
@@ -37,7 +37,7 @@ import forge.Singletons;
|
|||||||
import forge.card.abilityfactory.AbilityFactory;
|
import forge.card.abilityfactory.AbilityFactory;
|
||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.game.GamePlayerRating;
|
import forge.game.GamePlayerRating;
|
||||||
import forge.quest.data.QuestData;
|
import forge.quest.data.QuestController;
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* InputMulligan class.
|
* InputMulligan class.
|
||||||
@@ -103,8 +103,8 @@ public class InputMulligan extends Input {
|
|||||||
|
|
||||||
final int newHand = this.doMulligan(humanPlayer, humanRating);
|
final int newHand = this.doMulligan(humanPlayer, humanRating);
|
||||||
|
|
||||||
final QuestData quest = AllZone.getQuestData();
|
final QuestController quest = AllZone.getQuest();
|
||||||
if ((quest != null) && quest.getInventory().hasItem("Sleight") && (humanRating.getMulliganCount() == 1)) {
|
if (quest.isLoaded() && quest.getAssets().getInventory().hasItem("Sleight") && (humanRating.getMulliganCount() == 1)) {
|
||||||
AllZone.getHumanPlayer().drawCard();
|
AllZone.getHumanPlayer().drawCard();
|
||||||
humanRating.notifyOpeningHandSize(newHand + 1);
|
humanRating.notifyOpeningHandSize(newHand + 1);
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -51,12 +51,12 @@ public class GameNew {
|
|||||||
*   int.
|
*   int.
|
||||||
* @param computerLife
|
* @param computerLife
|
||||||
*   int.
|
*   int.
|
||||||
|
* @param iconEnemy
|
||||||
*/
|
*/
|
||||||
public static void newGame(final Deck humanDeck, final Deck computerDeck, final CardList human,
|
public static void newGame(final Deck humanDeck, final Deck computerDeck, final CardList human,
|
||||||
final CardList computer, final int humanLife, final int computerLife) {
|
final CardList computer, final int humanLife, final int computerLife, String iconEnemy) {
|
||||||
Singletons.getControl().changeState(FControl.MATCH_SCREEN);
|
Singletons.getControl().changeState(FControl.MATCH_SCREEN);
|
||||||
Singletons.getControl().getControlMatch().initMatch();
|
Singletons.getControl().getControlMatch().initMatch(iconEnemy);
|
||||||
Constant.Quest.FANTASY_QUEST[0] = true;
|
|
||||||
|
|
||||||
GameNew.newGameCleanup();
|
GameNew.newGameCleanup();
|
||||||
GameNew.newMatchCleanup();
|
GameNew.newMatchCleanup();
|
||||||
@@ -88,8 +88,7 @@ public class GameNew {
|
|||||||
*/
|
*/
|
||||||
public static void newGame(final Deck humanDeck, final Deck computerDeck) {
|
public static void newGame(final Deck humanDeck, final Deck computerDeck) {
|
||||||
Singletons.getControl().changeState(FControl.MATCH_SCREEN);
|
Singletons.getControl().changeState(FControl.MATCH_SCREEN);
|
||||||
Singletons.getControl().getControlMatch().initMatch();
|
Singletons.getControl().getControlMatch().initMatch(null);
|
||||||
Constant.Quest.FANTASY_QUEST[0] = false;
|
|
||||||
|
|
||||||
GameNew.newGameCleanup();
|
GameNew.newGameCleanup();
|
||||||
GameNew.newMatchCleanup();
|
GameNew.newMatchCleanup();
|
||||||
|
|||||||
@@ -46,7 +46,7 @@ import forge.gui.deckeditor.elements.TableView;
|
|||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
import forge.item.InventoryItem;
|
import forge.item.InventoryItem;
|
||||||
import forge.item.ItemPool;
|
import forge.item.ItemPool;
|
||||||
import forge.quest.data.QuestData;
|
import forge.quest.data.QuestController;
|
||||||
import forge.util.Predicate;
|
import forge.util.Predicate;
|
||||||
|
|
||||||
//import forge.quest.data.QuestBoosterPack;
|
//import forge.quest.data.QuestBoosterPack;
|
||||||
@@ -74,7 +74,7 @@ public final class DeckEditorQuest extends DeckEditorBase<CardPrinted, Deck> {
|
|||||||
|
|
||||||
private FilterNameTypeSetPanel filterNameTypeSet;
|
private FilterNameTypeSetPanel filterNameTypeSet;
|
||||||
|
|
||||||
private final QuestData questData;
|
private final QuestController questData;
|
||||||
private final DeckController<Deck> controller;
|
private final DeckController<Deck> controller;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -179,7 +179,7 @@ public final class DeckEditorQuest extends DeckEditorBase<CardPrinted, Deck> {
|
|||||||
* @param questData2
|
* @param questData2
|
||||||
* the quest data2
|
* the quest data2
|
||||||
*/
|
*/
|
||||||
public DeckEditorQuest(final QuestData questData2) {
|
public DeckEditorQuest(final QuestController questData2) {
|
||||||
|
|
||||||
this.questData = questData2;
|
this.questData = questData2;
|
||||||
try {
|
try {
|
||||||
|
|||||||
@@ -54,7 +54,7 @@ import forge.item.OpenablePack;
|
|||||||
import forge.item.PreconDeck;
|
import forge.item.PreconDeck;
|
||||||
import forge.item.TournamentPack;
|
import forge.item.TournamentPack;
|
||||||
import forge.quest.ReadPriceList;
|
import forge.quest.ReadPriceList;
|
||||||
import forge.quest.data.QuestData;
|
import forge.quest.data.QuestController;
|
||||||
import forge.util.Predicate;
|
import forge.util.Predicate;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -81,7 +81,7 @@ public final class QuestCardShop extends DeckEditorBase<InventoryItem, DeckBase>
|
|||||||
|
|
||||||
private double multiplier;
|
private double multiplier;
|
||||||
|
|
||||||
private final QuestData questData;
|
private final QuestController questData;
|
||||||
|
|
||||||
// get pricelist:
|
// get pricelist:
|
||||||
private final ReadPriceList r = new ReadPriceList();
|
private final ReadPriceList r = new ReadPriceList();
|
||||||
@@ -211,7 +211,7 @@ public final class QuestCardShop extends DeckEditorBase<InventoryItem, DeckBase>
|
|||||||
* @param qd
|
* @param qd
|
||||||
* a {@link forge.quest.data.QuestData} object.
|
* a {@link forge.quest.data.QuestData} object.
|
||||||
*/
|
*/
|
||||||
public QuestCardShop(final QuestData qd) {
|
public QuestCardShop(final QuestController qd) {
|
||||||
this.questData = qd;
|
this.questData = qd;
|
||||||
try {
|
try {
|
||||||
this.setFilterBoxes(null);
|
this.setFilterBoxes(null);
|
||||||
@@ -265,7 +265,7 @@ public final class QuestCardShop extends DeckEditorBase<InventoryItem, DeckBase>
|
|||||||
this.setTitle("Card Shop");
|
this.setTitle("Card Shop");
|
||||||
|
|
||||||
this.creditsLabel.setBounds(new Rectangle(350, 365, 714, 31));
|
this.creditsLabel.setBounds(new Rectangle(350, 365, 714, 31));
|
||||||
this.creditsLabel.setText("Total credits: " + this.questData.getCredits());
|
this.creditsLabel.setText("Total credits: " + this.questData.getAssets().getCredits());
|
||||||
this.creditsLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
this.creditsLabel.setFont(new java.awt.Font("Dialog", 0, 14));
|
||||||
this.sellPercentageLabel.setBounds(new Rectangle(380, 395, 450, 31));
|
this.sellPercentageLabel.setBounds(new Rectangle(380, 395, 450, 31));
|
||||||
this.sellPercentageLabel.setText("(Sell percentage: " + this.multiplier + ")");
|
this.sellPercentageLabel.setText("(Sell percentage: " + this.multiplier + ")");
|
||||||
@@ -326,7 +326,7 @@ public final class QuestCardShop extends DeckEditorBase<InventoryItem, DeckBase>
|
|||||||
|
|
||||||
final int value = this.getCardValue(item);
|
final int value = this.getCardValue(item);
|
||||||
|
|
||||||
if (value <= this.questData.getCredits()) {
|
if (value <= this.questData.getAssets().getCredits()) {
|
||||||
|
|
||||||
if (item instanceof CardPrinted) {
|
if (item instanceof CardPrinted) {
|
||||||
this.getTopTableWithCards().removeCard(item);
|
this.getTopTableWithCards().removeCard(item);
|
||||||
@@ -368,7 +368,7 @@ public final class QuestCardShop extends DeckEditorBase<InventoryItem, DeckBase>
|
|||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
this.creditsLabel.setText("Total credits: " + this.questData.getCredits());
|
this.creditsLabel.setText("Total credits: " + this.questData.getAssets().getCredits());
|
||||||
} else {
|
} else {
|
||||||
JOptionPane.showMessageDialog(null, "Not enough credits!");
|
JOptionPane.showMessageDialog(null, "Not enough credits!");
|
||||||
}
|
}
|
||||||
@@ -398,7 +398,7 @@ public final class QuestCardShop extends DeckEditorBase<InventoryItem, DeckBase>
|
|||||||
.getSellPriceLimit());
|
.getSellPriceLimit());
|
||||||
this.questData.getCards().sellCard(card, price);
|
this.questData.getCards().sellCard(card, price);
|
||||||
|
|
||||||
this.creditsLabel.setText("Total credits: " + this.questData.getCredits());
|
this.creditsLabel.setText("Total credits: " + this.questData.getAssets().getCredits());
|
||||||
}
|
}
|
||||||
|
|
||||||
@SuppressWarnings("rawtypes")
|
@SuppressWarnings("rawtypes")
|
||||||
|
|||||||
@@ -15,6 +15,7 @@ import forge.gui.home.ICSubmenu;
|
|||||||
import forge.gui.home.quest.SubmenuQuestUtil.SelectablePanel;
|
import forge.gui.home.quest.SubmenuQuestUtil.SelectablePanel;
|
||||||
import forge.gui.toolbox.FLabel;
|
import forge.gui.toolbox.FLabel;
|
||||||
import forge.quest.data.QuestChallenge;
|
import forge.quest.data.QuestChallenge;
|
||||||
|
import forge.quest.data.QuestController;
|
||||||
import forge.quest.data.QuestEventManager;
|
import forge.quest.data.QuestEventManager;
|
||||||
import forge.view.ViewHomeUI;
|
import forge.view.ViewHomeUI;
|
||||||
|
|
||||||
@@ -26,15 +27,17 @@ public enum CSubmenuChallenges implements ICSubmenu {
|
|||||||
/** */
|
/** */
|
||||||
SINGLETON_INSTANCE;
|
SINGLETON_INSTANCE;
|
||||||
|
|
||||||
|
|
||||||
/* (non-Javadoc)
|
/* (non-Javadoc)
|
||||||
* @see forge.control.home.IControlSubmenu#getCommand()
|
* @see forge.control.home.IControlSubmenu#getCommand()
|
||||||
*/
|
*/
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@Override
|
@Override
|
||||||
public Command getMenuCommand() {
|
public Command getMenuCommand() {
|
||||||
|
final QuestController qc = AllZone.getQuest();
|
||||||
return new Command() {
|
return new Command() {
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if (AllZone.getQuestData() == null) {
|
if (qc.getAchievements() == null) {
|
||||||
ViewHomeUI.SINGLETON_INSTANCE.itemClick(EMenuItem.QUEST_DATA);
|
ViewHomeUI.SINGLETON_INSTANCE.itemClick(EMenuItem.QUEST_DATA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -70,17 +73,18 @@ public enum CSubmenuChallenges implements ICSubmenu {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
final QuestController quest = AllZone.getQuest();
|
||||||
view.getCbPlant().addActionListener(new ActionListener() {
|
view.getCbPlant().addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
AllZone.getQuestData().getPetManager().setUsePlant(view.getCbPlant().isSelected());
|
quest.getAssets().getPetManager().setUsePlant(view.getCbPlant().isSelected());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
view.getCbZep().addActionListener(new ActionListener() {
|
view.getCbZep().addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
AllZone.getQuestData().getPetManager().setUsePlant(view.getCbZep().isSelected());
|
quest.getAssets().getPetManager().setUsePlant(view.getCbZep().isSelected());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -90,10 +94,10 @@ public enum CSubmenuChallenges implements ICSubmenu {
|
|||||||
final int index = view.getCbxPet().getSelectedIndex();
|
final int index = view.getCbxPet().getSelectedIndex();
|
||||||
if (index != -1 && index != 0) {
|
if (index != -1 && index != 0) {
|
||||||
final String pet = ((String) view.getCbxPet().getSelectedItem());
|
final String pet = ((String) view.getCbxPet().getSelectedItem());
|
||||||
AllZone.getQuestData().getPetManager().setSelectedPet(pet.substring(7));
|
quest.getAssets().getPetManager().setSelectedPet(pet.substring(7));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
AllZone.getQuestData().getPetManager().setSelectedPet(null);
|
quest.getAssets().getPetManager().setSelectedPet(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -108,12 +112,12 @@ public enum CSubmenuChallenges implements ICSubmenu {
|
|||||||
|
|
||||||
final VSubmenuChallenges view = VSubmenuChallenges.SINGLETON_INSTANCE;
|
final VSubmenuChallenges view = VSubmenuChallenges.SINGLETON_INSTANCE;
|
||||||
|
|
||||||
if (AllZone.getQuestData() != null) {
|
if (AllZone.getQuest().getAchievements() != null) {
|
||||||
view.getLblTitle().setText("Challenges: " + AllZone.getQuestData().getRank());
|
view.getLblTitle().setText("Challenges: " + AllZone.getQuest().getRank());
|
||||||
|
|
||||||
view.getPnlChallenges().removeAll();
|
view.getPnlChallenges().removeAll();
|
||||||
final List<QuestChallenge> challenges =
|
final List<QuestChallenge> challenges =
|
||||||
QuestEventManager.generateChallenges();
|
QuestEventManager.INSTANCE.generateChallenges();
|
||||||
|
|
||||||
for (final QuestChallenge c : challenges) {
|
for (final QuestChallenge c : challenges) {
|
||||||
final SelectablePanel temp = new SelectablePanel(c);
|
final SelectablePanel temp = new SelectablePanel(c);
|
||||||
|
|||||||
@@ -9,6 +9,7 @@ import forge.Command;
|
|||||||
import forge.gui.home.EMenuItem;
|
import forge.gui.home.EMenuItem;
|
||||||
import forge.gui.home.ICSubmenu;
|
import forge.gui.home.ICSubmenu;
|
||||||
import forge.gui.home.quest.SubmenuQuestUtil.SelectablePanel;
|
import forge.gui.home.quest.SubmenuQuestUtil.SelectablePanel;
|
||||||
|
import forge.quest.data.QuestController;
|
||||||
import forge.quest.data.QuestDuel;
|
import forge.quest.data.QuestDuel;
|
||||||
import forge.quest.data.QuestEventManager;
|
import forge.quest.data.QuestEventManager;
|
||||||
import forge.view.ViewHomeUI;
|
import forge.view.ViewHomeUI;
|
||||||
@@ -27,9 +28,10 @@ public enum CSubmenuDuels implements ICSubmenu {
|
|||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
@Override
|
@Override
|
||||||
public Command getMenuCommand() {
|
public Command getMenuCommand() {
|
||||||
|
final QuestController qc = AllZone.getQuest();
|
||||||
return new Command() {
|
return new Command() {
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if (AllZone.getQuestData() == null) {
|
if (qc.getAchievements() == null) {
|
||||||
ViewHomeUI.SINGLETON_INSTANCE.itemClick(EMenuItem.QUEST_DATA);
|
ViewHomeUI.SINGLETON_INSTANCE.itemClick(EMenuItem.QUEST_DATA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -65,17 +67,18 @@ public enum CSubmenuDuels implements ICSubmenu {
|
|||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
final QuestController quest = AllZone.getQuest();
|
||||||
view.getCbPlant().addActionListener(new ActionListener() {
|
view.getCbPlant().addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
AllZone.getQuestData().getPetManager().setUsePlant(view.getCbPlant().isSelected());
|
quest.getAssets().getPetManager().setUsePlant(view.getCbPlant().isSelected());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
view.getCbZep().addActionListener(new ActionListener() {
|
view.getCbZep().addActionListener(new ActionListener() {
|
||||||
@Override
|
@Override
|
||||||
public void actionPerformed(ActionEvent arg0) {
|
public void actionPerformed(ActionEvent arg0) {
|
||||||
AllZone.getQuestData().getPetManager().setUsePlant(view.getCbZep().isSelected());
|
quest.getAssets().getPetManager().setUsePlant(view.getCbZep().isSelected());
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
@@ -85,10 +88,10 @@ public enum CSubmenuDuels implements ICSubmenu {
|
|||||||
final int index = view.getCbxPet().getSelectedIndex();
|
final int index = view.getCbxPet().getSelectedIndex();
|
||||||
if (index != -1 && index != 0) {
|
if (index != -1 && index != 0) {
|
||||||
final String pet = ((String) view.getCbxPet().getSelectedItem());
|
final String pet = ((String) view.getCbxPet().getSelectedItem());
|
||||||
AllZone.getQuestData().getPetManager().setSelectedPet(pet.substring(7));
|
quest.getAssets().getPetManager().setSelectedPet(pet.substring(7));
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
AllZone.getQuestData().getPetManager().setSelectedPet(null);
|
quest.getAssets().getPetManager().setSelectedPet(null);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
@@ -103,11 +106,11 @@ public enum CSubmenuDuels implements ICSubmenu {
|
|||||||
|
|
||||||
final VSubmenuDuels view = VSubmenuDuels.SINGLETON_INSTANCE;
|
final VSubmenuDuels view = VSubmenuDuels.SINGLETON_INSTANCE;
|
||||||
|
|
||||||
if (AllZone.getQuestData() != null) {
|
if (AllZone.getQuest().getAchievements() != null) {
|
||||||
view.getLblTitle().setText("Duels: " + AllZone.getQuestData().getRank());
|
view.getLblTitle().setText("Duels: " + AllZone.getQuest().getRank());
|
||||||
|
|
||||||
view.getPnlDuels().removeAll();
|
view.getPnlDuels().removeAll();
|
||||||
final List<QuestDuel> duels = QuestEventManager.generateDuels();
|
final List<QuestDuel> duels = QuestEventManager.INSTANCE.generateDuels();
|
||||||
|
|
||||||
for (final QuestDuel d : duels) {
|
for (final QuestDuel d : duels) {
|
||||||
final SelectablePanel temp = new SelectablePanel(d);
|
final SelectablePanel temp = new SelectablePanel(d);
|
||||||
|
|||||||
@@ -7,14 +7,17 @@ import forge.gui.GuiUtils;
|
|||||||
import forge.gui.home.ICSubmenu;
|
import forge.gui.home.ICSubmenu;
|
||||||
import forge.properties.ForgeProps;
|
import forge.properties.ForgeProps;
|
||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
|
import forge.quest.data.QuestController;
|
||||||
import forge.quest.data.QuestData;
|
import forge.quest.data.QuestData;
|
||||||
import forge.quest.data.QuestDataIO;
|
import forge.quest.data.QuestDataIO;
|
||||||
|
import forge.quest.data.QuestMode;
|
||||||
import forge.quest.data.QuestPreferences.QPref;
|
import forge.quest.data.QuestPreferences.QPref;
|
||||||
import forge.quest.data.QuestStartPool;
|
import forge.quest.data.QuestStartPool;
|
||||||
|
|
||||||
import javax.swing.*;
|
import javax.swing.*;
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FilenameFilter;
|
import java.io.FilenameFilter;
|
||||||
|
import java.util.ArrayList;
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
|
|
||||||
@@ -64,6 +67,7 @@ public enum CSubmenuQuestData implements ICSubmenu {
|
|||||||
public void update() {
|
public void update() {
|
||||||
final VSubmenuQuestData view = VSubmenuQuestData.SINGLETON_INSTANCE;
|
final VSubmenuQuestData view = VSubmenuQuestData.SINGLETON_INSTANCE;
|
||||||
final File dirQuests = ForgeProps.getFile(NewConstants.Quest.DATA_DIR);
|
final File dirQuests = ForgeProps.getFile(NewConstants.Quest.DATA_DIR);
|
||||||
|
final QuestController qc = AllZone.getQuest();
|
||||||
|
|
||||||
// Temporary transition code between v1.2.2 and v1.2.3.
|
// Temporary transition code between v1.2.2 and v1.2.3.
|
||||||
// Can be safely deleted after release of 1.2.3.
|
// Can be safely deleted after release of 1.2.3.
|
||||||
@@ -90,7 +94,7 @@ public enum CSubmenuQuestData implements ICSubmenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Populate list with available quest datas.
|
// Populate list with available quest datas.
|
||||||
view.getLstQuests().setQuests(arrQuests.values().toArray(new QuestData[0]));
|
view.getLstQuests().setQuests(new ArrayList<QuestData>(arrQuests.values()));
|
||||||
|
|
||||||
// If there are quests available, force select.
|
// If there are quests available, force select.
|
||||||
if (arrQuests.size() > 0) {
|
if (arrQuests.size() > 0) {
|
||||||
@@ -106,10 +110,10 @@ public enum CSubmenuQuestData implements ICSubmenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Drop into AllZone.
|
// Drop into AllZone.
|
||||||
AllZone.setQuestData(view.getLstQuests().getSelectedQuest());
|
qc.load(view.getLstQuests().getSelectedQuest());
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
AllZone.setQuestData(null);
|
qc.load(null);
|
||||||
}
|
}
|
||||||
|
|
||||||
view.getLstQuests().setSelectCommand(cmdQuestSelect);
|
view.getLstQuests().setSelectCommand(cmdQuestSelect);
|
||||||
@@ -122,11 +126,8 @@ public enum CSubmenuQuestData implements ICSubmenu {
|
|||||||
private void newQuest() {
|
private void newQuest() {
|
||||||
final VSubmenuQuestData view = VSubmenuQuestData.SINGLETON_INSTANCE;
|
final VSubmenuQuestData view = VSubmenuQuestData.SINGLETON_INSTANCE;
|
||||||
int difficulty = 0;
|
int difficulty = 0;
|
||||||
QuestData newdata = new QuestData();
|
|
||||||
|
|
||||||
final String mode = view.getRadFantasy().isSelected()
|
final QuestMode mode = view.getRadFantasy().isSelected() ? QuestMode.Fantasy : QuestMode.Classic;
|
||||||
? forge.quest.data.QuestData.FANTASY
|
|
||||||
: forge.quest.data.QuestData.CLASSIC;
|
|
||||||
|
|
||||||
if (view.getRadEasy().isSelected()) {
|
if (view.getRadEasy().isSelected()) {
|
||||||
difficulty = 0;
|
difficulty = 0;
|
||||||
@@ -163,9 +164,8 @@ public enum CSubmenuQuestData implements ICSubmenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Give the user a few cards to build a deck
|
// Give the user a few cards to build a deck
|
||||||
newdata.newGame(difficulty, mode, startPool, startPrecon);
|
AllZone.getQuest().newGame(questName, difficulty, mode, startPool, startPrecon);
|
||||||
newdata.setName(questName);
|
AllZone.getQuest().save();
|
||||||
newdata.saveData();
|
|
||||||
|
|
||||||
// Save in preferences.
|
// Save in preferences.
|
||||||
Singletons.getModel().getQuestPreferences().setPreference(QPref.CURRENT_QUEST, questName + ".dat");
|
Singletons.getModel().getQuestPreferences().setPreference(QPref.CURRENT_QUEST, questName + ".dat");
|
||||||
@@ -176,12 +176,12 @@ public enum CSubmenuQuestData implements ICSubmenu {
|
|||||||
|
|
||||||
/** Changes between quest data files. */
|
/** Changes between quest data files. */
|
||||||
private void changeQuest() {
|
private void changeQuest() {
|
||||||
AllZone.setQuestData(VSubmenuQuestData.SINGLETON_INSTANCE
|
AllZone.getQuest().load(VSubmenuQuestData.SINGLETON_INSTANCE
|
||||||
.getLstQuests().getSelectedQuest());
|
.getLstQuests().getSelectedQuest());
|
||||||
|
|
||||||
// Save in preferences.
|
// Save in preferences.
|
||||||
Singletons.getModel().getQuestPreferences().setPreference(QPref.CURRENT_QUEST,
|
Singletons.getModel().getQuestPreferences().setPreference(QPref.CURRENT_QUEST,
|
||||||
AllZone.getQuestData().getName() + ".dat");
|
AllZone.getQuest().getName() + ".dat");
|
||||||
Singletons.getModel().getQuestPreferences().save();
|
Singletons.getModel().getQuestPreferences().save();
|
||||||
|
|
||||||
SubmenuQuestUtil.updateStatsAndPet();
|
SubmenuQuestUtil.updateStatsAndPet();
|
||||||
|
|||||||
@@ -10,7 +10,7 @@ import forge.gui.OverlayUtils;
|
|||||||
import forge.gui.deckeditor.DeckEditorQuest;
|
import forge.gui.deckeditor.DeckEditorQuest;
|
||||||
import forge.gui.home.EMenuItem;
|
import forge.gui.home.EMenuItem;
|
||||||
import forge.gui.home.ICSubmenu;
|
import forge.gui.home.ICSubmenu;
|
||||||
import forge.quest.data.QuestData;
|
import forge.quest.data.QuestController;
|
||||||
import forge.quest.data.QuestPreferences.QPref;
|
import forge.quest.data.QuestPreferences.QPref;
|
||||||
import forge.view.ViewHomeUI;
|
import forge.view.ViewHomeUI;
|
||||||
|
|
||||||
@@ -27,7 +27,7 @@ public enum CSubmenuQuestDecks implements ICSubmenu {
|
|||||||
private final Command cmdDeckExit = new Command() {
|
private final Command cmdDeckExit = new Command() {
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
AllZone.getQuestData().saveData();
|
AllZone.getQuest().save();
|
||||||
OverlayUtils.hideOverlay();
|
OverlayUtils.hideOverlay();
|
||||||
update();
|
update();
|
||||||
}
|
}
|
||||||
@@ -52,10 +52,11 @@ public enum CSubmenuQuestDecks implements ICSubmenu {
|
|||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public Command getMenuCommand() {
|
public Command getMenuCommand() {
|
||||||
|
final QuestController qc = AllZone.getQuest();
|
||||||
return new Command() {
|
return new Command() {
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
if (AllZone.getQuestData() == null) {
|
if (qc.getAchievements() == null) {
|
||||||
ViewHomeUI.SINGLETON_INSTANCE.itemClick(EMenuItem.QUEST_DATA);
|
ViewHomeUI.SINGLETON_INSTANCE.itemClick(EMenuItem.QUEST_DATA);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -73,7 +74,7 @@ public enum CSubmenuQuestDecks implements ICSubmenu {
|
|||||||
VSubmenuQuestDecks.SINGLETON_INSTANCE.getBtnNewDeck().setCommand(new Command() {
|
VSubmenuQuestDecks.SINGLETON_INSTANCE.getBtnNewDeck().setCommand(new Command() {
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
final DeckEditorQuest editor = new DeckEditorQuest(AllZone.getQuestData());
|
final DeckEditorQuest editor = new DeckEditorQuest(AllZone.getQuest());
|
||||||
editor.show(cmdDeckExit);
|
editor.show(cmdDeckExit);
|
||||||
OverlayUtils.showOverlay();
|
OverlayUtils.showOverlay();
|
||||||
editor.setVisible(true);
|
editor.setVisible(true);
|
||||||
@@ -87,14 +88,15 @@ public enum CSubmenuQuestDecks implements ICSubmenu {
|
|||||||
@Override
|
@Override
|
||||||
public void update() {
|
public void update() {
|
||||||
final VSubmenuQuestDecks view = VSubmenuQuestDecks.SINGLETON_INSTANCE;
|
final VSubmenuQuestDecks view = VSubmenuQuestDecks.SINGLETON_INSTANCE;
|
||||||
final QuestData qData = AllZone.getQuestData();
|
final QuestController qData = AllZone.getQuest();
|
||||||
|
boolean hasQuest = qData.getAssets() != null;
|
||||||
// Retrieve and set all decks
|
// Retrieve and set all decks
|
||||||
view.getLstDecks().setDecks(qData != null ? qData.getMyDecks() : new ArrayList<Deck>());
|
view.getLstDecks().setDecks(hasQuest ? qData.getMyDecks() : new ArrayList<Deck>());
|
||||||
|
|
||||||
// Look through list for preferred deck from prefs
|
// Look through list for preferred deck from prefs
|
||||||
currentDeck = null;
|
currentDeck = null;
|
||||||
|
|
||||||
if (qData != null) {
|
if (hasQuest) {
|
||||||
final String cd = Singletons.getModel().getQuestPreferences().getPreference(QPref.CURRENT_DECK);
|
final String cd = Singletons.getModel().getQuestPreferences().getPreference(QPref.CURRENT_DECK);
|
||||||
|
|
||||||
for (Deck d : qData.getMyDecks()) {
|
for (Deck d : qData.getMyDecks()) {
|
||||||
|
|||||||
@@ -67,7 +67,7 @@ public class QuestFileLister extends JPanel {
|
|||||||
}
|
}
|
||||||
|
|
||||||
/** @param qd0   {@link forge.quest.data.QuestData}[] */
|
/** @param qd0   {@link forge.quest.data.QuestData}[] */
|
||||||
public void setQuests(QuestData[] qd0) {
|
public void setQuests(List<QuestData> qd0) {
|
||||||
this.removeAll();
|
this.removeAll();
|
||||||
List<RowPanel> tempRows = new ArrayList<RowPanel>();
|
List<RowPanel> tempRows = new ArrayList<RowPanel>();
|
||||||
List<QuestData> sorted = new ArrayList<QuestData>();
|
List<QuestData> sorted = new ArrayList<QuestData>();
|
||||||
@@ -95,13 +95,13 @@ public class QuestFileLister extends JPanel {
|
|||||||
RowPanel row;
|
RowPanel row;
|
||||||
String mode;
|
String mode;
|
||||||
for (QuestData qd : sorted) {
|
for (QuestData qd : sorted) {
|
||||||
mode = qd.getMode().equals("Realistic") ? "Classic" : qd.getMode();
|
mode = qd.getMode().toString();
|
||||||
row = new RowPanel(qd);
|
row = new RowPanel(qd);
|
||||||
row.add(new DeleteButton(row), "w 15%!, h 20px!, gap 0 0 5px 0");
|
row.add(new DeleteButton(row), "w 15%!, h 20px!, gap 0 0 5px 0");
|
||||||
row.add(new EditButton(row), "w 15%!, h 20px!, gaptop 5px");
|
row.add(new EditButton(row), "w 15%!, h 20px!, gaptop 5px");
|
||||||
row.add(new FLabel.Builder().text(qd.getName()).build(), "w 40%!, h 20px!, gap 0 0 5px 0");
|
row.add(new FLabel.Builder().text(qd.getName()).build(), "w 40%!, h 20px!, gap 0 0 5px 0");
|
||||||
row.add(new FLabel.Builder().text(mode).fontAlign(SwingConstants.CENTER).build(), "w 15%!, h 20px!, gap 0 0 5px 0");
|
row.add(new FLabel.Builder().text(mode).fontAlign(SwingConstants.CENTER).build(), "w 15%!, h 20px!, gap 0 0 5px 0");
|
||||||
row.add(new FLabel.Builder().text(qd.getWin() + "/" + qd.getLost())
|
row.add(new FLabel.Builder().text(qd.getAchievements().getWin() + "/" + qd.getAchievements().getLost())
|
||||||
.fontAlign(SwingConstants.CENTER).build(), "w 15%!, h 20px!, gap 0 0 5px 0");
|
.fontAlign(SwingConstants.CENTER).build(), "w 15%!, h 20px!, gap 0 0 5px 0");
|
||||||
this.add(row, "w 98%!, h 30px!, gap 1% 0 0 0");
|
this.add(row, "w 98%!, h 30px!, gap 1% 0 0 0");
|
||||||
tempRows.add(row);
|
tempRows.add(row);
|
||||||
|
|||||||
@@ -24,9 +24,13 @@ import forge.gui.toolbox.FSkin;
|
|||||||
import forge.gui.toolbox.FTextArea;
|
import forge.gui.toolbox.FTextArea;
|
||||||
import forge.properties.ForgeProps;
|
import forge.properties.ForgeProps;
|
||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
|
import forge.quest.data.QuestAchievements;
|
||||||
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.QuestChallenge;
|
import forge.quest.data.QuestChallenge;
|
||||||
import forge.quest.data.QuestData;
|
import forge.quest.data.QuestController;
|
||||||
import forge.quest.data.QuestEvent;
|
import forge.quest.data.QuestEvent;
|
||||||
|
import forge.quest.data.QuestEventManager;
|
||||||
|
import forge.quest.data.QuestMode;
|
||||||
import forge.quest.data.QuestPreferences.QPref;
|
import forge.quest.data.QuestPreferences.QPref;
|
||||||
import forge.quest.data.QuestUtil;
|
import forge.quest.data.QuestUtil;
|
||||||
import forge.quest.data.item.QuestItemZeppelin;
|
import forge.quest.data.item.QuestItemZeppelin;
|
||||||
@@ -47,28 +51,29 @@ public class SubmenuQuestUtil {
|
|||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
public static int nextChallengeInWins() {
|
public static int nextChallengeInWins() {
|
||||||
final QuestData qData = AllZone.getQuestData();
|
final QuestController qData = AllZone.getQuest();
|
||||||
final int challengesPlayed = qData.getChallengesPlayed();
|
final int challengesPlayed = qData.getAchievements().getChallengesPlayed();
|
||||||
|
|
||||||
int mul = 5;
|
int mul = 5;
|
||||||
if (qData.getInventory().hasItem("Zeppelin")) {
|
if (qData.getAssets().getInventory().hasItem("Zeppelin")) {
|
||||||
mul = 3;
|
mul = 3;
|
||||||
} else if (qData.getInventory().hasItem("Map")) {
|
} else if (qData.getAssets().getInventory().hasItem("Map")) {
|
||||||
mul = 4;
|
mul = 4;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int delta = (qData.getWin() < 20
|
final int wins = qData.getAchievements().getWin();
|
||||||
? 20 - qData.getWin()
|
final int delta = (wins < 20 ? 20 - wins : (challengesPlayed * mul) - wins);
|
||||||
: (challengesPlayed * mul) - qData.getWin());
|
|
||||||
|
|
||||||
return (delta > 0) ? delta : 0;
|
return (delta > 0) ? delta : 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** Updates stats, pets panels for both duels and challenges. */
|
/** Updates stats, pets panels for both duels and challenges. */
|
||||||
public static void updateStatsAndPet() {
|
public static void updateStatsAndPet() {
|
||||||
final QuestData qData = AllZone.getQuestData();
|
final QuestController qData = AllZone.getQuest();
|
||||||
|
final QuestAchievements qA = qData.getAchievements();
|
||||||
|
final QuestAssets qS = qData.getAssets();
|
||||||
|
|
||||||
if (qData == null) { return; }
|
if (qA == null) { return; }
|
||||||
|
|
||||||
final IStatsAndPet[] viewsToUpdate = new IStatsAndPet[] {
|
final IStatsAndPet[] viewsToUpdate = new IStatsAndPet[] {
|
||||||
VSubmenuDuels.SINGLETON_INSTANCE,
|
VSubmenuDuels.SINGLETON_INSTANCE,
|
||||||
@@ -83,10 +88,10 @@ public class SubmenuQuestUtil {
|
|||||||
view.getLblLife().setVisible(true);
|
view.getLblLife().setVisible(true);
|
||||||
|
|
||||||
// Stats panel
|
// Stats panel
|
||||||
view.getLblCredits().setText("Credits: " + qData.getCredits());
|
view.getLblCredits().setText("Credits: " + qS.getCredits());
|
||||||
view.getLblLife().setText("Life: " + qData.getLife());
|
view.getLblLife().setText("Life: " + qS.getLife());
|
||||||
view.getLblWins().setText("Wins: " + qData.getWin());
|
view.getLblWins().setText("Wins: " + qA.getWin());
|
||||||
view.getLblLosses().setText("Losses: " + qData.getLost());
|
view.getLblLosses().setText("Losses: " + qA.getLost());
|
||||||
view.updateCurrentDeckStatus();
|
view.updateCurrentDeckStatus();
|
||||||
|
|
||||||
final int num = SubmenuQuestUtil.nextChallengeInWins();
|
final int num = SubmenuQuestUtil.nextChallengeInWins();
|
||||||
@@ -98,13 +103,13 @@ public class SubmenuQuestUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
view.getLblWinStreak().setText(
|
view.getLblWinStreak().setText(
|
||||||
"Win streak: " + qData.getWinStreakCurrent()
|
"Win streak: " + qA.getWinStreakCurrent()
|
||||||
+ " (Best:" + qData.getWinStreakBest() + ")");
|
+ " (Best:" + qA.getWinStreakBest() + ")");
|
||||||
|
|
||||||
// Start panel: pet, plant, zep.
|
// Start panel: pet, plant, zep.
|
||||||
if (qData.getMode().equals(QuestData.FANTASY)) {
|
if (qData.getMode() == QuestMode.Fantasy) {
|
||||||
final Set<String> petList = qData.getPetManager().getAvailablePetNames();
|
final Set<String> petList = qS.getPetManager().getAvailablePetNames();
|
||||||
final QuestPetAbstract currentPet = qData.getPetManager().getSelectedPet();
|
final QuestPetAbstract currentPet = qS.getPetManager().getSelectedPet();
|
||||||
|
|
||||||
view.getCbxPet().removeAllItems();
|
view.getCbxPet().removeAllItems();
|
||||||
// Pet list visibility
|
// Pet list visibility
|
||||||
@@ -121,19 +126,19 @@ public class SubmenuQuestUtil {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Plant visiblity
|
// Plant visiblity
|
||||||
if (qData.getPetManager().getPlant().getLevel() == 0) {
|
if (qS.getPetManager().getPlant().getLevel() == 0) {
|
||||||
view.getCbPlant().setVisible(false);
|
view.getCbPlant().setVisible(false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
view.getCbPlant().setVisible(true);
|
view.getCbPlant().setVisible(true);
|
||||||
view.getCbPlant().setSelected(qData.getPetManager().shouldPlantBeUsed());
|
view.getCbPlant().setSelected(qS.getPetManager().shouldPlantBeUsed());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Zeppelin visibility: everything about the zeppelin is screwy right now
|
// Zeppelin visibility: everything about the zeppelin is screwy right now
|
||||||
// for some reason, needs a large overhaul, disabled for now. 4-03-12
|
// for some reason, needs a large overhaul, disabled for now. 4-03-12
|
||||||
if (false) { //view.equals(VSubmenuChallenges.SINGLETON_INSTANCE)) {
|
if (false) { //view.equals(VSubmenuChallenges.SINGLETON_INSTANCE)) {
|
||||||
final QuestItemZeppelin zeppelin = (QuestItemZeppelin) qData.getInventory().getItem("Zeppelin");
|
final QuestItemZeppelin zeppelin = (QuestItemZeppelin) qS.getInventory().getItem("Zeppelin");
|
||||||
view.getCbZep().setVisible(zeppelin.isAvailableForPurchase() ? true : false);
|
view.getCbZep().setVisible(zeppelin.isAvailableForPurchase(qS) ? true : false);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
view.getCbZep().setVisible(false);
|
view.getCbZep().setVisible(false);
|
||||||
@@ -160,8 +165,8 @@ public class SubmenuQuestUtil {
|
|||||||
public static Deck getCurrentDeck() {
|
public static Deck getCurrentDeck() {
|
||||||
Deck d = null;
|
Deck d = null;
|
||||||
|
|
||||||
if (AllZone.getQuestData() != null) {
|
if (AllZone.getQuest().getAssets() != null) {
|
||||||
d = AllZone.getQuestData().getMyDecks().get(
|
d = AllZone.getQuest().getMyDecks().get(
|
||||||
Singletons.getModel().getQuestPreferences().getPreference(QPref.CURRENT_DECK));
|
Singletons.getModel().getQuestPreferences().getPreference(QPref.CURRENT_DECK));
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -174,12 +179,12 @@ public class SubmenuQuestUtil {
|
|||||||
final Command exit = new Command() {
|
final Command exit = new Command() {
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
AllZone.getQuestData().saveData();
|
AllZone.getQuest().save();
|
||||||
updateStatsAndPet();
|
updateStatsAndPet();
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
final QuestCardShop g = new QuestCardShop(AllZone.getQuestData());
|
final QuestCardShop g = new QuestCardShop(AllZone.getQuest());
|
||||||
g.show(exit);
|
g.show(exit);
|
||||||
g.setVisible(true);
|
g.setVisible(true);
|
||||||
}
|
}
|
||||||
@@ -192,7 +197,7 @@ public class SubmenuQuestUtil {
|
|||||||
|
|
||||||
/** */
|
/** */
|
||||||
public static void startGame() {
|
public static void startGame() {
|
||||||
final QuestData qData = AllZone.getQuestData();
|
final QuestController qData = AllZone.getQuest();
|
||||||
final QuestEvent event = selectedOpponent.getEvent();
|
final QuestEvent event = selectedOpponent.getEvent();
|
||||||
|
|
||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
@@ -208,15 +213,13 @@ public class SubmenuQuestUtil {
|
|||||||
public Object doInBackground() {
|
public Object doInBackground() {
|
||||||
Constant.Runtime.HUMAN_DECK[0] = SubmenuQuestUtil.getCurrentDeck();
|
Constant.Runtime.HUMAN_DECK[0] = SubmenuQuestUtil.getCurrentDeck();
|
||||||
Constant.Runtime.COMPUTER_DECK[0] = event.getEventDeck();
|
Constant.Runtime.COMPUTER_DECK[0] = event.getEventDeck();
|
||||||
Constant.Quest.OPP_ICON_NAME[0] = event.getIconFilename();
|
|
||||||
Constant.Runtime.setGameType(GameType.Quest);
|
Constant.Runtime.setGameType(GameType.Quest);
|
||||||
|
|
||||||
qData.randomizeOpponents();
|
QuestEventManager.INSTANCE.randomizeOpponents();
|
||||||
qData.setCurrentEvent(event);
|
qData.setCurrentEvent(event);
|
||||||
qData.saveData();
|
qData.save();
|
||||||
|
|
||||||
if (qData.isFantasy()) {
|
if (qData.getMode() == QuestMode.Fantasy) {
|
||||||
Constant.Quest.FANTASY_QUEST[0] = true;
|
|
||||||
int lifeAI = 20;
|
int lifeAI = 20;
|
||||||
int lifeHuman = 20;
|
int lifeHuman = 20;
|
||||||
|
|
||||||
@@ -225,21 +228,22 @@ public class SubmenuQuestUtil {
|
|||||||
|
|
||||||
// If zeppelin has been purchased, gear will be at level 2.
|
// If zeppelin has been purchased, gear will be at level 2.
|
||||||
if (event.getEventType().equalsIgnoreCase("challenge")
|
if (event.getEventType().equalsIgnoreCase("challenge")
|
||||||
&& !qData.getInventory().getItem("Zeppelin").isAvailableForPurchase()
|
&& !qData.getAssets().getInventory().getItem("Zeppelin").isAvailableForPurchase(qData.getAssets())
|
||||||
&& VSubmenuChallenges.SINGLETON_INSTANCE.getCbZep().isSelected()) {
|
&& VSubmenuChallenges.SINGLETON_INSTANCE.getCbZep().isSelected()) {
|
||||||
extraLife = 3;
|
extraLife = 3;
|
||||||
}
|
}
|
||||||
lifeAI = ((QuestChallenge) event).getAILife();
|
lifeAI = ((QuestChallenge) event).getAILife();
|
||||||
lifeHuman = qData.getLife() + extraLife;
|
lifeHuman = qData.getAssets().getLife() + extraLife;
|
||||||
}
|
}
|
||||||
|
|
||||||
GameNew.newGame(
|
GameNew.newGame(
|
||||||
Constant.Runtime.HUMAN_DECK[0],
|
Constant.Runtime.HUMAN_DECK[0],
|
||||||
Constant.Runtime.COMPUTER_DECK[0],
|
Constant.Runtime.COMPUTER_DECK[0],
|
||||||
QuestUtil.getHumanStartingCards(qData),
|
QuestUtil.getHumanStartingCards(qData.getAssets(), event),
|
||||||
QuestUtil.getComputerStartingCards(qData),
|
QuestUtil.getComputerStartingCards(event),
|
||||||
lifeHuman,
|
lifeHuman,
|
||||||
lifeAI);
|
lifeAI,
|
||||||
|
event.getIconFilename());
|
||||||
} // End isFantasy
|
} // End isFantasy
|
||||||
else {
|
else {
|
||||||
GameNew.newGame(SubmenuQuestUtil.getCurrentDeck(), event.getEventDeck());
|
GameNew.newGame(SubmenuQuestUtil.getCurrentDeck(), event.getEventDeck());
|
||||||
|
|||||||
@@ -6,7 +6,7 @@ import forge.gui.home.ICSubmenu;
|
|||||||
import forge.gui.home.IVSubmenu;
|
import forge.gui.home.IVSubmenu;
|
||||||
import forge.gui.toolbox.*;
|
import forge.gui.toolbox.*;
|
||||||
import forge.item.PreconDeck;
|
import forge.item.PreconDeck;
|
||||||
import forge.quest.data.QuestData;
|
import forge.quest.data.QuestController;
|
||||||
import forge.util.IStorageView;
|
import forge.util.IStorageView;
|
||||||
import net.miginfocom.swing.MigLayout;
|
import net.miginfocom.swing.MigLayout;
|
||||||
import org.apache.commons.lang3.text.WordUtils;
|
import org.apache.commons.lang3.text.WordUtils;
|
||||||
@@ -93,7 +93,7 @@ public enum VSubmenuQuestData implements IVSubmenu {
|
|||||||
};
|
};
|
||||||
|
|
||||||
final Map<String, String> preconDescriptions = new HashMap<String, String>();
|
final Map<String, String> preconDescriptions = new HashMap<String, String>();
|
||||||
IStorageView<PreconDeck> preconDecks = QuestData.getPrecons();
|
IStorageView<PreconDeck> preconDecks = QuestController.getPrecons();
|
||||||
for (String preconDeck : preconDecks.getNames()) {
|
for (String preconDeck : preconDecks.getNames()) {
|
||||||
cbxPrecon.addItem(preconDeck);
|
cbxPrecon.addItem(preconDeck);
|
||||||
String description = preconDecks.get(preconDeck).getDescription();
|
String description = preconDecks.get(preconDeck).getDescription();
|
||||||
@@ -102,6 +102,8 @@ public enum VSubmenuQuestData implements IVSubmenu {
|
|||||||
}
|
}
|
||||||
|
|
||||||
cbxPrecon.setRenderer(new BasicComboBoxRenderer() {
|
cbxPrecon.setRenderer(new BasicComboBoxRenderer() {
|
||||||
|
private static final long serialVersionUID = 3477357932538947199L;
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public Component getListCellRendererComponent(
|
public Component getListCellRendererComponent(
|
||||||
JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
JList list, Object value, int index, boolean isSelected, boolean cellHasFocus) {
|
||||||
|
|||||||
@@ -279,11 +279,11 @@ public enum CSubmenuConstructed implements ICSubmenu {
|
|||||||
|
|
||||||
final List<String> eventNames = new ArrayList<String>();
|
final List<String> eventNames = new ArrayList<String>();
|
||||||
|
|
||||||
for (final QuestEvent e : QuestEventManager.ALL_DUELS) {
|
for (final QuestEvent e : QuestEventManager.INSTANCE.ALL_DUELS) {
|
||||||
eventNames.add(e.getEventDeck().getName());
|
eventNames.add(e.getEventDeck().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final QuestEvent e : QuestEventManager.ALL_CHALLENGES) {
|
for (final QuestEvent e : QuestEventManager.INSTANCE.ALL_CHALLENGES) {
|
||||||
eventNames.add(e.getEventDeck().getName());
|
eventNames.add(e.getEventDeck().getName());
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -416,7 +416,7 @@ public enum CSubmenuConstructed implements ICSubmenu {
|
|||||||
deck.getMain().add(cards);
|
deck.getMain().add(cards);
|
||||||
}
|
}
|
||||||
else if (lst0.getName().equals(ESubmenuConstructedTypes.QUESTEVENTS.toString())) {
|
else if (lst0.getName().equals(ESubmenuConstructedTypes.QUESTEVENTS.toString())) {
|
||||||
deck = QuestEventManager.getEvent(selection[0]).getEventDeck();
|
deck = QuestEventManager.INSTANCE.getEvent(selection[0]).getEventDeck();
|
||||||
}
|
}
|
||||||
// Custom deck
|
// Custom deck
|
||||||
else if (lst0.getName().equals(ESubmenuConstructedTypes.CUSTOM.toString())) {
|
else if (lst0.getName().equals(ESubmenuConstructedTypes.CUSTOM.toString())) {
|
||||||
@@ -441,7 +441,7 @@ public enum CSubmenuConstructed implements ICSubmenu {
|
|||||||
deck = Singletons.getModel().getDecks().getConstructed().get(deckName);
|
deck = Singletons.getModel().getDecks().getConstructed().get(deckName);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
deck = QuestEventManager.getEvent(deckName).getEventDeck();
|
deck = QuestEventManager.INSTANCE.getEvent(deckName).getEventDeck();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Dump into map and display.
|
// Dump into map and display.
|
||||||
|
|||||||
@@ -427,7 +427,7 @@ public class DeckLister extends JPanel {
|
|||||||
switch (this.gametype) {
|
switch (this.gametype) {
|
||||||
case Quest:
|
case Quest:
|
||||||
Constant.Runtime.HUMAN_DECK[0] = d0;
|
Constant.Runtime.HUMAN_DECK[0] = d0;
|
||||||
final DeckEditorQuest editor = new DeckEditorQuest(AllZone.getQuestData());
|
final DeckEditorQuest editor = new DeckEditorQuest(AllZone.getQuest());
|
||||||
editor.show(this.cmdEditorExit);
|
editor.show(this.cmdEditorExit);
|
||||||
editor.setVisible(true);
|
editor.setVisible(true);
|
||||||
editor.setAlwaysOnTop(true);
|
editor.setAlwaysOnTop(true);
|
||||||
@@ -475,8 +475,8 @@ public class DeckLister extends JPanel {
|
|||||||
} else if (this.gametype.equals(GameType.Sealed)) {
|
} else if (this.gametype.equals(GameType.Sealed)) {
|
||||||
deckManager.getSealed().delete(d0.getName());
|
deckManager.getSealed().delete(d0.getName());
|
||||||
} else if (this.gametype.equals(GameType.Quest)) {
|
} else if (this.gametype.equals(GameType.Quest)) {
|
||||||
AllZone.getQuestData().getMyDecks().delete(d0.getName());
|
AllZone.getQuest().getMyDecks().delete(d0.getName());
|
||||||
AllZone.getQuestData().saveData();
|
AllZone.getQuest().save();
|
||||||
} else {
|
} else {
|
||||||
deckManager.getConstructed().delete(d0.getName());
|
deckManager.getConstructed().delete(d0.getName());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -185,7 +185,7 @@ public class FMatchState {
|
|||||||
* @since 1.2.3
|
* @since 1.2.3
|
||||||
*/
|
*/
|
||||||
public final void addAnteWonToCardPool() {
|
public final void addAnteWonToCardPool() {
|
||||||
AllZone.getQuestData().getCards().addAllCards(antesWon);
|
AllZone.getQuest().getCards().addAllCards(antesWon);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,7 +19,7 @@ package forge.quest;
|
|||||||
|
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
|
|
||||||
import forge.quest.data.QuestData;
|
import forge.quest.data.QuestAchievements;
|
||||||
import forge.util.FileSection;
|
import forge.util.FileSection;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,11 +56,11 @@ public class SellRules {
|
|||||||
* @param quest the quest
|
* @param quest the quest
|
||||||
* @return true, if successful
|
* @return true, if successful
|
||||||
*/
|
*/
|
||||||
public boolean meetsRequiremnts(QuestData quest) {
|
public boolean meetsRequiremnts(QuestAchievements quest) {
|
||||||
if (quest.getWin() < minWins) {
|
if (quest.getWin() < minWins) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
if (quest.getDifficultyIndex() < minDifficulty || quest.getDifficultyIndex() > maxDifficulty) {
|
if (quest.getDifficulty() < minDifficulty || quest.getDifficulty() > maxDifficulty) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
158
src/main/java/forge/quest/data/QuestAchievements.java
Normal file
158
src/main/java/forge/quest/data/QuestAchievements.java
Normal file
@@ -0,0 +1,158 @@
|
|||||||
|
package forge.quest.data;
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import forge.Singletons;
|
||||||
|
import forge.quest.data.QuestPreferences.QPref;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this type.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class QuestAchievements {
|
||||||
|
|
||||||
|
// Challenge history
|
||||||
|
/** The challenges played. */
|
||||||
|
int challengesPlayed = 0;
|
||||||
|
/** The completed challenges. */
|
||||||
|
List<Integer> completedChallenges = new ArrayList<Integer>();
|
||||||
|
/** The win. */
|
||||||
|
int win; // number of wins
|
||||||
|
int winstreakBest = 0;
|
||||||
|
int winstreakCurrent = 0;
|
||||||
|
|
||||||
|
/** The lost. */
|
||||||
|
int lost;
|
||||||
|
|
||||||
|
// Difficulty - will store only index from now.
|
||||||
|
private int difficulty;
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for Constructor.
|
||||||
|
* @param diff
|
||||||
|
*/
|
||||||
|
public QuestAchievements(int diff) {
|
||||||
|
difficulty = diff;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for Constructor.
|
||||||
|
* @param mode
|
||||||
|
*/
|
||||||
|
/**
|
||||||
|
* Adds the win.
|
||||||
|
*/
|
||||||
|
public void addWin() { // changes getRank()
|
||||||
|
this.win++;
|
||||||
|
this.winstreakCurrent++;
|
||||||
|
|
||||||
|
if (this.winstreakCurrent > this.winstreakBest) {
|
||||||
|
this.winstreakBest = this.winstreakCurrent;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
// Challenge performance
|
||||||
|
/**
|
||||||
|
* Gets the challenges played.
|
||||||
|
*
|
||||||
|
* @return the challenges played
|
||||||
|
*/
|
||||||
|
public int getChallengesPlayed() {
|
||||||
|
return this.challengesPlayed;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* getCompletedChallenges.
|
||||||
|
* </p>
|
||||||
|
* Returns stored list of non-repeatable challenge IDs.
|
||||||
|
*
|
||||||
|
* @return List<Integer>
|
||||||
|
*/
|
||||||
|
public List<Integer> getCompletedChallenges() {
|
||||||
|
return this.completedChallenges;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Adds the challenges played.
|
||||||
|
*/
|
||||||
|
public void addChallengesPlayed() {
|
||||||
|
this.challengesPlayed++;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* <p>
|
||||||
|
* addCompletedChallenge.
|
||||||
|
* </p>
|
||||||
|
* Add non-repeatable challenge ID to list.
|
||||||
|
*
|
||||||
|
* @param i
|
||||||
|
* the i
|
||||||
|
*/
|
||||||
|
|
||||||
|
// Poorly named - this should be "setLockedChalleneges" or similar.
|
||||||
|
public void addCompletedChallenge(final int i) {
|
||||||
|
this.completedChallenges.add(i);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Adds the lost.
|
||||||
|
*/
|
||||||
|
public void addLost() {
|
||||||
|
this.lost++;
|
||||||
|
this.winstreakCurrent = 0;
|
||||||
|
}
|
||||||
|
// Level, read-only ( note: it increments in addWin() )
|
||||||
|
/**
|
||||||
|
* Gets the level.
|
||||||
|
*
|
||||||
|
* @return the level
|
||||||
|
*/
|
||||||
|
public int getLevel() {
|
||||||
|
final int winsToLvlUp = Singletons.getModel().getQuestPreferences().getPreferenceInt(QPref.WINS_RANKUP, difficulty);
|
||||||
|
return this.win / winsToLvlUp;
|
||||||
|
}
|
||||||
|
// Wins & Losses
|
||||||
|
/**
|
||||||
|
* Gets the lost.
|
||||||
|
*
|
||||||
|
* @return the lost
|
||||||
|
*/
|
||||||
|
public int getLost() {
|
||||||
|
return this.lost;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the win.
|
||||||
|
*
|
||||||
|
* @return the win
|
||||||
|
*/
|
||||||
|
public int getWin() {
|
||||||
|
return win;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the win streak best.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public int getWinStreakBest() {
|
||||||
|
return winstreakBest;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the win streak current.
|
||||||
|
*
|
||||||
|
* @return int
|
||||||
|
*/
|
||||||
|
public int getWinStreakCurrent() {
|
||||||
|
return winstreakCurrent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the difficulty index.
|
||||||
|
*
|
||||||
|
* @return the difficulty index
|
||||||
|
*/
|
||||||
|
public int getDifficulty() {
|
||||||
|
return this.difficulty;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
164
src/main/java/forge/quest/data/QuestAssets.java
Normal file
164
src/main/java/forge/quest/data/QuestAssets.java
Normal file
@@ -0,0 +1,164 @@
|
|||||||
|
package forge.quest.data;
|
||||||
|
|
||||||
|
import java.util.HashMap;
|
||||||
|
|
||||||
|
import forge.Singletons;
|
||||||
|
import forge.deck.Deck;
|
||||||
|
import forge.item.CardPrinted;
|
||||||
|
import forge.item.InventoryItem;
|
||||||
|
import forge.item.ItemPool;
|
||||||
|
import forge.item.ItemPoolView;
|
||||||
|
import forge.quest.data.QuestPreferences.QPref;
|
||||||
|
import forge.quest.data.item.QuestInventory;
|
||||||
|
import forge.quest.data.pet.QuestPetManager;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this type.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class QuestAssets {
|
||||||
|
|
||||||
|
// Cards associated with quest
|
||||||
|
/** The card pool. */
|
||||||
|
final ItemPool<CardPrinted> cardPool = new ItemPool<CardPrinted>(CardPrinted.class); // player's
|
||||||
|
/** The credits. */
|
||||||
|
long credits; // this money is good for all modes
|
||||||
|
// game
|
||||||
|
// with
|
||||||
|
/** The inventory. */
|
||||||
|
final QuestInventory inventory = new QuestInventory(); // different
|
||||||
|
/** The life. */
|
||||||
|
int life; // for fantasy mode, how much life bought at shop to start
|
||||||
|
// Decks collected by player
|
||||||
|
/** The my decks. */
|
||||||
|
final HashMap<String, Deck> myDecks = new HashMap<String, Deck>();
|
||||||
|
// current
|
||||||
|
// shop
|
||||||
|
// list
|
||||||
|
/** The new card list. */
|
||||||
|
final ItemPool<InventoryItem> newCardList = new ItemPool<InventoryItem>(InventoryItem.class); // cards
|
||||||
|
// belonging
|
||||||
|
/** The shop list. */
|
||||||
|
final ItemPool<InventoryItem> shopList = new ItemPool<InventoryItem>(InventoryItem.class); // the
|
||||||
|
// gadgets
|
||||||
|
|
||||||
|
/** The pet manager. */
|
||||||
|
final QuestPetManager petManager = new QuestPetManager(); // pets
|
||||||
|
/**
|
||||||
|
* Adds n life to maximum.
|
||||||
|
*
|
||||||
|
* @param n
|
||||||
|
*   int
|
||||||
|
*/
|
||||||
|
public void addLife(final int n) {
|
||||||
|
this.life += n;
|
||||||
|
}
|
||||||
|
public QuestAssets(QuestMode mode) {
|
||||||
|
this.life = mode.equals(QuestMode.Fantasy) ? 15 : 20;
|
||||||
|
|
||||||
|
|
||||||
|
final QuestPreferences prefs = Singletons.getModel().getQuestPreferences();
|
||||||
|
final ItemPoolView<CardPrinted> lands = QuestUtilCards.generateBasicLands(
|
||||||
|
prefs.getPreferenceInt(QPref.STARTING_BASIC_LANDS), prefs.getPreferenceInt(QPref.STARTING_SNOW_LANDS));
|
||||||
|
this.getCardPool().addAll(lands);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the credits.
|
||||||
|
*
|
||||||
|
* @return the credits
|
||||||
|
*/
|
||||||
|
public long getCredits() {
|
||||||
|
return this.credits;
|
||||||
|
}
|
||||||
|
// All belongings
|
||||||
|
/**
|
||||||
|
* Gets the inventory.
|
||||||
|
*
|
||||||
|
* @return the inventory
|
||||||
|
*/
|
||||||
|
public QuestInventory getInventory() {
|
||||||
|
return this.inventory;
|
||||||
|
}
|
||||||
|
// Life (only fantasy)
|
||||||
|
/**
|
||||||
|
* Gets the life.
|
||||||
|
*
|
||||||
|
* @return the life
|
||||||
|
*/
|
||||||
|
public int getLife() {
|
||||||
|
return this.life;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Gets the new card list.
|
||||||
|
*
|
||||||
|
* @return the newCardList
|
||||||
|
*/
|
||||||
|
public ItemPool<InventoryItem> getNewCardList() {
|
||||||
|
return this.newCardList;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Gets the shop list.
|
||||||
|
*
|
||||||
|
* @return the shopList
|
||||||
|
*/
|
||||||
|
public ItemPool<InventoryItem> getShopList() {
|
||||||
|
return this.shopList;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Removes n life from maximum.
|
||||||
|
*
|
||||||
|
* @param n
|
||||||
|
*   int
|
||||||
|
*/
|
||||||
|
public void removeLife(final int n) {
|
||||||
|
this.life -= n;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Sets the credits.
|
||||||
|
*
|
||||||
|
* @param credits0
|
||||||
|
* the credits to set
|
||||||
|
*/
|
||||||
|
public void setCredits(final long credits0) {
|
||||||
|
this.credits = credits0;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the pet manager.
|
||||||
|
*
|
||||||
|
* @return the pet manager
|
||||||
|
*/
|
||||||
|
public QuestPetManager getPetManager() {
|
||||||
|
return this.petManager;
|
||||||
|
}
|
||||||
|
// Credits
|
||||||
|
/**
|
||||||
|
* Adds the credits.
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
* the c
|
||||||
|
*/
|
||||||
|
public void addCredits(final long c) {
|
||||||
|
this.setCredits(this.getCredits() + c);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Gets the card pool.
|
||||||
|
*
|
||||||
|
* @return the cardPool
|
||||||
|
*/
|
||||||
|
public ItemPool<CardPrinted> getCardPool() {
|
||||||
|
return this.cardPool;
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* Subtract credits.
|
||||||
|
*
|
||||||
|
* @param c
|
||||||
|
* the c
|
||||||
|
*/
|
||||||
|
public void subtractCredits(final long c) {
|
||||||
|
this.setCredits(this.getCredits() > c ? this.getCredits() - c : 0);
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
239
src/main/java/forge/quest/data/QuestController.java
Normal file
239
src/main/java/forge/quest/data/QuestController.java
Normal file
@@ -0,0 +1,239 @@
|
|||||||
|
package forge.quest.data;
|
||||||
|
|
||||||
|
|
||||||
|
import java.util.ArrayList;
|
||||||
|
import java.util.List;
|
||||||
|
|
||||||
|
import forge.Singletons;
|
||||||
|
import forge.deck.Deck;
|
||||||
|
import forge.item.CardPrinted;
|
||||||
|
import forge.item.PreconDeck;
|
||||||
|
import forge.properties.ForgeProps;
|
||||||
|
import forge.properties.NewConstants;
|
||||||
|
import forge.quest.data.QuestPreferences.QPref;
|
||||||
|
import forge.util.IStorage;
|
||||||
|
import forge.util.IStorageView;
|
||||||
|
import forge.util.Predicate;
|
||||||
|
import forge.util.StorageView;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this type.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public class QuestController {
|
||||||
|
|
||||||
|
private QuestData model;
|
||||||
|
// gadgets
|
||||||
|
|
||||||
|
// Utility class to access cards, has access to private fields
|
||||||
|
// Moved some methods there that otherwise would make this class even more
|
||||||
|
// complex
|
||||||
|
private transient QuestUtilCards myCards;
|
||||||
|
|
||||||
|
private transient QuestEvent currentEvent;
|
||||||
|
|
||||||
|
transient IStorage<Deck> decks;
|
||||||
|
|
||||||
|
// acquired
|
||||||
|
// since
|
||||||
|
// last
|
||||||
|
// game-win/loss
|
||||||
|
|
||||||
|
/** The available challenges. */
|
||||||
|
private List<Integer> availableChallenges = new ArrayList<Integer>();
|
||||||
|
|
||||||
|
/** The available quests. */
|
||||||
|
private List<Integer> availableQuests = null;
|
||||||
|
|
||||||
|
// This is used by shop. Had no idea where else to place this
|
||||||
|
private static transient IStorageView<PreconDeck> preconManager =
|
||||||
|
new StorageView<PreconDeck>(new PreconReader(ForgeProps.getFile(NewConstants.Quest.PRECONS)));
|
||||||
|
|
||||||
|
/** The Constant RANK_TITLES. */
|
||||||
|
public static final String[] RANK_TITLES = new String[] { "Level 0 - Confused Wizard", "Level 1 - Mana Mage",
|
||||||
|
"Level 2 - Death by Megrim", "Level 3 - Shattered the Competition", "Level 4 - Black Knighted",
|
||||||
|
"Level 5 - Shockingly Good", "Level 6 - Regressed into Timmy", "Level 7 - Loves Blue Control",
|
||||||
|
"Level 8 - Immobilized by Fear", "Level 9 - Lands = Friends", "Level 10 - Forging new paths",
|
||||||
|
"Level 11 - Infect-o-tron", "Level 12 - Great Balls of Fire", "Level 13 - Artifact Schmartifact",
|
||||||
|
"Level 14 - Mike Mulligan's The Name", "Level 15 - Fresh Air: Good For The Health",
|
||||||
|
"Level 16 - In It For The Love", "Level 17 - Sticks, Stones, Bones", "Level 18 - Credits For Breakfast",
|
||||||
|
"Level 19 - Millasaurus", "Level 20 - One-turn Wonder", "Teaching Gandalf a Lesson",
|
||||||
|
"What Do You Do With The Other Hand?", "Freelance Sorcerer, Works Weekends",
|
||||||
|
"Should We Hire Commentators?", "Saltblasted For Your Talent", "Serra Angel Is Your Girlfriend", };
|
||||||
|
|
||||||
|
// Cards - class uses data from here
|
||||||
|
/**
|
||||||
|
* Gets the cards.
|
||||||
|
*
|
||||||
|
* @return the cards
|
||||||
|
*/
|
||||||
|
public QuestUtilCards getCards() {
|
||||||
|
return this.myCards;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the my decks.
|
||||||
|
*
|
||||||
|
* @return the myDecks
|
||||||
|
*/
|
||||||
|
public IStorage<Deck> getMyDecks() {
|
||||||
|
return decks;
|
||||||
|
}
|
||||||
|
|
||||||
|
public QuestEvent getCurrentEvent() {
|
||||||
|
return currentEvent;
|
||||||
|
}
|
||||||
|
public void setCurrentEvent(QuestEvent currentEvent) {
|
||||||
|
this.currentEvent = currentEvent;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the precons.
|
||||||
|
*
|
||||||
|
* @return QuestPreconManager
|
||||||
|
*/
|
||||||
|
public static IStorageView<PreconDeck> getPrecons() {
|
||||||
|
return preconManager;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
* @param selectedQuest
|
||||||
|
*/
|
||||||
|
public void load(QuestData selectedQuest) {
|
||||||
|
model = selectedQuest;
|
||||||
|
// These are helper classes that hold no data.
|
||||||
|
this.decks = model == null ? null : new QuestDeckMap(model.getAssets().myDecks);
|
||||||
|
this.myCards = model == null ? null : new QuestUtilCards(this);
|
||||||
|
currentEvent = null;
|
||||||
|
|
||||||
|
QuestEventManager.INSTANCE.randomizeOpponents();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
*/
|
||||||
|
public void save() {
|
||||||
|
if ( model != null )
|
||||||
|
model.saveData();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public boolean isLoaded() {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Clear available challenges.
|
||||||
|
*/
|
||||||
|
public void clearAvailableChallenges() {
|
||||||
|
this.availableChallenges.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the available challenges.
|
||||||
|
*
|
||||||
|
* @return the available challenges
|
||||||
|
*/
|
||||||
|
public List<Integer> getAvailableChallenges() {
|
||||||
|
// This should be phased out after a while, when
|
||||||
|
// old quest decks have been updated. (changes made 19-9-11)
|
||||||
|
if (this.availableQuests != null) {
|
||||||
|
this.availableChallenges = this.availableQuests;
|
||||||
|
this.availableQuests = null;
|
||||||
|
}
|
||||||
|
|
||||||
|
return this.availableChallenges != null ? new ArrayList<Integer>(this.availableChallenges) : null;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Sets the available challenges.
|
||||||
|
*
|
||||||
|
* @param list
|
||||||
|
* the new available challenges
|
||||||
|
*/
|
||||||
|
public void setAvailableChallenges(final List<Integer> list) {
|
||||||
|
this.availableChallenges = list;
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* New game.
|
||||||
|
*
|
||||||
|
* @param diff
|
||||||
|
* the diff
|
||||||
|
* @param mode
|
||||||
|
* the mode
|
||||||
|
* @param startPool
|
||||||
|
* the start type
|
||||||
|
*/
|
||||||
|
public void newGame(final String name, final int diff, final QuestMode mode, final QuestStartPool startPool, final String preconName) {
|
||||||
|
|
||||||
|
load(new QuestData(name, diff, mode));
|
||||||
|
|
||||||
|
final Predicate<CardPrinted> filter;
|
||||||
|
switch (startPool) {
|
||||||
|
case PRECON:
|
||||||
|
myCards.addPreconDeck(preconManager.get(preconName));
|
||||||
|
return;
|
||||||
|
|
||||||
|
case STANDARD:
|
||||||
|
filter = Singletons.getModel().getFormats().getStandard().getFilterPrinted();
|
||||||
|
break;
|
||||||
|
|
||||||
|
default: //Unrestricted
|
||||||
|
filter = CardPrinted.Predicates.Presets.IS_TRUE;
|
||||||
|
break;
|
||||||
|
}
|
||||||
|
|
||||||
|
this.getAssets().setCredits(Singletons.getModel().getQuestPreferences().getPreferenceInt(QPref.STARTING_CREDITS, diff));
|
||||||
|
this.myCards.setupNewGameCardPool(filter, diff);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Gets the rank.
|
||||||
|
*
|
||||||
|
* @return the rank
|
||||||
|
*/
|
||||||
|
public String getRank() {
|
||||||
|
int level = model.getAchievements().getLevel();
|
||||||
|
if (level >= RANK_TITLES.length) {
|
||||||
|
level = RANK_TITLES.length - 1;
|
||||||
|
}
|
||||||
|
return RANK_TITLES[level];
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public QuestAssets getAssets() {
|
||||||
|
return model == null ? null : model.getAssets();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public String getName() {
|
||||||
|
return model == null ? null : model.getName();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public QuestAchievements getAchievements() {
|
||||||
|
return model == null ? null : model.getAchievements();
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public QuestMode getMode() {
|
||||||
|
return model.getMode();
|
||||||
|
}
|
||||||
|
}
|
||||||
@@ -17,20 +17,6 @@
|
|||||||
*/
|
*/
|
||||||
package forge.quest.data;
|
package forge.quest.data;
|
||||||
|
|
||||||
import forge.Singletons;
|
|
||||||
import forge.deck.Deck;
|
|
||||||
import forge.item.*;
|
|
||||||
import forge.properties.ForgeProps;
|
|
||||||
import forge.properties.NewConstants;
|
|
||||||
import forge.quest.data.QuestPreferences.QPref;
|
|
||||||
import forge.quest.data.item.QuestInventory;
|
|
||||||
import forge.quest.data.pet.QuestPetManager;
|
|
||||||
import forge.util.*;
|
|
||||||
|
|
||||||
import java.util.ArrayList;
|
|
||||||
import java.util.HashMap;
|
|
||||||
import java.util.List;
|
|
||||||
|
|
||||||
//when you create QuestDataOld and AFTER you copy the AI decks over
|
//when you create QuestDataOld and AFTER you copy the AI decks over
|
||||||
//you have to call one of these two methods below
|
//you have to call one of these two methods below
|
||||||
//see Gui_QuestOptions for more details
|
//see Gui_QuestOptions for more details
|
||||||
@@ -47,7 +33,7 @@ public final class QuestData {
|
|||||||
|
|
||||||
// This field holds the version of the Quest Data
|
// This field holds the version of the Quest Data
|
||||||
/** Constant <code>CURRENT_VERSION_NUMBER=2</code>. */
|
/** Constant <code>CURRENT_VERSION_NUMBER=2</code>. */
|
||||||
public static final int CURRENT_VERSION_NUMBER = 2;
|
public static final int CURRENT_VERSION_NUMBER = 3;
|
||||||
|
|
||||||
// This field places the version number into QD instance,
|
// This field places the version number into QD instance,
|
||||||
// but only when the object is created through the constructor
|
// but only when the object is created through the constructor
|
||||||
@@ -55,447 +41,30 @@ public final class QuestData {
|
|||||||
/** The version number. */
|
/** The version number. */
|
||||||
private int versionNumber = QuestData.CURRENT_VERSION_NUMBER;
|
private int versionNumber = QuestData.CURRENT_VERSION_NUMBER;
|
||||||
|
|
||||||
/** The rank index. */
|
private final String name;
|
||||||
private int rankIndex; // level
|
|
||||||
|
|
||||||
/** The win. */
|
|
||||||
private int win; // number of wins
|
|
||||||
|
|
||||||
/** The lost. */
|
|
||||||
private int lost;
|
|
||||||
|
|
||||||
private int winstreakBest = 0;
|
|
||||||
|
|
||||||
private int winstreakCurrent = 0;
|
|
||||||
|
|
||||||
/** The credits. */
|
|
||||||
private long credits; // this money is good for all modes
|
|
||||||
|
|
||||||
/** The life. */
|
|
||||||
private int life; // for fantasy mode, how much life bought at shop to start
|
|
||||||
// game
|
|
||||||
// with
|
|
||||||
/** The inventory. */
|
|
||||||
private QuestInventory inventory = new QuestInventory(); // different
|
|
||||||
// gadgets
|
|
||||||
|
|
||||||
/** The pet manager. */
|
|
||||||
private final QuestPetManager petManager = new QuestPetManager(); // pets
|
|
||||||
// that
|
|
||||||
// start
|
|
||||||
// match
|
|
||||||
// with you
|
|
||||||
|
|
||||||
// Diffuculty - they store both index and title
|
|
||||||
/** The diff index. */
|
|
||||||
private int diffIndex;
|
|
||||||
|
|
||||||
/** The difficulty. */
|
|
||||||
private String difficulty;
|
|
||||||
|
|
||||||
/** */
|
|
||||||
private String name = "";
|
|
||||||
|
|
||||||
// Quest mode - there should be an enum :(
|
// Quest mode - there should be an enum :(
|
||||||
/** The mode. */
|
/** The mode. */
|
||||||
private String mode = "";
|
private QuestMode mode;
|
||||||
|
|
||||||
/** The Constant FANTASY. */
|
|
||||||
public static final String FANTASY = "Fantasy";
|
|
||||||
|
|
||||||
/** The Constant CLASSIC. */
|
// gadgets
|
||||||
public static final String CLASSIC = "Classic";
|
|
||||||
|
|
||||||
// Decks collected by player
|
private final QuestAssets assets;
|
||||||
/** The my decks. */
|
private final QuestAchievements achievements;
|
||||||
private final HashMap<String, Deck> myDecks = new HashMap<String, Deck>();
|
|
||||||
|
|
||||||
private transient IStorage<Deck> decks;
|
|
||||||
|
|
||||||
// Cards associated with quest
|
|
||||||
/** The card pool. */
|
|
||||||
private final ItemPool<CardPrinted> cardPool = new ItemPool<CardPrinted>(CardPrinted.class); // player's
|
|
||||||
// belonging
|
|
||||||
/** The shop list. */
|
|
||||||
private ItemPool<InventoryItem> shopList = new ItemPool<InventoryItem>(InventoryItem.class); // the
|
|
||||||
// current
|
|
||||||
// shop
|
|
||||||
// list
|
|
||||||
/** The new card list. */
|
|
||||||
private ItemPool<InventoryItem> newCardList = new ItemPool<InventoryItem>(InventoryItem.class); // cards
|
|
||||||
// acquired
|
|
||||||
// since
|
|
||||||
// last
|
|
||||||
// game-win/loss
|
|
||||||
|
|
||||||
// Challenge history
|
|
||||||
/** The challenges played. */
|
|
||||||
private int challengesPlayed = 0;
|
|
||||||
|
|
||||||
/** The available challenges. */
|
|
||||||
private List<Integer> availableChallenges = new ArrayList<Integer>();
|
|
||||||
|
|
||||||
/** The completed challenges. */
|
|
||||||
private List<Integer> completedChallenges = new ArrayList<Integer>();
|
|
||||||
|
|
||||||
// Challenges used to be called quests. During the renaming,
|
|
||||||
// files could be corrupted. These fields ensure old files still work.
|
|
||||||
// These fields should be phased out after a little while.
|
|
||||||
// The old files, if played once, are updated automatically to the new
|
|
||||||
// system.
|
|
||||||
/** The quests played. */
|
|
||||||
private int questsPlayed = -1;
|
|
||||||
|
|
||||||
/** The available quests. */
|
|
||||||
private List<Integer> availableQuests = null;
|
|
||||||
|
|
||||||
/** The completed quests. */
|
|
||||||
private List<Integer> completedQuests = null;
|
|
||||||
|
|
||||||
// own randomizer seed
|
|
||||||
private long randomSeed = 0;
|
|
||||||
|
|
||||||
// Utility class to access cards, has access to private fields
|
|
||||||
// Moved some methods there that otherwise would make this class even more
|
|
||||||
// complex
|
|
||||||
private transient QuestUtilCards myCards;
|
|
||||||
|
|
||||||
private transient QuestEvent currentEvent;
|
|
||||||
|
|
||||||
// This is used by shop. Had no idea where else to place this
|
|
||||||
private static transient IStorageView<PreconDeck> preconManager =
|
|
||||||
new StorageView<PreconDeck>(new PreconReader(ForgeProps.getFile(NewConstants.Quest.PRECONS)));
|
|
||||||
|
|
||||||
/** The Constant RANK_TITLES. */
|
|
||||||
public static final String[] RANK_TITLES = new String[] { "Level 0 - Confused Wizard", "Level 1 - Mana Mage",
|
|
||||||
"Level 2 - Death by Megrim", "Level 3 - Shattered the Competition", "Level 4 - Black Knighted",
|
|
||||||
"Level 5 - Shockingly Good", "Level 6 - Regressed into Timmy", "Level 7 - Loves Blue Control",
|
|
||||||
"Level 8 - Immobilized by Fear", "Level 9 - Lands = Friends", "Level 10 - Forging new paths",
|
|
||||||
"Level 11 - Infect-o-tron", "Level 12 - Great Balls of Fire", "Level 13 - Artifact Schmartifact",
|
|
||||||
"Level 14 - Mike Mulligan's The Name", "Level 15 - Fresh Air: Good For The Health",
|
|
||||||
"Level 16 - In It For The Love", "Level 17 - Sticks, Stones, Bones", "Level 18 - Credits For Breakfast",
|
|
||||||
"Level 19 - Millasaurus", "Level 20 - One-turn Wonder", "Teaching Gandalf a Lesson",
|
|
||||||
"What Do You Do With The Other Hand?", "Freelance Sorcerer, Works Weekends",
|
|
||||||
"Should We Hire Commentators?", "Saltblasted For Your Talent", "Serra Angel Is Your Girlfriend", };
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new quest data.
|
* Instantiates a new quest data.
|
||||||
*/
|
* @param mode2
|
||||||
public QuestData() {
|
|
||||||
this("An Unknown Quest");
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Constructor for QuestData.
|
|
||||||
* </p>
|
|
||||||
*
|
|
||||||
* @param s0
|
|
||||||
*   String name
|
|
||||||
*/
|
|
||||||
public QuestData(final String s0) {
|
|
||||||
this.initTransients();
|
|
||||||
this.setName(s0);
|
|
||||||
|
|
||||||
final QuestPreferences prefs = Singletons.getModel().getQuestPreferences();
|
|
||||||
final ItemPoolView<CardPrinted> lands = QuestUtilCards.generateBasicLands(
|
|
||||||
prefs.getPreferenceInt(QPref.STARTING_BASIC_LANDS), prefs.getPreferenceInt(QPref.STARTING_SNOW_LANDS));
|
|
||||||
this.getCardPool().addAll(lands);
|
|
||||||
this.randomizeOpponents();
|
|
||||||
}
|
|
||||||
|
|
||||||
private void initTransients() {
|
|
||||||
// These are helper classes that hold no data.
|
|
||||||
this.decks = new QuestDeckMap(this.myDecks);
|
|
||||||
this.myCards = new QuestUtilCards(this);
|
|
||||||
|
|
||||||
// to avoid NPE some pools will be created here if they are null
|
|
||||||
if (null == this.getNewCardList()) {
|
|
||||||
this.setNewCardList(new ItemPool<InventoryItem>(InventoryItem.class));
|
|
||||||
}
|
|
||||||
if (null == this.getShopList()) {
|
|
||||||
this.setShopList(new ItemPool<InventoryItem>(InventoryItem.class));
|
|
||||||
}
|
|
||||||
|
|
||||||
currentEvent = null;
|
|
||||||
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* New game.
|
|
||||||
*
|
|
||||||
* @param diff
|
* @param diff
|
||||||
* the diff
|
* @param name2
|
||||||
* @param mode
|
|
||||||
* the mode
|
|
||||||
* @param startPool
|
|
||||||
* the start type
|
|
||||||
*/
|
*/
|
||||||
public void newGame(final int diff, final String mode, final QuestStartPool startPool, final String preconName) {
|
public QuestData(String name2, int diff, QuestMode mode2) {
|
||||||
this.setDifficulty(diff);
|
this.name = name2;
|
||||||
|
|
||||||
this.mode = mode;
|
this.mode = mode2;
|
||||||
this.life = this.mode.equals(QuestData.FANTASY) ? 15 : 20;
|
this.achievements = new QuestAchievements(diff);
|
||||||
|
this.assets = new QuestAssets(mode2);
|
||||||
final Predicate<CardPrinted> filter;
|
|
||||||
switch (startPool) {
|
|
||||||
case PRECON:
|
|
||||||
myCards.addPreconDeck(preconManager.get(preconName));
|
|
||||||
return;
|
|
||||||
|
|
||||||
case STANDARD:
|
|
||||||
filter = Singletons.getModel().getFormats().getStandard().getFilterPrinted();
|
|
||||||
break;
|
|
||||||
|
|
||||||
default: //Unrestricted
|
|
||||||
filter = CardPrinted.Predicates.Presets.IS_TRUE;
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.setCredits(Singletons.getModel().getQuestPreferences().getPreferenceInt(QPref.STARTING_CREDITS, diff));
|
|
||||||
this.myCards.setupNewGameCardPool(filter, diff);
|
|
||||||
}
|
|
||||||
|
|
||||||
// All belongings
|
|
||||||
/**
|
|
||||||
* Gets the inventory.
|
|
||||||
*
|
|
||||||
* @return the inventory
|
|
||||||
*/
|
|
||||||
public QuestInventory getInventory() {
|
|
||||||
return this.inventory;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the pet manager.
|
|
||||||
*
|
|
||||||
* @return the pet manager
|
|
||||||
*/
|
|
||||||
public QuestPetManager getPetManager() {
|
|
||||||
return this.petManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Cards - class uses data from here
|
|
||||||
/**
|
|
||||||
* Gets the cards.
|
|
||||||
*
|
|
||||||
* @return the cards
|
|
||||||
*/
|
|
||||||
public QuestUtilCards getCards() {
|
|
||||||
return this.myCards;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Challenge performance
|
|
||||||
/**
|
|
||||||
* Gets the challenges played.
|
|
||||||
*
|
|
||||||
* @return the challenges played
|
|
||||||
*/
|
|
||||||
public int getChallengesPlayed() {
|
|
||||||
// This should be phased out after a while, when
|
|
||||||
// old quest decks have been updated. (changes made 19-9-11)
|
|
||||||
if (this.questsPlayed != -1) {
|
|
||||||
this.challengesPlayed = this.questsPlayed;
|
|
||||||
this.questsPlayed = -1;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.challengesPlayed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the challenges played.
|
|
||||||
*/
|
|
||||||
public void addChallengesPlayed() {
|
|
||||||
this.challengesPlayed++;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the available challenges.
|
|
||||||
*
|
|
||||||
* @return the available challenges
|
|
||||||
*/
|
|
||||||
public List<Integer> getAvailableChallenges() {
|
|
||||||
// This should be phased out after a while, when
|
|
||||||
// old quest decks have been updated. (changes made 19-9-11)
|
|
||||||
if (this.availableQuests != null) {
|
|
||||||
this.availableChallenges = this.availableQuests;
|
|
||||||
this.availableQuests = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.availableChallenges != null ? new ArrayList<Integer>(this.availableChallenges) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the available challenges.
|
|
||||||
*
|
|
||||||
* @param list
|
|
||||||
* the new available challenges
|
|
||||||
*/
|
|
||||||
public void setAvailableChallenges(final List<Integer> list) {
|
|
||||||
this.availableChallenges = list;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Clear available challenges.
|
|
||||||
*/
|
|
||||||
public void clearAvailableChallenges() {
|
|
||||||
this.availableChallenges.clear();
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* getCompletedChallenges.
|
|
||||||
* </p>
|
|
||||||
* Returns stored list of non-repeatable challenge IDs.
|
|
||||||
*
|
|
||||||
* @return List<Integer>
|
|
||||||
*/
|
|
||||||
public List<Integer> getCompletedChallenges() {
|
|
||||||
// This should be phased out after a while, when
|
|
||||||
// old quest decks have been updated. (changes made 19-9-11)
|
|
||||||
// Also, poorly named - this should be "getLockedChalleneges" or
|
|
||||||
// similar.
|
|
||||||
if (this.completedQuests != null) {
|
|
||||||
this.completedChallenges = this.completedQuests;
|
|
||||||
this.completedQuests = null;
|
|
||||||
}
|
|
||||||
|
|
||||||
return this.completedChallenges != null ? new ArrayList<Integer>(this.completedChallenges) : null;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* addCompletedChallenge.
|
|
||||||
* </p>
|
|
||||||
* Add non-repeatable challenge ID to list.
|
|
||||||
*
|
|
||||||
* @param i
|
|
||||||
* the i
|
|
||||||
*/
|
|
||||||
|
|
||||||
// Poorly named - this should be "setLockedChalleneges" or similar.
|
|
||||||
public void addCompletedChallenge(final int i) {
|
|
||||||
this.completedChallenges.add(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Wins & Losses
|
|
||||||
/**
|
|
||||||
* Gets the lost.
|
|
||||||
*
|
|
||||||
* @return the lost
|
|
||||||
*/
|
|
||||||
public int getLost() {
|
|
||||||
return this.lost;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the lost.
|
|
||||||
*/
|
|
||||||
public void addLost() {
|
|
||||||
this.lost++;
|
|
||||||
|
|
||||||
if (this.winstreakCurrent > this.winstreakBest) {
|
|
||||||
this.winstreakBest = this.winstreakCurrent;
|
|
||||||
}
|
|
||||||
|
|
||||||
this.winstreakCurrent = 0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the win.
|
|
||||||
*
|
|
||||||
* @return the win
|
|
||||||
*/
|
|
||||||
public int getWin() {
|
|
||||||
return this.win;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds the win.
|
|
||||||
*/
|
|
||||||
public void addWin() { // changes getRank()
|
|
||||||
this.win++;
|
|
||||||
this.winstreakCurrent++;
|
|
||||||
|
|
||||||
if (this.winstreakCurrent > this.winstreakBest) {
|
|
||||||
this.winstreakBest = this.winstreakCurrent;
|
|
||||||
}
|
|
||||||
|
|
||||||
final int winsToLvlUp = Singletons.getModel().getQuestPreferences()
|
|
||||||
.getPreferenceInt(QPref.WINS_RANKUP, this.diffIndex);
|
|
||||||
if ((this.win % winsToLvlUp) == 0) {
|
|
||||||
this.rankIndex++;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
// Life (only fantasy)
|
|
||||||
/**
|
|
||||||
* Gets the life.
|
|
||||||
*
|
|
||||||
* @return the life
|
|
||||||
*/
|
|
||||||
public int getLife() {
|
|
||||||
return this.isFantasy() ? this.life : 20;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Adds n life to maximum.
|
|
||||||
*
|
|
||||||
* @param n
|
|
||||||
*   int
|
|
||||||
*/
|
|
||||||
public void addLife(final int n) {
|
|
||||||
this.life += n;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Removes n life from maximum.
|
|
||||||
*
|
|
||||||
* @param n
|
|
||||||
*   int
|
|
||||||
*/
|
|
||||||
public void removeLife(final int n) {
|
|
||||||
this.life -= n;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Credits
|
|
||||||
/**
|
|
||||||
* Adds the credits.
|
|
||||||
*
|
|
||||||
* @param c
|
|
||||||
* the c
|
|
||||||
*/
|
|
||||||
public void addCredits(final long c) {
|
|
||||||
this.setCredits(this.getCredits() + c);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Subtract credits.
|
|
||||||
*
|
|
||||||
* @param c
|
|
||||||
* the c
|
|
||||||
*/
|
|
||||||
public void subtractCredits(final long c) {
|
|
||||||
this.setCredits(this.getCredits() > c ? this.getCredits() - c : 0);
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the credits.
|
|
||||||
*
|
|
||||||
* @return the credits
|
|
||||||
*/
|
|
||||||
public long getCredits() {
|
|
||||||
return this.credits;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Quest mode
|
|
||||||
/**
|
|
||||||
* Checks if is fantasy.
|
|
||||||
*
|
|
||||||
* @return true, if is fantasy
|
|
||||||
*/
|
|
||||||
public boolean isFantasy() {
|
|
||||||
return this.mode.equals(QuestData.FANTASY);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -503,101 +72,12 @@ public final class QuestData {
|
|||||||
*
|
*
|
||||||
* @return the mode
|
* @return the mode
|
||||||
*/
|
*/
|
||||||
public String getMode() {
|
public QuestMode getMode() {
|
||||||
return this.mode == null ? "" : this.mode;
|
return this.mode;
|
||||||
}
|
}
|
||||||
|
|
||||||
// Difficulty
|
|
||||||
/**
|
|
||||||
* Gets the difficulty.
|
|
||||||
*
|
|
||||||
* @return the difficulty
|
|
||||||
*/
|
|
||||||
public String getDifficulty() {
|
|
||||||
return this.difficulty;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the difficulty index.
|
|
||||||
*
|
|
||||||
* @return the difficulty index
|
|
||||||
*/
|
|
||||||
public int getDifficultyIndex() {
|
|
||||||
return this.diffIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the difficulty.
|
|
||||||
*
|
|
||||||
* @param i
|
|
||||||
* the new difficulty
|
|
||||||
*/
|
|
||||||
public void setDifficulty(final int i) {
|
|
||||||
this.diffIndex = i;
|
|
||||||
this.difficulty = QuestPreferences.getDifficulty(i);
|
|
||||||
}
|
|
||||||
|
|
||||||
// Level, read-only ( note: it increments in addWin() )
|
|
||||||
/**
|
|
||||||
* Gets the level.
|
|
||||||
*
|
|
||||||
* @return the level
|
|
||||||
*/
|
|
||||||
public int getLevel() {
|
|
||||||
return this.rankIndex;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the rank.
|
|
||||||
*
|
|
||||||
* @return the rank
|
|
||||||
*/
|
|
||||||
public String getRank() {
|
|
||||||
if (this.rankIndex >= QuestData.RANK_TITLES.length) {
|
|
||||||
this.rankIndex = QuestData.RANK_TITLES.length - 1;
|
|
||||||
}
|
|
||||||
return QuestData.RANK_TITLES[this.rankIndex];
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the win streak best.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public int getWinStreakBest() {
|
|
||||||
return this.winstreakBest;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the win streak current.
|
|
||||||
*
|
|
||||||
* @return int
|
|
||||||
*/
|
|
||||||
public int getWinStreakCurrent() {
|
|
||||||
return this.winstreakCurrent;
|
|
||||||
}
|
|
||||||
|
|
||||||
// decks management
|
|
||||||
|
|
||||||
// randomizer - related
|
|
||||||
/**
|
|
||||||
* Gets the random seed.
|
|
||||||
*
|
|
||||||
* @return the random seed
|
|
||||||
*/
|
|
||||||
public long getRandomSeed() {
|
|
||||||
return this.randomSeed;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* This method should be called whenever the opponents should change.
|
|
||||||
*/
|
|
||||||
public void randomizeOpponents() {
|
|
||||||
this.randomSeed = MyRandom.getRandom().nextLong();
|
|
||||||
}
|
|
||||||
|
|
||||||
// SERIALIZATION - related things
|
// SERIALIZATION - related things
|
||||||
|
|
||||||
// This must be called by XML-serializer via reflection
|
// This must be called by XML-serializer via reflection
|
||||||
/**
|
/**
|
||||||
* Read resolve.
|
* Read resolve.
|
||||||
@@ -605,7 +85,6 @@ public final class QuestData {
|
|||||||
* @return the object
|
* @return the object
|
||||||
*/
|
*/
|
||||||
public Object readResolve() {
|
public Object readResolve() {
|
||||||
this.initTransients();
|
|
||||||
return this;
|
return this;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -616,91 +95,6 @@ public final class QuestData {
|
|||||||
QuestDataIO.saveData(this);
|
QuestDataIO.saveData(this);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the card pool.
|
|
||||||
*
|
|
||||||
* @return the cardPool
|
|
||||||
*/
|
|
||||||
public ItemPool<CardPrinted> getCardPool() {
|
|
||||||
return this.cardPool;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the shop list.
|
|
||||||
*
|
|
||||||
* @return the shopList
|
|
||||||
*/
|
|
||||||
public ItemPool<InventoryItem> getShopList() {
|
|
||||||
return this.shopList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the shop list.
|
|
||||||
*
|
|
||||||
* @param shopList0
|
|
||||||
* the shopList to set
|
|
||||||
*/
|
|
||||||
public void setShopList(final ItemPool<InventoryItem> shopList0) {
|
|
||||||
this.shopList = shopList0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the new card list.
|
|
||||||
*
|
|
||||||
* @return the newCardList
|
|
||||||
*/
|
|
||||||
public ItemPool<InventoryItem> getNewCardList() {
|
|
||||||
return this.newCardList;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the new card list.
|
|
||||||
*
|
|
||||||
* @param newCardList0
|
|
||||||
* the newCardList to set
|
|
||||||
*/
|
|
||||||
public void setNewCardList(final ItemPool<InventoryItem> newCardList0) {
|
|
||||||
this.newCardList = newCardList0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the my decks.
|
|
||||||
*
|
|
||||||
* @return the myDecks
|
|
||||||
*/
|
|
||||||
public IStorage<Deck> getMyDecks() {
|
|
||||||
return this.decks;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Gets the precons.
|
|
||||||
*
|
|
||||||
* @return QuestPreconManager
|
|
||||||
*/
|
|
||||||
public static IStorageView<PreconDeck> getPrecons() {
|
|
||||||
return QuestData.preconManager;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the inventory.
|
|
||||||
*
|
|
||||||
* @param inventory0
|
|
||||||
* the inventory to set
|
|
||||||
*/
|
|
||||||
public void setInventory(final QuestInventory inventory0) {
|
|
||||||
this.inventory = inventory0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the credits.
|
|
||||||
*
|
|
||||||
* @param credits0
|
|
||||||
* the credits to set
|
|
||||||
*/
|
|
||||||
public void setCredits(final long credits0) {
|
|
||||||
this.credits = credits0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the version number.
|
* Gets the version number.
|
||||||
*
|
*
|
||||||
@@ -720,15 +114,6 @@ public final class QuestData {
|
|||||||
this.versionNumber = versionNumber0;
|
this.versionNumber = versionNumber0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
|
||||||
* Sets the name.
|
|
||||||
*
|
|
||||||
* @param s0   {@link java.lang.String}
|
|
||||||
*/
|
|
||||||
public void setName(final String s0) {
|
|
||||||
this.name = s0;
|
|
||||||
}
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Gets the name.
|
* Gets the name.
|
||||||
*
|
*
|
||||||
@@ -738,11 +123,21 @@ public final class QuestData {
|
|||||||
return this.name;
|
return this.name;
|
||||||
}
|
}
|
||||||
|
|
||||||
public QuestEvent getCurrentEvent() {
|
/**
|
||||||
return currentEvent;
|
* TODO: Write javadoc for this method.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public QuestAssets getAssets() {
|
||||||
|
return assets;
|
||||||
}
|
}
|
||||||
|
|
||||||
public void setCurrentEvent(QuestEvent currentEvent) {
|
|
||||||
this.currentEvent = currentEvent;
|
/**
|
||||||
|
* TODO: Write javadoc for this method.
|
||||||
|
* @return
|
||||||
|
*/
|
||||||
|
public QuestAchievements getAchievements() {
|
||||||
|
return achievements;
|
||||||
}
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,9 +21,13 @@ import java.io.BufferedOutputStream;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.io.FileInputStream;
|
import java.io.FileInputStream;
|
||||||
import java.io.FileOutputStream;
|
import java.io.FileOutputStream;
|
||||||
|
import java.io.IOException;
|
||||||
import java.io.InputStreamReader;
|
import java.io.InputStreamReader;
|
||||||
import java.io.StringReader;
|
import java.io.StringReader;
|
||||||
|
import java.io.StringWriter;
|
||||||
|
import java.lang.reflect.Field;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
|
import java.util.HashMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map.Entry;
|
import java.util.Map.Entry;
|
||||||
import java.util.zip.GZIPInputStream;
|
import java.util.zip.GZIPInputStream;
|
||||||
@@ -31,9 +35,18 @@ import java.util.zip.GZIPOutputStream;
|
|||||||
|
|
||||||
import javax.xml.parsers.DocumentBuilder;
|
import javax.xml.parsers.DocumentBuilder;
|
||||||
import javax.xml.parsers.DocumentBuilderFactory;
|
import javax.xml.parsers.DocumentBuilderFactory;
|
||||||
|
import javax.xml.transform.OutputKeys;
|
||||||
|
import javax.xml.transform.Transformer;
|
||||||
|
import javax.xml.transform.TransformerException;
|
||||||
|
import javax.xml.transform.TransformerFactory;
|
||||||
|
import javax.xml.transform.dom.DOMSource;
|
||||||
|
import javax.xml.transform.stream.StreamResult;
|
||||||
|
|
||||||
import org.apache.commons.lang3.StringUtils;
|
import org.apache.commons.lang3.StringUtils;
|
||||||
|
import org.w3c.dom.Attr;
|
||||||
import org.w3c.dom.Document;
|
import org.w3c.dom.Document;
|
||||||
|
import org.w3c.dom.NamedNodeMap;
|
||||||
|
import org.w3c.dom.Node;
|
||||||
import org.w3c.dom.NodeList;
|
import org.w3c.dom.NodeList;
|
||||||
import org.xml.sax.InputSource;
|
import org.xml.sax.InputSource;
|
||||||
|
|
||||||
@@ -61,6 +74,7 @@ import forge.item.TournamentPack;
|
|||||||
import forge.properties.ForgeProps;
|
import forge.properties.ForgeProps;
|
||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
import forge.quest.data.item.QuestInventory;
|
import forge.quest.data.item.QuestInventory;
|
||||||
|
import forge.quest.data.pet.QuestPetManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -71,12 +85,16 @@ import forge.quest.data.item.QuestInventory;
|
|||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public class QuestDataIO {
|
public class QuestDataIO {
|
||||||
/**
|
|
||||||
* <p>
|
|
||||||
* Constructor for QuestDataIO.
|
protected static XStream getSerializer(boolean isIgnoring) {
|
||||||
* </p>
|
final XStream xStream = isIgnoring ? new IgnoringXStream() : new XStream();
|
||||||
*/
|
xStream.registerConverter(new ItemPoolToXml());
|
||||||
public QuestDataIO() {
|
xStream.registerConverter(new DeckSectionToXml());
|
||||||
|
xStream.registerConverter(new GameTypeToXml());
|
||||||
|
xStream.alias("CardPool", ItemPool.class);
|
||||||
|
xStream.alias("DeckSection", DeckSection.class);
|
||||||
|
return xStream;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -91,11 +109,6 @@ public class QuestDataIO {
|
|||||||
public static QuestData loadData(final File xmlSaveFile) {
|
public static QuestData loadData(final File xmlSaveFile) {
|
||||||
try {
|
try {
|
||||||
QuestData data = null;
|
QuestData data = null;
|
||||||
final String name = xmlSaveFile.getName().substring(0, xmlSaveFile.getName().length() - 4);
|
|
||||||
|
|
||||||
if (!xmlSaveFile.exists()) {
|
|
||||||
return new QuestData(name);
|
|
||||||
}
|
|
||||||
|
|
||||||
final GZIPInputStream zin = new GZIPInputStream(new FileInputStream(xmlSaveFile));
|
final GZIPInputStream zin = new GZIPInputStream(new FileInputStream(xmlSaveFile));
|
||||||
|
|
||||||
@@ -110,21 +123,14 @@ public class QuestDataIO {
|
|||||||
xml.append(buf, 0, len);
|
xml.append(buf, 0, len);
|
||||||
}
|
}
|
||||||
|
|
||||||
final IgnoringXStream xStream = new IgnoringXStream();
|
zin.close();
|
||||||
xStream.registerConverter(new ItemPoolToXml());
|
|
||||||
xStream.registerConverter(new DeckSectionToXml());
|
data = (QuestData) getSerializer(true).fromXML(xml.toString());
|
||||||
xStream.registerConverter(new GameTypeToXml());
|
|
||||||
xStream.alias("CardPool", ItemPool.class);
|
|
||||||
xStream.alias("DeckSection", DeckSection.class);
|
|
||||||
data = (QuestData) xStream.fromXML(xml.toString());
|
|
||||||
data.setName(name);
|
|
||||||
|
|
||||||
if (data.getVersionNumber() != QuestData.CURRENT_VERSION_NUMBER) {
|
if (data.getVersionNumber() != QuestData.CURRENT_VERSION_NUMBER) {
|
||||||
QuestDataIO.updateSaveFile(data, xml.toString());
|
QuestDataIO.updateSaveFile(data, xml.toString());
|
||||||
}
|
}
|
||||||
|
|
||||||
zin.close();
|
|
||||||
|
|
||||||
return data;
|
return data;
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
ErrorViewer.showError(ex, "Error loading Quest Data");
|
ErrorViewer.showError(ex, "Error loading Quest Data");
|
||||||
@@ -132,6 +138,12 @@ public class QuestDataIO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static <T> void setFinalField(Class<T> clasz, String fieldName, T instance, Object newValue) throws IllegalAccessException, NoSuchFieldException {
|
||||||
|
Field field = clasz.getDeclaredField(fieldName);
|
||||||
|
field.setAccessible(true);
|
||||||
|
field.set(instance, newValue); // no difference here (used only to set initial lives)
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* updateSaveFile.
|
* updateSaveFile.
|
||||||
@@ -142,6 +154,7 @@ public class QuestDataIO {
|
|||||||
* @param input
|
* @param input
|
||||||
* a {@link java.lang.String} object.
|
* a {@link java.lang.String} object.
|
||||||
*/
|
*/
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
private static void updateSaveFile(final QuestData newData, final String input) {
|
private static void updateSaveFile(final QuestData newData, final String input) {
|
||||||
try {
|
try {
|
||||||
final DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
final DocumentBuilder builder = DocumentBuilderFactory.newInstance().newDocumentBuilder();
|
||||||
@@ -149,33 +162,74 @@ public class QuestDataIO {
|
|||||||
is.setCharacterStream(new StringReader(input));
|
is.setCharacterStream(new StringReader(input));
|
||||||
final Document document = builder.parse(is);
|
final Document document = builder.parse(is);
|
||||||
|
|
||||||
switch (newData.getVersionNumber()) {
|
final int saveVersion = newData.getVersionNumber();
|
||||||
|
|
||||||
|
if( saveVersion < 3 ) {
|
||||||
|
// no difference here (used only to set initial lives)
|
||||||
|
setFinalField(QuestData.class, "assets", newData, new QuestAssets(QuestMode.Classic));
|
||||||
|
|
||||||
|
int diffIdx = Integer.parseInt(document.getElementsByTagName("diffIndex").item(0).getTextContent());
|
||||||
|
setFinalField(QuestData.class, "achievements", newData, new QuestAchievements(diffIdx));
|
||||||
|
}
|
||||||
|
|
||||||
|
switch (saveVersion) {
|
||||||
// There should be a fall-through b/w the cases so that each
|
// There should be a fall-through b/w the cases so that each
|
||||||
// version's changes get applied progressively
|
// version's changes get applied progressively
|
||||||
case 0:
|
case 0:
|
||||||
// First beta release with new file format,
|
// First beta release with new file format,
|
||||||
// inventory needs to be migrated
|
// inventory needs to be migrated
|
||||||
newData.setInventory(new QuestInventory());
|
setFinalField(QuestAssets.class, "inventory", newData.getAssets(), new QuestInventory());
|
||||||
NodeList elements = document.getElementsByTagName("estatesLevel");
|
NodeList elements = document.getElementsByTagName("estatesLevel");
|
||||||
newData.getInventory().setItemLevel("Estates", Integer.parseInt(elements.item(0).getTextContent()));
|
newData.getAssets().getInventory().setItemLevel("Estates", Integer.parseInt(elements.item(0).getTextContent()));
|
||||||
elements = document.getElementsByTagName("luckyCoinLevel");
|
elements = document.getElementsByTagName("luckyCoinLevel");
|
||||||
newData.getInventory().setItemLevel("Lucky Coin", Integer.parseInt(elements.item(0).getTextContent()));
|
newData.getAssets().getInventory().setItemLevel("Lucky Coin", Integer.parseInt(elements.item(0).getTextContent()));
|
||||||
elements = document.getElementsByTagName("sleightOfHandLevel");
|
elements = document.getElementsByTagName("sleightOfHandLevel");
|
||||||
newData.getInventory().setItemLevel("Sleight", Integer.parseInt(elements.item(0).getTextContent()));
|
newData.getAssets().getInventory().setItemLevel("Sleight", Integer.parseInt(elements.item(0).getTextContent()));
|
||||||
elements = document.getElementsByTagName("gearLevel");
|
elements = document.getElementsByTagName("gearLevel");
|
||||||
|
|
||||||
final int gearLevel = Integer.parseInt(elements.item(0).getTextContent());
|
final int gearLevel = Integer.parseInt(elements.item(0).getTextContent());
|
||||||
if (gearLevel >= 1) {
|
if (gearLevel >= 1) {
|
||||||
newData.getInventory().setItemLevel("Map", 1);
|
newData.getAssets().getInventory().setItemLevel("Map", 1);
|
||||||
}
|
}
|
||||||
if (gearLevel == 2) {
|
if (gearLevel == 2) {
|
||||||
newData.getInventory().setItemLevel("Zeppelin", 1);
|
newData.getAssets().getInventory().setItemLevel("Zeppelin", 1);
|
||||||
}
|
}
|
||||||
// fall-through
|
// fall-through
|
||||||
case 1:
|
case 1:
|
||||||
// nothing to do here, everything is managed by CardPoolToXml
|
// nothing to do here, everything is managed by CardPoolToXml
|
||||||
// deserializer
|
// deserializer
|
||||||
break;
|
|
||||||
|
case 2:
|
||||||
|
if (StringUtils.isBlank(newData.getName())) {
|
||||||
|
setFinalField(QuestData.class, "name", newData, "questData");
|
||||||
|
}
|
||||||
|
|
||||||
|
QuestAchievements qA = newData.getAchievements();
|
||||||
|
qA.win = Integer.parseInt(document.getElementsByTagName("win").item(0).getTextContent());
|
||||||
|
qA.lost = Integer.parseInt(document.getElementsByTagName("lost").item(0).getTextContent());
|
||||||
|
qA.winstreakBest = Integer.parseInt(document.getElementsByTagName("winstreakBest").item(0).getTextContent());
|
||||||
|
qA.winstreakCurrent = Integer.parseInt(document.getElementsByTagName("winstreakCurrent").item(0).getTextContent());
|
||||||
|
qA.challengesPlayed = Integer.parseInt(document.getElementsByTagName("challengesPlayed").item(0).getTextContent());
|
||||||
|
qA.completedChallenges = new ArrayList<Integer>();
|
||||||
|
NodeList ccs = document.getElementsByTagName("completedChallenges").item(0).getChildNodes();
|
||||||
|
for(int iN = 0; iN < ccs.getLength(); iN++) {
|
||||||
|
Node n = ccs.item(iN);
|
||||||
|
if ( n.getNodeType() != Node.ELEMENT_NODE ) continue;
|
||||||
|
qA.completedChallenges.add(Integer.parseInt(n.getTextContent()));
|
||||||
|
}
|
||||||
|
|
||||||
|
QuestAssets qS = newData.getAssets();
|
||||||
|
qS.credits = Integer.parseInt(document.getElementsByTagName("credits").item(0).getTextContent());
|
||||||
|
qS.life = Integer.parseInt(document.getElementsByTagName("life").item(0).getTextContent());
|
||||||
|
|
||||||
|
XStream xs = getSerializer(true);
|
||||||
|
|
||||||
|
setFinalField(QuestAssets.class, "cardPool", qS, readAsset(xs, document, "cardPool", ItemPool.class));
|
||||||
|
setFinalField(QuestAssets.class, "inventory", qS, readAsset(xs, document, "inventory", QuestInventory.class));
|
||||||
|
setFinalField(QuestAssets.class, "myDecks", qS, readAsset(xs, document, "myDecks", HashMap.class));
|
||||||
|
setFinalField(QuestAssets.class, "petManager", qS, readAsset(xs, document, "petManager", QuestPetManager.class));
|
||||||
|
setFinalField(QuestAssets.class, "shopList", qS, readAsset(xs, document, "shopList", ItemPool.class));
|
||||||
|
setFinalField(QuestAssets.class, "newCardList", qS, readAsset(xs, document, "newCardList", ItemPool.class));
|
||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
@@ -188,6 +242,33 @@ public class QuestDataIO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@SuppressWarnings("unchecked")
|
||||||
|
private static <T> T readAsset(XStream xs, Document doc, String tagName, Class<T> clasz) throws IllegalAccessException, NoSuchFieldException {
|
||||||
|
NodeList nn = doc.getElementsByTagName(tagName);
|
||||||
|
Node n = nn.item(0);
|
||||||
|
|
||||||
|
Attr att = doc.createAttribute("resolves-to");
|
||||||
|
att.setValue(clasz.getCanonicalName());
|
||||||
|
n.getAttributes().setNamedItem(att);
|
||||||
|
|
||||||
|
String xmlData = nodeToString(n);
|
||||||
|
return (T) xs.fromXML(xmlData);
|
||||||
|
}
|
||||||
|
|
||||||
|
private static String nodeToString(Node node) {
|
||||||
|
StringWriter sw = new StringWriter();
|
||||||
|
try {
|
||||||
|
Transformer t = TransformerFactory.newInstance().newTransformer();
|
||||||
|
t.setOutputProperty(OutputKeys.OMIT_XML_DECLARATION, "yes");
|
||||||
|
t.setOutputProperty(OutputKeys.INDENT, "yes");
|
||||||
|
t.transform(new DOMSource(node), new StreamResult(sw));
|
||||||
|
} catch (TransformerException te) {
|
||||||
|
System.out.println("nodeToString Transformer Exception");
|
||||||
|
}
|
||||||
|
return sw.toString();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* saveData.
|
* saveData.
|
||||||
@@ -198,25 +279,11 @@ public class QuestDataIO {
|
|||||||
*/
|
*/
|
||||||
public static void saveData(final QuestData qd) {
|
public static void saveData(final QuestData qd) {
|
||||||
try {
|
try {
|
||||||
final XStream xStream = new XStream();
|
final XStream xStream = getSerializer(false);
|
||||||
xStream.registerConverter(new ItemPoolToXml());
|
|
||||||
xStream.registerConverter(new DeckSectionToXml());
|
|
||||||
xStream.alias("CardPool", ItemPool.class);
|
|
||||||
xStream.alias("DeckSection", DeckSection.class);
|
|
||||||
|
|
||||||
final File f = new File(ForgeProps.getFile(NewConstants.Quest.DATA_DIR) + File.separator + qd.getName()
|
final File f = new File(ForgeProps.getFile(NewConstants.Quest.DATA_DIR), qd.getName() );
|
||||||
+ ".dat");
|
savePacked(f + ".dat", xStream, qd);
|
||||||
final BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream(f));
|
saveUnpacked(f + ".xml", xStream, qd);
|
||||||
final GZIPOutputStream zout = new GZIPOutputStream(bout);
|
|
||||||
xStream.toXML(qd, zout);
|
|
||||||
zout.flush();
|
|
||||||
zout.close();
|
|
||||||
|
|
||||||
// BufferedOutputStream boutUnp = new BufferedOutputStream(new
|
|
||||||
// FileOutputStream(f + ".xml"));
|
|
||||||
// xStream.toXML(qd, boutUnp);
|
|
||||||
// boutUnp.flush();
|
|
||||||
// boutUnp.close();
|
|
||||||
|
|
||||||
} catch (final Exception ex) {
|
} catch (final Exception ex) {
|
||||||
ErrorViewer.showError(ex, "Error saving Quest Data.");
|
ErrorViewer.showError(ex, "Error saving Quest Data.");
|
||||||
@@ -224,6 +291,22 @@ public class QuestDataIO {
|
|||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
private static void savePacked(String f, XStream xStream, QuestData qd) throws IOException {
|
||||||
|
final BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream(f));
|
||||||
|
final GZIPOutputStream zout = new GZIPOutputStream(bout);
|
||||||
|
xStream.toXML(qd, zout);
|
||||||
|
zout.flush();
|
||||||
|
zout.close();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
private static void saveUnpacked(String f, XStream xStream, QuestData qd) throws IOException {
|
||||||
|
BufferedOutputStream boutUnp = new BufferedOutputStream(new FileOutputStream(f));
|
||||||
|
xStream.toXML(qd, boutUnp);
|
||||||
|
boutUnp.flush();
|
||||||
|
boutUnp.close();
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Xstream subclass that ignores fields that are present in the save but not
|
* Xstream subclass that ignores fields that are present in the save but not
|
||||||
* in the class. This one is intended to skip fields defined in Object class
|
* in the class. This one is intended to skip fields defined in Object class
|
||||||
@@ -379,7 +462,7 @@ public class QuestDataIO {
|
|||||||
if (name == null) {
|
if (name == null) {
|
||||||
name = reader.getAttribute("s");
|
name = reader.getAttribute("s");
|
||||||
}
|
}
|
||||||
return QuestData.getPrecons().get(name);
|
return QuestController.getPrecons().get(name);
|
||||||
}
|
}
|
||||||
|
|
||||||
protected BoosterPack readBooster(final HierarchicalStreamReader reader) {
|
protected BoosterPack readBooster(final HierarchicalStreamReader reader) {
|
||||||
|
|||||||
12
src/main/java/forge/quest/data/QuestDuelDifficulty.java
Normal file
12
src/main/java/forge/quest/data/QuestDuelDifficulty.java
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package forge.quest.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this type.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public enum QuestDuelDifficulty {
|
||||||
|
EASY,
|
||||||
|
MEDIUM,
|
||||||
|
HARD,
|
||||||
|
EXPERT
|
||||||
|
}
|
||||||
@@ -20,6 +20,7 @@ package forge.quest.data;
|
|||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.Collections;
|
import java.util.Collections;
|
||||||
|
import java.util.EnumMap;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.Random;
|
import java.util.Random;
|
||||||
@@ -45,23 +46,17 @@ import forge.util.FileUtil;
|
|||||||
*/
|
*/
|
||||||
public enum QuestEventManager {
|
public enum QuestEventManager {
|
||||||
/** */
|
/** */
|
||||||
SINGLETON_INSTANCE;
|
INSTANCE;
|
||||||
|
|
||||||
|
private final Map<QuestDuelDifficulty, List<QuestDuel>> SortedDuels = new EnumMap<QuestDuelDifficulty, List<QuestDuel>>(QuestDuelDifficulty.class);
|
||||||
|
|
||||||
/** */
|
/** */
|
||||||
private static final List<QuestDuel> EASY_DUELS = new ArrayList<QuestDuel>();
|
public final List<QuestDuel> ALL_DUELS = new ArrayList<QuestDuel>();
|
||||||
/** */
|
/** */
|
||||||
private static final List<QuestDuel> MEDIUM_DUELS = new ArrayList<QuestDuel>();
|
public final List<QuestChallenge> ALL_CHALLENGES = new ArrayList<QuestChallenge>();
|
||||||
/** */
|
|
||||||
private static final List<QuestDuel> HARD_DUELS = new ArrayList<QuestDuel>();
|
|
||||||
/** */
|
|
||||||
private static final List<QuestDuel> EXPERT_DUELS = new ArrayList<QuestDuel>();
|
|
||||||
/** */
|
|
||||||
public static final List<QuestDuel> ALL_DUELS = new ArrayList<QuestDuel>();
|
|
||||||
/** */
|
|
||||||
public static final List<QuestChallenge> ALL_CHALLENGES = new ArrayList<QuestChallenge>();
|
|
||||||
|
|
||||||
/** Instantiate all events and difficulty lists. */
|
/** Instantiate all events and difficulty lists. */
|
||||||
static {
|
private QuestEventManager() {
|
||||||
QuestEvent tempEvent;
|
QuestEvent tempEvent;
|
||||||
|
|
||||||
final File[] allFiles = ForgeProps.getFile(NewConstants.Quest.DECKS).listFiles(DeckSerializer.DCK_FILE_FILTER);
|
final File[] allFiles = ForgeProps.getFile(NewConstants.Quest.DECKS).listFiles(DeckSerializer.DCK_FILE_FILTER);
|
||||||
@@ -70,20 +65,20 @@ public enum QuestEventManager {
|
|||||||
final Map<String, List<String>> contents = FileSection.parseSections(FileUtil.readFile(f));
|
final Map<String, List<String>> contents = FileSection.parseSections(FileUtil.readFile(f));
|
||||||
|
|
||||||
if (contents.containsKey("quest")) {
|
if (contents.containsKey("quest")) {
|
||||||
tempEvent = QuestEventManager.readChallenge(contents.get("quest"));
|
tempEvent = readChallenge(contents.get("quest"));
|
||||||
ALL_CHALLENGES.add((QuestChallenge) tempEvent);
|
ALL_CHALLENGES.add((QuestChallenge) tempEvent);
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
tempEvent = QuestEventManager.readDuel(contents.get("metadata"));
|
tempEvent = readDuel(contents.get("metadata"));
|
||||||
ALL_DUELS.add((QuestDuel) tempEvent);
|
ALL_DUELS.add((QuestDuel) tempEvent);
|
||||||
}
|
}
|
||||||
|
|
||||||
// Assemble metadata (may not be necessary later) and deck object.
|
// Assemble metadata (may not be necessary later) and deck object.
|
||||||
QuestEventManager.readMetadata(contents.get("metadata"), tempEvent);
|
readMetadata(contents.get("metadata"), tempEvent);
|
||||||
tempEvent.setEventDeck(Deck.fromSections(contents));
|
tempEvent.setEventDeck(Deck.fromSections(contents));
|
||||||
} // End for(allFiles)
|
} // End for(allFiles)
|
||||||
|
|
||||||
QuestEventManager.assembleDuelDifficultyLists();
|
assembleDuelDifficultyLists();
|
||||||
} // End assembleAllEvents()
|
} // End assembleAllEvents()
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,7 +88,7 @@ public enum QuestEventManager {
|
|||||||
*   {@link java.lang.String}
|
*   {@link java.lang.String}
|
||||||
* @return {@link forge.data.QuestEvent}
|
* @return {@link forge.data.QuestEvent}
|
||||||
*/
|
*/
|
||||||
public static QuestEvent getEvent(final String s0) {
|
public QuestEvent getEvent(final String s0) {
|
||||||
for (final QuestEvent q : ALL_DUELS) {
|
for (final QuestEvent q : ALL_DUELS) {
|
||||||
if (q.getName().equals(s0)) {
|
if (q.getName().equals(s0)) {
|
||||||
return q;
|
return q;
|
||||||
@@ -113,43 +108,47 @@ public enum QuestEventManager {
|
|||||||
*
|
*
|
||||||
* @return an array of {@link java.lang.String} objects.
|
* @return an array of {@link java.lang.String} objects.
|
||||||
*/
|
*/
|
||||||
public static final List<QuestDuel> generateDuels() {
|
public final List<QuestDuel> generateDuels() {
|
||||||
final QuestPreferences qpref = Singletons.getModel().getQuestPreferences();
|
final QuestPreferences qpref = Singletons.getModel().getQuestPreferences();
|
||||||
if (AllZone.getQuestData() == null) {
|
if (AllZone.getQuest().getAchievements() == null) {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int index = AllZone.getQuestData().getDifficultyIndex();
|
final QuestController qCtrl = AllZone.getQuest();
|
||||||
|
final int cntWins = qCtrl.getAchievements().getWin();
|
||||||
|
|
||||||
|
final int index = qCtrl.getAchievements().getDifficulty();
|
||||||
final List<QuestDuel> duelOpponents = new ArrayList<QuestDuel>();
|
final List<QuestDuel> duelOpponents = new ArrayList<QuestDuel>();
|
||||||
|
|
||||||
if (AllZone.getQuestData().getWin() < qpref.getPreferenceInt(QPref.WINS_MEDIUMAI, index)) {
|
|
||||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(QuestEventManager.EASY_DUELS, 0));
|
if (cntWins < qpref.getPreferenceInt(QPref.WINS_MEDIUMAI, index)) {
|
||||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(QuestEventManager.EASY_DUELS, 1));
|
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.EASY).get(0));
|
||||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(QuestEventManager.EASY_DUELS, 2));
|
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.EASY).get(1));
|
||||||
} else if (AllZone.getQuestData().getWin() == qpref.getPreferenceInt(QPref.WINS_MEDIUMAI, index)) {
|
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.EASY).get(2));
|
||||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(QuestEventManager.EASY_DUELS, 0));
|
} else if (cntWins == qpref.getPreferenceInt(QPref.WINS_MEDIUMAI, index)) {
|
||||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(QuestEventManager.MEDIUM_DUELS, 0));
|
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.EASY).get(0));
|
||||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(QuestEventManager.MEDIUM_DUELS, 1));
|
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.MEDIUM).get(0));
|
||||||
} else if (AllZone.getQuestData().getWin() < qpref.getPreferenceInt(QPref.WINS_HARDAI, index)) {
|
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.MEDIUM).get(1));
|
||||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(QuestEventManager.MEDIUM_DUELS, 0));
|
} else if (cntWins < qpref.getPreferenceInt(QPref.WINS_HARDAI, index)) {
|
||||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(QuestEventManager.MEDIUM_DUELS, 1));
|
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.MEDIUM).get(0));
|
||||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(QuestEventManager.MEDIUM_DUELS, 2));
|
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.MEDIUM).get(1));
|
||||||
|
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.MEDIUM).get(2));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (AllZone.getQuestData().getWin() == qpref.getPreferenceInt(QPref.WINS_HARDAI, index)) {
|
else if (cntWins == qpref.getPreferenceInt(QPref.WINS_HARDAI, index)) {
|
||||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(QuestEventManager.MEDIUM_DUELS, 0));
|
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.MEDIUM).get(0));
|
||||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(QuestEventManager.HARD_DUELS, 0));
|
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.HARD).get(0));
|
||||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(QuestEventManager.HARD_DUELS, 1));
|
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.HARD).get(1));
|
||||||
}
|
}
|
||||||
|
|
||||||
else if (AllZone.getQuestData().getWin() < qpref.getPreferenceInt(QPref.WINS_EXPERTAI, index)) {
|
else if (cntWins < qpref.getPreferenceInt(QPref.WINS_EXPERTAI, index)) {
|
||||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(QuestEventManager.HARD_DUELS, 0));
|
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.HARD).get(0));
|
||||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(QuestEventManager.HARD_DUELS, 1));
|
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.HARD).get(1));
|
||||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(QuestEventManager.HARD_DUELS, 2));
|
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.HARD).get(2));
|
||||||
} else {
|
} else {
|
||||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(QuestEventManager.HARD_DUELS, 0));
|
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.HARD).get(0));
|
||||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(QuestEventManager.HARD_DUELS, 1));
|
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.HARD).get(1));
|
||||||
duelOpponents.add(QuestEventManager.getDuelOpponentByNumber(QuestEventManager.EXPERT_DUELS, 2));
|
duelOpponents.add(SortedDuels.get(QuestDuelDifficulty.EXPERT).get(0));
|
||||||
}
|
}
|
||||||
|
|
||||||
return duelOpponents;
|
return duelOpponents;
|
||||||
@@ -159,9 +158,10 @@ public enum QuestEventManager {
|
|||||||
*
|
*
|
||||||
* @return a {@link java.util.List} object.
|
* @return a {@link java.util.List} object.
|
||||||
*/
|
*/
|
||||||
public static final List<QuestChallenge> generateChallenges() {
|
public final List<QuestChallenge> generateChallenges() {
|
||||||
final List<QuestChallenge> challengeOpponents = new ArrayList<QuestChallenge>();
|
final List<QuestChallenge> challengeOpponents = new ArrayList<QuestChallenge>();
|
||||||
final QuestData qData = AllZone.getQuestData();
|
final QuestController qCtrl = AllZone.getQuest();
|
||||||
|
final QuestAchievements qData = qCtrl.getAchievements();
|
||||||
|
|
||||||
int maxChallenges = qData.getWin() / 10;
|
int maxChallenges = qData.getWin() / 10;
|
||||||
if (maxChallenges > 5) {
|
if (maxChallenges > 5) {
|
||||||
@@ -169,12 +169,12 @@ public enum QuestEventManager {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Generate IDs as needed.
|
// Generate IDs as needed.
|
||||||
if ((qData.getAvailableChallenges() == null) || (qData.getAvailableChallenges().size() < maxChallenges)) {
|
if ((qCtrl.getAvailableChallenges() == null) || (qCtrl.getAvailableChallenges().size() < maxChallenges)) {
|
||||||
|
|
||||||
final List<Integer> unlockedChallengeIds = new ArrayList<Integer>();
|
final List<Integer> unlockedChallengeIds = new ArrayList<Integer>();
|
||||||
final List<Integer> availableChallengeIds = new ArrayList<Integer>();
|
final List<Integer> availableChallengeIds = new ArrayList<Integer>();
|
||||||
|
|
||||||
for (final QuestChallenge qc : QuestEventManager.ALL_CHALLENGES) {
|
for (final QuestChallenge qc : ALL_CHALLENGES) {
|
||||||
if ((qc.getWinsReqd() <= qData.getWin())
|
if ((qc.getWinsReqd() <= qData.getWin())
|
||||||
&& !qData.getCompletedChallenges().contains(qc.getId())) {
|
&& !qData.getCompletedChallenges().contains(qc.getId())) {
|
||||||
unlockedChallengeIds.add(qc.getId());
|
unlockedChallengeIds.add(qc.getId());
|
||||||
@@ -189,13 +189,13 @@ public enum QuestEventManager {
|
|||||||
availableChallengeIds.add(unlockedChallengeIds.get(i));
|
availableChallengeIds.add(unlockedChallengeIds.get(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
qData.setAvailableChallenges(availableChallengeIds);
|
qCtrl.setAvailableChallenges(availableChallengeIds);
|
||||||
qData.saveData();
|
qCtrl.save();
|
||||||
}
|
}
|
||||||
|
|
||||||
// Finally, pull challenge events from available IDs and return.
|
// Finally, pull challenge events from available IDs and return.
|
||||||
for (final int i : qData.getAvailableChallenges()) {
|
for (final int i : qCtrl.getAvailableChallenges()) {
|
||||||
challengeOpponents.add(QuestEventManager.getChallengeEventByNumber(i));
|
challengeOpponents.add(getChallengeEventByNumber(i));
|
||||||
}
|
}
|
||||||
|
|
||||||
return challengeOpponents;
|
return challengeOpponents;
|
||||||
@@ -210,7 +210,7 @@ public enum QuestEventManager {
|
|||||||
* @param contents
|
* @param contents
|
||||||
* @param qd
|
* @param qd
|
||||||
*/
|
*/
|
||||||
private static QuestDuel readDuel(final List<String> contents) {
|
private QuestDuel readDuel(final List<String> contents) {
|
||||||
final QuestDuel qd = new QuestDuel();
|
final QuestDuel qd = new QuestDuel();
|
||||||
int eqpos;
|
int eqpos;
|
||||||
String key, value;
|
String key, value;
|
||||||
@@ -243,7 +243,7 @@ public enum QuestEventManager {
|
|||||||
* @param contents
|
* @param contents
|
||||||
* @param qc
|
* @param qc
|
||||||
*/
|
*/
|
||||||
private static QuestChallenge readChallenge(final List<String> contents) {
|
private QuestChallenge readChallenge(final List<String> contents) {
|
||||||
int eqpos;
|
int eqpos;
|
||||||
String key, value;
|
String key, value;
|
||||||
|
|
||||||
@@ -312,7 +312,7 @@ public enum QuestEventManager {
|
|||||||
* @param contents
|
* @param contents
|
||||||
* @param qe
|
* @param qe
|
||||||
*/
|
*/
|
||||||
private static void readMetadata(final List<String> contents, final QuestEvent qe) {
|
private void readMetadata(final List<String> contents, final QuestEvent qe) {
|
||||||
int eqpos;
|
int eqpos;
|
||||||
String key, value;
|
String key, value;
|
||||||
|
|
||||||
@@ -347,46 +347,36 @@ public enum QuestEventManager {
|
|||||||
* </p>
|
* </p>
|
||||||
* Assemble duel deck difficulty lists
|
* Assemble duel deck difficulty lists
|
||||||
*/
|
*/
|
||||||
private static void assembleDuelDifficultyLists() {
|
private void assembleDuelDifficultyLists() {
|
||||||
EASY_DUELS.clear();
|
SortedDuels.clear();
|
||||||
MEDIUM_DUELS.clear();
|
SortedDuels.put(QuestDuelDifficulty.EASY, new ArrayList<QuestDuel>() );
|
||||||
HARD_DUELS.clear();
|
SortedDuels.put(QuestDuelDifficulty.MEDIUM, new ArrayList<QuestDuel>() );
|
||||||
EXPERT_DUELS.clear();
|
SortedDuels.put(QuestDuelDifficulty.HARD, new ArrayList<QuestDuel>() );
|
||||||
|
SortedDuels.put(QuestDuelDifficulty.EXPERT, new ArrayList<QuestDuel>() );
|
||||||
|
|
||||||
String s;
|
String s;
|
||||||
|
|
||||||
for (final QuestDuel qd : ALL_DUELS) {
|
for (final QuestDuel qd : ALL_DUELS) {
|
||||||
s = qd.getDifficulty();
|
s = qd.getDifficulty();
|
||||||
if (s.equalsIgnoreCase("easy")) {
|
if (s.equalsIgnoreCase("easy")) {
|
||||||
EASY_DUELS.add(qd);
|
SortedDuels.get(QuestDuelDifficulty.EASY).add(qd);
|
||||||
} else if (s.equalsIgnoreCase("medium")) {
|
} else if (s.equalsIgnoreCase("medium")) {
|
||||||
MEDIUM_DUELS.add(qd);
|
SortedDuels.get(QuestDuelDifficulty.MEDIUM).add(qd);
|
||||||
} else if (s.equalsIgnoreCase("hard")) {
|
} else if (s.equalsIgnoreCase("hard")) {
|
||||||
HARD_DUELS.add(qd);
|
SortedDuels.get(QuestDuelDifficulty.HARD).add(qd);
|
||||||
} else if (s.equalsIgnoreCase("very hard")) {
|
} else if (s.equalsIgnoreCase("very hard")) {
|
||||||
EXPERT_DUELS.add(qd);
|
SortedDuels.get(QuestDuelDifficulty.EXPERT).add(qd);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
public void randomizeOpponents() {
|
||||||
* <p>
|
long seed = new Random().nextLong();
|
||||||
* getDuelOpponent.
|
Random r = new Random(seed);
|
||||||
* </p>
|
Collections.shuffle(SortedDuels.get(QuestDuelDifficulty.EASY), r);
|
||||||
* Returns specific duel opponent from current shuffle of available duels.
|
Collections.shuffle(SortedDuels.get(QuestDuelDifficulty.MEDIUM), r);
|
||||||
* This is to make sure that the opponents do not change when the deck
|
Collections.shuffle(SortedDuels.get(QuestDuelDifficulty.HARD), r);
|
||||||
* editor is launched.
|
Collections.shuffle(SortedDuels.get(QuestDuelDifficulty.EXPERT), r);
|
||||||
*
|
|
||||||
* @param aiDeck
|
|
||||||
* a {@link java.util.List} object.
|
|
||||||
* @param number
|
|
||||||
* a int.
|
|
||||||
* @return a {@link java.lang.String} object.
|
|
||||||
*/
|
|
||||||
private static QuestDuel getDuelOpponentByNumber(final List<QuestDuel> aiDeck, final int n) {
|
|
||||||
final List<QuestDuel> deckListCopy = new ArrayList<QuestDuel>(aiDeck);
|
|
||||||
Collections.shuffle(deckListCopy, new Random(AllZone.getQuestData().getRandomSeed()));
|
|
||||||
|
|
||||||
return deckListCopy.get(n);
|
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -399,7 +389,7 @@ public enum QuestEventManager {
|
|||||||
* @param n
|
* @param n
|
||||||
* @return
|
* @return
|
||||||
*/
|
*/
|
||||||
private static QuestChallenge getChallengeEventByNumber(final int n) {
|
private QuestChallenge getChallengeEventByNumber(final int n) {
|
||||||
for (final QuestChallenge qc : ALL_CHALLENGES) {
|
for (final QuestChallenge qc : ALL_CHALLENGES) {
|
||||||
if (qc.getId() == n) {
|
if (qc.getId() == n) {
|
||||||
return qc;
|
return qc;
|
||||||
|
|||||||
12
src/main/java/forge/quest/data/QuestMode.java
Normal file
12
src/main/java/forge/quest/data/QuestMode.java
Normal file
@@ -0,0 +1,12 @@
|
|||||||
|
package forge.quest.data;
|
||||||
|
|
||||||
|
/**
|
||||||
|
* TODO: Write javadoc for this type.
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
public enum QuestMode {
|
||||||
|
// Do not apply checkstyle here, to maintain compatibility with old saves
|
||||||
|
Fantasy,
|
||||||
|
Classic,
|
||||||
|
Gauntlet
|
||||||
|
}
|
||||||
@@ -3,5 +3,6 @@ package forge.quest.data;
|
|||||||
public enum QuestStartPool {
|
public enum QuestStartPool {
|
||||||
COMPLETE,
|
COMPLETE,
|
||||||
STANDARD,
|
STANDARD,
|
||||||
|
Extended,
|
||||||
PRECON
|
PRECON
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -44,7 +44,7 @@ public class QuestUtil {
|
|||||||
* a {@link forge.quest.data.QuestData} object.
|
* a {@link forge.quest.data.QuestData} object.
|
||||||
* @return a {@link forge.CardList} object.
|
* @return a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
public static CardList getComputerStartingCards(final QuestData qd) {
|
public static CardList getComputerStartingCards() {
|
||||||
return new CardList();
|
return new CardList();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -60,7 +60,7 @@ public class QuestUtil {
|
|||||||
* a {@link forge.quest.data.QuestEvent} object.
|
* a {@link forge.quest.data.QuestEvent} object.
|
||||||
* @return a {@link forge.CardList} object.
|
* @return a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
public static CardList getComputerStartingCards(final QuestData qd, final QuestEvent qe) {
|
public static CardList getComputerStartingCards(final QuestEvent qe) {
|
||||||
final CardList list = new CardList();
|
final CardList list = new CardList();
|
||||||
|
|
||||||
if (qe.getEventType().equals("challenge")) {
|
if (qe.getEventType().equals("challenge")) {
|
||||||
@@ -84,7 +84,7 @@ public class QuestUtil {
|
|||||||
* a {@link forge.quest.data.QuestData} object.
|
* a {@link forge.quest.data.QuestData} object.
|
||||||
* @return a {@link forge.CardList} object.
|
* @return a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
public static CardList getHumanStartingCards(final QuestData qd) {
|
public static CardList getHumanStartingCards(final QuestAssets qd) {
|
||||||
final CardList list = new CardList();
|
final CardList list = new CardList();
|
||||||
|
|
||||||
if (qd.getPetManager().shouldPetBeUsed()) {
|
if (qd.getPetManager().shouldPetBeUsed()) {
|
||||||
@@ -111,8 +111,8 @@ public class QuestUtil {
|
|||||||
* a {@link forge.quest.data.QuestEvent} object.
|
* a {@link forge.quest.data.QuestEvent} object.
|
||||||
* @return a {@link forge.CardList} object.
|
* @return a {@link forge.CardList} object.
|
||||||
*/
|
*/
|
||||||
public static CardList getHumanStartingCards(final QuestData qd, final QuestEvent qe) {
|
public static CardList getHumanStartingCards(final QuestAssets qa, final QuestEvent qe) {
|
||||||
final CardList list = QuestUtil.getHumanStartingCards(qd);
|
final CardList list = QuestUtil.getHumanStartingCards(qa);
|
||||||
|
|
||||||
if (qe.getEventType().equals("challenge")) {
|
if (qe.getEventType().equals("challenge")) {
|
||||||
final List<String> extras = ((QuestChallenge) qe).getHumanExtraCards();
|
final List<String> extras = ((QuestChallenge) qe).getHumanExtraCards();
|
||||||
|
|||||||
@@ -38,8 +38,9 @@ import java.util.Map.Entry;
|
|||||||
* created to decrease complexity of questData class
|
* created to decrease complexity of questData class
|
||||||
*/
|
*/
|
||||||
public final class QuestUtilCards {
|
public final class QuestUtilCards {
|
||||||
private final QuestData q;
|
private final QuestController qc;
|
||||||
private final QuestPreferences qpref;
|
private final QuestPreferences qpref;
|
||||||
|
private final QuestAssets qa;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Instantiates a new quest util cards.
|
* Instantiates a new quest util cards.
|
||||||
@@ -47,8 +48,9 @@ public final class QuestUtilCards {
|
|||||||
* @param qd
|
* @param qd
|
||||||
* the qd
|
* the qd
|
||||||
*/
|
*/
|
||||||
public QuestUtilCards(final QuestData qd) {
|
public QuestUtilCards(final QuestController qd) {
|
||||||
this.q = qd;
|
this.qc = qd;
|
||||||
|
this.qa = qc.getAssets();
|
||||||
this.qpref = Singletons.getModel().getQuestPreferences();
|
this.qpref = Singletons.getModel().getQuestPreferences();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -121,10 +123,10 @@ public final class QuestUtilCards {
|
|||||||
* the card
|
* the card
|
||||||
*/
|
*/
|
||||||
public void addSingleCard(final CardPrinted card) {
|
public void addSingleCard(final CardPrinted card) {
|
||||||
this.q.getCardPool().add(card);
|
this.qa.getCardPool().add(card);
|
||||||
|
|
||||||
// register card into that list so that it would appear as a new one.
|
// register card into that list so that it would appear as a new one.
|
||||||
this.q.getNewCardList().add(card);
|
this.qa.getNewCardList().add(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
private static final Predicate<CardPrinted> RARE_PREDICATE = CardPrinted.Predicates.Presets.IS_RARE_OR_MYTHIC;
|
private static final Predicate<CardPrinted> RARE_PREDICATE = CardPrinted.Predicates.Presets.IS_RARE_OR_MYTHIC;
|
||||||
@@ -178,9 +180,9 @@ public final class QuestUtilCards {
|
|||||||
* the value
|
* the value
|
||||||
*/
|
*/
|
||||||
public void buyCard(final CardPrinted card, final int value) {
|
public void buyCard(final CardPrinted card, final int value) {
|
||||||
if (this.q.getCredits() >= value) {
|
if (this.qa.getCredits() >= value) {
|
||||||
this.q.setCredits(this.q.getCredits() - value);
|
this.qa.setCredits(this.qa.getCredits() - value);
|
||||||
this.q.getShopList().remove(card);
|
this.qa.getShopList().remove(card);
|
||||||
this.addSingleCard(card);
|
this.addSingleCard(card);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -194,9 +196,8 @@ public final class QuestUtilCards {
|
|||||||
* the value
|
* the value
|
||||||
*/
|
*/
|
||||||
public void buyPack(final OpenablePack booster, final int value) {
|
public void buyPack(final OpenablePack booster, final int value) {
|
||||||
if (this.q.getCredits() >= value) {
|
if (this.qa.getCredits() >= value) {
|
||||||
this.q.setCredits(this.q.getCredits() - value);
|
this.qa.setCredits(this.qa.getCredits() - value);
|
||||||
this.q.getShopList().remove(booster);
|
|
||||||
this.addAllCards(booster.getCards());
|
this.addAllCards(booster.getCards());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -210,15 +211,15 @@ public final class QuestUtilCards {
|
|||||||
* the value
|
* the value
|
||||||
*/
|
*/
|
||||||
public void buyPreconDeck(final PreconDeck precon, final int value) {
|
public void buyPreconDeck(final PreconDeck precon, final int value) {
|
||||||
if (this.q.getCredits() >= value) {
|
if (this.qa.getCredits() >= value) {
|
||||||
this.q.setCredits(this.q.getCredits() - value);
|
this.qa.setCredits(this.qa.getCredits() - value);
|
||||||
this.q.getShopList().remove(precon);
|
this.qa.getShopList().remove(precon);
|
||||||
addPreconDeck(precon);
|
addPreconDeck(precon);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void addPreconDeck(PreconDeck precon) {
|
void addPreconDeck(PreconDeck precon) {
|
||||||
this.q.getMyDecks().add(precon.getDeck());
|
this.qc.getMyDecks().add(precon.getDeck());
|
||||||
this.addAllCards(precon.getDeck().getMain().toFlatList());
|
this.addAllCards(precon.getDeck().getMain().toFlatList());
|
||||||
this.addAllCards(precon.getDeck().getSideboard().toFlatList());
|
this.addAllCards(precon.getDeck().getSideboard().toFlatList());
|
||||||
}
|
}
|
||||||
@@ -247,17 +248,17 @@ public final class QuestUtilCards {
|
|||||||
*/
|
*/
|
||||||
public void sellCard(final CardPrinted card, final int price, final boolean addToShop) {
|
public void sellCard(final CardPrinted card, final int price, final boolean addToShop) {
|
||||||
if (price > 0) {
|
if (price > 0) {
|
||||||
this.q.setCredits(this.q.getCredits() + price);
|
this.qa.setCredits(this.qa.getCredits() + price);
|
||||||
}
|
}
|
||||||
this.q.getCardPool().remove(card);
|
this.qa.getCardPool().remove(card);
|
||||||
if (addToShop) {
|
if (addToShop) {
|
||||||
this.q.getShopList().add(card);
|
this.qa.getShopList().add(card);
|
||||||
}
|
}
|
||||||
|
|
||||||
// remove card being sold from all decks
|
// remove card being sold from all decks
|
||||||
final int leftInPool = this.q.getCardPool().count(card);
|
final int leftInPool = this.qa.getCardPool().count(card);
|
||||||
// remove sold cards from all decks:
|
// remove sold cards from all decks:
|
||||||
for (final Deck deck : this.q.getMyDecks()) {
|
for (final Deck deck : this.qc.getMyDecks()) {
|
||||||
deck.getMain().remove(card, deck.getMain().count(card) - leftInPool);
|
deck.getMain().remove(card, deck.getMain().count(card) - leftInPool);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -266,8 +267,8 @@ public final class QuestUtilCards {
|
|||||||
* Clear shop list.
|
* Clear shop list.
|
||||||
*/
|
*/
|
||||||
public void clearShopList() {
|
public void clearShopList() {
|
||||||
if (null != this.q.getShopList()) {
|
if (null != this.qa.getShopList()) {
|
||||||
this.q.getShopList().clear();
|
this.qa.getShopList().clear();
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -277,12 +278,12 @@ public final class QuestUtilCards {
|
|||||||
* @return the sell mutliplier
|
* @return the sell mutliplier
|
||||||
*/
|
*/
|
||||||
public double getSellMutliplier() {
|
public double getSellMutliplier() {
|
||||||
double multi = 0.20 + (0.001 * this.q.getWin());
|
double multi = 0.20 + (0.001 * this.qc.getAchievements().getWin());
|
||||||
if (multi > 0.6) {
|
if (multi > 0.6) {
|
||||||
multi = 0.6;
|
multi = 0.6;
|
||||||
}
|
}
|
||||||
|
|
||||||
final int lvlEstates = this.q.isFantasy() ? this.q.getInventory().getItemLevel("Estates") : 0;
|
final int lvlEstates = this.qc.getMode() == QuestMode.Fantasy ? this.qa.getInventory().getItemLevel("Estates") : 0;
|
||||||
switch (lvlEstates) {
|
switch (lvlEstates) {
|
||||||
case 1:
|
case 1:
|
||||||
multi += 0.01;
|
multi += 0.01;
|
||||||
@@ -306,7 +307,7 @@ public final class QuestUtilCards {
|
|||||||
* @return the sell price limit
|
* @return the sell price limit
|
||||||
*/
|
*/
|
||||||
public int getSellPriceLimit() {
|
public int getSellPriceLimit() {
|
||||||
return this.q.getWin() <= 50 ? 1000 : Integer.MAX_VALUE;
|
return this.qc.getAchievements().getWin() <= 50 ? 1000 : Integer.MAX_VALUE;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -340,7 +341,7 @@ public final class QuestUtilCards {
|
|||||||
final int rollD100 = MyRandom.getRandom().nextInt(100);
|
final int rollD100 = MyRandom.getRandom().nextInt(100);
|
||||||
final Predicate<CardEdition> filter = rollD100 < 40 ? this.filterT2booster
|
final Predicate<CardEdition> filter = rollD100 < 40 ? this.filterT2booster
|
||||||
: (rollD100 < 75 ? this.filterExtButT2 : this.filterNotExt);
|
: (rollD100 < 75 ? this.filterExtButT2 : this.filterNotExt);
|
||||||
this.q.getShopList().addAllFlat(
|
this.qa.getShopList().addAllFlat(
|
||||||
filter.random(Singletons.getModel().getEditions(), 1, BoosterPack.FN_FROM_SET));
|
filter.random(Singletons.getModel().getEditions(), 1, BoosterPack.FN_FROM_SET));
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@@ -353,14 +354,14 @@ public final class QuestUtilCards {
|
|||||||
*/
|
*/
|
||||||
public void generateTournamentsInShop(final int count) {
|
public void generateTournamentsInShop(final int count) {
|
||||||
Predicate<CardEdition> hasTournament = CardEdition.Predicates.HAS_TOURNAMENT_PACK;
|
Predicate<CardEdition> hasTournament = CardEdition.Predicates.HAS_TOURNAMENT_PACK;
|
||||||
this.q.getShopList().addAllFlat(hasTournament.random(Singletons.getModel().getEditions(),
|
this.qa.getShopList().addAllFlat(hasTournament.random(Singletons.getModel().getEditions(),
|
||||||
count,
|
count,
|
||||||
TournamentPack.FN_FROM_SET));
|
TournamentPack.FN_FROM_SET));
|
||||||
}
|
}
|
||||||
|
|
||||||
public void generateFatPacksInShop(final int count) {
|
public void generateFatPacksInShop(final int count) {
|
||||||
Predicate<CardEdition> hasPack = CardEdition.Predicates.HAS_FAT_PACK;
|
Predicate<CardEdition> hasPack = CardEdition.Predicates.HAS_FAT_PACK;
|
||||||
this.q.getShopList().addAllFlat(hasPack.random(Singletons.getModel().getEditions(), count, FatPack.FN_FROM_SET));
|
this.qa.getShopList().addAllFlat(hasPack.random(Singletons.getModel().getEditions(), count, FatPack.FN_FROM_SET));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -371,12 +372,12 @@ public final class QuestUtilCards {
|
|||||||
*/
|
*/
|
||||||
public void generatePreconsInShop(final int count) {
|
public void generatePreconsInShop(final int count) {
|
||||||
final List<PreconDeck> meetRequirements = new ArrayList<PreconDeck>();
|
final List<PreconDeck> meetRequirements = new ArrayList<PreconDeck>();
|
||||||
for (final PreconDeck deck : QuestData.getPrecons()) {
|
for (final PreconDeck deck : QuestController.getPrecons()) {
|
||||||
if (deck.getRecommendedDeals().meetsRequiremnts(this.q)) {
|
if (deck.getRecommendedDeals().meetsRequiremnts(this.qc.getAchievements())) {
|
||||||
meetRequirements.add(deck);
|
meetRequirements.add(deck);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.q.getShopList().addAllFlat(Predicate.getTrue(PreconDeck.class).random(meetRequirements, count));
|
this.qa.getShopList().addAllFlat(Predicate.getTrue(PreconDeck.class).random(meetRequirements, count));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -385,6 +386,8 @@ public final class QuestUtilCards {
|
|||||||
public void generateCardsInShop() {
|
public void generateCardsInShop() {
|
||||||
final BoosterGenerator pack = new BoosterGenerator(CardDb.instance().getAllCards());
|
final BoosterGenerator pack = new BoosterGenerator(CardDb.instance().getAllCards());
|
||||||
|
|
||||||
|
int nLevel = this.qc.getAchievements().getLevel();
|
||||||
|
|
||||||
// Preferences
|
// Preferences
|
||||||
final int startPacks = this.qpref.getPreferenceInt(QPref.SHOP_STARTING_PACKS);
|
final int startPacks = this.qpref.getPreferenceInt(QPref.SHOP_STARTING_PACKS);
|
||||||
final int winsForPack = this.qpref.getPreferenceInt(QPref.SHOP_WINS_FOR_ADDITIONAL_PACK);
|
final int winsForPack = this.qpref.getPreferenceInt(QPref.SHOP_WINS_FOR_ADDITIONAL_PACK);
|
||||||
@@ -393,20 +396,20 @@ public final class QuestUtilCards {
|
|||||||
final int uncommon = this.qpref.getPreferenceInt(QPref.SHOP_SINGLES_UNCOMMON);
|
final int uncommon = this.qpref.getPreferenceInt(QPref.SHOP_SINGLES_UNCOMMON);
|
||||||
final int rare = this.qpref.getPreferenceInt(QPref.SHOP_SINGLES_RARE);
|
final int rare = this.qpref.getPreferenceInt(QPref.SHOP_SINGLES_RARE);
|
||||||
|
|
||||||
final int levelPacks = this.q.getLevel() > 0 ? startPacks / this.q.getLevel() : startPacks;
|
final int levelPacks = nLevel > 0 ? startPacks / nLevel : startPacks;
|
||||||
final int winPacks = this.q.getWin() / winsForPack;
|
final int winPacks = this.qc.getAchievements().getWin() / winsForPack;
|
||||||
final int totalPacks = Math.min(levelPacks + winPacks, maxPacks);
|
final int totalPacks = Math.min(levelPacks + winPacks, maxPacks);
|
||||||
|
|
||||||
this.q.getShopList().clear();
|
this.qa.getShopList().clear();
|
||||||
for (int i = 0; i < totalPacks; i++) {
|
for (int i = 0; i < totalPacks; i++) {
|
||||||
this.q.getShopList().addAllFlat(pack.getBoosterPack(common, uncommon, rare, 0, 0, 0, 0, 0, 0));
|
this.qa.getShopList().addAllFlat(pack.getBoosterPack(common, uncommon, rare, 0, 0, 0, 0, 0, 0));
|
||||||
}
|
}
|
||||||
|
|
||||||
this.generateBoostersInShop(totalPacks);
|
this.generateBoostersInShop(totalPacks);
|
||||||
this.generatePreconsInShop(totalPacks);
|
this.generatePreconsInShop(totalPacks);
|
||||||
this.generateTournamentsInShop(totalPacks);
|
this.generateTournamentsInShop(totalPacks);
|
||||||
this.generateFatPacksInShop(totalPacks);
|
this.generateFatPacksInShop(totalPacks);
|
||||||
this.q.getShopList().addAll(QuestUtilCards.generateBasicLands(10, 5));
|
this.qa.getShopList().addAll(QuestUtilCards.generateBasicLands(10, 5));
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -415,7 +418,7 @@ public final class QuestUtilCards {
|
|||||||
* @return the cardpool
|
* @return the cardpool
|
||||||
*/
|
*/
|
||||||
public ItemPool<CardPrinted> getCardpool() {
|
public ItemPool<CardPrinted> getCardpool() {
|
||||||
return this.q.getCardPool();
|
return this.qa.getCardPool();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -424,10 +427,10 @@ public final class QuestUtilCards {
|
|||||||
* @return the shop list
|
* @return the shop list
|
||||||
*/
|
*/
|
||||||
public ItemPoolView<InventoryItem> getShopList() {
|
public ItemPoolView<InventoryItem> getShopList() {
|
||||||
if (this.q.getShopList().isEmpty()) {
|
if (this.qa.getShopList().isEmpty()) {
|
||||||
this.generateCardsInShop();
|
this.generateCardsInShop();
|
||||||
}
|
}
|
||||||
return this.q.getShopList();
|
return this.qa.getShopList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -436,14 +439,14 @@ public final class QuestUtilCards {
|
|||||||
* @return the new cards
|
* @return the new cards
|
||||||
*/
|
*/
|
||||||
public ItemPoolView<InventoryItem> getNewCards() {
|
public ItemPoolView<InventoryItem> getNewCards() {
|
||||||
return this.q.getNewCardList();
|
return this.qa.getNewCardList();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Reset new list.
|
* Reset new list.
|
||||||
*/
|
*/
|
||||||
public void resetNewList() {
|
public void resetNewList() {
|
||||||
this.q.getNewCardList().clear();
|
this.qa.getNewCardList().clear();
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -475,7 +478,7 @@ public final class QuestUtilCards {
|
|||||||
private final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnNewCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
private final Lambda1<Comparable, Entry<InventoryItem, Integer>> fnNewCompare = new Lambda1<Comparable, Entry<InventoryItem, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
public Comparable apply(final Entry<InventoryItem, Integer> from) {
|
||||||
return QuestUtilCards.this.q.getNewCardList().contains(from.getKey()) ? Integer.valueOf(1) : Integer
|
return QuestUtilCards.this.qa.getNewCardList().contains(from.getKey()) ? Integer.valueOf(1) : Integer
|
||||||
.valueOf(0);
|
.valueOf(0);
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
@@ -484,7 +487,7 @@ public final class QuestUtilCards {
|
|||||||
private final Lambda1<Object, Entry<InventoryItem, Integer>> fnNewGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
private final Lambda1<Object, Entry<InventoryItem, Integer>> fnNewGet = new Lambda1<Object, Entry<InventoryItem, Integer>>() {
|
||||||
@Override
|
@Override
|
||||||
public Object apply(final Entry<InventoryItem, Integer> from) {
|
public Object apply(final Entry<InventoryItem, Integer> from) {
|
||||||
return QuestUtilCards.this.q.getNewCardList().contains(from.getKey()) ? "NEW" : "";
|
return QuestUtilCards.this.qa.getNewCardList().contains(from.getKey()) ? "NEW" : "";
|
||||||
}
|
}
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,13 +19,15 @@ package forge.quest.data.bazaar;
|
|||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
|
import forge.quest.data.QuestAssets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* This interface defines a thing that can be sold at the Bazaar.
|
* This interface defines a thing that can be sold at the Bazaar.
|
||||||
*
|
*
|
||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public interface QuestStallPurchasable extends Comparable<Object> {
|
public interface IQuestStallPurchasable extends Comparable<Object> {
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
* getPurchaseName.
|
* getPurchaseName.
|
||||||
@@ -60,7 +62,7 @@ public interface QuestStallPurchasable extends Comparable<Object> {
|
|||||||
*
|
*
|
||||||
* @return the buying cost of the item in credits
|
* @return the buying cost of the item in credits
|
||||||
*/
|
*/
|
||||||
int getBuyingPrice();
|
int getBuyingPrice(QuestAssets qA);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -69,7 +71,7 @@ public interface QuestStallPurchasable extends Comparable<Object> {
|
|||||||
*
|
*
|
||||||
* @return the selling cost of the item in credits
|
* @return the selling cost of the item in credits
|
||||||
*/
|
*/
|
||||||
int getSellingPrice();
|
int getSellingPrice(QuestAssets qA);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Returns if the item is available for purchase;.
|
* Returns if the item is available for purchase;.
|
||||||
@@ -78,12 +80,13 @@ public interface QuestStallPurchasable extends Comparable<Object> {
|
|||||||
* <code>false</code> if the item should not be displayed in store
|
* <code>false</code> if the item should not be displayed in store
|
||||||
* since, for example, prerequisites are not met
|
* since, for example, prerequisites are not met
|
||||||
*/
|
*/
|
||||||
boolean isAvailableForPurchase();
|
boolean isAvailableForPurchase(QuestAssets questAssets);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Executed when the item is bought.
|
* Executed when the item is bought.
|
||||||
|
* @param questAssets
|
||||||
*/
|
*/
|
||||||
void onPurchase();
|
void onPurchase(QuestAssets questAssets);
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -26,6 +26,7 @@ import java.util.TreeSet;
|
|||||||
|
|
||||||
import forge.AllZone;
|
import forge.AllZone;
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
|
import forge.quest.data.QuestAssets;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -40,7 +41,7 @@ public class QuestStallManager {
|
|||||||
/** Constant <code>stalls</code>. */
|
/** Constant <code>stalls</code>. */
|
||||||
private static Map<String, QuestStallDefinition> stalls;
|
private static Map<String, QuestStallDefinition> stalls;
|
||||||
/** Constant <code>items</code>. */
|
/** Constant <code>items</code>. */
|
||||||
private static Map<String, SortedSet<QuestStallPurchasable>> items;
|
private static Map<String, SortedSet<IQuestStallPurchasable>> items;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Master method for assembling stall data: merchant...
|
* Master method for assembling stall data: merchant...
|
||||||
@@ -109,18 +110,19 @@ public class QuestStallManager {
|
|||||||
* and maps to appropriate merchant.
|
* and maps to appropriate merchant.
|
||||||
*/
|
*/
|
||||||
public static void buildItems() {
|
public static void buildItems() {
|
||||||
final SortedSet<QuestStallPurchasable> itemSet = new TreeSet<QuestStallPurchasable>();
|
final SortedSet<IQuestStallPurchasable> itemSet = new TreeSet<IQuestStallPurchasable>();
|
||||||
|
|
||||||
itemSet.addAll(AllZone.getQuestData().getInventory().getItems());
|
final QuestAssets qA = AllZone.getQuest().getAssets();
|
||||||
itemSet.addAll(AllZone.getQuestData().getPetManager().getPetsAndPlants());
|
itemSet.addAll(qA.getInventory().getItems());
|
||||||
|
itemSet.addAll(qA.getPetManager().getPetsAndPlants());
|
||||||
|
|
||||||
QuestStallManager.items = new HashMap<String, SortedSet<QuestStallPurchasable>>();
|
QuestStallManager.items = new HashMap<String, SortedSet<IQuestStallPurchasable>>();
|
||||||
|
|
||||||
for (final String stallName : QuestStallManager.getStallNames()) {
|
for (final String stallName : QuestStallManager.getStallNames()) {
|
||||||
QuestStallManager.items.put(stallName, new TreeSet<QuestStallPurchasable>());
|
QuestStallManager.items.put(stallName, new TreeSet<IQuestStallPurchasable>());
|
||||||
}
|
}
|
||||||
|
|
||||||
for (final QuestStallPurchasable purchasable : itemSet) {
|
for (final IQuestStallPurchasable purchasable : itemSet) {
|
||||||
QuestStallManager.items.get(purchasable.getStallName()).add(purchasable);
|
QuestStallManager.items.get(purchasable.getStallName()).add(purchasable);
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -132,13 +134,14 @@ public class QuestStallManager {
|
|||||||
* @param stallName   {@link java.lang.String}
|
* @param stallName   {@link java.lang.String}
|
||||||
* @return {@link java.util.List}.
|
* @return {@link java.util.List}.
|
||||||
*/
|
*/
|
||||||
public static List<QuestStallPurchasable> getItems(final String stallName) {
|
public static List<IQuestStallPurchasable> getItems(final String stallName) {
|
||||||
QuestStallManager.buildItems();
|
QuestStallManager.buildItems();
|
||||||
|
|
||||||
final List<QuestStallPurchasable> ret = new ArrayList<QuestStallPurchasable>();
|
final List<IQuestStallPurchasable> ret = new ArrayList<IQuestStallPurchasable>();
|
||||||
|
|
||||||
for (final QuestStallPurchasable purchasable : QuestStallManager.items.get(stallName)) {
|
QuestAssets qA = AllZone.getQuest().getAssets();
|
||||||
if (purchasable.isAvailableForPurchase()) {
|
for (final IQuestStallPurchasable purchasable : QuestStallManager.items.get(stallName)) {
|
||||||
|
if (purchasable.isAvailableForPurchase(qA)) {
|
||||||
ret.add(purchasable);
|
ret.add(purchasable);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ package forge.quest.data.item;
|
|||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
import forge.AllZone;
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.bazaar.QuestStallPurchasable;
|
import forge.quest.data.bazaar.IQuestStallPurchasable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -30,7 +30,7 @@ import forge.quest.data.bazaar.QuestStallPurchasable;
|
|||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public abstract class QuestItemAbstract implements QuestStallPurchasable {
|
public abstract class QuestItemAbstract implements IQuestStallPurchasable {
|
||||||
private int level = 0;
|
private int level = 0;
|
||||||
private final String name;
|
private final String name;
|
||||||
private final String shopName;
|
private final String shopName;
|
||||||
@@ -104,9 +104,9 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
|
|||||||
* This method will be invoked when an item is bought in a shop.
|
* This method will be invoked when an item is bought in a shop.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onPurchase() {
|
public void onPurchase(QuestAssets qA) {
|
||||||
final int currentLevel = AllZone.getQuestData().getInventory().getItemLevel(this.name);
|
final int currentLevel = qA.getInventory().getItemLevel(this.name);
|
||||||
AllZone.getQuestData().getInventory().setItemLevel(this.name, currentLevel + 1);
|
qA.getInventory().setItemLevel(this.name, currentLevel + 1);
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -117,8 +117,8 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailableForPurchase() {
|
public boolean isAvailableForPurchase(QuestAssets qA) {
|
||||||
return AllZone.getQuestData().getInventory().getItemLevel(this.name) < this.maxLevel;
|
return qA.getInventory().getItemLevel(this.name) < this.maxLevel;
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -188,16 +188,16 @@ public abstract class QuestItemAbstract implements QuestStallPurchasable {
|
|||||||
|
|
||||||
/** @return a int. */
|
/** @return a int. */
|
||||||
@Override
|
@Override
|
||||||
public abstract int getBuyingPrice();
|
public abstract int getBuyingPrice(QuestAssets qA);
|
||||||
|
|
||||||
/** @return a int. */
|
/** @return a int. */
|
||||||
@Override
|
@Override
|
||||||
public abstract int getSellingPrice();
|
public abstract int getSellingPrice(QuestAssets qA);
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final int compareTo(final Object o) {
|
public final int compareTo(final Object o) {
|
||||||
final QuestStallPurchasable q = (QuestStallPurchasable) o;
|
final IQuestStallPurchasable q = (IQuestStallPurchasable) o;
|
||||||
return this.getPurchaseName().compareTo(q.getPurchaseName());
|
return this.getPurchaseName().compareTo(q.getPurchaseName());
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ package forge.quest.data.item;
|
|||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
import forge.AllZone;
|
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.bazaar.QuestStallManager;
|
import forge.quest.data.bazaar.QuestStallManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -56,7 +56,7 @@ public class QuestItemElixir extends QuestItemAbstract {
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final int getBuyingPrice() {
|
public final int getBuyingPrice(QuestAssets qA) {
|
||||||
if (this.getLevel() < 5) {
|
if (this.getLevel() < 5) {
|
||||||
return 250;
|
return 250;
|
||||||
} else if (this.getLevel() < 10) {
|
} else if (this.getLevel() < 10) {
|
||||||
@@ -70,17 +70,17 @@ public class QuestItemElixir extends QuestItemAbstract {
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final int getSellingPrice() {
|
public final int getSellingPrice(QuestAssets qA) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final void onPurchase() {
|
public final void onPurchase(QuestAssets qA) {
|
||||||
super.onPurchase();
|
super.onPurchase(qA);
|
||||||
|
|
||||||
if (this.getLevel() <= this.getMaxLevel()) {
|
if (this.getLevel() <= this.getMaxLevel()) {
|
||||||
AllZone.getQuestData().addLife(1);
|
qA.addLife(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ package forge.quest.data.item;
|
|||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.bazaar.QuestStallManager;
|
import forge.quest.data.bazaar.QuestStallManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -58,7 +59,7 @@ public class QuestItemEstates extends QuestItemAbstract {
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final int getBuyingPrice() {
|
public final int getBuyingPrice(QuestAssets qA) {
|
||||||
if (this.getLevel() == 0) {
|
if (this.getLevel() == 0) {
|
||||||
return 500;
|
return 500;
|
||||||
} else if (this.getLevel() == 1) {
|
} else if (this.getLevel() == 1) {
|
||||||
@@ -70,7 +71,7 @@ public class QuestItemEstates extends QuestItemAbstract {
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final int getSellingPrice() {
|
public final int getSellingPrice(QuestAssets qA) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ package forge.quest.data.item;
|
|||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.bazaar.QuestStallManager;
|
import forge.quest.data.bazaar.QuestStallManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -55,13 +56,13 @@ public class QuestItemLuckyCoin extends QuestItemAbstract {
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final int getBuyingPrice() {
|
public final int getBuyingPrice(QuestAssets qA) {
|
||||||
return 2000;
|
return 2000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final int getSellingPrice() {
|
public final int getSellingPrice(QuestAssets qA) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ package forge.quest.data.item;
|
|||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.bazaar.QuestStallManager;
|
import forge.quest.data.bazaar.QuestStallManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -61,13 +62,13 @@ public class QuestItemMap extends QuestItemAbstract {
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final int getBuyingPrice() {
|
public final int getBuyingPrice(QuestAssets qA) {
|
||||||
return 2000;
|
return 2000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final int getSellingPrice() {
|
public final int getSellingPrice(QuestAssets qA) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -21,6 +21,7 @@ import javax.swing.ImageIcon;
|
|||||||
|
|
||||||
import forge.AllZone;
|
import forge.AllZone;
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.bazaar.QuestStallManager;
|
import forge.quest.data.bazaar.QuestStallManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -45,7 +46,7 @@ public class QuestItemPoundFlesh extends QuestItemAbstract {
|
|||||||
public final String getPurchaseDescription() {
|
public final String getPurchaseDescription() {
|
||||||
return "The Alchemist welcomes contributions to his famous Elixer.\n"
|
return "The Alchemist welcomes contributions to his famous Elixer.\n"
|
||||||
+ "But beware, you may build an immunity to its effects...\n"
|
+ "But beware, you may build an immunity to its effects...\n"
|
||||||
+ "\nEffect: Alchemist gives you " + getSellingPrice() + " credits."
|
+ "\nEffect: Alchemist gives you " + getSellingPrice(AllZone.getQuest().getAssets()) + " credits."
|
||||||
+ "\nEffect: Reduces maximum life by 1.";
|
+ "\nEffect: Reduces maximum life by 1.";
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -57,13 +58,13 @@ public class QuestItemPoundFlesh extends QuestItemAbstract {
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final int getBuyingPrice() {
|
public final int getBuyingPrice(QuestAssets qA) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
public final int getSellingPrice() {
|
public final int getSellingPrice(QuestAssets qA) {
|
||||||
if (AllZone.getQuestData().getLife() < 2) {
|
if (qA.getLife() < 2) {
|
||||||
return 0;
|
return 0;
|
||||||
} else if (this.getLevel() < 5) {
|
} else if (this.getLevel() < 5) {
|
||||||
return 250;
|
return 250;
|
||||||
@@ -76,10 +77,10 @@ public class QuestItemPoundFlesh extends QuestItemAbstract {
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final void onPurchase() {
|
public final void onPurchase(QuestAssets qA) {
|
||||||
if (AllZone.getQuestData().getLife() > 1) {
|
if (qA.getLife() > 1) {
|
||||||
super.onPurchase();
|
super.onPurchase(qA);
|
||||||
AllZone.getQuestData().removeLife(1);
|
qA.removeLife(1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -20,6 +20,7 @@ package forge.quest.data.item;
|
|||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.bazaar.QuestStallManager;
|
import forge.quest.data.bazaar.QuestStallManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -49,13 +50,13 @@ public class QuestItemSleight extends QuestItemAbstract {
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final int getBuyingPrice() {
|
public final int getBuyingPrice(QuestAssets qA) {
|
||||||
return 2000;
|
return 2000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final int getSellingPrice() {
|
public final int getSellingPrice(QuestAssets qA) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -19,8 +19,8 @@ package forge.quest.data.item;
|
|||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
import forge.AllZone;
|
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.bazaar.QuestStallManager;
|
import forge.quest.data.bazaar.QuestStallManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -68,20 +68,20 @@ public class QuestItemZeppelin extends QuestItemAbstract {
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final int getBuyingPrice() {
|
public final int getBuyingPrice(QuestAssets qA) {
|
||||||
return 5000;
|
return 5000;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final int getSellingPrice() {
|
public final int getSellingPrice(QuestAssets qA) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final boolean isAvailableForPurchase() {
|
public final boolean isAvailableForPurchase(QuestAssets qA) {
|
||||||
return super.isAvailableForPurchase() && AllZone.getQuestData().getInventory().hasItem("Map");
|
return super.isAvailableForPurchase(qA) && qA.getInventory().hasItem("Map");
|
||||||
}
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
|||||||
@@ -19,10 +19,10 @@ package forge.quest.data.pet;
|
|||||||
|
|
||||||
import javax.swing.ImageIcon;
|
import javax.swing.ImageIcon;
|
||||||
|
|
||||||
import forge.AllZone;
|
|
||||||
import forge.Card;
|
import forge.Card;
|
||||||
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.bazaar.QuestStallManager;
|
import forge.quest.data.bazaar.QuestStallManager;
|
||||||
import forge.quest.data.bazaar.QuestStallPurchasable;
|
import forge.quest.data.bazaar.IQuestStallPurchasable;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* <p>
|
* <p>
|
||||||
@@ -32,7 +32,7 @@ import forge.quest.data.bazaar.QuestStallPurchasable;
|
|||||||
* @author Forge
|
* @author Forge
|
||||||
* @version $Id$
|
* @version $Id$
|
||||||
*/
|
*/
|
||||||
public abstract class QuestPetAbstract implements QuestStallPurchasable {
|
public abstract class QuestPetAbstract implements IQuestStallPurchasable {
|
||||||
|
|
||||||
/** The level. */
|
/** The level. */
|
||||||
private int level;
|
private int level;
|
||||||
@@ -67,13 +67,13 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
|
|||||||
* @return a int.
|
* @return a int.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public final int getBuyingPrice() {
|
public final int getBuyingPrice(QuestAssets qA) {
|
||||||
return this.getAllUpgradePrices()[this.level];
|
return this.getAllUpgradePrices()[this.level];
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final int getSellingPrice() {
|
public final int getSellingPrice(QuestAssets qA) {
|
||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -293,8 +293,8 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
|
|||||||
* @return a boolean.
|
* @return a boolean.
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public boolean isAvailableForPurchase() {
|
public boolean isAvailableForPurchase(QuestAssets qA) {
|
||||||
final QuestPetAbstract pet = AllZone.getQuestData().getPetManager().getPet(this.name);
|
final QuestPetAbstract pet = qA.getPetManager().getPet(this.name);
|
||||||
if (pet == null) {
|
if (pet == null) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -307,7 +307,7 @@ public abstract class QuestPetAbstract implements QuestStallPurchasable {
|
|||||||
* </p>
|
* </p>
|
||||||
*/
|
*/
|
||||||
@Override
|
@Override
|
||||||
public void onPurchase() {
|
public void onPurchase(QuestAssets qA) {
|
||||||
AllZone.getQuestData().getPetManager().addPetLevel(this.name);
|
qA.getPetManager().addPetLevel(this.name);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -30,6 +30,7 @@ import forge.card.spellability.AbilityActivated;
|
|||||||
import forge.card.spellability.SpellAbility;
|
import forge.card.spellability.SpellAbility;
|
||||||
import forge.properties.ForgeProps;
|
import forge.properties.ForgeProps;
|
||||||
import forge.properties.NewConstants;
|
import forge.properties.NewConstants;
|
||||||
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.bazaar.QuestStallManager;
|
import forge.quest.data.bazaar.QuestStallManager;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -173,14 +174,14 @@ public class QuestPetPlant extends QuestPetAbstract {
|
|||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final void onPurchase() {
|
public final void onPurchase(QuestAssets qA) {
|
||||||
AllZone.getQuestData().getPetManager().addPlantLevel();
|
qA.getPetManager().addPlantLevel();
|
||||||
}
|
}
|
||||||
|
|
||||||
/** {@inheritDoc} */
|
/** {@inheritDoc} */
|
||||||
@Override
|
@Override
|
||||||
public final boolean isAvailableForPurchase() {
|
public final boolean isAvailableForPurchase(QuestAssets qA) {
|
||||||
final QuestPetPlant plant = (QuestPetPlant) AllZone.getQuestData().getPetManager().getPlant();
|
final QuestPetPlant plant = (QuestPetPlant) qA.getPetManager().getPlant();
|
||||||
|
|
||||||
return (plant == null) || (plant.getLevel() < plant.getMaxLevel());
|
return (plant == null) || (plant.getLevel() < plant.getMaxLevel());
|
||||||
}
|
}
|
||||||
|
|||||||
@@ -106,7 +106,7 @@ public enum ViewHomeUI {
|
|||||||
final File data = new File(dirQuests.getPath() + File.separator + questname);
|
final File data = new File(dirQuests.getPath() + File.separator + questname);
|
||||||
|
|
||||||
if (data.exists()) {
|
if (data.exists()) {
|
||||||
AllZone.setQuestData(QuestDataIO.loadData(data));
|
AllZone.getQuest().load(QuestDataIO.loadData(data));
|
||||||
}
|
}
|
||||||
//////////////////////////////
|
//////////////////////////////
|
||||||
|
|
||||||
|
|||||||
@@ -12,14 +12,15 @@ import forge.gui.toolbox.FLabel;
|
|||||||
import forge.gui.toolbox.FPanel;
|
import forge.gui.toolbox.FPanel;
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
import forge.gui.toolbox.FTextArea;
|
import forge.gui.toolbox.FTextArea;
|
||||||
import forge.quest.data.bazaar.QuestStallPurchasable;
|
import forge.quest.data.QuestAssets;
|
||||||
|
import forge.quest.data.bazaar.IQuestStallPurchasable;
|
||||||
|
|
||||||
/** An update-able panel instance representing a single item. */
|
/** An update-able panel instance representing a single item. */
|
||||||
@SuppressWarnings("serial")
|
@SuppressWarnings("serial")
|
||||||
public class ViewItem extends FPanel {
|
public class ViewItem extends FPanel {
|
||||||
private final FLabel lblIcon, lblName, lblPrice, btnPurchase;
|
private final FLabel lblIcon, lblName, lblPrice, btnPurchase;
|
||||||
private final FTextArea tarDesc;
|
private final FTextArea tarDesc;
|
||||||
private QuestStallPurchasable item;
|
private IQuestStallPurchasable item;
|
||||||
|
|
||||||
/** An update-able panel instance representing a single item. */
|
/** An update-able panel instance representing a single item. */
|
||||||
public ViewItem() {
|
public ViewItem() {
|
||||||
@@ -45,22 +46,23 @@ public class ViewItem extends FPanel {
|
|||||||
btnPurchase.setCommand(new Command() {
|
btnPurchase.setCommand(new Command() {
|
||||||
@Override
|
@Override
|
||||||
public void execute() {
|
public void execute() {
|
||||||
AllZone.getQuestData().subtractCredits(getItem().getBuyingPrice());
|
QuestAssets qA = AllZone.getQuest().getAssets();
|
||||||
AllZone.getQuestData().addCredits(getItem().getSellingPrice());
|
qA.subtractCredits(getItem().getBuyingPrice(qA));
|
||||||
getItem().onPurchase();
|
qA.addCredits(getItem().getSellingPrice(qA));
|
||||||
AllZone.getQuestData().saveData();
|
getItem().onPurchase(qA);
|
||||||
|
AllZone.getQuest().save();
|
||||||
Singletons.getView().getViewBazaar().refreshLastInstance();
|
Singletons.getView().getViewBazaar().refreshLastInstance();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @param i0   {@link forge.quest.data.bazaar.QuestStallPurchasable} */
|
/** @param i0   {@link forge.quest.data.bazaar.IQuestStallPurchasable} */
|
||||||
public void setItem(QuestStallPurchasable i0) {
|
public void setItem(IQuestStallPurchasable i0) {
|
||||||
this.item = i0;
|
this.item = i0;
|
||||||
}
|
}
|
||||||
|
|
||||||
/** @return {@link forge.quest.data.bazaar.QuestStallPurchasable} */
|
/** @return {@link forge.quest.data.bazaar.IQuestStallPurchasable} */
|
||||||
public QuestStallPurchasable getItem() {
|
public IQuestStallPurchasable getItem() {
|
||||||
return this.item;
|
return this.item;
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -69,12 +71,13 @@ public class ViewItem extends FPanel {
|
|||||||
SwingUtilities.invokeLater(new Runnable() {
|
SwingUtilities.invokeLater(new Runnable() {
|
||||||
@Override
|
@Override
|
||||||
public void run() {
|
public void run() {
|
||||||
|
QuestAssets qA = AllZone.getQuest().getAssets();
|
||||||
lblIcon.setIcon(getItem().getIcon());
|
lblIcon.setIcon(getItem().getIcon());
|
||||||
lblName.setText(getItem().getPurchaseName());
|
lblName.setText(getItem().getPurchaseName());
|
||||||
lblPrice.setText("Cost: " + String.valueOf(getItem().getBuyingPrice()) + " credits");
|
lblPrice.setText("Cost: " + String.valueOf(getItem().getBuyingPrice(qA)) + " credits");
|
||||||
tarDesc.setText(getItem().getPurchaseDescription());
|
tarDesc.setText(getItem().getPurchaseDescription());
|
||||||
|
|
||||||
if (AllZone.getQuestData().getCredits() < getItem().getBuyingPrice()) {
|
if (qA.getCredits() < getItem().getBuyingPrice(qA)) {
|
||||||
btnPurchase.setEnabled(false);
|
btnPurchase.setEnabled(false);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -35,9 +35,10 @@ import forge.control.bazaar.ControlStall;
|
|||||||
import forge.gui.toolbox.FLabel;
|
import forge.gui.toolbox.FLabel;
|
||||||
import forge.gui.toolbox.FScrollPane;
|
import forge.gui.toolbox.FScrollPane;
|
||||||
import forge.gui.toolbox.FSkin;
|
import forge.gui.toolbox.FSkin;
|
||||||
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.bazaar.QuestStallDefinition;
|
import forge.quest.data.bazaar.QuestStallDefinition;
|
||||||
import forge.quest.data.bazaar.QuestStallManager;
|
import forge.quest.data.bazaar.QuestStallManager;
|
||||||
import forge.quest.data.bazaar.QuestStallPurchasable;
|
import forge.quest.data.bazaar.IQuestStallPurchasable;
|
||||||
import forge.view.ViewBazaarUI;
|
import forge.view.ViewBazaarUI;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -143,13 +144,13 @@ public class ViewStall extends JPanel {
|
|||||||
* and creates new panels if necessary.
|
* and creates new panels if necessary.
|
||||||
*/
|
*/
|
||||||
public void updateStall() {
|
public void updateStall() {
|
||||||
if (AllZone.getQuestData() == null) { return; }
|
if (AllZone.getQuest().getAssets() == null) { return; }
|
||||||
|
|
||||||
|
QuestAssets qS = AllZone.getQuest().getAssets();
|
||||||
this.lblStats.setText(
|
this.lblStats.setText(
|
||||||
"Credits: " + AllZone.getQuestData().getCredits()
|
"Credits: " + qS.getCredits() + " Life: " + qS.getLife());
|
||||||
+ " Life: " + AllZone.getQuestData().getLife());
|
|
||||||
|
|
||||||
final List<QuestStallPurchasable> items =
|
final List<IQuestStallPurchasable> items =
|
||||||
QuestStallManager.getItems(stall.getName());
|
QuestStallManager.getItems(stall.getName());
|
||||||
|
|
||||||
lblStallName.setText(stall.getDisplayName());
|
lblStallName.setText(stall.getDisplayName());
|
||||||
|
|||||||
@@ -51,9 +51,11 @@ import forge.gui.toolbox.FSkin;
|
|||||||
import forge.item.CardPrinted;
|
import forge.item.CardPrinted;
|
||||||
import forge.model.FMatchState;
|
import forge.model.FMatchState;
|
||||||
import forge.properties.ForgePreferences.FPref;
|
import forge.properties.ForgePreferences.FPref;
|
||||||
|
import forge.quest.data.QuestAssets;
|
||||||
import forge.quest.data.QuestChallenge;
|
import forge.quest.data.QuestChallenge;
|
||||||
import forge.quest.data.QuestData;
|
import forge.quest.data.QuestController;
|
||||||
import forge.quest.data.QuestEvent;
|
import forge.quest.data.QuestEvent;
|
||||||
|
import forge.quest.data.QuestMode;
|
||||||
import forge.quest.data.QuestPreferences.QPref;
|
import forge.quest.data.QuestPreferences.QPref;
|
||||||
import forge.quest.data.QuestUtil;
|
import forge.quest.data.QuestUtil;
|
||||||
import forge.util.MyRandom;
|
import forge.util.MyRandom;
|
||||||
@@ -81,7 +83,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
|||||||
private static final String CONSTRAINTS_CARDS = "w 95%!, h 330px!, gap 0 0 0 20px";
|
private static final String CONSTRAINTS_CARDS = "w 95%!, h 330px!, gap 0 0 0 20px";
|
||||||
|
|
||||||
private final transient FMatchState matchState;
|
private final transient FMatchState matchState;
|
||||||
private final transient QuestData qData;
|
private final transient QuestController qData;
|
||||||
private final transient QuestEvent qEvent;
|
private final transient QuestEvent qEvent;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
@@ -93,7 +95,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
|||||||
super(view0);
|
super(view0);
|
||||||
this.view = view0;
|
this.view = view0;
|
||||||
matchState = Singletons.getModel().getMatchState();
|
matchState = Singletons.getModel().getMatchState();
|
||||||
qData = AllZone.getQuestData();
|
qData = AllZone.getQuest();
|
||||||
qEvent = qData.getCurrentEvent();
|
qEvent = qData.getCurrentEvent();
|
||||||
this.wonMatch = matchState.isMatchWonBy(AllZone.getHumanPlayer().getName());
|
this.wonMatch = matchState.isMatchWonBy(AllZone.getHumanPlayer().getName());
|
||||||
this.isAnte = Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE);
|
this.isAnte = Singletons.getModel().getPreferences().getPrefBoolean(FPref.UI_ANTE);
|
||||||
@@ -112,26 +114,27 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
|||||||
OverlayUtils.hideOverlay();
|
OverlayUtils.hideOverlay();
|
||||||
Singletons.getModel().getQuestPreferences().save();
|
Singletons.getModel().getQuestPreferences().save();
|
||||||
|
|
||||||
if (Constant.Quest.FANTASY_QUEST[0]) {
|
QuestAssets qa = qData.getAssets();
|
||||||
|
if (qData.getMode() == QuestMode.Fantasy) {
|
||||||
int extraLife = 0;
|
int extraLife = 0;
|
||||||
|
|
||||||
if (qEvent.getEventType().equals("challenge")) {
|
if (qEvent.getEventType().equals("challenge")) {
|
||||||
if (qData.getInventory().hasItem("Zeppelin")) {
|
if (qa.getInventory().hasItem("Zeppelin")) {
|
||||||
extraLife = 3;
|
extraLife = 3;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
final CardList humanList = QuestUtil.getHumanStartingCards(qData, qEvent);
|
final CardList humanList = QuestUtil.getHumanStartingCards(qa, qEvent);
|
||||||
final CardList computerList = QuestUtil.getComputerStartingCards(qData, qEvent);
|
final CardList computerList = QuestUtil.getComputerStartingCards(qEvent);
|
||||||
|
|
||||||
final int humanLife = qData.getLife() + extraLife;
|
final int humanLife = qa.getLife() + extraLife;
|
||||||
int computerLife = 20;
|
int computerLife = 20;
|
||||||
if (qEvent.getEventType().equals("challenge")) {
|
if (qEvent.getEventType().equals("challenge")) {
|
||||||
computerLife = ((QuestChallenge) qEvent).getAILife();
|
computerLife = ((QuestChallenge) qEvent).getAILife();
|
||||||
}
|
}
|
||||||
|
|
||||||
GameNew.newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0],
|
GameNew.newGame(Constant.Runtime.HUMAN_DECK[0], Constant.Runtime.COMPUTER_DECK[0],
|
||||||
humanList, computerList, humanLife, computerLife);
|
humanList, computerList, humanLife, computerLife, qEvent.getIconFilename());
|
||||||
} else {
|
} else {
|
||||||
super.startNextRound();
|
super.startNextRound();
|
||||||
}
|
}
|
||||||
@@ -165,7 +168,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
|||||||
final List<CardPrinted> antesPrinted = Singletons.getModel().getMatchState().addAnteLost(antes);
|
final List<CardPrinted> antesPrinted = Singletons.getModel().getMatchState().addAnteLost(antes);
|
||||||
for (final CardPrinted ante : antesPrinted) {
|
for (final CardPrinted ante : antesPrinted) {
|
||||||
//the last param here (should) determine if this is added to the Card Shop
|
//the last param here (should) determine if this is added to the Card Shop
|
||||||
AllZone.getQuestData().getCards().sellCard(ante, 0, false);
|
AllZone.getQuest().getCards().sellCard(ante, 0, false);
|
||||||
}
|
}
|
||||||
this.anteLost(antesPrinted);
|
this.anteLost(antesPrinted);
|
||||||
}
|
}
|
||||||
@@ -199,12 +202,12 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
|||||||
}
|
}
|
||||||
|
|
||||||
// Random rare for winning against a very hard deck
|
// Random rare for winning against a very hard deck
|
||||||
if (qData.getDifficultyIndex() == 4) {
|
if (qData.getAchievements().getDifficulty() == 4) {
|
||||||
this.awardRandomRare("You've won a random rare for winning against a very hard deck.");
|
this.awardRandomRare("You've won a random rare for winning against a very hard deck.");
|
||||||
}
|
}
|
||||||
|
|
||||||
// Award jackpot every 80 games won (currently 10 rares)
|
// Award jackpot every 80 games won (currently 10 rares)
|
||||||
final int wins = qData.getWin();
|
final int wins = qData.getAchievements().getWin();
|
||||||
if ((wins > 0) && ((wins % 80) == 0)) {
|
if ((wins > 0) && ((wins % 80) == 0)) {
|
||||||
this.awardJackpot();
|
this.awardJackpot();
|
||||||
}
|
}
|
||||||
@@ -216,8 +219,8 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
|||||||
|
|
||||||
// Win or lose, still a chance to win a booster, frequency set in
|
// Win or lose, still a chance to win a booster, frequency set in
|
||||||
// preferences
|
// preferences
|
||||||
final int outcome = this.wonMatch ? qData.getWin() : qData.getLost();
|
final int outcome = this.wonMatch ? qData.getAchievements().getWin() : qData.getAchievements().getLost();
|
||||||
if ((outcome % Singletons.getModel().getQuestPreferences().getPreferenceInt(QPref.WINS_BOOSTER, qData.getDifficultyIndex())) == 0) {
|
if ((outcome % Singletons.getModel().getQuestPreferences().getPreferenceInt(QPref.WINS_BOOSTER, qData.getAchievements().getDifficulty())) == 0) {
|
||||||
this.awardBooster();
|
this.awardBooster();
|
||||||
}
|
}
|
||||||
|
|
||||||
@@ -276,10 +279,10 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
|||||||
|
|
||||||
// Record win/loss in quest data
|
// Record win/loss in quest data
|
||||||
if (this.wonMatch) {
|
if (this.wonMatch) {
|
||||||
qData.addWin();
|
qData.getAchievements().addWin();
|
||||||
} else {
|
} else {
|
||||||
qData.addLost();
|
qData.getAchievements().addLost();
|
||||||
qData.subtractCredits(x);
|
qData.getAssets().subtractCredits(x);
|
||||||
}
|
}
|
||||||
|
|
||||||
qData.getCards().clearShopList();
|
qData.getCards().clearShopList();
|
||||||
@@ -293,7 +296,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
|||||||
CSubmenuChallenges.SINGLETON_INSTANCE.update();
|
CSubmenuChallenges.SINGLETON_INSTANCE.update();
|
||||||
|
|
||||||
qData.setCurrentEvent(null);
|
qData.setCurrentEvent(null);
|
||||||
qData.saveData();
|
qData.save();
|
||||||
Singletons.getModel().getQuestPreferences().save();
|
Singletons.getModel().getQuestPreferences().save();
|
||||||
Singletons.getModel().savePrefs();
|
Singletons.getModel().savePrefs();
|
||||||
|
|
||||||
@@ -338,7 +341,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
|||||||
|
|
||||||
credBase += (int) ((base * multiplier)
|
credBase += (int) ((base * multiplier)
|
||||||
+ (Double.parseDouble(Singletons.getModel().getQuestPreferences().getPreference(QPref.REWARDS_WINS_MULTIPLIER))
|
+ (Double.parseDouble(Singletons.getModel().getQuestPreferences().getPreference(QPref.REWARDS_WINS_MULTIPLIER))
|
||||||
* qData.getWin()));
|
* qData.getAchievements().getWin()));
|
||||||
|
|
||||||
sb.append(diff + " opponent: " + credBase + " credits.<br>");
|
sb.append(diff + " opponent: " + credBase + " credits.<br>");
|
||||||
// Gameplay bonuses (for each game win)
|
// Gameplay bonuses (for each game win)
|
||||||
@@ -421,7 +424,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
|||||||
// Estates bonus
|
// Estates bonus
|
||||||
credTotal = credBase + credGameplay + credUndefeated;
|
credTotal = credBase + credGameplay + credUndefeated;
|
||||||
double estateValue = 0;
|
double estateValue = 0;
|
||||||
switch (qData.getInventory().getItemLevel("Estates")) {
|
switch (qData.getAssets().getInventory().getItemLevel("Estates")) {
|
||||||
case 1:
|
case 1:
|
||||||
estateValue = .1;
|
estateValue = .1;
|
||||||
break;
|
break;
|
||||||
@@ -459,7 +462,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
|||||||
|
|
||||||
sb.append(String.format("%s <b>%d credits</b> in total.</h3>", congrats, credTotal));
|
sb.append(String.format("%s <b>%d credits</b> in total.</h3>", congrats, credTotal));
|
||||||
sb.append("</body></html>");
|
sb.append("</body></html>");
|
||||||
qData.addCredits(credTotal);
|
qData.getAssets().addCredits(credTotal);
|
||||||
|
|
||||||
// Generate Swing components and attach.
|
// Generate Swing components and attach.
|
||||||
this.icoTemp = GuiUtils.getResizedIcon(FSkin.getIcon(FSkin.QuestIcons.ICO_GOLD), 0.5);
|
this.icoTemp = GuiUtils.getResizedIcon(FSkin.getIcon(FSkin.QuestIcons.ICO_GOLD), 0.5);
|
||||||
@@ -560,12 +563,12 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
|||||||
*/
|
*/
|
||||||
private void awardChallengeWin() {
|
private void awardChallengeWin() {
|
||||||
if (!((QuestChallenge) qEvent).getRepeatable()) {
|
if (!((QuestChallenge) qEvent).getRepeatable()) {
|
||||||
qData.addCompletedChallenge(((QuestChallenge) qEvent).getId());
|
qData.getAchievements().addCompletedChallenge(((QuestChallenge) qEvent).getId());
|
||||||
}
|
}
|
||||||
|
|
||||||
// Note: challenge only registers as "played" if it's won.
|
// Note: challenge only registers as "played" if it's won.
|
||||||
// This doesn't seem right, but it's easy to fix. Doublestrike 01-10-11
|
// This doesn't seem right, but it's easy to fix. Doublestrike 01-10-11
|
||||||
qData.addChallengesPlayed();
|
qData.getAchievements().addChallengesPlayed();
|
||||||
|
|
||||||
final List<CardPrinted> cardsWon = ((QuestChallenge) qEvent).getCardRewardList();
|
final List<CardPrinted> cardsWon = ((QuestChallenge) qEvent).getCardRewardList();
|
||||||
final long questRewardCredits = ((QuestChallenge) qEvent).getCreditsReward();
|
final long questRewardCredits = ((QuestChallenge) qEvent).getCreditsReward();
|
||||||
@@ -574,7 +577,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
|||||||
sb.append("<html>Challenge completed.<br><br>");
|
sb.append("<html>Challenge completed.<br><br>");
|
||||||
sb.append("Challenge bounty: <b>" + questRewardCredits + " credits.</b></html>");
|
sb.append("Challenge bounty: <b>" + questRewardCredits + " credits.</b></html>");
|
||||||
|
|
||||||
qData.addCredits(questRewardCredits);
|
qData.getAssets().addCredits(questRewardCredits);
|
||||||
|
|
||||||
// Generate Swing components and attach.
|
// Generate Swing components and attach.
|
||||||
this.icoTemp = GuiUtils.getResizedIcon(FSkin.getIcon(FSkin.QuestIcons.ICO_BOX), 0.5);
|
this.icoTemp = GuiUtils.getResizedIcon(FSkin.getIcon(FSkin.QuestIcons.ICO_BOX), 0.5);
|
||||||
@@ -624,7 +627,7 @@ public class QuestWinLoseHandler extends ControlWinLose {
|
|||||||
* @return boolean
|
* @return boolean
|
||||||
*/
|
*/
|
||||||
private boolean getLuckyCoinResult() {
|
private boolean getLuckyCoinResult() {
|
||||||
final boolean hasCoin = qData.getInventory().getItemLevel("Lucky Coin") >= 1;
|
final boolean hasCoin = qData.getAssets().getInventory().getItemLevel("Lucky Coin") >= 1;
|
||||||
|
|
||||||
return MyRandom.getRandom().nextFloat() <= (hasCoin ? 0.65f : 0.5f);
|
return MyRandom.getRandom().nextFloat() <= (hasCoin ? 0.65f : 0.5f);
|
||||||
}
|
}
|
||||||
|
|||||||
Reference in New Issue
Block a user