changes to support multi-duel matches and sideboarding

This commit is contained in:
BetaSteward 2010-12-28 23:34:06 -05:00
parent aa5e45e69d
commit 4b26727d71
40 changed files with 536 additions and 147 deletions

View file

@ -54,11 +54,13 @@ import javax.swing.*;
import javax.swing.JToolBar.Separator;
import com.sun.java.swing.Painter;
import mage.cards.decks.Deck;
import mage.client.cards.CardsStorage;
import mage.client.components.MageComponents;
import mage.client.components.MageJDesktop;
import mage.client.components.MageRoundPane;
import mage.client.components.arcane.ManaSymbols;
import mage.client.constants.Constants.DeckEditorMode;
import mage.client.dialog.*;
import mage.client.plugins.impl.Plugins;
import mage.client.remote.Session;
@ -502,11 +504,10 @@ public class MageFrame extends javax.swing.JFrame {
private void btnDeckEditorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeckEditorActionPerformed
this.gamePane.setVisible(false);
this.tablesPane.setVisible(false);
this.deckEditorPane.setVisible(true);
this.deckEditorPane.showTables();
showDeckEditor(DeckEditorMode.Constructed, null, null);
}//GEN-LAST:event_btnDeckEditorActionPerformed
private void btnPreferencesActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeckEditorActionPerformed
private void btnPreferencesActionPerformed(java.awt.event.ActionEvent evt) {
PhasesDialog.main(new String[]{});
}
@ -562,6 +563,11 @@ public class MageFrame extends javax.swing.JFrame {
this.deckEditorPane.setVisible(false);
}
public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId) {
this.deckEditorPane.setVisible(true);
this.deckEditorPane.show(mode, deck, tableId);
}
public static CombatDialog getCombatDialog() {
return combat;
}

View file

@ -82,4 +82,11 @@ public final class Constants {
public static final String imageBaseDir = "plugins" + File.separator + "images" + File.separator;
public static final String IMAGE_PROPERTIES_FILE = "image.url.properties";
}
public enum DeckEditorMode {
Constructed,
Limited,
Sideboard
}
}

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.1" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<SyntheticProperties>

View file

@ -37,10 +37,13 @@ package mage.client.deckeditor;
import java.awt.Component;
import java.util.HashMap;
import java.util.Map;
import java.util.UUID;
import javax.swing.JComponent;
import mage.cards.decks.Deck;
import mage.client.MagePane;
import mage.client.constants.Constants.DeckEditorMode;
import mage.client.plugins.impl.Plugins;
/**
@ -70,8 +73,8 @@ public class DeckEditorPane extends MagePane {
}
}
public void showTables() {
this.deckEditorPanel1.showDeckEditor();
public void show(DeckEditorMode mode, Deck deck, UUID tableId) {
this.deckEditorPanel1.showDeckEditor(mode, deck, tableId);
this.repaint();
}

View file

@ -36,7 +36,6 @@ package mage.client.deckeditor;
import mage.cards.Card;
import mage.cards.decks.Deck;
import mage.cards.decks.DeckCardLists;
import mage.client.MageFrame;
import mage.client.plugins.impl.Plugins;
import mage.client.util.Event;
@ -49,14 +48,13 @@ import mage.view.CardsView;
import javax.swing.*;
import javax.swing.filechooser.FileFilter;
import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File;
import java.io.IOException;
import java.lang.reflect.Constructor;
import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import mage.client.constants.Constants.DeckEditorMode;
import mage.sets.Sets;
/**
@ -69,6 +67,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
private JFileChooser fcImportDeck;
private Deck deck = new Deck();
private boolean isShowCardInfo = false;
private UUID tableId;
/** Creates new form DeckEditorPanel */
public DeckEditorPanel() {
@ -85,10 +84,18 @@ public class DeckEditorPanel extends javax.swing.JPanel {
jSplitPane1.setOpaque(false);
}
public void showDeckEditor() {
public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId) {
if (deck != null)
this.deck = deck;
this.tableId = tableId;
showDeckEditor(mode);
}
public void showDeckEditor(DeckEditorMode mode) {
this.cardSelector.loadCards(this.bigCard);
this.cardSelector.setVisible(true);
this.jPanel1.setVisible(true);
this.btnSubmit.setVisible(mode == DeckEditorMode.Sideboard);
this.cardSelector.getCardsList().clearCardEventListeners();
this.cardSelector.getCardsList().addCardEventListener(
new Listener<Event> () {
@ -132,6 +139,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
}
}
);
refreshDeck();
this.setVisible(true);
this.repaint();
}
@ -172,6 +180,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
btnNew = new javax.swing.JButton();
btnExit = new javax.swing.JButton();
btnImport = new javax.swing.JButton();
btnSubmit = new javax.swing.JButton();
jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
jSplitPane1.setResizeWeight(0.5);
@ -229,7 +238,15 @@ public class DeckEditorPanel extends javax.swing.JPanel {
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
btnSubmit.setText("Submit");
btnSubmit.setName("btnSubmit"); // NOI18N
btnSubmit.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnSubmitActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -253,7 +270,9 @@ public class DeckEditorPanel extends javax.swing.JPanel {
.addComponent(btnExit))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnImport)))
.addComponent(btnImport)
.addContainerGap()
.addComponent(btnSubmit)))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
@ -270,7 +289,9 @@ public class DeckEditorPanel extends javax.swing.JPanel {
.addComponent(btnNew)
.addComponent(btnExit))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnImport)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnImport)
.addComponent(btnSubmit))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, isShowCardInfo ? 30 : 159, Short.MAX_VALUE)
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
@ -383,6 +404,11 @@ public class DeckEditorPanel extends javax.swing.JPanel {
fcImportDeck.setSelectedFile(null);
}//GEN-LAST:event_btnImportActionPerformed
private void btnSubmitActionPerformed(java.awt.event.ActionEvent evt) {
MageFrame.getSession().submitDeck(tableId, deck.getDeckCardLists());
this.setVisible(false);
}
public DeckImporter getDeckImporter(String file) {
if (file.toLowerCase().endsWith("dec"))
return new DecDeckImporter();
@ -410,6 +436,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
// End of variables declaration//GEN-END:variables
private JComponent cardInfoPane;
private javax.swing.JButton btnSubmit;
}
class DeckFilter extends FileFilter {

View file

@ -23,7 +23,7 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace pref="358" max="32767" attributes="0"/>
<EmptySpace pref="395" max="32767" attributes="0"/>
<Component id="btnOK" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="btnCancel" min="-2" max="-2" attributes="0"/>
@ -32,7 +32,7 @@
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="lbDeckType" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="426" max="32767" attributes="0"/>
<EmptySpace pref="463" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
@ -41,17 +41,22 @@
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblNumPlayers" min="-2" max="-2" attributes="0"/>
<Component id="spnNumPlayers" min="-2" pref="90" max="-2" attributes="0"/>
<Component id="spnNumPlayers" min="-2" pref="57" max="-2" attributes="0"/>
</Group>
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblRange" min="-2" max="-2" attributes="1"/>
<Component id="cbRange" min="-2" pref="141" max="-2" attributes="1"/>
<Component id="cbRange" min="-2" pref="143" max="-2" attributes="1"/>
</Group>
<EmptySpace type="separate" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblAttack" min="-2" max="-2" attributes="0"/>
<Component id="cbAttackOption" alignment="0" min="-2" pref="199" max="-2" attributes="0"/>
<Component id="cbAttackOption" pref="235" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="spnNumWins" min="-2" pref="50" max="-2" attributes="0"/>
<Component id="lblNumWins" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="lblGameType" alignment="0" min="-2" max="-2" attributes="0"/>
@ -61,34 +66,34 @@
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jSeparator2" pref="466" max="32767" attributes="0"/>
<Component id="jSeparator2" pref="503" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="396" max="32767" attributes="0"/>
<EmptySpace pref="433" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="player1Panel" pref="466" max="32767" attributes="0"/>
<Component id="player1Panel" pref="503" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="399" max="32767" attributes="0"/>
<EmptySpace pref="436" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jSeparator1" pref="466" max="32767" attributes="0"/>
<Component id="jSeparator1" pref="503" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Component id="pnlOtherPlayers" alignment="0" min="-2" pref="486" max="-2" attributes="0"/>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jSeparator3" pref="466" max="32767" attributes="0"/>
<Component id="jSeparator3" pref="503" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
@ -105,25 +110,32 @@
<Component id="lblGameType" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="cbGameType" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="lblAttack" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="cbAttackOption" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="lblNumPlayers" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="spnNumPlayers" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Component id="lblNumPlayers" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="spnNumPlayers" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="lblRange" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="cbRange" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="lblAttack" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="cbAttackOption" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
<Component id="lblRange" min="-2" max="-2" attributes="0"/>
<Component id="lblNumWins" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="cbRange" min="-2" max="-2" attributes="0"/>
<Component id="spnNumWins" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jSeparator2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
@ -132,21 +144,21 @@
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="pnlOtherPlayers" pref="83" max="32767" attributes="0"/>
<Component id="pnlOtherPlayers" pref="97" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jSeparator1" pref="4" max="32767" attributes="0"/>
<Component id="jSeparator1" pref="19" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnOK" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
</Group>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="223" max="-2" attributes="0"/>
<Component id="jSeparator3" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="149" max="32767" attributes="0"/>
<EmptySpace pref="159" max="32767" attributes="0"/>
</Group>
</Group>
</Group>
@ -260,5 +272,18 @@
<Property name="text" type="java.lang.String" value="Other Players"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblNumWins">
<Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="spnNumWins"/>
</Property>
<Property name="text" type="java.lang.String" value="Wins"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnNumWins">
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spnNumWinsnumPlayersChanged"/>
</Events>
</Component>
</SubComponents>
</Form>

View file

@ -78,6 +78,7 @@ public class NewTableDialog extends MageDialog {
/** Creates new form NewTableDialog */
public NewTableDialog() {
initComponents();
this.spnNumWins.setModel(new SpinnerNumberModel(1, 1, 5, 1));
}
/** This method is called from within the constructor to
@ -108,6 +109,8 @@ public class NewTableDialog extends MageDialog {
jLabel1 = new javax.swing.JLabel();
jSeparator3 = new javax.swing.JSeparator();
jLabel2 = new javax.swing.JLabel();
lblNumWins = new javax.swing.JLabel();
spnNumWins = new javax.swing.JSpinner();
setTitle("New Table");
@ -158,12 +161,21 @@ public class NewTableDialog extends MageDialog {
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11));
jLabel2.setText("Other Players");
lblNumWins.setLabelFor(spnNumWins);
lblNumWins.setText("Wins");
spnNumWins.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spnNumWinsnumPlayersChanged(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(358, Short.MAX_VALUE)
.addContainerGap(395, Short.MAX_VALUE)
.addComponent(btnOK)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel)
@ -171,7 +183,7 @@ public class NewTableDialog extends MageDialog {
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(lbDeckType)
.addContainerGap(426, Short.MAX_VALUE))
.addContainerGap(463, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
@ -179,43 +191,47 @@ public class NewTableDialog extends MageDialog {
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblNumPlayers)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 90, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblRange)
.addComponent(cbRange, javax.swing.GroupLayout.PREFERRED_SIZE, 141, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(18, 18, 18)
.addComponent(cbRange, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblAttack)
.addComponent(cbAttackOption, javax.swing.GroupLayout.PREFERRED_SIZE, 199, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(cbAttackOption, 0, 235, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblNumWins)))
.addComponent(lblGameType)
.addComponent(cbDeckType, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 466, Short.MAX_VALUE)
.addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 503, Short.MAX_VALUE)
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addContainerGap(396, Short.MAX_VALUE))
.addContainerGap(433, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(player1Panel, javax.swing.GroupLayout.DEFAULT_SIZE, 466, Short.MAX_VALUE)
.addComponent(player1Panel, javax.swing.GroupLayout.DEFAULT_SIZE, 503, Short.MAX_VALUE)
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel2)
.addContainerGap(399, Short.MAX_VALUE))
.addContainerGap(436, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 466, Short.MAX_VALUE)
.addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 503, Short.MAX_VALUE)
.addContainerGap())
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 486, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 466, Short.MAX_VALUE)
.addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 503, Short.MAX_VALUE)
.addContainerGap()))
);
layout.setVerticalGroup(
@ -230,19 +246,24 @@ public class NewTableDialog extends MageDialog {
.addGap(0, 0, 0)
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblNumPlayers)
.addGap(0, 0, 0)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(lblRange)
.addGap(0, 0, 0)
.addComponent(cbRange, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(lblAttack)
.addGap(0, 0, 0)
.addComponent(cbAttackOption, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addComponent(lblAttack)
.addComponent(lblNumWins)
.addGap(0, 0, 0)
.addComponent(cbAttackOption, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(lblNumPlayers)
.addGap(0, 0, 0)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(lblRange)
.addGap(0, 0, 0)
.addComponent(cbRange, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator2, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -252,19 +273,19 @@ public class NewTableDialog extends MageDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 83, Short.MAX_VALUE)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 4, Short.MAX_VALUE)
.addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 19, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnCancel)
.addComponent(btnOK))
.addGap(0, 0, 0))
.addGap(6, 6, 6))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(223, 223, 223)
.addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(149, Short.MAX_VALUE)))
.addContainerGap(159, Short.MAX_VALUE)))
);
pack();
@ -286,7 +307,7 @@ public class NewTableDialog extends MageDialog {
options.setDeckType((String) this.cbDeckType.getSelectedItem());
options.setAttackOption((MultiplayerAttackOption) this.cbAttackOption.getSelectedItem());
options.setRange((RangeOfInfluence) this.cbRange.getSelectedItem());
options.setWinsNeeded(1);
options.setWinsNeeded((Integer)this.spnNumWins.getValue());
table = session.createTable(roomId, options);
try {
if (session.joinTable(roomId, table.getTableId(), this.player1Panel.getPlayerName(), Sets.loadDeck(this.player1Panel.getDeckFile()))) {
@ -324,6 +345,10 @@ public class NewTableDialog extends MageDialog {
createPlayers(numPlayers);
}//GEN-LAST:event_numPlayersChanged
private void spnNumWinsnumPlayersChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spnNumWinsnumPlayersChanged
// TODO add your handling code here:
}//GEN-LAST:event_spnNumWinsnumPlayersChanged
private void setGameOptions() {
GameTypeView gameType = (GameTypeView) cbGameType.getSelectedItem();
this.spnNumPlayers.setModel(new SpinnerNumberModel(gameType.getMinPlayers(), gameType.getMinPlayers(), gameType.getMaxPlayers(), 1));
@ -422,10 +447,12 @@ public class NewTableDialog extends MageDialog {
private javax.swing.JLabel lblAttack;
private javax.swing.JLabel lblGameType;
private javax.swing.JLabel lblNumPlayers;
private javax.swing.JLabel lblNumWins;
private javax.swing.JLabel lblRange;
private mage.client.table.NewPlayerPanel player1Panel;
private javax.swing.JPanel pnlOtherPlayers;
private javax.swing.JSpinner spnNumPlayers;
private javax.swing.JSpinner spnNumWins;
// End of variables declaration//GEN-END:variables
}

View file

@ -33,8 +33,10 @@ import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import mage.cards.decks.Deck;
import mage.client.MageFrame;
import mage.client.chat.ChatPanel;
import mage.client.constants.Constants.DeckEditorMode;
import mage.client.plugins.impl.Plugins;
import mage.client.util.GameManager;
import mage.interfaces.callback.CallbackClient;
@ -44,6 +46,7 @@ import mage.view.AbilityPickerView;
import mage.view.ChatMessage;
import mage.view.GameClientMessage;
import mage.view.GameView;
import mage.view.TableClientMessage;
/**
*
@ -73,9 +76,9 @@ public class Client implements CallbackClient {
logger.info(callback.getMessageId() + " - " + callback.getMethod());
try {
if (callback.getMethod().equals("startGame")) {
UUID[] data = (UUID[]) callback.getData();
GameManager.getInstance().setCurrentPlayerUUID(data[1]);
gameStarted(data[0], data[1]);
TableClientMessage message = (TableClientMessage) callback.getData();
GameManager.getInstance().setCurrentPlayerUUID(message.getPlayerId());
gameStarted(message.getGameId(), message.getPlayerId());
}
else if (callback.getMethod().equals("replayGame")) {
replayGame();
@ -154,6 +157,10 @@ public class Client implements CallbackClient {
logger.warning("message out of sequence - ignoring");
}
}
else if (callback.getMethod().equals("sideboard")) {
TableClientMessage message = (TableClientMessage) callback.getData();
sideboard(message.getDeck(), message.getTableId());
}
messageId = callback.getMessageId();
}
catch (Exception ex) {
@ -199,6 +206,10 @@ public class Client implements CallbackClient {
}
}
protected void sideboard(Deck deck, UUID tableId) {
frame.showDeckEditor(DeckEditorMode.Sideboard, deck, tableId);
}
private void handleException(Exception ex) {
logger.log(Level.SEVERE, "Client error\n", ex);
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Unrecoverable client error. Disconnecting", "Error", JOptionPane.ERROR_MESSAGE);

View file

@ -40,8 +40,6 @@ import java.util.UUID;
import java.util.logging.Level;
import java.util.logging.Logger;
import javax.swing.JOptionPane;
import mage.Constants.MultiplayerAttackOption;
import mage.Constants.RangeOfInfluence;
import mage.cards.decks.DeckCardLists;
import mage.client.MageFrame;
import mage.client.chat.ChatPanel;
@ -49,7 +47,6 @@ import mage.client.components.MageUI;
import mage.client.game.GamePanel;
import mage.client.util.Config;
import mage.game.GameException;
import mage.game.match.MatchType;
import mage.interfaces.MageException;
import mage.game.match.MatchOptions;
import mage.interfaces.Server;
@ -468,6 +465,20 @@ public class Session {
return false;
}
public boolean submitDeck(UUID tableId, DeckCardLists deck) {
try {
server.submitDeck(sessionId, tableId, deck);
return true;
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
} catch (GameException ex) {
handleGameException(ex);
}
return false;
}
public boolean concedeGame(UUID gameId) {
try {
server.concedeGame(gameId, sessionId);