added Sealed tournaments

This commit is contained in:
BetaSteward 2011-02-10 22:00:47 -05:00
parent 44aefaf47a
commit f7ffbb4773
51 changed files with 652 additions and 143 deletions

View file

@ -627,7 +627,7 @@ public class MageFrame extends javax.swing.JFrame {
}// </editor-fold>//GEN-END:initComponents }// </editor-fold>//GEN-END:initComponents
private void btnDeckEditorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeckEditorActionPerformed private void btnDeckEditorActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnDeckEditorActionPerformed
showDeckEditor(DeckEditorMode.Constructed, null, null); showDeckEditor(DeckEditorMode.Constructed, null, null, 0);
}//GEN-LAST:event_btnDeckEditorActionPerformed }//GEN-LAST:event_btnDeckEditorActionPerformed
private void btnCollectionViewerActionPerformed(java.awt.event.ActionEvent evt) { private void btnCollectionViewerActionPerformed(java.awt.event.ActionEvent evt) {
@ -685,10 +685,10 @@ public class MageFrame extends javax.swing.JFrame {
btnDeckEditor.setEnabled(true); btnDeckEditor.setEnabled(true);
} }
public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId) { public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId, int time) {
this.deckEditorPane.setVisible(true); this.deckEditorPane.setVisible(true);
this.deckEditorPane.toFront(); this.deckEditorPane.toFront();
this.deckEditorPane.show(mode, deck, tableId); this.deckEditorPane.show(mode, deck, tableId, time);
} }
public void showCollectionViewer() { public void showCollectionViewer() {

View file

@ -73,12 +73,12 @@ public class DeckEditorPane extends MagePane {
} }
} }
public void show(DeckEditorMode mode, Deck deck, UUID tableId) { public void show(DeckEditorMode mode, Deck deck, UUID tableId, int time) {
if (deck != null) if (deck != null)
this.setTitle("Deck Editor - " + deck.getName()); this.setTitle("Deck Editor - " + deck.getName());
else else
this.setTitle("Deck Editor"); this.setTitle("Deck Editor");
this.deckEditorPanel1.showDeckEditor(mode, deck, tableId); this.deckEditorPanel1.showDeckEditor(mode, deck, tableId, time);
this.repaint(); this.repaint();
} }

View file

@ -47,14 +47,14 @@ import mage.view.CardView;
import javax.swing.*; import javax.swing.*;
import javax.swing.filechooser.FileFilter; import javax.swing.filechooser.FileFilter;
import java.awt.*; import java.awt.*;
import java.awt.event.ActionEvent;
import java.awt.event.ActionListener;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.lang.reflect.Constructor;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.UUID; import java.util.UUID;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import mage.client.MagePane;
import mage.client.cards.BigCard; import mage.client.cards.BigCard;
import mage.client.constants.Constants.DeckEditorMode; import mage.client.constants.Constants.DeckEditorMode;
import mage.client.dialog.AddLandDialog; import mage.client.dialog.AddLandDialog;
@ -72,6 +72,8 @@ public class DeckEditorPanel extends javax.swing.JPanel {
private boolean isShowCardInfo = false; private boolean isShowCardInfo = false;
private UUID tableId; private UUID tableId;
private DeckEditorMode mode; private DeckEditorMode mode;
private int timeout;
private Timer countdown;
/** Creates new form DeckEditorPanel */ /** Creates new form DeckEditorPanel */
@ -87,9 +89,23 @@ public class DeckEditorPanel extends javax.swing.JPanel {
deckArea.setOpaque(false); deckArea.setOpaque(false);
jPanel1.setOpaque(false); jPanel1.setOpaque(false);
jSplitPane1.setOpaque(false); jSplitPane1.setOpaque(false);
} countdown = new Timer(1000,
new ActionListener() {
@Override
public void actionPerformed(ActionEvent e) {
if (--timeout > 0) {
setTimeout(Integer.toString(timeout));
}
else {
setTimeout("0");
countdown.stop();
}
}
}
);
}
public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId) { public void showDeckEditor(DeckEditorMode mode, Deck deck, UUID tableId, int time) {
if (deck != null) if (deck != null)
this.deck = deck; this.deck = deck;
this.tableId = tableId; this.tableId = tableId;
@ -98,6 +114,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
switch (mode) { switch (mode) {
case Limited: case Limited:
this.btnAddLand.setVisible(true); this.btnAddLand.setVisible(true);
this.txtTimeRemaining.setVisible(true);
case Sideboard: case Sideboard:
this.btnSubmit.setVisible(true); this.btnSubmit.setVisible(true);
this.cardSelector.loadCards(new ArrayList<Card>(deck.getSideboard()), this.bigCard, mode == DeckEditorMode.Limited); this.cardSelector.loadCards(new ArrayList<Card>(deck.getSideboard()), this.bigCard, mode == DeckEditorMode.Limited);
@ -105,6 +122,12 @@ public class DeckEditorPanel extends javax.swing.JPanel {
this.btnImport.setVisible(false); this.btnImport.setVisible(false);
this.btnLoad.setVisible(false); this.btnLoad.setVisible(false);
this.deckArea.showSideboard(false); this.deckArea.showSideboard(false);
countdown.stop();
this.timeout = time;
setTimeout(Integer.toString(timeout));
if (timeout != 0) {
countdown.start();
}
break; break;
case Constructed: case Constructed:
this.btnSubmit.setVisible(false); this.btnSubmit.setVisible(false);
@ -113,6 +136,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
this.btnImport.setVisible(true); this.btnImport.setVisible(true);
this.btnLoad.setVisible(true); this.btnLoad.setVisible(true);
this.deckArea.showSideboard(true); this.deckArea.showSideboard(true);
this.txtTimeRemaining.setVisible(false);
break; break;
} }
init(); init();
@ -184,7 +208,11 @@ public class DeckEditorPanel extends javax.swing.JPanel {
} }
} }
private void initComponents() { private void setTimeout(String text) {
this.txtTimeRemaining.setText(text);
}
private void initComponents() {
jSplitPane1 = new javax.swing.JSplitPane(); jSplitPane1 = new javax.swing.JSplitPane();
cardSelector = new mage.client.deckeditor.CardSelector(); cardSelector = new mage.client.deckeditor.CardSelector();
@ -200,6 +228,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
btnImport = new javax.swing.JButton(); btnImport = new javax.swing.JButton();
btnSubmit = new javax.swing.JButton(); btnSubmit = new javax.swing.JButton();
btnAddLand = new javax.swing.JButton(); btnAddLand = new javax.swing.JButton();
txtTimeRemaining = new javax.swing.JTextField();
jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT); jSplitPane1.setOrientation(javax.swing.JSplitPane.VERTICAL_SPLIT);
jSplitPane1.setResizeWeight(0.5); jSplitPane1.setResizeWeight(0.5);
@ -273,6 +302,11 @@ public class DeckEditorPanel extends javax.swing.JPanel {
} }
}); });
txtTimeRemaining.setEditable(false);
txtTimeRemaining.setForeground(java.awt.Color.red);
txtTimeRemaining.setHorizontalAlignment(javax.swing.JTextField.CENTER);
txtTimeRemaining.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1); javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout); jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup( jPanel1Layout.setHorizontalGroup(
@ -301,7 +335,11 @@ public class DeckEditorPanel extends javax.swing.JPanel {
.addContainerGap() .addContainerGap()
.addComponent(btnAddLand) .addComponent(btnAddLand)
.addContainerGap() .addContainerGap()
.addComponent(btnSubmit))) .addComponent(btnSubmit))
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(txtTimeRemaining))
)
.addContainerGap()) .addContainerGap())
); );
jPanel1Layout.setVerticalGroup( jPanel1Layout.setVerticalGroup(
@ -322,6 +360,9 @@ public class DeckEditorPanel extends javax.swing.JPanel {
.addComponent(btnImport) .addComponent(btnImport)
.addComponent(btnAddLand) .addComponent(btnAddLand)
.addComponent(btnSubmit)) .addComponent(btnSubmit))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtTimeRemaining))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, isShowCardInfo ? 30 : 159, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, isShowCardInfo ? 30 : 159, Short.MAX_VALUE)
.addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cardInfoPane, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
@ -488,6 +529,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
private JComponent cardInfoPane; private JComponent cardInfoPane;
private javax.swing.JButton btnSubmit; private javax.swing.JButton btnSubmit;
private javax.swing.JButton btnAddLand; private javax.swing.JButton btnAddLand;
private javax.swing.JTextField txtTimeRemaining;
} }
class DeckFilter extends FileFilter { class DeckFilter extends FileFilter {

View file

@ -1,6 +1,6 @@
<?xml version="1.1" encoding="UTF-8" ?> <?xml version="1.1" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo"> <Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<NonVisualComponents> <NonVisualComponents>
<Component class="javax.swing.JButton" name="jButton2"> <Component class="javax.swing.JButton" name="jButton2">
<Properties> <Properties>
@ -97,7 +97,7 @@
<Component id="lblSwamp" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblSwamp" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="spnSwamp" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="spnSwamp" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace pref="16" max="32767" attributes="0"/> <EmptySpace pref="20" max="32767" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="btnAdd" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnAdd" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="btnCancel" alignment="3" min="-2" max="-2" attributes="0"/>
@ -114,8 +114,18 @@
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JSpinner" name="spnForest"> <Component class="javax.swing.JSpinner" name="spnForest">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component> </Component>
<Component class="javax.swing.JSpinner" name="spnIsland"> <Component class="javax.swing.JSpinner" name="spnIsland">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblIsland"> <Component class="javax.swing.JLabel" name="lblIsland">
<Properties> <Properties>
@ -128,8 +138,18 @@
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JSpinner" name="spnPlains"> <Component class="javax.swing.JSpinner" name="spnPlains">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component> </Component>
<Component class="javax.swing.JSpinner" name="spnMountain"> <Component class="javax.swing.JSpinner" name="spnMountain">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblMountain"> <Component class="javax.swing.JLabel" name="lblMountain">
<Properties> <Properties>
@ -137,6 +157,11 @@
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JSpinner" name="spnSwamp"> <Component class="javax.swing.JSpinner" name="spnSwamp">
<Properties>
<Property name="model" type="javax.swing.SpinnerModel" editor="org.netbeans.modules.form.editors2.SpinnerModelEditor">
<SpinnerModel initial="0" minimum="0" numberType="java.lang.Integer" stepSize="1" type="number"/>
</Property>
</Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblSwamp"> <Component class="javax.swing.JLabel" name="lblSwamp">
<Properties> <Properties>

View file

@ -88,12 +88,22 @@ public class AddLandDialog extends MageDialog {
lblForest.setText("Forest"); lblForest.setText("Forest");
spnForest.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
spnIsland.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
lblIsland.setText("Island"); lblIsland.setText("Island");
lblPains.setText("Plains"); lblPains.setText("Plains");
spnPlains.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
spnMountain.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
lblMountain.setText("Mountain"); lblMountain.setText("Mountain");
spnSwamp.setModel(new javax.swing.SpinnerNumberModel(Integer.valueOf(0), Integer.valueOf(0), null, Integer.valueOf(1)));
lblSwamp.setText("Swamp"); lblSwamp.setText("Swamp");
btnAdd.setText("Add"); btnAdd.setText("Add");
@ -168,7 +178,7 @@ public class AddLandDialog extends MageDialog {
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblSwamp) .addComponent(lblSwamp)
.addComponent(spnSwamp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(spnSwamp, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 16, Short.MAX_VALUE) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 20, Short.MAX_VALUE)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnAdd) .addComponent(btnAdd)
.addComponent(btnCancel)) .addComponent(btnCancel))

View file

@ -49,6 +49,8 @@ import mage.client.MageFrame;
import mage.client.remote.Session; import mage.client.remote.Session;
import mage.client.table.TournamentPlayerPanel; import mage.client.table.TournamentPlayerPanel;
import mage.game.draft.DraftOptions; import mage.game.draft.DraftOptions;
import mage.game.draft.DraftOptions.TimingOption;
import mage.game.tournament.LimitedOptions;
import mage.game.tournament.TournamentOptions; import mage.game.tournament.TournamentOptions;
import mage.sets.Sets; import mage.sets.Sets;
import mage.util.Logging; import mage.util.Logging;
@ -80,6 +82,7 @@ public class NewTournamentDialog extends MageDialog {
session = MageFrame.getSession(); session = MageFrame.getSession();
this.txtPlayer1Name.setText(session.getUserName()); this.txtPlayer1Name.setText(session.getUserName());
cbTournamentType.setModel(new DefaultComboBoxModel(session.getTournamentTypes().toArray())); cbTournamentType.setModel(new DefaultComboBoxModel(session.getTournamentTypes().toArray()));
cbDraftTiming.setModel(new DefaultComboBoxModel(DraftOptions.TimingOption.values()));
this.setModal(true); this.setModal(true);
setTournamentOptions(); setTournamentOptions();
this.setLocation(150, 100); this.setLocation(150, 100);
@ -108,6 +111,9 @@ public class NewTournamentDialog extends MageDialog {
txtPlayer1Name = new javax.swing.JTextField(); txtPlayer1Name = new javax.swing.JTextField();
pnlOtherPlayers = new javax.swing.JPanel(); pnlOtherPlayers = new javax.swing.JPanel();
jLabel5 = new javax.swing.JLabel(); jLabel5 = new javax.swing.JLabel();
pnlDraftOptions = new javax.swing.JPanel();
cbDraftTiming = new javax.swing.JComboBox();
jLabel6 = new javax.swing.JLabel();
setTitle("New Tournament"); setTitle("New Tournament");
@ -178,12 +184,33 @@ public class NewTournamentDialog extends MageDialog {
.addComponent(jLabel4) .addComponent(jLabel4)
.addComponent(txtPlayer1Name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(txtPlayer1Name, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 58, Short.MAX_VALUE)) .addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 80, Short.MAX_VALUE))
); );
jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11));
jLabel5.setText("Packs"); jLabel5.setText("Packs");
cbDraftTiming.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "Item 1", "Item 2", "Item 3", "Item 4" }));
jLabel6.setText("Timing:");
javax.swing.GroupLayout pnlDraftOptionsLayout = new javax.swing.GroupLayout(pnlDraftOptions);
pnlDraftOptions.setLayout(pnlDraftOptionsLayout);
pnlDraftOptionsLayout.setHorizontalGroup(
pnlDraftOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlDraftOptionsLayout.createSequentialGroup()
.addComponent(jLabel6)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbDraftTiming, javax.swing.GroupLayout.PREFERRED_SIZE, 161, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(232, Short.MAX_VALUE))
);
pnlDraftOptionsLayout.setVerticalGroup(
pnlDraftOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlDraftOptionsLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(cbDraftTiming, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel6))
);
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(
@ -191,8 +218,8 @@ public class NewTournamentDialog extends MageDialog {
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(pnlPacks, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 525, Short.MAX_VALUE) .addComponent(pnlPacks, javax.swing.GroupLayout.Alignment.TRAILING, javax.swing.GroupLayout.DEFAULT_SIZE, 525, Short.MAX_VALUE)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addComponent(btnOk) .addComponent(btnOk)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -201,11 +228,13 @@ public class NewTournamentDialog extends MageDialog {
.addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(jLabel1, javax.swing.GroupLayout.PREFERRED_SIZE, 113, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbTournamentType, 0, 408, Short.MAX_VALUE)) .addComponent(cbTournamentType, 0, 408, Short.MAX_VALUE))
.addComponent(jLabel5)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addComponent(jLabel2) .addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel5)) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
.addContainerGap()) .addContainerGap())
); );
layout.setVerticalGroup( layout.setVerticalGroup(
@ -218,13 +247,15 @@ public class NewTournamentDialog extends MageDialog {
.addGap(3, 3, 3) .addGap(3, 3, 3)
.addComponent(jLabel5) .addComponent(jLabel5)
.addGap(1, 1, 1) .addGap(1, 1, 1)
.addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, 47, Short.MAX_VALUE) .addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, 46, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(pnlDraftOptions, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2)) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addGap(19, 19, 19) .addComponent(spnNumPlayers)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(jLabel2)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnCancel) .addComponent(btnCancel)
@ -248,10 +279,16 @@ public class NewTournamentDialog extends MageDialog {
tOptions.getPlayerTypes().add(player.getPlayerType()); tOptions.getPlayerTypes().add(player.getPlayerType());
} }
if (tournamentType.isDraft()) { if (tournamentType.isDraft()) {
tOptions.getDraftOptions().setDraftType(""); DraftOptions options = new DraftOptions();
tOptions.getDraftOptions().setTiming(DraftOptions.TimingOption.REGULAR); options.setDraftType("");
options.setTiming((TimingOption) this.cbDraftTiming.getSelectedItem());
tOptions.setLimitedOptions(options);
}
if (tournamentType.isLimited()) {
if (tOptions.getLimitedOptions() == null)
tOptions.setLimitedOptions(new LimitedOptions());
for (JComboBox pack: packs) { for (JComboBox pack: packs) {
tOptions.getDraftOptions().getSets().add((ExpansionSet) pack.getSelectedItem()); tOptions.getLimitedOptions().getSets().add((ExpansionSet) pack.getSelectedItem());
} }
} }
tOptions.getMatchOptions().setDeckType("Limited"); tOptions.getMatchOptions().setDeckType("Limited");
@ -294,7 +331,14 @@ public class NewTournamentDialog extends MageDialog {
this.spnNumPlayers.setModel(new SpinnerNumberModel(tournamentType.getMinPlayers(), tournamentType.getMinPlayers(), tournamentType.getMaxPlayers(), 1)); this.spnNumPlayers.setModel(new SpinnerNumberModel(tournamentType.getMinPlayers(), tournamentType.getMinPlayers(), tournamentType.getMaxPlayers(), 1));
this.spnNumPlayers.setEnabled(tournamentType.getMinPlayers() != tournamentType.getMaxPlayers()); this.spnNumPlayers.setEnabled(tournamentType.getMinPlayers() != tournamentType.getMaxPlayers());
createPlayers(tournamentType.getMinPlayers() - 1); createPlayers(tournamentType.getMinPlayers() - 1);
createPacks(tournamentType.getNumBoosters()); if (tournamentType.isLimited()) {
this.pnlPacks.setVisible(true);
createPacks(tournamentType.getNumBoosters());
}
else {
this.pnlPacks.setVisible(false);
}
this.pnlDraftOptions.setVisible(tournamentType.isDraft());
} }
private void createPacks(int numPacks) { private void createPacks(int numPacks) {
@ -343,13 +387,16 @@ public class NewTournamentDialog extends MageDialog {
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnCancel; private javax.swing.JButton btnCancel;
private javax.swing.JButton btnOk; private javax.swing.JButton btnOk;
private javax.swing.JComboBox cbDraftTiming;
private javax.swing.JComboBox cbTournamentType; private javax.swing.JComboBox cbTournamentType;
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4; private javax.swing.JLabel jLabel4;
private javax.swing.JLabel jLabel5; private javax.swing.JLabel jLabel5;
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel1; private javax.swing.JPanel jPanel1;
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 spnNumPlayers; private javax.swing.JSpinner spnNumPlayers;

View file

@ -169,11 +169,11 @@ public class Client implements CallbackClient {
} }
else if (callback.getMethod().equals("sideboard")) { else if (callback.getMethod().equals("sideboard")) {
TableClientMessage message = (TableClientMessage) callback.getData(); TableClientMessage message = (TableClientMessage) callback.getData();
sideboard(message.getDeck(), message.getTableId()); sideboard(message.getDeck(), message.getTableId(), message.getTime());
} }
else if (callback.getMethod().equals("construct")) { else if (callback.getMethod().equals("construct")) {
TableClientMessage message = (TableClientMessage) callback.getData(); TableClientMessage message = (TableClientMessage) callback.getData();
construct(message.getDeck(), message.getTableId()); construct(message.getDeck(), message.getTableId(), message.getTime());
} }
else if (callback.getMethod().equals("draftOver")) { else if (callback.getMethod().equals("draftOver")) {
session.getDraft().hideDraft(); session.getDraft().hideDraft();
@ -266,12 +266,12 @@ public class Client implements CallbackClient {
} }
} }
protected void sideboard(Deck deck, UUID tableId) { protected void sideboard(Deck deck, UUID tableId, int time) {
frame.showDeckEditor(DeckEditorMode.Sideboard, deck, tableId); frame.showDeckEditor(DeckEditorMode.Sideboard, deck, tableId, time);
} }
protected void construct(Deck deck, UUID tableId) { protected void construct(Deck deck, UUID tableId, int time) {
frame.showDeckEditor(DeckEditorMode.Limited, deck, tableId); frame.showDeckEditor(DeckEditorMode.Limited, deck, tableId, time);
} }
private void handleException(Exception ex) { private void handleException(Exception ex) {

View file

@ -43,10 +43,12 @@ public class TableClientMessage implements Serializable {
private UUID tableId; private UUID tableId;
private UUID gameId; private UUID gameId;
private UUID playerId; private UUID playerId;
private int time;
public TableClientMessage(Deck deck, UUID tableId) { public TableClientMessage(Deck deck, UUID tableId, int time) {
this.deck = deck; this.deck = deck;
this.tableId = tableId; this.tableId = tableId;
this.time = time;
} }
public TableClientMessage(UUID gameId, UUID playerId) { public TableClientMessage(UUID gameId, UUID playerId) {
@ -69,4 +71,8 @@ public class TableClientMessage implements Serializable {
public UUID getPlayerId() { public UUID getPlayerId() {
return playerId; return playerId;
} }
public int getTime() {
return time;
}
} }

View file

@ -43,6 +43,7 @@ public class TournamentTypeView implements Serializable {
private int maxPlayers; private int maxPlayers;
private int numBoosters; private int numBoosters;
private boolean draft; private boolean draft;
private boolean limited;
public TournamentTypeView(TournamentType tournamentType) { public TournamentTypeView(TournamentType tournamentType) {
this.name = tournamentType.getName(); this.name = tournamentType.getName();
@ -50,6 +51,7 @@ public class TournamentTypeView implements Serializable {
this.maxPlayers = tournamentType.getMaxPlayers(); this.maxPlayers = tournamentType.getMaxPlayers();
this.numBoosters = tournamentType.getNumBoosters(); this.numBoosters = tournamentType.getNumBoosters();
this.draft = tournamentType.isDraft(); this.draft = tournamentType.isDraft();
this.limited = tournamentType.isLimited();
} }
@Override @Override
@ -76,4 +78,8 @@ public class TournamentTypeView implements Serializable {
public boolean isDraft() { public boolean isDraft() {
return draft; return draft;
} }
public boolean isLimited() {
return limited;
}
} }

View file

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>mage-root</artifactId> <artifactId>Mage-Server-Plugins</artifactId>
<version>0.6</version> <version>0.6</version>
</parent> </parent>

View file

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>mage-root</artifactId> <artifactId>Mage-Server-Plugins</artifactId>
<version>0.6</version> <version>0.6</version>
</parent> </parent>

View file

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>mage-root</artifactId> <artifactId>Mage-Server-Plugins</artifactId>
<version>0.6</version> <version>0.6</version>
</parent> </parent>

View file

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>mage-root</artifactId> <artifactId>Mage-Server-Plugins</artifactId>
<version>0.6</version> <version>0.6</version>
</parent> </parent>

View file

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>mage-root</artifactId> <artifactId>Mage-Server-Plugins</artifactId>
<version>0.6</version> <version>0.6</version>
</parent> </parent>

View file

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>mage-root</artifactId> <artifactId>Mage-Server-Plugins</artifactId>
<version>0.6</version> <version>0.6</version>
</parent> </parent>

View file

@ -81,6 +81,7 @@ import mage.game.Game;
import mage.game.Table; import mage.game.Table;
import mage.game.combat.CombatGroup; import mage.game.combat.CombatGroup;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.game.tournament.Tournament;
import mage.player.ai.utils.RateCard; import mage.player.ai.utils.RateCard;
import mage.players.Player; import mage.players.Player;
import mage.players.PlayerImpl; import mage.players.PlayerImpl;
@ -774,7 +775,7 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
} }
@Override @Override
public void construct(Table table, Deck deck) { public void construct(Tournament tournament, Deck deck) {
//TODO: improve this //TODO: improve this
if (deck.getCards().size() < 40) { if (deck.getCards().size() < 40) {
while (deck.getCards().size() < 40) { while (deck.getCards().size() < 40) {
@ -783,7 +784,7 @@ public class ComputerPlayer<T extends ComputerPlayer<T>> extends PlayerImpl<T> i
deck.getSideboard().remove(card); deck.getSideboard().remove(card);
} }
} }
table.fireSubmitDeckEvent(playerId, deck); tournament.submitDeck(playerId, deck);
} }
@Override @Override

View file

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>mage-root</artifactId> <artifactId>Mage-Server-Plugins</artifactId>
<version>0.6</version> <version>0.6</version>
</parent> </parent>

View file

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>mage-root</artifactId> <artifactId>Mage-Server-Plugins</artifactId>
<version>0.6</version> <version>0.6</version>
</parent> </parent>

View file

@ -58,6 +58,7 @@ import mage.filter.common.FilterCreatureForCombat;
import mage.game.Game; import mage.game.Game;
import mage.game.Table; import mage.game.Table;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.game.tournament.Tournament;
import mage.target.Target; import mage.target.Target;
import mage.target.TargetAmount; import mage.target.TargetAmount;
import mage.target.TargetCard; import mage.target.TargetCard;
@ -486,8 +487,8 @@ public class HumanPlayer extends PlayerImpl<HumanPlayer> {
} }
@Override @Override
public void construct(Table table, Deck deck) { public void construct(Tournament tournament, Deck deck) {
table.fireConstructEvent(playerId, deck); tournament.fireConstructEvent(playerId, deck);
} }
@Override @Override

View file

@ -30,6 +30,7 @@ package mage.tournament;
import mage.game.draft.BoosterDraft; import mage.game.draft.BoosterDraft;
import mage.game.draft.Draft; import mage.game.draft.Draft;
import mage.game.draft.DraftOptions;
import mage.game.events.TableEvent.EventType; import mage.game.events.TableEvent.EventType;
import mage.game.tournament.TournamentOptions; import mage.game.tournament.TournamentOptions;
import mage.game.tournament.TournamentPlayer; import mage.game.tournament.TournamentPlayer;
@ -53,7 +54,7 @@ public class BoosterDraftEliminationTournament extends TournamentSingleEliminati
} }
protected void draft() { protected void draft() {
Draft draft = new BoosterDraft(options.getDraftOptions()); Draft draft = new BoosterDraft((DraftOptions) options.getLimitedOptions());
for (TournamentPlayer player: players.values()) { for (TournamentPlayer player: players.values()) {
draft.addPlayer(player.getPlayer()); draft.addPlayer(player.getPlayer());
} }

View file

@ -42,6 +42,7 @@ public class BoosterDraftEliminationTournamentType extends TournamentType<Booste
this.minPlayers = 4; this.minPlayers = 4;
this.numBoosters = 3; this.numBoosters = 3;
this.draft = true; this.draft = true;
this.limited = true;
} }
} }

View file

@ -0,0 +1,51 @@
<project xmlns="http://maven.apache.org/POM/4.0.0" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance"
xsi:schemaLocation="http://maven.apache.org/POM/4.0.0 http://maven.apache.org/maven-v4_0_0.xsd">
<modelVersion>4.0.0</modelVersion>
<parent>
<groupId>org.mage</groupId>
<artifactId>Mage-Server-Plugins</artifactId>
<version>0.6</version>
</parent>
<artifactId>Mage-Tournament-Sealed</artifactId>
<packaging>jar</packaging>
<name>Mage Tournament Sealed</name>
<dependencies>
<dependency>
<groupId>${project.groupId}</groupId>
<artifactId>Mage</artifactId>
<version>${project.version}</version>
</dependency>
</dependencies>
<build>
<sourceDirectory>src</sourceDirectory>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
<plugin>
<artifactId>maven-resources-plugin</artifactId>
<configuration>
<encoding>UTF-8</encoding>
</configuration>
</plugin>
</plugins>
<finalName>mage-tournament-sealed</finalName>
</build>
<properties/>
</project>

View file

@ -0,0 +1,77 @@
/*
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.tournament;
import mage.game.tournament.TournamentOptions;
import mage.game.tournament.TournamentSingleElimination;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class SealedEliminationTournament extends TournamentSingleElimination {
protected enum TournamentStep {
START, OPEN_BOOSTERS, CONSTRUCT, COMPETE, WINNERS
}
protected TournamentStep currentStep;
public SealedEliminationTournament(TournamentOptions options) {
super(options);
currentStep = TournamentStep.START;
}
protected void winners() {
throw new UnsupportedOperationException("Not supported yet.");
}
@Override
public void nextStep() {
switch (currentStep) {
case START:
currentStep = TournamentStep.OPEN_BOOSTERS;
openBoosters();
break;
case OPEN_BOOSTERS:
currentStep = TournamentStep.CONSTRUCT;
construct();
break;
case CONSTRUCT:
currentStep = TournamentStep.COMPETE;
runTournament();
break;
case COMPETE:
currentStep = TournamentStep.WINNERS;
winners();
break;
}
}
}

View file

@ -0,0 +1,48 @@
/*
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.tournament;
import mage.game.tournament.TournamentType;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class SealedEliminationTournamentType extends TournamentType<SealedEliminationTournamentType> {
public SealedEliminationTournamentType() {
this.name = "Sealed Elimination";
this.maxPlayers = 16;
this.minPlayers = 4;
this.numBoosters = 6;
this.draft = false;
this.limited = true;
}
}

View file

@ -11,7 +11,7 @@
<artifactId>Mage-Server-Plugins</artifactId> <artifactId>Mage-Server-Plugins</artifactId>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Mage Server Plugins</name> <name>Mage Server Plugins</name>
<description>Mage Server Plugins POM</description> <description>Mage Server Plugins POM</description>
<modules> <modules>
@ -24,6 +24,7 @@
<module>Mage.Player.AI.MA</module> <module>Mage.Player.AI.MA</module>
<module>Mage.Player.Human</module> <module>Mage.Player.Human</module>
<module>Mage.Tournament.BoosterDraft</module> <module>Mage.Tournament.BoosterDraft</module>
</modules> <module>Mage.Tournament.Sealed</module>
</modules>
</project> </project>

View file

@ -15,6 +15,7 @@
</gameTypes> </gameTypes>
<tournamentTypes> <tournamentTypes>
<tournamentType name="Elimination Booster Draft" jar="mage-tournament-booster-draft.jar" className="mage.tournament.BoosterDraftEliminationTournament" typeName="mage.tournament.BoosterDraftEliminationTournamentType"/> <tournamentType name="Elimination Booster Draft" jar="mage-tournament-booster-draft.jar" className="mage.tournament.BoosterDraftEliminationTournament" typeName="mage.tournament.BoosterDraftEliminationTournamentType"/>
<tournamentType name="Sealed Elimination" jar="mage-tournament-sealed.jar" className="mage.tournament.SealedEliminationTournament" typeName="mage.tournament.SealedEliminationTournamentType"/>
</tournamentTypes> </tournamentTypes>
<deckTypes> <deckTypes>
<deckType name="Constructed" jar="mage-deck-constructed.jar" className="mage.deck.Constructed"/> <deckType name="Constructed" jar="mage-deck-constructed.jar" className="mage.deck.Constructed"/>

View file

@ -90,7 +90,7 @@
</dependency> </dependency>
<dependency> <dependency>
<groupId>${project.groupId}</groupId> <groupId>${project.groupId}</groupId>
<artifactId>Mage-Draft-8PlayerBooster</artifactId> <artifactId>Mage-Tournament-BoosterDraft</artifactId>
<version>${project.version}</version> <version>${project.version}</version>
<scope>runtime</scope> <scope>runtime</scope>
</dependency> </dependency>

View file

@ -3,20 +3,20 @@
<config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Config.xsd"> <config xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xsi:noNamespaceSchemaLocation="../Config.xsd">
<server serverAddress="localhost" serverName="mage-server" port="17171" maxGameThreads="10" maxSecondsIdle="600"/> <server serverAddress="localhost" serverName="mage-server" port="17171" maxGameThreads="10" maxSecondsIdle="600"/>
<playerTypes> <playerTypes>
<playerType name="Human" jar="Mage-Player-Human-${project.version}.jar" className="mage.player.human.HumanPlayer"/> <playerType name="Human" jar="mage-player-human.jar" className="mage.player.human.HumanPlayer"/>
<playerType name="Computer - default" jar="Mage-Player-AI-${project.version}.jar" className="mage.player.ai.ComputerPlayer"/> <playerType name="Computer - default" jar="mage-player-ai.jar" className="mage.player.ai.ComputerPlayer"/>
<playerType name="Computer - minimax" jar="Mage-Player-AIMinimax-${project.version}.jar" className="mage.player.ai.ComputerPlayer2"/> <playerType name="Computer - minimax" jar="mage-player-aiminimax.jar" className="mage.player.ai.ComputerPlayer2"/>
<playerType name="Computer - minimax hybrid" jar="Mage-Player-AIMinimax-${project.version}.jar" className="mage.player.ai.ComputerPlayer3"/> <playerType name="Computer - minimax hybrid" jar="mage-player-aiminimax.jar" className="mage.player.ai.ComputerPlayer3"/>
</playerTypes> </playerTypes>
<gameTypes> <gameTypes>
<gameType name="Two Player Duel" jar="Mage-Game-TwoPlayerDuel-${project.version}.jar" className="mage.game.TwoPlayerMatch" typeName="mage.game.TwoPlayerDuelType"/> <gameType name="Two Player Duel" jar="mage-game-twoplayerduel.jar" className="mage.game.TwoPlayerMatch" typeName="mage.game.TwoPlayerDuelType"/>
<gameType name="Free For All" jar="Mage-Game-FreeForAll-${project.version}.jar" className="mage.game.FreeForAllMatch" typeName="mage.game.FreeForAllType"/> <gameType name="Free For All" jar="mage-game-freeforall.jar" className="mage.game.FreeForAllMatch" typeName="mage.game.FreeForAllType"/>
</gameTypes> </gameTypes>
<draftTypes> <tournamentTypes>
<draftType name="8 Player Booster" jar="Mage-Draft-8PlayerBooster-${project.version}.jar" className="mage.draft.BoosterDraft"/> <tournamentType name="Booster Draft" jar="mage-tournament-booster-draft.jar" className="mage.tournament.BoosterDraftEliminationTournament" typeName="mage.tournament.BoosterDraftEliminationTournamentType"/>
</draftTypes> </tournamentTypes>
<deckTypes> <deckTypes>
<deckType name="Constructed" jar="Mage-Deck-Constructed-${project.version}.jar" className="mage.deck.Constructed"/> <deckType name="Constructed" jar="mage-deck-constructed.jar" className="mage.deck.Constructed"/>
<deckType name="Limited" jar="Mage-Deck-Limited-${project.version}.jar" className="mage.deck.Limited"/> <deckType name="Limited" jar="mage-deck-limited.jar" className="mage.deck.Limited"/>
</deckTypes> </deckTypes>
</config> </config>

View file

@ -102,12 +102,12 @@ public class Session {
fireCallback(new ClientCallback("startTournament", new TableClientMessage(tournamentId, playerId))); fireCallback(new ClientCallback("startTournament", new TableClientMessage(tournamentId, playerId)));
} }
public void sideboard(final Deck deck, final UUID tableId) { public void sideboard(final Deck deck, final UUID tableId, final int time) {
fireCallback(new ClientCallback("sideboard", new TableClientMessage(deck, tableId))); fireCallback(new ClientCallback("sideboard", new TableClientMessage(deck, tableId, time)));
} }
public void construct(final Deck deck, final UUID tableId) { public void construct(final Deck deck, final UUID tableId, final int time) {
fireCallback(new ClientCallback("construct", new TableClientMessage(deck, tableId))); fireCallback(new ClientCallback("construct", new TableClientMessage(deck, tableId, time)));
} }
public void watchGame(final UUID gameId) { public void watchGame(final UUID gameId) {

View file

@ -68,9 +68,6 @@ import mage.game.tournament.Tournament;
import mage.game.tournament.TournamentOptions; import mage.game.tournament.TournamentOptions;
import mage.game.tournament.TournamentPlayer; import mage.game.tournament.TournamentPlayer;
import mage.players.Player; import mage.players.Player;
import mage.server.ChatManager;
import mage.server.Main;
import mage.server.SessionManager;
import mage.server.game.DeckValidatorFactory; import mage.server.game.DeckValidatorFactory;
import mage.server.game.GameFactory; import mage.server.game.GameFactory;
import mage.server.game.GameManager; import mage.server.game.GameManager;
@ -88,6 +85,8 @@ public class TableController {
private final static Logger logger = Logging.getLogger(TableController.class.getName()); private final static Logger logger = Logging.getLogger(TableController.class.getName());
private static final int SIDEBOARD_TIME = 180;
private UUID sessionId; private UUID sessionId;
private UUID chatId; private UUID chatId;
private Table table; private Table table;
@ -124,9 +123,9 @@ public class TableController {
case SIDEBOARD: case SIDEBOARD:
sideboard(event.getPlayerId(), event.getDeck()); sideboard(event.getPlayerId(), event.getDeck());
break; break;
case CONSTRUCT: // case CONSTRUCT:
construct(event.getPlayerId(), event.getDeck()); // construct(event.getPlayerId(), event.getDeck());
break; // break;
case SUBMIT_DECK: case SUBMIT_DECK:
submitDeck(event.getPlayerId(), event.getDeck()); submitDeck(event.getPlayerId(), event.getDeck());
break; break;
@ -200,30 +199,21 @@ public class TableController {
if (table.getState() != TableState.SIDEBOARDING && table.getState() != TableState.CONSTRUCTING) { if (table.getState() != TableState.SIDEBOARDING && table.getState() != TableState.CONSTRUCTING) {
return false; return false;
} }
String playerName;
if (table.getState() == TableState.SIDEBOARDING) {
MatchPlayer player = match.getPlayer(sessionPlayerMap.get(sessionId));
playerName = player.getPlayer().getName();
}
else {
TournamentPlayer player = tournament.getPlayer(sessionPlayerMap.get(sessionId));
playerName = player.getPlayer().getName();
}
Deck deck = Deck.load(deckList); Deck deck = Deck.load(deckList);
if (!Main.server.isTestMode() && !validDeck(deck)) { if (!Main.server.isTestMode() && !validDeck(deck)) {
throw new GameException(playerName + " has an invalid deck for this format"); throw new GameException("Invalid deck for this format");
} }
submitDeck(sessionPlayerMap.get(sessionId), deck); submitDeck(sessionId, deck);
return true; return true;
} }
private void submitDeck(UUID playerId, Deck deck) { private void submitDeck(UUID sessionId, Deck deck) {
if (table.getState() == TableState.SIDEBOARDING) { if (table.getState() == TableState.SIDEBOARDING) {
MatchPlayer player = match.getPlayer(playerId); MatchPlayer player = match.getPlayer(sessionPlayerMap.get(sessionId));
player.submitDeck(deck); player.submitDeck(deck);
} }
else { else {
tournament.submitDeck(playerId, deck); TournamentManager.getInstance().submitDeck(tournament.getId(), sessionId, deck);
} }
} }
@ -294,6 +284,7 @@ public class TableController {
public synchronized void startTournament(UUID sessionId) { public synchronized void startTournament(UUID sessionId) {
if (sessionId.equals(this.sessionId) && table.getState() == TableState.STARTING) { if (sessionId.equals(this.sessionId) && table.getState() == TableState.STARTING) {
table.initTournament();
TournamentManager.getInstance().createTournamentSession(tournament, sessionPlayerMap, table.getId()); TournamentManager.getInstance().createTournamentSession(tournament, sessionPlayerMap, table.getId());
SessionManager sessionManager = SessionManager.getInstance(); SessionManager sessionManager = SessionManager.getInstance();
for (Entry<UUID, UUID> entry: sessionPlayerMap.entrySet()) { for (Entry<UUID, UUID> entry: sessionPlayerMap.entrySet()) {
@ -324,29 +315,29 @@ public class TableController {
SessionManager sessionManager = SessionManager.getInstance(); SessionManager sessionManager = SessionManager.getInstance();
for (Entry<UUID, UUID> entry: sessionPlayerMap.entrySet()) { for (Entry<UUID, UUID> entry: sessionPlayerMap.entrySet()) {
if (entry.getValue().equals(playerId)) { if (entry.getValue().equals(playerId)) {
sessionManager.getSession(entry.getKey()).sideboard(deck, table.getId()); sessionManager.getSession(entry.getKey()).sideboard(deck, table.getId(), SIDEBOARD_TIME);
break; break;
} }
} }
} }
public void construct() { // public void construct() {
table.construct(); // table.construct();
for (TournamentPlayer player: tournament.getPlayers()) { // for (TournamentPlayer player: tournament.getPlayers()) {
player.setConstructing(); // player.setConstructing();
player.getPlayer().construct(table, player.getDeck()); // player.getPlayer().construct(table, player.getDeck());
} // }
} // }
private void construct(UUID playerId, Deck deck) { // private void construct(UUID playerId, Deck deck) {
SessionManager sessionManager = SessionManager.getInstance(); // SessionManager sessionManager = SessionManager.getInstance();
for (Entry<UUID, UUID> entry: sessionPlayerMap.entrySet()) { // for (Entry<UUID, UUID> entry: sessionPlayerMap.entrySet()) {
if (entry.getValue().equals(playerId)) { // if (entry.getValue().equals(playerId)) {
sessionManager.getSession(entry.getKey()).construct(deck, table.getId()); // sessionManager.getSession(entry.getKey()).construct(deck, table.getId(), CONSTRUCT_TIME);
break; // break;
} // }
} // }
} // }
public void endGame() { public void endGame() {
UUID choosingPlayerId = match.getChooser(); UUID choosingPlayerId = match.getChooser();

View file

@ -161,9 +161,9 @@ public class TableManager {
} }
} }
public void construct(UUID tableId) { // public void construct(UUID tableId) {
controllers.get(tableId).construct(); // controllers.get(tableId).construct();
} // }
public void addPlayer(UUID sessionId, UUID tableId, Player player, String playerType, Deck deck) throws GameException { public void addPlayer(UUID sessionId, UUID tableId, Player player, String playerType, Deck deck) throws GameException {
controllers.get(tableId).addPlayer(sessionId, player, playerType, deck); controllers.get(tableId).addPlayer(sessionId, player, playerType, deck);

View file

@ -175,7 +175,6 @@ public class DraftController {
public void timeout(UUID sessionId) { public void timeout(UUID sessionId) {
if (sessionPlayerMap.containsKey(sessionId)) { if (sessionPlayerMap.containsKey(sessionId)) {
// ChatManager.getInstance().broadcast(chatId, "", draft.getPlayer(sessionPlayerMap.get(sessionId)).getPlayer().getName() + " has timed out. Auto picking.", MessageColor.BLACK);
draft.autoPick(sessionPlayerMap.get(sessionId)); draft.autoPick(sessionPlayerMap.get(sessionId));
} }
} }

View file

@ -76,11 +76,11 @@ public class DraftManager {
draftControllers.get(draftId).kill(sessionId); draftControllers.get(draftId).kill(sessionId);
} }
void timeout(UUID gameId, UUID sessionId) { public void timeout(UUID gameId, UUID sessionId) {
draftControllers.get(gameId).timeout(sessionId); draftControllers.get(gameId).timeout(sessionId);
} }
void removeDraft(UUID draftId) { public void removeDraft(UUID draftId) {
draftControllers.remove(draftId); draftControllers.remove(draftId);
} }

View file

@ -33,10 +33,12 @@ import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import mage.cards.decks.Deck;
import mage.game.GameException; import mage.game.GameException;
import mage.game.Table; import mage.game.Table;
import mage.game.draft.Draft; import mage.game.draft.Draft;
import mage.game.events.Listener; import mage.game.events.Listener;
import mage.game.events.PlayerQueryEvent;
import mage.game.events.TableEvent; import mage.game.events.TableEvent;
import mage.game.match.MatchOptions; import mage.game.match.MatchOptions;
import mage.game.tournament.Tournament; import mage.game.tournament.Tournament;
@ -64,6 +66,8 @@ public class TournamentController {
private ConcurrentHashMap<UUID, UUID> sessionPlayerMap = new ConcurrentHashMap<UUID, UUID>(); private ConcurrentHashMap<UUID, UUID> sessionPlayerMap = new ConcurrentHashMap<UUID, UUID>();
private ConcurrentHashMap<UUID, TournamentSession> tournamentSessions = new ConcurrentHashMap<UUID, TournamentSession>(); private ConcurrentHashMap<UUID, TournamentSession> tournamentSessions = new ConcurrentHashMap<UUID, TournamentSession>();
private static final int CONSTRUCT_TIME = 600;
public TournamentController(Tournament tournament, ConcurrentHashMap<UUID, UUID> sessionPlayerMap, UUID tableId) { public TournamentController(Tournament tournament, ConcurrentHashMap<UUID, UUID> sessionPlayerMap, UUID tableId) {
sessionId = UUID.randomUUID(); sessionId = UUID.randomUUID();
this.sessionPlayerMap = sessionPlayerMap; this.sessionPlayerMap = sessionPlayerMap;
@ -83,15 +87,27 @@ public class TournamentController {
ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.BLACK); ChatManager.getInstance().broadcast(chatId, "", event.getMessage(), MessageColor.BLACK);
logger.finest(tournament.getId() + " " + event.getMessage()); logger.finest(tournament.getId() + " " + event.getMessage());
break; break;
case CONSTRUCT:
construct();
break;
case START_DRAFT: case START_DRAFT:
startDraft(event.getDraft()); startDraft(event.getDraft());
break; break;
case START_MATCH: case START_MATCH:
startMatch(event.getPair(), event.getMatchOptions()); startMatch(event.getPair(), event.getMatchOptions());
break; break;
case SUBMIT_DECK:
submitDeck(event.getPlayerId(), event.getDeck());
break;
}
}
}
);
tournament.addPlayerQueryEventListener(
new Listener<PlayerQueryEvent> () {
@Override
public void event(PlayerQueryEvent event) {
switch (event.getQueryType()) {
case CONSTRUCT:
construct(event.getPlayerId(), event.getDeck(), event.getMax());
break;
} }
} }
} }
@ -108,7 +124,7 @@ public class TournamentController {
public synchronized void join(UUID sessionId) { public synchronized void join(UUID sessionId) {
UUID playerId = sessionPlayerMap.get(sessionId); UUID playerId = sessionPlayerMap.get(sessionId);
TournamentSession tournamentSession = new TournamentSession(tournament, sessionId, playerId); TournamentSession tournamentSession = new TournamentSession(tournament, sessionId, tableId, playerId);
tournamentSessions.put(playerId, tournamentSession); tournamentSessions.put(playerId, tournamentSession);
TournamentPlayer player = tournament.getPlayer(playerId); TournamentPlayer player = tournament.getPlayer(playerId);
player.setJoined(); player.setJoined();
@ -170,8 +186,21 @@ public class TournamentController {
TableManager.getInstance().startDraft(tableId, draft); TableManager.getInstance().startDraft(tableId, draft);
} }
private void construct() { private synchronized void construct(UUID sessionId, Deck deck, int timeout) {
TableManager.getInstance().construct(tableId); if (tournamentSessions.containsKey(sessionId))
tournamentSessions.get(sessionId).construct(deck, timeout);
}
public void submitDeck(UUID sessionId, Deck deck) {
tournamentSessions.get(sessionPlayerMap.get(sessionId)).submitDeck(deck);
}
public void timeout(UUID sessionId) {
if (sessionPlayerMap.containsKey(sessionId)) {
TournamentPlayer player = tournament.getPlayer(sessionPlayerMap.get(sessionId));
tournament.autoSubmit(sessionPlayerMap.get(sessionId), player.getDeck());
}
} }
public UUID getSessionId() { public UUID getSessionId() {

View file

@ -30,6 +30,7 @@ package mage.server.tournament;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ConcurrentHashMap; import java.util.concurrent.ConcurrentHashMap;
import mage.cards.decks.Deck;
import mage.game.tournament.Tournament; import mage.game.tournament.Tournament;
import mage.view.TournamentView; import mage.view.TournamentView;
@ -61,6 +62,14 @@ public class TournamentManager {
controllers.get(tournamentId).kill(sessionId); controllers.get(tournamentId).kill(sessionId);
} }
public void timeout(UUID tournamentId, UUID sessionId) {
controllers.get(tournamentId).timeout(sessionId);
}
public void submitDeck(UUID tournamentId, UUID sessionId, Deck deck) {
controllers.get(tournamentId).submitDeck(sessionId, deck);
}
public TournamentView getTournamentView(UUID tournamentId) { public TournamentView getTournamentView(UUID tournamentId) {
return controllers.get(tournamentId).getTournamentView(); return controllers.get(tournamentId).getTournamentView();
} }

View file

@ -30,12 +30,17 @@ package mage.server.tournament;
import java.rmi.RemoteException; import java.rmi.RemoteException;
import java.util.UUID; import java.util.UUID;
import java.util.concurrent.ScheduledExecutorService;
import java.util.concurrent.ScheduledFuture;
import java.util.concurrent.TimeUnit;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import mage.cards.decks.Deck;
import mage.game.tournament.Tournament; import mage.game.tournament.Tournament;
import mage.interfaces.callback.ClientCallback; import mage.interfaces.callback.ClientCallback;
import mage.server.Session; import mage.server.Session;
import mage.server.SessionManager; import mage.server.SessionManager;
import mage.server.util.ThreadExecutor;
import mage.util.Logging; import mage.util.Logging;
import mage.view.TournamentView; import mage.view.TournamentView;
@ -48,13 +53,18 @@ public class TournamentSession {
protected UUID sessionId; protected UUID sessionId;
protected UUID playerId; protected UUID playerId;
protected UUID tableId;
protected Tournament tournament; protected Tournament tournament;
protected boolean killed = false; protected boolean killed = false;
public TournamentSession(Tournament tournament, UUID sessionId, UUID playerId) { private ScheduledFuture<?> futureTimeout;
protected static ScheduledExecutorService timeoutExecutor = ThreadExecutor.getInstance().getTimeoutExecutor();
public TournamentSession(Tournament tournament, UUID sessionId, UUID tableId, UUID playerId) {
this.sessionId = sessionId; this.sessionId = sessionId;
this.tournament = tournament; this.tournament = tournament;
this.playerId = playerId; this.playerId = playerId;
this.tableId = tableId;
} }
public boolean init(final TournamentView tournamentView) { public boolean init(final TournamentView tournamentView) {
@ -94,6 +104,20 @@ public class TournamentSession {
} }
} }
public void construct(Deck deck, int timeout) {
if (!killed) {
setupTimeout(timeout);
Session session = SessionManager.getInstance().getSession(sessionId);
if (session != null)
session.construct(deck, tableId, timeout);
}
}
public void submitDeck(Deck deck) {
cancelTimeout();
tournament.submitDeck(playerId, deck);
}
protected void handleRemoteException(RemoteException ex) { protected void handleRemoteException(RemoteException ex) {
logger.log(Level.SEVERE, null, ex); logger.log(Level.SEVERE, null, ex);
TournamentManager.getInstance().kill(tournament.getId(), sessionId); TournamentManager.getInstance().kill(tournament.getId(), sessionId);
@ -103,4 +127,25 @@ public class TournamentSession {
killed = true; killed = true;
} }
private synchronized void setupTimeout(int seconds) {
cancelTimeout();
if (seconds > 0) {
futureTimeout = timeoutExecutor.schedule(
new Runnable() {
@Override
public void run() {
TournamentManager.getInstance().timeout(tournament.getId(), sessionId);
}
},
seconds, TimeUnit.SECONDS
);
}
}
private synchronized void cancelTimeout() {
if (futureTimeout != null) {
futureTimeout.cancel(false);
}
}
} }

View file

@ -153,10 +153,6 @@ public class Table implements Serializable {
state = TableState.SIDEBOARDING; state = TableState.SIDEBOARDING;
} }
public void construct() {
state = TableState.CONSTRUCTING;
}
public String getName() { public String getName() {
return this.name; return this.name;
} }
@ -177,4 +173,8 @@ public class Table implements Serializable {
tableEventSource.addListener(listener); tableEventSource.addListener(listener);
} }
public void initTournament() {
state = TableState.CONSTRUCTING;
}
} }

View file

@ -29,18 +29,15 @@
package mage.game.draft; package mage.game.draft;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import mage.game.tournament.LimitedOptions;
import java.util.List;
import mage.cards.ExpansionSet;
/** /**
* *
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
*/ */
public class DraftOptions implements Serializable { public class DraftOptions extends LimitedOptions implements Serializable {
protected String draftType; protected String draftType;
protected List<ExpansionSet> sets = new ArrayList<ExpansionSet>();
protected TimingOption timing; protected TimingOption timing;
public enum TimingOption { public enum TimingOption {
@ -59,10 +56,6 @@ public class DraftOptions implements Serializable {
} }
} }
public List<ExpansionSet> getSets() {
return sets;
}
public String getDraftType() { public String getDraftType() {
return draftType; return draftType;
} }

View file

@ -36,6 +36,7 @@ import mage.abilities.ActivatedAbility;
import mage.abilities.TriggeredAbilities; import mage.abilities.TriggeredAbilities;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.Cards; import mage.cards.Cards;
import mage.cards.decks.Deck;
/** /**
* *
@ -44,7 +45,7 @@ import mage.cards.Cards;
public class PlayerQueryEvent extends EventObject implements ExternalEvent, Serializable { public class PlayerQueryEvent extends EventObject implements ExternalEvent, Serializable {
public enum QueryType { public enum QueryType {
ASK, CHOOSE, CHOOSE_ABILITY, PICK_TARGET, PICK_ABILITY, SELECT, PLAY_MANA, PLAY_X_MANA, AMOUNT, LOOK, PICK_CARD ASK, CHOOSE, CHOOSE_ABILITY, PICK_TARGET, PICK_ABILITY, SELECT, PLAY_MANA, PLAY_X_MANA, AMOUNT, LOOK, PICK_CARD, CONSTRUCT
} }
private String message; private String message;
@ -58,6 +59,7 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
private boolean required; private boolean required;
private int min; private int min;
private int max; private int max;
private Deck deck;
private Map<String, Serializable> options; private Map<String, Serializable> options;
private PlayerQueryEvent(UUID playerId, String message, Collection<? extends Ability> abilities, Set<String> choices, Set<UUID> targets, Cards cards, QueryType queryType, int min, int max, boolean required, Map<String, Serializable> options) { private PlayerQueryEvent(UUID playerId, String message, Collection<? extends Ability> abilities, Set<String> choices, Set<UUID> targets, Cards cards, QueryType queryType, int min, int max, boolean required, Map<String, Serializable> options) {
@ -88,6 +90,15 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
this.max = time; this.max = time;
} }
private PlayerQueryEvent(UUID playerId, String message, QueryType queryType, Deck deck, int time) {
super(playerId);
this.queryType = queryType;
this.message = message;
this.playerId = playerId;
this.deck = deck;
this.max = time;
}
public static PlayerQueryEvent askEvent(UUID playerId, String message) { public static PlayerQueryEvent askEvent(UUID playerId, String message) {
return new PlayerQueryEvent(playerId, message, null, null, null, null, QueryType.ASK, 0, 0, false); return new PlayerQueryEvent(playerId, message, null, null, null, null, QueryType.ASK, 0, 0, false);
} }
@ -139,6 +150,11 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
return new PlayerQueryEvent(playerId, message, booster, QueryType.PICK_CARD, time); return new PlayerQueryEvent(playerId, message, booster, QueryType.PICK_CARD, time);
} }
public static PlayerQueryEvent construct(UUID playerId, String message, Deck deck, int time) {
return new PlayerQueryEvent(playerId, message, QueryType.CONSTRUCT, deck, time);
}
public String getMessage() { public String getMessage() {
return message; return message;
} }
@ -183,6 +199,10 @@ public class PlayerQueryEvent extends EventObject implements ExternalEvent, Seri
return max; return max;
} }
public Deck getDeck() {
return deck;
}
public Map<String, Serializable> getOptions() { public Map<String, Serializable> getOptions() {
return options; return options;
} }

View file

@ -35,6 +35,7 @@ import mage.abilities.ActivatedAbility;
import mage.abilities.TriggeredAbilities; import mage.abilities.TriggeredAbilities;
import mage.cards.Card; import mage.cards.Card;
import mage.cards.Cards; import mage.cards.Cards;
import mage.cards.decks.Deck;
/** /**
* *
@ -101,4 +102,8 @@ public class PlayerQueryEventSource implements EventSource<PlayerQueryEvent>, Se
dispatcher.fireEvent(PlayerQueryEvent.pickCard(playerId, message, booster, time)); dispatcher.fireEvent(PlayerQueryEvent.pickCard(playerId, message, booster, time));
} }
public void construct(UUID playerId, String message, Deck deck, int time) {
dispatcher.fireEvent(PlayerQueryEvent.construct(playerId, message, deck, time));
}
} }

View file

@ -0,0 +1,48 @@
/*
* Copyright 2011 BetaSteward_at_googlemail.com. All rights reserved.
*
* Redistribution and use in source and binary forms, with or without modification, are
* permitted provided that the following conditions are met:
*
* 1. Redistributions of source code must retain the above copyright notice, this list of
* conditions and the following disclaimer.
*
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
* of conditions and the following disclaimer in the documentation and/or other materials
* provided with the distribution.
*
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
*
* The views and conclusions contained in the software and documentation are those of the
* authors and should not be interpreted as representing official policies, either expressed
* or implied, of BetaSteward_at_googlemail.com.
*/
package mage.game.tournament;
import java.io.Serializable;
import java.util.ArrayList;
import java.util.List;
import mage.cards.ExpansionSet;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class LimitedOptions implements Serializable {
protected List<ExpansionSet> sets = new ArrayList<ExpansionSet>();
public List<ExpansionSet> getSets() {
return sets;
}
}

View file

@ -32,6 +32,7 @@ import java.util.Collection;
import java.util.UUID; import java.util.UUID;
import mage.cards.decks.Deck; import mage.cards.decks.Deck;
import mage.game.events.Listener; import mage.game.events.Listener;
import mage.game.events.PlayerQueryEvent;
import mage.game.events.TableEvent; import mage.game.events.TableEvent;
import mage.players.Player; import mage.players.Player;
@ -47,11 +48,15 @@ public interface Tournament {
public Collection<TournamentPlayer> getPlayers(); public Collection<TournamentPlayer> getPlayers();
public Collection<Round> getRounds(); public Collection<Round> getRounds();
public void submitDeck(UUID playerId, Deck deck); public void submitDeck(UUID playerId, Deck deck);
public void autoSubmit(UUID playerId, Deck deck);
public boolean allJoined(); public boolean allJoined();
public boolean isDoneConstructing(); public boolean isDoneConstructing();
public void leave(UUID playerId); public void leave(UUID playerId);
public void nextStep(); public void nextStep();
public void addTableEventListener(Listener<TableEvent> listener); public void addTableEventListener(Listener<TableEvent> listener);
public void addPlayerQueryEventListener(Listener<PlayerQueryEvent> listener);
public void fireConstructEvent(UUID playerId, Deck deck);
public void fireSubmitDeckEvent(UUID playerId, Deck deck);
} }

View file

@ -38,8 +38,12 @@ import java.util.UUID;
import java.util.concurrent.CopyOnWriteArrayList; import java.util.concurrent.CopyOnWriteArrayList;
import java.util.logging.Level; import java.util.logging.Level;
import java.util.logging.Logger; import java.util.logging.Logger;
import mage.cards.Card;
import mage.cards.ExpansionSet;
import mage.cards.decks.Deck; import mage.cards.decks.Deck;
import mage.game.events.Listener; import mage.game.events.Listener;
import mage.game.events.PlayerQueryEvent;
import mage.game.events.PlayerQueryEventSource;
import mage.game.events.TableEvent; import mage.game.events.TableEvent;
import mage.game.events.TableEvent.EventType; import mage.game.events.TableEvent.EventType;
import mage.game.events.TableEventSource; import mage.game.events.TableEventSource;
@ -60,6 +64,7 @@ public abstract class TournamentImpl implements Tournament {
protected TournamentOptions options; protected TournamentOptions options;
protected transient TableEventSource tableEventSource = new TableEventSource(); protected transient TableEventSource tableEventSource = new TableEventSource();
protected transient PlayerQueryEventSource playerQueryEventSource = new PlayerQueryEventSource();
public TournamentImpl(TournamentOptions options) { public TournamentImpl(TournamentOptions options) {
this.options = options; this.options = options;
@ -80,6 +85,13 @@ public abstract class TournamentImpl implements Tournament {
return players.get(playerId); return players.get(playerId);
} }
@Override
public void autoSubmit(UUID playerId, Deck deck) {
if (players.containsKey(playerId)) {
players.get(playerId).submitDeck(deck);
}
}
@Override @Override
public Collection<TournamentPlayer> getPlayers() { public Collection<TournamentPlayer> getPlayers() {
return players.values(); return players.values();
@ -195,8 +207,27 @@ public abstract class TournamentImpl implements Tournament {
tableEventSource.addListener(listener); tableEventSource.addListener(listener);
} }
@Override
public void fireSubmitDeckEvent(UUID playerId, Deck deck) {
tableEventSource.fireTableEvent(EventType.SUBMIT_DECK, playerId, deck);
}
@Override
public void addPlayerQueryEventListener(Listener<PlayerQueryEvent> listener) {
playerQueryEventSource.addListener(listener);
}
@Override
public void fireConstructEvent(UUID playerId, Deck deck) {
TournamentPlayer player = players.get(playerId);
playerQueryEventSource.construct(playerId, "Construct", deck, 600);
}
public void construct() { public void construct() {
tableEventSource.fireTableEvent(EventType.CONSTRUCT); for (TournamentPlayer player: players.values()) {
player.setConstructing();
player.getPlayer().construct(this, player.getDeck());
}
synchronized(this) { synchronized(this) {
while (!isDoneConstructing()) { while (!isDoneConstructing()) {
try { try {
@ -207,6 +238,19 @@ public abstract class TournamentImpl implements Tournament {
nextStep(); nextStep();
} }
protected void openBoosters() {
for (TournamentPlayer player: this.players.values()) {
player.setDeck(new Deck());
for (ExpansionSet set: options.limitedOptions.getSets()) {
List<Card> booster = set.createBooster();
for (Card card: booster) {
player.getDeck().getSideboard().add(card);
}
}
}
nextStep();
}
public void playMatch(TournamentPairing pair) { public void playMatch(TournamentPairing pair) {
options.getMatchOptions().getPlayerTypes().clear(); options.getMatchOptions().getPlayerTypes().clear();
options.getMatchOptions().getPlayerTypes().add(pair.getPlayer1().getPlayerType()); options.getMatchOptions().getPlayerTypes().add(pair.getPlayer1().getPlayerType());

View file

@ -31,7 +31,6 @@ package mage.game.tournament;
import java.io.Serializable; import java.io.Serializable;
import java.util.ArrayList; import java.util.ArrayList;
import java.util.List; import java.util.List;
import mage.game.draft.DraftOptions;
import mage.game.match.MatchOptions; import mage.game.match.MatchOptions;
/** /**
@ -44,7 +43,7 @@ public class TournamentOptions implements Serializable {
protected String tournamentType; protected String tournamentType;
protected List<String> playerTypes = new ArrayList<String>(); protected List<String> playerTypes = new ArrayList<String>();
protected MatchOptions matchOptions = new MatchOptions("", "Two Player Duel"); protected MatchOptions matchOptions = new MatchOptions("", "Two Player Duel");
protected DraftOptions draftOptions = new DraftOptions(); protected LimitedOptions limitedOptions;
public TournamentOptions(String name) { public TournamentOptions(String name) {
this.name = name; this.name = name;
@ -70,8 +69,12 @@ public class TournamentOptions implements Serializable {
return matchOptions; return matchOptions;
} }
public DraftOptions getDraftOptions() { public void setLimitedOptions(LimitedOptions limitedOptions) {
return draftOptions; this.limitedOptions = limitedOptions;
}
public LimitedOptions getLimitedOptions() {
return limitedOptions;
} }
} }

View file

@ -41,6 +41,7 @@ public class TournamentType <T extends TournamentType<T>> implements Serializabl
protected int maxPlayers; protected int maxPlayers;
protected int numBoosters; protected int numBoosters;
protected boolean draft; protected boolean draft;
protected boolean limited;
protected TournamentType() {} protected TournamentType() {}
@ -69,4 +70,7 @@ public class TournamentType <T extends TournamentType<T>> implements Serializabl
return draft; return draft;
} }
public boolean isLimited() {
return limited;
}
} }

View file

@ -57,6 +57,7 @@ import mage.game.Game;
import mage.game.Table; import mage.game.Table;
import mage.game.draft.Draft; import mage.game.draft.Draft;
import mage.game.permanent.Permanent; import mage.game.permanent.Permanent;
import mage.game.tournament.Tournament;
import mage.target.Target; import mage.target.Target;
import mage.target.TargetAmount; import mage.target.TargetAmount;
import mage.target.TargetCard; import mage.target.TargetCard;
@ -154,7 +155,7 @@ public interface Player extends MageItem, Copyable<Player> {
public abstract void assignDamage(int damage, List<UUID> targets, UUID sourceId, Game game); public abstract void assignDamage(int damage, List<UUID> targets, UUID sourceId, Game game);
public abstract int getAmount(int min, int max, String message, Game game); public abstract int getAmount(int min, int max, String message, Game game);
public abstract void sideboard(Table table, Deck deck); public abstract void sideboard(Table table, Deck deck);
public abstract void construct(Table table, Deck deck); public abstract void construct(Tournament tournament, Deck deck);
public abstract void pickCard(List<Card> cards, Deck deck, Draft draft); public abstract void pickCard(List<Card> cards, Deck deck, Draft draft);
public void declareAttacker(UUID attackerId, UUID defenderId, Game game); public void declareAttacker(UUID attackerId, UUID defenderId, Game game);

View file

@ -25,12 +25,7 @@
<repositories> <repositories>
<repository> <repository>
<id>mage.googlecode.com</id> <id>mage.googlecode.com</id>
<url>http://magic--another-game-engine.googlecode.com/svn/trunk/repository</url> <url>http://mage.googlecode.com/svn/trunk/repository</url>
</repository>
<repository>
<id>java-image-scaling</id>
<name>Java Image Scaling Repository Released</name>
<url>svn:https://java-image-scaling.googlecode.com/svn/repo/released</url>
</repository> </repository>
<repository> <repository>
<id>jetlang.googlecode.com</id> <id>jetlang.googlecode.com</id>