* Number of wins can be set for tournaments. * Current score of running matches is shown in the table list.

This commit is contained in:
LevelX2 2013-06-10 16:25:31 +02:00
parent bbf277f17e
commit 3dbdba32e9
6 changed files with 129 additions and 52 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">
<Properties>
@ -26,7 +26,7 @@
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
<Component id="pnlPacks" alignment="1" pref="563" 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"/>
@ -41,9 +41,14 @@
<Component id="jLabel1" alignment="1" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Component id="txtName" pref="470" max="32767" attributes="0"/>
<Component id="cbTournamentType" alignment="0" pref="470" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" max="-2" attributes="0">
<Component id="txtName" max="32767" attributes="0"/>
<Component id="cbTournamentType" pref="420" max="32767" attributes="0"/>
</Group>
<EmptySpace type="unrelated" max="32767" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="spnNumWins" alignment="0" 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">
@ -59,25 +64,34 @@
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblName" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbTournamentType" alignment="3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="1" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="3" attributes="0">
<Component id="txtName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblName" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="jLabel1" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbTournamentType" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Group type="102" attributes="0">
<Component id="lblNumWins" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="0" max="-2" attributes="0"/>
<Component id="spnNumWins" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="pnlPacks" pref="61" max="32767" attributes="0"/>
<Component id="pnlPacks" pref="63" max="32767" attributes="0"/>
<EmptySpace min="-2" pref="11" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="spnNumPlayers" alignment="0" pref="24" max="32767" attributes="1"/>
<Component id="spnNumPlayers" alignment="0" pref="26" max="32767" attributes="1"/>
<Component id="pnlDraftOptions" max="32767" attributes="1"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
@ -152,7 +166,7 @@
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<Group type="103" groupAlignment="1" attributes="0">
<Component id="pnlOtherPlayers" alignment="0" pref="563" max="32767" attributes="0"/>
<Component id="pnlOtherPlayers" alignment="0" max="32767" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="483" max="-2" attributes="0"/>
@ -160,7 +174,7 @@
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel4" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="txtPlayer1Name" pref="528" max="32767" attributes="0"/>
<Component id="txtPlayer1Name" max="32767" attributes="0"/>
</Group>
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
@ -269,5 +283,15 @@
</Component>
</SubComponents>
</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>
</Form>

View file

@ -73,6 +73,7 @@ public class NewTournamentDialog extends MageDialog {
public NewTournamentDialog() {
initComponents();
txtName.setText("Tournament");
this.spnNumWins.setModel(new SpinnerNumberModel(2, 1, 5, 1));
}
public void showDialog(UUID roomId) {
@ -114,6 +115,8 @@ public class NewTournamentDialog extends MageDialog {
pnlDraftOptions = new javax.swing.JPanel();
jLabel6 = new javax.swing.JLabel();
cbDraftTiming = new javax.swing.JComboBox();
lblNumWins = new javax.swing.JLabel();
spnNumWins = new javax.swing.JSpinner();
setTitle("New Tournament");
@ -150,7 +153,7 @@ public class NewTournamentDialog extends MageDialog {
pnlPacks.setLayout(new java.awt.GridLayout(0, 1, 2, 0));
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11));
jLabel3.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel3.setText("Player 1 (You)");
jLabel4.setText("Name:");
@ -165,14 +168,14 @@ public class NewTournamentDialog extends MageDialog {
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, 563, Short.MAX_VALUE)
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.Alignment.LEADING, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 483, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(javax.swing.GroupLayout.Alignment.LEADING, jPanel1Layout.createSequentialGroup()
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtPlayer1Name, javax.swing.GroupLayout.DEFAULT_SIZE, 528, Short.MAX_VALUE)))
.addComponent(txtPlayer1Name)))
.addContainerGap())
);
jPanel1Layout.setVerticalGroup(
@ -187,7 +190,7 @@ public class NewTournamentDialog extends MageDialog {
.addComponent(pnlOtherPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 91, Short.MAX_VALUE))
);
jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11));
jLabel5.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N
jLabel5.setText("Packs");
lblName.setText("Name:");
@ -214,6 +217,14 @@ public class NewTournamentDialog extends MageDialog {
.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());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
@ -222,7 +233,7 @@ public class NewTournamentDialog extends MageDialog {
.addContainerGap()
.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(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, 563, 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)
@ -235,9 +246,13 @@ public class NewTournamentDialog extends MageDialog {
.addComponent(lblName)
.addComponent(jLabel1))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addComponent(txtName, javax.swing.GroupLayout.DEFAULT_SIZE, 470, Short.MAX_VALUE)
.addComponent(cbTournamentType, javax.swing.GroupLayout.Alignment.LEADING, 0, 470, Short.MAX_VALUE)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING, false)
.addComponent(txtName)
.addComponent(cbTournamentType, 0, 420, 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)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, 50, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblNumWins)))
.addGroup(layout.createSequentialGroup()
.addComponent(btnOk)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -248,20 +263,26 @@ public class NewTournamentDialog extends MageDialog {
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblName))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(cbTournamentType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.TRAILING)
.addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblName))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(jLabel1)
.addComponent(cbTournamentType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createSequentialGroup()
.addComponent(lblNumWins)
.addGap(0, 0, 0)
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel5)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, 61, Short.MAX_VALUE)
.addComponent(pnlPacks, javax.swing.GroupLayout.DEFAULT_SIZE, 63, Short.MAX_VALUE)
.addGap(11, 11, 11)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 24, Short.MAX_VALUE)
.addComponent(spnNumPlayers, javax.swing.GroupLayout.DEFAULT_SIZE, 26, Short.MAX_VALUE)
.addComponent(pnlDraftOptions, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addComponent(jLabel2))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
@ -301,7 +322,7 @@ public class NewTournamentDialog extends MageDialog {
}
}
tOptions.getMatchOptions().setDeckType("Limited");
tOptions.getMatchOptions().setWinsNeeded(2);
tOptions.getMatchOptions().setWinsNeeded((Integer)this.spnNumWins.getValue());
tOptions.getMatchOptions().setAttackOption(MultiplayerAttackOption.LEFT);
tOptions.getMatchOptions().setRange(RangeOfInfluence.ALL);
tOptions.getMatchOptions().setLimited(true);
@ -340,6 +361,10 @@ public class NewTournamentDialog extends MageDialog {
createPlayers(numPlayers);
}//GEN-LAST:event_spnNumPlayersStateChanged
private void spnNumWinsnumPlayersChanged(javax.swing.event.ChangeEvent evt) {//GEN-FIRST:event_spnNumWinsnumPlayersChanged
// TODO add your handling code here:
}//GEN-LAST:event_spnNumWinsnumPlayersChanged
private void setTournamentOptions() {
TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
this.spnNumPlayers.setModel(new SpinnerNumberModel(tournamentType.getMinPlayers(), tournamentType.getMinPlayers(), tournamentType.getMaxPlayers(), 1));
@ -366,6 +391,7 @@ public class NewTournamentDialog extends MageDialog {
pnlPacks.add(pack);
packs.add(pack);
pack.addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
packActionPerformed(evt);
}
@ -413,6 +439,7 @@ public class NewTournamentDialog extends MageDialog {
for (TournamentPlayerPanel panel: players) {
this.pnlOtherPlayers.add(panel);
panel.getPlayerType().addActionListener(new java.awt.event.ActionListener() {
@Override
public void actionPerformed(java.awt.event.ActionEvent evt) {
playerActionPerformed(evt);
}
@ -457,10 +484,12 @@ public class NewTournamentDialog extends MageDialog {
private javax.swing.JLabel jLabel6;
private javax.swing.JPanel jPanel1;
private javax.swing.JLabel lblName;
private javax.swing.JLabel lblNumWins;
private javax.swing.JPanel pnlDraftOptions;
private javax.swing.JPanel pnlOtherPlayers;
private javax.swing.JPanel pnlPacks;
private javax.swing.JSpinner spnNumPlayers;
private javax.swing.JSpinner spnNumWins;
private javax.swing.JTextField txtName;
private javax.swing.JTextField txtPlayer1Name;
// End of variables declaration//GEN-END:variables

View file

@ -120,10 +120,10 @@ public class TablesPanel extends javax.swing.JPanel {
public void actionPerformed(ActionEvent e)
{
int modelRow = Integer.valueOf( e.getActionCommand() );
UUID tableId = (UUID)tableModel.getValueAt(modelRow, 10);
UUID gameId = (UUID)tableModel.getValueAt(modelRow, 9);
UUID tableId = (UUID)tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 3);
UUID gameId = (UUID)tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 2);
String state = (String)tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN);
boolean isTournament = (Boolean)tableModel.getValueAt(modelRow, 8);
boolean isTournament = (Boolean)tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN + 1);
String owner = (String)tableModel.getValueAt(modelRow, 1);
if (state.equals("Join")) {
@ -606,9 +606,9 @@ private void chkShowCompletedActionPerformed(java.awt.event.ActionEvent evt) {//
class TableTableModel extends AbstractTableModel {
public static int ACTION_COLUMN = 7; // column the action is located (starting with 0)
public static int ACTION_COLUMN = 8; // column the action is located (starting with 0)
private String[] columnNames = new String[]{"Match Name", "Owner / Players", "Game Type", "Deck Type", "Info", "Status", "Created", "Action"};
private String[] columnNames = new String[]{"Match Name", "Owner / Players", "Game Type", "Wins", "Deck Type", "Info", "Status", "Created", "Action"};
private TableView[] tables = new TableView[0];
private static final DateFormat timeFormatter = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
@ -641,16 +641,18 @@ class TableTableModel extends AbstractTableModel {
case 1:
return tables[arg0].getControllerName();
case 2:
return tables[arg0].getGameType().toString();
return tables[arg0].getGameType();
case 3:
return tables[arg0].getDeckType().toString();
return Integer.toString(tables[arg0].getWins());
case 4:
return tables[arg0].getAdditionalInfo().toString();
return tables[arg0].getDeckType();
case 5:
return tables[arg0].getTableState().toString();
return tables[arg0].getAdditionalInfo();
case 6:
return timeFormatter.format(tables[arg0].getCreateTime());
return tables[arg0].getTableState().toString();
case 7:
return timeFormatter.format(tables[arg0].getCreateTime());
case 8:
switch (tables[arg0].getTableState()) {
case WAITING:
String owner = tables[arg0].getControllerName();
@ -678,14 +680,14 @@ class TableTableModel extends AbstractTableModel {
default:
return "";
}
case 8:
return tables[arg0].isTournament();
case 9:
return tables[arg0].isTournament();
case 10:
if (!tables[arg0].getGames().isEmpty()) {
return tables[arg0].getGames().get(0);
}
return null;
case 10:
case 11:
return tables[arg0].getTableId();
}
return "";

View file

@ -49,6 +49,7 @@ public class TableView implements Serializable {
private UUID tableId;
private String gameType;
private int wins;
private String deckType;
private String tableName;
private String controllerName;
@ -71,19 +72,30 @@ public class TableView implements Serializable {
seats.add(new SeatView(seat));
}
if (!table.isTournament()) {
this.additionalInfo = new StringBuilder("Wins: ").append(table.getMatch().getWinsNeeded()).toString();
this.wins = table.getMatch().getWinsNeeded();
for (Game game: table.getMatch().getGames()) {
games.add(game.getId());
}
StringBuilder sb = new StringBuilder();
StringBuilder sbScore = new StringBuilder("Score: ");
for(MatchPlayer matchPlayer: table.getMatch().getPlayers()) {
if (!matchPlayer.getPlayer().getName().equals(table.getControllerName())) {
sb.append(", ").append(matchPlayer.getPlayer().getName());
sbScore.append("-").append(matchPlayer.getWins());
} else {
sbScore.insert(0,matchPlayer.getWins()).insert(0,"Score: ");
}
}
this.controllerName += sb.toString();
this.deckType = table.getDeckType();
if (table.getMatch().getGames().isEmpty()) {
this.additionalInfo = "";
} else {
this.additionalInfo = sbScore.toString();
}
} else {
this.wins = table.getTournament().getOptions().getMatchOptions().getWinsNeeded();
StringBuilder sb1 = new StringBuilder();
for (TournamentPlayer tp: table.getTournament().getPlayers()) {
if (!tp.getPlayer().getName().equals(table.getControllerName())) {
@ -98,7 +110,6 @@ public class TableView implements Serializable {
this.additionalInfo = sb.toString();
this.deckType = new StringBuilder(table.getDeckType()).append(" ").append(table.getTournament().getSetsFormatedShort()).toString();
}
}
public UUID getTableId() {
@ -117,6 +128,10 @@ public class TableView implements Serializable {
return gameType;
}
public int getWins() {
return wins;
}
public String getDeckType() {
return deckType;
}

View file

@ -70,6 +70,8 @@ public interface Tournament {
void addPlayerQueryEventListener(Listener<PlayerQueryEvent> listener);
void fireConstructEvent(UUID playerId);
TournamentOptions getOptions();
// tournament times
Date getStartTime();
Date getEndTime();

View file

@ -90,6 +90,11 @@ public abstract class TournamentImpl implements Tournament {
}
}
@Override
public TournamentOptions getOptions() {
return options;
}
@Override
public Collection<TournamentPlayer> getPlayers() {
return players.values();