remove games from list when finished + added name and owner to tables

This commit is contained in:
BetaSteward 2011-05-09 23:02:54 -04:00
parent 2f515e242b
commit 017b2b4339
12 changed files with 770 additions and 624 deletions

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"> <Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<Properties> <Properties>
@ -23,22 +23,15 @@
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace pref="395" max="32767" attributes="0"/> <Group type="103" groupAlignment="1" attributes="0">
<Component id="btnOK" min="-2" max="-2" attributes="0"/> <Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="btnCancel" min="-2" max="-2" attributes="0"/> <Component id="btnOK" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> <Component id="btnCancel" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0"> </Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="lbDeckType" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="463" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="cbGameType" alignment="0" max="32767" attributes="1"/>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="lblNumPlayers" min="-2" max="-2" attributes="0"/> <Component id="lblNumPlayers" min="-2" max="-2" attributes="0"/>
<Component id="spnNumPlayers" min="-2" pref="57" max="-2" attributes="0"/> <Component id="spnNumPlayers" min="-2" pref="57" max="-2" attributes="0"/>
@ -51,7 +44,7 @@
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="lblAttack" min="-2" max="-2" attributes="0"/> <Component id="lblAttack" min="-2" max="-2" attributes="0"/>
<Component id="cbAttackOption" pref="235" max="32767" attributes="0"/> <Component id="cbAttackOption" pref="287" max="32767" attributes="0"/>
</Group> </Group>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
@ -59,41 +52,50 @@
<Component id="lblNumWins" alignment="0" min="-2" max="-2" attributes="0"/> <Component id="lblNumWins" alignment="0" min="-2" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
<Component id="lblGameType" alignment="0" min="-2" max="-2" attributes="0"/> <Group type="102" alignment="1" attributes="0">
<Component id="cbDeckType" alignment="0" max="32767" attributes="1"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jSeparator2" pref="555" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="player1Panel" pref="555" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="16" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="lbDeckType" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="lblGameType" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="lblName" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="cbDeckType" alignment="0" pref="487" max="32767" attributes="1"/>
<Component id="cbGameType" alignment="1" pref="487" max="32767" attributes="1"/>
<Component id="txtName" alignment="1" pref="487" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="pnlOtherPlayers" alignment="1" pref="555" max="32767" attributes="0"/>
<Component id="jSeparator1" alignment="0" pref="555" max="32767" attributes="0"/>
</Group>
</Group>
</Group> </Group>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jSeparator2" pref="503" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" 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="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="436" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" 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="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jSeparator3" pref="503" max="32767" attributes="0"/> <Component id="jSeparator3" pref="555" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
@ -103,14 +105,21 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="lbDeckType" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0">
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/> <Component id="lblName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbDeckType" min="-2" max="-2" attributes="0"/> <Component id="txtName" alignment="3" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/> </Group>
<Component id="lblGameType" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/> <Group type="103" groupAlignment="1" attributes="0">
<Component id="cbGameType" min="-2" max="-2" attributes="0"/> <Component id="lbDeckType" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/> <Component id="cbDeckType" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="cbGameType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblGameType" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0"> <Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
@ -144,21 +153,21 @@
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/> <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="pnlOtherPlayers" pref="97" max="32767" attributes="0"/> <Component id="pnlOtherPlayers" pref="136" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jSeparator1" pref="19" max="32767" attributes="0"/> <Component id="jSeparator1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnOK" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnOK" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> <Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="223" max="-2" attributes="0"/> <EmptySpace min="-2" pref="201" max="-2" attributes="0"/>
<Component id="jSeparator3" min="-2" max="-2" attributes="0"/> <Component id="jSeparator3" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="159" max="32767" attributes="0"/> <EmptySpace pref="207" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</Group> </Group>
@ -167,7 +176,7 @@
<SubComponents> <SubComponents>
<Component class="javax.swing.JLabel" name="lblGameType"> <Component class="javax.swing.JLabel" name="lblGameType">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Game Type"/> <Property name="text" type="java.lang.String" value="Game Type:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JComboBox" name="cbGameType"> <Component class="javax.swing.JComboBox" name="cbGameType">
@ -177,7 +186,7 @@
</Component> </Component>
<Component class="javax.swing.JLabel" name="lbDeckType"> <Component class="javax.swing.JLabel" name="lbDeckType">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Deck Type"/> <Property name="text" type="java.lang.String" value="Deck Type:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JComboBox" name="cbDeckType"> <Component class="javax.swing.JComboBox" name="cbDeckType">
@ -285,5 +294,15 @@
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spnNumWinsnumPlayersChanged"/> <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spnNumWinsnumPlayersChanged"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JTextField" name="txtName">
</Component>
<Component class="javax.swing.JLabel" name="lblName">
<Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="txtName"/>
</Property>
<Property name="text" type="java.lang.String" value="Name:"/>
</Properties>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

View file

@ -47,7 +47,6 @@ import javax.swing.JOptionPane;
import javax.swing.SpinnerNumberModel; import javax.swing.SpinnerNumberModel;
import mage.Constants.MultiplayerAttackOption; import mage.Constants.MultiplayerAttackOption;
import mage.Constants.RangeOfInfluence; import mage.Constants.RangeOfInfluence;
import mage.cards.decks.DeckCardLists;
import mage.client.components.MageComponents; import mage.client.components.MageComponents;
import mage.client.remote.Session; import mage.client.remote.Session;
import mage.client.table.TablePlayerPanel; import mage.client.table.TablePlayerPanel;
@ -112,10 +111,12 @@ public class NewTableDialog extends MageDialog {
jLabel2 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel();
lblNumWins = new javax.swing.JLabel(); lblNumWins = new javax.swing.JLabel();
spnNumWins = new javax.swing.JSpinner(); spnNumWins = new javax.swing.JSpinner();
txtName = new javax.swing.JTextField();
lblName = new javax.swing.JLabel();
setTitle("New Table"); setTitle("New Table");
lblGameType.setText("Game Type"); lblGameType.setText("Game Type:");
cbGameType.addActionListener(new java.awt.event.ActionListener() { cbGameType.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -123,7 +124,7 @@ public class NewTableDialog extends MageDialog {
} }
}); });
lbDeckType.setText("Deck Type"); lbDeckType.setText("Deck Type:");
btnOK.setText("OK"); btnOK.setText("OK");
btnOK.addActionListener(new java.awt.event.ActionListener() { btnOK.addActionListener(new java.awt.event.ActionListener() {
@ -171,25 +172,22 @@ public class NewTableDialog extends MageDialog {
} }
}); });
lblName.setLabelFor(txtName);
lblName.setText("Name:");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(395, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(btnOK)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel)
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(lbDeckType)
.addContainerGap(463, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(cbGameType, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnOK)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblNumPlayers) .addComponent(lblNumPlayers)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE))
@ -200,52 +198,61 @@ public class NewTableDialog extends MageDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblAttack) .addComponent(lblAttack)
.addComponent(cbAttackOption, 0, 235, Short.MAX_VALUE)) .addComponent(cbAttackOption, 0, 287, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblNumWins))) .addComponent(lblNumWins)))
.addComponent(lblGameType) .addGroup(layout.createSequentialGroup()
.addComponent(cbDeckType, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap()
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 503, Short.MAX_VALUE) .addComponent(jLabel1))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(player1Panel, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel2))
.addGroup(layout.createSequentialGroup()
.addGap(16, 16, 16)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lbDeckType)
.addComponent(lblGameType)
.addComponent(lblName))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(cbDeckType, javax.swing.GroupLayout.Alignment.LEADING, 0, 487, Short.MAX_VALUE)
.addComponent(cbGameType, 0, 487, Short.MAX_VALUE)
.addComponent(txtName, javax.swing.GroupLayout.DEFAULT_SIZE, 487, Short.MAX_VALUE)))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE)
.addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE))))
.addContainerGap()) .addContainerGap())
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addContainerGap(433, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(player1Panel, javax.swing.GroupLayout.DEFAULT_SIZE, 503, Short.MAX_VALUE)
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel2)
.addContainerGap(436, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.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.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 503, Short.MAX_VALUE) .addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE)
.addContainerGap())) .addContainerGap()))
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(lbDeckType) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addGap(0, 0, 0) .addComponent(lblName)
.addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblGameType) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGap(0, 0, 0) .addComponent(lbDeckType)
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cbDeckType, 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.BASELINE)
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblGameType))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
@ -274,19 +281,19 @@ public class NewTableDialog extends MageDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(jLabel2) .addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 97, Short.MAX_VALUE) .addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 136, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 19, Short.MAX_VALUE) .addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnCancel) .addComponent(btnCancel)
.addComponent(btnOK)) .addComponent(btnOK))
.addGap(6, 6, 6)) .addContainerGap())
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(223, 223, 223) .addGap(201, 201, 201)
.addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jSeparator3, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(159, Short.MAX_VALUE))) .addContainerGap(207, Short.MAX_VALUE)))
); );
pack(); pack();
@ -300,7 +307,7 @@ public class NewTableDialog extends MageDialog {
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
GameTypeView gameType = (GameTypeView) cbGameType.getSelectedItem(); GameTypeView gameType = (GameTypeView) cbGameType.getSelectedItem();
MatchOptions options = new MatchOptions("Quick Start Game", gameType.getName()); MatchOptions options = new MatchOptions(this.txtName.getText(), gameType.getName());
options.getPlayerTypes().add("Human"); options.getPlayerTypes().add("Human");
for (TablePlayerPanel player: players) { for (TablePlayerPanel player: players) {
options.getPlayerTypes().add(player.getPlayerType()); options.getPlayerTypes().add(player.getPlayerType());
@ -447,6 +454,7 @@ public class NewTableDialog extends MageDialog {
private javax.swing.JLabel lbDeckType; private javax.swing.JLabel lbDeckType;
private javax.swing.JLabel lblAttack; private javax.swing.JLabel lblAttack;
private javax.swing.JLabel lblGameType; private javax.swing.JLabel lblGameType;
private javax.swing.JLabel lblName;
private javax.swing.JLabel lblNumPlayers; private javax.swing.JLabel lblNumPlayers;
private javax.swing.JLabel lblNumWins; private javax.swing.JLabel lblNumWins;
private javax.swing.JLabel lblRange; private javax.swing.JLabel lblRange;
@ -454,6 +462,7 @@ public class NewTableDialog extends MageDialog {
private javax.swing.JPanel pnlOtherPlayers; private javax.swing.JPanel pnlOtherPlayers;
private javax.swing.JSpinner spnNumPlayers; private javax.swing.JSpinner spnNumPlayers;
private javax.swing.JSpinner spnNumWins; private javax.swing.JSpinner spnNumWins;
private javax.swing.JTextField txtName;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
} }

View file

@ -22,27 +22,35 @@
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="1" attributes="0">
<Component id="pnlPacks" alignment="1" pref="525" max="32767" attributes="0"/>
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/> <Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
<Component id="pnlPacks" alignment="1" pref="563" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnNumPlayers" min="-2" pref="45" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="pnlDraftOptions" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jLabel5" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="lblName" min="-2" max="-2" attributes="0"/>
<Component id="jLabel1" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="txtName" pref="470" max="32767" attributes="0"/>
<Component id="cbTournamentType" alignment="0" pref="470" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<Component id="btnOk" min="-2" max="-2" attributes="0"/> <Component id="btnOk" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="btnCancel" min="-2" max="-2" attributes="0"/> <Component id="btnCancel" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel1" min="-2" pref="113" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbTournamentType" pref="408" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnNumPlayers" min="-2" pref="45" max="-2" attributes="0"/>
</Group>
<Component id="jLabel5" alignment="0" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
@ -51,28 +59,35 @@
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblName" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbTournamentType" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="cbTournamentType" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace min="-2" pref="3" max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" min="-2" max="-2" attributes="0"/> <Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
<Component id="pnlPacks" pref="49" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Component id="pnlPacks" pref="57" max="32767" attributes="0"/>
<Component id="spnNumPlayers" alignment="3" min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" pref="11" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="spnNumPlayers" alignment="0" max="32767" attributes="1"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="pnlDraftOptions" max="32767" attributes="1"/>
</Group> </Group>
<EmptySpace min="-2" pref="19" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" max="32767" attributes="0"/> <Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" 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"/> <Component id="btnOk" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -139,15 +154,15 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0"> <Group type="103" groupAlignment="1" attributes="0">
<Component id="pnlOtherPlayers" alignment="0" pref="525" max="32767" attributes="0"/> <Component id="pnlOtherPlayers" alignment="0" pref="563" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="jLabel3" min="-2" max="-2" attributes="0"/> <Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="445" max="-2" attributes="0"/> <EmptySpace pref="483" max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="jLabel4" min="-2" max="-2" attributes="0"/> <Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="txtPlayer1Name" pref="490" max="32767" attributes="0"/> <Component id="txtPlayer1Name" pref="528" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
@ -164,7 +179,7 @@
<Component id="txtPlayer1Name" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="txtPlayer1Name" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace type="unrelated" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="pnlOtherPlayers" pref="60" max="32767" attributes="0"/> <Component id="pnlOtherPlayers" pref="91" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -206,5 +221,55 @@
<Property name="text" type="java.lang.String" value="Packs"/> <Property name="text" type="java.lang.String" value="Packs"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JTextField" name="txtName">
</Component>
<Component class="javax.swing.JLabel" name="lblName">
<Properties>
<Property name="text" type="java.lang.String" value="Name:"/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="pnlDraftOptions">
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel6" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbDraftTiming" min="-2" pref="107" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="103" alignment="0" groupAlignment="3" attributes="0">
<Component id="cbDraftTiming" alignment="3" max="32767" attributes="1"/>
<Component id="jLabel6" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel6">
<Properties>
<Property name="text" type="java.lang.String" value="Timing:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="cbDraftTiming">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="4">
<StringItem index="0" value="Item 1"/>
<StringItem index="1" value="Item 2"/>
<StringItem index="2" value="Item 3"/>
<StringItem index="3" value="Item 4"/>
</StringArray>
</Property>
</Properties>
</Component>
</SubComponents>
</Container>
</SubComponents> </SubComponents>
</Form> </Form>

View file

@ -1,448 +1,466 @@
/* /*
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved. * Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
* *
* Redistribution and use in source and binary forms, with or without modification, are * Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met: * permitted provided that the following conditions are met:
* *
* 1. Redistributions of source code must retain the above copyright notice, this list of * 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer. * conditions and the following disclaimer.
* *
* 2. Redistributions in binary form must reproduce the above copyright notice, this list * 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials * of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution. * provided with the distribution.
* *
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED * THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND * WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR * FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR * CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR * CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON * SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING * ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF * NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. * ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
* *
* The views and conclusions contained in the software and documentation are those of the * The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed * authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com. * or implied, of BetaSteward_at_googlemail.com.
*/ */
/* /*
* NewTournamentDialog.java * NewTournamentDialog.java
* *
* Created on Jan 28, 2011, 12:15:56 PM * Created on Jan 28, 2011, 12:15:56 PM
*/ */
package mage.client.dialog; package mage.client.dialog;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Logger; import java.util.logging.Logger;
import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox; import javax.swing.JComboBox;
import javax.swing.JOptionPane; import javax.swing.JOptionPane;
import javax.swing.SpinnerNumberModel; import javax.swing.SpinnerNumberModel;
import mage.Constants.MultiplayerAttackOption; import mage.Constants.MultiplayerAttackOption;
import mage.Constants.RangeOfInfluence; import mage.Constants.RangeOfInfluence;
import mage.cards.ExpansionSet; import mage.cards.ExpansionSet;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.remote.Session; import mage.client.remote.Session;
import mage.client.table.TournamentPlayerPanel; import mage.client.table.TournamentPlayerPanel;
import mage.game.draft.DraftOptions; import mage.game.draft.DraftOptions;
import mage.game.draft.DraftOptions.TimingOption; import mage.game.draft.DraftOptions.TimingOption;
import mage.game.tournament.LimitedOptions; import mage.game.tournament.LimitedOptions;
import mage.game.tournament.TournamentOptions; import mage.game.tournament.TournamentOptions;
import mage.sets.Sets; import mage.sets.Sets;
import mage.util.Logging; import mage.util.Logging;
import mage.view.TableView; import mage.view.TableView;
import mage.view.TournamentTypeView; import mage.view.TournamentTypeView;
/** /**
* *
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class NewTournamentDialog extends MageDialog { public class NewTournamentDialog extends MageDialog {
private final static Logger logger = Logging.getLogger(NewTournamentDialog.class.getName()); private final static Logger logger = Logging.getLogger(NewTournamentDialog.class.getName());
private TableView table; private TableView table;
private UUID playerId; private UUID playerId;
private UUID roomId; private UUID roomId;
private Session session; private Session session;
private List<TournamentPlayerPanel> players = new ArrayList<TournamentPlayerPanel>(); private List<TournamentPlayerPanel> players = new ArrayList<TournamentPlayerPanel>();
private List<JComboBox> packs = new ArrayList<JComboBox>(); private List<JComboBox> packs = new ArrayList<JComboBox>();
/** Creates new form NewTournamentDialog */ /** Creates new form NewTournamentDialog */
public NewTournamentDialog() { public NewTournamentDialog() {
initComponents(); initComponents();
} }
public void showDialog(UUID roomId) { public void showDialog(UUID roomId) {
this.roomId = roomId; this.roomId = roomId;
session = MageFrame.getSession(); session = MageFrame.getSession();
this.txtPlayer1Name.setText(session.getUserName()); this.txtPlayer1Name.setText(session.getUserName());
cbTournamentType.setModel(new DefaultComboBoxModel(session.getTournamentTypes().toArray())); cbTournamentType.setModel(new DefaultComboBoxModel(session.getTournamentTypes().toArray()));
cbDraftTiming.setModel(new DefaultComboBoxModel(DraftOptions.TimingOption.values())); cbDraftTiming.setModel(new DefaultComboBoxModel(DraftOptions.TimingOption.values()));
this.setModal(true); this.setModal(true);
setTournamentOptions(); setTournamentOptions();
this.setLocation(150, 100); this.setLocation(150, 100);
this.setVisible(true); this.setVisible(true);
} }
/** This method is called from within the constructor to /** This method is called from within the constructor to
* initialize the form. * initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor. * always regenerated by the Form Editor.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
jLabel1 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel();
cbTournamentType = new javax.swing.JComboBox(); cbTournamentType = new javax.swing.JComboBox();
spnNumPlayers = new javax.swing.JSpinner(); spnNumPlayers = new javax.swing.JSpinner();
jLabel2 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel();
btnOk = new javax.swing.JButton(); btnOk = new javax.swing.JButton();
btnCancel = new javax.swing.JButton(); btnCancel = new javax.swing.JButton();
pnlPacks = new javax.swing.JPanel(); pnlPacks = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel(); jPanel1 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel();
txtPlayer1Name = new javax.swing.JTextField(); txtPlayer1Name = new javax.swing.JTextField();
pnlOtherPlayers = new javax.swing.JPanel(); pnlOtherPlayers = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel();
pnlDraftOptions = new javax.swing.JPanel(); txtName = new javax.swing.JTextField();
cbDraftTiming = new javax.swing.JComboBox(); lblName = new javax.swing.JLabel();
jLabel6 = new javax.swing.JLabel(); pnlDraftOptions = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();
setTitle("New Tournament"); cbDraftTiming = new javax.swing.JComboBox();
jLabel1.setText("Tournament Type:"); setTitle("New Tournament");
cbTournamentType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); jLabel1.setText("Tournament Type:");
cbTournamentType.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { cbTournamentType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbTournamentTypeActionPerformed(evt); cbTournamentType.addActionListener(new java.awt.event.ActionListener() {
} public void actionPerformed(java.awt.event.ActionEvent evt) {
}); cbTournamentTypeActionPerformed(evt);
}
spnNumPlayers.addChangeListener(new javax.swing.event.ChangeListener() { });
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spnNumPlayersStateChanged(evt); spnNumPlayers.addChangeListener(new javax.swing.event.ChangeListener() {
} public void stateChanged(javax.swing.event.ChangeEvent evt) {
}); spnNumPlayersStateChanged(evt);
}
jLabel2.setText("Players:"); });
btnOk.setText("OK"); jLabel2.setText("Players:");
btnOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { btnOk.setText("OK");
btnOkActionPerformed(evt); btnOk.addActionListener(new java.awt.event.ActionListener() {
} public void actionPerformed(java.awt.event.ActionEvent evt) {
}); btnOkActionPerformed(evt);
}
btnCancel.setText("Cancel"); });
btnCancel.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { btnCancel.setText("Cancel");
btnCancelActionPerformed(evt); btnCancel.addActionListener(new java.awt.event.ActionListener() {
} public void actionPerformed(java.awt.event.ActionEvent evt) {
}); btnCancelActionPerformed(evt);
}
pnlPacks.setLayout(new java.awt.GridLayout(0, 1, 2, 0)); });
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); pnlPacks.setLayout(new java.awt.GridLayout(0, 1, 2, 0));
jLabel3.setText("Player 1 (You)");
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11));
jLabel4.setText("Name:"); jLabel3.setText("Player 1 (You)");
txtPlayer1Name.setEditable(false); jLabel4.setText("Name:");
pnlOtherPlayers.setLayout(new java.awt.GridLayout(0, 1, 2, 0)); txtPlayer1Name.setEditable(false);
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); pnlOtherPlayers.setLayout(new java.awt.GridLayout(0, 1, 2, 0));
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) jPanel1.setLayout(jPanel1Layout);
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup() jPanel1Layout.setHorizontalGroup(
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 525, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup() .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jLabel3) .addComponent(pnlOtherPlayers, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 563, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 445, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup() .addComponent(jLabel3)
.addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 483, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
.addComponent(txtPlayer1Name, javax.swing.GroupLayout.DEFAULT_SIZE, 490, Short.MAX_VALUE))) .addComponent(jLabel4)
.addContainerGap()) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
); .addComponent(txtPlayer1Name, javax.swing.GroupLayout.DEFAULT_SIZE, 528, Short.MAX_VALUE)))
jPanel1Layout.setVerticalGroup( .addContainerGap())
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) );
.addGroup(jPanel1Layout.createSequentialGroup() jPanel1Layout.setVerticalGroup(
.addComponent(jLabel3) jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(jLabel3)
.addComponent(jLabel4) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtPlayer1Name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addComponent(jLabel4)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE)) .addComponent(txtPlayer1Name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
); .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE))
jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); );
jLabel5.setText("Packs");
jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11));
cbDraftTiming.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); jLabel5.setText("Packs");
jLabel6.setText("Timing:"); lblName.setText("Name:");
javax.swing.GroupLayout pnlDraftOptionsLayout = new javax.swing.GroupLayout(pnlDraftOptions); jLabel6.setText("Timing:");
pnlDraftOptions.setLayout(pnlDraftOptionsLayout);
pnlDraftOptionsLayout.setHorizontalGroup( cbDraftTiming.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
pnlDraftOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlDraftOptionsLayout.createSequentialGroup() javax.swing.GroupLayout pnlDraftOptionsLayout = new javax.swing.GroupLayout(pnlDraftOptions);
.addComponent(jLabel6) pnlDraftOptions.setLayout(pnlDraftOptionsLayout);
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) pnlDraftOptionsLayout.setHorizontalGroup(
.addComponent(cbDraftTiming, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE) pnlDraftOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addContainerGap(232, Short.MAX_VALUE)) .addGroup(pnlDraftOptionsLayout.createSequentialGroup()
); .addContainerGap()
pnlDraftOptionsLayout.setVerticalGroup( .addComponent(jLabel6)
pnlDraftOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(pnlDraftOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(cbDraftTiming, javax.swing.GroupLayout.PREFERRED_SIZE, 107, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbDraftTiming, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addComponent(jLabel6)) );
); pnlDraftOptionsLayout.setVerticalGroup(
pnlDraftOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); .addGroup(pnlDraftOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
getContentPane().setLayout(layout); .addComponent(cbDraftTiming)
layout.setHorizontalGroup( .addComponent(jLabel6))
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) );
.addGroup(layout.createSequentialGroup()
.addContainerGap() javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) getContentPane().setLayout(layout);
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) layout.setHorizontalGroup(
.addComponent(pnlPacks, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 525, Short.MAX_VALUE) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(btnOk) .addContainerGap()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(btnCancel)) .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup() .addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, 563, Short.MAX_VALUE)
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel2)
.addComponent(cbTournamentType, 0, 408, Short.MAX_VALUE)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5) .addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2) .addComponent(pnlDraftOptions, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))) .addComponent(lblName)
.addContainerGap()) .addComponent(jLabel1))
); .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
layout.setVerticalGroup( .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addComponent(txtName, javax.swing.GroupLayout.DEFAULT_SIZE, 470, Short.MAX_VALUE)
.addGroup(layout.createSequentialGroup() .addComponent(cbTournamentType, javax.swing.GroupLayout.Alignment.LEADING, 0, 470, Short.MAX_VALUE)))
.addContainerGap() .addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(btnOk)
.addComponent(jLabel1) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbTournamentType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(btnCancel)))
.addGap(3, 3, 3) .addContainerGap())
.addComponent(jLabel5) );
.addGap(1, 1, 1) layout.setVerticalGroup(
.addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addContainerGap()
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(spnNumPlayers) .addComponent(lblName))
.addComponent(jLabel2))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addComponent(cbTournamentType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel) .addComponent(jLabel5)
.addComponent(btnOk)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addContainerGap()) .addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, 57, Short.MAX_VALUE)
); .addGap(11, 11, 11)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
pack(); .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
}// </editor-fold>//GEN-END:initComponents .addComponent(spnNumPlayers)
.addComponent(jLabel2))
private void cbTournamentTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbTournamentTypeActionPerformed .addComponent(pnlDraftOptions, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
setTournamentOptions(); .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
}//GEN-LAST:event_cbTournamentTypeActionPerformed .addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem(); .addComponent(btnOk)
TournamentOptions tOptions = new TournamentOptions(tournamentType.getName()); .addComponent(btnCancel)))
tOptions.setTournamentType(tournamentType.getName()); );
tOptions.getPlayerTypes().add("Human");
for (TournamentPlayerPanel player: players) { pack();
tOptions.getPlayerTypes().add((String) player.getPlayerType().getSelectedItem()); }// </editor-fold>//GEN-END:initComponents
}
if (tournamentType.isDraft()) { private void cbTournamentTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbTournamentTypeActionPerformed
DraftOptions options = new DraftOptions(); setTournamentOptions();
options.setDraftType(""); }//GEN-LAST:event_cbTournamentTypeActionPerformed
options.setTiming((TimingOption) this.cbDraftTiming.getSelectedItem());
tOptions.setLimitedOptions(options); private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOkActionPerformed
} TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
if (tournamentType.isLimited()) { TournamentOptions tOptions = new TournamentOptions(this.txtName.getText());
if (tOptions.getLimitedOptions() == null) tOptions.setTournamentType(tournamentType.getName());
tOptions.setLimitedOptions(new LimitedOptions()); tOptions.getPlayerTypes().add("Human");
for (JComboBox pack: packs) { for (TournamentPlayerPanel player: players) {
tOptions.getLimitedOptions().getSets().add((ExpansionSet) pack.getSelectedItem()); tOptions.getPlayerTypes().add((String) player.getPlayerType().getSelectedItem());
} }
} if (tournamentType.isDraft()) {
tOptions.getMatchOptions().setDeckType("Limited"); DraftOptions options = new DraftOptions();
tOptions.getMatchOptions().setWinsNeeded(2); options.setDraftType("");
tOptions.getMatchOptions().setAttackOption(MultiplayerAttackOption.LEFT); options.setTiming((TimingOption) this.cbDraftTiming.getSelectedItem());
tOptions.getMatchOptions().setRange(RangeOfInfluence.ALL); tOptions.setLimitedOptions(options);
table = session.createTournamentTable(roomId, tOptions); }
if (session.joinTournamentTable(roomId, table.getTableId(), this.txtPlayer1Name.getText(), "Human", 1)) { if (tournamentType.isLimited()) {
for (TournamentPlayerPanel player: players) { if (tOptions.getLimitedOptions() == null)
if (!player.getPlayerType().equals("Human")) { tOptions.setLimitedOptions(new LimitedOptions());
if (!player.joinTournamentTable(roomId, table.getTableId())) { for (JComboBox pack: packs) {
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining tournament.", "Error", JOptionPane.ERROR_MESSAGE); tOptions.getLimitedOptions().getSets().add((ExpansionSet) pack.getSelectedItem());
session.removeTable(roomId, table.getTableId()); }
table = null; }
return; tOptions.getMatchOptions().setDeckType("Limited");
} tOptions.getMatchOptions().setWinsNeeded(2);
} tOptions.getMatchOptions().setAttackOption(MultiplayerAttackOption.LEFT);
} tOptions.getMatchOptions().setRange(RangeOfInfluence.ALL);
this.setVisible(false); table = session.createTournamentTable(roomId, tOptions);
return; if (session.joinTournamentTable(roomId, table.getTableId(), this.txtPlayer1Name.getText(), "Human", 1)) {
} for (TournamentPlayerPanel player: players) {
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining tournament.", "Error", JOptionPane.ERROR_MESSAGE); if (!player.getPlayerType().equals("Human")) {
session.removeTable(roomId, table.getTableId()); if (!player.joinTournamentTable(roomId, table.getTableId())) {
table = null; JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining tournament.", "Error", JOptionPane.ERROR_MESSAGE);
}//GEN-LAST:event_btnOkActionPerformed session.removeTable(roomId, table.getTableId());
table = null;
private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed return;
this.table = null; }
this.playerId = null; }
this.setVisible(false); }
}//GEN-LAST:event_btnCancelActionPerformed this.setVisible(false);
return;
private void spnNumPlayersStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spnNumPlayersStateChanged }
int numPlayers = (Integer)this.spnNumPlayers.getValue() - 1; JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining tournament.", "Error", JOptionPane.ERROR_MESSAGE);
createPlayers(numPlayers); session.removeTable(roomId, table.getTableId());
}//GEN-LAST:event_spnNumPlayersStateChanged table = null;
}//GEN-LAST:event_btnOkActionPerformed
private void setTournamentOptions() {
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem(); private void btnCancelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCancelActionPerformed
this.spnNumPlayers.setModel(new SpinnerNumberModel(tournamentType.getMinPlayers(), tournamentType.getMinPlayers(), tournamentType.getMaxPlayers(), 1)); this.table = null;
this.spnNumPlayers.setEnabled(tournamentType.getMinPlayers() != tournamentType.getMaxPlayers()); this.playerId = null;
createPlayers(tournamentType.getMinPlayers() - 1); this.setVisible(false);
if (tournamentType.isLimited()) { }//GEN-LAST:event_btnCancelActionPerformed
this.pnlPacks.setVisible(true);
createPacks(tournamentType.getNumBoosters()); private void spnNumPlayersStateChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spnNumPlayersStateChanged
} int numPlayers = (Integer)this.spnNumPlayers.getValue() - 1;
else { createPlayers(numPlayers);
this.pnlPacks.setVisible(false); }//GEN-LAST:event_spnNumPlayersStateChanged
}
this.pnlDraftOptions.setVisible(tournamentType.isDraft()); private void setTournamentOptions() {
} TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
this.spnNumPlayers.setModel(new SpinnerNumberModel(tournamentType.getMinPlayers(), tournamentType.getMinPlayers(), tournamentType.getMaxPlayers(), 1));
private void createPacks(int numPacks) { this.spnNumPlayers.setEnabled(tournamentType.getMinPlayers() != tournamentType.getMaxPlayers());
while (packs.size() < numPacks) { createPlayers(tournamentType.getMinPlayers() - 1);
JComboBox pack = new JComboBox(); if (tournamentType.isLimited()) {
pack.setModel(new DefaultComboBoxModel(Sets.getInstance().values().toArray())); this.pnlPacks.setVisible(true);
pnlPacks.add(pack); createPacks(tournamentType.getNumBoosters());
packs.add(pack); }
pack.addActionListener(new java.awt.event.ActionListener() { else {
public void actionPerformed(java.awt.event.ActionEvent evt) { this.pnlPacks.setVisible(false);
packActionPerformed(evt); }
} this.pnlDraftOptions.setVisible(tournamentType.isDraft());
}); }
}
this.pack(); private void createPacks(int numPacks) {
this.revalidate(); while (packs.size() > numPacks) {
this.repaint(); pnlPacks.remove(packs.get(packs.size() - 1));
} packs.remove(packs.size() - 1);
}
private void packActionPerformed(java.awt.event.ActionEvent evt) { while (packs.size() < numPacks) {
boolean start = false; JComboBox pack = new JComboBox();
int selectedIndex = 0; pack.setModel(new DefaultComboBoxModel(Sets.getInstance().values().toArray()));
for (JComboBox pack: packs) { pnlPacks.add(pack);
if (!start) { packs.add(pack);
if (evt.getSource().equals(pack)) { pack.addActionListener(new java.awt.event.ActionListener() {
start = true; public void actionPerformed(java.awt.event.ActionEvent evt) {
selectedIndex = pack.getSelectedIndex(); packActionPerformed(evt);
} }
} });
else { }
pack.setSelectedIndex(selectedIndex); this.pack();
} this.revalidate();
} this.repaint();
} }
private void createPlayers(int numPlayers) { private void packActionPerformed(java.awt.event.ActionEvent evt) {
if (numPlayers > players.size()) { boolean start = false;
while (players.size() != numPlayers) { int selectedIndex = 0;
TournamentPlayerPanel playerPanel = new TournamentPlayerPanel(); for (JComboBox pack: packs) {
playerPanel.init(players.size() + 2); if (!start) {
players.add(playerPanel); if (evt.getSource().equals(pack)) {
} start = true;
} selectedIndex = pack.getSelectedIndex();
else if (numPlayers < players.size()) { }
while (players.size() != numPlayers) { }
players.remove(players.size() - 1); else {
} pack.setSelectedIndex(selectedIndex);
} }
drawPlayers(); }
} }
private void drawPlayers() { private void createPlayers(int numPlayers) {
this.pnlOtherPlayers.removeAll(); if (numPlayers > players.size()) {
for (TournamentPlayerPanel panel: players) { while (players.size() != numPlayers) {
this.pnlOtherPlayers.add(panel); TournamentPlayerPanel playerPanel = new TournamentPlayerPanel();
panel.getPlayerType().addActionListener(new java.awt.event.ActionListener() { playerPanel.init(players.size() + 2);
public void actionPerformed(java.awt.event.ActionEvent evt) { players.add(playerPanel);
playerActionPerformed(evt); }
} }
}); else if (numPlayers < players.size()) {
} while (players.size() != numPlayers) {
this.pack(); players.remove(players.size() - 1);
this.revalidate(); }
this.repaint(); }
} drawPlayers();
}
private void playerActionPerformed(java.awt.event.ActionEvent evt) {
boolean start = false; private void drawPlayers() {
int selectedIndex = 0; this.pnlOtherPlayers.removeAll();
for (TournamentPlayerPanel player: players) { for (TournamentPlayerPanel panel: players) {
if (!start) { this.pnlOtherPlayers.add(panel);
if (evt.getSource().equals(player.getPlayerType())) { panel.getPlayerType().addActionListener(new java.awt.event.ActionListener() {
start = true; public void actionPerformed(java.awt.event.ActionEvent evt) {
selectedIndex = player.getPlayerType().getSelectedIndex(); playerActionPerformed(evt);
} }
} });
else { }
player.getPlayerType().setSelectedIndex(selectedIndex); this.pack();
} this.revalidate();
} this.repaint();
} }
public TableView getTable() { private void playerActionPerformed(java.awt.event.ActionEvent evt) {
return table; boolean start = false;
} int selectedIndex = 0;
for (TournamentPlayerPanel player: players) {
if (!start) {
// Variables declaration - do not modify//GEN-BEGIN:variables if (evt.getSource().equals(player.getPlayerType())) {
private javax.swing.JButton btnCancel; start = true;
private javax.swing.JButton btnOk; selectedIndex = player.getPlayerType().getSelectedIndex();
private javax.swing.JComboBox cbDraftTiming; }
private javax.swing.JComboBox cbTournamentType; }
private javax.swing.JLabel jLabel1; else {
private javax.swing.JLabel jLabel2; player.getPlayerType().setSelectedIndex(selectedIndex);
private javax.swing.JLabel jLabel3; }
private javax.swing.JLabel jLabel4; }
private javax.swing.JLabel jLabel5; }
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel1; public TableView getTable() {
private javax.swing.JPanel pnlDraftOptions; return table;
private javax.swing.JPanel pnlOtherPlayers; }
private javax.swing.JPanel pnlPacks;
private javax.swing.JSpinner spnNumPlayers;
private javax.swing.JTextField txtPlayer1Name; // Variables declaration - do not modify//GEN-BEGIN:variables
// End of variables declaration//GEN-END:variables private javax.swing.JButton btnCancel;
private javax.swing.JButton btnOk;
} private javax.swing.JComboBox cbDraftTiming;
private javax.swing.JComboBox cbTournamentType;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel lblName;
private javax.swing.JPanel pnlDraftOptions;
private javax.swing.JPanel pnlOtherPlayers;
private javax.swing.JPanel pnlPacks;
private javax.swing.JSpinner spnNumPlayers;
private javax.swing.JTextField txtName;
private javax.swing.JTextField txtPlayer1Name;
// End of variables declaration//GEN-END:variables
}

View file

@ -93,10 +93,10 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
public void actionPerformed(ActionEvent e) public void actionPerformed(ActionEvent e)
{ {
int modelRow = Integer.valueOf( e.getActionCommand() ); int modelRow = Integer.valueOf( e.getActionCommand() );
UUID tableId = UUID.fromString((String)tableModel.getValueAt(modelRow, 0)); UUID tableId = (UUID)tableModel.getValueAt(modelRow, 8);
UUID gameId = (UUID)tableModel.getValueAt(modelRow, 6); UUID gameId = (UUID)tableModel.getValueAt(modelRow, 7);
String state = (String)tableModel.getValueAt(modelRow, 4); String state = (String)tableModel.getValueAt(modelRow, 5);
boolean isTournament = (Boolean)tableModel.getValueAt(modelRow, 5); boolean isTournament = (Boolean)tableModel.getValueAt(modelRow, 6);
if (state.equals("Join")) { if (state.equals("Join")) {
if (isTournament) { if (isTournament) {
@ -120,7 +120,7 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
} }
}; };
ButtonColumn buttonColumn = new ButtonColumn(tableTables, join, 4); ButtonColumn buttonColumn = new ButtonColumn(tableTables, join, 5);
jSplitPane1.setOpaque(false); jSplitPane1.setOpaque(false);
jScrollPane1.setOpaque(false); jScrollPane1.setOpaque(false);
@ -344,7 +344,7 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
} }
class TableTableModel extends AbstractTableModel { class TableTableModel extends AbstractTableModel {
private String[] columnNames = new String[]{"Table Id", "Game Type", "Deck Type", "Status", "Action"}; private String[] columnNames = new String[]{"Table Name", "Owner", "Game Type", "Deck Type", "Status", "Action"};
private TableView[] tables = new TableView[0]; private TableView[] tables = new TableView[0];
@ -367,14 +367,16 @@ class TableTableModel extends AbstractTableModel {
public Object getValueAt(int arg0, int arg1) { public Object getValueAt(int arg0, int arg1) {
switch (arg1) { switch (arg1) {
case 0: case 0:
return tables[arg0].getTableId().toString(); return tables[arg0].getTableName();
case 1: case 1:
return tables[arg0].getGameType().toString(); return tables[arg0].getControllerName();
case 2: case 2:
return tables[arg0].getDeckType().toString(); return tables[arg0].getGameType().toString();
case 3: case 3:
return tables[arg0].getTableState().toString(); return tables[arg0].getDeckType().toString();
case 4: case 4:
return tables[arg0].getTableState().toString();
case 5:
switch (tables[arg0].getTableState()) { switch (tables[arg0].getTableState()) {
case WAITING: case WAITING:
return "Join"; return "Join";
@ -385,12 +387,14 @@ class TableTableModel extends AbstractTableModel {
default: default:
return ""; return "";
} }
case 5:
return tables[arg0].isTournament();
case 6: case 6:
return tables[arg0].isTournament();
case 7:
if (!tables[arg0].getGames().isEmpty()) if (!tables[arg0].getGames().isEmpty())
return tables[arg0].getGames().get(0); return tables[arg0].getGames().get(0);
return null; return null;
case 8:
return tables[arg0].getTableId();
} }
return ""; return "";
} }
@ -412,7 +416,7 @@ class TableTableModel extends AbstractTableModel {
@Override @Override
public boolean isCellEditable(int rowIndex, int columnIndex) { public boolean isCellEditable(int rowIndex, int columnIndex) {
if (columnIndex != 4) if (columnIndex != 5)
return false; return false;
return true; return true;
} }

View file

@ -47,6 +47,8 @@ public class TableView implements Serializable {
private UUID tableId; private UUID tableId;
private String gameType; private String gameType;
private String deckType; private String deckType;
private String tableName;
private String controllerName;
private TableState tableState; private TableState tableState;
private boolean isTournament; private boolean isTournament;
private List<SeatView> seats = new ArrayList<SeatView>(); private List<SeatView> seats = new ArrayList<SeatView>();
@ -55,6 +57,8 @@ public class TableView implements Serializable {
public TableView(Table table) { public TableView(Table table) {
this.tableId = table.getId(); this.tableId = table.getId();
this.gameType = table.getGameType(); this.gameType = table.getGameType();
this.tableName = table.getName();
this.controllerName = table.getControllerName();
this.deckType = table.getDeckType(); this.deckType = table.getDeckType();
this.tableState = table.getState(); this.tableState = table.getState();
this.isTournament = table.isTournament(); this.isTournament = table.isTournament();
@ -72,6 +76,14 @@ public class TableView implements Serializable {
return tableId; return tableId;
} }
public String getTableName() {
return tableName;
}
public String getControllerName() {
return controllerName;
}
public String getGameType() { public String getGameType() {
return gameType; return gameType;
} }

View file

@ -1,5 +1,5 @@
#default levels #default levels
log4j.rootLogger=debug, logfile log4j.rootLogger=debug, console
#console log #console log
log4j.appender.console=org.apache.log4j.ConsoleAppender log4j.appender.console=org.apache.log4j.ConsoleAppender

View file

@ -66,26 +66,29 @@ public class TableController {
private UUID sessionId; private UUID sessionId;
private UUID chatId; private UUID chatId;
private String controllerName;
private Table table; private Table table;
private Match match; private Match match;
private MatchOptions options; private MatchOptions options;
private Tournament tournament; private Tournament tournament;
private ConcurrentHashMap<UUID, UUID> sessionPlayerMap = new ConcurrentHashMap<UUID, UUID>(); private ConcurrentHashMap<UUID, UUID> sessionPlayerMap = new ConcurrentHashMap<UUID, UUID>();
public TableController(UUID sessionId, MatchOptions options) { public TableController(UUID roomId, UUID sessionId, MatchOptions options) {
this.sessionId = sessionId; this.sessionId = sessionId;
chatId = ChatManager.getInstance().createChatSession(); chatId = ChatManager.getInstance().createChatSession();
this.options = options; this.options = options;
match = GameFactory.getInstance().createMatch(options.getGameType(), options); match = GameFactory.getInstance().createMatch(options.getGameType(), options);
table = new Table(options.getGameType(), options.getName(), DeckValidatorFactory.getInstance().createDeckValidator(options.getDeckType()), options.getPlayerTypes(), match); controllerName = SessionManager.getInstance().getSession(sessionId).getUsername();
table = new Table(roomId, options.getGameType(), options.getName(), controllerName, DeckValidatorFactory.getInstance().createDeckValidator(options.getDeckType()), options.getPlayerTypes(), match);
init(); init();
} }
public TableController(UUID sessionId, TournamentOptions options) { public TableController(UUID roomId, UUID sessionId, TournamentOptions options) {
this.sessionId = sessionId; this.sessionId = sessionId;
chatId = ChatManager.getInstance().createChatSession(); chatId = ChatManager.getInstance().createChatSession();
tournament = TournamentFactory.getInstance().createTournament(options.getTournamentType(), options); tournament = TournamentFactory.getInstance().createTournament(options.getTournamentType(), options);
table = new Table(options.getTournamentType(), options.getName(), DeckValidatorFactory.getInstance().createDeckValidator(options.getMatchOptions().getDeckType()), options.getPlayerTypes(), tournament); controllerName = SessionManager.getInstance().getSession(sessionId).getUsername();
table = new Table(roomId, options.getTournamentType(), options.getName(), controllerName, DeckValidatorFactory.getInstance().createDeckValidator(options.getMatchOptions().getDeckType()), options.getPlayerTypes(), tournament);
} }
private void init() { private void init() {
@ -320,7 +323,7 @@ public class TableController {
UUID choosingPlayerId = match.getChooser(); UUID choosingPlayerId = match.getChooser();
match.endGame(); match.endGame();
table.endGame(); table.endGame();
GameManager.getInstance().saveGame(match.getGame().getId()); // GameManager.getInstance().saveGame(match.getGame().getId());
GameManager.getInstance().removeGame(match.getGame().getId()); GameManager.getInstance().removeGame(match.getGame().getId());
try { try {
if (!match.isMatchOver()) { if (!match.isMatchOver()) {
@ -328,6 +331,9 @@ public class TableController {
match.sideboard(); match.sideboard();
startGame(choosingPlayerId); startGame(choosingPlayerId);
} }
else {
GamesRoomManager.getInstance().getRoom(table.getRoomId()).removeTable(sessionId, table.getId());
}
} catch (GameException ex) { } catch (GameException ex) {
logger.fatal(null, ex); logger.fatal(null, ex);
} }

View file

@ -58,22 +58,22 @@ public class TableManager {
return INSTANCE; return INSTANCE;
} }
public Table createTable(UUID sessionId, MatchOptions options) { public Table createTable(UUID roomId, UUID sessionId, MatchOptions options) {
TableController tableController = new TableController(sessionId, options); TableController tableController = new TableController(roomId, sessionId, options);
controllers.put(tableController.getTable().getId(), tableController); controllers.put(tableController.getTable().getId(), tableController);
tables.put(tableController.getTable().getId(), tableController.getTable()); tables.put(tableController.getTable().getId(), tableController.getTable());
return tableController.getTable(); return tableController.getTable();
} }
public Table createTable(MatchOptions options) { public Table createTable(UUID roomId, MatchOptions options) {
TableController tableController = new TableController(UUID.randomUUID(), options); TableController tableController = new TableController(roomId, UUID.randomUUID(), options);
controllers.put(tableController.getTable().getId(), tableController); controllers.put(tableController.getTable().getId(), tableController);
tables.put(tableController.getTable().getId(), tableController.getTable()); tables.put(tableController.getTable().getId(), tableController.getTable());
return tableController.getTable(); return tableController.getTable();
} }
public Table createTournamentTable(UUID sessionId, TournamentOptions options) { public Table createTournamentTable(UUID roomId, UUID sessionId, TournamentOptions options) {
TableController tableController = new TableController(sessionId, options); TableController tableController = new TableController(roomId, sessionId, options);
controllers.put(tableController.getTable().getId(), tableController); controllers.put(tableController.getTable().getId(), tableController);
tables.put(tableController.getTable().getId(), tableController.getTable()); tables.put(tableController.getTable().getId(), tableController.getTable());
return tableController.getTable(); return tableController.getTable();

View file

@ -73,7 +73,7 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
@Override @Override
public TableView createTable(UUID sessionId, MatchOptions options) { public TableView createTable(UUID sessionId, MatchOptions options) {
Table table = TableManager.getInstance().createTable(sessionId, options); Table table = TableManager.getInstance().createTable(this.getRoomId(), sessionId, options);
tables.put(table.getId(), table); tables.put(table.getId(), table);
return new TableView(table); return new TableView(table);
} }
@ -89,7 +89,7 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
@Override @Override
public TableView createTournamentTable(UUID sessionId, TournamentOptions options) { public TableView createTournamentTable(UUID sessionId, TournamentOptions options) {
Table table = TableManager.getInstance().createTournamentTable(sessionId, options); Table table = TableManager.getInstance().createTournamentTable(this.getRoomId(), sessionId, options);
tables.put(table.getId(), table); tables.put(table.getId(), table);
return new TableView(table); return new TableView(table);
} }

View file

@ -44,6 +44,7 @@ import mage.game.tournament.TournamentPairing;
import mage.game.tournament.TournamentPlayer; import mage.game.tournament.TournamentPlayer;
import mage.server.ChatManager; import mage.server.ChatManager;
import mage.server.TableManager; import mage.server.TableManager;
import mage.server.game.GamesRoomManager;
import mage.server.util.ThreadExecutor; import mage.server.util.ThreadExecutor;
import mage.view.ChatMessage.MessageColor; import mage.view.ChatMessage.MessageColor;
import mage.view.TournamentView; import mage.view.TournamentView;
@ -169,7 +170,7 @@ public class TournamentController {
private void startMatch(TournamentPairing pair, MatchOptions matchOptions) { private void startMatch(TournamentPairing pair, MatchOptions matchOptions) {
try { try {
TableManager tableManager = TableManager.getInstance(); TableManager tableManager = TableManager.getInstance();
Table table = tableManager.createTable(matchOptions); Table table = tableManager.createTable(GamesRoomManager.getInstance().getMainRoomId(), matchOptions);
TournamentPlayer player1 = pair.getPlayer1(); TournamentPlayer player1 = pair.getPlayer1();
TournamentPlayer player2 = pair.getPlayer2(); TournamentPlayer player2 = pair.getPlayer2();
tableManager.addPlayer(getPlayerSessionId(player1.getPlayer().getId()), table.getId(), player1.getPlayer(), player1.getPlayerType(), player1.getDeck()); tableManager.addPlayer(getPlayerSessionId(player1.getPlayer().getId()), table.getId(), player1.getPlayer(), player1.getPlayerType(), player1.getDeck());

View file

@ -47,7 +47,9 @@ import mage.players.Player;
public class Table implements Serializable { public class Table implements Serializable {
private UUID tableId; private UUID tableId;
private UUID roomId;
private String name; private String name;
private String controllerName;
private String gameType; private String gameType;
private Seat[] seats; private Seat[] seats;
private int numSeats; private int numSeats;
@ -59,23 +61,25 @@ public class Table implements Serializable {
protected TableEventSource tableEventSource = new TableEventSource(); protected TableEventSource tableEventSource = new TableEventSource();
public Table(String gameType, String name, DeckValidator validator, List<String> playerTypes, Tournament tournament) { public Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List<String> playerTypes, Tournament tournament) {
this(gameType, name, validator, playerTypes); this(roomId, gameType, name, controllerName, validator, playerTypes);
this.tournament = tournament; this.tournament = tournament;
this.isTournament = true; this.isTournament = true;
} }
public Table(String gameType, String name, DeckValidator validator, List<String> playerTypes, Match match) { public Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List<String> playerTypes, Match match) {
this(gameType, name, validator, playerTypes); this(roomId, gameType, name, controllerName, validator, playerTypes);
this.match = match; this.match = match;
this.isTournament = false; this.isTournament = false;
} }
protected Table(String gameType, String name, DeckValidator validator, List<String> playerTypes) { protected Table(UUID roomId, String gameType, String name, String controllerName, DeckValidator validator, List<String> playerTypes) {
tableId = UUID.randomUUID(); tableId = UUID.randomUUID();
this.roomId = roomId;
this.numSeats = playerTypes.size(); this.numSeats = playerTypes.size();
this.gameType = gameType; this.gameType = gameType;
this.name = name; this.name = name;
this.controllerName = controllerName;
createSeats(playerTypes); createSeats(playerTypes);
this.validator = validator; this.validator = validator;
} }
@ -93,6 +97,10 @@ public class Table implements Serializable {
return tableId; return tableId;
} }
public UUID getRoomId() {
return roomId;
}
public void initGame() { public void initGame() {
state = TableState.DUELING; state = TableState.DUELING;
} }
@ -194,4 +202,8 @@ public class Table implements Serializable {
return tournament; return tournament;
} }
public String getControllerName() {
return controllerName;
}
} }