Deprecated old QuestData, updated all references to use the new QuestData structure

Refactored pets, all pet logic decoupled from the UI. This should make adding/changing pets much easier.
This commit is contained in:
jendave
2011-08-06 17:29:03 +00:00
parent 26a2cf7757
commit e9594c88b9
43 changed files with 10801 additions and 11545 deletions

28
.gitattributes vendored
View File

@@ -7256,7 +7256,7 @@ src/forge/GUI_DeckAnalysis.java -text svneol=native#text/plain
src/forge/GUI_Filter.java -text svneol=native#text/plain
src/forge/GUI_ImportPicture.java -text svneol=native#text/plain
src/forge/GUI_Quest_Filter.java -text svneol=native#text/plain
src/forge/GameAction.java -text svneol=native#text/plain
src/forge/GameAction.java svneol=native#text/plain
src/forge/GameActionUtil.java -text svneol=native#text/plain
src/forge/GameInfo.java -text svneol=native#text/plain
src/forge/Generate2ColorDeck.java -text svneol=native#text/plain
@@ -7268,7 +7268,7 @@ src/forge/GenerateSealedDeck.java svneol=native#text/plain
src/forge/GenerateThemeDeck.java -text svneol=native#text/plain
src/forge/GuiDisplay.java svneol=native#text/plain
src/forge/GuiDisplay2.java svneol=native#text/plain
src/forge/GuiDisplay3.java -text svneol=native#text/plain
src/forge/GuiDisplay3.java svneol=native#text/plain
src/forge/GuiDisplay4.java svneol=native#text/plain
src/forge/GuiDisplayUtil.java svneol=native#text/plain
src/forge/GuiInput.java svneol=native#text/plain
@@ -7281,23 +7281,23 @@ src/forge/Gui_DownloadPictures.java svneol=native#text/plain
src/forge/Gui_DownloadPictures_LQ.java -text svneol=native#text/plain
src/forge/Gui_DownloadPrices.java -text svneol=native#text/plain
src/forge/Gui_DownloadSetPictures_LQ.java -text svneol=native#text/plain
src/forge/Gui_ElixirShop.java -text svneol=native#text/plain
src/forge/Gui_Gear.java -text svneol=native#text/plain
src/forge/Gui_Library.java -text svneol=native#text/plain
src/forge/Gui_ElixirShop.java svneol=native#text/plain
src/forge/Gui_Gear.java svneol=native#text/plain
src/forge/Gui_Library.java svneol=native#text/plain
src/forge/Gui_MultipleBlockers.java svneol=native#text/plain
src/forge/Gui_NewGame.java svneol=native#text/plain
src/forge/Gui_PetShop.java -text svneol=native#text/plain
src/forge/Gui_PlantShop.java -text svneol=native#text/plain
src/forge/Gui_PetShop.java svneol=native#text/plain
src/forge/Gui_PlantShop.java svneol=native#text/plain
src/forge/Gui_Quest.java svneol=native#text/plain
src/forge/Gui_QuestOptions.java svneol=native#text/plain
src/forge/Gui_Quest_Assignments.java svneol=native#text/plain
src/forge/Gui_Quest_DeckEditor.java -text svneol=native#text/plain
src/forge/Gui_Quest_DeckEditor_Menu.java -text svneol=native#text/plain
src/forge/Gui_Quest_DeckEditor.java svneol=native#text/plain
src/forge/Gui_Quest_DeckEditor_Menu.java svneol=native#text/plain
src/forge/Gui_Quest_Deck_Info.java svneol=native#text/plain
src/forge/Gui_SealedDeck.java svneol=native#text/plain
src/forge/Gui_SetEditor.java svneol=native#text/plain
src/forge/Gui_Shops.java -text svneol=native#text/plain
src/forge/Gui_Treasury.java -text svneol=native#text/plain
src/forge/Gui_Treasury.java svneol=native#text/plain
src/forge/Gui_Welcome.java svneol=native#text/plain
src/forge/Gui_WinLose.java svneol=native#text/plain
src/forge/HandSizeOp.java -text svneol=native#text/plain
@@ -7350,15 +7350,15 @@ src/forge/PrintCardNames.java svneol=native#text/plain
src/forge/PrintCardPictures.java svneol=native#text/plain
src/forge/QuestData.java svneol=native#text/plain
src/forge/QuestData_BoosterPack.java svneol=native#text/plain
src/forge/QuestData_Prefs.java -text svneol=native#text/plain
src/forge/QuestData_Prefs.java svneol=native#text/plain
src/forge/QuestData_State.java svneol=native#text/plain
src/forge/QuestUtil.java -text svneol=native#text/plain
src/forge/QuestUtil.java svneol=native#text/plain
src/forge/Quest_Assignment.java -text svneol=native#text/plain
src/forge/ReadBoosterPack.java svneol=native#text/plain
src/forge/ReadCard.java svneol=native#text/plain
src/forge/ReadDraftBoosterPack.java -text svneol=native#text/plain
src/forge/ReadPriceList.java -text svneol=native#text/plain
src/forge/ReadQuest_Assignment.java -text svneol=native#text/plain
src/forge/ReadQuest_Assignment.java svneol=native#text/plain
src/forge/Run.java svneol=native#text/plain
src/forge/RunTest.java svneol=native#text/plain
src/forge/SetInfo.java -text svneol=native#text/plain
@@ -7428,8 +7428,8 @@ src/forge/quest/data/QuestUtil.java svneol=native#text/plain
src/forge/quest/data/pet/QuestPetAbstract.java svneol=native#text/plain
src/forge/quest/data/pet/QuestPetBird.java svneol=native#text/plain
src/forge/quest/data/pet/QuestPetCrocodile.java svneol=native#text/plain
src/forge/quest/data/pet/QuestPetFactory.java svneol=native#text/plain
src/forge/quest/data/pet/QuestPetHound.java svneol=native#text/plain
src/forge/quest/data/pet/QuestPetManager.java svneol=native#text/plain
src/forge/quest/data/pet/QuestPetPlant.java svneol=native#text/plain
src/forge/quest/data/pet/QuestPetWolf.java svneol=native#text/plain
src/forge/quest/gui/QuestAbstractPanel.java svneol=native#text/plain

View File

@@ -19,6 +19,8 @@ import java.util.Map.Entry;
*
* @author Clemens Koza
*/
@SuppressWarnings({"deprecation"})
@Deprecated
public class QuestData_State implements Serializable {
private static final long serialVersionUID = 7007940230351051937L;

View File

@@ -1,13 +1,13 @@
package forge;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
public class AllZone implements NewConstants {
//only for testing, should read decks from local directory
@@ -16,7 +16,7 @@ public class AllZone implements NewConstants {
public static final Player HumanPlayer = new HumanPlayer("Human");
public static final Player ComputerPlayer = new AIPlayer("Computer");
public static QuestData QuestData = null;
public static forge.quest.data.QuestData QuestData = null;
public static Quest_Assignment QuestAssignment = null;
public static final NameChanger NameChanger = new NameChanger();

View File

@@ -2,12 +2,13 @@
package forge;
import forge.quest.data.QuestMatchState;
import javax.swing.*;
import java.util.Arrays;
import java.util.Collections;
import java.util.List;
import javax.swing.ImageIcon;
public interface Constant {
public static final String ProgramName = "Forge - http://cardforge.org";
@@ -17,7 +18,7 @@ public interface Constant {
public static final Deck[] HumanDeck = new Deck[1];
public static final Deck[] ComputerDeck = new Deck[1];
public static final String[] GameType = new String[1];
public static final WinLose WinLose = new WinLose();
public static final QuestMatchState matchState = new QuestMatchState();
public static final boolean[] Smooth = new boolean[1];
public static final boolean[] Mill = new boolean[1];
public static final boolean[] DevMode = new boolean[1]; // one for normal mode one for quest mode

File diff suppressed because it is too large Load Diff

View File

@@ -2,24 +2,6 @@
package forge;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.util.Observable;
import java.util.Observer;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JSeparator;
import forge.gui.GuiUtils;
import forge.gui.game.CardDetailPanel;
import forge.gui.game.CardPanel;
@@ -27,6 +9,13 @@ import forge.gui.game.CardPicturePanel;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import javax.swing.*;
import java.awt.BorderLayout;
import java.awt.Frame;
import java.awt.event.*;
import java.util.Observable;
import java.util.Observer;
public class GuiDisplay2 extends javax.swing.JFrame implements CardContainer, Display, NewConstants {
private static final long serialVersionUID = 8974795337536720207L;
@@ -109,7 +98,7 @@ public class GuiDisplay2 extends javax.swing.JFrame implements CardContainer, Di
concedeGame.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
dispose();
Constant.Runtime.WinLose.addLose();
Constant.Runtime.matchState.addLose();
new Gui_WinLose();
}
});
@@ -796,7 +785,7 @@ public class GuiDisplay2 extends javax.swing.JFrame implements CardContainer, Di
private void exitForm(java.awt.event.WindowEvent evt)//GEN-FIRST:event_exitForm
{
dispose();
Constant.Runtime.WinLose.addLose();
Constant.Runtime.matchState.addLose();
new Gui_WinLose();
}//GEN-LAST:event_exitForm

File diff suppressed because it is too large Load Diff

View File

@@ -1,68 +1,6 @@
package forge;
import static org.jdesktop.swingx.MultiSplitLayout.parseModel;
import java.awt.BorderLayout;
import java.awt.Color;
import java.awt.Component;
import java.awt.FlowLayout;
import java.awt.Font;
import java.awt.Frame;
import java.awt.GridLayout;
import java.awt.Insets;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.KeyAdapter;
import java.awt.event.KeyEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.MouseMotionAdapter;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.beans.XMLDecoder;
import java.beans.XMLEncoder;
import java.io.BufferedInputStream;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.IOException;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.List;
import java.util.Observable;
import java.util.Observer;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JDialog;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JLayeredPane;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JMenuItem;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JSeparator;
import javax.swing.JTextArea;
import javax.swing.ScrollPaneConstants;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import org.jdesktop.swingx.JXMultiSplitPane;
import org.jdesktop.swingx.MultiSplitLayout.Node;
import arcane.ui.HandArea;
import arcane.ui.PlayArea;
import arcane.ui.ViewPanel;
@@ -75,6 +13,24 @@ import forge.gui.game.CardPanel;
import forge.properties.ForgePreferences;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import org.jdesktop.swingx.JXMultiSplitPane;
import org.jdesktop.swingx.MultiSplitLayout.Node;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.awt.Color;
import java.awt.event.*;
import java.beans.XMLDecoder;
import java.beans.XMLEncoder;
import java.io.*;
import java.util.*;
import java.util.List;
import static org.jdesktop.swingx.MultiSplitLayout.parseModel;
public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewConstants, NewConstants.GUI.GuiDisplay, NewConstants.LANG.GuiDisplay {
@@ -995,15 +951,15 @@ public class GuiDisplay4 extends JFrame implements CardContainer, Display, NewCo
private void concede() {
savePrefs();
dispose();
Constant.Runtime.WinLose.addLose();
Constant.Runtime.matchState.addLose();
if (!Constant.Quest.fantasyQuest[0])
new Gui_WinLose();
else {
//new Gui_WinLose(Constant.Quest.humanList[0], Constant.Quest.computerList[0],Constant.Quest.humanLife[0], Constant.Quest.computerLife[0]);
CardList humanList = QuestUtil.getHumanPlantAndPet(AllZone.QuestData, AllZone.QuestAssignment);
CardList computerList = QuestUtil.getComputerCreatures(AllZone.QuestData, AllZone.QuestAssignment);
CardList humanList = forge.quest.data.QuestUtil.getHumanPlantAndPet(AllZone.QuestData, AllZone.QuestAssignment);
CardList computerList = forge.quest.data.QuestUtil.getComputerCreatures(AllZone.QuestData, AllZone.QuestAssignment);
int humanLife = QuestUtil.getLife(AllZone.QuestData);
int humanLife = AllZone.QuestData.getLife();
int computerLife = 20;
if (AllZone.QuestAssignment!=null)

View File

@@ -2,45 +2,26 @@
package forge;
import java.awt.Color;
import java.awt.Component;
import java.awt.Container;
import java.awt.Dimension;
import java.awt.GridLayout;
import java.awt.Image;
import java.awt.Point;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Map;
import java.util.Random;
import forge.error.ErrorViewer;
import forge.gui.game.CardDetailPanel;
import forge.gui.game.CardPicturePanel;
import forge.properties.NewConstants;
import javax.swing.BorderFactory;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.JTable;
import javax.swing.SwingUtilities;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import javax.swing.event.MouseInputListener;
import javax.swing.table.DefaultTableCellRenderer;
import javax.swing.table.TableCellRenderer;
import forge.error.ErrorViewer;
import forge.gui.game.CardDetailPanel;
import forge.gui.game.CardPicturePanel;
import forge.properties.NewConstants;
import java.awt.Color;
import java.awt.*;
import java.awt.event.*;
import java.text.DecimalFormat;
import java.text.NumberFormat;
import java.util.ArrayList;
import java.util.Map;
import java.util.Random;
public class Gui_CardShop extends JFrame implements CardContainer, DeckDisplay, NewConstants {
@@ -84,7 +65,7 @@ public class Gui_CardShop extends JFrame implements CardContainer, DeckDisplay,
private CardPicturePanel picture = new CardPicturePanel(null);
private JPanel glassPane;
private QuestData questData;
private forge.quest.data.QuestData questData;
@Override
public void setTitle(String message) {
super.setTitle(message);
@@ -281,49 +262,57 @@ public class Gui_CardShop extends JFrame implements CardContainer, DeckDisplay,
}
else //grab existing shopList
{
ArrayList<String> shopList = questData.getShopList();
java.util.List<String> shopList = questData.getShopList();
shop = new CardList();
for(int i = 0; i < shopList.size(); i++) {
Card c = AllZone.CardFactory.getCard(shopList.get(i).toString(), null);
c.setRarity(pack.getRarity(c.getName()));
if (map.containsKey(c.getName()))
c.setValue(map.get(c.getName()));
else //card is not on pricelist
{
System.out.println("Card " + c.getName() + " is not in the price list.");
if (c.getRarity().equals("Common"))
c.setValue(10);
else if (c.getRarity().equals("Uncommon"))
c.setValue(50);
else if (c.getRarity().equals("Rare"))
c.setValue(200);
}
shop.add(c);
}
for (String aShopList : shopList) {
Card c = AllZone.CardFactory.getCard(aShopList, null);
c.setRarity(pack.getRarity(c.getName()));
if (map.containsKey(c.getName())) {
c.setValue(map.get(c.getName()));
}
else //card is not on pricelist
{
System.out.println("Card " + c.getName() + " is not in the price list.");
if (c.getRarity().equals("Common")) {
c.setValue(10);
}
else if (c.getRarity().equals("Uncommon")) {
c.setValue(50);
}
else if (c.getRarity().equals("Rare")) {
c.setValue(200);
}
}
shop.add(c);
}
}
ArrayList<String> list = questData.getCardpool();
java.util.List<String> list = questData.getCardpool();
CardList owned = new CardList();
for(int i = 0; i < list.size(); i++) {
Card c = AllZone.CardFactory.getCard(list.get(i).toString(), null);
for (String aList : list) {
Card c = AllZone.CardFactory.getCard(aList, null);
c.setRarity(pack.getRarity(c.getName()));
if (map.containsKey(c.getName()))
c.setValue(map.get(c.getName()));
if (map.containsKey(c.getName())) {
c.setValue(map.get(c.getName()));
}
else //card is not on pricelist
{
System.out.println("Card " + c.getName() + " is not in the price list.");
if (c.getRarity().equals("Common"))
c.setValue(10);
else if (c.getRarity().equals("Uncommon"))
c.setValue(50);
else if (c.getRarity().equals("Rare"))
c.setValue(200);
System.out.println("Card " + c.getName() + " is not in the price list.");
if (c.getRarity().equals("Common")) {
c.setValue(10);
}
else if (c.getRarity().equals("Uncommon")) {
c.setValue(50);
}
else if (c.getRarity().equals("Rare")) {
c.setValue(200);
}
}
owned.add(c);
owned.add(c);
}
customMenu.populateShop(shop, owned);
@@ -402,7 +391,7 @@ public class Gui_CardShop extends JFrame implements CardContainer, DeckDisplay,
if (multi > 0.6)
multi = 0.6;
if (questData.getMode().equals(QuestData.FANTASY))
if (questData.getMode().equals(forge.quest.data.QuestData.FANTASY))
{
if (questData.getEstatesLevel()==1)
multi+=0.01;
@@ -443,7 +432,7 @@ public class Gui_CardShop extends JFrame implements CardContainer, DeckDisplay,
// setExtendedState(Frame.MAXIMIZED_BOTH);
}//setupAndDisplay()
public Gui_CardShop(QuestData qd) {
public Gui_CardShop(forge.quest.data.QuestData qd) {
questData = qd;
try {
jbInit();
@@ -625,7 +614,7 @@ public class Gui_CardShop extends JFrame implements CardContainer, DeckDisplay,
creditsLabel.setText("Total credits: " + questData.getCredits());
//remove sold cards from all decks:
ArrayList<String> deckNames = questData.getDeckNames();
java.util.List<String> deckNames = questData.getDeckNames();
for (String deckName:deckNames)
{
Deck deck = questData.getDeck(deckName);
@@ -633,7 +622,7 @@ public class Gui_CardShop extends JFrame implements CardContainer, DeckDisplay,
{
//count occurences:
int cardPoolCount = 0;
ArrayList<String> cpList = questData.getCards();
java.util.List<String> cpList = questData.getCards();
while(cpList.contains(c.getName()))
{
cpList.remove(cpList.indexOf(c.getName()));

View File

@@ -1,221 +1,216 @@
package forge;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import java.io.File;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import forge.error.ErrorViewer;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
public class Gui_ElixirShop extends JFrame implements NewConstants{
private static final long serialVersionUID = 2409591658245091210L;
private JFrame shopsGUI;
private JLabel titleLabel = new JLabel();
private JLabel potionDescLabel = new JLabel();
private JLabel potionStatsLabel = new JLabel();
private JLabel potionPriceLabel = new JLabel();
private JLabel potionIconLabel = new JLabel();
private JLabel creditsLabel = new JLabel();
private ImageIcon potionIcon = new ImageIcon();
private JButton buyPotionButton = new JButton();
private JButton quitButton = new JButton();
private QuestData questData = AllZone.QuestData;
public Gui_ElixirShop(JFrame parent) {
try {
jbInit();
} catch(Exception ex) {
ErrorViewer.showError(ex);
}
shopsGUI = parent;
setup();
//for some reason, the Bazaar window does not return when closing with X
//for now, just disable X closing:
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
Dimension screen = this.getToolkit().getScreenSize();
setBounds(screen.width / 3, 100, //position
530, 430); //size
setVisible(true);
}
//only do this ONCE:
private void setup() {
buyPotionButton.setBounds(new Rectangle(10, 297, 120, 50));
buyPotionButton.setText(getButtonText());
//buyPlantButton.setIcon(icon);
buyPotionButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
buyPotionButton_actionPerformed(e);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
}//setup();
private String getDesc()
{
StringBuilder sb = new StringBuilder();
sb.append("<html>");
sb.append("Gives +1 to max Life.<br>");
sb.append("<u>Current life:</u>" + questData.getLife());
sb.append("</html>");
return sb.toString();
}
private long getPrice()
{
long l = 0;
if (questData.getLife() < 20)
l = 250;
else if (questData.getLife() < 25)
l = 500;
else
l = 750;
return l;
}
private String getButtonText()
{
return "Buy Elixir";
}
private String getStats()
{
return "Elixir of Health";
}
private String getImageString()
{
return "ElixirIcon.png";
}
private void jbInit() throws Exception {
titleLabel.setFont(new java.awt.Font("sserif", Font.BOLD, 22));
titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
titleLabel.setText("Apothecary");
titleLabel.setBounds(new Rectangle(130, 5, 198, 60));
this.getContentPane().setLayout(null);
potionStatsLabel.setFont(new Font("sserif", Font.BOLD, 12));
potionStatsLabel.setText(getStats());
potionStatsLabel.setBounds(new Rectangle(10, 65, 100, 15));
potionDescLabel.setFont(new Font("sserif", 0, 12));
potionDescLabel.setText(getDesc());
potionDescLabel.setBounds(new Rectangle(10, 80, 300, 150));
potionPriceLabel.setFont(new Font("sserif", 0, 12));
potionPriceLabel.setText("<html><b><u>Price</u></b>: " + getPrice() + " credits</html>");
potionPriceLabel.setBounds(new Rectangle(10, 230, 150, 15));
creditsLabel.setFont(new Font("sserif", 0, 12));
creditsLabel.setText("Credits: " + questData.getCredits());
creditsLabel.setBounds(new Rectangle(10, 265, 150, 15));
potionIcon = getIcon(getImageString());
potionIconLabel.setText("");
potionIconLabel.setIcon(potionIcon);
potionIconLabel.setBounds(new Rectangle(280, 65, 201, 280));
potionIconLabel.setIconTextGap(0);
//String fileName = "LeafIconSmall.png";
//ImageIcon icon = getIcon(fileName);
buyPotionButton.setEnabled(true);
if (questData.getCredits() < getPrice() || questData.getLife() >= 30)
buyPotionButton.setEnabled(false);
quitButton.setBounds(new Rectangle(140, 297, 120, 50));
quitButton.setText("Quit");
quitButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
quitButton_actionPerformed(e);
}
});
//jPanel2.add(quitButton, null);
this.getContentPane().add(buyPotionButton, null);
this.getContentPane().add(titleLabel, null);
this.getContentPane().add(potionStatsLabel, null);
this.getContentPane().add(potionDescLabel, null);
this.getContentPane().add(potionIconLabel, null);
this.getContentPane().add(potionPriceLabel, null);
this.getContentPane().add(creditsLabel, null);
this.getContentPane().add(quitButton,null);
}
void editDeckButton_actionPerformed(ActionEvent e) {
Command exit = new Command() {
private static final long serialVersionUID = 4735992294414389187L;
public void execute() {
new Gui_WinLose();
}
};
Gui_DeckEditor editor = new Gui_DeckEditor();
editor.show(exit);
dispose();
}//editDeckButton_actionPerformed()
void buyPotionButton_actionPerformed(ActionEvent e) throws Exception {
questData.subtractCredits(getPrice());
questData.addLife(1);
QuestData.saveData(questData);
jbInit();
}
private ImageIcon getIcon(String fileName)
{
File base = ForgeProps.getFile(IMAGE_ICON);
File file = new File(base, fileName);
ImageIcon icon = new ImageIcon(file.toString());
return icon;
}
void quitButton_actionPerformed(ActionEvent e) {
QuestData.saveData(questData);
//new Gui_Shops();
shopsGUI.setVisible(true);
dispose();
}
void this_windowClosing(WindowEvent e) {
quitButton_actionPerformed(null);
}
}
package forge;
import forge.error.ErrorViewer;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import javax.swing.*;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import java.io.File;
public class Gui_ElixirShop extends JFrame implements NewConstants{
private static final long serialVersionUID = 2409591658245091210L;
private JFrame shopsGUI;
private JLabel titleLabel = new JLabel();
private JLabel potionDescLabel = new JLabel();
private JLabel potionStatsLabel = new JLabel();
private JLabel potionPriceLabel = new JLabel();
private JLabel potionIconLabel = new JLabel();
private JLabel creditsLabel = new JLabel();
private ImageIcon potionIcon = new ImageIcon();
private JButton buyPotionButton = new JButton();
private JButton quitButton = new JButton();
private forge.quest.data.QuestData questData = AllZone.QuestData;
public Gui_ElixirShop(JFrame parent) {
try {
jbInit();
} catch(Exception ex) {
ErrorViewer.showError(ex);
}
shopsGUI = parent;
setup();
//for some reason, the Bazaar window does not return when closing with X
//for now, just disable X closing:
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
Dimension screen = this.getToolkit().getScreenSize();
setBounds(screen.width / 3, 100, //position
530, 430); //size
setVisible(true);
}
//only do this ONCE:
private void setup() {
buyPotionButton.setBounds(new Rectangle(10, 297, 120, 50));
buyPotionButton.setText(getButtonText());
//buyPlantButton.setIcon(icon);
buyPotionButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
buyPotionButton_actionPerformed(e);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
}//setup();
private String getDesc()
{
StringBuilder sb = new StringBuilder();
sb.append("<html>");
sb.append("Gives +1 to max Life.<br>");
sb.append("<u>Current life:</u>" + questData.getLife());
sb.append("</html>");
return sb.toString();
}
private long getPrice()
{
long l = 0;
if (questData.getLife() < 20)
l = 250;
else if (questData.getLife() < 25)
l = 500;
else
l = 750;
return l;
}
private String getButtonText()
{
return "Buy Elixir";
}
private String getStats()
{
return "Elixir of Health";
}
private String getImageString()
{
return "ElixirIcon.png";
}
private void jbInit() throws Exception {
titleLabel.setFont(new java.awt.Font("sserif", Font.BOLD, 22));
titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
titleLabel.setText("Apothecary");
titleLabel.setBounds(new Rectangle(130, 5, 198, 60));
this.getContentPane().setLayout(null);
potionStatsLabel.setFont(new Font("sserif", Font.BOLD, 12));
potionStatsLabel.setText(getStats());
potionStatsLabel.setBounds(new Rectangle(10, 65, 100, 15));
potionDescLabel.setFont(new Font("sserif", 0, 12));
potionDescLabel.setText(getDesc());
potionDescLabel.setBounds(new Rectangle(10, 80, 300, 150));
potionPriceLabel.setFont(new Font("sserif", 0, 12));
potionPriceLabel.setText("<html><b><u>Price</u></b>: " + getPrice() + " credits</html>");
potionPriceLabel.setBounds(new Rectangle(10, 230, 150, 15));
creditsLabel.setFont(new Font("sserif", 0, 12));
creditsLabel.setText("Credits: " + questData.getCredits());
creditsLabel.setBounds(new Rectangle(10, 265, 150, 15));
potionIcon = getIcon(getImageString());
potionIconLabel.setText("");
potionIconLabel.setIcon(potionIcon);
potionIconLabel.setBounds(new Rectangle(280, 65, 201, 280));
potionIconLabel.setIconTextGap(0);
//String fileName = "LeafIconSmall.png";
//ImageIcon icon = getIcon(fileName);
buyPotionButton.setEnabled(true);
if (questData.getCredits() < getPrice() || questData.getLife() >= 30)
buyPotionButton.setEnabled(false);
quitButton.setBounds(new Rectangle(140, 297, 120, 50));
quitButton.setText("Quit");
quitButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
quitButton_actionPerformed(e);
}
});
//jPanel2.add(quitButton, null);
this.getContentPane().add(buyPotionButton, null);
this.getContentPane().add(titleLabel, null);
this.getContentPane().add(potionStatsLabel, null);
this.getContentPane().add(potionDescLabel, null);
this.getContentPane().add(potionIconLabel, null);
this.getContentPane().add(potionPriceLabel, null);
this.getContentPane().add(creditsLabel, null);
this.getContentPane().add(quitButton,null);
}
void editDeckButton_actionPerformed(ActionEvent e) {
Command exit = new Command() {
private static final long serialVersionUID = 4735992294414389187L;
public void execute() {
new Gui_WinLose();
}
};
Gui_DeckEditor editor = new Gui_DeckEditor();
editor.show(exit);
dispose();
}//editDeckButton_actionPerformed()
void buyPotionButton_actionPerformed(ActionEvent e) throws Exception {
questData.subtractCredits(getPrice());
questData.addLife(1);
questData.saveData();
jbInit();
}
private ImageIcon getIcon(String fileName)
{
File base = ForgeProps.getFile(IMAGE_ICON);
File file = new File(base, fileName);
ImageIcon icon = new ImageIcon(file.toString());
return icon;
}
void quitButton_actionPerformed(ActionEvent e) {
questData.saveData();
//new Gui_Shops();
shopsGUI.setVisible(true);
dispose();
}
void this_windowClosing(WindowEvent e) {
quitButton_actionPerformed(null);
}
}

View File

@@ -1,222 +1,217 @@
package forge;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import java.io.File;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import forge.error.ErrorViewer;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
public class Gui_Gear extends JFrame implements NewConstants{
private static final long serialVersionUID = -2124386606846472829L;
private JFrame shopsGUI;
private JLabel titleLabel = new JLabel();
private JLabel gearDescLabel = new JLabel();
private JLabel gearPriceLabel = new JLabel();
private JLabel gearIconLabel = new JLabel();
private JLabel creditsLabel = new JLabel();
private ImageIcon gearIcon = new ImageIcon();
private JButton gearButton = new JButton();
private JButton quitButton = new JButton();
private QuestData questData = AllZone.QuestData;
public Gui_Gear(JFrame parent) {
try {
jbInit();
} catch(Exception ex) {
ErrorViewer.showError(ex);
}
shopsGUI = parent;
setup();
//for some reason, the Bazaar window does not return when closing with X
//for now, just disable X closing:
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
Dimension screen = this.getToolkit().getScreenSize();
setBounds(screen.width / 3, 100, //position
530, 430); //size
setVisible(true);
}
//only do this ONCE:
private void setup() {
gearButton.setBounds(new Rectangle(10, 297, 120, 50));
gearButton.setText(getButtonText());
//buyPlantButton.setIcon(icon);
gearButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
learnEstatesButton_actionPerformed(e);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
}//setup();
private String getDesc()
{
StringBuilder sb = new StringBuilder();
sb.append("<html>");
if (questData.getGearLevel() == 0)
{
sb.append("<u><b>Adventurer's Map</b></u><br>");
sb.append("These ancient charts should facilitate navigation during your travels significantly.<br>");
sb.append("<u>Quest assignments become available more frequently</u>.");
}
else if (questData.getGearLevel() == 1)
{
sb.append("<u><b>Adventurer's Zeppelin</b></u><br>");
sb.append("This extremely comfortable airship allows for more efficient and safe travel to faraway destinations. <br>");
sb.append("<u>Quest assignments become available more frequently, adds +3 to max life</u>.");
}
else
{
sb.append("Currently nothing for sale. <br>Please check back later.");
}
sb.append("</html>");
return sb.toString();
}
private long getPrice()
{
long l = 0;
if (questData.getGearLevel() == 0)
l = 2000;
else if (questData.getGearLevel() == 1)
l = 5000;
return l;
}
private String getButtonText()
{
return "Buy";
}
private String getImageString()
{
if (questData.getGearLevel() == 0)
return "MapIconLarge.png";
else if (questData.getGearLevel() == 1)
return "ZeppelinIcon.png";
return "";
}
private void jbInit() throws Exception {
titleLabel.setFont(new java.awt.Font("sserif", Font.BOLD, 22));
titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
titleLabel.setText("Adventurer's Gear");
titleLabel.setBounds(new Rectangle(155, 5, 198, 60));
this.getContentPane().setLayout(null);
/*
potionStatsLabel.setFont(new Font("sserif", Font.BOLD, 12));
potionStatsLabel.setText(getStats());
potionStatsLabel.setBounds(new Rectangle(10, 65, 100, 15));
*/
gearDescLabel.setFont(new Font("sserif", 0, 12));
gearDescLabel.setText(getDesc());
gearDescLabel.setBounds(new Rectangle(10, 80, 300, 150));
gearPriceLabel.setFont(new Font("sserif", 0, 12));
gearPriceLabel.setText("<html><b><u>Price</u></b>: " + getPrice() + " credits</html>");
gearPriceLabel.setBounds(new Rectangle(10, 230, 150, 15));
creditsLabel.setFont(new Font("sserif", 0, 12));
creditsLabel.setText("Credits: " + questData.getCredits());
creditsLabel.setBounds(new Rectangle(10, 265, 150, 15));
gearIcon = getIcon(getImageString());
gearIconLabel.setText("");
gearIconLabel.setIcon(gearIcon);
gearIconLabel.setBounds(new Rectangle(325, 100, 128, 128));
gearIconLabel.setIconTextGap(0);
//String fileName = "LeafIconSmall.png";
//ImageIcon icon = getIcon(fileName);
gearButton.setEnabled(true);
if (questData.getCredits() < getPrice() || questData.getGearLevel() >= 2)
gearButton.setEnabled(false);
quitButton.setBounds(new Rectangle(140, 297, 120, 50));
quitButton.setText("Quit");
quitButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
quitButton_actionPerformed(e);
}
});
//jPanel2.add(quitButton, null);
this.getContentPane().add(gearButton, null);
this.getContentPane().add(titleLabel, null);
this.getContentPane().add(gearDescLabel, null);
this.getContentPane().add(gearIconLabel, null);
this.getContentPane().add(gearPriceLabel, null);
this.getContentPane().add(creditsLabel, null);
this.getContentPane().add(quitButton,null);
}
void learnEstatesButton_actionPerformed(ActionEvent e) throws Exception {
questData.subtractCredits(getPrice());
if (questData.getGearLevel() < 2)
{
questData.addGearLevel(1);
}
QuestData.saveData(questData);
jbInit();
}
private ImageIcon getIcon(String fileName)
{
File base = ForgeProps.getFile(IMAGE_ICON);
File file = new File(base, fileName);
ImageIcon icon = new ImageIcon(file.toString());
return icon;
}
void quitButton_actionPerformed(ActionEvent e) {
QuestData.saveData(questData);
//new Gui_Shops();
shopsGUI.setVisible(true);
dispose();
}
void this_windowClosing(WindowEvent e) {
quitButton_actionPerformed(null);
}
}
package forge;
import forge.error.ErrorViewer;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import javax.swing.*;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import java.io.File;
public class Gui_Gear extends JFrame implements NewConstants{
private static final long serialVersionUID = -2124386606846472829L;
private JFrame shopsGUI;
private JLabel titleLabel = new JLabel();
private JLabel gearDescLabel = new JLabel();
private JLabel gearPriceLabel = new JLabel();
private JLabel gearIconLabel = new JLabel();
private JLabel creditsLabel = new JLabel();
private ImageIcon gearIcon = new ImageIcon();
private JButton gearButton = new JButton();
private JButton quitButton = new JButton();
private forge.quest.data.QuestData questData = AllZone.QuestData;
public Gui_Gear(JFrame parent) {
try {
jbInit();
} catch(Exception ex) {
ErrorViewer.showError(ex);
}
shopsGUI = parent;
setup();
//for some reason, the Bazaar window does not return when closing with X
//for now, just disable X closing:
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
Dimension screen = this.getToolkit().getScreenSize();
setBounds(screen.width / 3, 100, //position
530, 430); //size
setVisible(true);
}
//only do this ONCE:
private void setup() {
gearButton.setBounds(new Rectangle(10, 297, 120, 50));
gearButton.setText(getButtonText());
//buyPlantButton.setIcon(icon);
gearButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
learnEstatesButton_actionPerformed(e);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
}//setup();
private String getDesc()
{
StringBuilder sb = new StringBuilder();
sb.append("<html>");
if (questData.getGearLevel() == 0)
{
sb.append("<u><b>Adventurer's Map</b></u><br>");
sb.append("These ancient charts should facilitate navigation during your travels significantly.<br>");
sb.append("<u>Quest assignments become available more frequently</u>.");
}
else if (questData.getGearLevel() == 1)
{
sb.append("<u><b>Adventurer's Zeppelin</b></u><br>");
sb.append("This extremely comfortable airship allows for more efficient and safe travel to faraway destinations. <br>");
sb.append("<u>Quest assignments become available more frequently, adds +3 to max life</u>.");
}
else
{
sb.append("Currently nothing for sale. <br>Please check back later.");
}
sb.append("</html>");
return sb.toString();
}
private long getPrice()
{
long l = 0;
if (questData.getGearLevel() == 0)
l = 2000;
else if (questData.getGearLevel() == 1)
l = 5000;
return l;
}
private String getButtonText()
{
return "Buy";
}
private String getImageString()
{
if (questData.getGearLevel() == 0)
return "MapIconLarge.png";
else if (questData.getGearLevel() == 1)
return "ZeppelinIcon.png";
return "";
}
private void jbInit() throws Exception {
titleLabel.setFont(new java.awt.Font("sserif", Font.BOLD, 22));
titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
titleLabel.setText("Adventurer's Gear");
titleLabel.setBounds(new Rectangle(155, 5, 198, 60));
this.getContentPane().setLayout(null);
/*
potionStatsLabel.setFont(new Font("sserif", Font.BOLD, 12));
potionStatsLabel.setText(getStats());
potionStatsLabel.setBounds(new Rectangle(10, 65, 100, 15));
*/
gearDescLabel.setFont(new Font("sserif", 0, 12));
gearDescLabel.setText(getDesc());
gearDescLabel.setBounds(new Rectangle(10, 80, 300, 150));
gearPriceLabel.setFont(new Font("sserif", 0, 12));
gearPriceLabel.setText("<html><b><u>Price</u></b>: " + getPrice() + " credits</html>");
gearPriceLabel.setBounds(new Rectangle(10, 230, 150, 15));
creditsLabel.setFont(new Font("sserif", 0, 12));
creditsLabel.setText("Credits: " + questData.getCredits());
creditsLabel.setBounds(new Rectangle(10, 265, 150, 15));
gearIcon = getIcon(getImageString());
gearIconLabel.setText("");
gearIconLabel.setIcon(gearIcon);
gearIconLabel.setBounds(new Rectangle(325, 100, 128, 128));
gearIconLabel.setIconTextGap(0);
//String fileName = "LeafIconSmall.png";
//ImageIcon icon = getIcon(fileName);
gearButton.setEnabled(true);
if (questData.getCredits() < getPrice() || questData.getGearLevel() >= 2)
gearButton.setEnabled(false);
quitButton.setBounds(new Rectangle(140, 297, 120, 50));
quitButton.setText("Quit");
quitButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
quitButton_actionPerformed(e);
}
});
//jPanel2.add(quitButton, null);
this.getContentPane().add(gearButton, null);
this.getContentPane().add(titleLabel, null);
this.getContentPane().add(gearDescLabel, null);
this.getContentPane().add(gearIconLabel, null);
this.getContentPane().add(gearPriceLabel, null);
this.getContentPane().add(creditsLabel, null);
this.getContentPane().add(quitButton,null);
}
void learnEstatesButton_actionPerformed(ActionEvent e) throws Exception {
questData.subtractCredits(getPrice());
if (questData.getGearLevel() < 2)
{
questData.addGearLevel(1);
}
questData.saveData();
jbInit();
}
private ImageIcon getIcon(String fileName)
{
File base = ForgeProps.getFile(IMAGE_ICON);
File file = new File(base, fileName);
ImageIcon icon = new ImageIcon(file.toString());
return icon;
}
void quitButton_actionPerformed(ActionEvent e) {
questData.saveData();
//new Gui_Shops();
shopsGUI.setVisible(true);
dispose();
}
void this_windowClosing(WindowEvent e) {
quitButton_actionPerformed(null);
}
}

View File

@@ -1,210 +1,205 @@
package forge;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import java.io.File;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import forge.error.ErrorViewer;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
public class Gui_Library extends JFrame implements NewConstants{
private static final long serialVersionUID = 2409591658245091210L;
private JFrame shopsGUI;
private JLabel titleLabel = new JLabel();
private JLabel sleightOfHandDescLabel = new JLabel();
private JLabel sleightOfHandPriceLabel = new JLabel();
private JLabel sleightOfHandIconLabel = new JLabel();
private JLabel creditsLabel = new JLabel();
private ImageIcon sleightOfHandIcon = new ImageIcon();
private JButton sleightOfHandButton= new JButton();
private JButton quitButton = new JButton();
private QuestData questData = AllZone.QuestData;
public Gui_Library(JFrame parent) {
try {
jbInit();
} catch(Exception ex) {
ErrorViewer.showError(ex);
}
shopsGUI = parent;
setup();
//for some reason, the Bazaar window does not return when closing with X
//for now, just disable X closing:
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
Dimension screen = this.getToolkit().getScreenSize();
setBounds(screen.width / 3, 100, //position
530, 430); //size
setVisible(true);
}
//only do this ONCE:
private void setup() {
sleightOfHandButton.setBounds(new Rectangle(10, 297, 120, 50));
sleightOfHandButton.setText(getButtonText());
//buyPlantButton.setIcon(icon);
sleightOfHandButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
learnEstatesButton_actionPerformed(e);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
}//setup();
private String getDesc()
{
StringBuilder sb = new StringBuilder();
sb.append("<html>");
if (questData.getSleightOfHandLevel() == 0)
{
sb.append("<u><b>Sleight of Hand Vol. I</b></u><br>");
sb.append("These volumes explain how to perform the most difficult of sleights.<br>");
sb.append("<u>Your first mulligan is <b>free</b></u>.");
}
else
{
sb.append("Currently nothing to study at the Library. <br>Please check back later.");
}
sb.append("</html>");
return sb.toString();
}
private long getPrice()
{
long l = 0;
if (questData.getSleightOfHandLevel() == 0)
l = 2000;
return l;
}
private String getButtonText()
{
return "Learn Sleight";
}
private String getImageString()
{
return "BookIcon.png";
}
private void jbInit() throws Exception {
titleLabel.setFont(new java.awt.Font("sserif", Font.BOLD, 22));
titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
titleLabel.setText("Library");
titleLabel.setBounds(new Rectangle(130, 5, 198, 60));
this.getContentPane().setLayout(null);
/*
potionStatsLabel.setFont(new Font("sserif", Font.BOLD, 12));
potionStatsLabel.setText(getStats());
potionStatsLabel.setBounds(new Rectangle(10, 65, 100, 15));
*/
sleightOfHandDescLabel.setFont(new Font("sserif", 0, 12));
sleightOfHandDescLabel.setText(getDesc());
sleightOfHandDescLabel.setBounds(new Rectangle(10, 80, 300, 150));
sleightOfHandPriceLabel.setFont(new Font("sserif", 0, 12));
sleightOfHandPriceLabel.setText("<html><b><u>Price</u></b>: " + getPrice() + " credits</html>");
sleightOfHandPriceLabel.setBounds(new Rectangle(10, 230, 150, 15));
creditsLabel.setFont(new Font("sserif", 0, 12));
creditsLabel.setText("Credits: " + questData.getCredits());
creditsLabel.setBounds(new Rectangle(10, 265, 150, 15));
sleightOfHandIcon = getIcon(getImageString());
sleightOfHandIconLabel.setText("");
sleightOfHandIconLabel.setIcon(sleightOfHandIcon);
sleightOfHandIconLabel.setBounds(new Rectangle(300, 135, 128, 128));
sleightOfHandIconLabel.setIconTextGap(0);
//String fileName = "LeafIconSmall.png";
//ImageIcon icon = getIcon(fileName);
sleightOfHandButton.setEnabled(true);
if (questData.getCredits() < getPrice() || questData.getSleightOfHandLevel() >= 1)
sleightOfHandButton.setEnabled(false);
quitButton.setBounds(new Rectangle(140, 297, 120, 50));
quitButton.setText("Quit");
quitButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
quitButton_actionPerformed(e);
}
});
//jPanel2.add(quitButton, null);
this.getContentPane().add(sleightOfHandButton, null);
this.getContentPane().add(titleLabel, null);
this.getContentPane().add(sleightOfHandDescLabel, null);
this.getContentPane().add(sleightOfHandIconLabel, null);
this.getContentPane().add(sleightOfHandPriceLabel, null);
this.getContentPane().add(creditsLabel, null);
this.getContentPane().add(quitButton,null);
}
void learnEstatesButton_actionPerformed(ActionEvent e) throws Exception {
questData.subtractCredits(getPrice());
if (questData.getSleightOfHandLevel() < 1)
{
questData.addSleightOfHandLevel(1);
}
QuestData.saveData(questData);
jbInit();
}
private ImageIcon getIcon(String fileName)
{
File base = ForgeProps.getFile(IMAGE_ICON);
File file = new File(base, fileName);
ImageIcon icon = new ImageIcon(file.toString());
return icon;
}
void quitButton_actionPerformed(ActionEvent e) {
QuestData.saveData(questData);
//new Gui_Shops();
shopsGUI.setVisible(true);
dispose();
}
void this_windowClosing(WindowEvent e) {
quitButton_actionPerformed(null);
}
}
package forge;
import forge.error.ErrorViewer;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import javax.swing.*;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import java.io.File;
public class Gui_Library extends JFrame implements NewConstants{
private static final long serialVersionUID = 2409591658245091210L;
private JFrame shopsGUI;
private JLabel titleLabel = new JLabel();
private JLabel sleightOfHandDescLabel = new JLabel();
private JLabel sleightOfHandPriceLabel = new JLabel();
private JLabel sleightOfHandIconLabel = new JLabel();
private JLabel creditsLabel = new JLabel();
private ImageIcon sleightOfHandIcon = new ImageIcon();
private JButton sleightOfHandButton= new JButton();
private JButton quitButton = new JButton();
private forge.quest.data.QuestData questData = AllZone.QuestData;
public Gui_Library(JFrame parent) {
try {
jbInit();
} catch(Exception ex) {
ErrorViewer.showError(ex);
}
shopsGUI = parent;
setup();
//for some reason, the Bazaar window does not return when closing with X
//for now, just disable X closing:
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
Dimension screen = this.getToolkit().getScreenSize();
setBounds(screen.width / 3, 100, //position
530, 430); //size
setVisible(true);
}
//only do this ONCE:
private void setup() {
sleightOfHandButton.setBounds(new Rectangle(10, 297, 120, 50));
sleightOfHandButton.setText(getButtonText());
//buyPlantButton.setIcon(icon);
sleightOfHandButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
learnEstatesButton_actionPerformed(e);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
}//setup();
private String getDesc()
{
StringBuilder sb = new StringBuilder();
sb.append("<html>");
if (questData.getSleightOfHandLevel() == 0)
{
sb.append("<u><b>Sleight of Hand Vol. I</b></u><br>");
sb.append("These volumes explain how to perform the most difficult of sleights.<br>");
sb.append("<u>Your first mulligan is <b>free</b></u>.");
}
else
{
sb.append("Currently nothing to study at the Library. <br>Please check back later.");
}
sb.append("</html>");
return sb.toString();
}
private long getPrice()
{
long l = 0;
if (questData.getSleightOfHandLevel() == 0)
l = 2000;
return l;
}
private String getButtonText()
{
return "Learn Sleight";
}
private String getImageString()
{
return "BookIcon.png";
}
private void jbInit() throws Exception {
titleLabel.setFont(new java.awt.Font("sserif", Font.BOLD, 22));
titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
titleLabel.setText("Library");
titleLabel.setBounds(new Rectangle(130, 5, 198, 60));
this.getContentPane().setLayout(null);
/*
potionStatsLabel.setFont(new Font("sserif", Font.BOLD, 12));
potionStatsLabel.setText(getStats());
potionStatsLabel.setBounds(new Rectangle(10, 65, 100, 15));
*/
sleightOfHandDescLabel.setFont(new Font("sserif", 0, 12));
sleightOfHandDescLabel.setText(getDesc());
sleightOfHandDescLabel.setBounds(new Rectangle(10, 80, 300, 150));
sleightOfHandPriceLabel.setFont(new Font("sserif", 0, 12));
sleightOfHandPriceLabel.setText("<html><b><u>Price</u></b>: " + getPrice() + " credits</html>");
sleightOfHandPriceLabel.setBounds(new Rectangle(10, 230, 150, 15));
creditsLabel.setFont(new Font("sserif", 0, 12));
creditsLabel.setText("Credits: " + questData.getCredits());
creditsLabel.setBounds(new Rectangle(10, 265, 150, 15));
sleightOfHandIcon = getIcon(getImageString());
sleightOfHandIconLabel.setText("");
sleightOfHandIconLabel.setIcon(sleightOfHandIcon);
sleightOfHandIconLabel.setBounds(new Rectangle(300, 135, 128, 128));
sleightOfHandIconLabel.setIconTextGap(0);
//String fileName = "LeafIconSmall.png";
//ImageIcon icon = getIcon(fileName);
sleightOfHandButton.setEnabled(true);
if (questData.getCredits() < getPrice() || questData.getSleightOfHandLevel() >= 1)
sleightOfHandButton.setEnabled(false);
quitButton.setBounds(new Rectangle(140, 297, 120, 50));
quitButton.setText("Quit");
quitButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
quitButton_actionPerformed(e);
}
});
//jPanel2.add(quitButton, null);
this.getContentPane().add(sleightOfHandButton, null);
this.getContentPane().add(titleLabel, null);
this.getContentPane().add(sleightOfHandDescLabel, null);
this.getContentPane().add(sleightOfHandIconLabel, null);
this.getContentPane().add(sleightOfHandPriceLabel, null);
this.getContentPane().add(creditsLabel, null);
this.getContentPane().add(quitButton,null);
}
void learnEstatesButton_actionPerformed(ActionEvent e) throws Exception {
questData.subtractCredits(getPrice());
if (questData.getSleightOfHandLevel() < 1)
{
questData.addSleightOfHandLevel(1);
}
questData.saveData();
jbInit();
}
private ImageIcon getIcon(String fileName)
{
File base = ForgeProps.getFile(IMAGE_ICON);
File file = new File(base, fileName);
ImageIcon icon = new ImageIcon(file.toString());
return icon;
}
void quitButton_actionPerformed(ActionEvent e) {
questData.saveData();
//new Gui_Shops();
shopsGUI.setVisible(true);
dispose();
}
void this_windowClosing(WindowEvent e) {
quitButton_actionPerformed(null);
}
}

View File

@@ -1,5 +1,24 @@
package forge;
import arcane.ui.util.ManaSymbols;
import arcane.util.MultiplexOutputStream;
import com.esotericsoftware.minlog.Log;
import forge.error.ErrorViewer;
import forge.error.ExceptionHandler;
import forge.gui.GuiUtils;
import forge.gui.ListChooser;
import forge.properties.ForgePreferences;
import forge.properties.ForgePreferences.CardSizeType;
import forge.properties.ForgePreferences.StackOffsetType;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import forge.properties.NewConstants.LANG.Gui_NewGame.MENU_BAR.MENU;
import forge.properties.NewConstants.LANG.Gui_NewGame.MENU_BAR.OPTIONS;
import net.miginfocom.swing.MigLayout;
import javax.swing.*;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.border.TitledBorder;
import java.awt.Color;
import java.awt.Component;
import java.awt.Font;
@@ -8,59 +27,8 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.io.BufferedOutputStream;
import java.io.File;
import java.io.FileNotFoundException;
import java.io.FileOutputStream;
import java.io.OutputStream;
import java.io.PrintStream;
import java.util.ArrayList;
import java.util.Arrays;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Random;
import javax.swing.AbstractAction;
import javax.swing.Action;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JCheckBoxMenuItem;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JMenu;
import javax.swing.JMenuBar;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.SwingConstants;
import javax.swing.SwingUtilities;
import javax.swing.UIManager;
import javax.swing.UIManager.LookAndFeelInfo;
import javax.swing.border.TitledBorder;
import net.miginfocom.swing.MigLayout;
import arcane.ui.util.ManaSymbols;
import arcane.util.MultiplexOutputStream;
import com.esotericsoftware.minlog.Log;
import forge.error.ErrorViewer;
import forge.error.ExceptionHandler;
import forge.gui.GuiUtils;
import forge.gui.ListChooser;
import forge.properties.ForgePreferences;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import forge.properties.ForgePreferences.CardSizeType;
import forge.properties.ForgePreferences.StackOffsetType;
import forge.properties.NewConstants.LANG.Gui_NewGame.MENU_BAR.MENU;
import forge.properties.NewConstants.LANG.Gui_NewGame.MENU_BAR.OPTIONS;
import java.io.*;
import java.util.*;
/*CHOPPIC*/
@@ -193,7 +161,7 @@ public class Gui_NewGame extends JFrame implements NewConstants, NewConstants.LA
AllZone.QuestData = null;
allDecks = getDecks();
Constant.Runtime.WinLose.reset();
Constant.Runtime.matchState.reset();
if(Constant.Runtime.width[0] == 0) Constant.Runtime.width[0] = 70;

File diff suppressed because it is too large Load Diff

View File

@@ -1,311 +1,306 @@
package forge;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import java.io.File;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import forge.error.ErrorViewer;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
public class Gui_PlantShop extends JFrame implements NewConstants{
private static final long serialVersionUID = 2409591658245091210L;
private JFrame shopsGUI;
private JLabel titleLabel = new JLabel();
private JLabel plantDescLabel = new JLabel();
private JLabel plantStatsLabel = new JLabel();
private JLabel plantPriceLabel = new JLabel();
private JLabel plantIconLabel = new JLabel();
private JLabel creditsLabel = new JLabel();
private ImageIcon plantIcon = new ImageIcon();
private JButton buyPlantButton = new JButton();
private JButton quitButton = new JButton();
private QuestData questData = AllZone.QuestData;
public Gui_PlantShop(JFrame parent) {
try {
jbInit();
} catch(Exception ex) {
ErrorViewer.showError(ex);
}
shopsGUI = parent;
setup();
//for some reason, the Bazaar window does not return when closing with X
//for now, just disable X closing:
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
Dimension screen = this.getToolkit().getScreenSize();
setBounds(screen.width / 3, 100, //position
530, 430); //size
setVisible(true);
}
private void setup() {
//buyPlantButton.setIcon(icon);
buyPlantButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
buyPlantButton_actionPerformed(e);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
}//setup();
private String getDesc()
{
StringBuilder sb = new StringBuilder();
sb.append("<html>");
if (questData.getPlantLevel() == 0)
{
sb.append("Start each of your battles with this lush, <br> verdant plant on your side.<br>");
sb.append("Excellent at blocking the nastiest of critters!<br><br>");
sb.append("<u><b>Level 1</b></u>: 0/1<br>");
sb.append("<u><b>Next Level</b></u>: 0/2<br>");
sb.append("<u><b>Can learn</b></u>: Deathtouch");
}
else if (questData.getPlantLevel() == 1)
{
sb.append("Improve the toughness of your plant.<br>");
sb.append("<u><b>Level 2</b></u>: 0/2<br>");
sb.append("<u><b>Next Level</b></u>: 0/3<br>");
sb.append("<u><b>Can learn</b></u>: Deathtouch");
}
else if (questData.getPlantLevel() == 2)
{
sb.append("Improve the toughness of your plant.<br>");
sb.append("<u><b>Level 3</b></u>: 0/3<br>");
sb.append("<u><b>Next Level</b></u>: 1/3<br>");
sb.append("<u><b>Can learn</b></u>: Deathtouch");
}
else if (questData.getPlantLevel() == 3)
{
sb.append("Improve the power of your plant.<br>");
sb.append("<u><b>Level 4</b></u>: 1/3<br>");
sb.append("<u><b>Next Level</b></u>: Deathtouch<br>");
sb.append("<u><b>Can learn</b></u>: Deathtouch");
}
else if (questData.getPlantLevel() == 4)
{
sb.append("Grow venomous thorns on your plant.<br>");
sb.append("<u><b>Level 5</b></u>: Deathtouch<br>");
sb.append("<u><b>Next Level</b></u>: 1/4<br>");
}
else if (questData.getPlantLevel() == 5)
{
sb.append("As well as gaining more toughness,<br>");
sb.append("your plant will have healing properties.<br>");
sb.append("<u><b>Level 6</b></u>: 1/4 and Tap, you gain 1 life.");
}
else
{
sb.append("Plant Level Maxed out.");
}
sb.append("</html>");
return sb.toString();
}
private long getPrice()
{
long l = 0;
if (questData.getPlantLevel() == 0)
l = 100;
else if (questData.getPlantLevel() == 1)
l = 150;
else if (questData.getPlantLevel() == 2)
l = 200;
else if (questData.getPlantLevel() == 3)
l = 300;
else if (questData.getPlantLevel() == 4)
l = 750;
else if (questData.getPlantLevel() == 5)
l = 1000;
return l;
}
private String getButtonText()
{
String s = "";
if (questData.getPlantLevel() == 0)
s = "Buy Plant";
else
s = "Upgrade Plant";
return s;
}
private String getStats()
{
StringBuilder sb = new StringBuilder();
if (questData.getPlantLevel() == 0)
sb.append("0/1");
else if (questData.getPlantLevel() == 1)
sb.append("0/2");
else if (questData.getPlantLevel() == 2)
sb.append("0/3");
else if (questData.getPlantLevel() == 3)
sb.append("1/3");
else if (questData.getPlantLevel() == 4)
sb.append("1/3");
else
sb.append("1/4");
sb.append(" Plant Wall (current level ");
sb.append(questData.getPlantLevel());
sb.append("/6)");
return sb.toString();
}
private String getImageString()
{
String s = "";
if (questData.getPlantLevel() == 0)
s = "g_0_1_plant_wall_small.jpg";
else if (questData.getPlantLevel() == 1)
s = "g_0_2_plant_wall_small.jpg";
else if (questData.getPlantLevel() == 2)
s = "g_0_3_plant_wall_small.jpg";
else if (questData.getPlantLevel() == 3)
s = "g_1_3_plant_wall_small.jpg";
else if (questData.getPlantLevel() == 4)
s = "g_1_3_plant_wall_deathtouch_small.jpg";
else if (questData.getPlantLevel() == 5)
s = "g_1_4_plant_wall_small.jpg";
return s;
}
private void jbInit() throws Exception {
titleLabel.setFont(new java.awt.Font("sserif", Font.BOLD, 22));
titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
titleLabel.setText("Plant Nursery");
titleLabel.setBounds(new Rectangle(130, 5, 198, 60));
this.getContentPane().setLayout(null);
plantStatsLabel.setFont(new Font("sserif", Font.BOLD, 12));
plantStatsLabel.setText(getStats());
plantStatsLabel.setBounds(new Rectangle(10, 65, 200, 15));
plantDescLabel.setFont(new Font("sserif", 0, 12));
plantDescLabel.setText(getDesc());
plantDescLabel.setBounds(new Rectangle(10, 80, 300, 150));
plantPriceLabel.setFont(new Font("sserif", 0, 12));
plantPriceLabel.setText("<html><b><u>Price</u></b>: " + getPrice() + " credits</html>");
plantPriceLabel.setBounds(new Rectangle(10, 230, 150, 15));
creditsLabel.setFont(new Font("sserif", 0, 12));
creditsLabel.setText("Credits: " + questData.getCredits());
creditsLabel.setBounds(new Rectangle(10, 265, 150, 15));
plantIcon = getIcon(getImageString());
plantIconLabel.setText("");
plantIconLabel.setIcon(plantIcon);
plantIconLabel.setBounds(new Rectangle(280, 65, 201, 280));
plantIconLabel.setIconTextGap(0);
//String fileName = "LeafIconSmall.png";
//ImageIcon icon = getIcon(fileName);
buyPlantButton.setBounds(new Rectangle(10, 297, 120, 50));
buyPlantButton.setText(getButtonText());
buyPlantButton.setEnabled(true);
if (questData.getCredits() < getPrice() || questData.getPlantLevel() >= 6)
buyPlantButton.setEnabled(false);
quitButton.setBounds(new Rectangle(140, 297, 120, 50));
quitButton.setText("Quit");
quitButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
quitButton_actionPerformed(e);
}
});
//jPanel2.add(quitButton, null);
this.getContentPane().add(buyPlantButton, null);
this.getContentPane().add(titleLabel, null);
this.getContentPane().add(plantStatsLabel, null);
this.getContentPane().add(plantDescLabel, null);
this.getContentPane().add(plantIconLabel, null);
this.getContentPane().add(plantPriceLabel, null);
this.getContentPane().add(creditsLabel, null);
this.getContentPane().add(quitButton,null);
}
void editDeckButton_actionPerformed(ActionEvent e) {
Command exit = new Command() {
private static final long serialVersionUID = 4735992294414389187L;
public void execute() {
new Gui_WinLose();
}
};
Gui_DeckEditor editor = new Gui_DeckEditor();
editor.show(exit);
dispose();
}//editDeckButton_actionPerformed()
void buyPlantButton_actionPerformed(ActionEvent e) throws Exception {
questData.subtractCredits(getPrice());
questData.addPlantLevel();
jbInit();
}
void restartButton_actionPerformed(ActionEvent e) {
Constant.Runtime.WinLose.reset();
AllZone.GameAction.newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0]);
AllZone.Display.setVisible(true);
dispose();
}
private ImageIcon getIcon(String fileName)
{
File base = ForgeProps.getFile(IMAGE_ICON);
File file = new File(base, fileName);
ImageIcon icon = new ImageIcon(file.toString());
return icon;
}
void quitButton_actionPerformed(ActionEvent e) {
QuestData.saveData(questData);
//new Gui_Shops();
shopsGUI.setVisible(true);
dispose();
}
void this_windowClosing(WindowEvent e) {
quitButton_actionPerformed(null);
}
}
package forge;
import forge.error.ErrorViewer;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import javax.swing.*;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import java.io.File;
public class Gui_PlantShop extends JFrame implements NewConstants{
private static final long serialVersionUID = 2409591658245091210L;
private JFrame shopsGUI;
private JLabel titleLabel = new JLabel();
private JLabel plantDescLabel = new JLabel();
private JLabel plantStatsLabel = new JLabel();
private JLabel plantPriceLabel = new JLabel();
private JLabel plantIconLabel = new JLabel();
private JLabel creditsLabel = new JLabel();
private ImageIcon plantIcon = new ImageIcon();
private JButton buyPlantButton = new JButton();
private JButton quitButton = new JButton();
private forge.quest.data.QuestData questData = AllZone.QuestData;
public Gui_PlantShop(JFrame parent) {
try {
jbInit();
} catch(Exception ex) {
ErrorViewer.showError(ex);
}
shopsGUI = parent;
setup();
//for some reason, the Bazaar window does not return when closing with X
//for now, just disable X closing:
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
Dimension screen = this.getToolkit().getScreenSize();
setBounds(screen.width / 3, 100, //position
530, 430); //size
setVisible(true);
}
private void setup() {
//buyPlantButton.setIcon(icon);
buyPlantButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
buyPlantButton_actionPerformed(e);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
}//setup();
private String getDesc()
{
StringBuilder sb = new StringBuilder();
sb.append("<html>");
if (questData.getPetManager().getPlant().getLevel() == 0)
{
sb.append("Start each of your battles with this lush, <br> verdant plant on your side.<br>");
sb.append("Excellent at blocking the nastiest of critters!<br><br>");
sb.append("<u><b>Level 1</b></u>: 0/1<br>");
sb.append("<u><b>Next Level</b></u>: 0/2<br>");
sb.append("<u><b>Can learn</b></u>: Deathtouch");
}
else if (questData.getPetManager().getPlant().getLevel() == 1)
{
sb.append("Improve the toughness of your plant.<br>");
sb.append("<u><b>Level 2</b></u>: 0/2<br>");
sb.append("<u><b>Next Level</b></u>: 0/3<br>");
sb.append("<u><b>Can learn</b></u>: Deathtouch");
}
else if (questData.getPetManager().getPlant().getLevel() == 2)
{
sb.append("Improve the toughness of your plant.<br>");
sb.append("<u><b>Level 3</b></u>: 0/3<br>");
sb.append("<u><b>Next Level</b></u>: 1/3<br>");
sb.append("<u><b>Can learn</b></u>: Deathtouch");
}
else if (questData.getPetManager().getPlant().getLevel() == 3)
{
sb.append("Improve the power of your plant.<br>");
sb.append("<u><b>Level 4</b></u>: 1/3<br>");
sb.append("<u><b>Next Level</b></u>: Deathtouch<br>");
sb.append("<u><b>Can learn</b></u>: Deathtouch");
}
else if (questData.getPetManager().getPlant().getLevel() == 4)
{
sb.append("Grow venomous thorns on your plant.<br>");
sb.append("<u><b>Level 5</b></u>: Deathtouch<br>");
sb.append("<u><b>Next Level</b></u>: 1/4<br>");
}
else if (questData.getPetManager().getPlant().getLevel() == 5)
{
sb.append("As well as gaining more toughness,<br>");
sb.append("your plant will have healing properties.<br>");
sb.append("<u><b>Level 6</b></u>: 1/4 and Tap, you gain 1 life.");
}
else
{
sb.append("Plant Level Maxed out.");
}
sb.append("</html>");
return sb.toString();
}
private long getPrice()
{
long l = 0;
if (questData.getPetManager().getPlant().getLevel() == 0)
l = 100;
else if (questData.getPetManager().getPlant().getLevel() == 1)
l = 150;
else if (questData.getPetManager().getPlant().getLevel() == 2)
l = 200;
else if (questData.getPetManager().getPlant().getLevel() == 3)
l = 300;
else if (questData.getPetManager().getPlant().getLevel() == 4)
l = 750;
else if (questData.getPetManager().getPlant().getLevel() == 5)
l = 1000;
return l;
}
private String getButtonText()
{
String s = "";
if (questData.getPetManager().getPlant().getLevel() == 0)
s = "Buy Plant";
else
s = "Upgrade Plant";
return s;
}
private String getStats()
{
StringBuilder sb = new StringBuilder();
if (questData.getPetManager().getPlant().getLevel() == 0)
sb.append("0/1");
else if (questData.getPetManager().getPlant().getLevel() == 1)
sb.append("0/2");
else if (questData.getPetManager().getPlant().getLevel() == 2)
sb.append("0/3");
else if (questData.getPetManager().getPlant().getLevel() == 3)
sb.append("1/3");
else if (questData.getPetManager().getPlant().getLevel() == 4)
sb.append("1/3");
else
sb.append("1/4");
sb.append(" Plant Wall (current level ");
sb.append(questData.getPetManager().getPlant().getLevel());
sb.append("/6)");
return sb.toString();
}
private String getImageString()
{
String s = "";
if (questData.getPetManager().getPlant().getLevel() == 0)
s = "g_0_1_plant_wall_small.jpg";
else if (questData.getPetManager().getPlant().getLevel() == 1)
s = "g_0_2_plant_wall_small.jpg";
else if (questData.getPetManager().getPlant().getLevel() == 2)
s = "g_0_3_plant_wall_small.jpg";
else if (questData.getPetManager().getPlant().getLevel() == 3)
s = "g_1_3_plant_wall_small.jpg";
else if (questData.getPetManager().getPlant().getLevel() == 4)
s = "g_1_3_plant_wall_deathtouch_small.jpg";
else if (questData.getPetManager().getPlant().getLevel() == 5)
s = "g_1_4_plant_wall_small.jpg";
return s;
}
private void jbInit() throws Exception {
titleLabel.setFont(new java.awt.Font("sserif", Font.BOLD, 22));
titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
titleLabel.setText("Plant Nursery");
titleLabel.setBounds(new Rectangle(130, 5, 198, 60));
this.getContentPane().setLayout(null);
plantStatsLabel.setFont(new Font("sserif", Font.BOLD, 12));
plantStatsLabel.setText(getStats());
plantStatsLabel.setBounds(new Rectangle(10, 65, 200, 15));
plantDescLabel.setFont(new Font("sserif", 0, 12));
plantDescLabel.setText(getDesc());
plantDescLabel.setBounds(new Rectangle(10, 80, 300, 150));
plantPriceLabel.setFont(new Font("sserif", 0, 12));
plantPriceLabel.setText("<html><b><u>Price</u></b>: " + getPrice() + " credits</html>");
plantPriceLabel.setBounds(new Rectangle(10, 230, 150, 15));
creditsLabel.setFont(new Font("sserif", 0, 12));
creditsLabel.setText("Credits: " + questData.getCredits());
creditsLabel.setBounds(new Rectangle(10, 265, 150, 15));
plantIcon = getIcon(getImageString());
plantIconLabel.setText("");
plantIconLabel.setIcon(plantIcon);
plantIconLabel.setBounds(new Rectangle(280, 65, 201, 280));
plantIconLabel.setIconTextGap(0);
//String fileName = "LeafIconSmall.png";
//ImageIcon icon = getIcon(fileName);
buyPlantButton.setBounds(new Rectangle(10, 297, 120, 50));
buyPlantButton.setText(getButtonText());
buyPlantButton.setEnabled(true);
if (questData.getCredits() < getPrice() || questData.getPetManager().getPlant().getLevel() >= 6)
buyPlantButton.setEnabled(false);
quitButton.setBounds(new Rectangle(140, 297, 120, 50));
quitButton.setText("Quit");
quitButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
quitButton_actionPerformed(e);
}
});
//jPanel2.add(quitButton, null);
this.getContentPane().add(buyPlantButton, null);
this.getContentPane().add(titleLabel, null);
this.getContentPane().add(plantStatsLabel, null);
this.getContentPane().add(plantDescLabel, null);
this.getContentPane().add(plantIconLabel, null);
this.getContentPane().add(plantPriceLabel, null);
this.getContentPane().add(creditsLabel, null);
this.getContentPane().add(quitButton,null);
}
void editDeckButton_actionPerformed(ActionEvent e) {
Command exit = new Command() {
private static final long serialVersionUID = 4735992294414389187L;
public void execute() {
new Gui_WinLose();
}
};
Gui_DeckEditor editor = new Gui_DeckEditor();
editor.show(exit);
dispose();
}//editDeckButton_actionPerformed()
void buyPlantButton_actionPerformed(ActionEvent e) throws Exception {
questData.subtractCredits(getPrice());
questData.getPetManager().addPlantLevel();
jbInit();
}
void restartButton_actionPerformed(ActionEvent e) {
Constant.Runtime.matchState.reset();
AllZone.GameAction.newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0]);
AllZone.Display.setVisible(true);
dispose();
}
private ImageIcon getIcon(String fileName)
{
File base = ForgeProps.getFile(IMAGE_ICON);
File file = new File(base, fileName);
ImageIcon icon = new ImageIcon(file.toString());
return icon;
}
void quitButton_actionPerformed(ActionEvent e) {
questData.saveData();
//new Gui_Shops();
shopsGUI.setVisible(true);
dispose();
}
void this_windowClosing(WindowEvent e) {
quitButton_actionPerformed(null);
}
}

View File

@@ -1,28 +1,20 @@
package forge;
import forge.error.ErrorViewer;
import forge.properties.NewConstants;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import java.awt.Color;
import java.awt.Dimension;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
import java.util.Collections;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.SwingConstants;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import forge.error.ErrorViewer;
import forge.properties.NewConstants;
import java.util.List;
import java.util.Set;
//presumes AllZone.QuestData is not null
@@ -30,7 +22,7 @@ import forge.properties.NewConstants;
public class Gui_Quest extends JFrame implements NewConstants{
private static final long serialVersionUID = -6432089669283627896L;
private QuestData questData;
private forge.quest.data.QuestData questData;
private JLabel jLabel1 = new JLabel();
private JLabel difficultyLabel = new JLabel();
@@ -100,7 +92,7 @@ public class Gui_Quest extends JFrame implements NewConstants{
rankLabel.setText(questData.getRank());
creditsLabel.setText("Credits: " + questData.getCredits());
if (questData.getMode().equals(QuestData.FANTASY))
if (questData.getMode().equals(forge.quest.data.QuestData.FANTASY))
{
int life = questData.getLife();
if (life<15)
@@ -121,14 +113,16 @@ public class Gui_Quest extends JFrame implements NewConstants{
//get deck names as Strings
ArrayList<String> list = questData.getDeckNames();
List<String> list = questData.getDeckNames();
Collections.sort(list);
for(int i = 0; i < list.size(); i++)
deckComboBox.addItem(list.get(i));
for (String aList : list) {
deckComboBox.addItem(aList);
}
if(Constant.Runtime.HumanDeck[0] != null) deckComboBox.setSelectedItem(Constant.Runtime.HumanDeck[0].getName());
if (QuestData.FANTASY.equals(questData.getMode()))
if (forge.quest.data.QuestData.FANTASY.equals(questData.getMode()))
{
}
@@ -178,7 +172,7 @@ public class Gui_Quest extends JFrame implements NewConstants{
});
//if (questData.getMode().equals("Fantasy"))
if (QuestData.FANTASY.equals(questData.getMode()))
if (forge.quest.data.QuestData.FANTASY.equals(questData.getMode()))
{
refreshPets();
@@ -272,7 +266,7 @@ public class Gui_Quest extends JFrame implements NewConstants{
jPanel2.add(oppOneRadio, null);
jPanel2.add(oppTwoRadio, null);
jPanel2.add(oppThreeRadio, null);
if (QuestData.FANTASY.equals(questData.getMode())) {
if (forge.quest.data.QuestData.FANTASY.equals(questData.getMode())) {
this.getContentPane().add(otherShopsButton, null);
this.getContentPane().add(lifeLabel,null);
this.getContentPane().add(questsButton, null);
@@ -316,10 +310,12 @@ public class Gui_Quest extends JFrame implements NewConstants{
void refreshPets(){
petComboBox.removeAllItems();
ArrayList<String> petList = QuestUtil.getPetNames(questData);
for (int i=0;i<petList.size();i++)
petComboBox.addItem(petList.get(i));
Set<String> petList = questData.getPetManager().getAvailablePetNames();
for (String s : petList) {
petComboBox.addItem(s);
}
petComboBox.addItem("None");
petComboBox.addItem("No Plant/Pet");
}
@@ -344,7 +340,7 @@ public class Gui_Quest extends JFrame implements NewConstants{
public void execute() {
//saves all deck data
QuestData.saveData(AllZone.QuestData);
AllZone.QuestData.saveData();
new Gui_Quest();
}
@@ -372,7 +368,7 @@ public class Gui_Quest extends JFrame implements NewConstants{
public void execute() {
//saves all deck data
QuestData.saveData(AllZone.QuestData);
AllZone.QuestData.saveData();
new Gui_Quest();
}
@@ -413,16 +409,16 @@ public class Gui_Quest extends JFrame implements NewConstants{
Constant.Runtime.Smooth[0] = smoothLandCheckBox.isSelected();
if (questData.getMode().equals(QuestData.REALISTIC))
if (questData.getMode().equals(forge.quest.data.QuestData.REALISTIC))
AllZone.GameAction.newGame(human, computer);
else
{
Object pet = petComboBox.getSelectedItem();
if (pet != null)
questData.setSelectedPet(pet.toString());
Object petName = petComboBox.getSelectedItem();
if (petName != null)
questData.getPetManager().setSelectedPet((String) petName);
CardList hCl = QuestUtil.getHumanPlantAndPet(questData);
int hLife = QuestUtil.getLife(questData);
CardList hCl = forge.quest.data.QuestUtil.getHumanPlantAndPet(questData);
int hLife = questData.getLife();
AllZone.GameAction.newGame(human, computer, hCl, new CardList(), hLife, 20, null);
}
@@ -448,7 +444,7 @@ public class Gui_Quest extends JFrame implements NewConstants{
Object pet = petComboBox.getSelectedItem();
if (pet != null)
questData.setSelectedPet(pet.toString());
questData.getPetManager().setSelectedPet((String) pet);
Gui_Quest_Assignments g = new Gui_Quest_Assignments(this, human);
g.setVisible(true);

View File

@@ -13,13 +13,12 @@ import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import java.util.ArrayList;
public class Gui_QuestOptions extends JFrame {
private static final long serialVersionUID = 2018518804206822235L;
private QuestData questData = new QuestData();
private forge.quest.data.QuestData questData = new forge.quest.data.QuestData();
private JLabel jLabel1 = new JLabel();
private JButton continueQuestButton = new JButton();
private JPanel jPanel1 = new JPanel();
@@ -79,7 +78,7 @@ public class Gui_QuestOptions extends JFrame {
//show total number of games for each difficulty
private void setupRadioButtonText() {
String[] diff = questData.getDifficutlyChoices();
String[] diff = questData.getDifficultyChoices();
JRadioButton[] b = {easyRadio, mediumRadio, hardRadio, veryHardRadio};
for(int i = 0; i < diff.length; i++) {
@@ -188,7 +187,7 @@ public class Gui_QuestOptions extends JFrame {
void continueQuestButton_actionPerformed(ActionEvent e) {
//set global variable
AllZone.QuestData = QuestData.loadData();
AllZone.QuestData = forge.quest.data.QuestData.loadData();
AllZone.QuestData.setDifficultyIndex();
dispose();
@@ -207,7 +206,7 @@ public class Gui_QuestOptions extends JFrame {
void newQuestButton_actionPerformed(ActionEvent e) {
int difficulty = 0;
String mode = fantasyRadio.isSelected() ? QuestData.FANTASY : QuestData.REALISTIC;
String mode = fantasyRadio.isSelected() ? forge.quest.data.QuestData.FANTASY : forge.quest.data.QuestData.REALISTIC;
if(easyRadio.isSelected()) difficulty = 0;
@@ -234,10 +233,8 @@ public class Gui_QuestOptions extends JFrame {
//give the user a few cards to build a deck
questData.newGame(difficulty, mode);
copyAIDecks(questData, QuestData.loadData());
QuestData.saveData(questData);
questData.saveData();
questData.readAIQuestDeckFiles();
//set global variable
AllZone.QuestData = questData;
@@ -254,9 +251,10 @@ public class Gui_QuestOptions extends JFrame {
}
//copy AI decks from old to newData
void copyAIDecks(QuestData newData, QuestData old) {
ArrayList<String> a = old.ai_getDeckNames();
for(int i = 0; i < a.size(); i++)
newData.ai_addDeck(old.ai_getDeck(a.get(i).toString()));
void copyAIDecks(forge.quest.data.QuestData newData, forge.quest.data.QuestData old) {
java.util.List<String> oldDeckNames = old.ai_getDeckNames();
for (String oldDeckName : oldDeckNames) {
newData.ai_addDeck(old.ai_getDeck(oldDeckName));
}
}
}

View File

@@ -13,6 +13,7 @@ import java.io.File;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Enumeration;
import java.util.List;
public class Gui_Quest_Assignments extends JFrame implements NewConstants{
@@ -26,7 +27,7 @@ public class Gui_Quest_Assignments extends JFrame implements NewConstants{
private ButtonGroup buttonGroup = new ButtonGroup();
private QuestData questData;
private forge.quest.data.QuestData questData;
private Deck hDeck;
@@ -79,11 +80,11 @@ public class Gui_Quest_Assignments extends JFrame implements NewConstants{
read = new ReadQuest_Assignment(ForgeProps.getFile(QUEST.QUESTS), questData);
read.run();
ArrayList<Quest_Assignment> questsToDisplay = new ArrayList<Quest_Assignment>();
List<Quest_Assignment> questsToDisplay = new ArrayList<Quest_Assignment>();
if (questData.getAvailableQuests()!= null && questData.getAvailableQuests().size() > 0)
{
ArrayList<Quest_Assignment> availableQuests = read.getQuestsByIds(questData.getAvailableQuests());
List<Quest_Assignment> availableQuests = read.getQuestsByIds(questData.getAvailableQuests());
questsToDisplay = availableQuests;
/*
@@ -97,7 +98,7 @@ public class Gui_Quest_Assignments extends JFrame implements NewConstants{
else //generate some random quests
{
//System.out.println("null");
ArrayList<Quest_Assignment> allAvailableQuests = read.getQuests();
List<Quest_Assignment> allAvailableQuests = read.getQuests();
ArrayList<Integer> availableInts = new ArrayList<Integer>();
@@ -116,7 +117,7 @@ public class Gui_Quest_Assignments extends JFrame implements NewConstants{
questsToDisplay.add(qa);
}
questData.setAvailableQuests(availableInts);
QuestData.saveData(questData);
questData.saveData();
}//else
JRadioButton radio;
@@ -262,7 +263,7 @@ public class Gui_Quest_Assignments extends JFrame implements NewConstants{
if(Gui_Quest.newGUICheckbox.isSelected()) AllZone.Display = new GuiDisplay4();
else AllZone.Display = new GuiDisplay3();
AllZone.GameAction.newGame(hDeck, computerDeck, QuestUtil.getHumanPlantAndPet(questData, selectedQuest), new CardList(), questData.getLife()+extraLife,
AllZone.GameAction.newGame(hDeck, computerDeck, forge.quest.data.QuestUtil.getHumanPlantAndPet(questData, selectedQuest), new CardList(), questData.getLife()+extraLife,
selectedQuest.getComputerLife(), selectedQuest);
AllZone.Display.setVisible(true);
@@ -278,7 +279,7 @@ public class Gui_Quest_Assignments extends JFrame implements NewConstants{
}
void quitButton_actionPerformed(ActionEvent e) {
//QuestData.saveData(questData);
//questData.saveData();
//new Gui_Shops();
questGui.setVisible(true);

File diff suppressed because it is too large Load Diff

File diff suppressed because it is too large Load Diff

View File

@@ -1,249 +1,244 @@
package forge;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import java.io.File;
import javax.swing.ImageIcon;
import javax.swing.JButton;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.SwingConstants;
import forge.error.ErrorViewer;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
public class Gui_Treasury extends JFrame implements NewConstants{
private static final long serialVersionUID = 2409591658245091210L;
private JFrame shopsGUI;
private JLabel titleLabel = new JLabel();
private JLabel estatesDescLabel = new JLabel();
//private JLabel estatesStatsLabel = new JLabel();
private JLabel estatesPriceLabel = new JLabel();
private JLabel estatesIconLabel = new JLabel();
private JLabel creditsLabel = new JLabel();
private ImageIcon estatesIcon = new ImageIcon();
private JButton learnEstatesButton= new JButton();
private JButton quitButton = new JButton();
private QuestData questData = AllZone.QuestData;
public Gui_Treasury(JFrame parent) {
try {
jbInit();
} catch(Exception ex) {
ErrorViewer.showError(ex);
}
shopsGUI = parent;
setup();
//for some reason, the Bazaar window does not return when closing with X
//for now, just disable X closing:
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
Dimension screen = this.getToolkit().getScreenSize();
setBounds(screen.width / 3, 100, //position
530, 430); //size
setVisible(true);
}
//only do this ONCE:
private void setup() {
learnEstatesButton.setBounds(new Rectangle(10, 297, 120, 50));
learnEstatesButton.setText(getButtonText());
//buyPlantButton.setIcon(icon);
learnEstatesButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
learnEstatesButton_actionPerformed(e);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
}//setup();
private String getDesc()
{
StringBuilder sb = new StringBuilder();
sb.append("<html>");
if (questData.getEstatesLevel() == 0)
{
sb.append("<u>Level 1 Estates</u><br>");
sb.append("Gives a bonus of <b>10%</b> to match winnings.<br>");
sb.append("Improves sell percentage by <b>1.0%</b>.");
}
else if (questData.getEstatesLevel() == 1)
{
sb.append("<u>Level 2 Estates</u><br>");
sb.append("Gives a bonus of <b>15%</b> to match winnings.<br>");
sb.append("Improves sell percentage by <b>1.75%</b>.");
}
else if (questData.getEstatesLevel() == 2)
{
sb.append("<u>Level 3 Estates</u><br>");
sb.append("Gives a bonus of <b>20%</b> to match winnings.<br>");
sb.append("Improves sell percentage by <b>2.5%</b>.");
}
else if (questData.getEstatesLevel() >= 3 && questData.getLuckyCoinLevel() == 0)
{
sb.append("Estates Level Maxed out.<br>");
sb.append("<u><b>Lucky Coin</b></u><br>");
sb.append("This coin is believed to give good luck to its owner.<br>");
sb.append("Improves the chance of getting a random <br>rare after each match by <b>15%</b>.");
/*sb.append("Current Level: 3/3<br>");
sb.append("Gives a bonus of <b>20%</b> to match winnings.<br>");
sb.append("Improves sell percentage by <b>2.5%</b>.");*/
}
else
{
sb.append("Currently nothing for sale at the Treasury. <br>Please check back later.");
}
sb.append("</html>");
return sb.toString();
}
private long getPrice()
{
long l = 0;
if (questData.getEstatesLevel() == 0)
l = 500;
else if (questData.getEstatesLevel() == 1)
l = 750;
else if (questData.getEstatesLevel() == 2)
l = 1000;
else if (questData.getEstatesLevel() >= 3 && questData.getLuckyCoinLevel() == 0)
l = 500;
return l;
}
private String getButtonText()
{
if (questData.getEstatesLevel() < 3)
return "Learn Estates";
else
return "Buy Coin";
}
private String getImageString()
{
if (questData.getEstatesLevel() < 3)
return "GoldIconLarge.png";
else
return "CoinIcon.png";
}
private void jbInit() throws Exception {
titleLabel.setFont(new java.awt.Font("sserif", Font.BOLD, 22));
titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
titleLabel.setText("Treasury");
titleLabel.setBounds(new Rectangle(130, 5, 198, 60));
this.getContentPane().setLayout(null);
/*
potionStatsLabel.setFont(new Font("sserif", Font.BOLD, 12));
potionStatsLabel.setText(getStats());
potionStatsLabel.setBounds(new Rectangle(10, 65, 100, 15));
*/
estatesDescLabel.setFont(new Font("sserif", 0, 12));
estatesDescLabel.setText(getDesc());
estatesDescLabel.setBounds(new Rectangle(10, 80, 300, 150));
estatesPriceLabel.setFont(new Font("sserif", 0, 12));
estatesPriceLabel.setText("<html><b><u>Price</u></b>: " + getPrice() + " credits</html>");
estatesPriceLabel.setBounds(new Rectangle(10, 230, 150, 15));
creditsLabel.setFont(new Font("sserif", 0, 12));
creditsLabel.setText("Credits: " + questData.getCredits());
creditsLabel.setBounds(new Rectangle(10, 265, 150, 15));
estatesIcon = getIcon(getImageString());
estatesIconLabel.setText("");
estatesIconLabel.setIcon(estatesIcon);
estatesIconLabel.setBounds(new Rectangle(255, 65, 256, 256));
estatesIconLabel.setIconTextGap(0);
//String fileName = "LeafIconSmall.png";
//ImageIcon icon = getIcon(fileName);
learnEstatesButton.setEnabled(true);
if (questData.getCredits() < getPrice() || (questData.getEstatesLevel() >= 3 && questData.getLuckyCoinLevel() >= 1))
learnEstatesButton.setEnabled(false);
quitButton.setBounds(new Rectangle(140, 297, 120, 50));
quitButton.setText("Quit");
quitButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
quitButton_actionPerformed(e);
}
});
//jPanel2.add(quitButton, null);
this.getContentPane().add(learnEstatesButton, null);
this.getContentPane().add(titleLabel, null);
this.getContentPane().add(estatesDescLabel, null);
this.getContentPane().add(estatesIconLabel, null);
this.getContentPane().add(estatesPriceLabel, null);
this.getContentPane().add(creditsLabel, null);
this.getContentPane().add(quitButton,null);
}
void learnEstatesButton_actionPerformed(ActionEvent e) throws Exception {
questData.subtractCredits(getPrice());
if (questData.getEstatesLevel() < 3)
{
questData.addEstatesLevel(1);
}
else if (questData.getLuckyCoinLevel() < 1)
{
questData.addLuckyCoinLevel(1);
}
QuestData.saveData(questData);
jbInit();
}
private ImageIcon getIcon(String fileName)
{
File base = ForgeProps.getFile(IMAGE_ICON);
File file = new File(base, fileName);
ImageIcon icon = new ImageIcon(file.toString());
return icon;
}
void quitButton_actionPerformed(ActionEvent e) {
QuestData.saveData(questData);
//new Gui_Shops();
shopsGUI.setVisible(true);
dispose();
}
void this_windowClosing(WindowEvent e) {
quitButton_actionPerformed(null);
}
}
package forge;
import forge.error.ErrorViewer;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import javax.swing.*;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.WindowEvent;
import java.io.File;
public class Gui_Treasury extends JFrame implements NewConstants{
private static final long serialVersionUID = 2409591658245091210L;
private JFrame shopsGUI;
private JLabel titleLabel = new JLabel();
private JLabel estatesDescLabel = new JLabel();
//private JLabel estatesStatsLabel = new JLabel();
private JLabel estatesPriceLabel = new JLabel();
private JLabel estatesIconLabel = new JLabel();
private JLabel creditsLabel = new JLabel();
private ImageIcon estatesIcon = new ImageIcon();
private JButton learnEstatesButton= new JButton();
private JButton quitButton = new JButton();
private forge.quest.data.QuestData questData = AllZone.QuestData;
public Gui_Treasury(JFrame parent) {
try {
jbInit();
} catch(Exception ex) {
ErrorViewer.showError(ex);
}
shopsGUI = parent;
setup();
//for some reason, the Bazaar window does not return when closing with X
//for now, just disable X closing:
this.setDefaultCloseOperation(JFrame.DO_NOTHING_ON_CLOSE);
Dimension screen = this.getToolkit().getScreenSize();
setBounds(screen.width / 3, 100, //position
530, 430); //size
setVisible(true);
}
//only do this ONCE:
private void setup() {
learnEstatesButton.setBounds(new Rectangle(10, 297, 120, 50));
learnEstatesButton.setText(getButtonText());
//buyPlantButton.setIcon(icon);
learnEstatesButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
try {
learnEstatesButton_actionPerformed(e);
} catch (Exception e1) {
// TODO Auto-generated catch block
e1.printStackTrace();
}
}
});
}//setup();
private String getDesc()
{
StringBuilder sb = new StringBuilder();
sb.append("<html>");
if (questData.getEstatesLevel() == 0)
{
sb.append("<u>Level 1 Estates</u><br>");
sb.append("Gives a bonus of <b>10%</b> to match winnings.<br>");
sb.append("Improves sell percentage by <b>1.0%</b>.");
}
else if (questData.getEstatesLevel() == 1)
{
sb.append("<u>Level 2 Estates</u><br>");
sb.append("Gives a bonus of <b>15%</b> to match winnings.<br>");
sb.append("Improves sell percentage by <b>1.75%</b>.");
}
else if (questData.getEstatesLevel() == 2)
{
sb.append("<u>Level 3 Estates</u><br>");
sb.append("Gives a bonus of <b>20%</b> to match winnings.<br>");
sb.append("Improves sell percentage by <b>2.5%</b>.");
}
else if (questData.getEstatesLevel() >= 3 && questData.getLuckyCoinLevel() == 0)
{
sb.append("Estates Level Maxed out.<br>");
sb.append("<u><b>Lucky Coin</b></u><br>");
sb.append("This coin is believed to give good luck to its owner.<br>");
sb.append("Improves the chance of getting a random <br>rare after each match by <b>15%</b>.");
/*sb.append("Current Level: 3/3<br>");
sb.append("Gives a bonus of <b>20%</b> to match winnings.<br>");
sb.append("Improves sell percentage by <b>2.5%</b>.");*/
}
else
{
sb.append("Currently nothing for sale at the Treasury. <br>Please check back later.");
}
sb.append("</html>");
return sb.toString();
}
private long getPrice()
{
long l = 0;
if (questData.getEstatesLevel() == 0)
l = 500;
else if (questData.getEstatesLevel() == 1)
l = 750;
else if (questData.getEstatesLevel() == 2)
l = 1000;
else if (questData.getEstatesLevel() >= 3 && questData.getLuckyCoinLevel() == 0)
l = 500;
return l;
}
private String getButtonText()
{
if (questData.getEstatesLevel() < 3)
return "Learn Estates";
else
return "Buy Coin";
}
private String getImageString()
{
if (questData.getEstatesLevel() < 3)
return "GoldIconLarge.png";
else
return "CoinIcon.png";
}
private void jbInit() throws Exception {
titleLabel.setFont(new java.awt.Font("sserif", Font.BOLD, 22));
titleLabel.setHorizontalAlignment(SwingConstants.CENTER);
titleLabel.setText("Treasury");
titleLabel.setBounds(new Rectangle(130, 5, 198, 60));
this.getContentPane().setLayout(null);
/*
potionStatsLabel.setFont(new Font("sserif", Font.BOLD, 12));
potionStatsLabel.setText(getStats());
potionStatsLabel.setBounds(new Rectangle(10, 65, 100, 15));
*/
estatesDescLabel.setFont(new Font("sserif", 0, 12));
estatesDescLabel.setText(getDesc());
estatesDescLabel.setBounds(new Rectangle(10, 80, 300, 150));
estatesPriceLabel.setFont(new Font("sserif", 0, 12));
estatesPriceLabel.setText("<html><b><u>Price</u></b>: " + getPrice() + " credits</html>");
estatesPriceLabel.setBounds(new Rectangle(10, 230, 150, 15));
creditsLabel.setFont(new Font("sserif", 0, 12));
creditsLabel.setText("Credits: " + questData.getCredits());
creditsLabel.setBounds(new Rectangle(10, 265, 150, 15));
estatesIcon = getIcon(getImageString());
estatesIconLabel.setText("");
estatesIconLabel.setIcon(estatesIcon);
estatesIconLabel.setBounds(new Rectangle(255, 65, 256, 256));
estatesIconLabel.setIconTextGap(0);
//String fileName = "LeafIconSmall.png";
//ImageIcon icon = getIcon(fileName);
learnEstatesButton.setEnabled(true);
if (questData.getCredits() < getPrice() || (questData.getEstatesLevel() >= 3 && questData.getLuckyCoinLevel() >= 1))
learnEstatesButton.setEnabled(false);
quitButton.setBounds(new Rectangle(140, 297, 120, 50));
quitButton.setText("Quit");
quitButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
quitButton_actionPerformed(e);
}
});
//jPanel2.add(quitButton, null);
this.getContentPane().add(learnEstatesButton, null);
this.getContentPane().add(titleLabel, null);
this.getContentPane().add(estatesDescLabel, null);
this.getContentPane().add(estatesIconLabel, null);
this.getContentPane().add(estatesPriceLabel, null);
this.getContentPane().add(creditsLabel, null);
this.getContentPane().add(quitButton,null);
}
void learnEstatesButton_actionPerformed(ActionEvent e) throws Exception {
questData.subtractCredits(getPrice());
if (questData.getEstatesLevel() < 3)
{
questData.addEstatesLevel(1);
}
else if (questData.getLuckyCoinLevel() < 1)
{
questData.addLuckyCoinLevel(1);
}
questData.saveData();
jbInit();
}
private ImageIcon getIcon(String fileName)
{
File base = ForgeProps.getFile(IMAGE_ICON);
File file = new File(base, fileName);
ImageIcon icon = new ImageIcon(file.toString());
return icon;
}
void quitButton_actionPerformed(ActionEvent e) {
questData.saveData();
//new Gui_Shops();
shopsGUI.setVisible(true);
dispose();
}
void this_windowClosing(WindowEvent e) {
quitButton_actionPerformed(null);
}
}

View File

@@ -6,6 +6,8 @@ import forge.error.ErrorViewer;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import forge.properties.NewConstants.LANG.Gui_WinLose.WINLOSE_TEXT;
import forge.quest.data.QuestMatchState;
import forge.quest.data.QuestPreferences;
import forge.quest.gui.QuestFrame;
import net.miginfocom.swing.MigLayout;
@@ -46,8 +48,8 @@ public class Gui_WinLose extends JFrame implements NewConstants {
public static void main(String[] args) {
Constant.Runtime.GameType[0] = Constant.GameType.Sealed;
Constant.Runtime.WinLose.addWin();
Constant.Runtime.WinLose.addLose();
Constant.Runtime.matchState.addWin();
Constant.Runtime.matchState.addLose();
//setup limited deck
Deck deck = new Deck(Constant.GameType.Sealed);
@@ -114,7 +116,7 @@ public class Gui_WinLose extends JFrame implements NewConstants {
private void setup() {
AllZone.GameInfo.clearColorChanges();
WinLose winLose = Constant.Runtime.WinLose;
QuestMatchState winLose = Constant.Runtime.matchState;
Phase.GameBegins = 0;
//3 is the match length, 3 is the number of games
//disable buttons if match is up, or human player won 2 or lost 2 games already
@@ -228,16 +230,16 @@ public class Gui_WinLose extends JFrame implements NewConstants {
else{
int extraLife = 0;
if (AllZone.QuestAssignment != null) {
QuestUtil.setupQuest(AllZone.QuestAssignment);
forge.quest.data.QuestUtil.setupQuest(AllZone.QuestAssignment);
if (AllZone.QuestData.getGearLevel() == 2)
extraLife = 3;
}
//AllZone.GameAction.newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0], humanList, computerList, humanLife, computerLife);
CardList humanList = QuestUtil.getHumanPlantAndPet(AllZone.QuestData, AllZone.QuestAssignment);
CardList humanList = forge.quest.data.QuestUtil.getHumanPlantAndPet(AllZone.QuestData, AllZone.QuestAssignment);
CardList computerList = new CardList();
int humanLife = QuestUtil.getLife(AllZone.QuestData) + extraLife;
int humanLife = AllZone.QuestData.getLife() + extraLife;
int computerLife = 20;
if (AllZone.QuestAssignment!=null)
computerLife = AllZone.QuestAssignment.getComputerLife();
@@ -250,7 +252,7 @@ public class Gui_WinLose extends JFrame implements NewConstants {
}
void restartButton_actionPerformed(ActionEvent e) {
Constant.Runtime.WinLose.reset();
Constant.Runtime.matchState.reset();
if (!Constant.Quest.fantasyQuest[0])
AllZone.GameAction.newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0]);
@@ -258,16 +260,16 @@ public class Gui_WinLose extends JFrame implements NewConstants {
int extraLife = 0;
//AllZone.GameAction.newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0], humanList, computerList, humanLife, computerLife);
if (AllZone.QuestAssignment != null) {
QuestUtil.setupQuest(AllZone.QuestAssignment);
forge.quest.data.QuestUtil.setupQuest(AllZone.QuestAssignment);
if (AllZone.QuestData.getGearLevel() == 2)
extraLife = 3;
}
CardList humanList = QuestUtil.getHumanPlantAndPet(AllZone.QuestData, AllZone.QuestAssignment);
CardList humanList = forge.quest.data.QuestUtil.getHumanPlantAndPet(AllZone.QuestData, AllZone.QuestAssignment);
//CardList computerList = QuestUtil.getComputerCreatures(AllZone.QuestData, AllZone.QuestAssignment);
CardList computerList = new CardList();
int humanLife = QuestUtil.getLife(AllZone.QuestData) +extraLife;
int humanLife = AllZone.QuestData.getLife() +extraLife;
int computerLife = 20;
if (AllZone.QuestAssignment!=null)
@@ -280,7 +282,7 @@ public class Gui_WinLose extends JFrame implements NewConstants {
dispose();
}
private String getWinText(long creds, WinLose winLose, QuestData q)
private String getWinText(long creds, QuestMatchState winLose, forge.quest.data.QuestData q)
{
// todo use q.qdPrefs to write bonus credits in prefs file
StringBuilder sb = new StringBuilder();
@@ -288,7 +290,7 @@ public class Gui_WinLose extends JFrame implements NewConstants {
sb.append("<html>");
QuestData_Prefs qdPrefs = q.qdPrefs;
QuestPreferences qdPrefs = q.getQuestPreferences();
for (String s : wins)
{
@@ -394,11 +396,11 @@ public class Gui_WinLose extends JFrame implements NewConstants {
new Gui_NewGame();
}
else { //Quest
WinLose winLose = Constant.Runtime.WinLose;
QuestData quest = AllZone.QuestData;
QuestMatchState matchState = Constant.Runtime.matchState;
forge.quest.data.QuestData quest = AllZone.QuestData;
boolean wonMatch = false;
if(winLose.getWin() == 2){
if(matchState.getWin() == 2){
quest.addWin();
wonMatch = true;
}
@@ -425,8 +427,8 @@ public class Gui_WinLose extends JFrame implements NewConstants {
}
if (wonMatch){
long creds = quest.getCreditsToAdd(winLose);
String s = getWinText(creds, winLose, quest);
long creds = quest.getCreditsToAdd(matchState);
String s = getWinText(creds, matchState, quest);
String fileName = "GoldIcon.png";
ImageIcon icon = getIcon(fileName);
@@ -489,11 +491,11 @@ public class Gui_WinLose extends JFrame implements NewConstants {
JOptionPane.showMessageDialog(null, "", "You have won a random rare.", JOptionPane.INFORMATION_MESSAGE, icon);
}
winLose.reset();
matchState.reset();
AllZone.QuestAssignment = null;
QuestData.saveData(quest);
quest.saveData();
if (AllZone.QuestData.useNewQuestUI){
new QuestFrame();
}

View File

@@ -1,24 +1,14 @@
package forge;
import java.io.File;
import java.io.FileInputStream;
import java.io.FileOutputStream;
import java.io.ObjectInputStream;
import java.io.ObjectOutputStream;
import java.util.ArrayList;
import java.util.Collections;
import java.util.HashMap;
import java.util.Iterator;
import java.util.Map;
import java.util.Random;
import com.esotericsoftware.minlog.Log;
import forge.error.ErrorViewer;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import java.io.*;
import java.util.*;
//when you create QuestData and AFTER you copy the AI decks over
//you have to call one of these two methods below
@@ -27,6 +17,8 @@ import forge.properties.NewConstants;
//static readAIQuestDeckFiles(QuestData data, ArrayList aiDeckNames)
//OR non-static readAIQuestDeckFiles()
//which reads the files "questDecks-easy", "questDecks-medium","questDecks-hard",
@SuppressWarnings({"deprecation"})
@Deprecated
public class QuestData implements NewConstants {
QuestData_Prefs qdPrefs = null;

View File

@@ -9,6 +9,7 @@ import java.util.*;
//balance the number of colors and creature/spells for
//new cards that are won in quest mode
@Deprecated
public class QuestData_BoosterPack implements NewConstants {
// final private static String comment = "//";

View File

@@ -1,357 +1,358 @@
package forge;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.Serializable;
import forge.properties.ForgeProps;
import forge.properties.NewConstants.QUEST;
public class QuestData_Prefs implements Serializable {
private static final long serialVersionUID = 3266336025656577905L;
private int numDiff = 4;
// Descriptive difficulty names
private String[] sDifficulty = { "Easy", "Normal", "Hard", "Very Hard" };
// Default match wins it takes to gain a booster
private int[] winsForBooster = { 1, 1, 2, 2 };
private int[] winsForRankIncrease = { 1, 2, 3, 4 };
private int[] winsForMediumAI = { 6, 6, 11, 11 };
private int[] winsForHardAI = { 9, 9, 21, 21 };
// Default starting land for a quest
private int startingBasicLand = 20;
private int startingSnowBasicLand = 20;
// Default starting amount of each rarity
private int[] startingCommons = {45, 40, 40, 40};
private int[] startingUncommons = {20, 15, 15, 15};
private int[] startingRares = {10, 10, 10, 10};
private int startingCredits = 250;
private int boosterPackRare = 1;
private int boosterPackUncommon = 3;
private int boosterPackCommon = 9;
private int matchRewardBase = 10;
private double matchRewardTotalWins = 0.3;
private int matchRewardNoLosses = 10;
private int matchRewardPoisonWinBonus = 50;
private int matchRewardMilledWinBonus = 40;
private int matchRewardAltWinBonus = 100;
private int matchRewardWinOnFirstTurn = 1500;
private int matchRewardWinByTurnFive = 250;
private int matchRewardWinByTurnTen = 50;
private int matchRewardWinByTurnFifteen = 5;
private int matchRewardMullToZero = 500;
public QuestData_Prefs()
{
// if quest.prefs exists
grabPrefsFromFile();
}
public void grabPrefsFromFile(){
try{
BufferedReader input = new BufferedReader(new FileReader(ForgeProps.getFile(QUEST.PREFS)));
String line = null;
while((line = input.readLine()) != null){
if (line.startsWith("#") || line.length() == 0)
continue;
String[] split = line.split("=");
if (split[0].equals("difficultyString"))
setDifficulty(split[1]);
else if (split[0].equals("winsForBooster"))
setWinsForBooster(split[1]);
else if (split[0].equals("winsForRankIncrease"))
setWinsForRank(split[1]);
else if (split[0].equals("winsForMediumAI"))
setWinsForMediumAI(split[1]);
else if (split[0].equals("winsForHardAI"))
setWinsForHardAI(split[1]);
else if (split[0].equals("startingBasicLand"))
setStartingBasic(split[1]);
else if (split[0].equals("startingSnowBasicLand"))
setStartingSnowBasic(split[1]);
else if (split[0].equals("startingCommons"))
setStartingCommons(split[1]);
else if (split[0].equals("startingUncommons"))
setStartingUncommons(split[1]);
else if (split[0].equals("startingRares"))
setStartingRares(split[1]);
else if (split[0].equals("startingCredits"))
setStartingCredits(split[1]);
else if (split[0].equals("boosterPackCommon"))
setNumCommon(split[1]);
else if (split[0].equals("boosterPackUncommon"))
setNumUncommon(split[1]);
else if (split[0].equals("boosterPackRare"))
setNumRares(split[1]);
else if (split[0].equals("matchRewardBase"))
setMatchRewardBase(split[1]);
else if (split[0].equals("matchRewardTotalWins"))
setMatchRewardTotalWins(split[1]);
else if (split[0].equals("matchRewardNoLosses"))
setMatchRewardNoLosses(split[1]);
else if (split[0].equals("matchRewardMilledWinBonus"))
setMatchRewardMilledWinBonus(split[1]);
else if (split[0].equals("matchRewardPoisonWinBonus"))
setMatchRewardPoisonWinBonus(split[1]);
else if (split[0].equals("matchRewardAltWinBonus"))
setMatchRewardAltWinBonus(split[1]);
else if (split[0].equals("matchRewardWinOnFirstTurn"))
setMatchRewardWinFirst(split[1]);
else if (split[0].equals("matchRewardWinByTurnFive"))
setMatchRewardWinByFifth(split[1]);
else if (split[0].equals("matchRewardWinByTurnTen"))
setMatchRewardWinByTen(split[1]);
else if (split[0].equals("matchRewardWinByTurnFifteen"))
setMatchRewardWinByFifteen(split[1]);
else if (split[0].equals("matchRewardMullToZero"))
setMatchMullToZero(split[1]);
}
}
catch(Exception e)
{
System.out.println("Trouble grabbing quest data preferences. Using default values.");
}
}
// getters
public String[] getDifficulty(){
return sDifficulty;
}
public String getDifficulty(int index){
return sDifficulty[index];
}
public int getWinsForBooster(int index){
return winsForBooster[index];
}
public int getWinsForRankIncrease(int index){
return winsForRankIncrease[index];
}
public int getWinsForMediumAI(int index){
return winsForMediumAI[index];
}
public int getWinsForHardAI(int index){
return winsForHardAI[index];
}
public int getStartingBasic(){
return startingBasicLand;
}
public int getStartingSnowBasic(){
return startingSnowBasicLand;
}
public int getStartingCommons(int index){
return startingCommons[index];
}
public int getStartingUncommons(int index){
return startingUncommons[index];
}
public int getStartingRares(int index){
return startingRares[index];
}
public int getStartingCredits(){
return startingCredits;
}
public int getNumCommon(){
return boosterPackCommon;
}
public int getNumUncommon(){
return boosterPackUncommon;
}
public int getNumRare(){
return boosterPackRare;
}
public int getMatchRewardBase(){
return matchRewardBase;
}
public double getMatchRewardTotalWins(){
return matchRewardTotalWins;
}
public int getMatchRewardNoLosses(){
return matchRewardNoLosses;
}
public int getMatchRewardPoisonWinBonus(){
return matchRewardPoisonWinBonus;
}
public int getMatchRewardMilledWinBonus(){
return matchRewardMilledWinBonus;
}
public int getMatchRewardAltWinBonus(){
return matchRewardAltWinBonus;
}
public int getMatchRewardWinFirst(){
return matchRewardWinOnFirstTurn;
}
public int getMatchRewardWinByFifth(){
return matchRewardWinByTurnFive;
}
public int getMatchRewardWinByTen(){
return matchRewardWinByTurnTen;
}
public int getMatchRewardWinByFifteen(){
return matchRewardWinByTurnFifteen;
}
public int getMatchMullToZero(){
return matchRewardMullToZero;
}
// setters
public void setDifficulty(String diff){
this.sDifficulty = diff.split(",");
}
public void setWinsForBooster(String wins){
String[] winsStr = wins.split(",");
for(int i = 0; i < numDiff; i++)
this.winsForBooster[i] = Integer.parseInt(winsStr[i]);
}
public void setWinsForRank(String wins){
String[] winsStr = wins.split(",");
for(int i = 0; i < numDiff; i++)
this.winsForRankIncrease[i] = Integer.parseInt(winsStr[i]);
}
public void setWinsForMediumAI(String wins){
String[] winsStr = wins.split(",");
for(int i = 0; i < numDiff; i++)
this.winsForMediumAI[i] = Integer.parseInt(winsStr[i]);
}
public void setWinsForHardAI(String wins){
String[] winsStr = wins.split(",");
for(int i = 0; i < numDiff; i++)
this.winsForHardAI[i] = Integer.parseInt(winsStr[i]);
}
public void setStartingBasic(String land){
this.startingBasicLand = Integer.parseInt(land);
}
public void setStartingSnowBasic(String land){
this.startingSnowBasicLand = Integer.parseInt(land);
}
public void setStartingCommons(String rarity){
String[] splitStr = rarity.split(",");
for(int i = 0; i < numDiff; i++)
this.startingCommons[i] = Integer.parseInt(splitStr[i]);
}
public void setStartingUncommons(String rarity){
String[] splitStr = rarity.split(",");
for(int i = 0; i < numDiff; i++)
this.startingUncommons[i] = Integer.parseInt(splitStr[i]);
}
public void setStartingRares(String rarity){
String[] splitStr = rarity.split(",");
for(int i = 0; i < numDiff; i++)
this.startingRares[i] = Integer.parseInt(splitStr[i]);
}
public void setStartingCredits(String credits){
this.startingCredits = Integer.parseInt(credits);
}
public void setNumCommon(String pack){
this.boosterPackCommon = Integer.parseInt(pack);
}
public void setNumUncommon(String pack){
this.boosterPackUncommon = Integer.parseInt(pack);
}
public void setNumRares(String pack){
this.boosterPackRare = Integer.parseInt(pack);
}
public void setMatchRewardBase(String match){
this.matchRewardBase = Integer.parseInt(match);
}
public void setMatchRewardTotalWins(String match){
this.matchRewardTotalWins = Double.parseDouble(match);
}
public void setMatchRewardNoLosses(String match){
this.matchRewardNoLosses = Integer.parseInt(match);
}
public void setMatchRewardPoisonWinBonus(String match){
this.matchRewardPoisonWinBonus = Integer.parseInt(match);
}
public void setMatchRewardMilledWinBonus(String match){
this.matchRewardMilledWinBonus = Integer.parseInt(match);
}
public void setMatchRewardAltWinBonus(String match){
this.matchRewardAltWinBonus = Integer.parseInt(match);
}
public void setMatchRewardWinFirst(String match){
this.matchRewardWinOnFirstTurn = Integer.parseInt(match);
}
public void setMatchRewardWinByFifth(String match){
this.matchRewardWinByTurnFive = Integer.parseInt(match);
}
public void setMatchRewardWinByTen(String match){
this.matchRewardWinByTurnTen = Integer.parseInt(match);
}
public void setMatchRewardWinByFifteen(String match){
this.matchRewardWinByTurnFifteen = Integer.parseInt(match);
}
public void setMatchMullToZero(String match){
this.matchRewardMullToZero = Integer.parseInt(match);
}
}
package forge;
import forge.properties.ForgeProps;
import forge.properties.NewConstants.QUEST;
import java.io.BufferedReader;
import java.io.FileReader;
import java.io.Serializable;
@Deprecated
public class QuestData_Prefs implements Serializable {
private static final long serialVersionUID = 3266336025656577905L;
private int numDiff = 4;
// Descriptive difficulty names
private String[] sDifficulty = { "Easy", "Normal", "Hard", "Very Hard" };
// Default match wins it takes to gain a booster
private int[] winsForBooster = { 1, 1, 2, 2 };
private int[] winsForRankIncrease = { 1, 2, 3, 4 };
private int[] winsForMediumAI = { 6, 6, 11, 11 };
private int[] winsForHardAI = { 9, 9, 21, 21 };
// Default starting land for a quest
private int startingBasicLand = 20;
private int startingSnowBasicLand = 20;
// Default starting amount of each rarity
private int[] startingCommons = {45, 40, 40, 40};
private int[] startingUncommons = {20, 15, 15, 15};
private int[] startingRares = {10, 10, 10, 10};
private int startingCredits = 250;
private int boosterPackRare = 1;
private int boosterPackUncommon = 3;
private int boosterPackCommon = 9;
private int matchRewardBase = 10;
private double matchRewardTotalWins = 0.3;
private int matchRewardNoLosses = 10;
private int matchRewardPoisonWinBonus = 50;
private int matchRewardMilledWinBonus = 40;
private int matchRewardAltWinBonus = 100;
private int matchRewardWinOnFirstTurn = 1500;
private int matchRewardWinByTurnFive = 250;
private int matchRewardWinByTurnTen = 50;
private int matchRewardWinByTurnFifteen = 5;
private int matchRewardMullToZero = 500;
public QuestData_Prefs()
{
// if quest.prefs exists
grabPrefsFromFile();
}
public void grabPrefsFromFile(){
try{
BufferedReader input = new BufferedReader(new FileReader(ForgeProps.getFile(QUEST.PREFS)));
String line = null;
while((line = input.readLine()) != null){
if (line.startsWith("#") || line.length() == 0)
continue;
String[] split = line.split("=");
if (split[0].equals("difficultyString"))
setDifficulty(split[1]);
else if (split[0].equals("winsForBooster"))
setWinsForBooster(split[1]);
else if (split[0].equals("winsForRankIncrease"))
setWinsForRank(split[1]);
else if (split[0].equals("winsForMediumAI"))
setWinsForMediumAI(split[1]);
else if (split[0].equals("winsForHardAI"))
setWinsForHardAI(split[1]);
else if (split[0].equals("startingBasicLand"))
setStartingBasic(split[1]);
else if (split[0].equals("startingSnowBasicLand"))
setStartingSnowBasic(split[1]);
else if (split[0].equals("startingCommons"))
setStartingCommons(split[1]);
else if (split[0].equals("startingUncommons"))
setStartingUncommons(split[1]);
else if (split[0].equals("startingRares"))
setStartingRares(split[1]);
else if (split[0].equals("startingCredits"))
setStartingCredits(split[1]);
else if (split[0].equals("boosterPackCommon"))
setNumCommon(split[1]);
else if (split[0].equals("boosterPackUncommon"))
setNumUncommon(split[1]);
else if (split[0].equals("boosterPackRare"))
setNumRares(split[1]);
else if (split[0].equals("matchRewardBase"))
setMatchRewardBase(split[1]);
else if (split[0].equals("matchRewardTotalWins"))
setMatchRewardTotalWins(split[1]);
else if (split[0].equals("matchRewardNoLosses"))
setMatchRewardNoLosses(split[1]);
else if (split[0].equals("matchRewardMilledWinBonus"))
setMatchRewardMilledWinBonus(split[1]);
else if (split[0].equals("matchRewardPoisonWinBonus"))
setMatchRewardPoisonWinBonus(split[1]);
else if (split[0].equals("matchRewardAltWinBonus"))
setMatchRewardAltWinBonus(split[1]);
else if (split[0].equals("matchRewardWinOnFirstTurn"))
setMatchRewardWinFirst(split[1]);
else if (split[0].equals("matchRewardWinByTurnFive"))
setMatchRewardWinByFifth(split[1]);
else if (split[0].equals("matchRewardWinByTurnTen"))
setMatchRewardWinByTen(split[1]);
else if (split[0].equals("matchRewardWinByTurnFifteen"))
setMatchRewardWinByFifteen(split[1]);
else if (split[0].equals("matchRewardMullToZero"))
setMatchMullToZero(split[1]);
}
}
catch(Exception e)
{
System.out.println("Trouble grabbing quest data preferences. Using default values.");
}
}
// getters
public String[] getDifficulty(){
return sDifficulty;
}
public String getDifficulty(int index){
return sDifficulty[index];
}
public int getWinsForBooster(int index){
return winsForBooster[index];
}
public int getWinsForRankIncrease(int index){
return winsForRankIncrease[index];
}
public int getWinsForMediumAI(int index){
return winsForMediumAI[index];
}
public int getWinsForHardAI(int index){
return winsForHardAI[index];
}
public int getStartingBasic(){
return startingBasicLand;
}
public int getStartingSnowBasic(){
return startingSnowBasicLand;
}
public int getStartingCommons(int index){
return startingCommons[index];
}
public int getStartingUncommons(int index){
return startingUncommons[index];
}
public int getStartingRares(int index){
return startingRares[index];
}
public int getStartingCredits(){
return startingCredits;
}
public int getNumCommon(){
return boosterPackCommon;
}
public int getNumUncommon(){
return boosterPackUncommon;
}
public int getNumRare(){
return boosterPackRare;
}
public int getMatchRewardBase(){
return matchRewardBase;
}
public double getMatchRewardTotalWins(){
return matchRewardTotalWins;
}
public int getMatchRewardNoLosses(){
return matchRewardNoLosses;
}
public int getMatchRewardPoisonWinBonus(){
return matchRewardPoisonWinBonus;
}
public int getMatchRewardMilledWinBonus(){
return matchRewardMilledWinBonus;
}
public int getMatchRewardAltWinBonus(){
return matchRewardAltWinBonus;
}
public int getMatchRewardWinFirst(){
return matchRewardWinOnFirstTurn;
}
public int getMatchRewardWinByFifth(){
return matchRewardWinByTurnFive;
}
public int getMatchRewardWinByTen(){
return matchRewardWinByTurnTen;
}
public int getMatchRewardWinByFifteen(){
return matchRewardWinByTurnFifteen;
}
public int getMatchMullToZero(){
return matchRewardMullToZero;
}
// setters
public void setDifficulty(String diff){
this.sDifficulty = diff.split(",");
}
public void setWinsForBooster(String wins){
String[] winsStr = wins.split(",");
for(int i = 0; i < numDiff; i++)
this.winsForBooster[i] = Integer.parseInt(winsStr[i]);
}
public void setWinsForRank(String wins){
String[] winsStr = wins.split(",");
for(int i = 0; i < numDiff; i++)
this.winsForRankIncrease[i] = Integer.parseInt(winsStr[i]);
}
public void setWinsForMediumAI(String wins){
String[] winsStr = wins.split(",");
for(int i = 0; i < numDiff; i++)
this.winsForMediumAI[i] = Integer.parseInt(winsStr[i]);
}
public void setWinsForHardAI(String wins){
String[] winsStr = wins.split(",");
for(int i = 0; i < numDiff; i++)
this.winsForHardAI[i] = Integer.parseInt(winsStr[i]);
}
public void setStartingBasic(String land){
this.startingBasicLand = Integer.parseInt(land);
}
public void setStartingSnowBasic(String land){
this.startingSnowBasicLand = Integer.parseInt(land);
}
public void setStartingCommons(String rarity){
String[] splitStr = rarity.split(",");
for(int i = 0; i < numDiff; i++)
this.startingCommons[i] = Integer.parseInt(splitStr[i]);
}
public void setStartingUncommons(String rarity){
String[] splitStr = rarity.split(",");
for(int i = 0; i < numDiff; i++)
this.startingUncommons[i] = Integer.parseInt(splitStr[i]);
}
public void setStartingRares(String rarity){
String[] splitStr = rarity.split(",");
for(int i = 0; i < numDiff; i++)
this.startingRares[i] = Integer.parseInt(splitStr[i]);
}
public void setStartingCredits(String credits){
this.startingCredits = Integer.parseInt(credits);
}
public void setNumCommon(String pack){
this.boosterPackCommon = Integer.parseInt(pack);
}
public void setNumUncommon(String pack){
this.boosterPackUncommon = Integer.parseInt(pack);
}
public void setNumRares(String pack){
this.boosterPackRare = Integer.parseInt(pack);
}
public void setMatchRewardBase(String match){
this.matchRewardBase = Integer.parseInt(match);
}
public void setMatchRewardTotalWins(String match){
this.matchRewardTotalWins = Double.parseDouble(match);
}
public void setMatchRewardNoLosses(String match){
this.matchRewardNoLosses = Integer.parseInt(match);
}
public void setMatchRewardPoisonWinBonus(String match){
this.matchRewardPoisonWinBonus = Integer.parseInt(match);
}
public void setMatchRewardMilledWinBonus(String match){
this.matchRewardMilledWinBonus = Integer.parseInt(match);
}
public void setMatchRewardAltWinBonus(String match){
this.matchRewardAltWinBonus = Integer.parseInt(match);
}
public void setMatchRewardWinFirst(String match){
this.matchRewardWinOnFirstTurn = Integer.parseInt(match);
}
public void setMatchRewardWinByFifth(String match){
this.matchRewardWinByTurnFive = Integer.parseInt(match);
}
public void setMatchRewardWinByTen(String match){
this.matchRewardWinByTurnTen = Integer.parseInt(match);
}
public void setMatchRewardWinByFifteen(String match){
this.matchRewardWinByTurnFifteen = Integer.parseInt(match);
}
public void setMatchMullToZero(String match){
this.matchRewardMullToZero = Integer.parseInt(match);
}
}

View File

@@ -20,6 +20,9 @@ import java.util.Map;
* @version V0.0 26.10.2009
* @author Clemens Koza
*/
@Deprecated
public class QuestData_State implements Serializable {
private static final long serialVersionUID = 7007940230351051937L;

File diff suppressed because it is too large Load Diff

View File

@@ -1,194 +1,195 @@
package forge;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import forge.error.ErrorViewer;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
public class ReadQuest_Assignment implements Runnable, NewConstants {
private BufferedReader in;
private ArrayList<Quest_Assignment> allQuests = new ArrayList<Quest_Assignment>();
private int totalWins;
private ArrayList<Integer> completedQuests = new ArrayList<Integer>();
public static void main(String args[]) throws Exception {
try {
ReadQuest_Assignment read = new ReadQuest_Assignment(ForgeProps.getFile(QUEST.QUESTS), null);
javax.swing.SwingUtilities.invokeAndWait(read);
// read.run();
Quest_Assignment qa[] = new Quest_Assignment[read.allQuests.size()];
read.allQuests.toArray(qa);
for(int i = 0; i < qa.length; i++) {
System.out.println(qa[i].getId());
System.out.println(qa[i].getName());
System.out.println(qa[i].getDesc());
System.out.println(qa[i].getDifficulty());
System.out.println(qa[i].isRepeatable());
System.out.println(qa[i].getRequiredNumberWins());
}
} catch(Exception ex) {
ErrorViewer.showError(ex);
System.out.println("Error reading file " + ex);
}
}
public ArrayList<Quest_Assignment> getQuests() {
return new ArrayList<Quest_Assignment>(allQuests);
}
public ArrayList<Quest_Assignment> getQuestsByIds(ArrayList<Integer> availableQuestIds) {
ArrayList<Quest_Assignment> quests = new ArrayList<Quest_Assignment>();
for(Quest_Assignment qa:allQuests)
{
if (availableQuestIds.contains(qa.getId()))
quests.add(qa);
}
return quests;
}
public Quest_Assignment getQuestById(int i)
{
for(Quest_Assignment qa:allQuests)
{
if (qa.getId() == i)
return qa;
}
return null;
}
/*
public Quest_Assignment getQuestById(int id) {
return allQuests.get(id);
}
*/
public ReadQuest_Assignment(String filename, QuestData questData) {
this(new File(filename), questData);
}
public ReadQuest_Assignment(File file, QuestData questData) {
if (questData != null) {
totalWins = questData.getWin();
if (questData.getCompletedQuests() != null)
completedQuests = questData.getCompletedQuests();
else
completedQuests = new ArrayList<Integer>();
}
if(!file.exists())
throw new RuntimeException("ReadQuest_Assignment : constructor error -- file not found -- filename is "
+ file.getAbsolutePath());
//makes the checked exception, into an unchecked runtime exception
try {
in = new BufferedReader(new FileReader(file));
} catch(Exception ex) {
ErrorViewer.showError(ex, "File \"%s\" not found", file.getAbsolutePath());
throw new RuntimeException("ReadQuest_Assignment : constructor error -- file not found -- filename is "
+ file.getPath());
}
}//ReadCard()
/* id
* name
* desc
* difficulty
* repeatable
* numberWinsRequired
* cardReward
* creditsReward
*/
public void run() {
Quest_Assignment qa;
String s = readLine();
ArrayList<Integer> ids = new ArrayList<Integer>();
while(!s.equals("End")) {
qa = new Quest_Assignment();
if(s.equals("")) throw new RuntimeException("ReadQuest_Assignment : run() reading error, id is blank");
int id = Integer.parseInt(s);
qa.setId(id);
s = readLine();
qa.setName(s);
s = readLine();
qa.setDesc(s);
s = readLine();
qa.setDifficulty(s);
if (qa.getDifficulty().equals("Medium"))
qa.setComputerLife(25);
else if (qa.getDifficulty().equals("Hard"))
qa.setComputerLife(30);
else if (qa.getDifficulty().equals("Very Hard"))
qa.setComputerLife(35);
else if (qa.getDifficulty().equals("Expert"))
qa.setComputerLife(50);
else if (qa.getDifficulty().equals("Insane"))
qa.setComputerLife(100);
s = readLine();
if (s.equals("Repeatable"))
qa.setRepeatable(true);
else
qa.setRepeatable(false);
s = readLine();
int wins = Integer.valueOf(s);
qa.setRequiredNumberWins(wins);
s = readLine();
qa.setCardReward(s);
s = readLine();
long reward = Long.parseLong(s.trim());
qa.setCreditsReward(reward);
s = readLine();
qa.setIconName(s);
//s = readLine();
s = readLine();
if(ids.contains(qa.getId())) {
System.out.println("ReadQuest_Assignment:run() error - duplicate card name: " + qa.getId());
throw new RuntimeException("ReadQuest_Assignment:run() error - duplicate card name: " + qa.getId());
}
ids.add(qa.getId());
if (qa.getRequiredNumberWins() <= totalWins && !completedQuests.contains(qa.getId()) ) {
QuestUtil.setupQuest(qa);
allQuests.add(qa);
}
//id:
s = readLine();
}
}//run()
private String readLine() {
//makes the checked exception, into an unchecked runtime exception
try {
String s = in.readLine();
if(s != null) s = s.trim();
return s;
} catch(Exception ex) {
ErrorViewer.showError(ex);
throw new RuntimeException("ReadQuest_Assignment: readLine(Quest_Assignment) error");
}
}//readLine(Quest_Assignment)
package forge;
import forge.error.ErrorViewer;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import java.io.BufferedReader;
import java.io.File;
import java.io.FileReader;
import java.util.ArrayList;
import java.util.List;
public class ReadQuest_Assignment implements Runnable, NewConstants {
private BufferedReader in;
private ArrayList<Quest_Assignment> allQuests = new ArrayList<Quest_Assignment>();
private int totalWins;
private List<Integer> completedQuests = new ArrayList<Integer>();
public static void main(String args[]) throws Exception {
try {
ReadQuest_Assignment read = new ReadQuest_Assignment(ForgeProps.getFile(QUEST.QUESTS), null);
javax.swing.SwingUtilities.invokeAndWait(read);
// read.run();
Quest_Assignment qa[] = new Quest_Assignment[read.allQuests.size()];
read.allQuests.toArray(qa);
for(int i = 0; i < qa.length; i++) {
System.out.println(qa[i].getId());
System.out.println(qa[i].getName());
System.out.println(qa[i].getDesc());
System.out.println(qa[i].getDifficulty());
System.out.println(qa[i].isRepeatable());
System.out.println(qa[i].getRequiredNumberWins());
}
} catch(Exception ex) {
ErrorViewer.showError(ex);
System.out.println("Error reading file " + ex);
}
}
public List<Quest_Assignment> getQuests() {
return new ArrayList<Quest_Assignment>(allQuests);
}
public List<Quest_Assignment> getQuestsByIds(List<Integer> availableQuestIds) {
List<Quest_Assignment> quests = new ArrayList<Quest_Assignment>();
for(Quest_Assignment qa:allQuests)
{
if (availableQuestIds.contains(qa.getId()))
quests.add(qa);
}
return quests;
}
public Quest_Assignment getQuestById(int i)
{
for(Quest_Assignment qa:allQuests)
{
if (qa.getId() == i)
return qa;
}
return null;
}
/*
public Quest_Assignment getQuestById(int id) {
return allQuests.get(id);
}
*/
public ReadQuest_Assignment(String filename, forge.quest.data.QuestData questData) {
this(new File(filename), questData);
}
public ReadQuest_Assignment(File file, forge.quest.data.QuestData questData) {
if (questData != null) {
totalWins = questData.getWin();
if (questData.getCompletedQuests() != null)
completedQuests = questData.getCompletedQuests();
else
completedQuests = new ArrayList<Integer>();
}
if(!file.exists())
throw new RuntimeException("ReadQuest_Assignment : constructor error -- file not found -- filename is "
+ file.getAbsolutePath());
//makes the checked exception, into an unchecked runtime exception
try {
in = new BufferedReader(new FileReader(file));
} catch(Exception ex) {
ErrorViewer.showError(ex, "File \"%s\" not found", file.getAbsolutePath());
throw new RuntimeException("ReadQuest_Assignment : constructor error -- file not found -- filename is "
+ file.getPath());
}
}//ReadCard()
/* id
* name
* desc
* difficulty
* repeatable
* numberWinsRequired
* cardReward
* creditsReward
*/
public void run() {
Quest_Assignment qa;
String s = readLine();
ArrayList<Integer> ids = new ArrayList<Integer>();
while(!s.equals("End")) {
qa = new Quest_Assignment();
if(s.equals("")) throw new RuntimeException("ReadQuest_Assignment : run() reading error, id is blank");
int id = Integer.parseInt(s);
qa.setId(id);
s = readLine();
qa.setName(s);
s = readLine();
qa.setDesc(s);
s = readLine();
qa.setDifficulty(s);
if (qa.getDifficulty().equals("Medium"))
qa.setComputerLife(25);
else if (qa.getDifficulty().equals("Hard"))
qa.setComputerLife(30);
else if (qa.getDifficulty().equals("Very Hard"))
qa.setComputerLife(35);
else if (qa.getDifficulty().equals("Expert"))
qa.setComputerLife(50);
else if (qa.getDifficulty().equals("Insane"))
qa.setComputerLife(100);
s = readLine();
if (s.equals("Repeatable"))
qa.setRepeatable(true);
else
qa.setRepeatable(false);
s = readLine();
int wins = Integer.valueOf(s);
qa.setRequiredNumberWins(wins);
s = readLine();
qa.setCardReward(s);
s = readLine();
long reward = Long.parseLong(s.trim());
qa.setCreditsReward(reward);
s = readLine();
qa.setIconName(s);
//s = readLine();
s = readLine();
if(ids.contains(qa.getId())) {
System.out.println("ReadQuest_Assignment:run() error - duplicate card name: " + qa.getId());
throw new RuntimeException("ReadQuest_Assignment:run() error - duplicate card name: " + qa.getId());
}
ids.add(qa.getId());
if (qa.getRequiredNumberWins() <= totalWins && !completedQuests.contains(qa.getId()) ) {
forge.quest.data.QuestUtil.setupQuest(qa);
allQuests.add(qa);
}
//id:
s = readLine();
}
}//run()
private String readLine() {
//makes the checked exception, into an unchecked runtime exception
try {
String s = in.readLine();
if(s != null) s = s.trim();
return s;
} catch(Exception ex) {
ErrorViewer.showError(ex);
throw new RuntimeException("ReadQuest_Assignment: readLine(Quest_Assignment) error");
}
}//readLine(Quest_Assignment)
}

View File

@@ -1,4 +1,5 @@
package forge;
@Deprecated
public class WinLose
{
//the way wins were achieved:

View File

@@ -1,28 +1,19 @@
package forge.gui;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.Frame;
import java.awt.Image;
import java.awt.Rectangle;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Collection;
import java.util.List;
import javax.swing.Box;
import javax.swing.ImageIcon;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import forge.AllZone;
import forge.Card;
import forge.properties.ForgeProps;
import forge.properties.NewConstants;
import javax.swing.*;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
import java.awt.*;
import java.awt.image.BufferedImage;
import java.io.File;
import java.util.Collection;
import java.util.List;
public class GuiUtils {
@@ -87,11 +78,11 @@ public class GuiUtils {
public static ImageIcon getIconFromFile(String iconName) {
File base = ForgeProps.getFile(NewConstants.IMAGE_ICON);
File file = new File(base, iconName);
if (file.exists()) {
return new ImageIcon(file.toString());
if (iconName.equals("") || !file.exists()) {
return null;
}
else {
return null;
return new ImageIcon(file.toString());
}
}

View File

@@ -14,66 +14,60 @@ import java.util.zip.GZIPInputStream;
import java.util.zip.GZIPOutputStream;
//when you create QuestData 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
//see Gui_QuestOptions for more details
//
//static readAIQuestDeckFiles(QuestData data, ArrayList aiDeckNames)
//static readAIQuestDeckFiles(QuestDataOld data, ArrayList aiDeckNames)
//OR non-static readAIQuestDeckFiles()
//which reads the files "questDecks-easy", "questDecks-medium","questDecks-hard",
public class QuestData {
QuestPreferences qdPrefs = null;
QuestPreferences preferences = null;
private int rankIndex;
private int win;
private int lost;
private List<QuestPetAbstract> pets;
private QuestPetAbstract selectedPet;
private int life;
private int estatesLevel;
private int luckyCoinLevel;
private int sleightOfHandLevel;
private int gearLevel;
private int questsPlayed;
private long credits;
private int diffIndex;
private String difficulty;
private String mode = "";
private transient ArrayList<String> easyAIDecks;
private transient ArrayList<String> mediumAIDecks;
private transient ArrayList<String> hardAIDecks;
private transient Map<String, Deck> aiDecks;
private transient List<String> easyAIDecks;
private transient List<String> mediumAIDecks;
private transient List<String> hardAIDecks;
private Map<String, Deck> myDecks = new HashMap<String, Deck>();
private transient Map<String, Deck> aiDecks = new HashMap<String, Deck>();
//holds String card names
private ArrayList<String> cardPool = new ArrayList<String>();
private ArrayList<String> newCardList = new ArrayList<String>();
private ArrayList<String> shopList = new ArrayList<String>();
private List<String> cardPool = new ArrayList<String>();
private List<String> newCardList = new ArrayList<String>();
private ArrayList<Integer> availableQuests = new ArrayList<Integer>();
private ArrayList<Integer> completedQuests = new ArrayList<Integer>();
private List<String> shopList = new ArrayList<String>();
private List<Integer> availableQuests = new ArrayList<Integer>();
private transient QuestBoosterPack boosterPack = new QuestBoosterPack();
private List<Integer> completedQuests = new ArrayList<Integer>();
private transient QuestBoosterPack boosterPack;
//used by shouldAddAdditionalCards()
private Random random = new Random();
//feel free to change this to something funnier
private transient String[] rankArray = {
"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", "Saltblasted for your talent", "Serra Angel is your girlfriend",};
//feel free to change this to something funnier
private transient String[] rankArray;
public static final String FANTASY = "Fantasy";
public static final String REALISTIC = "Realistic";
@@ -81,10 +75,12 @@ public class QuestData {
//TODO: Temporary.
public boolean useNewQuestUI = false;
public QuestData() {
qdPrefs = new QuestPreferences();
public final QuestPetManager petManager = new QuestPetManager();
for (int i = 0; i < qdPrefs.getStartingBasic(); i++) {
public QuestData() {
preferences = new QuestPreferences();
for (int i = 0; i < preferences.getStartingBasic(); i++) {
cardPool.add("Forest");
cardPool.add("Mountain");
cardPool.add("Swamp");
@@ -92,7 +88,7 @@ public class QuestData {
cardPool.add("Plains");
}
for (int i = 0; i < qdPrefs.getStartingSnowBasic(); i++) {
for (int i = 0; i < preferences.getStartingSnowBasic(); i++) {
cardPool.add("Snow-Covered Forest");
cardPool.add("Snow-Covered Mountain");
cardPool.add("Snow-Covered Swamp");
@@ -100,21 +96,46 @@ public class QuestData {
cardPool.add("Snow-Covered Plains");
}
readAIQuestDeckFiles();
}//QuestData
initTransients();
}
private void initTransients() {
aiDecks = new HashMap<String, Deck>();
List<String> aiDeckNames = ai_getDeckNames();
easyAIDecks = readFile(ForgeProps.getFile(NewConstants.QUEST.EASY), aiDeckNames);
mediumAIDecks = readFile(ForgeProps.getFile(NewConstants.QUEST.MEDIUM), aiDeckNames);
hardAIDecks = readFile(ForgeProps.getFile(NewConstants.QUEST.HARD), aiDeckNames);
rankArray = 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",
"Saltblasted for your talent",
"Serra Angel is your girlfriend",};
boosterPack = new QuestBoosterPack();
}
//adds cards to card pool and sets difficulty
public void newGame(int difficulty, String m) {
setDifficulty(difficulty);
ArrayList<String> list = new ArrayList<String>();
list.addAll(boosterPack.getCommon(qdPrefs.getStartingCommons(difficulty)));
list.addAll(boosterPack.getUncommon(qdPrefs.getStartingUncommons(difficulty)));
list.addAll(boosterPack.getRare(qdPrefs.getStartingRares(difficulty)));
list.addAll(boosterPack.getCommon(preferences.getStartingCommons(difficulty)));
list.addAll(boosterPack.getUncommon(preferences.getStartingUncommons(difficulty)));
list.addAll(boosterPack.getRare(preferences.getStartingRares(difficulty)));
//because cardPool already has basic land added to it
cardPool.addAll(list);
credits = qdPrefs.getStartingCredits();
credits = preferences.getStartingCredits();
mode = m;
if (mode.equals(FANTASY)) {
@@ -125,36 +146,28 @@ public class QuestData {
}
}
public String[] getOpponents() {
int index = getDifficultyIndex();
if (getWin() < qdPrefs.getWinsForMediumAI(index)) {
if (getWin() < preferences.getWinsForMediumAI(index)) {
return getOpponents(easyAIDecks);
}
if (getWin() < qdPrefs.getWinsForHardAI(index)) {
if (getWin() < preferences.getWinsForHardAI(index)) {
return getOpponents(mediumAIDecks);
}
return getOpponents(hardAIDecks);
}//getOpponents()
private void readAIQuestDeckFiles(QuestData data, ArrayList<String> aiDeckNames) {
data.easyAIDecks = readFile(ForgeProps.getFile(NewConstants.QUEST.EASY), aiDeckNames);
data.mediumAIDecks = readFile(ForgeProps.getFile(NewConstants.QUEST.MEDIUM), aiDeckNames);
data.hardAIDecks = readFile(ForgeProps.getFile(NewConstants.QUEST.HARD), aiDeckNames);
}
public String[] getOpponents(ArrayList<String> aiDeck) {
public String[] getOpponents(List<String> aiDeck) {
Collections.shuffle(aiDeck);
return new String[]{aiDeck.get(0).toString(), aiDeck.get(1).toString(), aiDeck.get(2).toString()};
}//getOpponents()
}
private static ArrayList<String> readFile(File file, ArrayList<String> aiDecks) {
private static List<String> readFile(File file, List<String> aiDecks) {
ArrayList<String> list = FileUtil.readFile(file);
//remove any blank lines
@@ -177,7 +190,7 @@ public class QuestData {
for (int i = 0; i < list.size(); i++)
/*if(!aiDecks.contains(list.get(i).toString())) ErrorViewer.showError(new Exception(),
"QuestData : readFile() error, file %s contains the invalid ai deck name: %s", file,
"QuestDataOld : readFile() error, file %s contains the invalid ai deck name: %s", file,
list.get(i));*/ {
if (!aiDecks.contains(list.get(i).toString())) {
aiDecks.add(list.get(i).toString());
@@ -186,12 +199,9 @@ public class QuestData {
return list;
}//readFile()
public void readAIQuestDeckFiles() {
readAIQuestDeckFiles(this, ai_getDeckNames());
}
static public QuestData loadData() {
try {
//read file "questData"
@@ -213,7 +223,6 @@ public class QuestData {
XStream xStream = new XStream();
data = (QuestData) xStream.fromXML(zin);
data.readAIQuestDeckFiles(data, new ArrayList<String>());
zin.close();
}
@@ -226,6 +235,24 @@ public class QuestData {
}
}
public void saveData() {
try {
File f = ForgeProps.getFile(NewConstants.QUEST.XMLDATA);
BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream(f));
GZIPOutputStream zout = new GZIPOutputStream(bout);
XStream xStream = new XStream();
xStream.toXML(this, zout);
zout.flush();
zout.close();
} catch (Exception ex) {
ErrorViewer.showError(ex, "Error saving Quest Data");
throw new RuntimeException(ex);
}
}
@SuppressWarnings({"deprecation"})
private static QuestData convertSaveFormat() {
forge.QuestData oldData = forge.QuestData.loadData();
QuestData newData = new QuestData();
@@ -233,7 +260,7 @@ public class QuestData {
newData.difficulty = oldData.getDifficulty();
newData.diffIndex = oldData.getDiffIndex();
newData.rankIndex = oldData.getWin()/newData.qdPrefs.getWinsForRankIncrease(newData.diffIndex);
newData.rankIndex = oldData.getWin() / newData.preferences.getWinsForRankIncrease(newData.diffIndex);
newData.win = oldData.getWin();
newData.lost = oldData.getLost();
@@ -259,46 +286,47 @@ public class QuestData {
newData.availableQuests = oldData.getAvailableQuests();
newData.completedQuests = oldData.getCompletedQuests();
newData.pets = new ArrayList<QuestPetAbstract>();
QuestPetAbstract newPet;
if(oldData.getBirdPetLevel() > 0){
if (oldData.getBirdPetLevel() > 0) {
newPet = new QuestPetBird();
newPet.setLevel(oldData.getBirdPetLevel());
newData.pets.add(newPet);
newData.petManager.addPet(newPet);
}
if(oldData.getHoundPetLevel() > 0){
if (oldData.getHoundPetLevel() > 0) {
newPet = new QuestPetHound();
newPet.setLevel(oldData.getHoundPetLevel());
newData.pets.add(newPet);
newData.petManager.addPet(newPet);
}
if(oldData.getWolfPetLevel() > 0){
if (oldData.getWolfPetLevel() > 0) {
newPet = new QuestPetWolf();
newPet.setLevel(oldData.getWolfPetLevel());
newData.pets.add(newPet);
newData.petManager.addPet(newPet);
}
if(oldData.getCrocPetLevel() > 0){
if (oldData.getCrocPetLevel() > 0) {
newPet = new QuestPetCrocodile();
newPet.setLevel(oldData.getCrocPetLevel());
newData.pets.add(newPet);
newData.petManager.addPet(newPet);
}
if(oldData.getPlantLevel() > 0){
if (oldData.getPlantLevel() > 0) {
newPet = new QuestPetPlant();
newPet.setLevel(oldData.getPlantLevel());
newData.pets.add(newPet);
newData.petManager.getPlant().setLevel(oldData.getPlantLevel());
}
newData.getPetManager().setSelectedPet(null);
return newData;
}
//returns Strings of the card names
public ArrayList<String> getCardpool() {
public List<String> getCardpool() {
//make a copy so the internal ArrrayList cannot be changed externally
return new ArrayList<String>(cardPool);
}
public ArrayList<String> getShopList() {
public List<String> getShopList() {
if (shopList != null) {
return new ArrayList<String>(shopList);
}
@@ -307,12 +335,12 @@ public class QuestData {
}
}
public void setShopList(ArrayList<String> list) {
public void setShopList(List<String> list) {
shopList = list;
}
public ArrayList<Integer> getAvailableQuests() {
public List<Integer> getAvailableQuests() {
if (availableQuests != null) {
return new ArrayList<Integer>(availableQuests);
}
@@ -321,7 +349,7 @@ public class QuestData {
}
}
public void setAvailableQuests(ArrayList<Integer> list) {
public void setAvailableQuests(List<Integer> list) {
availableQuests = list;
}
@@ -329,7 +357,7 @@ public class QuestData {
availableQuests.clear();
}
public ArrayList<Integer> getCompletedQuests() {
public List<Integer> getCompletedQuests() {
if (completedQuests != null) {
return new ArrayList<Integer>(completedQuests);
}
@@ -338,7 +366,7 @@ public class QuestData {
}
}
public void setCompletedQuests(ArrayList<Integer> list) {
public void setCompletedQuests(List<Integer> list) {
completedQuests = list;
}
@@ -347,8 +375,6 @@ public class QuestData {
shopList.clear();
}
//rename - removeDeck, addDeck
//copy - addDeck
public void removeDeck(String deckName) {
myDecks.remove(deckName);
@@ -416,18 +442,18 @@ public class QuestData {
//returns human player decks
//returns ArrayList of String deck names
public ArrayList<String> getDeckNames() {
public List<String> getDeckNames() {
return getDeckNames_String(myDecks);
}//getDecks()
}
//returns AI computer decks
//returns ArrayList of String deck names
public ArrayList<String> ai_getDeckNames() {
public List<String> ai_getDeckNames() {
return getDeckNames_String(aiDecks);
}
//returns ArrayList of Deck String names
private ArrayList<String> getDeckNames_String(Map<String, Deck> map) {
private List<String> getDeckNames_String(Map<String, Deck> map) {
ArrayList<String> out = new ArrayList<String>();
Iterator<String> it = map.keySet().iterator();
@@ -439,16 +465,16 @@ public class QuestData {
}
//get new cards that were added to your card pool by addCards()
public ArrayList<String> getAddedCards() {
public List<String> getAddedCards() {
return new ArrayList<String>(newCardList);
}
//adds 11 cards, to the current card pool
//(I chose 11 cards instead of 15 in order to make things more challenging)
public void addCards() {
int nCommon = qdPrefs.getNumCommon();
int nUncommon = qdPrefs.getNumUncommon();
int nRare = qdPrefs.getNumRare();
int nCommon = preferences.getNumCommon();
int nUncommon = preferences.getNumUncommon();
int nRare = preferences.getNumRare();
ArrayList<String> newCards = new ArrayList<String>();
newCards.addAll(boosterPack.getCommon(nCommon));
@@ -461,18 +487,6 @@ public class QuestData {
//getAddedCards() uses newCardList
newCardList = newCards;
}//addCards()
public ArrayList<String> getRandomRares(int n, int colorIndex) {
ArrayList<String> newCards = new ArrayList<String>();
newCards.addAll(boosterPack.getRare(n, colorIndex));
/*
for(String s : newCards ) {
Card c = AllZone.CardFactory.getCard(s, AllZone.HumanPlayer);
list.add(c);
}*/
return newCards;
}
public void addRandomRare(int n) {
@@ -541,49 +555,49 @@ public class QuestData {
}
public long getCreditsToAdd(QuestMatchState matchState) {
long creds = (long) (qdPrefs.getMatchRewardBase() + (qdPrefs.getMatchRewardTotalWins() * win));
long creds = (long) (preferences.getMatchRewardBase() + (preferences.getMatchRewardTotalWins() * win));
String[] wins = matchState.getWinMethods();
int[] winTurns = matchState.getWinTurns();
boolean[] mulliganedToZero = matchState.getMulliganedToZero();
if (matchState.getLose() == 0) {
creds += qdPrefs.getMatchRewardNoLosses();
creds += preferences.getMatchRewardNoLosses();
}
for (String s : wins) {
if (s != null) {
if (s.equals("Poison Counters")) {
creds += qdPrefs.getMatchRewardPoisonWinBonus();
creds += preferences.getMatchRewardPoisonWinBonus();
}
else if (s.equals("Milled")) {
creds += qdPrefs.getMatchRewardMilledWinBonus();
creds += preferences.getMatchRewardMilledWinBonus();
}
else if (s.equals("Battle of Wits") || s.equals("Felidar Sovereign") || s.equals("Helix Pinnacle") ||
s.equals("Epic Struggle") || s.equals("Door to Nothingness") || s.equals("Barren Glory") ||
s.equals("Near-Death Experience") || s.equals("Mortal Combat") || s.equals("Test of Endurance")) {
creds += qdPrefs.getMatchRewardAltWinBonus();
creds += preferences.getMatchRewardAltWinBonus();
}
}
}
for (int i : winTurns) {
if (i == 1) {
creds += qdPrefs.getMatchRewardWinFirst();
creds += preferences.getMatchRewardWinFirst();
}
else if (i <= 5) {
creds += qdPrefs.getMatchRewardWinByFifth();
creds += preferences.getMatchRewardWinByFifth();
}
else if (i <= 10) {
creds += qdPrefs.getMatchRewardWinByTen();
creds += preferences.getMatchRewardWinByTen();
}
else if (i <= 15) {
creds += qdPrefs.getMatchRewardWinByFifteen();
creds += preferences.getMatchRewardWinByFifteen();
}
}
for (boolean b : mulliganedToZero) {
if (b == true) {
creds += qdPrefs.getMatchMullToZero();
creds += preferences.getMatchMullToZero();
}
}
@@ -603,7 +617,7 @@ public class QuestData {
}
//gets all of the cards that are in the cardpool
public ArrayList<String> getCards() {
public List<String> getCards() {
//copy CardList in order to keep private variables private
//if we just return cardPool, it could be changed externally
return new ArrayList<String>(cardPool);
@@ -613,7 +627,7 @@ public class QuestData {
public int getTotalNumberOfGames(int difficulty) {
//-2 because you start a level 1, and the last level is secret
int numberLevels = rankArray.length - 2;
int nMatches = qdPrefs.getWinsForRankIncrease(difficulty);
int nMatches = preferences.getWinsForRankIncrease(difficulty);
return numberLevels * nMatches;
}
@@ -622,10 +636,10 @@ public class QuestData {
public void addWin() {
win++;
if (win % qdPrefs.getWinsForRankIncrease(diffIndex) == 0) {
if (win % preferences.getWinsForRankIncrease(diffIndex) == 0) {
rankIndex++;
}
}//addWin()
}
public void addLost() {
lost++;
@@ -641,15 +655,6 @@ public class QuestData {
//********************FANTASY STUFF START***********************
public void setSelectedPet(QuestPetAbstract pet) {
selectedPet = pet;
}
public QuestPetAbstract getSelectedPet() {
return selectedPet;
}
public void setLife(int n) {
life = n;
}
@@ -726,6 +731,10 @@ public class QuestData {
return mode;
}
//should be called first, because the difficultly won't change
public String getDifficulty() {
return difficulty;
}
public int getDifficultyIndex() {
return diffIndex;
@@ -733,14 +742,26 @@ public class QuestData {
public void setDifficulty(int i) {
diffIndex = i;
difficulty = qdPrefs.getDifficulty(i);
difficulty = preferences.getDifficulty(i);
}
public void setDifficultyIndex() {
String[] diffStr = preferences.getDifficulty();
for (int i = 0; i < diffStr.length; i++) {
if (difficulty.equals(diffStr[i])) {
diffIndex = i;
}
}
}
public String[] getDifficultyChoices() {
return preferences.getDifficulty();
}
public String getRank() {
//is rankIndex too big?
if (rankIndex == rankArray.length) {
rankIndex--;
if (rankIndex >= rankArray.length) {
rankIndex = rankArray.length - 1;
}
return rankArray[rankIndex];
@@ -748,7 +769,7 @@ public class QuestData {
//add cards after a certain number of wins or losses
public boolean shouldAddCards(boolean didWin) {
int n = qdPrefs.getWinsForBooster(diffIndex);
int n = preferences.getWinsForBooster(diffIndex);
if (didWin) {
return getWin() % n == 0;
@@ -777,26 +798,10 @@ public class QuestData {
}
public boolean hasSaveFile() {
return ForgeProps.getFile(NewConstants.QUEST.DATA).exists();
return ForgeProps.getFile(NewConstants.QUEST.DATA).exists()||
ForgeProps.getFile(NewConstants.QUEST.XMLDATA).exists();
}
public void saveData() {
try {
File f = ForgeProps.getFile(NewConstants.QUEST.XMLDATA);
BufferedOutputStream bout = new BufferedOutputStream(new FileOutputStream(f));
GZIPOutputStream zout = new GZIPOutputStream(bout);
XStream xStream = new XStream();
xStream.toXML(this, zout);
zout.flush();
zout.close();
} catch (Exception ex) {
ErrorViewer.showError(ex, "Error saving Quest Data");
throw new RuntimeException(ex);
}
}//saveData()
public static void main(String[] args) {
QuestData q = new QuestData();
for (int i = 0; i < 20; i++) {
@@ -811,5 +816,21 @@ public class QuestData {
System.exit(1);
}
public QuestPetManager getPetManager() {
return petManager;
}
public QuestPreferences getQuestPreferences() {
return preferences;
}
//get new cards that were added to your card pool by addCards()
public void addToNewList(ArrayList<String> added) {
newCardList.addAll(added);
}
public Object readResolve() {
initTransients();
return this;
}
}

View File

@@ -5,12 +5,7 @@ import forge.*;
import java.util.ArrayList;
public class QuestUtil {
public static int getLife(QuestData qd)
{
return qd.getLife();
}
public static CardList getComputerCreatures(QuestData qd)
{
return new CardList();
@@ -39,24 +34,14 @@ public class QuestUtil {
public static CardList getHumanPlantAndPet(QuestData qd)
{
CardList list = new CardList();
if (qd.getSelectedPet() != null)
{
if (qd.getSelectedPet().equals("No Plant/Pet"))
return list;
if (qd.getSelectedPet().equals("Wolf") && qd.getWolfPetLevel() > 0)
list.add(getWolfPetToken(qd.getWolfPetLevel()));
else if (qd.getSelectedPet().equals("Croc") && qd.getCrocPetLevel() > 0)
list.add(getCrocPetToken(qd.getCrocPetLevel()));
else if (qd.getSelectedPet().equals("Bird") && qd.getBirdPetLevel() > 0)
list.add(getBirdPetToken(qd.getBirdPetLevel()));
else if (qd.getSelectedPet().equals("Hound") && qd.getHoundPetLevel() > 0)
list.add(getHoundPetToken(qd.getHoundPetLevel()));
}
if (qd.getPlantLevel() > 0)
list.add(getPlantToken(qd.getPlantLevel()));
if (qd.getPetManager().shouldPetBeUsed()){
list.add(qd.getPetManager().getSelectedPet().getPetCard());
}
if (qd.getPetManager().shouldPlantBeUsed()){
list.add(qd.getPetManager().getPlant().getPetCard());
}
return list;
}
@@ -70,357 +55,7 @@ public class QuestUtil {
return list;
}
//makeToken(String name, String imageName, Card source, String manaCost, String[] types, int baseAttack, int baseDefense, String[] intrinsicKeywords) {
public static Card getPlantToken(int level)
{
String imageName = "";
int baseAttack = 0;
int baseDefense = 0;
String keyword = "";
if (level == 1)
{
imageName = "G 0 1 Plant Wall";
baseDefense = 1;
}
else if (level == 2)
{
imageName = "G 0 2 Plant Wall";
baseDefense = 2;
}
else if (level == 3)
{
imageName = "G 0 3 Plant Wall";
baseDefense = 3;
}
else if (level == 4)
{
imageName = "G 1 3 Plant Wall";
baseDefense = 3;
baseAttack = 1;
}
else if (level == 5)
{
imageName = "G 1 3 Plant Wall Deathtouch";
baseDefense = 3;
baseAttack = 1;
keyword = "Deathtouch";
}
else if (level == 6)
{
imageName = "G 1 4 Plant Wall";
baseDefense = 4;
baseAttack = 1;
keyword = "Deathtouch";
}
Card c = new Card();
c.setName("Plant Wall");
c.setImageName(imageName);
c.setController(AllZone.HumanPlayer);
c.setOwner(AllZone.HumanPlayer);
//c.setManaCost("G");
c.addColor("G");
c.setToken(true);
c.addType("Creature");
c.addType("Plant");
c.addType("Wall");
c.addIntrinsicKeyword("Defender");
if (!keyword.equals(""))
c.addIntrinsicKeyword("Deathtouch");
c.setBaseAttack(baseAttack);
c.setBaseDefense(baseDefense);
if (level == 6)
{
final Card crd = c;
Ability_Cost abCost = new Ability_Cost("T", crd.getName(), true);
final SpellAbility ability = new Ability_Activated(crd, abCost, null){
private static final long serialVersionUID = 7546242087593613719L;
@Override
public boolean canPlayAI() {
return AllZone.Phase.getPhase().equals(Constant.Phase.Main2);
}
@Override
public void resolve() {
crd.getController().gainLife(1, crd);
}
};
c.addSpellAbility(ability);
ability.setDescription("tap: You gain 1 life.");
StringBuilder sb = new StringBuilder();
sb.append("Plant Wall - ").append(c.getController()).append(" gains 1 life.");
ability.setStackDescription(sb.toString());
c.setText("tap: You gain 1 life.");
}
return c;
}//getPlantToken
public static Card getWolfPetToken(int level)
{
String imageName = "";
int baseAttack = 0;
int baseDefense = 0;
if (level == 1)
{
imageName = "G 1 1 Wolf Pet";
baseDefense = 1;
baseAttack = 1;
}
else if (level == 2)
{
imageName = "G 1 2 Wolf Pet";
baseDefense = 2;
baseAttack = 1;
}
else if (level == 3)
{
imageName = "G 2 2 Wolf Pet";
baseDefense = 2;
baseAttack = 2;
}
else if (level == 4)
{
imageName = "G 2 2 Wolf Pet Flanking";
baseDefense = 2;
baseAttack = 2;
}
Card c = new Card();
c.setName("Wolf Pet");
c.setImageName(imageName);
c.setController(AllZone.HumanPlayer);
c.setOwner(AllZone.HumanPlayer);
//c.setManaCost("G");
c.addColor("G");
c.setToken(true);
c.addType("Creature");
c.addType("Wolf");
c.addType("Pet");
if (level >= 4)
c.addIntrinsicKeyword("Flanking");
c.setBaseAttack(baseAttack);
c.setBaseDefense(baseDefense);
return c;
}//getWolfPetToken
public static Card getCrocPetToken(int level)
{
String imageName = "";
int baseAttack = 0;
int baseDefense = 0;
if (level == 1)
{
imageName = "B 1 1 Crocodile Pet";
baseDefense = 1;
baseAttack = 1;
}
else if (level == 2)
{
imageName = "B 2 1 Crocodile Pet";
baseDefense = 1;
baseAttack = 2;
}
else if (level == 3)
{
imageName = "B 3 1 Crocodile Pet";
baseDefense = 1;
baseAttack = 3;
}
else if (level == 4)
{
imageName = "B 3 1 Crocodile Pet Swampwalk";
baseDefense = 1;
baseAttack = 3;
}
Card c = new Card();
c.setName("Crocodile Pet");
c.setImageName(imageName);
c.setController(AllZone.HumanPlayer);
c.setOwner(AllZone.HumanPlayer);
//c.setManaCost("B");
c.addColor("B");
c.setToken(true);
c.addType("Creature");
c.addType("Crocodile");
c.addType("Pet");
if (level >= 4)
c.addIntrinsicKeyword("Swampwalk");
c.setBaseAttack(baseAttack);
c.setBaseDefense(baseDefense);
return c;
}//getCrocPetToken
public static Card getBirdPetToken(int level)
{
String imageName = "";
int baseAttack = 0;
int baseDefense = 0;
if (level == 1)
{
imageName = "W 0 1 Bird Pet";
baseDefense = 1;
baseAttack = 0;
}
else if (level == 2)
{
imageName = "W 1 1 Bird Pet";
baseDefense = 1;
baseAttack = 1;
}
else if (level == 3)
{
imageName = "W 2 1 Bird Pet";
baseDefense = 1;
baseAttack = 2;
}
else if (level == 4)
{
imageName = "W 2 1 Bird Pet First Strike";
baseDefense = 1;
baseAttack = 2;
}
Card c = new Card();
c.setName("Bird Pet");
c.setImageName(imageName);
c.setController(AllZone.HumanPlayer);
c.setOwner(AllZone.HumanPlayer);
//c.setManaCost("W");
c.addColor("W");
c.setToken(true);
c.addType("Creature");
c.addType("Bird");
c.addType("Pet");
c.addIntrinsicKeyword("Flying");
if (level >= 4)
c.addIntrinsicKeyword("First Strike");
c.setBaseAttack(baseAttack);
c.setBaseDefense(baseDefense);
return c;
}
public static Card getHoundPetToken(int level)
{
String imageName = "";
int baseAttack = 0;
int baseDefense = 0;
if (level == 1)
{
imageName = "R 1 1 Hound Pet";
baseDefense = 1;
baseAttack = 1;
}
else if (level == 2)
{
imageName = "R 1 1 Hound Pet Haste";
baseDefense = 1;
baseAttack = 1;
}
else if (level == 3)
{
imageName = "R 2 1 Hound Pet";
baseDefense = 1;
baseAttack = 2;
}
else if (level == 4)
{
imageName = "R 2 1 Hound Pet Alone";
baseDefense = 1;
baseAttack = 2;
}
Card c = new Card();
c.setName("Hound Pet");
c.setImageName(imageName);
c.setController(AllZone.HumanPlayer);
c.setOwner(AllZone.HumanPlayer);
//c.setManaCost("R");
c.addColor("R");
c.setToken(true);
c.addType("Creature");
c.addType("Hound");
c.addType("Pet");
if (level >= 2)
c.addIntrinsicKeyword("Haste");
if (level >= 4)
c.addIntrinsicKeyword("Whenever this creature attacks alone, it gets +2/+0 until end of turn.");
c.setBaseAttack(baseAttack);
c.setBaseDefense(baseDefense);
return c;
}
public static ArrayList<String> getPetNames(QuestData questData)
{
ArrayList<String> list = new ArrayList<String>();
if (questData.getWolfPetLevel() > 0)
list.add("Wolf");
if (questData.getCrocPetLevel() > 0)
list.add("Croc");
if (questData.getBirdPetLevel() > 0)
list.add("Bird");
if (questData.getHoundPetLevel() > 0)
list.add("Hound");
return list;
}
public static void setupQuest(Quest_Assignment qa)
{

View File

@@ -2,7 +2,7 @@ package forge.quest.data.pet;
import forge.Card;
public abstract class QuestPetAbstract {
public abstract class QuestPetAbstract implements Comparable{
int level;
private int maxLevel;
private String name;
@@ -55,4 +55,21 @@ public abstract class QuestPetAbstract {
public void setLevel(int level){
this.level = level;
}
public String getDescription() {
return description;
}
public String getName() {
return name;
}
@Override
public String toString() {
return name;
}
public int compareTo(Object o) {
return name.compareTo(o.toString());
}
}

View File

@@ -1,17 +0,0 @@
package forge.quest.data.pet;
import java.util.ArrayList;
import java.util.List;
public class QuestPetFactory {
static List<QuestPetAbstract> getAllPets(){
List<QuestPetAbstract> pets = new ArrayList<QuestPetAbstract>();
pets.add(new QuestPetWolf());
pets.add(new QuestPetCrocodile());
pets.add(new QuestPetBird());
pets.add(new QuestPetHound());
return pets;
}
}

View File

@@ -0,0 +1,102 @@
package forge.quest.data.pet;
import java.util.*;
public class QuestPetManager{
public Map<String, QuestPetAbstract> pets = new HashMap<String, QuestPetAbstract>();
public QuestPetAbstract selectedPet;
public QuestPetAbstract plant;
public boolean usePlant;
public QuestPetManager() {
plant = new QuestPetPlant();
for (QuestPetAbstract pet : getAllPets()) {
addPet(pet);
}
}
public void setSelectedPet(String pet) {
selectedPet = (pet == null) ? null : getPet(pet);
}
public QuestPetAbstract getSelectedPet() {
return selectedPet;
}
public QuestPetAbstract getPlant() {
return plant;
}
public void addPlantLevel() {
if (plant == null) {
plant = new QuestPetPlant();
}
else {
plant.incrementLevel();
}
}
public QuestPetAbstract getPet(String petName) {
return pets.get(petName);
}
public void addPet(QuestPetAbstract newPet) {
pets.put(newPet.getName(), newPet);
}
public Set<String> getPetNames() {
return pets.keySet();
}
public void addPetLevel(String s) {
pets.get(s).incrementLevel();
}
public boolean shouldPlantBeUsed() {
return usePlant;
}
public boolean shouldPetBeUsed() {
return selectedPet != null;
}
public static Set<QuestPetAbstract> getAllPets() {
SortedSet<QuestPetAbstract> set = new TreeSet<QuestPetAbstract>();
set.add(new QuestPetBird());
set.add(new QuestPetCrocodile());
set.add(new QuestPetHound());
set.add(new QuestPetWolf());
return set;
}
public Set<String> getAvailablePetNames() {
SortedSet<String> set = new TreeSet<String>();
for (Map.Entry<String, QuestPetAbstract> pet : pets.entrySet()) {
if (pet.getValue().getLevel() > 0){
set.add(pet.getKey());
}
}
return set;
}
public Collection<QuestPetAbstract> getPets() {
return pets.values();
}
//Magic to support added pet types when reading saves.
private Object readResolve() {
for (QuestPetAbstract pet : getAllPets()) {
if (!pets.containsKey(pet.getName())) {
addPet(pet);
}
}
return this;
}
}

View File

@@ -2,7 +2,6 @@ package forge.quest.gui;
import forge.AllZone;
import forge.Gui_NewGame;
import forge.QuestData;
import forge.gui.GuiUtils;
import forge.quest.gui.bazaar.QuestBazaarPanel;
import forge.quest.gui.main.QuestMainPanel;
@@ -24,7 +23,6 @@ public class QuestFrame extends JFrame {
public static final String MAIN_PANEL = "Main";
public static final String BAZAAR_PANEL = "Bazaar";
private static final String QUESTS_PANEL = "Quests";
Map<String, QuestAbstractPanel> subPanelMap = new HashMap<String, QuestAbstractPanel>();
@@ -79,7 +77,7 @@ public class QuestFrame extends JFrame {
public void returnToMainMenu() {
QuestData.saveData(AllZone.QuestData);
AllZone.QuestData.saveData();
(new Gui_NewGame()).setVisible(true) ;
this.dispose();
}

View File

@@ -1,7 +1,6 @@
package forge.quest.gui.bazaar;
import forge.AllZone;
import forge.QuestData;
import forge.gui.GuiUtils;
import javax.swing.*;
@@ -72,7 +71,7 @@ public abstract class QuestAbstractBazaarItem {
public void actionPerformed(ActionEvent e) {
AllZone.QuestData.subtractCredits(price);
purchaseItem();
QuestData.saveData(AllZone.QuestData);
AllZone.QuestData.saveData();
QuestBazaarPanel.refreshLastInstance();
}
});

View File

@@ -1,9 +1,9 @@
package forge.quest.gui.bazaar;
import forge.AllZone;
import forge.QuestData;
import forge.gui.GuiUtils;
import forge.properties.NewConstants;
import forge.quest.data.QuestData;
import javax.swing.*;
import javax.swing.border.EmptyBorder;

View File

@@ -1,133 +1,44 @@
package forge.quest.gui.bazaar;
import forge.gui.GuiUtils;
import forge.quest.data.pet.QuestPetAbstract;
import java.util.ArrayList;
import java.util.List;
public class QuestNurseryStall extends QuestAbstractBazaarStall{
private static final long serialVersionUID = 9217496944324343390L;
public class QuestNurseryStall extends QuestAbstractBazaarStall {
private static final long serialVersionUID = 9217496944324343390L;
public QuestNurseryStall() {
super("Nursery", "LeafIconSmall.png", "The smells of the one hundred and one different plants forms a unique fragrance.");
public QuestNurseryStall() {
super("Nursery",
"LeafIconSmall.png",
"The smells of the one hundred and one different plants forms a unique fragrance.");
}
@Override
protected List<QuestAbstractBazaarItem> populateItems() {
if (questData.getPlantLevel()>=6){
QuestPetAbstract plant = questData.getPetManager().getPlant();
if (plant.getLevel() >= 6) {
return new ArrayList<QuestAbstractBazaarItem>();
}
List<QuestAbstractBazaarItem> itemList = new ArrayList<QuestAbstractBazaarItem>();
itemList.add(new QuestAbstractBazaarItem("Wall of plants",
getDesc(),
getPrice(),
GuiUtils.getIconFromFile(getImageString())) {
itemList.add(new QuestAbstractBazaarItem(plant.getName(),
plant.getUpgradeDescription(),
plant.getUpgradePrice(),
GuiUtils.getIconFromFile(plant.getImageName())) {
@Override
public void purchaseItem() {
questData.addPlantLevel();
questData.getPetManager().getPlant().incrementLevel();
}
});
return itemList;
}
private String getDesc()
{
StringBuilder sb = new StringBuilder();
sb.append("<html>");
if (questData.getPlantLevel() == 0)
{
sb.append("<br>Start each of your battles with this lush, verdant plant on your side.<br>");
sb.append("Excellent at blocking the nastiest of critters!<br><br>");
sb.append("<u><b>Current Level</b></u>: <em>Not purchased</em><br>");
sb.append("<u><b>Level 1</b></u>: 0/1<br>");
sb.append("<u><b>Level 2</b></u>: 0/2<br>");
sb.append("<u><b>Can learn</b></u>: Deathtouch");
}
else if (questData.getPlantLevel() == 1)
{
sb.append("Improve the toughness of your plant.<br>");
sb.append("<u><b>Current Level</b></u>: 0/1 <br>");
sb.append("<u><b>Level 2</b></u>: 0/2<br>");
sb.append("<u><b>Level 3</b></u>: 0/3<br>");
sb.append("<u><b>Can learn</b></u>: Deathtouch");
}
else if (questData.getPlantLevel() == 2)
{
sb.append("Improve the toughness of your plant.<br>");
sb.append("<u><b>Current Level</b></u>: 0/2 <br>");
sb.append("<u><b>Level 3</b></u>: 0/3<br>");
sb.append("<u><b>Level 4</b></u>: 1/3<br>");
sb.append("<u><b>Can learn</b></u>: Deathtouch");
}
else if (questData.getPlantLevel() == 3)
{
sb.append("Improve the power of your plant.<br>");
sb.append("<u><b>Current Level</b></u>: 0/3 <br>");
sb.append("<u><b>Level 4</b></u>: 1/3<br>");
sb.append("<u><b>Level 5</b></u>: Deathtouch<br>");
sb.append("<u><b>Can learn</b></u>: Deathtouch");
}
else if (questData.getPlantLevel() == 4)
{
sb.append("Grow venomous thorns on your plant.<br>");
sb.append("<u><b>Current Level</b></u>: 1/3 <br>");
sb.append("<u><b>Level 5</b></u>: 1/3, Deathtouch<br>");
sb.append("<u><b>Level 6</b></u>: 1/4, Deathtouch, Tap: you gain 1 life.<br>");
}
else if (questData.getPlantLevel() == 5)
{
sb.append("As well as gaining more toughness,<br>");
sb.append("your plant will have healing properties.<br>");
sb.append("<u><b>Current Level</b></u>: 1/3, Deathtouch<br>");
sb.append("<u><b>Level 6</b></u>: 1/4, Deathtouch, Tap: you gain 1 life.");
}
else
{
sb.append("Plant Level Maxed out.");
}
sb.append("</html>");
return sb.toString();
}
private int getPrice()
{
int l = 0;
if (questData.getPlantLevel() == 0)
l = 100;
else if (questData.getPlantLevel() == 1)
l = 150;
else if (questData.getPlantLevel() == 2)
l = 200;
else if (questData.getPlantLevel() == 3)
l = 300;
else if (questData.getPlantLevel() == 4)
l = 750;
else if (questData.getPlantLevel() == 5)
l = 1000;
return l;
}
private String getImageString()
{
String s = "";
if (questData.getPlantLevel() == 0)
s = "g_0_1_plant_wall_small.jpg";
else if (questData.getPlantLevel() == 1)
s = "g_0_2_plant_wall_small.jpg";
else if (questData.getPlantLevel() == 2)
s = "g_0_3_plant_wall_small.jpg";
else if (questData.getPlantLevel() == 3)
s = "g_1_3_plant_wall_small.jpg";
else if (questData.getPlantLevel() == 4)
s = "g_1_3_plant_wall_deathtouch_small.jpg";
else if (questData.getPlantLevel() == 5)
s = "g_1_4_plant_wall_small.jpg";
return s;
}
}

View File

@@ -1,8 +1,10 @@
package forge.quest.gui.bazaar;
import forge.gui.GuiUtils;
import forge.quest.data.pet.QuestPetAbstract;
import java.util.ArrayList;
import java.util.Collection;
import java.util.List;
public class QuestPetStall extends QuestAbstractBazaarStall {
@@ -17,246 +19,25 @@ public class QuestPetStall extends QuestAbstractBazaarStall {
protected List<QuestAbstractBazaarItem> populateItems() {
List<QuestAbstractBazaarItem> itemList = new ArrayList<QuestAbstractBazaarItem>();
if (questData.getWolfPetLevel()<=3){
itemList.add(new QuestAbstractBazaarItem("Wolf Pet",
getDesc(WOLF),
getPrice(WOLF),
GuiUtils.getIconFromFile(getImageString(WOLF))) {
@Override
public void purchaseItem() {
questData.addWolfPetLevel();
}
});
}
if (questData.getCrocPetLevel()<=3){
itemList.add(new QuestAbstractBazaarItem("Crocodile Pet",
getDesc(CROC),
getPrice(CROC),
GuiUtils.getIconFromFile(getImageString(CROC))) {
@Override
public void purchaseItem() {
questData.addCrocPetLevel();
}
});
}
if (questData.getBirdPetLevel()<=3){
itemList.add(new QuestAbstractBazaarItem("Bird Pet",
getDesc(BIRD),
getPrice(BIRD),
GuiUtils.getIconFromFile(getImageString(BIRD))) {
@Override
public void purchaseItem() {
questData.addBirdPetLevel();
}
});
}
if (questData.getHoundPetLevel()<=3){
itemList.add(new QuestAbstractBazaarItem("Hound Pet",
getDesc(HOUND),
getPrice(HOUND),
GuiUtils.getIconFromFile(getImageString(HOUND))) {
@Override
public void purchaseItem() {
questData.addHoundPetLevel();
}
});
Collection<QuestPetAbstract> pets = questData.getPetManager().getPets();
for (final QuestPetAbstract pet : pets) {
if (pet.getLevel() < pet.getMaxLevel()){
itemList.add(new QuestAbstractBazaarItem(
pet.getName(),
pet.getUpgradeDescription(),
pet.getUpgradePrice(),
GuiUtils.getIconFromFile(pet.getImageName())) {
@Override
public void purchaseItem() {
questData.getPetManager().addPetLevel(pet.getName());
}
});
}
}
return itemList;
}
private String getDesc(int petType) {
StringBuilder sb = new StringBuilder();
sb.append("<html><br>");
switch (petType) {
case WOLF:
if (questData.getWolfPetLevel() == 0) {
sb.append("This ferocious animal may have been raised in captivity, but it has been trained to<br>kill.<br>");
sb.append("<em>Eats goblins for breakfast.<em><br><br>");
sb.append("<u><b>Level 1</b></u>: 1/1<br>");
sb.append("<u><b>Next Level</b></u>: 1/2<br>");
sb.append("<u><b>Can learn</b></u>: Flanking");
} else if (questData.getWolfPetLevel() == 1) {
sb.append("Improve the toughness of your wolf.<br>");
sb.append("<u><b>Level 2</b></u>: 1/2<br>");
sb.append("<u><b>Next Level</b></u>: 2/2<br>");
sb.append("<u><b>Can learn</b></u>: Flanking");
} else if (questData.getWolfPetLevel() == 2) {
sb.append("Improve the attack power of your wolf.<br>");
sb.append("<u><b>Level 3</b></u>: 2/2<br>");
sb.append("<u><b>Next Level</b></u>: Flanking<br>");
sb.append("<u><b>Can learn</b></u>: Flanking");
} else if (questData.getWolfPetLevel() == 3) {
sb.append("Gives Flanking to your wolf.<br>");
sb.append("<u><b>Level 4</b></u>: 2/2 Flanking<br>");
}
break;
case CROC:
if (questData.getCrocPetLevel() == 0) {
sb.append("With its razor sharp teeth, this swamp-dwelling monster is extremely dangerous.<br>");
sb.append("<em>Crikey mate!<em><br><br>");
sb.append("<u><b>Level 1</b></u>: 1/1<br>");
sb.append("<u><b>Next Level</b></u>: 2/1<br>");
sb.append("<u><b>Can learn</b></u>: Swampwalk");
} else if (questData.getCrocPetLevel() == 1) {
sb.append("Improve the attack power of your croc.<br>");
sb.append("<u><b>Level 2</b></u>: 2/1<br>");
sb.append("<u><b>Next Level</b></u>: 3/1<br>");
sb.append("<u><b>Can learn</b></u>: Swampwalk");
} else if (questData.getCrocPetLevel() == 2) {
sb.append("Improve the attack power of your croc.<br>");
sb.append("<u><b>Level 3</b></u>: 3/1<br>");
sb.append("<u><b>Next Level</b></u>: 3/1 Swampwalk<br>");
} else if (questData.getCrocPetLevel() == 3) {
sb.append("Gives Swampwalk to your croc.<br>");
sb.append("<u><b>Level 4</b></u>: 3/1 Swampwalk<br>");
}
break;
case BIRD:
if (questData.getBirdPetLevel() == 0) {
sb.append("Unmatched in speed, agility and awareness,<br>");
sb.append("this trained hawk makes a fantastic hunter.<br><br>");
sb.append("<u><b>Level 1</b></u>: 0/1 Flying<br>");
sb.append("<u><b>Next Level</b></u>: 1/1<br>");
sb.append("<u><b>Can learn</b></u>: First strike");
} else if (questData.getBirdPetLevel() == 1) {
sb.append("Improve the attack power of your bird.<br>");
sb.append("<u><b>Level 2</b></u>: 1/1<br>");
sb.append("<u><b>Next Level</b></u>: 2/1 <br>");
sb.append("<u><b>Can learn</b></u>: First strike");
} else if (questData.getBirdPetLevel() == 2) {
sb.append("Improve the attack power of your bird.<br>");
sb.append("<u><b>Level 3</b></u>: 2/1<br>");
sb.append("<u><b>Next Level</b></u>: 2/1 First strike<br>");
} else if (questData.getBirdPetLevel() == 3) {
sb.append("Gives First strike to your bird.<br>");
sb.append("<u><b>Level 4</b></u>: 2/1 First strike<br>");
}
break;
case HOUND:
if (questData.getHoundPetLevel() == 0) {
sb.append("Dogs are said to be man's best friend.<br>");
sb.append("Definitely not this one.<br><br>");
sb.append("<u><b>Level 1</b></u>: 1/1<br>");
sb.append("<u><b>Next Level</b></u>: 1/1 Haste<br>");
sb.append("<u><b>Can learn</b></u>: Whenever this creature attacks alone,<br> it gets +2/+0 until end of turn.");
} else if (questData.getHoundPetLevel() == 1) {
sb.append("Gives haste to your hound.<br>");
sb.append("<u><b>Level 2</b></u>: 1/1 Haste<br>");
sb.append("<u><b>Next Level</b></u>: 2/1 Haste<br>");
sb.append("<u><b>Can learn</b></u>: Whenever this creature attacks alone,<br> it gets +2/+0 until end of turn.");
} else if (questData.getHoundPetLevel() == 2) {
sb.append("Improve the attack power of your hound.<br>");
sb.append("<u><b>Level 3</b></u>: 2/1 Haste<br>");
sb.append("<u><b>Next Level</b></u>: 2/1 Whenever this creature attacks<br> alone, it gets +2/+0 until end of turn.<br>");
} else if (questData.getHoundPetLevel() == 3) {
sb.append("Greatly improves your hound's attack power if it<br> attacks alone.<br>");
sb.append("<u><b>Level 4</b></u>: 2/1 Haste, whenever this creature attacks alone, it gets +2/+0 until end of turn.<br>");
}
break;
}
sb.append("</html>");
return sb.toString();
}
private int getPrice(int petType) {
int l = 0;
switch (petType) {
case WOLF:
if (questData.getWolfPetLevel() == 0)
l = 250;
else if (questData.getWolfPetLevel() == 1)
l = 250;
else if (questData.getWolfPetLevel() == 2)
l = 500;
else if (questData.getWolfPetLevel() == 3)
l = 550;
break;
case CROC:
if (questData.getCrocPetLevel() == 0)
l = 250;
else if (questData.getCrocPetLevel() == 1)
l = 300;
else if (questData.getCrocPetLevel() == 2)
l = 450;
else if (questData.getCrocPetLevel() == 3)
l = 600;
break;
case BIRD:
if (questData.getBirdPetLevel() == 0)
l = 200;
else if (questData.getBirdPetLevel() == 1)
l = 300;
else if (questData.getBirdPetLevel() == 2)
l = 450;
else if (questData.getBirdPetLevel() == 3)
l = 400;
break;
case HOUND:
if (questData.getHoundPetLevel() == 0)
l = 200;
else if (questData.getHoundPetLevel() == 1)
l = 350;
else if (questData.getHoundPetLevel() == 2)
l = 450;
else if (questData.getHoundPetLevel() == 3)
l = 750;
break;
}
return l;
}
private String getImageString(int petType) {
String s = null;
switch (petType) {
case WOLF:
if (questData.getWolfPetLevel() == 0)
s = "g_1_1_wolf_pet_small.jpg";
else if (questData.getWolfPetLevel() == 1)
s = "g_1_2_wolf_pet_small.jpg";
else if (questData.getWolfPetLevel() == 2)
s = "g_2_2_wolf_pet_small.jpg";
else if (questData.getWolfPetLevel() == 3)
s = "g_2_2_wolf_pet_flanking_small.jpg";
break;
case CROC:
if (questData.getCrocPetLevel() == 0)
s = "b_1_1_crocodile_pet_small.jpg";
else if (questData.getCrocPetLevel() == 1)
s = "b_2_1_crocodile_pet_small.jpg";
else if (questData.getCrocPetLevel() == 2)
s = "b_3_1_crocodile_pet_small.jpg";
else if (questData.getCrocPetLevel() == 3)
s = "b_3_1_crocodile_pet_swampwalk_small.jpg";
break;
case BIRD:
if (questData.getBirdPetLevel() == 0)
s = "w_0_1_bird_pet_small.jpg";
else if (questData.getBirdPetLevel() == 1)
s = "w_1_1_bird_pet_small.jpg";
else if (questData.getBirdPetLevel() == 2)
s = "w_2_1_bird_pet_small.jpg";
else if (questData.getBirdPetLevel() == 3)
s = "w_2_1_bird_pet_first_strike_small.jpg";
case HOUND:
if (questData.getHoundPetLevel() == 0)
s = "r_1_1_hound_pet_small.jpg";
else if (questData.getHoundPetLevel() == 1)
s = "r_1_1_hound_pet_haste_small.jpg";
else if (questData.getHoundPetLevel() == 2)
s = "r_2_1_hound_pet_small.jpg";
else if (questData.getHoundPetLevel() == 3)
s = "r_2_1_hound_pet_alone_small.jpg";
break;
}
return s;
}
public static final int WOLF = 1;
public static final int CROC = 2;
public static final int HOUND = 3;
public static final int BIRD = 4;
}

View File

@@ -2,8 +2,8 @@ package forge.quest.gui.main;
import forge.AllZone;
import forge.QuestData;
import forge.gui.GuiUtils;
import forge.quest.data.QuestData;
import javax.swing.*;
import java.util.ArrayList;
@@ -233,23 +233,23 @@ public class QuestBattle extends QuestSelectablePanel {
public static List<QuestSelectablePanel> getBattles(){
List<QuestSelectablePanel> opponentList = new ArrayList<QuestSelectablePanel>();
try{
QuestData questData = AllZone.QuestData;
String[] opponentNames = questData.getOpponents();
for (String opponentName : opponentNames) {
String oppIconName = opponentName.substring(0, opponentName.length() - 1).trim() + ".jpg";
ImageIcon icon = GuiUtils.getIconFromFile(oppIconName);
try {
String oppIconName = opponentName.substring(0, opponentName.length() - 1).trim() + ".jpg";
ImageIcon icon = GuiUtils.getIconFromFile(oppIconName);
opponentList.add(new QuestBattle(opponentName,
nameDeckMap.get(opponentName).difficulty,
nameDeckMap.get(opponentName).description,
icon));
}
}
catch (NullPointerException e)
{
System.out.println("Break Here");
opponentList.add(new QuestBattle(opponentName,
nameDeckMap.get(opponentName).difficulty,
nameDeckMap.get(opponentName).description,
icon));
}
catch (NullPointerException e) {
System.out.println("Caught NPE, Fix me:" + opponentName);
}
}
return opponentList;
}

View File

@@ -2,6 +2,7 @@ package forge.quest.gui.main;
import forge.*;
import forge.gui.GuiUtils;
import forge.quest.data.QuestData;
import forge.quest.gui.QuestAbstractPanel;
import forge.quest.gui.QuestFrame;
@@ -14,17 +15,15 @@ import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.*;
import java.util.List;
//presumes AllZone.QuestData is not null
//presumes AllZone.QuestDataOld is not null
//AllZone.QuestData should be set by Gui_QuestOptions
//AllZone.QuestDataOld should be set by Gui_QuestOptions
public class QuestMainPanel extends QuestAbstractPanel {
private QuestData questData;
private forge.quest.data.QuestData questData;
JLabel creditsLabel = new JLabel();
JLabel lifeLabel = new JLabel();
@@ -148,7 +147,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
cardShopButton.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 20));
JButton bazaarButton = null;
if (questData.getMode().equals(QuestData.FANTASY)) {
if (questData.getMode().equals(forge.quest.data.QuestData.FANTASY)) {
bazaarButton = new JButton("Bazaar");
bazaarButton.addActionListener(new ActionListener() {
@@ -192,7 +191,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
panel.add(Box.createVerticalGlue());
panel.add(Box.createVerticalGlue());
if (questData.getMode().equals(QuestData.FANTASY)) {
if (questData.getMode().equals(forge.quest.data.QuestData.FANTASY)) {
panel.add(this.lifeLabel);
this.lifeLabel.setFont(new Font(Font.DIALOG, Font.BOLD, 14));
@@ -206,7 +205,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
GuiUtils.addGap(panel, 10);
panel.add(cardShopButton);
if (questData.getMode().equals(QuestData.FANTASY)) {
if (questData.getMode().equals(forge.quest.data.QuestData.FANTASY)) {
GuiUtils.addGap(panel);
panel.add(bazaarButton);
}
@@ -274,17 +273,17 @@ public class QuestMainPanel extends QuestAbstractPanel {
GuiUtils.addGap(matchPanel);
if (questData.getMode().equals(QuestData.FANTASY)) {
if (questData.getMode().equals(forge.quest.data.QuestData.FANTASY)) {
JPanel petPanel = new JPanel();
petPanel.setLayout(new BoxLayout(petPanel, BoxLayout.X_AXIS));
this.petCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
if (petCheckBox.isSelected()) {
questData.setSelectedPet((String) petComboBox.getSelectedItem());
questData.getPetManager().setSelectedPet((String) petComboBox.getSelectedItem());
}
else {
questData.setSelectedPet("No Plant/Pet");
questData.getPetManager().setSelectedPet(null);
}
petComboBox.setEnabled(petCheckBox.isSelected());
@@ -296,10 +295,10 @@ public class QuestMainPanel extends QuestAbstractPanel {
this.petComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
if (petCheckBox.isSelected()) {
questData.setSelectedPet((String) petComboBox.getSelectedItem());
questData.getPetManager().setSelectedPet((String) petComboBox.getSelectedItem());
}
else {
questData.setSelectedPet("No Plant/Pet");
questData.getPetManager().setSelectedPet(null);
}
}
});
@@ -350,7 +349,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
}
void refresh() {
QuestData.saveData(AllZone.QuestData);
AllZone.QuestData.saveData();
devModeCheckBox.setSelected(Constant.Runtime.DevMode[0]);
smoothLandCheckBox.setSelected(Constant.Runtime.Smooth[0]);
@@ -400,7 +399,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
petComboBox.removeAllItems();
List<String> petList = QuestUtil.getPetNames(questData);
Set<String> petList = questData.getPetManager().getAvailablePetNames();
if (petList.size() > 0) {
petComboBox.setEnabled(true);
@@ -416,13 +415,13 @@ public class QuestMainPanel extends QuestAbstractPanel {
petCheckBox.setEnabled(false);
}
if (questData.getSelectedPet() == null || questData.getSelectedPet().equals("No Plant/Pet")) {
if (!questData.getPetManager().shouldPetBeUsed()) {
petCheckBox.setSelected(false);
petComboBox.setEnabled(false);
}
else {
petCheckBox.setSelected(true);
petComboBox.setSelectedItem(questData.getSelectedPet());
petComboBox.setSelectedItem(questData.getPetManager().getSelectedPet().getName());
}
}
@@ -462,7 +461,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
public void execute() {
//saves all deck data
QuestData.saveData(AllZone.QuestData);
AllZone.QuestData.saveData();
new QuestFrame();
}
@@ -485,7 +484,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
public void execute() {
//saves all deck data
QuestData.saveData(AllZone.QuestData);
AllZone.QuestData.saveData();
new QuestFrame();
}
@@ -549,9 +548,9 @@ public class QuestMainPanel extends QuestAbstractPanel {
AllZone.GameAction.newGame(
humanDeck,
computer,
QuestUtil.getHumanPlantAndPet(questData),
forge.quest.data.QuestUtil.getHumanPlantAndPet(questData),
new CardList(),
QuestUtil.getLife(questData),
questData.getLife(),
20,
null);
}
@@ -573,7 +572,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
AllZone.GameAction.newGame(
humanDeck,
computerDeck,
QuestUtil.getHumanPlantAndPet(questData, selectedQuest),
forge.quest.data.QuestUtil.getHumanPlantAndPet(questData, selectedQuest),
new CardList(),
questData.getLife() + extraLife,
selectedQuest.getComputerLife(),

View File

@@ -1,7 +1,6 @@
package forge.quest.gui.main;
import forge.AllZone;
import forge.QuestData;
import forge.Quest_Assignment;
import forge.ReadQuest_Assignment;
import forge.gui.GuiUtils;
@@ -46,21 +45,21 @@ public class QuestQuest extends QuestSelectablePanel {
}
private static List<Quest_Assignment> readQuests() {
QuestData questData = AllZone.QuestData;
forge.quest.data.QuestData questData = AllZone.QuestData;
ReadQuest_Assignment read = new ReadQuest_Assignment(ForgeProps.getFile(NewConstants.QUEST.QUESTS), questData);
read.run();
ArrayList<Quest_Assignment> questsToDisplay = new ArrayList<Quest_Assignment>();
List<Quest_Assignment> questsToDisplay = new ArrayList<Quest_Assignment>();
if (questData.getAvailableQuests() != null && questData.getAvailableQuests().size() > 0) {
ArrayList<Quest_Assignment> availableQuests = read.getQuestsByIds(questData.getAvailableQuests());
List<Quest_Assignment> availableQuests = read.getQuestsByIds(questData.getAvailableQuests());
questsToDisplay = availableQuests;
}
else {
ArrayList<Quest_Assignment> allAvailableQuests = read.getQuests();
List<Quest_Assignment> allAvailableQuests = read.getQuests();
ArrayList<Integer> availableInts = new ArrayList<Integer>();
List<Integer> availableInts = new ArrayList<Integer>();
int maxQuests = questData.getWin() / 10;
if (maxQuests > 5) {
@@ -80,7 +79,7 @@ public class QuestQuest extends QuestSelectablePanel {
questsToDisplay.add(qa);
}
questData.setAvailableQuests(availableInts);
QuestData.saveData(questData);
questData.saveData();
}//else
return questsToDisplay;
}