checkstyle

This commit is contained in:
jendave
2011-10-26 18:13:13 +00:00
parent 6d2615eff6
commit d5872e3b47
7 changed files with 693 additions and 493 deletions

View File

@@ -1,30 +1,38 @@
package forge.quest.gui;
import javax.swing.*;
import javax.swing.JPanel;
/**
* <p>Abstract QuestAbstractPanel class.</p>
* <p>
* Abstract QuestAbstractPanel class.
* </p>
*
* @author Forge
* @version $Id$
*/
public abstract class QuestAbstractPanel extends JPanel {
/** Constant <code>serialVersionUID=-6378675010346615367L</code> */
/** Constant <code>serialVersionUID=-6378675010346615367L</code>. */
private static final long serialVersionUID = -6378675010346615367L;
/** The main frame. */
public QuestFrame mainFrame;
/**
* <p>Constructor for QuestAbstractPanel.</p>
* <p>
* Constructor for QuestAbstractPanel.
* </p>
*
* @param mainFrame a {@link forge.quest.gui.QuestFrame} object.
* @param mainFrame
* a {@link forge.quest.gui.QuestFrame} object.
*/
protected QuestAbstractPanel(QuestFrame mainFrame) {
protected QuestAbstractPanel(final QuestFrame mainFrame) {
this.mainFrame = mainFrame;
}
/**
* <p>refreshState.</p>
* <p>
* refreshState.
* </p>
*/
public abstract void refreshState();
}

View File

@@ -1,41 +1,56 @@
package forge.quest.gui;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Dimension;
import java.awt.HeadlessException;
import java.util.HashMap;
import java.util.Map;
import javax.swing.JFrame;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import forge.AllZone;
import forge.gui.GuiUtils;
import forge.quest.gui.bazaar.QuestBazaarPanel;
import forge.view.swing.Gui_HomeScreen;
import forge.view.swing.OldGuiNewGame;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import java.awt.*;
import java.util.HashMap;
import java.util.Map;
/**
* <p>QuestFrame class.</p>
* <p>
* QuestFrame class.
* </p>
*
* @author Forge
* @version $Id$
*/
public class QuestFrame extends JFrame {
/** Constant <code>serialVersionUID=-2832625381531838412L</code> */
/** Constant <code>serialVersionUID=-2832625381531838412L</code>. */
private static final long serialVersionUID = -2832625381531838412L;
/** The visible panel. */
JPanel visiblePanel;
/** The quest layout. */
CardLayout questLayout;
/** Constant <code>MAIN_PANEL="Main"</code> */
/** Constant <code>MAIN_PANEL="Main"</code>. */
public static final String MAIN_PANEL = "Main";
/** Constant <code>BAZAAR_PANEL="Bazaar"</code> */
/** Constant <code>BAZAAR_PANEL="Bazaar"</code>. */
public static final String BAZAAR_PANEL = "Bazaar";
/** The sub panel map. */
Map<String, QuestAbstractPanel> subPanelMap = new HashMap<String, QuestAbstractPanel>();
/**
* <p>Constructor for QuestFrame.</p>
* <p>
* Constructor for QuestFrame.
* </p>
*
* @throws java.awt.HeadlessException if any.
* @throws HeadlessException
* the headless exception
*/
public QuestFrame() throws HeadlessException {
this.setTitle("Quest Mode");
@@ -68,41 +83,48 @@ public class QuestFrame extends JFrame {
}
/**
* <p>showPane.</p>
* <p>
* showPane.
* </p>
*
* @param paneName a {@link java.lang.String} object.
* @param paneName
* a {@link java.lang.String} object.
*/
private void showPane(String paneName) {
private void showPane(final String paneName) {
subPanelMap.get(paneName).refreshState();
questLayout.show(visiblePanel, paneName);
}
/**
* <p>showMainPane.</p>
* <p>
* showMainPane.
* </p>
*/
public void showMainPane() {
public final void showMainPane() {
showPane(MAIN_PANEL);
}
/**
* <p>showBazaarPane.</p>
* <p>
* showBazaarPane.
* </p>
*/
public void showBazaarPane() {
public final void showBazaarPane() {
showPane(BAZAAR_PANEL);
}
/**
* <p>returnToMainMenu.</p>
* <p>
* returnToMainMenu.
* </p>
*/
public void returnToMainMenu() {
public final void returnToMainMenu() {
AllZone.getQuestData().saveData();
if (System.getenv("NG2") != null) {
if (System.getenv("NG2").equalsIgnoreCase("true")) {
String argz[] = {};
String[] argz = {};
Gui_HomeScreen.main(argz);
} else {
new OldGuiNewGame();

View File

@@ -1,65 +1,102 @@
package forge.quest.gui;
import forge.*;
import forge.deck.Deck;
import forge.gui.GuiUtils;
import forge.gui.deckeditor.DeckEditorShop;
import forge.gui.deckeditor.DeckEditorQuest;
import forge.quest.data.QuestData;
import forge.quest.data.QuestUtil;
import forge.quest.data.item.QuestItemZeppelin;
import forge.quest.gui.main.QuestDuel;
import forge.quest.gui.main.QuestDuelPanel;
import forge.quest.gui.main.QuestChallenge;
import forge.quest.gui.main.QuestChallengePanel;
import forge.quest.gui.main.QuestEventManager;
import forge.quest.gui.main.QuestSelectablePanel;
import javax.swing.*;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.awt.BorderLayout;
import java.awt.CardLayout;
import java.awt.Component;
import java.awt.Dimension;
import java.awt.Font;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.awt.event.MouseAdapter;
import java.awt.event.MouseEvent;
import java.util.*;
import java.util.ArrayList;
import java.util.Collections;
import java.util.Comparator;
import java.util.List;
import java.util.Set;
import javax.swing.Box;
import javax.swing.BoxLayout;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JComboBox;
import javax.swing.JLabel;
import javax.swing.JPanel;
import javax.swing.border.EmptyBorder;
import javax.swing.border.EtchedBorder;
import javax.swing.border.TitledBorder;
import forge.AllZone;
import forge.Command;
import forge.Constant;
import forge.GuiDisplay4;
import forge.ImageCache;
import forge.deck.Deck;
import forge.gui.GuiUtils;
import forge.gui.deckeditor.DeckEditorQuest;
import forge.gui.deckeditor.DeckEditorShop;
import forge.quest.data.QuestData;
import forge.quest.data.QuestUtil;
import forge.quest.data.item.QuestItemZeppelin;
import forge.quest.gui.main.QuestChallenge;
import forge.quest.gui.main.QuestChallengePanel;
import forge.quest.gui.main.QuestDuel;
import forge.quest.gui.main.QuestDuelPanel;
import forge.quest.gui.main.QuestEventManager;
import forge.quest.gui.main.QuestSelectablePanel;
/**
* <p>QuestMainPanel class.</p>
* <p>
* QuestMainPanel class.
* </p>
* VIEW - lays out swing components for duel and challenge events.
*
* @author Forge
* @version $Id: QuestMainPanel.java 10358 2011-09-11 05:20:13Z Doublestrike $
*/
public class QuestMainPanel extends QuestAbstractPanel {
/** Constant <code>serialVersionUID=6142934729724012402L</code> */
/** Constant <code>serialVersionUID=6142934729724012402L</code>. */
private static final long serialVersionUID = 6142934729724012402L;
private forge.quest.data.QuestData questData;
private forge.quest.gui.main.QuestEventManager qem;
/** The credits label. */
JLabel creditsLabel = new JLabel();
/** The life label. */
JLabel lifeLabel = new JLabel();
/** The stats label. */
JLabel statsLabel = new JLabel();
/** The title label. */
JLabel titleLabel = new JLabel();
/** The next quest label. */
JLabel nextQuestLabel = new JLabel();
/** The pet combo box. */
JComboBox petComboBox = new JComboBox();
/** The deck combo box. */
JComboBox deckComboBox = new JComboBox();
/** The event button. */
JButton eventButton = new JButton("Challenges");
/** The play button. */
JButton playButton = new JButton("Play");
private QuestSelectablePanel selectedOpponent;
/** The next match panel. */
JPanel nextMatchPanel = new JPanel();
/** The next match layout. */
CardLayout nextMatchLayout;
/** The is showing challenges. */
boolean isShowingChallenges = false;
private JCheckBox devModeCheckBox = new JCheckBox("Developer Mode");
// private JCheckBox newGUICheckbox = new JCheckBox("Use new UI", true);
@@ -67,26 +104,29 @@ public class QuestMainPanel extends QuestAbstractPanel {
private JCheckBox petCheckBox = new JCheckBox("Summon Pet");
private JCheckBox plantBox = new JCheckBox("Summon Plant");
/** Constant <code>NO_DECKS_AVAILABLE="No decks available"</code> */
/** Constant <code>NO_DECKS_AVAILABLE="No decks available"</code>. */
private static final String NO_DECKS_AVAILABLE = "No decks available";
/** Constant <code>DUELS="Duels"</code> */
/** Constant <code>DUELS="Duels"</code>. */
private static final String DUELS = "Duels";
/** Constant <code>CHALLENGES="Challenges"</code> */
/** Constant <code>CHALLENGES="Challenges"</code>. */
private static final String CHALLENGES = "Challenges";
// TODO: Make this ordering permanent
/** Constant <code>lastUsedDeck="//TODO: Make this ordering permanent"</code> */
/** Constant <code>lastUsedDeck="//TODO: Make this ordering permanent"</code>. */
private static String lastUsedDeck;
private JButton zeppelinButton = new JButton("<html>Launch<br>Zeppelin</html>",
GuiUtils.getResizedIcon(GuiUtils.getIconFromFile("ZeppelinIcon.png"), 40, 40));
private JButton zeppelinButton = new JButton("<html>Launch<br>Zeppelin</html>", GuiUtils.getResizedIcon(
GuiUtils.getIconFromFile("ZeppelinIcon.png"), 40, 40));
private JPanel zeppelinPanel = new JPanel();
/**
* <p>Constructor for QuestMainPanel.</p>
* <p>
* Constructor for QuestMainPanel.
* </p>
*
* @param mainFrame a {@link forge.quest.gui.QuestFrame} object.
* @param mainFrame
* a {@link forge.quest.gui.QuestFrame} object.
*/
public QuestMainPanel(QuestFrame mainFrame) {
public QuestMainPanel(final QuestFrame mainFrame) {
super(mainFrame);
questData = AllZone.getQuestData();
qem = AllZone.getQuestEventManager();
@@ -103,7 +143,9 @@ public class QuestMainPanel extends QuestAbstractPanel {
}
/**
* <p>initUI.</p>
* <p>
* initUI.
* </p>
*/
private void initUI() {
refresh();
@@ -126,7 +168,9 @@ public class QuestMainPanel extends QuestAbstractPanel {
}
/**
* <p>createStatusPanel.</p>
* <p>
* createStatusPanel.
* </p>
*
* @return a {@link javax.swing.JPanel} object.
*/
@@ -160,7 +204,9 @@ public class QuestMainPanel extends QuestAbstractPanel {
}
/**
* <p>createSidePanel.</p>
* <p>
* createSidePanel.
* </p>
*
* @return a {@link javax.swing.JPanel} object.
*/
@@ -174,7 +220,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
JButton mainMenuButton = new JButton("Return to Main Menu");
mainMenuButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
public void actionPerformed(final ActionEvent actionEvent) {
mainFrame.returnToMainMenu();
}
});
@@ -182,7 +228,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
JButton cardShopButton = new JButton("Card Shop");
cardShopButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
public void actionPerformed(final ActionEvent actionEvent) {
QuestMainPanel.this.showCardShop();
}
});
@@ -194,7 +240,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
bazaarButton = new JButton("Bazaar");
bazaarButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
public void actionPerformed(final ActionEvent actionEvent) {
QuestMainPanel.this.showBazaar();
}
});
@@ -202,9 +248,8 @@ public class QuestMainPanel extends QuestAbstractPanel {
bazaarButton.setFont(new Font(Font.SANS_SERIF, Font.PLAIN, 20));
}
eventButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
public void actionPerformed(final ActionEvent actionEvent) {
QuestMainPanel.this.showChallenges();
}
});
@@ -212,9 +257,8 @@ public class QuestMainPanel extends QuestAbstractPanel {
eventButton.setFont(new Font(Font.SANS_SERIF, Font.BOLD, 18));
eventButton.setPreferredSize(new Dimension(0, 60));
playButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
public void actionPerformed(final ActionEvent actionEvent) {
QuestMainPanel.this.launchGame();
}
});
@@ -222,7 +266,6 @@ public class QuestMainPanel extends QuestAbstractPanel {
playButton.setFont(new Font(Font.DIALOG, Font.BOLD, 28));
playButton.setPreferredSize(new Dimension(0, 100));
eastComponents.add(playButton);
eastComponents.add(optionsPanel);
@@ -266,7 +309,9 @@ public class QuestMainPanel extends QuestAbstractPanel {
}
/**
* <p>createOptionsPanel.</p>
* <p>
* createOptionsPanel.
* </p>
*
* @return a {@link javax.swing.JPanel} object.
*/
@@ -285,7 +330,9 @@ public class QuestMainPanel extends QuestAbstractPanel {
}
/**
* <p>createMatchSettingsPanel.</p>
* <p>
* createMatchSettingsPanel.
* </p>
*
* @return a {@link javax.swing.JPanel} object.
*/
@@ -302,7 +349,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
GuiUtils.addGap(deckPanel);
this.deckComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
public void actionPerformed(final ActionEvent actionEvent) {
playButton.setEnabled(canGameBeLaunched());
lastUsedDeck = (String) deckComboBox.getSelectedItem();
}
@@ -313,7 +360,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
JButton editDeckButton = new JButton("Deck Editor");
editDeckButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
public void actionPerformed(final ActionEvent actionEvent) {
showDeckEditor();
}
});
@@ -322,7 +369,6 @@ public class QuestMainPanel extends QuestAbstractPanel {
deckPanel.setAlignmentX(LEFT_ALIGNMENT);
matchPanel.add(deckPanel);
GuiUtils.addGap(matchPanel);
if (questData.getMode().equals(forge.quest.data.QuestData.FANTASY)) {
@@ -333,7 +379,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
petPanel.setLayout(new BoxLayout(petPanel, BoxLayout.X_AXIS));
this.petCheckBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
public void actionPerformed(final ActionEvent actionEvent) {
if (petCheckBox.isSelected()) {
questData.getPetManager().setSelectedPet((String) petComboBox.getSelectedItem());
} else {
@@ -347,7 +393,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
petPanel.add(this.petCheckBox);
GuiUtils.addGap(petPanel);
this.petComboBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
public void actionPerformed(final ActionEvent actionEvent) {
if (petCheckBox.isSelected()) {
questData.getPetManager().setSelectedPet((String) petComboBox.getSelectedItem());
} else {
@@ -355,13 +401,12 @@ public class QuestMainPanel extends QuestAbstractPanel {
}
}
});
this.petComboBox.setMaximumSize(
new Dimension(Integer.MAX_VALUE,
(int) this.petCheckBox.getPreferredSize().getHeight()));
this.petComboBox.setMaximumSize(new Dimension(Integer.MAX_VALUE, (int) this.petCheckBox.getPreferredSize()
.getHeight()));
petPanel.add(this.petComboBox);
this.plantBox.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
public void actionPerformed(final ActionEvent actionEvent) {
questData.getPetManager().usePlant = plantBox.isSelected();
}
});
@@ -374,7 +419,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
fantasyPanel.add(petPanel, BorderLayout.WEST);
zeppelinButton.addActionListener(new ActionListener() {
public void actionPerformed(ActionEvent actionEvent) {
public void actionPerformed(final ActionEvent actionEvent) {
questData.randomizeOpponents();
refreshNextMatchPanel();
QuestItemZeppelin zeppelin = (QuestItemZeppelin) questData.getInventory().getItem("Zeppelin");
@@ -394,8 +439,11 @@ public class QuestMainPanel extends QuestAbstractPanel {
}
/**
* <p>createDuelPanel.</p>
* Makes a parent panel, then selectable panel instances for all available duels.
* <p>
* createDuelPanel.
* </p>
* Makes a parent panel, then selectable panel instances for all available
* duels.
*
* @return a {@link javax.swing.JPanel} object.
*/
@@ -421,8 +469,11 @@ public class QuestMainPanel extends QuestAbstractPanel {
}
/**
* <p>createChallengePanel.</p>
* Makes a parent panel, then selectable panel instances for all available challenges.
* <p>
* createChallengePanel.
* </p>
* Makes a parent panel, then selectable panel instances for all available
* challenges.
*
* @return a {@link javax.swing.JPanel} object.
*/
@@ -443,14 +494,15 @@ public class QuestMainPanel extends QuestAbstractPanel {
GuiUtils.addGap(ChallengePanel, 3);
}
return ChallengePanel;
}
/**
* <p>refresh.</p>
* <p>
* refresh.
* </p>
*/
void refresh() {
final void refresh() {
AllZone.getQuestData().saveData();
devModeCheckBox.setSelected(Constant.Runtime.DevMode[0]);
@@ -470,7 +522,7 @@ public class QuestMainPanel extends QuestAbstractPanel {
List<String> deckNames = new ArrayList<String>(questData.getDeckNames());
Collections.sort(deckNames, new Comparator<String>() {
public int compare(String s, String s1) {
public int compare(final String s, final String s1) {
return s.compareToIgnoreCase(s1);
}
});
@@ -520,7 +572,6 @@ public class QuestMainPanel extends QuestAbstractPanel {
petComboBox.setSelectedItem(questData.getPetManager().getSelectedPet().getName());
}
this.plantBox.setEnabled(questData.getPetManager().getPlant().getLevel() > 0);
this.plantBox.setSelected(questData.getPetManager().shouldPlantBeUsed());
@@ -537,7 +588,6 @@ public class QuestMainPanel extends QuestAbstractPanel {
zeppelinButton.setEnabled(false);
}
}
if (nextChallengeInWins() > 0) {
@@ -552,7 +602,9 @@ public class QuestMainPanel extends QuestAbstractPanel {
}
/**
* <p>refreshNextMatchPanel.</p>
* <p>
* refreshNextMatchPanel.
* </p>
*/
private void refreshNextMatchPanel() {
nextMatchPanel.removeAll();
@@ -568,18 +620,22 @@ public class QuestMainPanel extends QuestAbstractPanel {
}
/**
* <p>nextChallengeInWins.</p>
* <p>
* nextChallengeInWins.
* </p>
*
* @return a int.
*/
private int nextChallengeInWins() {
// Number of wins was 25, lowereing the number to 20 to help short term questers.
// Number of wins was 25, lowereing the number to 20 to help short term
// questers.
if (questData.getWin() < 20) {
return 20 - questData.getWin();
}
// The int mul has been lowered by one, should face special opps more frequently.
// The int mul has been lowered by one, should face special opps more
// frequently.
int challengesPlayed = questData.getChallengesPlayed();
int mul = 5;
@@ -594,11 +650,12 @@ public class QuestMainPanel extends QuestAbstractPanel {
return (delta > 0) ? delta : 0;
}
/**
* <p>showDeckEditor.</p>
* <p>
* showDeckEditor.
* </p>
*/
void showDeckEditor() {
final void showDeckEditor() {
Command exit = new Command() {
private static final long serialVersionUID = -5110231879431074581L;
@@ -618,16 +675,20 @@ public class QuestMainPanel extends QuestAbstractPanel {
} // deck editor button
/**
* <p>showBazaar.</p>
* <p>
* showBazaar.
* </p>
*/
void showBazaar() {
final void showBazaar() {
mainFrame.showBazaarPane();
}
/**
* <p>showCardShop.</p>
* <p>
* showCardShop.
* </p>
*/
void showCardShop() {
final void showCardShop() {
Command exit = new Command() {
private static final long serialVersionUID = 8567193482568076362L;
@@ -649,10 +710,13 @@ public class QuestMainPanel extends QuestAbstractPanel {
} // card shop button
/**
* <p>launchGame.</p>
* <p>
* launchGame.
* </p>
*/
private void launchGame() {
//TODO: This is a temporary hack to see if the image cache affects the heap usage significantly.
// TODO This is a temporary hack to see if the image cache affects the
// heap usage significantly.
ImageCache.clear();
QuestItemZeppelin zeppelin = (QuestItemZeppelin) questData.getInventory().getItem("Zeppelin");
@@ -671,14 +735,14 @@ public class QuestMainPanel extends QuestAbstractPanel {
// Dev Mode occurs before Display
Constant.Runtime.DevMode[0] = devModeCheckBox.isSelected();
//DO NOT CHANGE THIS ORDER, GuiDisplay needs to be created before cards are added
// DO NOT CHANGE THIS ORDER, GuiDisplay needs to be created before cards
// are added
// if (newGUICheckbox.isSelected()) {
AllZone.setDisplay(new GuiDisplay4());
// } else {
// AllZone.setDisplay(new GuiDisplay3());
// }
Constant.Runtime.Smooth[0] = smoothLandCheckBox.isSelected();
AllZone.getMatchState().reset();
@@ -694,31 +758,34 @@ public class QuestMainPanel extends QuestAbstractPanel {
mainFrame.dispose();
}
/**
* <p>setupDuel.</p>
* <p>
* setupDuel.
* </p>
*
* @param humanDeck a {@link forge.deck.Deck} object.
* @param humanDeck
* a {@link forge.deck.Deck} object.
*/
void setupDuel(Deck humanDeck) {
final void setupDuel(final Deck humanDeck) {
Deck computer = selectedOpponent.getEvent().getEventDeck();
Constant.Runtime.ComputerDeck[0] = computer;
QuestDuel selectedDuel = (QuestDuel) selectedOpponent.getEvent();
AllZone.setQuestEvent(selectedDuel);
AllZone.getGameAction().newGame(humanDeck, computer,
QuestUtil.getHumanStartingCards(questData),
QuestUtil.getComputerStartingCards(questData),
questData.getLife(), 20, null);
AllZone.getGameAction().newGame(humanDeck, computer, QuestUtil.getHumanStartingCards(questData),
QuestUtil.getComputerStartingCards(questData), questData.getLife(), 20, null);
}
/**
* <p>setupChallenge.</p>
* <p>
* setupChallenge.
* </p>
*
* @param humanDeck a {@link forge.deck.Deck} object.
* @param humanDeck
* a {@link forge.deck.Deck} object.
*/
private void setupChallenge(Deck humanDeck) {
private void setupChallenge(final Deck humanDeck) {
QuestChallenge selectedChallenge = (QuestChallenge) selectedOpponent.getEvent();
Deck computer = selectedOpponent.getEvent().getEventDeck();
@@ -734,13 +801,15 @@ public class QuestMainPanel extends QuestAbstractPanel {
AllZone.getGameAction().newGame(humanDeck, computer,
QuestUtil.getHumanStartingCards(questData, selectedChallenge),
QuestUtil.getComputerStartingCards(questData, selectedChallenge),
questData.getLife() + extraLife, selectedChallenge.getAILife(), selectedChallenge);
QuestUtil.getComputerStartingCards(questData, selectedChallenge), questData.getLife() + extraLife,
selectedChallenge.getAILife(), selectedChallenge);
}
/**
* <p>getEventIconFilename.</p>
* <p>
* getEventIconFilename.
* </p>
*
* @return a {@link java.lang.String} object.
*/
@@ -749,9 +818,11 @@ public class QuestMainPanel extends QuestAbstractPanel {
}
/**
* <p>showChallenges.</p>
* <p>
* showChallenges.
* </p>
*/
void showChallenges() {
final void showChallenges() {
if (isShowingChallenges) {
isShowingChallenges = false;
eventButton.setText("Challenges");
@@ -769,16 +840,33 @@ public class QuestMainPanel extends QuestAbstractPanel {
refresh();
}
/**
* The Class SelectionAdapter.
*/
class SelectionAdapter extends MouseAdapter {
/** The selectable panel. */
QuestSelectablePanel selectablePanel;
SelectionAdapter(QuestSelectablePanel selectablePanel) {
/**
* Instantiates a new selection adapter.
*
* @param selectablePanel
* the selectable panel
*/
SelectionAdapter(final QuestSelectablePanel selectablePanel) {
super();
this.selectablePanel = selectablePanel;
}
/*
* (non-Javadoc)
*
* @see
* java.awt.event.MouseAdapter#mouseClicked(java.awt.event.MouseEvent)
*/
@Override
public void mouseClicked(MouseEvent mouseEvent) {
public void mouseClicked(final MouseEvent mouseEvent) {
if (selectedOpponent != null) {
selectedOpponent.setSelected(false);
@@ -793,27 +881,31 @@ public class QuestMainPanel extends QuestAbstractPanel {
}
/**
* <p>moveDeckToTop.</p>
* <p>
* moveDeckToTop.
* </p>
*
* @param humanDeckName a {@link java.lang.String} object.
* @param humanDeckName
* a {@link java.lang.String} object.
*/
private void moveDeckToTop(String humanDeckName) {
private void moveDeckToTop(final String humanDeckName) {
QuestMainPanel.lastUsedDeck = humanDeckName;
}
/**
* <p>canGameBeLaunched.</p>
* <p>
* canGameBeLaunched.
* </p>
*
* @return a boolean.
*/
boolean canGameBeLaunched() {
final boolean canGameBeLaunched() {
return !(NO_DECKS_AVAILABLE.equals(deckComboBox.getSelectedItem()) || selectedOpponent == null);
}
/** {@inheritDoc} */
@Override
public void refreshState() {
public final void refreshState() {
this.refresh();
}

View File

@@ -1,5 +1,26 @@
package forge.quest.gui;
import java.awt.Color;
import java.awt.GridLayout;
import java.awt.Rectangle;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
import javax.swing.BorderFactory;
import javax.swing.ButtonGroup;
import javax.swing.JButton;
import javax.swing.JCheckBox;
import javax.swing.JFrame;
import javax.swing.JLabel;
import javax.swing.JOptionPane;
import javax.swing.JPanel;
import javax.swing.JRadioButton;
import javax.swing.JTextArea;
import javax.swing.SwingConstants;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import forge.AllZone;
import forge.error.ErrorViewer;
import forge.gui.GuiUtils;
@@ -9,22 +30,16 @@ import forge.quest.data.QuestPreferences;
import forge.view.swing.Gui_HomeScreen;
import forge.view.swing.OldGuiNewGame;
import javax.swing.*;
import javax.swing.border.Border;
import javax.swing.border.TitledBorder;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.WindowAdapter;
import java.awt.event.WindowEvent;
/**
* <p>Gui_QuestOptions class.</p>
* <p>
* Gui_QuestOptions class.
* </p>
*
* @author Forge
* @version $Id$
*/
public class QuestOptions extends JFrame {
/** Constant <code>serialVersionUID=2018518804206822235L</code> */
/** Constant <code>serialVersionUID=2018518804206822235L</code>. */
private static final long serialVersionUID = 2018518804206822235L;
private QuestData questData = new QuestData();
@@ -52,7 +67,9 @@ public class QuestOptions extends JFrame {
private JPanel jPanel3 = new JPanel();
/**
* <p>Constructor for Gui_QuestOptions.</p>
* <p>
* Constructor for Gui_QuestOptions.
* </p>
*/
public QuestOptions() {
try {
@@ -70,17 +87,18 @@ public class QuestOptions extends JFrame {
}
/**
* <p>setup.</p>
* <p>
* setup.
* </p>
*/
private void setup() {
// make the text look correct on the screen
jTextArea1.setBackground(getBackground());
// if user closes this window, go back to "New Game" screen
this.addWindowListener(new WindowAdapter() {
@Override
public void windowClosing(WindowEvent ev) {
public void windowClosing(final WindowEvent ev) {
QuestOptions.this.dispose();
if (System.getenv("NG2") != null) {
@@ -98,12 +116,16 @@ public class QuestOptions extends JFrame {
});
// is there any saved data?
if (!questData.hasSaveFile()) continueQuestButton.setEnabled(false);
if (!questData.hasSaveFile()) {
continueQuestButton.setEnabled(false);
}
} // setup()
// show total number of games for each difficulty
/**
* <p>setupRadioButtonText.</p>
* <p>
* setupRadioButtonText.
* </p>
*/
private void setupRadioButtonText() {
String[] diff = QuestPreferences.getDifficulty();
@@ -120,14 +142,16 @@ public class QuestOptions extends JFrame {
} // setupRadioButtonText()
/**
* <p>jbInit.</p>
* <p>
* jbInit.
* </p>
*
* @throws java.lang.Exception if any.
* @throws java.lang.Exception
* if any.
*/
private void jbInit() throws Exception {
TitledBorder titledBorder1 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white,
new Color(148, 145, 140)),
"Quest Length");
TitledBorder titledBorder1 = new TitledBorder(BorderFactory.createEtchedBorder(Color.white, new Color(148, 145,
140)), "Quest Length");
Border border2 = BorderFactory.createEtchedBorder(Color.white, new Color(148, 145, 140));
TitledBorder titledBorder2 = new TitledBorder(border2, "Continue");
jLabel1.setFont(new java.awt.Font("Dialog", 0, 25));
@@ -140,7 +164,7 @@ public class QuestOptions extends JFrame {
continueQuestButton.setFont(new java.awt.Font("Dialog", 0, 18));
continueQuestButton.setText("Continue Quest");
continueQuestButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
public void actionPerformed(final ActionEvent e) {
continueQuestButton_actionPerformed(e);
}
});
@@ -170,7 +194,7 @@ public class QuestOptions extends JFrame {
newQuestButton.setFont(new java.awt.Font("Dialog", 0, 16));
newQuestButton.setText("New Quest");
newQuestButton.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(ActionEvent e) {
public void actionPerformed(final ActionEvent e) {
newQuestButton_actionPerformed(e);
}
});
@@ -225,11 +249,14 @@ public class QuestOptions extends JFrame {
}
/**
* <p>continueQuestButton_actionPerformed.</p>
* <p>
* continueQuestButton_actionPerformed.
* </p>
*
* @param e a {@link java.awt.event.ActionEvent} object.
* @param e
* a {@link java.awt.event.ActionEvent} object.
*/
void continueQuestButton_actionPerformed(ActionEvent e) {
final void continueQuestButton_actionPerformed(final ActionEvent e) {
// set global variable
AllZone.setQuestData(QuestDataIO.loadData());
AllZone.getQuestData().guessDifficultyIndex();
@@ -240,43 +267,49 @@ public class QuestOptions extends JFrame {
}
/**
* <p>newQuestButton_actionPerformed.</p>
* <p>
* newQuestButton_actionPerformed.
* </p>
*
* @param e a {@link java.awt.event.ActionEvent} object.
* @param e
* a {@link java.awt.event.ActionEvent} object.
*/
void newQuestButton_actionPerformed(ActionEvent e) {
final void newQuestButton_actionPerformed(final ActionEvent e) {
int difficulty = 0;
String mode = fantasyRadio.isSelected() ? forge.quest.data.QuestData.FANTASY : forge.quest.data.QuestData.REALISTIC;
String mode = fantasyRadio.isSelected() ? forge.quest.data.QuestData.FANTASY
: forge.quest.data.QuestData.REALISTIC;
if (easyRadio.isSelected()) difficulty = 0;
else if (mediumRadio.isSelected()) difficulty = 1;
else if (hardRadio.isSelected()) difficulty = 2;
else if (veryHardRadio.isSelected()) difficulty = 3;
else //user didn't select a difficulty{
if (easyRadio.isSelected()) {
difficulty = 0;
} else if (mediumRadio.isSelected()) {
difficulty = 1;
} else if (hardRadio.isSelected()) {
difficulty = 2;
} else if (veryHardRadio.isSelected()) {
difficulty = 3;
} else {
// user didn't select a difficulty{
return;
}
if (questData.hasSaveFile()) {
// this will overwrite your save file!
Object[] possibleValues = {"Yes", "No"};
Object choice = JOptionPane.showOptionDialog(null, "Starting a new quest will overwrite your current quest. Continue?",
"Start New Quest?", JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE,
null, possibleValues, possibleValues[1]);
Object choice = JOptionPane.showOptionDialog(null,
"Starting a new quest will overwrite your current quest. Continue?", "Start New Quest?",
JOptionPane.YES_NO_OPTION, JOptionPane.QUESTION_MESSAGE, null, possibleValues, possibleValues[1]);
if (!choice.equals(0))
if (!choice.equals(0)) {
return;
}
}
// give the user a few cards to build a deck
questData.newGame(difficulty, mode, cbStandardStart.isSelected());
questData.saveData();
// set global variable
AllZone.setQuestData(questData);
@@ -284,5 +317,4 @@ public class QuestOptions extends JFrame {
new QuestFrame();
}
}

View File

@@ -1,7 +1,13 @@
package forge.quest.gui;
import static java.util.Collections.unmodifiableList;
import javax.swing.*;
import java.util.List;
import javax.swing.AbstractListModel;
import javax.swing.JList;
import javax.swing.JPanel;
import javax.swing.JScrollPane;
import javax.swing.event.ListSelectionEvent;
import javax.swing.event.ListSelectionListener;
@@ -12,10 +18,6 @@ import forge.gui.game.CardDetailPanel;
import forge.gui.game.CardPicturePanel;
import forge.item.CardPrinted;
import java.util.List;
import static java.util.Collections.unmodifiableList;
/**
* A simple JPanel that shows three columns: card list, pic, and description..
*
@@ -33,7 +35,13 @@ public class QuestWinLoseCardViewer extends JPanel {
private CardDetailPanel detail;
private CardPicturePanel picture;
public QuestWinLoseCardViewer(List<CardPrinted> list) {
/**
* Instantiates a new quest win lose card viewer.
*
* @param list
* the list
*/
public QuestWinLoseCardViewer(final List<CardPrinted> list) {
this.list = unmodifiableList(list);
jList = new JList(new ChooserListModel());
detail = new CardDetailPanel(null);
@@ -53,10 +61,14 @@ public class QuestWinLoseCardViewer extends JPanel {
private static final long serialVersionUID = 3871965346333840556L;
public int getSize() { return list.size(); }
public Object getElementAt(int index) { return list.get(index); }
public int getSize() {
return list.size();
}
public Object getElementAt(final int index) {
return list.get(index);
}
}
private class SelListener implements ListSelectionListener {
private Card[] cache = null;
@@ -72,8 +84,10 @@ public class QuestWinLoseCardViewer extends JPanel {
}
}
private void ensureCacheHas(int row, CardPrinted cp) {
if (cache == null) { cache = new Card[list.size()]; }
private void ensureCacheHas(final int row, final CardPrinted cp) {
if (cache == null) {
cache = new Card[list.size()];
}
if (null == cache[row]) {
Card card = AllZone.getCardFactory().getCard(cp.getName(), null);
card.setCurSetCode(cp.getSet());

View File

@@ -12,7 +12,6 @@ import javax.swing.JLabel;
import javax.swing.SwingConstants;
import net.slightlymagic.maxmtg.Predicate;
import forge.AllZone;
import forge.CardList;
import forge.Constant;
@@ -31,14 +30,17 @@ import forge.quest.data.QuestData;
import forge.quest.data.QuestMatchState;
import forge.quest.data.QuestPreferences;
import forge.quest.data.QuestUtil;
import forge.quest.gui.QuestWinLoseCardViewer;
import forge.quest.gui.main.QuestEvent;
import forge.quest.gui.main.QuestChallenge;
import forge.quest.gui.main.QuestEvent;
import forge.view.swing.WinLoseModeHandler;
/** <p>QuestWinLoseHandler.</p>
* Processes win/lose presentation for Quest events. This presentation
* is displayed by WinLoseFrame. Components to be added to pnlCustom in
// TODO: Auto-generated Javadoc
/**
* <p>
* QuestWinLoseHandler.
* </p>
* Processes win/lose presentation for Quest events. This presentation is
* displayed by WinLoseFrame. Components to be added to pnlCustom in
* WinLoseFrame should use MigLayout.
*
*/
@@ -47,6 +49,8 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
private ImageIcon icoTemp;
private JLabel lblTemp1;
private JLabel lblTemp2;
/** The spacer. */
int spacer = 50;
private class CommonObjects {
@@ -57,6 +61,9 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
private CommonObjects model;
/**
* Instantiates a new quest win lose handler.
*/
public QuestWinLoseHandler() {
super();
model = new CommonObjects();
@@ -67,13 +74,14 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
}
/**
* <p>startNextRound.</p>
* <p>
* startNextRound.
* </p>
* Either continues or restarts a current game.
*
* @param e a {@link java.awt.event.ActionEvent} object.
*/
@Override
public void startNextRound() {
public final void startNextRound() {
if (Constant.Quest.fantasyQuest[0]) {
int extraLife = 0;
@@ -92,34 +100,35 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
computerLife = ((QuestChallenge) model.qEvent).getAILife();
}
AllZone.getGameAction().newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0],
humanList, computerList, humanLife, computerLife, model.qEvent);
AllZone.getGameAction().newGame(Constant.Runtime.HumanDeck[0], Constant.Runtime.ComputerDeck[0], humanList,
computerList, humanLife, computerLife, model.qEvent);
} else {
super.startNextRound();
}
}
/**
* <p>populateCustomPanel.</p>
* Checks conditions of win and fires various reward display methods accordingly.
* <p>
* populateCustomPanel.
* </p>
* Checks conditions of win and fires various reward display methods
* accordingly.
*
* @param boolean indicating if custom panel has contents.
* @return true, if successful
*/
@Override
public boolean populateCustomPanel() {
public final boolean populateCustomPanel() {
view.btnRestart.setVisible(false);
model.qData.getCards().resetNewList();
if (!model.qMatchState.isMatchOver()) {
view.btnQuit.setText("Quit (15 Credits)");
return false;
}
else {
} else {
view.btnContinue.setVisible(false);
if (wonMatch) {
view.btnQuit.setText("Great!");
}
else {
} else {
view.btnQuit.setText("OK");
}
}
@@ -155,7 +164,8 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
penalizeLoss();
}
// Win or lose, still a chance to win a booster, frequency set in preferences
// Win or lose, still a chance to win a booster, frequency set in
// preferences
int outcome = wonMatch ? model.qData.getWin() : model.qData.getLost();
if (outcome % QuestPreferences.getWinsForBooster(model.qData.getDifficultyIndex()) == 0) {
awardBooster();
@@ -165,12 +175,15 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
}
/**
* <p>actionOnQuit.</p>
* When "quit" button is pressed, this method adjusts quest data as appropriate and saves.
* <p>
* actionOnQuit.
* </p>
* When "quit" button is pressed, this method adjusts quest data as
* appropriate and saves.
*
*/
@Override
public void actionOnQuit() {
public final void actionOnQuit() {
// Record win/loss in quest data
if (wonMatch) {
model.qData.addWin();
@@ -194,7 +207,9 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
}
/**
* <p>awardEventCredits.</p>
* <p>
* awardEventCredits.
* </p>
* Generates and displays standard rewards for gameplay and skill level.
*
*/
@@ -217,33 +232,23 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
if (diff.equalsIgnoreCase("medium")) {
multiplier = 1.5;
}
else if(diff.equalsIgnoreCase("hard")) {
} else if (diff.equalsIgnoreCase("hard")) {
multiplier = 2;
}
else if(diff.equalsIgnoreCase("very hard")) {
} else if (diff.equalsIgnoreCase("very hard")) {
multiplier = 2.5;
}
else if(diff.equalsIgnoreCase("expert")) {
} else if (diff.equalsIgnoreCase("expert")) {
multiplier = 3;
}
credBase += (int) (base*multiplier +
(QuestPreferences.getMatchRewardTotalWins() * model.qData.getWin()));
credBase += (int) (base * multiplier + (QuestPreferences.getMatchRewardTotalWins() * model.qData.getWin()));
sb.append(diff + " opponent: " + credBase + " credits.<br>");
// Gameplay bonuses (for each game win)
boolean hasNeverLost = true;
Player computer = AllZone.getComputerPlayer();
for (GameSummary game : model.qMatchState.getGamesPlayed()) {
if (game.isWinner(computer.getName())) {
hasNeverLost = false;
continue; // no rewards for losing a game
}
// Alternate win
GamePlayerRating aiRating = game.getPlayerRating(computer.getName());
GamePlayerRating humanRating = game.getPlayerRating(AllZone.getHumanPlayer().getName());
@@ -256,39 +261,48 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
winConditionName = game.getWinSpellEffect();
} else {
switch (whyAiLost) {
case Poisoned: winConditionName = "Poison"; break;
case Milled: winConditionName = "Milled"; break;
case SpellEffect: winConditionName = aiRating.getLossSpellName(); break;
default: break;
case Poisoned:
winConditionName = "Poison";
break;
case Milled:
winConditionName = "Milled";
break;
case SpellEffect:
winConditionName = aiRating.getLossSpellName();
break;
default:
break;
}
}
credGameplay += 50;
sb.append(String.format("Alternate win condition: <u>%s</u>! " +
"Bonus: %d credits.<br>",
sb.append(String.format("Alternate win condition: <u>%s</u>! " + "Bonus: %d credits.<br>",
winConditionName, 50));
}
// Mulligan to zero
int cntCardsHumanStartedWith = humanRating.getOpeningHandSize();
int mulliganReward = QuestPreferences.getMatchMullToZero();
if (0 == cntCardsHumanStartedWith) {
credGameplay += mulliganReward;
sb.append(String.format("Mulliganed to zero and still won! " +
"Bonus: %d credits.<br>", mulliganReward));
sb.append(String
.format("Mulliganed to zero and still won! " + "Bonus: %d credits.<br>", mulliganReward));
}
// Early turn bonus
int winTurn = game.getTurnGameEnded();
int turnCredits = getCreditsRewardForWinByTurn(winTurn);
if (winTurn == 0) { System.err.println("QuestWinLoseHandler > " +
"turn calculation error: Zero turn win");
} else if (winTurn == 1) { sb.append("Won in one turn!");
} else if (winTurn <= 5) { sb.append("Won by turn 5!");
} else if (winTurn <= 10) { sb.append("Won by turn 10!");
} else if (winTurn <= 15) { sb.append("Won by turn 15!");
if (winTurn == 0) {
System.err.println("QuestWinLoseHandler > " + "turn calculation error: Zero turn win");
} else if (winTurn == 1) {
sb.append("Won in one turn!");
} else if (winTurn <= 5) {
sb.append("Won by turn 5!");
} else if (winTurn <= 10) {
sb.append("Won by turn 10!");
} else if (winTurn <= 15) {
sb.append("Won by turn 15!");
}
if (turnCredits > 0) {
@@ -301,8 +315,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
if (hasNeverLost) {
credUndefeated += QuestPreferences.getMatchRewardNoLosses();
int reward = QuestPreferences.getMatchRewardNoLosses();
sb.append(String.format("You have not lost once! " +
"Bonus: %d credits.<br>", reward));
sb.append(String.format("You have not lost once! " + "Bonus: %d credits.<br>", reward));
}
// Estates bonus
@@ -323,7 +336,8 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
sb.append("Estates bonus: 20%.<br>");
break;
default: break;
default:
break;
}
credTotal += credEstates;
@@ -357,17 +371,18 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
lblTemp2.setIcon(icoTemp);
lblTemp2.setIconTextGap(50);
view.pnlCustom.add(lblTemp1, "align center, width 95%!");
view.pnlCustom.add(lblTemp2, "align center, width 95%!, gaptop 10");
}
/**
* <p>awardRandomRare.</p>
* <p>
* awardRandomRare.
* </p>
* Generates and displays a random rare win case.
*
*/
private void awardRandomRare(String message) {
private void awardRandomRare(final String message) {
CardPrinted c = model.qData.getCards().addRandomRare();
List<CardPrinted> cardsWon = new ArrayList<CardPrinted>();
cardsWon.add(c);
@@ -377,13 +392,14 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon);
view.pnlCustom.add(lblTemp1,"align center, width 95%!, " +
"gaptop " + spacer + ", gapbottom 10");
view.pnlCustom.add(lblTemp1, "align center, width 95%!, " + "gaptop " + spacer + ", gapbottom 10");
view.pnlCustom.add(cv, "align center, width 95%!");
}
/**
* <p>awardJackpot.</p>
* <p>
* awardJackpot.
* </p>
* Generates and displays jackpot win case.
*
*/
@@ -394,34 +410,38 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
lblTemp1 = new TitleLabel("You just won 10 random rares!");
QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon);
view.pnlCustom.add(lblTemp1,"align center, width 95%!, " +
"gaptop " + spacer + ", gapbottom 10");
view.pnlCustom.add(lblTemp1, "align center, width 95%!, " + "gaptop " + spacer + ", gapbottom 10");
view.pnlCustom.add(cv, "align center, width 95%!");
}
/**
* <p>awardBooster.</p>
* <p>
* awardBooster.
* </p>
* Generates and displays booster pack win case.
*
*/
private void awardBooster() {
ListChooser<GameFormat> ch = new ListChooser<GameFormat>("Choose bonus booster format", 1, SetUtils.getFormats());
ListChooser<GameFormat> ch = new ListChooser<GameFormat>("Choose bonus booster format", 1,
SetUtils.getFormats());
ch.show();
GameFormat selected = ch.getSelectedValue();
List<CardPrinted> cardsWon = model.qData.getCards().addCards(Predicate.and(selected.getFilterPrinted(),CardPrinted.Predicates.Presets.nonAlternate));
List<CardPrinted> cardsWon = model.qData.getCards().addCards(
Predicate.and(selected.getFilterPrinted(), CardPrinted.Predicates.Presets.nonAlternate));
// Generate Swing components and attach.
lblTemp1 = new TitleLabel("Bonus booster pack from the \"" + selected.getName() + "\" format!");
QuestWinLoseCardViewer cv = new QuestWinLoseCardViewer(cardsWon);
view.pnlCustom.add(lblTemp1,"align center, width 95%!, " +
"gaptop " + spacer + ", gapbottom 10");
view.pnlCustom.add(lblTemp1, "align center, width 95%!, " + "gaptop " + spacer + ", gapbottom 10");
view.pnlCustom.add(cv, "align center, width 95%!");
}
/**
* <p>awardChallengeWin.</p>
* <p>
* awardChallengeWin.
* </p>
* Generates and displays win case for challenge event.
*
*/
@@ -445,8 +465,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
// Generate Swing components and attach.
icoTemp = GuiUtils.getResizedIcon("BoxIcon.png", 0.5);
lblTemp1 = new TitleLabel("Challenge Rewards for \"" +
((QuestChallenge)model.qEvent).getTitle() + "\"");
lblTemp1 = new TitleLabel("Challenge Rewards for \"" + ((QuestChallenge) model.qEvent).getTitle() + "\"");
lblTemp2 = new JLabel(sb.toString());
lblTemp2.setFont(AllZone.getSkin().font2.deriveFont(Font.PLAIN, 14));
@@ -455,8 +474,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
lblTemp2.setIconTextGap(50);
lblTemp2.setIcon(icoTemp);
view.pnlCustom.add(lblTemp1,"align center, width 95%!, " +
"gaptop " + spacer);
view.pnlCustom.add(lblTemp1, "align center, width 95%!, " + "gaptop " + spacer);
view.pnlCustom.add(lblTemp2, "align center, width 95%!, height 80!, gapbottom 10");
if (cardsWon != null) {
@@ -483,7 +501,9 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
}
/**
* <p>getLuckyCoinResult.</p>
* <p>
* getLuckyCoinResult.
* </p>
* A chance check, for rewards like random rares.
*
* @return boolean
@@ -495,25 +515,41 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
}
/**
* <p>getCreditsRewardForAltWin.</p>
* <p>
* getCreditsRewardForAltWin.
* </p>
* Retrieves credits for win under special conditions.
*
* @param GameLossReason why AI lost
* @param GameLossReason
* why AI lost
* @return int
*/
private int getCreditsRewardForAltWin(final GameLossReason whyAiLost) {
switch (whyAiLost) {
case LifeReachedZero: return 0; // nothing special here, ordinary kill
case Milled: return QuestPreferences.getMatchRewardMilledWinBonus();
case Poisoned: return QuestPreferences.getMatchRewardPoisonWinBonus();
case DidNotLoseYet: return QuestPreferences.getMatchRewardAltWinBonus(); // Felidar, Helix Pinnacle, etc.
case SpellEffect: return QuestPreferences.getMatchRewardAltWinBonus(); // Door to Nothingness, etc.
default: return 0;
case LifeReachedZero:
return 0; // nothing special here, ordinary kill
case Milled:
return QuestPreferences.getMatchRewardMilledWinBonus();
case Poisoned:
return QuestPreferences.getMatchRewardPoisonWinBonus();
case DidNotLoseYet:
return QuestPreferences.getMatchRewardAltWinBonus(); // Felidar,
// Helix
// Pinnacle,
// etc.
case SpellEffect:
return QuestPreferences.getMatchRewardAltWinBonus(); // Door to
// Nothingness,
// etc.
default:
return 0;
}
}
/**
* <p>getCreditsRewardForWinByTurn.</p>
* <p>
* getCreditsRewardForWinByTurn.
* </p>
* Retrieves credits for win on or under turn count.
*
* @param int turn count
@@ -524,14 +560,11 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
if (iTurn == 1) {
credits = QuestPreferences.getMatchRewardWinFirst();
}
else if (iTurn <= 5) {
} else if (iTurn <= 5) {
credits = QuestPreferences.getMatchRewardWinByFifth();
}
else if (iTurn <= 10) {
} else if (iTurn <= 10) {
credits = QuestPreferences.getMatchRewardWinByTen();
}
else if (iTurn <= 15) {
} else if (iTurn <= 15) {
credits = QuestPreferences.getMatchRewardWinByFifteen();
}
@@ -544,7 +577,7 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
*/
@SuppressWarnings("serial")
private class TitleLabel extends JLabel {
TitleLabel(String msg) {
TitleLabel(final String msg) {
super(msg);
this.setFont(AllZone.getSkin().font2.deriveFont(Font.ITALIC, 16));
this.setPreferredSize(new Dimension(200, 40));
@@ -553,5 +586,4 @@ public class QuestWinLoseHandler extends WinLoseModeHandler {
this.setBorder(BorderFactory.createMatteBorder(1, 0, 1, 0, Color.white));
}
}
}

View File

@@ -1,2 +1,2 @@
/** Forge Card Game */
/** Forge Card Game. */
package forge.quest.gui;