mirror of
https://github.com/correl/mage.git
synced 2025-03-07 20:53:18 -10:00
* The list of completed matches and tournaments shows now also columns with start and end time.
This commit is contained in:
parent
aef53bc4ce
commit
dec8f24c68
6 changed files with 75 additions and 12 deletions
|
@ -122,7 +122,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
int modelRow = Integer.valueOf( e.getActionCommand() );
|
||||
UUID tableId = (UUID)tableModel.getValueAt(modelRow, 10);
|
||||
UUID gameId = (UUID)tableModel.getValueAt(modelRow, 9);
|
||||
String state = (String)tableModel.getValueAt(modelRow, 7);
|
||||
String state = (String)tableModel.getValueAt(modelRow, TableTableModel.ACTION_COLUMN);
|
||||
boolean isTournament = (Boolean)tableModel.getValueAt(modelRow, 8);
|
||||
String owner = (String)tableModel.getValueAt(modelRow, 1);
|
||||
|
||||
|
@ -180,7 +180,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
public void actionPerformed(ActionEvent e)
|
||||
{
|
||||
int modelRow = Integer.valueOf( e.getActionCommand() );
|
||||
List<UUID> games = (List<UUID>)matchesModel.getValueAt(modelRow, 6);
|
||||
List<UUID> games = (List<UUID>)matchesModel.getValueAt(modelRow, MatchesTableModel.ACTION_COLUMN);
|
||||
if (games.size() == 1) {
|
||||
session.replayGame(games.get(0));
|
||||
}
|
||||
|
@ -191,9 +191,9 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
};
|
||||
|
||||
|
||||
// adds buttons (don't delete this)
|
||||
new ButtonColumn(tableTables, joinTable, 7);
|
||||
new ButtonColumn(tableCompleted, replayMatch, 5);
|
||||
// adds buttons to the table panel (don't delete this)
|
||||
new ButtonColumn(tableTables, joinTable, TableTableModel.ACTION_COLUMN);
|
||||
new ButtonColumn(tableCompleted, replayMatch, MatchesTableModel.ACTION_COLUMN);
|
||||
}
|
||||
|
||||
public Map<String, JComponent> getUIComponents() {
|
||||
|
@ -605,6 +605,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)
|
||||
|
||||
private String[] columnNames = new String[]{"Match Name", "Owner / Players", "Game Type", "Deck Type", "Info", "Status", "Created", "Action"};
|
||||
private TableView[] tables = new TableView[0];
|
||||
private static final DateFormat timeFormatter = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
|
@ -706,7 +709,7 @@ class TableTableModel extends AbstractTableModel {
|
|||
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
if (columnIndex != 7) {
|
||||
if (columnIndex != ACTION_COLUMN) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
@ -807,9 +810,12 @@ class UpdatePlayersTask extends SwingWorker<Void, Collection<String>> {
|
|||
}
|
||||
|
||||
class MatchesTableModel extends AbstractTableModel {
|
||||
private String[] columnNames = new String[]{"Match Name", "Game Type", "Deck Type", "Players", "Result", "Action"};
|
||||
|
||||
public static int ACTION_COLUMN = 7; // column the action is located (starting with 0)
|
||||
|
||||
private String[] columnNames = new String[]{"Match Name", "Game Type", "Deck Type", "Players", "Result", "Start Time", "End Time","Action"};
|
||||
private MatchView[] matches = new MatchView[0];
|
||||
private static final DateFormat timeFormatter = SimpleDateFormat.getTimeInstance(SimpleDateFormat.SHORT);
|
||||
private static final DateFormat timeFormatter = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
|
||||
public void loadData(Collection<MatchView> matches) throws MageRemoteException {
|
||||
this.matches = matches.toArray(new MatchView[0]);
|
||||
|
@ -840,8 +846,12 @@ class MatchesTableModel extends AbstractTableModel {
|
|||
case 4:
|
||||
return matches[arg0].getResult();
|
||||
case 5:
|
||||
return "None";
|
||||
return timeFormatter.format(matches[arg0].getStartTime());
|
||||
case 6:
|
||||
return timeFormatter.format(matches[arg0].getEndTime());
|
||||
case 7:
|
||||
return "None";
|
||||
case 8:
|
||||
return matches[arg0].getGames();
|
||||
}
|
||||
return "";
|
||||
|
@ -865,7 +875,7 @@ class MatchesTableModel extends AbstractTableModel {
|
|||
|
||||
@Override
|
||||
public boolean isCellEditable(int rowIndex, int columnIndex) {
|
||||
if (columnIndex != 5) {
|
||||
if (columnIndex != ACTION_COLUMN) {
|
||||
return false;
|
||||
}
|
||||
return true;
|
||||
|
|
|
@ -29,6 +29,7 @@ package mage.view;
|
|||
|
||||
import java.io.Serializable;
|
||||
import java.util.ArrayList;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.game.Game;
|
||||
|
@ -49,8 +50,11 @@ public class MatchView implements Serializable {
|
|||
private String deckType;
|
||||
|
||||
private List<UUID> games = new ArrayList<UUID>();
|
||||
private String result;
|
||||
private String result;
|
||||
private String players;
|
||||
|
||||
private Date startTime;
|
||||
private Date endTime;
|
||||
|
||||
public MatchView(Match match) {
|
||||
this.matchId = match.getId();
|
||||
|
@ -68,7 +72,8 @@ public class MatchView implements Serializable {
|
|||
players = sb1.substring(0, sb1.length() - 2);
|
||||
result = sb2.substring(0, sb2.length() - 2);
|
||||
}
|
||||
|
||||
this.startTime = match.getStartTime();
|
||||
this.endTime = match.getEndTime();
|
||||
}
|
||||
|
||||
// used for tournaments
|
||||
|
@ -88,6 +93,8 @@ public class MatchView implements Serializable {
|
|||
sb2.append(tPlayer.getPlayer().getName()).append(": ").append(tPlayer.getResults()).append(" ");
|
||||
}
|
||||
this.result = sb2.toString();
|
||||
this.startTime = table.getTournament().getStartTime();
|
||||
this.endTime = table.getTournament().getEndTime();
|
||||
}
|
||||
|
||||
public UUID getMatchId() {
|
||||
|
@ -118,4 +125,11 @@ public class MatchView implements Serializable {
|
|||
return players;
|
||||
}
|
||||
|
||||
public Date getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
public Date getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -28,6 +28,7 @@
|
|||
|
||||
package mage.game.match;
|
||||
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.cards.decks.Deck;
|
||||
|
@ -71,4 +72,7 @@ public interface Match {
|
|||
void addTableEventListener(Listener<TableEvent> listener);
|
||||
void fireSideboardEvent(UUID playerId, Deck deck);
|
||||
|
||||
// match times
|
||||
Date getStartTime();
|
||||
Date getEndTime();
|
||||
}
|
||||
|
|
|
@ -30,6 +30,7 @@ package mage.game.match;
|
|||
|
||||
import java.util.ArrayList;
|
||||
import java.util.Collections;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.Random;
|
||||
import java.util.UUID;
|
||||
|
@ -56,8 +57,12 @@ public abstract class MatchImpl implements Match {
|
|||
|
||||
protected TableEventSource tableEventSource = new TableEventSource();
|
||||
|
||||
protected Date startTime;
|
||||
protected Date endTime;
|
||||
|
||||
public MatchImpl(MatchOptions options) {
|
||||
this.options = options;
|
||||
startTime = new Date();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -114,6 +119,7 @@ public abstract class MatchImpl implements Match {
|
|||
public boolean isMatchOver() {
|
||||
for (MatchPlayer player: players) {
|
||||
if (player.getWins() >= options.getWinsNeeded()) {
|
||||
endTime = new Date();
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
@ -255,5 +261,15 @@ public abstract class MatchImpl implements Match {
|
|||
sb.append("\nGame has started\n");
|
||||
return sb.toString();
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
package mage.game.tournament;
|
||||
|
||||
import java.util.Collection;
|
||||
import java.util.Date;
|
||||
import java.util.List;
|
||||
import java.util.UUID;
|
||||
import mage.cards.ExpansionSet;
|
||||
|
@ -69,4 +70,7 @@ public interface Tournament {
|
|||
void addPlayerQueryEventListener(Listener<PlayerQueryEvent> listener);
|
||||
void fireConstructEvent(UUID playerId);
|
||||
|
||||
// tournament times
|
||||
Date getStartTime();
|
||||
Date getEndTime();
|
||||
}
|
||||
|
|
|
@ -58,10 +58,14 @@ public abstract class TournamentImpl implements Tournament {
|
|||
protected TableEventSource tableEventSource = new TableEventSource();
|
||||
protected PlayerQueryEventSource playerQueryEventSource = new PlayerQueryEventSource();
|
||||
|
||||
protected Date startTime;
|
||||
protected Date endTime;
|
||||
|
||||
private static final int CONSTRUCT_TIME = 600;
|
||||
|
||||
public TournamentImpl(TournamentOptions options) {
|
||||
this.options = options;
|
||||
startTime = new Date();
|
||||
}
|
||||
|
||||
@Override
|
||||
|
@ -292,9 +296,20 @@ public abstract class TournamentImpl implements Tournament {
|
|||
}
|
||||
|
||||
public void end() {
|
||||
endTime = new Date();
|
||||
tableEventSource.fireTableEvent(EventType.END);
|
||||
}
|
||||
|
||||
protected abstract void runTournament();
|
||||
|
||||
@Override
|
||||
public Date getStartTime() {
|
||||
return startTime;
|
||||
}
|
||||
|
||||
@Override
|
||||
public Date getEndTime() {
|
||||
return endTime;
|
||||
}
|
||||
|
||||
}
|
||||
|
|
Loading…
Add table
Reference in a new issue