* Added tournament options for adjustable construction time and free mulligans

* Added duel options for free mulligans
This commit is contained in:
LevelX2 2013-06-14 23:45:30 +02:00
parent fa5ddb23a2
commit 84df0f2c43
27 changed files with 558 additions and 402 deletions

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.JInternalFrameFormInfo"> <Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<Properties> <Properties>
@ -24,69 +24,73 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0"> <Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="btnOK" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnCancel" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblNumPlayers" min="-2" max="-2" attributes="0"/>
<Component id="spnNumPlayers" min="-2" pref="57" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblRange" min="-2" max="-2" attributes="1"/>
<Component id="cbRange" min="-2" pref="143" max="-2" attributes="1"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblAttack" min="-2" max="-2" attributes="0"/>
<Component id="cbAttackOption" pref="287" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="spnNumWins" min="-2" pref="50" max="-2" attributes="0"/>
<Component id="lblNumWins" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jSeparator2" pref="555" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="player1Panel" pref="555" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="16" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0"> <Group type="103" groupAlignment="1" attributes="0">
<Component id="lbDeckType" alignment="1" min="-2" max="-2" attributes="0"/> <Group type="102" alignment="0" attributes="0">
<Component id="lblGameType" alignment="1" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="lblName" min="-2" max="-2" attributes="0"/> <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace min="-2" pref="16" max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="lbDeckType" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="lblGameType" alignment="1" min="-2" max="-2" attributes="0"/>
<Component id="lblName" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" max="-2" attributes="0">
<Component id="cbDeckType" alignment="0" max="32767" attributes="1"/>
<Group type="102" alignment="0" attributes="0">
<Component id="cbGameType" min="-2" pref="398" max="-2" attributes="1"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblFreeMulligans" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnFreeMulligans" pref="50" max="32767" attributes="0"/>
</Group>
<Component id="txtName" max="32767" attributes="0"/>
</Group>
</Group>
</Group> </Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
<Group type="102" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0"> <Group type="103" groupAlignment="1" attributes="0">
<Component id="cbDeckType" alignment="0" pref="487" max="32767" attributes="1"/> <Group type="102" alignment="1" attributes="0">
<Component id="cbGameType" alignment="1" pref="487" max="32767" attributes="1"/> <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="txtName" alignment="1" pref="487" max="32767" attributes="0"/> <Component id="btnOK" min="-2" max="-2" attributes="0"/>
</Group> <EmptySpace max="-2" attributes="0"/>
</Group> <Component id="btnCancel" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0"> </Group>
<EmptySpace max="-2" attributes="0"/> <Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="pnlOtherPlayers" alignment="1" pref="555" max="32767" attributes="0"/> <Component id="lblNumPlayers" min="-2" max="-2" attributes="0"/>
<Component id="jSeparator1" alignment="0" pref="555" max="32767" attributes="0"/> <Component id="spnNumPlayers" min="-2" pref="57" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblRange" min="-2" max="-2" attributes="1"/>
<Component id="cbRange" min="-2" pref="143" max="-2" attributes="1"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblAttack" min="-2" max="-2" attributes="0"/>
<Component id="cbAttackOption" max="32767" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="spnNumWins" min="-2" pref="50" max="-2" attributes="0"/>
<Component id="lblNumWins" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="jSeparator2" alignment="1" max="32767" attributes="0"/>
<Component id="player1Panel" alignment="0" max="32767" attributes="0"/>
<Component id="pnlOtherPlayers" alignment="1" max="32767" attributes="0"/>
<Component id="jSeparator1" alignment="0" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</Group> </Group>
@ -95,7 +99,7 @@
<Group type="103" rootIndex="1" groupAlignment="0" attributes="0"> <Group type="103" rootIndex="1" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jSeparator3" pref="555" max="32767" attributes="0"/> <Component id="jSeparator3" pref="625" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
@ -118,6 +122,10 @@
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="cbGameType" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="cbGameType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblGameType" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblGameType" alignment="3" min="-2" max="-2" attributes="0"/>
<Group type="103" alignment="3" groupAlignment="3" attributes="0">
<Component id="spnFreeMulligans" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblFreeMulligans" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
@ -153,7 +161,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="136" max="32767" attributes="0"/> <Component id="pnlOtherPlayers" pref="140" 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"/>
@ -167,13 +175,30 @@
<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="207" max="32767" attributes="0"/> <EmptySpace pref="240" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
<SubComponents> <SubComponents>
<Component class="javax.swing.JLabel" name="lblName">
<Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="txtName"/>
</Property>
<Property name="text" type="java.lang.String" value="Name:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtName">
</Component>
<Component class="javax.swing.JLabel" name="lbDeckType">
<Properties>
<Property name="text" type="java.lang.String" value="Deck Type:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="cbDeckType">
</Component>
<Component class="javax.swing.JLabel" name="lblGameType"> <Component class="javax.swing.JLabel" name="lblGameType">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Game Type:"/> <Property name="text" type="java.lang.String" value="Game Type:"/>
@ -184,35 +209,12 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbGameTypeActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbGameTypeActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JLabel" name="lbDeckType"> <Component class="javax.swing.JLabel" name="lblFreeMulligans">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Deck Type:"/> <Property name="text" type="java.lang.String" value="Free Mulligans:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JComboBox" name="cbDeckType"> <Component class="javax.swing.JSpinner" name="spnFreeMulligans">
</Component>
<Component class="javax.swing.JButton" name="btnOK">
<Properties>
<Property name="text" type="java.lang.String" value="OK"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnOKActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnCancel">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelActionPerformed"/>
</Events>
</Component>
<Component class="mage.client.table.NewPlayerPanel" name="player1Panel">
</Component>
<Component class="javax.swing.JSpinner" name="spnNumPlayers">
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="numPlayersChanged"/>
</Events>
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblNumPlayers"> <Component class="javax.swing.JLabel" name="lblNumPlayers">
<Properties> <Properties>
@ -222,12 +224,10 @@
<Property name="text" type="java.lang.String" value="Players"/> <Property name="text" type="java.lang.String" value="Players"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JComboBox" name="cbRange"> <Component class="javax.swing.JSpinner" name="spnNumPlayers">
<Properties> <Events>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor"> <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="numPlayersChanged"/>
<StringArray count="0"/> </Events>
</Property>
</Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblRange"> <Component class="javax.swing.JLabel" name="lblRange">
<Properties> <Properties>
@ -237,6 +237,13 @@
<Property name="text" type="java.lang.String" value="Range of Influence"/> <Property name="text" type="java.lang.String" value="Range of Influence"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JComboBox" name="cbRange">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="0"/>
</Property>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblAttack"> <Component class="javax.swing.JLabel" name="lblAttack">
<Properties> <Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
@ -252,35 +259,6 @@
</Property> </Property>
</Properties> </Properties>
</Component> </Component>
<Container class="javax.swing.JPanel" name="pnlOtherPlayers">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
<Property name="columns" type="int" value="1"/>
<Property name="rows" type="int" value="0"/>
</Layout>
</Container>
<Component class="javax.swing.JSeparator" name="jSeparator1">
</Component>
<Component class="javax.swing.JSeparator" name="jSeparator2">
</Component>
<Component class="javax.swing.JLabel" name="jLabel1">
<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.JSeparator" name="jSeparator3">
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<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="Other Players"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="lblNumWins"> <Component class="javax.swing.JLabel" name="lblNumWins">
<Properties> <Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> <Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
@ -294,15 +272,52 @@
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spnNumWinsnumPlayersChanged"/> <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spnNumWinsnumPlayersChanged"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JTextField" name="txtName"> <Component class="javax.swing.JSeparator" name="jSeparator2">
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblName"> <Component class="javax.swing.JLabel" name="jLabel1">
<Properties> <Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor"> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">
<ComponentRef name="txtName"/> <Font name="Tahoma" size="11" style="1"/>
</Property> </Property>
<Property name="text" type="java.lang.String" value="Name:"/> <Property name="text" type="java.lang.String" value="Player 1 (You)"/>
</Properties> </Properties>
</Component> </Component>
<Component class="mage.client.table.NewPlayerPanel" name="player1Panel">
</Component>
<Component class="javax.swing.JSeparator" name="jSeparator3">
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
<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="Other Players"/>
</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"/>
<Property name="rows" type="int" value="0"/>
</Layout>
</Container>
<Component class="javax.swing.JSeparator" name="jSeparator1">
</Component>
<Component class="javax.swing.JButton" name="btnOK">
<Properties>
<Property name="text" type="java.lang.String" value="OK"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnOKActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnCancel">
<Properties>
<Property name="text" type="java.lang.String" value="Cancel"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelActionPerformed"/>
</Events>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

View file

@ -27,6 +27,13 @@
*/ */
package mage.client.dialog; package mage.client.dialog;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.swing.*;
import mage.Constants.MultiplayerAttackOption; import mage.Constants.MultiplayerAttackOption;
import mage.Constants.RangeOfInfluence; import mage.Constants.RangeOfInfluence;
import mage.cards.decks.importer.DeckImporterUtil; import mage.cards.decks.importer.DeckImporterUtil;
@ -41,13 +48,6 @@ import mage.view.GameTypeView;
import mage.view.TableView; import mage.view.TableView;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import javax.swing.*;
import java.io.FileNotFoundException;
import java.io.IOException;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/** /**
* *
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
@ -69,6 +69,7 @@ public class NewTableDialog extends MageDialog {
initComponents(); initComponents();
player1Panel.showLevel(false); player1Panel.showLevel(false);
this.spnNumWins.setModel(new SpinnerNumberModel(1, 1, 5, 1)); this.spnNumWins.setModel(new SpinnerNumberModel(1, 1, 5, 1));
this.spnFreeMulligans.setModel(new SpinnerNumberModel(0, 0, 5, 1));
} }
/** This method is called from within the constructor to /** This method is called from within the constructor to
@ -80,32 +81,39 @@ public class NewTableDialog extends MageDialog {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
lblGameType = new javax.swing.JLabel(); lblName = new javax.swing.JLabel();
cbGameType = new javax.swing.JComboBox(); txtName = new javax.swing.JTextField();
lbDeckType = new javax.swing.JLabel(); lbDeckType = new javax.swing.JLabel();
cbDeckType = new javax.swing.JComboBox(); cbDeckType = new javax.swing.JComboBox();
btnOK = new javax.swing.JButton(); lblGameType = new javax.swing.JLabel();
btnCancel = new javax.swing.JButton(); cbGameType = new javax.swing.JComboBox();
player1Panel = new mage.client.table.NewPlayerPanel(); lblFreeMulligans = new javax.swing.JLabel();
spnNumPlayers = new javax.swing.JSpinner(); spnFreeMulligans = new javax.swing.JSpinner();
lblNumPlayers = new javax.swing.JLabel(); lblNumPlayers = new javax.swing.JLabel();
cbRange = new javax.swing.JComboBox(); spnNumPlayers = new javax.swing.JSpinner();
lblRange = new javax.swing.JLabel(); lblRange = new javax.swing.JLabel();
cbRange = new javax.swing.JComboBox();
lblAttack = new javax.swing.JLabel(); lblAttack = new javax.swing.JLabel();
cbAttackOption = new javax.swing.JComboBox(); cbAttackOption = new javax.swing.JComboBox();
pnlOtherPlayers = new javax.swing.JPanel();
jSeparator1 = new javax.swing.JSeparator();
jSeparator2 = new javax.swing.JSeparator();
jLabel1 = new javax.swing.JLabel();
jSeparator3 = new javax.swing.JSeparator();
jLabel2 = new javax.swing.JLabel();
lblNumWins = new javax.swing.JLabel(); lblNumWins = new javax.swing.JLabel();
spnNumWins = new javax.swing.JSpinner(); spnNumWins = new javax.swing.JSpinner();
txtName = new javax.swing.JTextField(); jSeparator2 = new javax.swing.JSeparator();
lblName = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel();
player1Panel = new mage.client.table.NewPlayerPanel();
jSeparator3 = new javax.swing.JSeparator();
jLabel2 = new javax.swing.JLabel();
pnlOtherPlayers = new javax.swing.JPanel();
jSeparator1 = new javax.swing.JSeparator();
btnOK = new javax.swing.JButton();
btnCancel = new javax.swing.JButton();
setTitle("New Table"); setTitle("New Table");
lblName.setLabelFor(txtName);
lblName.setText("Name:");
lbDeckType.setText("Deck Type:");
lblGameType.setText("Game Type:"); lblGameType.setText("Game Type:");
cbGameType.addActionListener(new java.awt.event.ActionListener() { cbGameType.addActionListener(new java.awt.event.ActionListener() {
@ -114,7 +122,39 @@ public class NewTableDialog extends MageDialog {
} }
}); });
lbDeckType.setText("Deck Type:"); lblFreeMulligans.setText("Free Mulligans:");
lblNumPlayers.setLabelFor(spnNumPlayers);
lblNumPlayers.setText("Players");
spnNumPlayers.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
numPlayersChanged(evt);
}
});
lblRange.setLabelFor(cbRange);
lblRange.setText("Range of Influence");
lblAttack.setLabelFor(cbAttackOption);
lblAttack.setText("Attack Option");
lblNumWins.setLabelFor(spnNumWins);
lblNumWins.setText("Wins");
spnNumWins.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spnNumWinsnumPlayersChanged(evt);
}
});
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel1.setText("Player 1 (You)");
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel2.setText("Other Players");
pnlOtherPlayers.setLayout(new java.awt.GridLayout(0, 1));
btnOK.setText("OK"); btnOK.setText("OK");
btnOK.addActionListener(new java.awt.event.ActionListener() { btnOK.addActionListener(new java.awt.event.ActionListener() {
@ -130,102 +170,70 @@ public class NewTableDialog extends MageDialog {
} }
}); });
spnNumPlayers.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
numPlayersChanged(evt);
}
});
lblNumPlayers.setLabelFor(spnNumPlayers);
lblNumPlayers.setText("Players");
lblRange.setLabelFor(cbRange);
lblRange.setText("Range of Influence");
lblAttack.setLabelFor(cbAttackOption);
lblAttack.setText("Attack Option");
pnlOtherPlayers.setLayout(new java.awt.GridLayout(0, 1));
jLabel1.setFont(new java.awt.Font("Tahoma", 1, 11));
jLabel1.setText("Player 1 (You)");
jLabel2.setFont(new java.awt.Font("Tahoma", 1, 11));
jLabel2.setText("Other Players");
lblNumWins.setLabelFor(spnNumWins);
lblNumWins.setText("Wins");
spnNumWins.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spnNumWinsnumPlayersChanged(evt);
}
});
lblName.setLabelFor(txtName);
lblName.setText("Name:");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnOK)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblNumPlayers)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblRange)
.addComponent(cbRange, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblAttack)
.addComponent(cbAttackOption, 0, 287, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblNumWins)))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jSeparator2, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(player1Panel, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel2))
.addGroup(layout.createSequentialGroup()
.addGap(16, 16, 16)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lbDeckType) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(lblGameType) .addContainerGap()
.addComponent(lblName)) .addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addContainerGap()
.addComponent(cbDeckType, javax.swing.GroupLayout.Alignment.LEADING, 0, 487, Short.MAX_VALUE) .addComponent(jLabel2))
.addComponent(cbGameType, 0, 487, Short.MAX_VALUE) .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(txtName, javax.swing.GroupLayout.DEFAULT_SIZE, 487, Short.MAX_VALUE))) .addGap(16, 16, 16)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lbDeckType)
.addComponent(lblGameType)
.addComponent(lblName))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING, false)
.addComponent(cbDeckType, javax.swing.GroupLayout.Alignment.LEADING, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, 398, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblFreeMulligans)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.DEFAULT_SIZE, 50, Short.MAX_VALUE))
.addComponent(txtName))))
.addGap(0, 0, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE) .addGroup(layout.createSequentialGroup()
.addComponent(jSeparator1, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE)))) .addGap(0, 0, Short.MAX_VALUE)
.addComponent(btnOK)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnCancel))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblNumPlayers)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 57, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblRange)
.addComponent(cbRange, javax.swing.GroupLayout.PREFERRED_SIZE, 143, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(lblAttack)
.addComponent(cbAttackOption, 0, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblNumWins)))
.addComponent(jSeparator2)
.addComponent(player1Panel, javax.swing.GroupLayout.Alignment.LEADING, 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)
.addComponent(jSeparator1, javax.swing.GroupLayout.Alignment.LEADING))))
.addContainerGap()) .addContainerGap())
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 555, Short.MAX_VALUE) .addComponent(jSeparator3, javax.swing.GroupLayout.DEFAULT_SIZE, 625, Short.MAX_VALUE)
.addContainerGap())) .addContainerGap()))
); );
layout.setVerticalGroup( layout.setVerticalGroup(
@ -242,7 +250,10 @@ public class NewTableDialog 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(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cbGameType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblGameType)) .addComponent(lblGameType)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblFreeMulligans)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
@ -271,7 +282,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, 136, Short.MAX_VALUE) .addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 140, 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)
@ -283,7 +294,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(207, Short.MAX_VALUE))) .addContainerGap(240, Short.MAX_VALUE)))
); );
pack(); pack();
@ -307,6 +318,7 @@ public class NewTableDialog extends MageDialog {
options.setAttackOption((MultiplayerAttackOption) this.cbAttackOption.getSelectedItem()); options.setAttackOption((MultiplayerAttackOption) this.cbAttackOption.getSelectedItem());
options.setRange((RangeOfInfluence) this.cbRange.getSelectedItem()); options.setRange((RangeOfInfluence) this.cbRange.getSelectedItem());
options.setWinsNeeded((Integer)this.spnNumWins.getValue()); options.setWinsNeeded((Integer)this.spnNumWins.getValue());
options.setFreeMulligans((Integer)this.spnFreeMulligans.getValue());
saveGameSettingsToPrefs(options, this.player1Panel.getDeckFile()); saveGameSettingsToPrefs(options, this.player1Panel.getDeckFile());
table = session.createTable(roomId, options); table = session.createTable(roomId, options);
@ -458,6 +470,7 @@ public class NewTableDialog extends MageDialog {
this.player1Panel.setDeckFile(deckFile); this.player1Panel.setDeckFile(deckFile);
} }
this.spnNumWins.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_WINS, "2"))); this.spnNumWins.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_WINS, "2")));
this.spnFreeMulligans.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS, "0")));
this.spnNumPlayers.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_PLAYERS, "2"))); this.spnNumPlayers.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_PLAYERS, "2")));
int range = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_RANGE, "1")); int range = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_RANGE, "1"));
for (RangeOfInfluence roi :RangeOfInfluence.values()) { for (RangeOfInfluence roi :RangeOfInfluence.values()) {
@ -486,6 +499,7 @@ public class NewTableDialog extends MageDialog {
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_TYPE, options.getDeckType()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_TYPE, options.getDeckType());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_GAME_TYPE, options.getGameType()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_GAME_TYPE, options.getGameType());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_WINS, Integer.toString(options.getWinsNeeded())); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_WINS, Integer.toString(options.getWinsNeeded()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS, Integer.toString(options.getFreeMulligans()));
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE, deckFile); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE, deckFile);
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_PLAYERS, spnNumPlayers.getValue().toString()); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_PLAYERS, spnNumPlayers.getValue().toString());
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_RANGE, Integer.toString(options.getRange().getRange())); PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_RANGE, Integer.toString(options.getRange().getRange()));
@ -506,6 +520,7 @@ public class NewTableDialog extends MageDialog {
private javax.swing.JSeparator jSeparator3; private javax.swing.JSeparator jSeparator3;
private javax.swing.JLabel lbDeckType; private javax.swing.JLabel lbDeckType;
private javax.swing.JLabel lblAttack; private javax.swing.JLabel lblAttack;
private javax.swing.JLabel lblFreeMulligans;
private javax.swing.JLabel lblGameType; private javax.swing.JLabel lblGameType;
private javax.swing.JLabel lblName; private javax.swing.JLabel lblName;
private javax.swing.JLabel lblNumPlayers; private javax.swing.JLabel lblNumPlayers;
@ -513,6 +528,7 @@ public class NewTableDialog extends MageDialog {
private javax.swing.JLabel lblRange; private javax.swing.JLabel lblRange;
private mage.client.table.NewPlayerPanel player1Panel; private mage.client.table.NewPlayerPanel player1Panel;
private javax.swing.JPanel pnlOtherPlayers; private javax.swing.JPanel pnlOtherPlayers;
private javax.swing.JSpinner spnFreeMulligans;
private javax.swing.JSpinner spnNumPlayers; private javax.swing.JSpinner spnNumPlayers;
private javax.swing.JSpinner spnNumWins; private javax.swing.JSpinner spnNumWins;
private javax.swing.JTextField txtName; private javax.swing.JTextField txtName;

View file

@ -27,14 +27,6 @@
<Group type="103" groupAlignment="1" attributes="0"> <Group type="103" groupAlignment="1" attributes="0">
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/> <Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
<Component id="pnlPacks" alignment="1" max="32767" attributes="0"/> <Component id="pnlPacks" alignment="1" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnNumPlayers" min="-2" pref="45" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="pnlDraftOptions" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jLabel5" alignment="0" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0"> <Group type="103" groupAlignment="1" attributes="0">
<Component id="lblName" min="-2" max="-2" attributes="0"/> <Component id="lblName" min="-2" max="-2" attributes="0"/>
@ -43,19 +35,47 @@
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0"> <Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="txtName" max="32767" attributes="0"/> <Component id="txtName" max="32767" attributes="0"/>
<Component id="cbTournamentType" pref="420" max="32767" attributes="0"/> <Component id="cbTournamentType" pref="330" max="32767" attributes="0"/>
</Group> </Group>
<EmptySpace type="unrelated" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="spnNumWins" alignment="0" min="-2" pref="50" max="-2" attributes="0"/> <Group type="102" alignment="0" attributes="0">
<Component id="lblNumWins" alignment="0" min="-2" max="-2" attributes="0"/> <EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="lblFreeMulligans" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnFreeMulligans" max="32767" attributes="0"/>
<EmptySpace type="unrelated" max="-2" attributes="0"/>
<Component id="lblNumWins" min="-2" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="1" attributes="0">
<EmptySpace min="-2" pref="19" max="-2" attributes="0"/>
<Component id="lblConstructionTime" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="spnConstructTime" pref="48" max="32767" attributes="0"/>
<Component id="spnNumWins" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
<Group type="102" alignment="1" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
<Component id="btnOk" min="-2" max="-2" attributes="0"/> <Component id="btnOk" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="btnCancel" min="-2" max="-2" attributes="0"/> <Component id="btnCancel" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="0" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="spnNumPlayers" min="-2" pref="45" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="pnlDraftOptions" min="-2" max="-2" attributes="0"/>
</Group>
<Component id="jLabel5" alignment="0" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group>
</Group> </Group>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
@ -78,18 +98,26 @@
</Group> </Group>
</Group> </Group>
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Component id="lblNumWins" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="3" attributes="0">
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/> <Component id="lblConstructionTime" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnNumWins" min="-2" max="-2" attributes="0"/> <Component id="spnConstructTime" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="spnNumWins" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblNumWins" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnFreeMulligans" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblFreeMulligans" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group> </Group>
</Group> </Group>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" min="-2" max="-2" attributes="0"/> <Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="pnlPacks" pref="63" max="32767" attributes="0"/> <Component id="pnlPacks" pref="65" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="11" max="-2" attributes="0"/> <EmptySpace min="-2" pref="11" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="spnNumPlayers" alignment="0" pref="26" max="32767" attributes="1"/> <Component id="spnNumPlayers" alignment="0" pref="28" max="32767" attributes="1"/>
<Component id="pnlDraftOptions" max="32767" attributes="1"/> <Component id="pnlDraftOptions" max="32767" attributes="1"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/> <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
</Group> </Group>
@ -105,6 +133,20 @@
</DimensionLayout> </DimensionLayout>
</Layout> </Layout>
<SubComponents> <SubComponents>
<Component class="javax.swing.JLabel" name="lblName">
<Properties>
<Property name="text" type="java.lang.String" value="Name:"/>
</Properties>
</Component>
<Component class="javax.swing.JTextField" name="txtName">
</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">
</Component>
<Component class="javax.swing.JLabel" name="jLabel1"> <Component class="javax.swing.JLabel" name="jLabel1">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Tournament Type:"/> <Property name="text" type="java.lang.String" value="Tournament Type:"/>
@ -125,16 +167,41 @@
<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.JSpinner" name="spnNumPlayers"> <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">
</Component>
<Component class="javax.swing.JLabel" name="lblNumWins">
<Properties>
<Property name="text" type="java.lang.String" value="Wins:"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnNumWins">
<Events> <Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spnNumPlayersStateChanged"/> <EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spnNumWinsnumPlayersChanged"/>
</Events> </Events>
</Component> </Component>
<Container class="javax.swing.JPanel" name="pnlPacks">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
<Property name="columns" type="int" value="1"/>
<Property name="horizontalGap" type="int" value="2"/>
<Property name="rows" type="int" value="0"/>
</Layout>
</Container>
<Component class="javax.swing.JLabel" name="jLabel2"> <Component class="javax.swing.JLabel" name="jLabel2">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Players:"/> <Property name="text" type="java.lang.String" value="Players:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JSpinner" name="spnNumPlayers">
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spnNumPlayersStateChanged"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnOk"> <Component class="javax.swing.JButton" name="btnOk">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="OK"/> <Property name="text" type="java.lang.String" value="OK"/>
@ -151,14 +218,6 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnCancelActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Container class="javax.swing.JPanel" name="pnlPacks">
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignGridLayout">
<Property name="columns" type="int" value="1"/>
<Property name="horizontalGap" type="int" value="2"/>
<Property name="rows" type="int" value="0"/>
</Layout>
</Container>
<Container class="javax.swing.JPanel" name="jPanel1"> <Container class="javax.swing.JPanel" name="jPanel1">
<Layout> <Layout>
@ -174,7 +233,7 @@
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="jLabel4" min="-2" max="-2" attributes="0"/> <Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="txtPlayer1Name" max="32767" attributes="0"/> <Component id="txtPlayer1Name" pref="638" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
@ -233,13 +292,6 @@
<Property name="text" type="java.lang.String" value="Packs"/> <Property name="text" type="java.lang.String" value="Packs"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JTextField" name="txtName">
</Component>
<Component class="javax.swing.JLabel" name="lblName">
<Properties>
<Property name="text" type="java.lang.String" value="Name:"/>
</Properties>
</Component>
<Container class="javax.swing.JPanel" name="pnlDraftOptions"> <Container class="javax.swing.JPanel" name="pnlDraftOptions">
<Layout> <Layout>
@ -283,15 +335,5 @@
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>
<Component class="javax.swing.JLabel" name="lblNumWins">
<Properties>
<Property name="text" type="java.lang.String" value="Wins"/>
</Properties>
</Component>
<Component class="javax.swing.JSpinner" name="spnNumWins">
<Events>
<EventHandler event="stateChanged" listener="javax.swing.event.ChangeListener" parameters="javax.swing.event.ChangeEvent" handler="spnNumWinsnumPlayersChanged"/>
</Events>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

View file

@ -34,9 +34,17 @@
package mage.client.dialog; package mage.client.dialog;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
import javax.swing.DefaultComboBoxModel;
import javax.swing.JComboBox;
import javax.swing.JOptionPane;
import javax.swing.SpinnerNumberModel;
import mage.Constants.MultiplayerAttackOption; import mage.Constants.MultiplayerAttackOption;
import mage.Constants.RangeOfInfluence; import mage.Constants.RangeOfInfluence;
import mage.cards.ExpansionSet; import mage.cards.ExpansionSet;
import mage.cards.Sets;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.table.TournamentPlayerPanel; import mage.client.table.TournamentPlayerPanel;
import mage.game.draft.DraftOptions; import mage.game.draft.DraftOptions;
@ -44,15 +52,10 @@ 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.cards.Sets;
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;
import javax.swing.*;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
/** /**
* *
@ -74,6 +77,8 @@ public class NewTournamentDialog extends MageDialog {
initComponents(); initComponents();
txtName.setText("Tournament"); txtName.setText("Tournament");
this.spnNumWins.setModel(new SpinnerNumberModel(2, 1, 5, 1)); this.spnNumWins.setModel(new SpinnerNumberModel(2, 1, 5, 1));
this.spnFreeMulligans.setModel(new SpinnerNumberModel(0, 0, 5, 1));
this.spnConstructTime.setModel(new SpinnerNumberModel(10, 10, 30, 5));
} }
public void showDialog(UUID roomId) { public void showDialog(UUID roomId) {
@ -97,29 +102,37 @@ public class NewTournamentDialog extends MageDialog {
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() { private void initComponents() {
lblName = new javax.swing.JLabel();
txtName = new javax.swing.JTextField();
lblConstructionTime = new javax.swing.JLabel();
spnConstructTime = new javax.swing.JSpinner();
jLabel1 = new javax.swing.JLabel(); jLabel1 = new javax.swing.JLabel();
cbTournamentType = new javax.swing.JComboBox(); cbTournamentType = new javax.swing.JComboBox();
spnNumPlayers = new javax.swing.JSpinner(); lblFreeMulligans = new javax.swing.JLabel();
spnFreeMulligans = new javax.swing.JSpinner();
lblNumWins = new javax.swing.JLabel();
spnNumWins = new javax.swing.JSpinner();
pnlPacks = new javax.swing.JPanel();
jLabel2 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel();
spnNumPlayers = new javax.swing.JSpinner();
btnOk = new javax.swing.JButton(); btnOk = new javax.swing.JButton();
btnCancel = new javax.swing.JButton(); btnCancel = new javax.swing.JButton();
pnlPacks = new javax.swing.JPanel();
jPanel1 = new javax.swing.JPanel(); jPanel1 = new javax.swing.JPanel();
jLabel3 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel(); jLabel4 = new javax.swing.JLabel();
txtPlayer1Name = new javax.swing.JTextField(); txtPlayer1Name = new javax.swing.JTextField();
pnlOtherPlayers = new javax.swing.JPanel(); pnlOtherPlayers = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel();
txtName = new javax.swing.JTextField();
lblName = new javax.swing.JLabel();
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();
lblNumWins = new javax.swing.JLabel();
spnNumWins = new javax.swing.JSpinner();
setTitle("New Tournament"); setTitle("New Tournament");
lblName.setText("Name:");
lblConstructionTime.setText("Construction Time (Minutes):");
jLabel1.setText("Tournament Type:"); jLabel1.setText("Tournament Type:");
cbTournamentType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); cbTournamentType.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
@ -129,14 +142,26 @@ public class NewTournamentDialog extends MageDialog {
} }
}); });
lblFreeMulligans.setText("Free Mulligans:");
lblNumWins.setText("Wins:");
spnNumWins.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spnNumWinsnumPlayersChanged(evt);
}
});
pnlPacks.setLayout(new java.awt.GridLayout(0, 1, 2, 0));
jLabel2.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) {
spnNumPlayersStateChanged(evt); spnNumPlayersStateChanged(evt);
} }
}); });
jLabel2.setText("Players:");
btnOk.setText("OK"); btnOk.setText("OK");
btnOk.addActionListener(new java.awt.event.ActionListener() { btnOk.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
@ -151,8 +176,6 @@ public class NewTournamentDialog extends MageDialog {
} }
}); });
pnlPacks.setLayout(new java.awt.GridLayout(0, 1, 2, 0));
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel3.setText("Player 1 (You)"); jLabel3.setText("Player 1 (You)");
@ -175,7 +198,7 @@ public class NewTournamentDialog extends MageDialog {
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
.addComponent(jLabel4) .addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtPlayer1Name))) .addComponent(txtPlayer1Name, javax.swing.GroupLayout.DEFAULT_SIZE, 638, Short.MAX_VALUE)))
.addContainerGap()) .addContainerGap())
); );
jPanel1Layout.setVerticalGroup( jPanel1Layout.setVerticalGroup(
@ -193,8 +216,6 @@ public class NewTournamentDialog extends MageDialog {
jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel5.setText("Packs"); jLabel5.setText("Packs");
lblName.setText("Name:");
jLabel6.setText("Timing:"); jLabel6.setText("Timing:");
cbDraftTiming.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" })); cbDraftTiming.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
@ -217,14 +238,6 @@ public class NewTournamentDialog extends MageDialog {
.addComponent(jLabel6)) .addComponent(jLabel6))
); );
lblNumWins.setText("Wins");
spnNumWins.addChangeListener(new javax.swing.event.ChangeListener() {
public void stateChanged(javax.swing.event.ChangeEvent evt) {
spnNumWinsnumPlayersChanged(evt);
}
});
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
@ -234,13 +247,6 @@ public class NewTournamentDialog extends MageDialog {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jPanel1, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(lblName) .addComponent(lblName)
@ -248,15 +254,37 @@ public class NewTournamentDialog extends MageDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtName) .addComponent(txtName)
.addComponent(cbTournamentType, 0, 420, Short.MAX_VALUE)) .addComponent(cbTournamentType, 0, 330, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createSequentialGroup()
.addComponent(lblNumWins))) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lblFreeMulligans)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnFreeMulligans)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(lblNumWins))
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addGap(19, 19, 19)
.addComponent(lblConstructionTime)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(spnConstructTime, javax.swing.GroupLayout.DEFAULT_SIZE, 48, Short.MAX_VALUE)
.addComponent(spnNumWins)))
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.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(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, layout.createSequentialGroup()
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addComponent(jLabel5, javax.swing.GroupLayout.Alignment.LEADING))
.addGap(0, 0, Short.MAX_VALUE)))
.addContainerGap()) .addContainerGap())
); );
layout.setVerticalGroup( layout.setVerticalGroup(
@ -273,16 +301,22 @@ public class NewTournamentDialog extends MageDialog {
.addComponent(jLabel1) .addComponent(jLabel1)
.addComponent(cbTournamentType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(cbTournamentType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(lblNumWins) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addGap(0, 0, 0) .addComponent(lblConstructionTime)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))) .addComponent(spnConstructTime, 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(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblNumWins)
.addComponent(spnFreeMulligans, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblFreeMulligans))))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5) .addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE) .addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, 65, Short.MAX_VALUE)
.addGap(11, 11, 11) .addGap(11, 11, 11)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE) .addComponent(spnNumPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 28, Short.MAX_VALUE)
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(pnlDraftOptions, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2)) .addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -315,14 +349,17 @@ public class NewTournamentDialog extends MageDialog {
tOptions.setLimitedOptions(options); tOptions.setLimitedOptions(options);
} }
if (tournamentType.isLimited()) { if (tournamentType.isLimited()) {
if (tOptions.getLimitedOptions() == null) if (tOptions.getLimitedOptions() == null) {
tOptions.setLimitedOptions(new LimitedOptions()); tOptions.setLimitedOptions(new LimitedOptions());
tOptions.getLimitedOptions().setConstructionTime((Integer)this.spnConstructTime.getValue());
}
for (JComboBox pack: packs) { for (JComboBox pack: packs) {
tOptions.getLimitedOptions().getSetCodes().add(((ExpansionSet) pack.getSelectedItem()).getCode()); tOptions.getLimitedOptions().getSetCodes().add(((ExpansionSet) pack.getSelectedItem()).getCode());
} }
} }
tOptions.getMatchOptions().setDeckType("Limited"); 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().setAttackOption(MultiplayerAttackOption.LEFT); tOptions.getMatchOptions().setAttackOption(MultiplayerAttackOption.LEFT);
tOptions.getMatchOptions().setRange(RangeOfInfluence.ALL); tOptions.getMatchOptions().setRange(RangeOfInfluence.ALL);
tOptions.getMatchOptions().setLimited(true); tOptions.getMatchOptions().setLimited(true);
@ -483,11 +520,15 @@ public class NewTournamentDialog extends MageDialog {
private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6; private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel1;
private javax.swing.JLabel lblConstructionTime;
private javax.swing.JLabel lblFreeMulligans;
private javax.swing.JLabel lblName; private javax.swing.JLabel lblName;
private javax.swing.JLabel lblNumWins; private javax.swing.JLabel lblNumWins;
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.JSpinner spnConstructTime;
private javax.swing.JSpinner spnFreeMulligans;
private javax.swing.JSpinner spnNumPlayers; private javax.swing.JSpinner spnNumPlayers;
private javax.swing.JSpinner spnNumWins; private javax.swing.JSpinner spnNumWins;
private javax.swing.JTextField txtName; private javax.swing.JTextField txtName;

View file

@ -87,6 +87,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
public static final String KEY_NEW_TABLE_DECK_TYPE = "newTableDeckType"; public static final String KEY_NEW_TABLE_DECK_TYPE = "newTableDeckType";
public static final String KEY_NEW_TABLE_GAME_TYPE = "newTableGameType"; public static final String KEY_NEW_TABLE_GAME_TYPE = "newTableGameType";
public static final String KEY_NEW_TABLE_NUMBER_OF_WINS = "newTableNumberOfWins"; public static final String KEY_NEW_TABLE_NUMBER_OF_WINS = "newTableNumberOfWins";
public static final String KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS = "newTableNumberOfFreeMulligans";
public static final String KEY_NEW_TABLE_DECK_FILE = "newTableDeckFile"; public static final String KEY_NEW_TABLE_DECK_FILE = "newTableDeckFile";
public static final String KEY_NEW_TABLE_RANGE = "newTableRange"; public static final String KEY_NEW_TABLE_RANGE = "newTableRange";
public static final String KEY_NEW_TABLE_ATTACK_OPTION = "newTableAttackOption"; public static final String KEY_NEW_TABLE_ATTACK_OPTION = "newTableAttackOption";

View file

@ -606,9 +606,9 @@ private void chkShowCompletedActionPerformed(java.awt.event.ActionEvent evt) {//
class TableTableModel extends AbstractTableModel { class TableTableModel extends AbstractTableModel {
public static int ACTION_COLUMN = 8; // column the action is located (starting with 0) public static int ACTION_COLUMN = 9; // column the action is located (starting with 0)
private String[] columnNames = new String[]{"Match Name", "Owner / Players", "Game Type", "Wins", "Deck Type", "Info", "Status", "Created", "Action"}; private String[] columnNames = new String[]{"Match Name", "Owner / Players", "Game Type", "Wins", "Free Mulligans", "Deck Type", "Info", "Status", "Created", "Action"};
private TableView[] tables = new TableView[0]; private TableView[] tables = new TableView[0];
private static final DateFormat timeFormatter = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT); private static final DateFormat timeFormatter = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
@ -645,14 +645,16 @@ class TableTableModel extends AbstractTableModel {
case 3: case 3:
return Integer.toString(tables[arg0].getWins()); return Integer.toString(tables[arg0].getWins());
case 4: case 4:
return tables[arg0].getDeckType(); return Integer.toString(tables[arg0].getFreeMulligans());
case 5: case 5:
return tables[arg0].getAdditionalInfo(); return tables[arg0].getDeckType();
case 6: case 6:
return tables[arg0].getTableState().toString(); return tables[arg0].getAdditionalInfo();
case 7: case 7:
return timeFormatter.format(tables[arg0].getCreateTime()); return tables[arg0].getTableState().toString();
case 8: case 8:
return timeFormatter.format(tables[arg0].getCreateTime());
case 9:
switch (tables[arg0].getTableState()) { switch (tables[arg0].getTableState()) {
case WAITING: case WAITING:
String owner = tables[arg0].getControllerName(); String owner = tables[arg0].getControllerName();
@ -680,14 +682,14 @@ class TableTableModel extends AbstractTableModel {
default: default:
return ""; return "";
} }
case 9:
return tables[arg0].isTournament();
case 10: case 10:
return tables[arg0].isTournament();
case 11:
if (!tables[arg0].getGames().isEmpty()) { if (!tables[arg0].getGames().isEmpty()) {
return tables[arg0].getGames().get(0); return tables[arg0].getGames().get(0);
} }
return null; return null;
case 11: case 12:
return tables[arg0].getTableId(); return tables[arg0].getTableId();
} }
return ""; return "";

View file

@ -50,6 +50,7 @@ public class TableView implements Serializable {
private UUID tableId; private UUID tableId;
private String gameType; private String gameType;
private int wins; private int wins;
private int freeMulligans;
private String deckType; private String deckType;
private String tableName; private String tableName;
private String controllerName; private String controllerName;
@ -73,11 +74,12 @@ public class TableView implements Serializable {
} }
if (!table.isTournament()) { if (!table.isTournament()) {
this.wins = table.getMatch().getWinsNeeded(); this.wins = table.getMatch().getWinsNeeded();
this.freeMulligans = table.getMatch().getFreeMulligans();
for (Game game: table.getMatch().getGames()) { for (Game game: table.getMatch().getGames()) {
games.add(game.getId()); games.add(game.getId());
} }
StringBuilder sb = new StringBuilder(); StringBuilder sb = new StringBuilder();
StringBuilder sbScore = new StringBuilder("Score: "); StringBuilder sbScore = new StringBuilder();
for(MatchPlayer matchPlayer: table.getMatch().getPlayers()) { for(MatchPlayer matchPlayer: table.getMatch().getPlayers()) {
if (!matchPlayer.getPlayer().getName().equals(table.getControllerName())) { if (!matchPlayer.getPlayer().getName().equals(table.getControllerName())) {
sb.append(", ").append(matchPlayer.getPlayer().getName()); sb.append(", ").append(matchPlayer.getPlayer().getName());
@ -96,6 +98,7 @@ public class TableView implements Serializable {
} else { } else {
this.wins = table.getTournament().getOptions().getMatchOptions().getWinsNeeded(); this.wins = table.getTournament().getOptions().getMatchOptions().getWinsNeeded();
this.freeMulligans = table.getTournament().getOptions().getMatchOptions().getFreeMulligans();
StringBuilder sb1 = new StringBuilder(); StringBuilder sb1 = new StringBuilder();
for (TournamentPlayer tp: table.getTournament().getPlayers()) { for (TournamentPlayer tp: table.getTournament().getPlayers()) {
if (!tp.getPlayer().getName().equals(table.getControllerName())) { if (!tp.getPlayer().getName().equals(table.getControllerName())) {
@ -104,8 +107,15 @@ 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("Seats: ").append(table.getTournament().getPlayers().size()).append("/").append(table.getNumberOfSeats());
if (table.getState().equals(TableState.DUELING)) { switch (table.getState()) {
sb.append(" - Running round: ").append(table.getTournament().getRounds().size()); case WAITING:
case STARTING:
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());
break;
default:
} }
this.additionalInfo = sb.toString(); this.additionalInfo = sb.toString();
this.deckType = new StringBuilder(table.getDeckType()).append(" ").append(table.getTournament().getSetsFormatedShort()).toString(); this.deckType = new StringBuilder(table.getDeckType()).append(" ").append(table.getTournament().getSetsFormatedShort()).toString();
@ -132,6 +142,10 @@ public class TableView implements Serializable {
return wins; return wins;
} }
public int getFreeMulligans() {
return freeMulligans;
}
public String getDeckType() { public String getDeckType() {
return deckType; return deckType;
} }

View file

@ -39,8 +39,8 @@ import mage.game.turn.TurnMod;
public class CommanderDuel extends GameImpl<CommanderDuel> { public class CommanderDuel extends GameImpl<CommanderDuel> {
public CommanderDuel(MultiplayerAttackOption attackOption, RangeOfInfluence range) { public CommanderDuel(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans) {
super(attackOption, range); super(attackOption, range, freeMulligans);
} }
public CommanderDuel(final CommanderDuel game) { public CommanderDuel(final CommanderDuel game) {

View file

@ -43,7 +43,7 @@ public class CommanderDuelMatch extends MatchImpl {
@Override @Override
public void startGame() throws GameException { public void startGame() throws GameException {
CommanderDuel game = new CommanderDuel(options.getAttackOption(), options.getRange()); CommanderDuel game = new CommanderDuel(options.getAttackOption(), options.getRange(), options.getFreeMulligans());
game.setStartMessage(this.createGameStartMessage()); game.setStartMessage(this.createGameStartMessage());
initGame(game); initGame(game);
games.add(game); games.add(game);

View file

@ -28,15 +28,12 @@
package mage.game; package mage.game;
import java.util.ArrayList;
import java.util.HashSet; import java.util.HashSet;
import java.util.List;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.Constants.MultiplayerAttackOption; import mage.Constants.MultiplayerAttackOption;
import mage.Constants.RangeOfInfluence; import mage.Constants.RangeOfInfluence;
import mage.game.match.MatchType; import mage.game.match.MatchType;
import mage.players.Player;
/** /**
* *
@ -45,18 +42,14 @@ import mage.players.Player;
public class FreeForAll extends GameImpl<FreeForAll> { public class FreeForAll extends GameImpl<FreeForAll> {
private int numPlayers; private int numPlayers;
private List<UUID> mulliganed = new ArrayList<UUID>();
public FreeForAll(MultiplayerAttackOption attackOption, RangeOfInfluence range) { public FreeForAll(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans) {
super(attackOption, range); super(attackOption, range, freeMulligans);
} }
public FreeForAll(final FreeForAll game) { public FreeForAll(final FreeForAll game) {
super(game); super(game);
this.numPlayers = game.numPlayers; this.numPlayers = game.numPlayers;
for (UUID playerId: game.mulliganed) {
mulliganed.add(playerId);
}
} }
@Override @Override
@ -89,32 +82,6 @@ public class FreeForAll extends GameImpl<FreeForAll> {
return opponents; return opponents;
} }
@Override
public int mulliganDownTo(UUID playerId) {
Player player = getPlayer(playerId);
int numCards = player.getHand().size();
if (!mulliganed.contains(playerId)) {
numCards += 1;
}
return numCards -1;
}
@Override
public void mulligan(UUID playerId) {
Player player = getPlayer(playerId);
int numCards = player.getHand().size();
//record first mulligan and increment card count
if (!mulliganed.contains(playerId)) {
numCards += 1;
mulliganed.add(playerId);
}
player.getLibrary().addAll(player.getHand().getCards(this), this);
player.getHand().clear();
player.shuffleLibrary(this);
fireInformEvent(player.getName() + " mulligans down to " + Integer.toString(numCards - 1) + " cards");
player.drawCards(numCards - 1, this);
}
@Override @Override
public FreeForAll copy() { public FreeForAll copy() {
return new FreeForAll(this); return new FreeForAll(this);

View file

@ -43,7 +43,7 @@ public class FreeForAllMatch extends MatchImpl {
@Override @Override
public void startGame() throws GameException { public void startGame() throws GameException {
FreeForAll game = new FreeForAll(options.getAttackOption(), options.getRange()); FreeForAll game = new FreeForAll(options.getAttackOption(), options.getRange(), options.getFreeMulligans());
game.setStartMessage(this.createGameStartMessage()); game.setStartMessage(this.createGameStartMessage());
initGame(game); initGame(game);
games.add(game); games.add(game);

View file

@ -28,19 +28,19 @@
package mage.game; package mage.game;
import mage.game.match.MatchType;
import java.util.HashSet; import java.util.HashSet;
import java.util.Set; import java.util.Set;
import java.util.UUID; import java.util.UUID;
import mage.Constants.MultiplayerAttackOption; import mage.Constants.MultiplayerAttackOption;
import mage.Constants.PhaseStep; import mage.Constants.PhaseStep;
import mage.Constants.RangeOfInfluence; import mage.Constants.RangeOfInfluence;
import mage.game.match.MatchType;
import mage.game.turn.TurnMod; import mage.game.turn.TurnMod;
public class TwoPlayerDuel extends GameImpl<TwoPlayerDuel> { public class TwoPlayerDuel extends GameImpl<TwoPlayerDuel> {
public TwoPlayerDuel(MultiplayerAttackOption attackOption, RangeOfInfluence range) { public TwoPlayerDuel(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans) {
super(attackOption, range); super(attackOption, range, freeMulligans);
} }
public TwoPlayerDuel(final TwoPlayerDuel game) { public TwoPlayerDuel(final TwoPlayerDuel game) {
@ -78,8 +78,9 @@ public class TwoPlayerDuel extends GameImpl<TwoPlayerDuel> {
public Set<UUID> getOpponents(UUID playerId) { public Set<UUID> getOpponents(UUID playerId) {
Set<UUID> opponents = new HashSet<UUID>(); Set<UUID> opponents = new HashSet<UUID>();
for (UUID opponentId: this.getPlayer(playerId).getInRange()) { for (UUID opponentId: this.getPlayer(playerId).getInRange()) {
if (!opponentId.equals(playerId)) if (!opponentId.equals(playerId)) {
opponents.add(opponentId); opponents.add(opponentId);
}
} }
return opponents; return opponents;
} }

View file

@ -43,7 +43,7 @@ public class TwoPlayerMatch extends MatchImpl {
@Override @Override
public void startGame() throws GameException { public void startGame() throws GameException {
TwoPlayerDuel game = new TwoPlayerDuel(options.getAttackOption(), options.getRange()); TwoPlayerDuel game = new TwoPlayerDuel(options.getAttackOption(), options.getRange(), options.getFreeMulligans());
// Sets a start message about the match score // Sets a start message about the match score
game.setStartMessage(this.createGameStartMessage()); game.setStartMessage(this.createGameStartMessage());
initGame(game); initGame(game);

View file

@ -142,8 +142,8 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
updateGameStatePriority("chooseMulligan", game); updateGameStatePriority("chooseMulligan", game);
int nextHandSize = game.mulliganDownTo(playerId); int nextHandSize = game.mulliganDownTo(playerId);
game.fireAskPlayerEvent(playerId, new StringBuilder("Mulligan ") game.fireAskPlayerEvent(playerId, new StringBuilder("Mulligan ")
.append(getHand().size() > nextHandSize?"down":"") .append(getHand().size() > nextHandSize?"down to ":"for free, draw ")
.append(" to ").append(nextHandSize) .append(nextHandSize)
.append(nextHandSize == 1?" card?":" cards?").toString()); .append(nextHandSize == 1?" card?":" cards?").toString());
waitForBooleanResponse(); waitForBooleanResponse();
if (!abort) { if (!abort) {

View file

@ -50,6 +50,7 @@ public class BoosterDraftEliminationTournament extends TournamentSingleEliminati
public BoosterDraftEliminationTournament(TournamentOptions options) { public BoosterDraftEliminationTournament(TournamentOptions options) {
super(options); super(options);
this.getOptions().getLimitedOptions().setConstructionTime(600);
currentStep = TournamentStep.START; currentStep = TournamentStep.START;
} }

View file

@ -45,6 +45,7 @@ public class SealedEliminationTournament extends TournamentSingleElimination {
public SealedEliminationTournament(TournamentOptions options) { public SealedEliminationTournament(TournamentOptions options) {
super(options); super(options);
this.getOptions().getLimitedOptions().setConstructionTime(1200);
currentStep = TournamentStep.START; currentStep = TournamentStep.START;
} }

View file

@ -31,7 +31,7 @@ public class PlayGameTest extends MageTestBase {
@Ignore @Ignore
@Test @Test
public void playOneGame() throws GameException, FileNotFoundException, IllegalArgumentException { public void playOneGame() throws GameException, FileNotFoundException, IllegalArgumentException {
Game game = new TwoPlayerDuel(Constants.MultiplayerAttackOption.LEFT, Constants.RangeOfInfluence.ALL); Game game = new TwoPlayerDuel(Constants.MultiplayerAttackOption.LEFT, Constants.RangeOfInfluence.ALL, 0);
Player computerA = createPlayer("ComputerA", "Computer - minimax hybrid"); Player computerA = createPlayer("ComputerA", "Computer - minimax hybrid");
// Player playerA = createPlayer("ComputerA", "Computer - mad"); // Player playerA = createPlayer("ComputerA", "Computer - mad");

View file

@ -38,7 +38,7 @@ public class TestPlayRandomGame extends MageTestBase {
} }
private void playOneGame() throws GameException, FileNotFoundException, IllegalArgumentException { private void playOneGame() throws GameException, FileNotFoundException, IllegalArgumentException {
Game game = new TwoPlayerDuel(Constants.MultiplayerAttackOption.LEFT, Constants.RangeOfInfluence.ALL); Game game = new TwoPlayerDuel(Constants.MultiplayerAttackOption.LEFT, Constants.RangeOfInfluence.ALL, 0);
Player computerA = createRandomPlayer("ComputerA"); Player computerA = createRandomPlayer("ComputerA");
Deck deck = generateRandomDeck(); Deck deck = generateRandomDeck();

View file

@ -44,7 +44,7 @@ public abstract class CardTestMultiPlayerBase extends CardTestPlayerAPIImpl {
System.gc(); System.gc();
} }
Game game = new FreeForAll(Constants.MultiplayerAttackOption.LEFT, Constants.RangeOfInfluence.ONE); Game game = new FreeForAll(Constants.MultiplayerAttackOption.LEFT, Constants.RangeOfInfluence.ONE, 0);
playerA = createPlayer(game, playerA, "PlayerA"); playerA = createPlayer(game, playerA, "PlayerA");
playerB = createPlayer(game, playerB, "PlayerB"); playerB = createPlayer(game, playerB, "PlayerB");
@ -85,7 +85,7 @@ public abstract class CardTestMultiPlayerBase extends CardTestPlayerAPIImpl {
System.gc(); System.gc();
} }
Game game = new TwoPlayerDuel(Constants.MultiplayerAttackOption.LEFT, Constants.RangeOfInfluence.ALL); Game game = new TwoPlayerDuel(Constants.MultiplayerAttackOption.LEFT, Constants.RangeOfInfluence.ALL, 0);
playerA = createNewPlayer("ComputerA"); playerA = createNewPlayer("ComputerA");
playerA.setTestMode(true); playerA.setTestMode(true);

View file

@ -53,7 +53,7 @@ public abstract class CardTestPlayerBase extends CardTestPlayerAPIImpl {
System.gc(); System.gc();
} }
Game game = new TwoPlayerDuel(Constants.MultiplayerAttackOption.LEFT, Constants.RangeOfInfluence.ONE); Game game = new TwoPlayerDuel(Constants.MultiplayerAttackOption.LEFT, Constants.RangeOfInfluence.ONE, 0);
playerA = createNewPlayer("PlayerA"); playerA = createNewPlayer("PlayerA");
playerA.setTestMode(true); playerA.setTestMode(true);
@ -108,7 +108,7 @@ public abstract class CardTestPlayerBase extends CardTestPlayerAPIImpl {
System.gc(); System.gc();
} }
Game game = new TwoPlayerDuel(Constants.MultiplayerAttackOption.LEFT, Constants.RangeOfInfluence.ALL); Game game = new TwoPlayerDuel(Constants.MultiplayerAttackOption.LEFT, Constants.RangeOfInfluence.ALL, 0);
playerA = createNewPlayer("ComputerA"); playerA = createNewPlayer("ComputerA");
playerA.setTestMode(true); playerA.setTestMode(true);

View file

@ -137,6 +137,8 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
protected transient GameStates gameStates = new GameStates(); protected transient GameStates gameStates = new GameStates();
protected RangeOfInfluence range; protected RangeOfInfluence range;
protected int freeMulligans;
protected Map<UUID, Integer> usedFreeMulligans = new LinkedHashMap<UUID, Integer>();
protected MultiplayerAttackOption attackOption; protected MultiplayerAttackOption attackOption;
protected GameOptions gameOptions; protected GameOptions gameOptions;
protected String startMessage; protected String startMessage;
@ -156,9 +158,10 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
@Override @Override
public abstract T copy(); public abstract T copy();
public GameImpl(MultiplayerAttackOption attackOption, RangeOfInfluence range) { public GameImpl(MultiplayerAttackOption attackOption, RangeOfInfluence range, int freeMulligans) {
this.id = UUID.randomUUID(); this.id = UUID.randomUUID();
this.range = range; this.range = range;
this.freeMulligans = freeMulligans;
this.attackOption = attackOption; this.attackOption = attackOption;
this.state = new GameState(); this.state = new GameState();
this.actions = new LinkedList<MageAction>(); this.actions = new LinkedList<MageAction>();
@ -174,6 +177,7 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
this.startingPlayerId = game.startingPlayerId; this.startingPlayerId = game.startingPlayerId;
this.winnerId = game.winnerId; this.winnerId = game.winnerId;
this.range = game.range; this.range = game.range;
this.freeMulligans = game.freeMulligans;
this.attackOption = game.attackOption; this.attackOption = game.attackOption;
this.state = game.state.copy(); this.state = game.state.copy();
// Issue 350 // Issue 350
@ -740,7 +744,18 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
@Override @Override
public int mulliganDownTo(UUID playerId) { public int mulliganDownTo(UUID playerId) {
Player player = getPlayer(playerId); Player player = getPlayer(playerId);
return player.getHand().size() -1; int deduction = 1;
if (freeMulligans > 0) {
if (usedFreeMulligans != null && usedFreeMulligans.containsKey(player.getId())) {
int used = usedFreeMulligans.get(player.getId()).intValue();
if (used < freeMulligans ) {
deduction = 0;
}
} else {
deduction = 0;
}
}
return player.getHand().size() - deduction;
} }
@ -751,8 +766,25 @@ public abstract class GameImpl<T extends GameImpl<T>> implements Game, Serializa
player.getLibrary().addAll(player.getHand().getCards(this), this); player.getLibrary().addAll(player.getHand().getCards(this), this);
player.getHand().clear(); player.getHand().clear();
player.shuffleLibrary(this); player.shuffleLibrary(this);
fireInformEvent(player.getName() + " mulligans down to " + Integer.toString(numCards - 1) + " cards"); int deduction = 1;
player.drawCards(numCards - 1, this); if (freeMulligans > 0) {
if (usedFreeMulligans != null && usedFreeMulligans.containsKey(player.getId())) {
int used = usedFreeMulligans.get(player.getId()).intValue();
if (used < freeMulligans ) {
deduction = 0;
usedFreeMulligans.put(player.getId(), new Integer(used+1));
}
} else {
deduction = 0;
usedFreeMulligans.put(player.getId(), new Integer(1));
}
}
fireInformEvent(new StringBuilder(player.getName())
.append(" mulligans")
.append(deduction == 0 ? " for free and draws ":" down to ")
.append(Integer.toString(numCards - deduction))
.append(numCards - deduction == 1? " card":" cards").toString());
player.drawCards(numCards - deduction, this);
} }
@Override @Override

View file

@ -64,6 +64,7 @@ public interface Match {
Game getGame(); Game getGame();
List<Game> getGames(); List<Game> getGames();
int getWinsNeeded(); int getWinsNeeded();
int getFreeMulligans();
int getNumGames(); int getNumGames();
boolean isDoneSideboarding(); boolean isDoneSideboarding();
UUID getChooser(); UUID getChooser();

View file

@ -149,6 +149,11 @@ public abstract class MatchImpl implements Match {
return options.getWinsNeeded(); return options.getWinsNeeded();
} }
@Override
public int getFreeMulligans() {
return options.getFreeMulligans();
}
protected void initGame(Game game) throws GameException { protected void initGame(Game game) throws GameException {
shufflePlayers(); shufflePlayers();
for (MatchPlayer matchPlayer: this.players) { for (MatchPlayer matchPlayer: this.players) {

View file

@ -44,6 +44,7 @@ public class MatchOptions implements Serializable {
protected MultiplayerAttackOption attackOption; protected MultiplayerAttackOption attackOption;
protected RangeOfInfluence range; protected RangeOfInfluence range;
protected int winsNeeded; protected int winsNeeded;
protected int freeMulligans;
protected String gameType; protected String gameType;
protected String deckType; protected String deckType;
protected boolean limited; protected boolean limited;
@ -82,6 +83,13 @@ public class MatchOptions implements Serializable {
this.winsNeeded = winsNeeded; this.winsNeeded = winsNeeded;
} }
public int getFreeMulligans() {
return freeMulligans;
}
public void setFreeMulligans(int freeMulligans) {
this.freeMulligans = freeMulligans;
}
public String getGameType() { public String getGameType() {
return gameType; return gameType;
} }

View file

@ -39,9 +39,18 @@ import java.util.List;
public class LimitedOptions implements Serializable { public class LimitedOptions implements Serializable {
protected List<String> sets = new ArrayList<String>(); protected List<String> sets = new ArrayList<String>();
protected int constructionTime;
public List<String> getSetCodes() { public List<String> getSetCodes() {
return sets; return sets;
} }
public int getConstructionTime() {
return constructionTime;
}
public void setConstructionTime(int constructionTime) {
this.constructionTime = constructionTime;
}
} }

View file

@ -28,6 +28,8 @@
package mage.game.tournament; package mage.game.tournament;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.ExpansionSet; import mage.cards.ExpansionSet;
import mage.cards.decks.Deck; import mage.cards.decks.Deck;
@ -37,8 +39,6 @@ import mage.game.match.Match;
import mage.players.Player; import mage.players.Player;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
import java.util.*;
import java.util.concurrent.CopyOnWriteArrayList;
/** /**
* *
@ -61,8 +61,6 @@ public abstract class TournamentImpl implements Tournament {
protected Date startTime; protected Date startTime;
protected Date endTime; protected Date endTime;
private static final int CONSTRUCT_TIME = 600;
public TournamentImpl(TournamentOptions options) { public TournamentImpl(TournamentOptions options) {
this.options = options; this.options = options;
startTime = new Date(); startTime = new Date();
@ -227,8 +225,9 @@ public abstract class TournamentImpl implements Tournament {
@Override @Override
public boolean isDoneConstructing() { public boolean isDoneConstructing() {
for (TournamentPlayer player: this.players.values()) { for (TournamentPlayer player: this.players.values()) {
if (!player.isDoneConstructing()) if (!player.isDoneConstructing()) {
return false; return false;
}
} }
return true; return true;
} }
@ -236,8 +235,9 @@ public abstract class TournamentImpl implements Tournament {
@Override @Override
public boolean allJoined() { public boolean allJoined() {
for (TournamentPlayer player: this.players.values()) { for (TournamentPlayer player: this.players.values()) {
if (!player.isJoined()) if (!player.isJoined()) {
return false; return false;
}
} }
return true; return true;
} }
@ -254,8 +254,7 @@ public abstract class TournamentImpl implements Tournament {
@Override @Override
public void fireConstructEvent(UUID playerId) { public void fireConstructEvent(UUID playerId) {
TournamentPlayer player = players.get(playerId); playerQueryEventSource.construct(playerId, "Construct", getOptions().getLimitedOptions().getConstructionTime());
playerQueryEventSource.construct(playerId, "Construct", CONSTRUCT_TIME);
} }
public void construct() { public void construct() {

View file

@ -39,6 +39,7 @@ 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<String>(); protected List<String> playerTypes = new ArrayList<String>();