* 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 roomId;
private boolean joined = false;
private boolean isTournament;
/** Creates new form JoinTableDialog */
public JoinTableDialog() {
@ -53,10 +54,12 @@ public class JoinTableDialog extends MageDialog {
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.tableId = tableId;
this.isTournament = isTournament;
this.newPlayerPanel.setPlayerName(MageFrame.getSession().getUserName());
this.newPlayerPanel.showDeckElements(isLimited);
this.setModal(true);
this.setLocation(100, 100);
this.setVisible(true);
@ -146,7 +149,12 @@ public class JoinTableDialog extends MageDialog {
Session session = MageFrame.getSession();
try {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_PASSWORD, 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) {
handleError(ex);
}

View file

@ -106,7 +106,7 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="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">
<Component id="txtName" 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"/>
<Component id="jLabel2" min="-2" 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"/>
<Component id="jSeparator1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
@ -179,7 +179,7 @@
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="201" 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>

View file

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

View file

@ -25,16 +25,7 @@
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" 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="pnlPlayers" alignment="0" max="32767" attributes="0"/>
<Component id="pnlPacks" alignment="1" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
@ -42,8 +33,41 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="btnCancel" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="player1Panel" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" max="-2" 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">
<Component id="lblName" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
@ -53,43 +77,50 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="cbTimeLimit" max="32767" attributes="1"/>
</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">
<Component id="lblTournamentType" min="-2" max="-2" attributes="0"/>
<Component id="lblDraftCube" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<Component id="lblGameType" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="cbDraftCube" min="-2" pref="295" max="-2" attributes="0"/>
<Component id="cbTournamentType" min="-2" pref="295" max="-2" attributes="0"/>
</Group>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" 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"/>
<Component id="cbGameType" min="-2" pref="290" max="-2" attributes="1"/>
</Group>
<Group type="102" attributes="0">
<Component id="lblFreeMulligans" min="-2" max="-2" attributes="0"/>
<Component id="lbDeckType" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnFreeMulligans" min="-2" pref="41" max="-2" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="lblNumWins" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<Component id="spnNumWins" min="-2" pref="50" 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">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="lblNumRounds" min="-2" max="-2" attributes="0"/>
<Component id="lblTournamentType" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnNumRounds" min="-2" pref="50" max="-2" attributes="0"/>
<Component id="cbTournamentType" min="-2" pref="290" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="7" pref="7" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" 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">
<Component id="spnFreeMulligans" min="-2" pref="41" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblNumWins" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnNumWins" min="-2" pref="50" max="-2" attributes="0"/>
</Group>
<Component id="txtPassword" max="32767" attributes="0"/>
</Group>
</Group>
<Component id="lblPacks" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
@ -98,14 +129,14 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" 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">
<Component id="txtName" 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="cbTimeLimit" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblConstructionTime" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnConstructTime" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblPassword" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtPassword" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
@ -120,23 +151,47 @@
<Group type="103" groupAlignment="3" 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="spnNumRounds" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblNumRounds" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<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>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblPacks" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="pnlPacks" pref="95" max="32767" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" attributes="0">
<Component id="pnlPacks" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="cbAllowSpectators" alignment="1" max="32767" attributes="0"/>
<Component id="jLabel2" alignment="1" max="32767" attributes="0"/>
<Group type="103" alignment="1" groupAlignment="3" attributes="0">
<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 min="-2" max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<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>
<EmptySpace max="-2" attributes="0"/>
<Component id="player1Panel" pref="59" max="32767" 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">
<Component id="btnOk" 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 class="javax.swing.JComboBox" name="cbTimeLimit">
</Component>
<Component class="javax.swing.JLabel" name="lblConstructionTime">
<Component class="javax.swing.JLabel" name="lblPassword">
<Properties>
<Property name="text" type="java.lang.String" value="Construction Time (Minutes):"/>
<Property name="text" type="java.lang.String" value="Password:"/>
</Properties>
</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 class="javax.swing.JLabel" name="lblTournamentType">
<Properties>
@ -191,12 +249,34 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbTournamentTypeActionPerformed"/>
</Events>
</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">
<Properties>
<Property name="text" type="java.lang.String" value="Free Mulligans:"/>
</Properties>
</Component>
<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 class="javax.swing.JLabel" name="lblNumWins">
<Properties>
@ -210,7 +290,7 @@
</Component>
<Component class="javax.swing.JLabel" name="lblDraftCube">
<Properties>
<Property name="text" type="java.lang.String" value="Draft Cube"/>
<Property name="text" type="java.lang.String" value="Draft Cube:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="cbDraftCube">
@ -247,6 +327,13 @@
</Properties>
</Component>
<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">
<Property name="columns" type="int" value="1"/>
@ -254,7 +341,7 @@
<Property name="rows" type="int" value="0"/>
</Layout>
</Container>
<Component class="javax.swing.JLabel" name="jLabel2">
<Component class="javax.swing.JLabel" name="lblNbrPlayers">
<Properties>
<Property name="text" type="java.lang.String" value="Players:"/>
</Properties>
@ -318,40 +405,7 @@
<Property name="text" type="java.lang.String" value="Allow spectators"/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="jPanel1">
<Layout>
<DimensionLayout dim="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"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" 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>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="javax.swing.JLabel" name="jLabel3">
<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"/>
@ -359,26 +413,41 @@
<Property name="text" type="java.lang.String" value="Player 1 (You)"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel4">
<Component class="javax.swing.JLabel" name="lblConstructionTime">
<Properties>
<Property name="text" type="java.lang.String" value="Name:"/>
<Property name="text" type="java.lang.String" value="Construction Time (Minutes):"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtPlayer1Name">
<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>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="pnlOtherPlayers" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="pnlOtherPlayers" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="pnlOtherPlayers">
<Properties>
<Property name="editable" type="boolean" value="false"/>
<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>
<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>
</Component>
<Container class="javax.swing.JPanel" name="pnlOtherPlayers">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
<Property name="columns" type="int" value="1"/>

View file

@ -42,10 +42,10 @@ import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.SpinnerNumberModel;
import mage.cards.decks.importer.DeckImporterUtil;
import mage.cards.repository.ExpansionInfo;
import mage.cards.repository.ExpansionRepository;
import mage.client.MageFrame;
import mage.client.table.TablePlayerPanel;
import mage.client.table.TournamentPlayerPanel;
import mage.constants.MatchTimeLimit;
import mage.constants.MultiplayerAttackOption;
@ -55,6 +55,7 @@ import mage.game.draft.DraftOptions.TimingOption;
import mage.game.tournament.LimitedOptions;
import mage.game.tournament.TournamentOptions;
import mage.remote.Session;
import mage.view.GameTypeView;
import mage.view.TableView;
import mage.view.TournamentTypeView;
import org.apache.log4j.Logger;
@ -94,8 +95,13 @@ public class NewTournamentDialog extends MageDialog {
this.roomId = roomId;
if (!lastSessionId.equals(MageFrame.getSession().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()));
cbGameType.setModel(new DefaultComboBoxModel(session.getTournamentGameTypes().toArray()));
cbDeckType.setModel(new DefaultComboBoxModel(session.getDeckTypes()));
cbTimeLimit.setModel(new DefaultComboBoxModel(MatchTimeLimit.values()));
cbDraftCube.setModel(new DefaultComboBoxModel(session.getDraftCubes()));
cbDraftTiming.setModel(new DefaultComboBoxModel(DraftOptions.TimingOption.values()));
@ -126,10 +132,14 @@ public class NewTournamentDialog extends MageDialog {
txtName = new javax.swing.JTextField();
lbTimeLimit = new javax.swing.JLabel();
cbTimeLimit = new javax.swing.JComboBox();
lblConstructionTime = new javax.swing.JLabel();
spnConstructTime = new javax.swing.JSpinner();
lblPassword = new javax.swing.JLabel();
txtPassword = new javax.swing.JTextField();
lblTournamentType = new javax.swing.JLabel();
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();
spnFreeMulligans = new javax.swing.JSpinner();
lblNumWins = new javax.swing.JLabel();
@ -140,16 +150,17 @@ public class NewTournamentDialog extends MageDialog {
spnNumRounds = new javax.swing.JSpinner();
lblPacks = new javax.swing.JLabel();
pnlPacks = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel();
lblNbrPlayers = new javax.swing.JLabel();
spnNumPlayers = new javax.swing.JSpinner();
pnlDraftOptions = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();
cbDraftTiming = new javax.swing.JComboBox();
cbAllowSpectators = new javax.swing.JCheckBox();
jPanel1 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
txtPlayer1Name = new javax.swing.JTextField();
lblPlayer1 = new javax.swing.JLabel();
lblConstructionTime = new javax.swing.JLabel();
spnConstructTime = new javax.swing.JSpinner();
player1Panel = new mage.client.table.NewPlayerPanel();
pnlPlayers = new javax.swing.JPanel();
pnlOtherPlayers = new javax.swing.JPanel();
btnOk = 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"));
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:");
@ -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:");
spnFreeMulligans.setToolTipText("Players can take this number of free mulligans (their hand size will not be reduced).");
lblNumWins.setText("Wins:");
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.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.setText("Packs");
pnlPacks.setBorder(javax.swing.BorderFactory.createEtchedBorder());
pnlPacks.setLayout(new java.awt.GridLayout(0, 1, 2, 0));
jLabel2.setText("Players:");
lblNbrPlayers.setText("Players:");
spnNumPlayers.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
@ -245,41 +273,25 @@ public class NewTournamentDialog extends MageDialog {
cbAllowSpectators.setText("Allow spectators");
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel3.setText("Player 1 (You)");
lblPlayer1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
lblPlayer1.setText("Player 1 (You)");
jLabel4.setText("Name:");
lblConstructionTime.setText("Construction Time (Minutes):");
txtPlayer1Name.setEditable(false);
txtPlayer1Name.setBorder(javax.swing.BorderFactory.createEtchedBorder());
txtPlayer1Name.setDisabledTextColor(java.awt.Color.black);
txtPlayer1Name.setEnabled(false);
spnConstructTime.setToolTipText("The time players have to build their deck.");
pnlOtherPlayers.setBorder(javax.swing.BorderFactory.createEtchedBorder());
pnlOtherPlayers.setLayout(new java.awt.GridLayout(0, 1, 2, 0));
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.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))
javax.swing.GroupLayout pnlPlayersLayout = new javax.swing.GroupLayout(pnlPlayers);
pnlPlayers.setLayout(pnlPlayersLayout);
pnlPlayersLayout.setHorizontalGroup(
pnlPlayersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanel1Layout.createSequentialGroup()
.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))
pnlPlayersLayout.setVerticalGroup(
pnlPlayersLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
btnOk.setText("OK");
@ -303,23 +315,40 @@ public class NewTournamentDialog extends MageDialog {
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.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(pnlPlayers, 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()
.addGap(0, 0, Short.MAX_VALUE)
.addComponent(btnOk)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel))
.addComponent(player1Panel, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.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()
.addComponent(lblName)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -328,47 +357,52 @@ public class NewTournamentDialog extends MageDialog {
.addComponent(lbTimeLimit)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.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()
.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)
.addComponent(lblNumRounds)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addComponent(lblGameType)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnNumRounds, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))))
.addComponent(lblPacks))
.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)
.addComponent(lblNumWins)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(txtPassword))))
.addContainerGap())
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGap(4, 4, 4)
.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(lblName)
.addComponent(lbTimeLimit)
.addComponent(cbTimeLimit, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblConstructionTime)
.addComponent(spnConstructTime, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(lblPassword)
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblTournamentType)
@ -380,21 +414,39 @@ public class NewTournamentDialog extends MageDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.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(lblDraftCube)
.addComponent(spnNumRounds, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblNumRounds))
.addComponent(lblDraftCube))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.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)
.addComponent(lblPacks)
.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(jLabel2, 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(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.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)
.addComponent(player1Panel, javax.swing.GroupLayout.DEFAULT_SIZE, 59, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnOk)
@ -415,6 +467,7 @@ public class NewTournamentDialog extends MageDialog {
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
TournamentOptions tOptions = new TournamentOptions(this.txtName.getText());
tOptions.setTournamentType(tournamentType.getName());
tOptions.setPassword(txtPassword.getText());
tOptions.getPlayerTypes().add("Human");
tOptions.setWatchingAllowed(cbAllowSpectators.isSelected());
for (TournamentPlayerPanel player: players) {
@ -429,10 +482,10 @@ public class NewTournamentDialog extends MageDialog {
options.setTiming((TimingOption) this.cbDraftTiming.getSelectedItem());
tOptions.setLimitedOptions(options);
}
if (tournamentType.isLimited()) {
if (tOptions.getLimitedOptions() == null) {
tOptions.setLimitedOptions(new LimitedOptions());
}
if (tournamentType.isLimited()) {
tOptions.getLimitedOptions().setConstructionTime((Integer)this.spnConstructTime.getValue() * 60);
if (tournamentType.isCubeBooster()) {
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.getMatchOptions().setMatchTimeLimit((MatchTimeLimit) this.cbTimeLimit.getSelectedItem());
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().setWinsNeeded((Integer)this.spnNumWins.getValue());
tOptions.getMatchOptions().setFreeMulligans((Integer)this.spnFreeMulligans.getValue());
tOptions.getMatchOptions().setAttackOption(MultiplayerAttackOption.LEFT);
tOptions.getMatchOptions().setRange(RangeOfInfluence.ALL);
tOptions.getMatchOptions().setLimited(true);
saveTournamentSettingsToPrefs(tOptions);
table = session.createTournamentTable(roomId, tOptions);
@ -457,10 +519,16 @@ public class NewTournamentDialog extends MageDialog {
// message must be send by server!
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) {
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
session.removeTable(roomId, table.getTableId());
table = null;
@ -503,6 +571,21 @@ public class NewTournamentDialog extends MageDialog {
// TODO add your handling code here:
}//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) {
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
activatePanelElements(tournamentType);
@ -529,6 +612,16 @@ public class NewTournamentDialog extends MageDialog {
this.pnlDraftOptions.setVisible(tournamentType.isDraft());
this.lblNumRounds.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.isCubeBooster()) {
this.lblDraftCube.setVisible(true);
@ -545,7 +638,8 @@ public class NewTournamentDialog extends MageDialog {
// construced
this.lblDraftCube.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) {
TournamentPlayerPanel playerPanel = new TournamentPlayerPanel();
playerPanel.init(players.size() + 2);
players.add(playerPanel);
}
}
@ -643,6 +738,7 @@ public class NewTournamentDialog extends MageDialog {
private void setTournamentSettingsFromPrefs () {
int numPlayers;
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"));
for (MatchTimeLimit mtl :MatchTimeLimit.values()) {
if (mtl.getTimeLimit() == timeLimit) {
@ -724,26 +820,34 @@ public class NewTournamentDialog extends MageDialog {
*/
private void saveTournamentSettingsToPrefs(TournamentOptions tOptions) {
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()));
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_NUMBER_OF_FREE_MULLIGANS, Integer.toString(tOptions.getMatchOptions().getFreeMulligans()));
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_PLAYERS_SEALED, Integer.toString(tOptions.getPlayerTypes().size()));
break;
case "Elimination Booster Draft":
}
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());
}
break;
}
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"));
}
@ -757,34 +861,39 @@ public class NewTournamentDialog extends MageDialog {
private javax.swing.JButton btnCancel;
private javax.swing.JButton btnOk;
private javax.swing.JCheckBox cbAllowSpectators;
private javax.swing.JComboBox cbDeckType;
private javax.swing.JComboBox cbDraftCube;
private javax.swing.JComboBox cbDraftTiming;
private javax.swing.JComboBox cbGameType;
private javax.swing.JComboBox cbTimeLimit;
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.JPanel jPanel1;
private javax.swing.JLabel lbDeckType;
private javax.swing.JLabel lbTimeLimit;
private javax.swing.JLabel lblConstructionTime;
private javax.swing.JLabel lblDraftCube;
private javax.swing.JLabel lblFreeMulligans;
private javax.swing.JLabel lblGameType;
private javax.swing.JLabel lblName;
private javax.swing.JLabel lblNbrPlayers;
private javax.swing.JLabel lblNumRounds;
private javax.swing.JLabel lblNumWins;
private javax.swing.JLabel lblPacks;
private javax.swing.JLabel lblPassword;
private javax.swing.JLabel lblPlayer1;
private javax.swing.JLabel lblTournamentType;
private mage.client.table.NewPlayerPanel player1Panel;
private javax.swing.JPanel pnlDraftOptions;
private javax.swing.JPanel pnlOtherPlayers;
private javax.swing.JPanel pnlPacks;
private javax.swing.JPanel pnlPlayers;
private javax.swing.JSpinner spnConstructTime;
private javax.swing.JSpinner spnFreeMulligans;
private javax.swing.JSpinner spnNumPlayers;
private javax.swing.JSpinner spnNumRounds;
private javax.swing.JSpinner spnNumWins;
private javax.swing.JTextField txtName;
private javax.swing.JTextField txtPlayer1Name;
private javax.swing.JTextField txtPassword;
private org.jdesktop.beansbinding.BindingGroup bindingGroup;
// 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
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_CONSTR_TIME = "newTournamentConstructionTime";
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_DRAFT_TIMING = "newTournamentDraftTiming";
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
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">
<AuxValues>

View file

@ -123,6 +123,13 @@ public class NewPlayerPanel extends javax.swing.JPanel {
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
* initialize the form.
* 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 gameId = (UUID)tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 2);
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);
String owner = (String)tableModel.getValueAt(modelRow, 1);
switch (action) {
@ -170,10 +172,18 @@ public class TablesPanel extends javax.swing.JPanel {
}
if (isTournament) {
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 {
logger.info("Joining table " + tableId);
joinTableDialog.showDialog(roomId, tableId);
joinTableDialog.showDialog(roomId, tableId, false, false);
}
break;
case "Remove":
@ -696,6 +706,8 @@ private void chkShowCompletedActionPerformed(java.awt.event.ActionEvent evt) {//
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)
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">
<AuxValues>

View file

@ -37,6 +37,8 @@ package mage.client.table;
import java.util.UUID;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import mage.cards.decks.DeckCardLists;
import mage.cards.decks.importer.DeckImporterUtil;
import mage.client.MageFrame;
import mage.remote.Session;
@ -64,9 +66,16 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
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")) {
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;
}

View file

@ -82,7 +82,7 @@ public interface MageServer {
TableView createTable(String sessionId, UUID roomId, MatchOptions matchOptions) 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 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;
void updateDeck(String sessionId, UUID tableId, DeckCardLists deckList) throws MageException, GameException;
boolean watchTable(String sessionId, UUID roomId, UUID tableId) throws MageException;

View file

@ -29,6 +29,7 @@
package mage.interfaces;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import mage.utils.MageVersion;
import mage.view.GameTypeView;
@ -62,6 +63,16 @@ public class ServerState implements Serializable {
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() {
return tournamentTypes;
}

View file

@ -453,6 +453,11 @@ public class SessionImpl implements Session {
return serverState.getGameTypes();
}
@Override
public List<GameTypeView> getTournamentGameTypes() {
return serverState.getTournamentGameTypes();
}
@Override
public String[] getDeckTypes() {
return serverState.getDeckTypes();
@ -588,10 +593,10 @@ public class SessionImpl implements Session {
}
@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 {
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) {
handleGameException(ex);

View file

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

View file

@ -63,7 +63,7 @@ public interface PlayerActions {
// 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);

View file

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

View file

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

View file

@ -37,11 +37,12 @@ import mage.game.tournament.TournamentType;
public class ConstructedEliminationTournamentType extends TournamentType {
public ConstructedEliminationTournamentType() {
this.name = "Elimination Constructed";
this.name = "Constructed Elimination";
this.maxPlayers = 16;
this.minPlayers = 4;
this.numBoosters = 0;
this.draft = 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"/>
</gameTypes>
<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 (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"/>

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"/>
</gameTypes>
<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 (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"/>

View file

@ -236,7 +236,7 @@ public class MageServerImpl implements MageServer {
}
@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() {
@Override
public Boolean execute() throws MageException {
@ -251,7 +251,7 @@ public class MageServerImpl implements MageServer {
logger.fatal("Got no userId from sessionId" + sessionId + " tableId" + tableId);
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;
}
});

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) {
return false;
}
Seat seat = table.getNextAvailableSeat(playerType);
if (seat == null) {
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());
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")){
user.showUserMessage("Join Table", new StringBuilder("You can join a table only one time.").toString());
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);
if (player != null) {
if (!player.canJoinTable(table)) {
@ -173,6 +200,10 @@ public class TableController {
return false;
}
tournament.addPlayer(player, seat.getPlayerType());
TournamentPlayer tournamentPlayer = tournament.getPlayer(player.getId());
if (deck != null && tournamentPlayer != null) {
tournamentPlayer.submitDeck(deck);
}
table.joinTable(player, seat);
logger.trace("player " + player.getName() + " joined tableId: " + table.getId());
//only inform human players and add them to sessionPlayerMap

View file

@ -148,9 +148,9 @@ public class TableManager {
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)) {
return controllers.get(tableId).joinTournament(userId, name, playerType, skill);
return controllers.get(tableId).joinTournament(userId, name, playerType, skill, deckList, password);
}
return false;
}

View file

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

View file

@ -39,7 +39,6 @@ import mage.server.Room;
import mage.view.MatchView;
import mage.view.RoomUsersView;
import mage.view.TableView;
import mage.view.UsersView;
/**
*
@ -51,7 +50,7 @@ public interface GamesRoom extends Room {
List<MatchView> getFinished();
List<RoomUsersView> getRoomUsersInfo();
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 createTournamentTable(UUID userId, TournamentOptions options);
void removeTable(UUID userId, UUID tableId);

View file

@ -155,9 +155,9 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
}
@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)) {
return TableManager.getInstance().joinTournament(userId, tableId, name, playerType, skill);
return TableManager.getInstance().joinTournament(userId, tableId, name, playerType, skill, deckList, password);
} else {
return false;
}

View file

@ -69,13 +69,13 @@ public class TournamentFactory {
tournament = con.newInstance(new Object[] {options});
// transfer set information, create short info string for included sets
tournament.setTournamentType(tournamentTypes.get(tournamentType));
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);
}
if (tournament.getTournamentType().isLimited()) {
tournament.getOptions().getLimitedOptions().setNumberBoosters(tournament.getTournamentType().getNumBoosters());
if (tournament.getTournamentType().isCubeBooster()) {
tournament.getOptions().getLimitedOptions().setDraftCube(CubeFactory.getInstance().createDraftCube(tournament.getOptions().getLimitedOptions().getDraftCubeName()));
@ -87,14 +87,15 @@ public class TournamentFactory {
}
tournament.setBoosterInfo(sb.toString());
}
} else {
tournament.setBoosterInfo("");
}
} catch (Exception ex) {
logger.fatal("TournamentFactory error ", ex);
return null;
}
logger.debug("Tournament created: " + tournamentType); // + game.getId().toString());
logger.debug("Tournament created: " + tournamentType + " " + tournament.getId());
return tournament;
}

View file

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

View file

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