* Tournaments - Added handling for constructed formats and password protection.

This commit is contained in:
LevelX2 2014-10-12 04:19:28 +02:00
parent 8459e8d1f9
commit 5ccc1c91ae
32 changed files with 666 additions and 267 deletions

View file

@ -45,6 +45,7 @@ public class JoinTableDialog extends MageDialog {
private UUID tableId; private UUID tableId;
private UUID roomId; private UUID roomId;
private boolean joined = false; private boolean joined = false;
private boolean isTournament;
/** Creates new form JoinTableDialog */ /** Creates new form JoinTableDialog */
public JoinTableDialog() { public JoinTableDialog() {
@ -53,10 +54,12 @@ public class JoinTableDialog extends MageDialog {
txtPassword.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD, "")); txtPassword.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD, ""));
} }
public void showDialog(UUID roomId, UUID tableId) { public void showDialog(UUID roomId, UUID tableId, boolean isTournament, boolean isLimited) {
this.roomId = roomId; this.roomId = roomId;
this.tableId = tableId; this.tableId = tableId;
this.isTournament = isTournament;
this.newPlayerPanel.setPlayerName(MageFrame.getSession().getUserName()); this.newPlayerPanel.setPlayerName(MageFrame.getSession().getUserName());
this.newPlayerPanel.showDeckElements(isLimited);
this.setModal(true); this.setModal(true);
this.setLocation(100, 100); this.setLocation(100, 100);
this.setVisible(true); this.setVisible(true);
@ -146,7 +149,12 @@ public class JoinTableDialog extends MageDialog {
Session session = MageFrame.getSession(); Session session = MageFrame.getSession();
try { try {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD, txtPassword.getText()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD, txtPassword.getText());
joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText()); if (isTournament) {
joined = session.joinTournamentTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
} else {
joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), this.txtPassword.getText());
}
} catch (Exception ex) { } catch (Exception ex) {
handleError(ex); handleError(ex);
} }

View file

@ -106,7 +106,7 @@
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<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 min="-2" pref="4" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="txtName" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="txtName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblName" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblName" alignment="3" min="-2" max="-2" attributes="0"/>
@ -165,7 +165,7 @@
<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="189" max="32767" attributes="0"/> <Component id="pnlOtherPlayers" pref="244" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jSeparator1" min="-2" max="-2" attributes="0"/> <Component id="jSeparator1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
@ -179,7 +179,7 @@
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="201" 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="285" max="32767" attributes="0"/> <EmptySpace pref="335" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</Group> </Group>

View file

@ -260,7 +260,7 @@ public class NewTableDialog extends MageDialog {
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() .addGap(4, 4, 4)
.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(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblName) .addComponent(lblName)
@ -308,7 +308,7 @@ 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, 189, Short.MAX_VALUE) .addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 244, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jSeparator1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .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)
@ -320,7 +320,7 @@ public class NewTableDialog extends MageDialog {
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGap(201, 201, 201) .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(285, Short.MAX_VALUE))) .addContainerGap(335, Short.MAX_VALUE)))
); );
pack(); pack();

View file

@ -25,16 +25,7 @@
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Component id="pnlPlayers" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnNumPlayers" min="-2" pref="46" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
<Component id="pnlDraftOptions" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="cbAllowSpectators" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
<Component id="pnlPacks" alignment="1" max="32767" attributes="0"/> <Component id="pnlPacks" alignment="1" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/> <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
@ -42,8 +33,41 @@
<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="player1Panel" alignment="0" max="32767" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2" attributes="0"> <Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="lblNbrPlayers" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnNumPlayers" min="-2" pref="46" max="-2" attributes="0"/>
</Group>
<Component id="lblPacks" alignment="0" min="-2" max="-2" attributes="0"/>
<Component id="lblPlayer1" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" pref="28" max="-2" attributes="0"/>
<Component id="pnlDraftOptions" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="lblNumRounds" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<EmptySpace max="32767" attributes="0"/>
<Component id="lblConstructionTime" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="spnConstructTime" min="-2" pref="50" max="-2" attributes="0"/>
<Group type="102" attributes="0">
<Component id="spnNumRounds" min="-2" pref="50" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbAllowSpectators" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="lblName" min="-2" max="-2" attributes="0"/> <Component id="lblName" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
@ -53,43 +77,50 @@
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="cbTimeLimit" max="32767" attributes="1"/> <Component id="cbTimeLimit" max="32767" attributes="1"/>
</Group> </Group>
<Group type="102" alignment="0" attributes="0"> <Group type="102" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0"> <Group type="103" groupAlignment="1" attributes="0">
<Component id="lblTournamentType" min="-2" max="-2" attributes="0"/> <Group type="102" alignment="1" attributes="0">
<Component id="lblDraftCube" min="-2" max="-2" attributes="0"/> <Component id="lblGameType" max="-2" attributes="0"/>
</Group> <EmptySpace max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <Component id="cbGameType" min="-2" pref="290" max="-2" attributes="1"/>
<Group type="103" groupAlignment="0" attributes="0"> </Group>
<Component id="cbDraftCube" min="-2" pref="295" max="-2" attributes="0"/> <Group type="102" attributes="0">
<Component id="cbTournamentType" min="-2" pref="295" max="-2" attributes="0"/> <Component id="lbDeckType" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbDeckType" min="-2" pref="290" max="-2" attributes="1"/>
</Group>
<Group type="102" attributes="0">
<Component id="lblDraftCube" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbDraftCube" min="-2" pref="290" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="lblTournamentType" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbTournamentType" min="-2" pref="290" max="-2" attributes="0"/>
</Group>
</Group> </Group>
<EmptySpace min="7" pref="7" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
<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="lblFreeMulligans" min="-2" max="-2" attributes="0"/>
<Component id="lblPassword" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Component id="lblConstructionTime" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnConstructTime" min="-2" pref="50" max="-2" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="lblFreeMulligans" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnFreeMulligans" min="-2" pref="41" max="-2" attributes="0"/> <Component id="spnFreeMulligans" min="-2" pref="41" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="lblNumWins" min="-2" max="-2" attributes="0"/> <Component id="lblNumWins" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="spnNumWins" min="-2" pref="50" max="-2" attributes="0"/> <Component id="spnNumWins" min="-2" pref="50" max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="1" attributes="0"> <Component id="txtPassword" max="32767" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="lblNumRounds" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnNumRounds" min="-2" pref="50" max="-2" attributes="0"/>
</Group>
</Group> </Group>
</Group> </Group>
<Component id="lblPacks" alignment="0" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
@ -98,14 +129,14 @@
<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"/> <EmptySpace min="-2" pref="4" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="txtName" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="txtName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblName" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lbTimeLimit" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lbTimeLimit" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbTimeLimit" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="cbTimeLimit" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblConstructionTime" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblPassword" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnConstructTime" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="txtPassword" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </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">
@ -120,23 +151,47 @@
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="cbDraftCube" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="cbDraftCube" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblDraftCube" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblDraftCube" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnNumRounds" alignment="3" min="-2" max="-2" attributes="0"/> </Group>
<Component id="lblNumRounds" alignment="3" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="cbDeckType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lbDeckType" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="lblGameType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbGameType" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="lblPacks" min="-2" max="-2" attributes="0"/> <Component id="lblPacks" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="pnlPacks" pref="95" max="32767" attributes="0"/> <Group type="103" groupAlignment="1" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/> <Group type="102" attributes="0">
<Group type="103" groupAlignment="1" max="-2" attributes="0"> <Component id="pnlPacks" min="-2" max="-2" attributes="0"/>
<Component id="cbAllowSpectators" alignment="1" max="32767" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jLabel2" alignment="1" max="32767" attributes="0"/> <Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="spnNumPlayers" alignment="1" max="32767" attributes="1"/> <Group type="103" alignment="1" groupAlignment="3" attributes="0">
<Component id="pnlDraftOptions" alignment="1" pref="0" max="32767" attributes="1"/> <Component id="cbAllowSpectators" alignment="3" max="32767" attributes="0"/>
<Component id="spnNumRounds" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblNumRounds" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="lblNbrPlayers" alignment="1" max="32767" attributes="0"/>
<Component id="spnNumPlayers" alignment="1" max="32767" attributes="1"/>
<Component id="pnlDraftOptions" alignment="1" pref="0" max="32767" attributes="1"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblPlayer1" min="-2" pref="25" max="-2" attributes="0"/>
</Group>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="spnConstructTime" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblConstructionTime" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group> </Group>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/> <Component id="player1Panel" pref="59" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="pnlPlayers" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" 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"/> <Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/>
@ -164,12 +219,15 @@
</Component> </Component>
<Component class="javax.swing.JComboBox" name="cbTimeLimit"> <Component class="javax.swing.JComboBox" name="cbTimeLimit">
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblConstructionTime"> <Component class="javax.swing.JLabel" name="lblPassword">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Construction Time (Minutes):"/> <Property name="text" type="java.lang.String" value="Password:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JSpinner" name="spnConstructTime"> <Component class="javax.swing.JTextField" name="txtPassword">
<Properties>
<Property name="toolTipText" type="java.lang.String" value="Players have to enter this password to be able to enter the created table."/>
</Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblTournamentType"> <Component class="javax.swing.JLabel" name="lblTournamentType">
<Properties> <Properties>
@ -191,12 +249,34 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbTournamentTypeActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbTournamentTypeActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JLabel" name="lbDeckType">
<Properties>
<Property name="text" type="java.lang.String" value="Deck Type:"/>
<Property name="focusable" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="cbDeckType">
</Component>
<Component class="javax.swing.JLabel" name="lblGameType">
<Properties>
<Property name="text" type="java.lang.String" value="Game Type:"/>
<Property name="focusable" type="boolean" value="false"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="cbGameType">
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbGameTypeActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="lblFreeMulligans"> <Component class="javax.swing.JLabel" name="lblFreeMulligans">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Free Mulligans:"/> <Property name="text" type="java.lang.String" value="Free Mulligans:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JSpinner" name="spnFreeMulligans"> <Component class="javax.swing.JSpinner" name="spnFreeMulligans">
<Properties>
<Property name="toolTipText" type="java.lang.String" value="Players can take this number of free mulligans (their hand size will not be reduced)."/>
</Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblNumWins"> <Component class="javax.swing.JLabel" name="lblNumWins">
<Properties> <Properties>
@ -210,7 +290,7 @@
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblDraftCube"> <Component class="javax.swing.JLabel" name="lblDraftCube">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Draft Cube"/> <Property name="text" type="java.lang.String" value="Draft Cube:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JComboBox" name="cbDraftCube"> <Component class="javax.swing.JComboBox" name="cbDraftCube">
@ -247,6 +327,13 @@
</Properties> </Properties>
</Component> </Component>
<Container class="javax.swing.JPanel" name="pnlPacks"> <Container class="javax.swing.JPanel" name="pnlPacks">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/>
</Border>
</Property>
</Properties>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout"> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
<Property name="columns" type="int" value="1"/> <Property name="columns" type="int" value="1"/>
@ -254,7 +341,7 @@
<Property name="rows" type="int" value="0"/> <Property name="rows" type="int" value="0"/>
</Layout> </Layout>
</Container> </Container>
<Component class="javax.swing.JLabel" name="jLabel2"> <Component class="javax.swing.JLabel" name="lblNbrPlayers">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Players:"/> <Property name="text" type="java.lang.String" value="Players:"/>
</Properties> </Properties>
@ -318,67 +405,49 @@
<Property name="text" type="java.lang.String" value="Allow spectators"/> <Property name="text" type="java.lang.String" value="Allow spectators"/>
</Properties> </Properties>
</Component> </Component>
<Container class="javax.swing.JPanel" name="jPanel1"> <Component class="javax.swing.JLabel" name="lblPlayer1">
<Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="11" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="Player 1 (You)"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblConstructionTime">
<Properties>
<Property name="text" type="java.lang.String" value="Construction Time (Minutes):"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnConstructTime">
<Properties>
<Property name="toolTipText" type="java.lang.String" value="The time players have to build their deck."/>
</Properties>
</Component>
<Component class="mage.client.table.NewPlayerPanel" name="player1Panel">
</Component>
<Container class="javax.swing.JPanel" name="pnlPlayers">
<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="1" attributes="0">
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtPlayer1Name" max="32767" attributes="0"/>
</Group>
<Component id="pnlOtherPlayers" alignment="0" max="32767" attributes="0"/> <Component id="pnlOtherPlayers" alignment="0" max="32767" attributes="0"/>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Component id="pnlOtherPlayers" alignment="0" max="32767" attributes="0"/>
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="txtPlayer1Name" pref="24" max="32767" attributes="0"/>
<Component id="jLabel4" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="pnlOtherPlayers" pref="91" max="32767" attributes="0"/>
</Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
<SubComponents> <SubComponents>
<Component class="javax.swing.JLabel" name="jLabel3"> <Container class="javax.swing.JPanel" name="pnlOtherPlayers">
<Properties> <Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<Font name="Tahoma" size="11" style="1"/>
</Property>
<Property name="text" type="java.lang.String" value="Player 1 (You)"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Properties>
<Property name="text" type="java.lang.String" value="Name:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtPlayer1Name">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor"> <Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo"> <Border info="org.netbeans.modules.form.compat2.border.EtchedBorderInfo">
<EtchetBorder/> <EtchetBorder/>
</Border> </Border>
</Property> </Property>
<Property name="disabledTextColor" type="java.awt.Color" editor="org.netbeans.beaninfo.editors.ColorEditor">
<Color blue="0" green="0" id="black" palette="1" red="0" type="palette"/>
</Property>
<Property name="enabled" type="boolean" value="false"/>
</Properties> </Properties>
</Component>
<Container class="javax.swing.JPanel" name="pnlOtherPlayers">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout"> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
<Property name="columns" type="int" value="1"/> <Property name="columns" type="int" value="1"/>

View file

@ -42,10 +42,10 @@ 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.cards.decks.importer.DeckImporterUtil;
import mage.cards.repository.ExpansionInfo; import mage.cards.repository.ExpansionInfo;
import mage.cards.repository.ExpansionRepository; import mage.cards.repository.ExpansionRepository;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.table.TablePlayerPanel;
import mage.client.table.TournamentPlayerPanel; import mage.client.table.TournamentPlayerPanel;
import mage.constants.MatchTimeLimit; import mage.constants.MatchTimeLimit;
import mage.constants.MultiplayerAttackOption; import mage.constants.MultiplayerAttackOption;
@ -55,6 +55,7 @@ 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.remote.Session; import mage.remote.Session;
import mage.view.GameTypeView;
import mage.view.TableView; import mage.view.TableView;
import mage.view.TournamentTypeView; import mage.view.TournamentTypeView;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
@ -94,8 +95,13 @@ public class NewTournamentDialog extends MageDialog {
this.roomId = roomId; this.roomId = roomId;
if (!lastSessionId.equals(MageFrame.getSession().getSessionId())) { if (!lastSessionId.equals(MageFrame.getSession().getSessionId())) {
lastSessionId = session.getSessionId(); lastSessionId = session.getSessionId();
this.txtPlayer1Name.setText(session.getUserName()); this.player1Panel.setPlayerName(session.getUserName());
this.player1Panel.showLevel(false); // no computer
cbTournamentType.setModel(new DefaultComboBoxModel(session.getTournamentTypes().toArray())); cbTournamentType.setModel(new DefaultComboBoxModel(session.getTournamentTypes().toArray()));
cbGameType.setModel(new DefaultComboBoxModel(session.getTournamentGameTypes().toArray()));
cbDeckType.setModel(new DefaultComboBoxModel(session.getDeckTypes()));
cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values())); cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values()));
cbDraftCube.setModel(new DefaultComboBoxModel(session.getDraftCubes())); cbDraftCube.setModel(new DefaultComboBoxModel(session.getDraftCubes()));
cbDraftTiming.setModel(new DefaultComboBoxModel(DraftOptions.TimingOption.values())); cbDraftTiming.setModel(new DefaultComboBoxModel(DraftOptions.TimingOption.values()));
@ -126,10 +132,14 @@ public class NewTournamentDialog extends MageDialog {
txtName = new javax.swing.JTextField(); txtName = new javax.swing.JTextField();
lbTimeLimit = new javax.swing.JLabel(); lbTimeLimit = new javax.swing.JLabel();
cbTimeLimit = new javax.swing.JComboBox(); cbTimeLimit = new javax.swing.JComboBox();
lblConstructionTime = new javax.swing.JLabel(); lblPassword = new javax.swing.JLabel();
spnConstructTime = new javax.swing.JSpinner(); txtPassword = new javax.swing.JTextField();
lblTournamentType = new javax.swing.JLabel(); lblTournamentType = new javax.swing.JLabel();
cbTournamentType = new javax.swing.JComboBox(); cbTournamentType = new javax.swing.JComboBox();
lbDeckType = new javax.swing.JLabel();
cbDeckType = new javax.swing.JComboBox();
lblGameType = new javax.swing.JLabel();
cbGameType = new javax.swing.JComboBox();
lblFreeMulligans = new javax.swing.JLabel(); lblFreeMulligans = new javax.swing.JLabel();
spnFreeMulligans = new javax.swing.JSpinner(); spnFreeMulligans = new javax.swing.JSpinner();
lblNumWins = new javax.swing.JLabel(); lblNumWins = new javax.swing.JLabel();
@ -140,16 +150,17 @@ public class NewTournamentDialog extends MageDialog {
spnNumRounds = new javax.swing.JSpinner(); spnNumRounds = new javax.swing.JSpinner();
lblPacks = new javax.swing.JLabel(); lblPacks = new javax.swing.JLabel();
pnlPacks = new javax.swing.JPanel(); pnlPacks = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel(); lblNbrPlayers = new javax.swing.JLabel();
spnNumPlayers = new javax.swing.JSpinner(); spnNumPlayers = new javax.swing.JSpinner();
pnlDraftOptions = new javax.swing.JPanel(); pnlDraftOptions = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel(); jLabel6 = new javax.swing.JLabel();
cbDraftTiming = new javax.swing.JComboBox(); cbDraftTiming = new javax.swing.JComboBox();
cbAllowSpectators = new javax.swing.JCheckBox(); cbAllowSpectators = new javax.swing.JCheckBox();
jPanel1 = new javax.swing.JPanel(); lblPlayer1 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel(); lblConstructionTime = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel(); spnConstructTime = new javax.swing.JSpinner();
txtPlayer1Name = new javax.swing.JTextField(); player1Panel = new mage.client.table.NewPlayerPanel();
pnlPlayers = new javax.swing.JPanel();
pnlOtherPlayers = new javax.swing.JPanel(); pnlOtherPlayers = new javax.swing.JPanel();
btnOk = new javax.swing.JButton(); btnOk = new javax.swing.JButton();
btnCancel = new javax.swing.JButton(); btnCancel = new javax.swing.JButton();
@ -163,7 +174,9 @@ public class NewTournamentDialog extends MageDialog {
org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cbTimeLimit, org.jdesktop.beansbinding.ObjectProperty.create(), lbTimeLimit, org.jdesktop.beansbinding.BeanProperty.create("labelFor")); org.jdesktop.beansbinding.Binding binding = org.jdesktop.beansbinding.Bindings.createAutoBinding(org.jdesktop.beansbinding.AutoBinding.UpdateStrategy.READ_WRITE, cbTimeLimit, org.jdesktop.beansbinding.ObjectProperty.create(), lbTimeLimit, org.jdesktop.beansbinding.BeanProperty.create("labelFor"));
bindingGroup.addBinding(binding); bindingGroup.addBinding(binding);
lblConstructionTime.setText("Construction Time (Minutes):"); lblPassword.setText("Password:");
txtPassword.setToolTipText("Players have to enter this password to be able to enter the created table.");
lblTournamentType.setText("Tournament Type:"); lblTournamentType.setText("Tournament Type:");
@ -174,8 +187,22 @@ public class NewTournamentDialog extends MageDialog {
} }
}); });
lbDeckType.setText("Deck Type:");
lbDeckType.setFocusable(false);
lblGameType.setText("Game Type:");
lblGameType.setFocusable(false);
cbGameType.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
cbGameTypeActionPerformed(evt);
}
});
lblFreeMulligans.setText("Free Mulligans:"); lblFreeMulligans.setText("Free Mulligans:");
spnFreeMulligans.setToolTipText("Players can take this number of free mulligans (their hand size will not be reduced).");
lblNumWins.setText("Wins:"); lblNumWins.setText("Wins:");
spnNumWins.addChangeListener(new javax.swing.event.ChangeListener() { spnNumWins.addChangeListener(new javax.swing.event.ChangeListener() {
@ -184,7 +211,7 @@ public class NewTournamentDialog extends MageDialog {
} }
}); });
lblDraftCube.setText("Draft Cube"); lblDraftCube.setText("Draft Cube:");
cbDraftCube.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); cbDraftCube.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
cbDraftCube.addActionListener(new java.awt.event.ActionListener() { cbDraftCube.addActionListener(new java.awt.event.ActionListener() {
@ -204,9 +231,10 @@ public class NewTournamentDialog extends MageDialog {
lblPacks.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N lblPacks.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
lblPacks.setText("Packs"); lblPacks.setText("Packs");
pnlPacks.setBorder(javax.swing.BorderFactory.createEtchedBorder());
pnlPacks.setLayout(new java.awt.GridLayout(0, 1, 2, 0)); pnlPacks.setLayout(new java.awt.GridLayout(0, 1, 2, 0));
jLabel2.setText("Players:"); lblNbrPlayers.setText("Players:");
spnNumPlayers.addChangeListener(new javax.swing.event.ChangeListener() { spnNumPlayers.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) { public void stateChanged(javax.swing.event.ChangeEvent evt) {
@ -245,41 +273,25 @@ public class NewTournamentDialog extends MageDialog {
cbAllowSpectators.setText("Allow spectators"); cbAllowSpectators.setText("Allow spectators");
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N lblPlayer1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel3.setText("Player 1 (You)"); lblPlayer1.setText("Player 1 (You)");
jLabel4.setText("Name:"); lblConstructionTime.setText("Construction Time (Minutes):");
txtPlayer1Name.setEditable(false); spnConstructTime.setToolTipText("The time players have to build their deck.");
txtPlayer1Name.setBorder(javax.swing.BorderFactory.createEtchedBorder());
txtPlayer1Name.setDisabledTextColor(java.awt.Color.black);
txtPlayer1Name.setEnabled(false);
pnlOtherPlayers.setBorder(javax.swing.BorderFactory.createEtchedBorder());
pnlOtherPlayers.setLayout(new java.awt.GridLayout(0, 1, 2, 0)); pnlOtherPlayers.setLayout(new java.awt.GridLayout(0, 1, 2, 0));
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); javax.swing.GroupLayout pnlPlayersLayout = new javax.swing.GroupLayout(pnlPlayers);
jPanel1.setLayout(jPanel1Layout); pnlPlayers.setLayout(pnlPlayersLayout);
jPanel1Layout.setHorizontalGroup( pnlPlayersLayout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) pnlPlayersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addComponent(jLabel3)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(jPanel1Layout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtPlayer1Name))
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
); );
jPanel1Layout.setVerticalGroup( pnlPlayersLayout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) pnlPlayersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup() .addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtPlayer1Name, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
.addComponent(jLabel4, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE))
); );
btnOk.setText("OK"); btnOk.setText("OK");
@ -303,23 +315,40 @@ public class NewTournamentDialog extends MageDialog {
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addComponent(pnlPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(28, 28, 28)
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(cbAllowSpectators))
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlPacks, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(pnlPacks, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE) .addGap(0, 0, Short.MAX_VALUE)
.addComponent(btnOk) .addComponent(btnOk)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel)) .addComponent(btnCancel))
.addGroup(layout.createSequentialGroup() .addComponent(player1Panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblNbrPlayers)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 46, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(lblPacks)
.addComponent(lblPlayer1))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGap(28, 28, 28)
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lblNumRounds))
.addGroup(layout.createSequentialGroup()
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(lblConstructionTime)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spnConstructTime, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGroup(layout.createSequentialGroup()
.addComponent(spnNumRounds, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbAllowSpectators))))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(lblName) .addComponent(lblName)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -328,47 +357,52 @@ public class NewTournamentDialog extends MageDialog {
.addComponent(lbTimeLimit) .addComponent(lbTimeLimit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbTimeLimit, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(cbTimeLimit, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblTournamentType)
.addComponent(lblDraftCube))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(cbDraftCube, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbTournamentType, javax.swing.GroupLayout.PREFERRED_SIZE, 295, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(lblConstructionTime, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnConstructTime, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(lblFreeMulligans)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(18, 18, 18)
.addComponent(lblNumWins)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(0, 0, Short.MAX_VALUE) .addGap(0, 0, Short.MAX_VALUE)
.addComponent(lblNumRounds) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblGameType)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(lbDeckType)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(lblDraftCube)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbDraftCube, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(lblTournamentType)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbTournamentType, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGap(7, 7, 7)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblFreeMulligans)
.addComponent(lblPassword))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addGroup(layout.createSequentialGroup()
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, 41, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnNumRounds, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)))) .addComponent(lblNumWins)
.addComponent(lblPacks)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(txtPassword))))
.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() .addGap(4, 4, 4)
.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(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblName) .addComponent(lblName)
.addComponent(lbTimeLimit) .addComponent(lbTimeLimit)
.addComponent(cbTimeLimit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cbTimeLimit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblConstructionTime) .addComponent(lblPassword)
.addComponent(spnConstructTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(txtPassword, 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(lblTournamentType) .addComponent(lblTournamentType)
@ -380,21 +414,39 @@ public class NewTournamentDialog extends MageDialog {
.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(cbDraftCube, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cbDraftCube, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblDraftCube) .addComponent(lblDraftCube))
.addComponent(spnNumRounds, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblNumRounds)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lbDeckType))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblGameType)
.addComponent(cbGameType, 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(lblPacks) .addComponent(lblPacks)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, 95, Short.MAX_VALUE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(pnlPacks, 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, false)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbAllowSpectators, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(spnNumRounds, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblNumRounds))
.addComponent(lblNbrPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(spnNumPlayers)
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblPlayer1, javax.swing.GroupLayout.PREFERRED_SIZE, 25, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spnConstructTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblConstructionTime)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false) .addComponent(player1Panel, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)
.addComponent(cbAllowSpectators, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(spnNumPlayers)
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.PREFERRED_SIZE, 0, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(pnlPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.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(btnOk) .addComponent(btnOk)
@ -415,6 +467,7 @@ public class NewTournamentDialog extends MageDialog {
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem(); TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
TournamentOptions tOptions = new TournamentOptions(this.txtName.getText()); TournamentOptions tOptions = new TournamentOptions(this.txtName.getText());
tOptions.setTournamentType(tournamentType.getName()); tOptions.setTournamentType(tournamentType.getName());
tOptions.setPassword(txtPassword.getText());
tOptions.getPlayerTypes().add("Human"); tOptions.getPlayerTypes().add("Human");
tOptions.setWatchingAllowed(cbAllowSpectators.isSelected()); tOptions.setWatchingAllowed(cbAllowSpectators.isSelected());
for (TournamentPlayerPanel player: players) { for (TournamentPlayerPanel player: players) {
@ -429,10 +482,10 @@ public class NewTournamentDialog extends MageDialog {
options.setTiming((TimingOption) this.cbDraftTiming.getSelectedItem()); options.setTiming((TimingOption) this.cbDraftTiming.getSelectedItem());
tOptions.setLimitedOptions(options); tOptions.setLimitedOptions(options);
} }
if (tOptions.getLimitedOptions() == null) {
tOptions.setLimitedOptions(new LimitedOptions());
}
if (tournamentType.isLimited()) { if (tournamentType.isLimited()) {
if (tOptions.getLimitedOptions() == null) {
tOptions.setLimitedOptions(new LimitedOptions());
}
tOptions.getLimitedOptions().setConstructionTime((Integer)this.spnConstructTime.getValue() * 60); tOptions.getLimitedOptions().setConstructionTime((Integer)this.spnConstructTime.getValue() * 60);
if (tournamentType.isCubeBooster()) { if (tournamentType.isCubeBooster()) {
tOptions.getLimitedOptions().setDraftCubeName(this.cbDraftCube.getSelectedItem().toString()); tOptions.getLimitedOptions().setDraftCubeName(this.cbDraftCube.getSelectedItem().toString());
@ -441,15 +494,24 @@ public class NewTournamentDialog extends MageDialog {
tOptions.getLimitedOptions().getSetCodes().add(((ExpansionInfo) pack.getSelectedItem()).getCode()); tOptions.getLimitedOptions().getSetCodes().add(((ExpansionInfo) pack.getSelectedItem()).getCode());
} }
} }
} tOptions.getMatchOptions().setDeckType("Limited");
tOptions.getMatchOptions().setGameType("Two Player Duel");
tOptions.getMatchOptions().setLimited(true);
} else {
tOptions.getLimitedOptions().setConstructionTime(0);
tOptions.getLimitedOptions().setNumberBoosters(0);
tOptions.getLimitedOptions().setDraftCube(null);
tOptions.getLimitedOptions().setDraftCubeName("");
tOptions.getMatchOptions().setDeckType((String) this.cbDeckType.getSelectedItem());
tOptions.getMatchOptions().setGameType(((GameTypeView) this.cbGameType.getSelectedItem()).getName());
tOptions.getMatchOptions().setLimited(false);
}
tOptions.getMatchOptions().setMatchTimeLimit((MatchTimeLimit) this.cbTimeLimit.getSelectedItem()); tOptions.getMatchOptions().setMatchTimeLimit((MatchTimeLimit) this.cbTimeLimit.getSelectedItem());
tOptions.getMatchOptions().setDeckType("Limited");
tOptions.getMatchOptions().setWinsNeeded((Integer)this.spnNumWins.getValue()); tOptions.getMatchOptions().setWinsNeeded((Integer)this.spnNumWins.getValue());
tOptions.getMatchOptions().setFreeMulligans((Integer)this.spnFreeMulligans.getValue()); tOptions.getMatchOptions().setFreeMulligans((Integer)this.spnFreeMulligans.getValue());
tOptions.getMatchOptions().setAttackOption(MultiplayerAttackOption.LEFT); tOptions.getMatchOptions().setAttackOption(MultiplayerAttackOption.LEFT);
tOptions.getMatchOptions().setRange(RangeOfInfluence.ALL); tOptions.getMatchOptions().setRange(RangeOfInfluence.ALL);
tOptions.getMatchOptions().setLimited(true);
saveTournamentSettingsToPrefs(tOptions); saveTournamentSettingsToPrefs(tOptions);
table = session.createTournamentTable(roomId, tOptions); table = session.createTournamentTable(roomId, tOptions);
@ -457,10 +519,16 @@ public class NewTournamentDialog extends MageDialog {
// message must be send by server! // message must be send by server!
return; return;
} }
if (session.joinTournamentTable(roomId, table.getTableId(), this.txtPlayer1Name.getText(), "Human", 1)) { if (session.joinTournamentTable(
roomId,
table.getTableId(),
this.player1Panel.getPlayerName(),
"Human", 1,
DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()),
tOptions.getPassword())) {
for (TournamentPlayerPanel player: players) { for (TournamentPlayerPanel player: players) {
if (!player.getPlayerType().toString().equals("Human")) { if (!player.getPlayerType().toString().equals("Human")) {
if (!player.joinTournamentTable(roomId, table.getTableId())) { if (!player.joinTournamentTable(roomId, table.getTableId(), DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()))) {
// error message must be send by sever // error message must be send by sever
session.removeTable(roomId, table.getTableId()); session.removeTable(roomId, table.getTableId());
table = null; table = null;
@ -503,6 +571,21 @@ public class NewTournamentDialog extends MageDialog {
// TODO add your handling code here: // TODO add your handling code here:
}//GEN-LAST:event_spnNumRoundsnumPlayersChanged }//GEN-LAST:event_spnNumRoundsnumPlayersChanged
private void cbGameTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbGameTypeActionPerformed
setGameOptions();
}//GEN-LAST:event_cbGameTypeActionPerformed
private void setGameOptions() {
GameTypeView gameType = (GameTypeView) cbGameType.getSelectedItem();
// int oldValue = (Integer) this.spnNumPlayers.getValue();
// this.spnNumPlayers.setModel(new SpinnerNumberModel(gameType.getMinPlayers(), gameType.getMinPlayers(), gameType.getMaxPlayers(), 1));
// this.spnNumPlayers.setEnabled(gameType.getMinPlayers() != gameType.getMaxPlayers());
// if (oldValue >= gameType.getMinPlayers() && oldValue <= gameType.getMaxPlayers()){
// this.spnNumPlayers.setValue(oldValue);
// }
// this.cbAttackOption.setEnabled(gameType.isUseAttackOption());
// this.cbRange.setEnabled(gameType.isUseRange());
createPlayers((Integer) spnNumPlayers.getValue() - 1);
}
private void setTournamentOptions(int numbPlayers) { private void setTournamentOptions(int numbPlayers) {
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem(); TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
activatePanelElements(tournamentType); activatePanelElements(tournamentType);
@ -529,6 +612,16 @@ public class NewTournamentDialog extends MageDialog {
this.pnlDraftOptions.setVisible(tournamentType.isDraft()); this.pnlDraftOptions.setVisible(tournamentType.isDraft());
this.lblNumRounds.setVisible(!tournamentType.isElimination()); this.lblNumRounds.setVisible(!tournamentType.isElimination());
this.spnNumRounds.setVisible(!tournamentType.isElimination()); this.spnNumRounds.setVisible(!tournamentType.isElimination());
this.lblConstructionTime.setVisible(tournamentType.isLimited());
this.spnConstructTime.setVisible(tournamentType.isLimited());
this.lbDeckType.setVisible(!tournamentType.isLimited());
this.cbDeckType.setVisible(!tournamentType.isLimited());
this.lblGameType.setVisible(!tournamentType.isLimited());
this.cbGameType.setVisible(!tournamentType.isLimited());
this.player1Panel.showDeckElements(!tournamentType.isLimited());
if (tournamentType.isLimited()) { if (tournamentType.isLimited()) {
if (tournamentType.isCubeBooster()) { if (tournamentType.isCubeBooster()) {
this.lblDraftCube.setVisible(true); this.lblDraftCube.setVisible(true);
@ -545,7 +638,8 @@ public class NewTournamentDialog extends MageDialog {
// construced // construced
this.lblDraftCube.setVisible(false); this.lblDraftCube.setVisible(false);
this.cbDraftCube.setVisible(false); this.cbDraftCube.setVisible(false);
this.pnlPacks.setVisible(true); this.pnlPacks.setVisible(false);
this.pnlPacks.setVisible(false);
} }
} }
@ -593,6 +687,7 @@ public class NewTournamentDialog extends MageDialog {
while (players.size() != numPlayers) { while (players.size() != numPlayers) {
TournamentPlayerPanel playerPanel = new TournamentPlayerPanel(); TournamentPlayerPanel playerPanel = new TournamentPlayerPanel();
playerPanel.init(players.size() + 2); playerPanel.init(players.size() + 2);
players.add(playerPanel); players.add(playerPanel);
} }
} }
@ -643,6 +738,7 @@ public class NewTournamentDialog extends MageDialog {
private void setTournamentSettingsFromPrefs () { private void setTournamentSettingsFromPrefs () {
int numPlayers; int numPlayers;
txtName.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NAME, "Tournament")); txtName.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NAME, "Tournament"));
txtPassword.setText(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PASSWORD, ""));
int timeLimit = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TIME_LIMIT, "1500")); int timeLimit = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TIME_LIMIT, "1500"));
for (MatchTimeLimit mtl :MatchTimeLimit.values()) { for (MatchTimeLimit mtl :MatchTimeLimit.values()) {
if (mtl.getTimeLimit() == timeLimit) { if (mtl.getTimeLimit() == timeLimit) {
@ -724,26 +820,34 @@ public class NewTournamentDialog extends MageDialog {
*/ */
private void saveTournamentSettingsToPrefs(TournamentOptions tOptions) { private void saveTournamentSettingsToPrefs(TournamentOptions tOptions) {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NAME, tOptions.getName()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NAME, tOptions.getName());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PASSWORD, tOptions.getPassword());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TIME_LIMIT, Integer.toString(tOptions.getMatchOptions().getPriorityTime())); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TIME_LIMIT, Integer.toString(tOptions.getMatchOptions().getPriorityTime()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_CONSTR_TIME, Integer.toString(tOptions.getLimitedOptions().getConstructionTime())); if (this.spnConstructTime.isVisible()) {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_CONSTR_TIME, Integer.toString(tOptions.getLimitedOptions().getConstructionTime()));
}
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TYPE, tOptions.getTournamentType()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_TYPE, tOptions.getTournamentType());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_FREE_MULLIGANS, Integer.toString(tOptions.getMatchOptions().getFreeMulligans())); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_FREE_MULLIGANS, Integer.toString(tOptions.getMatchOptions().getFreeMulligans()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_WINS, Integer.toString(tOptions.getMatchOptions().getWinsNeeded())); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_NUMBER_OF_WINS, Integer.toString(tOptions.getMatchOptions().getWinsNeeded()));
switch (tOptions.getTournamentType()) {
case "Sealed Elimination": if (tOptions.getTournamentType().startsWith("Sealed")) {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_SEALED, tOptions.getLimitedOptions().getSetCodes().toString()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_SEALED, tOptions.getLimitedOptions().getSetCodes().toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_SEALED, Integer.toString(tOptions.getPlayerTypes().size())); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_SEALED, Integer.toString(tOptions.getPlayerTypes().size()));
break;
case "Elimination Booster Draft":
DraftOptions draftOptions = (DraftOptions) tOptions.getLimitedOptions();
if (draftOptions != null) {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_DRAFT, draftOptions.getSetCodes().toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_DRAFT, Integer.toString(tOptions.getPlayerTypes().size()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_DRAFT_TIMING, draftOptions.getTiming().name());
}
break;
} }
if (tOptions.getTournamentType().startsWith("Booster")) {
DraftOptions draftOptions = (DraftOptions) tOptions.getLimitedOptions();
if (draftOptions != null) {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PACKS_DRAFT, draftOptions.getSetCodes().toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_PLAYERS_DRAFT, Integer.toString(tOptions.getPlayerTypes().size()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_DRAFT_TIMING, draftOptions.getTiming().name());
}
}
if (tOptions.getTournamentType().startsWith("Booster")) {
String deckFile = this.player1Panel.getDeckFile();
if (deckFile != null && !deckFile.isEmpty()) {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE, deckFile);
}
}
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_SPECTATORS, (tOptions.isWatchingAllowed()?"Yes":"No")); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_SPECTATORS, (tOptions.isWatchingAllowed()?"Yes":"No"));
} }
@ -757,34 +861,39 @@ public class NewTournamentDialog extends MageDialog {
private javax.swing.JButton btnCancel; private javax.swing.JButton btnCancel;
private javax.swing.JButton btnOk; private javax.swing.JButton btnOk;
private javax.swing.JCheckBox cbAllowSpectators; private javax.swing.JCheckBox cbAllowSpectators;
private javax.swing.JComboBox cbDeckType;
private javax.swing.JComboBox cbDraftCube; private javax.swing.JComboBox cbDraftCube;
private javax.swing.JComboBox cbDraftTiming; private javax.swing.JComboBox cbDraftTiming;
private javax.swing.JComboBox cbGameType;
private javax.swing.JComboBox cbTimeLimit; private javax.swing.JComboBox cbTimeLimit;
private javax.swing.JComboBox cbTournamentType; private javax.swing.JComboBox cbTournamentType;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel1; private javax.swing.JLabel lbDeckType;
private javax.swing.JLabel lbTimeLimit; private javax.swing.JLabel lbTimeLimit;
private javax.swing.JLabel lblConstructionTime; private javax.swing.JLabel lblConstructionTime;
private javax.swing.JLabel lblDraftCube; private javax.swing.JLabel lblDraftCube;
private javax.swing.JLabel lblFreeMulligans; private javax.swing.JLabel lblFreeMulligans;
private javax.swing.JLabel lblGameType;
private javax.swing.JLabel lblName; private javax.swing.JLabel lblName;
private javax.swing.JLabel lblNbrPlayers;
private javax.swing.JLabel lblNumRounds; private javax.swing.JLabel lblNumRounds;
private javax.swing.JLabel lblNumWins; private javax.swing.JLabel lblNumWins;
private javax.swing.JLabel lblPacks; private javax.swing.JLabel lblPacks;
private javax.swing.JLabel lblPassword;
private javax.swing.JLabel lblPlayer1;
private javax.swing.JLabel lblTournamentType; private javax.swing.JLabel lblTournamentType;
private mage.client.table.NewPlayerPanel player1Panel;
private javax.swing.JPanel pnlDraftOptions; private javax.swing.JPanel pnlDraftOptions;
private javax.swing.JPanel pnlOtherPlayers; private javax.swing.JPanel pnlOtherPlayers;
private javax.swing.JPanel pnlPacks; private javax.swing.JPanel pnlPacks;
private javax.swing.JPanel pnlPlayers;
private javax.swing.JSpinner spnConstructTime; private javax.swing.JSpinner spnConstructTime;
private javax.swing.JSpinner spnFreeMulligans; private javax.swing.JSpinner spnFreeMulligans;
private javax.swing.JSpinner spnNumPlayers; private javax.swing.JSpinner spnNumPlayers;
private javax.swing.JSpinner spnNumRounds; private javax.swing.JSpinner spnNumRounds;
private javax.swing.JSpinner spnNumWins; private javax.swing.JSpinner spnNumWins;
private javax.swing.JTextField txtName; private javax.swing.JTextField txtName;
private javax.swing.JTextField txtPlayer1Name; private javax.swing.JTextField txtPassword;
private org.jdesktop.beansbinding.BindingGroup bindingGroup; private org.jdesktop.beansbinding.BindingGroup bindingGroup;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables

View file

@ -158,6 +158,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
// pref setting for new tournament dialog // pref setting for new tournament dialog
public static final String KEY_NEW_TOURNAMENT_NAME = "newTournamentName"; public static final String KEY_NEW_TOURNAMENT_NAME = "newTournamentName";
public static final String KEY_NEW_TOURNAMENT_PASSWORD = "newTournamentPassword";
public static final String KEY_NEW_TOURNAMENT_TIME_LIMIT = "newTournamentTimeLimit"; public static final String KEY_NEW_TOURNAMENT_TIME_LIMIT = "newTournamentTimeLimit";
public static final String KEY_NEW_TOURNAMENT_CONSTR_TIME = "newTournamentConstructionTime"; public static final String KEY_NEW_TOURNAMENT_CONSTR_TIME = "newTournamentConstructionTime";
public static final String KEY_NEW_TOURNAMENT_TYPE = "newTournamentType"; public static final String KEY_NEW_TOURNAMENT_TYPE = "newTournamentType";
@ -169,6 +170,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_NEW_TOURNAMENT_PLAYERS_DRAFT = "newTournamentPlayersDraft"; public static final String KEY_NEW_TOURNAMENT_PLAYERS_DRAFT = "newTournamentPlayersDraft";
public static final String KEY_NEW_TOURNAMENT_DRAFT_TIMING = "newTournamentDraftTiming"; public static final String KEY_NEW_TOURNAMENT_DRAFT_TIMING = "newTournamentDraftTiming";
public static final String KEY_NEW_TOURNAMENT_ALLOW_SPECTATORS = "newTournamentAllowSpectators"; public static final String KEY_NEW_TOURNAMENT_ALLOW_SPECTATORS = "newTournamentAllowSpectators";
public static final String KEY_NEW_TOURNAMENT_DECK_FILE = "newTournamentDeckFile";
// pref setting for deck generator // pref setting for deck generator
public static final String KEY_NEW_DECK_GENERATOR_DECK_SIZE = "newDeckGeneratorDeckSize"; public static final String KEY_NEW_DECK_GENERATOR_DECK_SIZE = "newDeckGeneratorDeckSize";

View file

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

View file

@ -123,6 +123,13 @@ public class NewPlayerPanel extends javax.swing.JPanel {
this.lblLevel.setVisible(show); this.lblLevel.setVisible(show);
} }
public void showDeckElements(boolean show) {
this.lblPlayerDeck.setVisible(show);
this.txtPlayerDeck.setVisible(show);
this.btnGenerate.setVisible(show);
this.btnPlayerDeck.setVisible(show);
}
/** 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

View file

@ -143,6 +143,8 @@ public class TablesPanel extends javax.swing.JPanel {
UUID tableId = (UUID)tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 3); UUID tableId = (UUID)tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 3);
UUID gameId = (UUID)tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 2); UUID gameId = (UUID)tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 2);
String action = (String)tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN); String action = (String)tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN);
String deckType = (String)tableModel.getValueAt(modelRow, TableTableModel.COLUMN_DECK_TYPE);
String info = (String)tableModel.getValueAt(modelRow, TableTableModel.COLUMN_INFO);
boolean isTournament = (Boolean)tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 1); boolean isTournament = (Boolean)tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 1);
String owner = (String)tableModel.getValueAt(modelRow, 1); String owner = (String)tableModel.getValueAt(modelRow, 1);
switch (action) { switch (action) {
@ -170,10 +172,18 @@ public class TablesPanel extends javax.swing.JPanel {
} }
if (isTournament) { if (isTournament) {
logger.info("Joining tournament " + tableId); logger.info("Joining tournament " + tableId);
session.joinTournamentTable(roomId, tableId, session.getUserName(), "Human", 1); if (deckType.startsWith("Limited")) {
if (!info.startsWith("PW")) {
session.joinTournamentTable(roomId, tableId, session.getUserName(), "Human", 1, null, "");
} else {
joinTableDialog.showDialog(roomId, tableId, true, deckType.startsWith("Limited"));
}
} else {
joinTableDialog.showDialog(roomId, tableId, true, deckType.startsWith("Limited"));
}
} else { } else {
logger.info("Joining table " + tableId); logger.info("Joining table " + tableId);
joinTableDialog.showDialog(roomId, tableId); joinTableDialog.showDialog(roomId, tableId, false, false);
} }
break; break;
case "Remove": case "Remove":
@ -696,6 +706,8 @@ private void chkShowCompletedActionPerformed(java.awt.event.ActionEvent evt) {//
class TableTableModel extends AbstractTableModel { class TableTableModel extends AbstractTableModel {
public static final int COLUMN_DECK_TYPE = 5; // column the deck type is located (starting with 0)
public static final int COLUMN_INFO = 6;
public static final int ACTION_COLUMN = 9; // column the action is located (starting with 0) public static final int ACTION_COLUMN = 9; // column the action is located (starting with 0)
private final String[] columnNames = new String[]{"Match Name", "Owner / Players", "Game Type", "Wins", "Free Mulligans", "Deck Type", "Info", "Status", "Created / Started", "Action"}; private final String[] columnNames = new String[]{"Match Name", "Owner / Players", "Game Type", "Wins", "Free Mulligans", "Deck Type", "Info", "Status", "Created / Started", "Action"};

View file

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

View file

@ -37,6 +37,8 @@ package mage.client.table;
import java.util.UUID; import java.util.UUID;
import javax.swing.DefaultComboBoxModel; import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox; import javax.swing.JComboBox;
import mage.cards.decks.DeckCardLists;
import mage.cards.decks.importer.DeckImporterUtil;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.remote.Session; import mage.remote.Session;
@ -64,9 +66,16 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
return this.cbPlayerType; return this.cbPlayerType;
} }
public boolean joinTournamentTable(UUID roomId, UUID tableId) { public boolean joinTournamentTable(UUID roomId, UUID tableId, DeckCardLists deckCardLists) {
if (!this.cbPlayerType.getSelectedItem().equals("Human")) { if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
return session.joinTournamentTable(roomId, tableId, this.txtPlayerName.getText(), (String)this.cbPlayerType.getSelectedItem(), Integer.valueOf((String)this.cbLevel.getSelectedItem())); return session.joinTournamentTable(
roomId,
tableId,
this.txtPlayerName.getText(),
(String)this.cbPlayerType.getSelectedItem(),
Integer.valueOf((String)this.cbLevel.getSelectedItem()),
deckCardLists,
"");
} }
return true; return true;
} }

View file

@ -82,7 +82,7 @@ public interface MageServer {
TableView createTable(String sessionId, UUID roomId, MatchOptions matchOptions) throws MageException; TableView createTable(String sessionId, UUID roomId, MatchOptions matchOptions) throws MageException;
TableView createTournamentTable(String sessionId, UUID roomId, TournamentOptions tournamentOptions) throws MageException; TableView createTournamentTable(String sessionId, UUID roomId, TournamentOptions tournamentOptions) throws MageException;
boolean joinTable(String sessionId, UUID roomId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws MageException, GameException; boolean joinTable(String sessionId, UUID roomId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws MageException, GameException;
boolean joinTournamentTable(String sessionId, UUID roomId, UUID tableId, String name, String playerType, int skill) throws MageException, GameException; boolean joinTournamentTable(String sessionId, UUID roomId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws MageException, GameException;
boolean submitDeck(String sessionId, UUID tableId, DeckCardLists deckList) throws MageException, GameException; boolean submitDeck(String sessionId, UUID tableId, DeckCardLists deckList) throws MageException, GameException;
void updateDeck(String sessionId, UUID tableId, DeckCardLists deckList) throws MageException, GameException; void updateDeck(String sessionId, UUID tableId, DeckCardLists deckList) throws MageException, GameException;
boolean watchTable(String sessionId, UUID roomId, UUID tableId) throws MageException; boolean watchTable(String sessionId, UUID roomId, UUID tableId) throws MageException;

View file

@ -29,6 +29,7 @@
package mage.interfaces; package mage.interfaces;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList;
import java.util.List; import java.util.List;
import mage.utils.MageVersion; import mage.utils.MageVersion;
import mage.view.GameTypeView; import mage.view.GameTypeView;
@ -62,6 +63,16 @@ public class ServerState implements Serializable {
return gameTypes; return gameTypes;
} }
public List<GameTypeView> getTournamentGameTypes() {
List<GameTypeView> tournamentGameTypes = new ArrayList<>();
for(GameTypeView gameTypeView: gameTypes) {
if (gameTypeView.getMinPlayers() == 2 && gameTypeView.getMaxPlayers() == 2) {
tournamentGameTypes.add(gameTypeView);
}
}
return tournamentGameTypes;
}
public List<TournamentTypeView> getTournamentTypes() { public List<TournamentTypeView> getTournamentTypes() {
return tournamentTypes; return tournamentTypes;
} }

View file

@ -453,6 +453,11 @@ public class SessionImpl implements Session {
return serverState.getGameTypes(); return serverState.getGameTypes();
} }
@Override
public List<GameTypeView> getTournamentGameTypes() {
return serverState.getTournamentGameTypes();
}
@Override @Override
public String[] getDeckTypes() { public String[] getDeckTypes() {
return serverState.getDeckTypes(); return serverState.getDeckTypes();
@ -588,10 +593,10 @@ public class SessionImpl implements Session {
} }
@Override @Override
public boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill) { public boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList, String password) {
try { try {
if (isConnected()) { if (isConnected()) {
return server.joinTournamentTable(sessionId, roomId, tableId, playerName, playerType, skill); return server.joinTournamentTable(sessionId, roomId, tableId, playerName, playerType, skill, deckList, password);
} }
} catch (GameException ex) { } catch (GameException ex) {
handleGameException(ex); handleGameException(ex);

View file

@ -27,11 +27,10 @@
*/ */
package mage.remote.interfaces; package mage.remote.interfaces;
import java.util.List;
import mage.view.GameTypeView; import mage.view.GameTypeView;
import mage.view.TournamentTypeView; import mage.view.TournamentTypeView;
import java.util.List;
/** /**
* @author noxx * @author noxx
*/ */
@ -40,6 +39,7 @@ public interface GameTypes {
String[] getPlayerTypes(); String[] getPlayerTypes();
List<GameTypeView> getGameTypes(); List<GameTypeView> getGameTypes();
List<GameTypeView> getTournamentGameTypes();
String[] getDeckTypes(); String[] getDeckTypes();

View file

@ -63,7 +63,7 @@ public interface PlayerActions {
// boolean startChallenge(UUID roomId, UUID tableId, UUID challengeId); // boolean startChallenge(UUID roomId, UUID tableId, UUID challengeId);
boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill); boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList, String password);
boolean watchTable(UUID roomId, UUID tableId); boolean watchTable(UUID roomId, UUID tableId);

View file

@ -109,7 +109,7 @@ public class TableView implements Serializable {
StringBuilder addInfo = new StringBuilder(); StringBuilder addInfo = new StringBuilder();
if (table.getMatch().getGames().isEmpty()) { if (table.getMatch().getGames().isEmpty()) {
if (!table.getMatch().getOptions().getPassword().isEmpty()) { if (!table.getMatch().getOptions().getPassword().isEmpty()) {
addInfo.append("PW -"); addInfo.append("PW-");
} }
addInfo.append("Timer: ").append(table.getMatch().getOptions().getMatchTimeLimit().toString()); addInfo.append("Timer: ").append(table.getMatch().getOptions().getMatchTimeLimit().toString());
} else { } else {
@ -129,12 +129,18 @@ public class TableView implements Serializable {
} }
} }
this.controllerName += sb1.toString(); this.controllerName += sb1.toString();
StringBuilder sb = new StringBuilder("Seats: ").append(table.getTournament().getPlayers().size()).append("/").append(table.getNumberOfSeats()); StringBuilder sb = new StringBuilder();
if (!table.getTournament().getOptions().getPassword().isEmpty()) {
sb.append("PW-");
}
sb.append("Seats: ").append(table.getTournament().getPlayers().size()).append("/").append(table.getNumberOfSeats());
switch (table.getState()) { switch (table.getState()) {
case WAITING: case WAITING:
case READY_TO_START: case READY_TO_START:
case STARTING: case STARTING:
sb.append(" Constr. Time: ").append(table.getTournament().getOptions().getLimitedOptions().getConstructionTime()/60).append(" Min."); if (table.getTournament().getTournamentType().isLimited()) {
sb.append(" Constr. Time: ").append(table.getTournament().getOptions().getLimitedOptions().getConstructionTime()/60).append(" Min.");
}
break; break;
case DUELING: case DUELING:
sb.append(" - Running round: ").append(table.getTournament().getRounds().size()); sb.append(" - Running round: ").append(table.getTournament().getRounds().size());

View file

@ -61,12 +61,14 @@ public class TournamentView implements Serializable {
public TournamentView(Tournament tournament) { public TournamentView(Tournament tournament) {
tournamentName = tournament.getOptions().getName(); tournamentName = tournament.getOptions().getName();
StringBuilder typeText = new StringBuilder(tournament.getOptions().getTournamentType());
if (tournament.getNumberRounds() > 0) { if (!tournament.getTournamentType().isLimited()) {
tournamentType = tournament.getOptions().getTournamentType() + " " + tournament.getNumberRounds()+ " rounds"; typeText.append(" / ").append(tournament.getOptions().getMatchOptions().getDeckType());
} else {
tournamentType = tournament.getOptions().getTournamentType();
} }
if (tournament.getNumberRounds() > 0) {
typeText.append(" ").append(tournament.getNumberRounds()).append(" rounds");
}
tournamentType = typeText.toString();
startTime = tournament.getStartTime(); startTime = tournament.getStartTime();
endTime = tournament.getEndTime(); endTime = tournament.getEndTime();
stepStartTime = tournament.getStepStartTime(); stepStartTime = tournament.getStepStartTime();

View file

@ -37,11 +37,12 @@ import mage.game.tournament.TournamentType;
public class ConstructedEliminationTournamentType extends TournamentType { public class ConstructedEliminationTournamentType extends TournamentType {
public ConstructedEliminationTournamentType() { public ConstructedEliminationTournamentType() {
this.name = "Elimination Constructed"; this.name = "Constructed Elimination";
this.maxPlayers = 16; this.maxPlayers = 16;
this.minPlayers = 4; this.minPlayers = 4;
this.numBoosters = 0; this.numBoosters = 0;
this.draft = false; this.draft = false;
this.limited = false; this.limited = false;
this.elimination = true;
} }
} }

View file

@ -0,0 +1,66 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 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
* provided with the distribution.
*
* 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
* 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
* 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
* 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
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* 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
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.tournament;
import mage.game.tournament.TournamentOptions;
import mage.game.tournament.TournamentSwiss;
/**
*
* @author LevelX2
*/
public class ConstructedSwissTournament extends TournamentSwiss {
protected enum TournamentStep {
START, COMPETE, WINNERS
}
protected TournamentStep currentStep;
public ConstructedSwissTournament(TournamentOptions options) {
super(options);
currentStep = TournamentStep.START;
}
@Override
public void nextStep() {
switch (currentStep) {
case START:
currentStep = TournamentStep.COMPETE;
runTournament();
break;
case COMPETE:
currentStep = TournamentStep.WINNERS;
winners();
end();
break;
}
}
}

View file

@ -0,0 +1,48 @@
/*
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 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
* provided with the distribution.
*
* 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
* 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
* 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
* 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
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* 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
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.tournament;
import mage.game.tournament.TournamentType;
/**
*
* @author LevelX2
*/
public class ConstructedSwissTournamentType extends TournamentType {
public ConstructedSwissTournamentType() {
this.name = "Constructed Swiss";
this.maxPlayers = 16;
this.minPlayers = 4;
this.numBoosters = 0;
this.draft = false;
this.limited = false;
this.elimination = false;
}
}

View file

@ -50,6 +50,8 @@
<gameType name="Commander Free For All" jar="mage-game-commanderfreeforall.jar" className="mage.game.CommanderFreeForAllMatch" typeName="mage.game.CommanderFreeForAllType"/> <gameType name="Commander Free For All" jar="mage-game-commanderfreeforall.jar" className="mage.game.CommanderFreeForAllMatch" typeName="mage.game.CommanderFreeForAllType"/>
</gameTypes> </gameTypes>
<tournamentTypes> <tournamentTypes>
<tournamentType name="Constructed Elimination" jar="mage-tournament-constructed.jar" className="mage.tournament.ConstructedEliminationTournament" typeName="mage.tournament.ConstructedEliminationTournamentType"/>
<tournamentType name="Constructed Swiss" jar="mage-tournament-constructed.jar" className="mage.tournament.ConstructedSwissTournament" typeName="mage.tournament.ConstructedSwissTournamentType"/>
<tournamentType name="Booster Draft Elimination" jar="mage-tournament-booster-draft.jar" className="mage.tournament.BoosterDraftEliminationTournament" typeName="mage.tournament.BoosterDraftEliminationTournamentType"/> <tournamentType name="Booster Draft Elimination" jar="mage-tournament-booster-draft.jar" className="mage.tournament.BoosterDraftEliminationTournament" typeName="mage.tournament.BoosterDraftEliminationTournamentType"/>
<tournamentType name="Booster Draft Elimination (Cube)" jar="mage-tournament-booster-draft.jar" className="mage.tournament.BoosterDraftEliminationTournament" typeName="mage.tournament.BoosterDraftEliminationCubeTournamentType"/> <tournamentType name="Booster Draft Elimination (Cube)" jar="mage-tournament-booster-draft.jar" className="mage.tournament.BoosterDraftEliminationTournament" typeName="mage.tournament.BoosterDraftEliminationCubeTournamentType"/>
<tournamentType name="Booster Draft Swiss" jar="mage-tournament-booster-draft.jar" className="mage.tournament.BoosterDraftSwissTournament" typeName="mage.tournament.BoosterDraftSwissTournamentType"/> <tournamentType name="Booster Draft Swiss" jar="mage-tournament-booster-draft.jar" className="mage.tournament.BoosterDraftSwissTournament" typeName="mage.tournament.BoosterDraftSwissTournamentType"/>

View file

@ -29,6 +29,8 @@
<gameType name="Commander Free For All" jar="mage-game-commanderfreeforall-${project.version}.jar" className="mage.game.CommanderFreeForAllMatch" typeName="mage.game.CommanderFreeForAllType"/> <gameType name="Commander Free For All" jar="mage-game-commanderfreeforall-${project.version}.jar" className="mage.game.CommanderFreeForAllMatch" typeName="mage.game.CommanderFreeForAllType"/>
</gameTypes> </gameTypes>
<tournamentTypes> <tournamentTypes>
<tournamentType name="Constructed Elimination" jar="mage-tournament-constructed-${project.version}.jar" className="mage.tournament.ConstructedEliminationTournament" typeName="mage.tournament.ConstructedEliminationTournamentType"/>
<tournamentType name="Constructed Swiss" jar="mage-tournament-constructed-${project.version}.jar" className="mage.tournament.ConstructedSwissTournament" typeName="mage.tournament.ConstructedSwissTournamentType"/>
<tournamentType name="Booster Draft Elimination" jar="mage-tournament-boosterdraft-${project.version}.jar" className="mage.tournament.BoosterDraftEliminationTournament" typeName="mage.tournament.BoosterDraftEliminationTournamentType"/> <tournamentType name="Booster Draft Elimination" jar="mage-tournament-boosterdraft-${project.version}.jar" className="mage.tournament.BoosterDraftEliminationTournament" typeName="mage.tournament.BoosterDraftEliminationTournamentType"/>
<tournamentType name="Booster Draft Elimination (Cube)" jar="mage-tournament-boosterdraft-${project.version}.jar" className="mage.tournament.BoosterDraftEliminationTournament" typeName="mage.tournament.BoosterDraftEliminationCubeTournamentType"/> <tournamentType name="Booster Draft Elimination (Cube)" jar="mage-tournament-boosterdraft-${project.version}.jar" className="mage.tournament.BoosterDraftEliminationTournament" typeName="mage.tournament.BoosterDraftEliminationCubeTournamentType"/>
<tournamentType name="Booster Draft Swiss" jar="mage-tournament-boosterdraft-${project.version}.jar" className="mage.tournament.BoosterDraftSwissTournament" typeName="mage.tournament.BoosterDraftSwissTournamentType"/> <tournamentType name="Booster Draft Swiss" jar="mage-tournament-boosterdraft-${project.version}.jar" className="mage.tournament.BoosterDraftSwissTournament" typeName="mage.tournament.BoosterDraftSwissTournamentType"/>

View file

@ -236,7 +236,7 @@ public class MageServerImpl implements MageServer {
} }
@Override @Override
public boolean joinTournamentTable(final String sessionId, final UUID roomId, final UUID tableId, final String name, final String playerType, final int skill) throws MageException, GameException { public boolean joinTournamentTable(final String sessionId, final UUID roomId, final UUID tableId, final String name, final String playerType, final int skill, final DeckCardLists deckList, final String password) throws MageException, GameException {
return executeWithResult("joinTournamentTable", sessionId, new ActionWithBooleanResult() { return executeWithResult("joinTournamentTable", sessionId, new ActionWithBooleanResult() {
@Override @Override
public Boolean execute() throws MageException { public Boolean execute() throws MageException {
@ -251,7 +251,7 @@ public class MageServerImpl implements MageServer {
logger.fatal("Got no userId from sessionId" + sessionId + " tableId" + tableId); logger.fatal("Got no userId from sessionId" + sessionId + " tableId" + tableId);
return false; return false;
} }
boolean ret = GamesRoomManager.getInstance().getRoom(roomId).joinTournamentTable(userId, tableId, name, playerType, skill); boolean ret = GamesRoomManager.getInstance().getRoom(roomId).joinTournamentTable(userId, tableId, name, playerType, skill, deckList, password);
return ret; return ret;
} }
}); });

View file

@ -149,10 +149,11 @@ public class TableController {
); );
} }
public synchronized boolean joinTournament(UUID userId, String name, String playerType, int skill) throws GameException { public synchronized boolean joinTournament(UUID userId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws GameException {
if (table.getState() != TableState.WAITING) { if (table.getState() != TableState.WAITING) {
return false; return false;
} }
Seat seat = table.getNextAvailableSeat(playerType); Seat seat = table.getNextAvailableSeat(playerType);
if (seat == null) { if (seat == null) {
throw new GameException("No available seats."); throw new GameException("No available seats.");
@ -162,10 +163,36 @@ public class TableController {
logger.fatal(new StringBuilder("couldn't get user ").append(name).append(" for join tournament userId = ").append(userId).toString()); logger.fatal(new StringBuilder("couldn't get user ").append(name).append(" for join tournament userId = ").append(userId).toString());
return false; return false;
} }
// check password
if (!table.getTournament().getOptions().getPassword().isEmpty() && playerType.equals("Human")) {
if (!table.getTournament().getOptions().getPassword().equals(password)) {
user.showUserMessage("Join Table", "Wrong password.");
return false;
}
}
if (userPlayerMap.containsKey(userId) && playerType.equals("Human")){ if (userPlayerMap.containsKey(userId) && playerType.equals("Human")){
user.showUserMessage("Join Table", new StringBuilder("You can join a table only one time.").toString()); user.showUserMessage("Join Table", new StringBuilder("You can join a table only one time.").toString());
return false; return false;
} }
Deck deck = null;
if (deckList != null) {
deck = Deck.load(deckList, false, false);
if (!Main.isTestMode() && !table.getValidator().validate(deck)) {
StringBuilder sb = new StringBuilder("You (").append(name).append(") have an invalid deck for the selected ").append(table.getValidator().getName()).append(" Format. \n\n");
for (Map.Entry<String, String> entry : table.getValidator().getInvalid().entrySet()) {
sb.append(entry.getKey()).append(": ").append(entry.getValue()).append("\n");
}
sb.append("\n\nSelect a deck that is appropriate for the selected format and try again!");
user.showUserMessage("Join Table", sb.toString());
if (isOwner(userId)) {
logger.debug("New table removed because owner submitted invalid deck tableId " + table.getId());
TableManager.getInstance().removeTable(table.getId());
}
return false;
}
}
Player player = createPlayer(name, seat.getPlayerType(), skill); Player player = createPlayer(name, seat.getPlayerType(), skill);
if (player != null) { if (player != null) {
if (!player.canJoinTable(table)) { if (!player.canJoinTable(table)) {
@ -173,6 +200,10 @@ public class TableController {
return false; return false;
} }
tournament.addPlayer(player, seat.getPlayerType()); tournament.addPlayer(player, seat.getPlayerType());
TournamentPlayer tournamentPlayer = tournament.getPlayer(player.getId());
if (deck != null && tournamentPlayer != null) {
tournamentPlayer.submitDeck(deck);
}
table.joinTable(player, seat); table.joinTable(player, seat);
logger.trace("player " + player.getName() + " joined tableId: " + table.getId()); logger.trace("player " + player.getName() + " joined tableId: " + table.getId());
//only inform human players and add them to sessionPlayerMap //only inform human players and add them to sessionPlayerMap

View file

@ -148,9 +148,9 @@ public class TableManager {
return false; return false;
} }
public boolean joinTournament(UUID userId, UUID tableId, String name, String playerType, int skill) throws GameException { public boolean joinTournament(UUID userId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws GameException {
if (controllers.containsKey(tableId)) { if (controllers.containsKey(tableId)) {
return controllers.get(tableId).joinTournament(userId, name, playerType, skill); return controllers.get(tableId).joinTournament(userId, name, playerType, skill, deckList, password);
} }
return false; return false;
} }

View file

@ -32,7 +32,7 @@ import java.lang.reflect.Constructor;
import java.util.LinkedHashMap; import java.util.LinkedHashMap;
import java.util.Map; import java.util.Map;
import java.util.Set; import java.util.Set;
import mage.cards.decks.*; import mage.cards.decks.DeckValidator;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
@ -44,7 +44,7 @@ public class DeckValidatorFactory {
private static final DeckValidatorFactory INSTANCE = new DeckValidatorFactory(); private static final DeckValidatorFactory INSTANCE = new DeckValidatorFactory();
private static final Logger logger = Logger.getLogger(DeckValidatorFactory.class); private static final Logger logger = Logger.getLogger(DeckValidatorFactory.class);
private Map<String, Class> deckTypes = new LinkedHashMap<String, Class>(); private final Map<String, Class> deckTypes = new LinkedHashMap<>();
public static DeckValidatorFactory getInstance() { public static DeckValidatorFactory getInstance() {
return INSTANCE; return INSTANCE;

View file

@ -39,7 +39,6 @@ import mage.server.Room;
import mage.view.MatchView; import mage.view.MatchView;
import mage.view.RoomUsersView; import mage.view.RoomUsersView;
import mage.view.TableView; import mage.view.TableView;
import mage.view.UsersView;
/** /**
* *
@ -51,7 +50,7 @@ public interface GamesRoom extends Room {
List<MatchView> getFinished(); List<MatchView> getFinished();
List<RoomUsersView> getRoomUsersInfo(); List<RoomUsersView> getRoomUsersInfo();
boolean joinTable(UUID userId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws MageException; boolean joinTable(UUID userId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws MageException;
boolean joinTournamentTable(UUID userId, UUID tableId, String name, String playerType, int skill) throws GameException; boolean joinTournamentTable(UUID userId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws GameException;
TableView createTable(UUID userId, MatchOptions options); TableView createTable(UUID userId, MatchOptions options);
TableView createTournamentTable(UUID userId, TournamentOptions options); TableView createTournamentTable(UUID userId, TournamentOptions options);
void removeTable(UUID userId, UUID tableId); void removeTable(UUID userId, UUID tableId);

View file

@ -155,9 +155,9 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
} }
@Override @Override
public boolean joinTournamentTable(UUID userId, UUID tableId, String name, String playerType, int skill) throws GameException { public boolean joinTournamentTable(UUID userId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList, String password) throws GameException {
if (tables.containsKey(tableId)) { if (tables.containsKey(tableId)) {
return TableManager.getInstance().joinTournament(userId, tableId, name, playerType, skill); return TableManager.getInstance().joinTournament(userId, tableId, name, playerType, skill, deckList, password);
} else { } else {
return false; return false;
} }

View file

@ -69,13 +69,13 @@ public class TournamentFactory {
tournament = con.newInstance(new Object[] {options}); tournament = con.newInstance(new Object[] {options});
// transfer set information, create short info string for included sets // transfer set information, create short info string for included sets
tournament.setTournamentType(tournamentTypes.get(tournamentType)); tournament.setTournamentType(tournamentTypes.get(tournamentType));
Map<String,Integer> setInfo = new LinkedHashMap<>();
for (String setCode: options.getLimitedOptions().getSetCodes()) {
tournament.getSets().add(Sets.findSet(setCode));
int count = setInfo.containsKey(setCode) ? setInfo.get(setCode) : 0;
setInfo.put(setCode, count + 1);
}
if (tournament.getTournamentType().isLimited()) { if (tournament.getTournamentType().isLimited()) {
Map<String,Integer> setInfo = new LinkedHashMap<>();
for (String setCode: options.getLimitedOptions().getSetCodes()) {
tournament.getSets().add(Sets.findSet(setCode));
int count = setInfo.containsKey(setCode) ? setInfo.get(setCode) : 0;
setInfo.put(setCode, count + 1);
}
tournament.getOptions().getLimitedOptions().setNumberBoosters(tournament.getTournamentType().getNumBoosters()); tournament.getOptions().getLimitedOptions().setNumberBoosters(tournament.getTournamentType().getNumBoosters());
if (tournament.getTournamentType().isCubeBooster()) { if (tournament.getTournamentType().isCubeBooster()) {
tournament.getOptions().getLimitedOptions().setDraftCube(CubeFactory.getInstance().createDraftCube(tournament.getOptions().getLimitedOptions().getDraftCubeName())); tournament.getOptions().getLimitedOptions().setDraftCube(CubeFactory.getInstance().createDraftCube(tournament.getOptions().getLimitedOptions().getDraftCubeName()));
@ -87,14 +87,15 @@ public class TournamentFactory {
} }
tournament.setBoosterInfo(sb.toString()); tournament.setBoosterInfo(sb.toString());
} }
} else {
tournament.setBoosterInfo("");
} }
} catch (Exception ex) { } catch (Exception ex) {
logger.fatal("TournamentFactory error ", ex); logger.fatal("TournamentFactory error ", ex);
return null; return null;
} }
logger.debug("Tournament created: " + tournamentType); // + game.getId().toString()); logger.debug("Tournament created: " + tournamentType + " " + tournament.getId());
return tournament; return tournament;
} }

View file

@ -160,7 +160,7 @@ public class Table implements Serializable {
if (validator != null) { if (validator != null) {
return validator.getName(); return validator.getName();
} }
return "<deckt type missing>"; return "<deck type missing>";
} }
public Date getCreateTime() { public Date getCreateTime() {

View file

@ -40,12 +40,13 @@ import mage.game.match.MatchOptions;
public class TournamentOptions implements Serializable { public class TournamentOptions implements Serializable {
protected String name; protected String name;
protected String tournamentType;; protected String tournamentType;
protected List<String> playerTypes = new ArrayList<>(); protected List<String> playerTypes = new ArrayList<>();
protected MatchOptions matchOptions = new MatchOptions("", "Two Player Duel"); protected MatchOptions matchOptions = new MatchOptions("", "Two Player Duel");
protected LimitedOptions limitedOptions; protected LimitedOptions limitedOptions;
protected boolean watchingAllowed = true; protected boolean watchingAllowed = true;
protected int numberRounds; protected int numberRounds;
protected String password;
public TournamentOptions(String name) { public TournamentOptions(String name) {
this.name = name; this.name = name;
@ -95,4 +96,12 @@ public class TournamentOptions implements Serializable {
this.numberRounds = numberRounds; this.numberRounds = numberRounds;
} }
public String getPassword() {
return password;
}
public void setPassword(String password) {
this.password = password;
}
} }