mirror of
https://github.com/correl/mage.git
synced 2024-12-25 03:00:15 +00:00
* Some changes to table and match view.
This commit is contained in:
parent
54de525401
commit
8426816b09
13 changed files with 205 additions and 95 deletions
|
@ -43,8 +43,8 @@ import javax.swing.JTextField;
|
||||||
import javax.swing.table.AbstractTableModel;
|
import javax.swing.table.AbstractTableModel;
|
||||||
import javax.swing.table.JTableHeader;
|
import javax.swing.table.JTableHeader;
|
||||||
import javax.swing.table.TableColumnModel;
|
import javax.swing.table.TableColumnModel;
|
||||||
import javax.swing.table.TableRowSorter;
|
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
|
import mage.client.util.MageTableRowSorter;
|
||||||
import mage.remote.MageRemoteException;
|
import mage.remote.MageRemoteException;
|
||||||
import mage.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.view.ChatMessage.MessageColor;
|
import mage.view.ChatMessage.MessageColor;
|
||||||
|
@ -143,7 +143,7 @@ public class ChatPanel extends javax.swing.JPanel {
|
||||||
setBackground(new Color(0, 0, 0, ALPHA));
|
setBackground(new Color(0, 0, 0, ALPHA));
|
||||||
jTablePlayers.setBackground(new Color(0, 0, 0, ALPHA));
|
jTablePlayers.setBackground(new Color(0, 0, 0, ALPHA));
|
||||||
jTablePlayers.setForeground(Color.white);
|
jTablePlayers.setForeground(Color.white);
|
||||||
jTablePlayers.setRowSorter(new TableRowSorter(tableModel));
|
jTablePlayers.setRowSorter(new MageTableRowSorter(tableModel));
|
||||||
if (jScrollPaneTxt != null) {
|
if (jScrollPaneTxt != null) {
|
||||||
jScrollPaneTxt.setBackground(new Color(0, 0, 0, ALPHA));
|
jScrollPaneTxt.setBackground(new Color(0, 0, 0, ALPHA));
|
||||||
jScrollPaneTxt.getViewport().setBackground(new Color(0, 0, 0, ALPHA));
|
jScrollPaneTxt.getViewport().setBackground(new Color(0, 0, 0, ALPHA));
|
||||||
|
|
|
@ -73,6 +73,7 @@ import mage.client.dialog.NewTournamentDialog;
|
||||||
import mage.client.dialog.PreferencesDialog;
|
import mage.client.dialog.PreferencesDialog;
|
||||||
import mage.client.dialog.TableWaitingDialog;
|
import mage.client.dialog.TableWaitingDialog;
|
||||||
import mage.client.util.ButtonColumn;
|
import mage.client.util.ButtonColumn;
|
||||||
|
import mage.client.util.MageTableRowSorter;
|
||||||
import mage.client.util.gui.GuiDisplayUtil;
|
import mage.client.util.gui.GuiDisplayUtil;
|
||||||
import mage.constants.MatchTimeLimit;
|
import mage.constants.MatchTimeLimit;
|
||||||
import mage.constants.MultiplayerAttackOption;
|
import mage.constants.MultiplayerAttackOption;
|
||||||
|
@ -120,6 +121,10 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
chkShowCompleted.setVisible(true);
|
chkShowCompleted.setVisible(true);
|
||||||
|
|
||||||
tableTables.createDefaultColumnsFromModel();
|
tableTables.createDefaultColumnsFromModel();
|
||||||
|
tableTables.setRowSorter(new MageTableRowSorter(tableModel));
|
||||||
|
|
||||||
|
tableCompleted.setRowSorter(new MageTableRowSorter(matchesModel));
|
||||||
|
|
||||||
chatPanel.useExtendedView(ChatPanel.VIEW_MODE.NONE);
|
chatPanel.useExtendedView(ChatPanel.VIEW_MODE.NONE);
|
||||||
chatPanel.setBorder(null);
|
chatPanel.setBorder(null);
|
||||||
chatPanel.setChatType(ChatPanel.ChatType.TABLES);
|
chatPanel.setChatType(ChatPanel.ChatType.TABLES);
|
||||||
|
@ -705,13 +710,13 @@ private void chkShowCompletedActionPerformed(java.awt.event.ActionEvent evt) {//
|
||||||
|
|
||||||
class TableTableModel extends AbstractTableModel {
|
class TableTableModel extends AbstractTableModel {
|
||||||
|
|
||||||
public static final int COLUMN_DECK_TYPE = 5; // column the deck type is located (starting with 0)
|
public static final int COLUMN_DECK_TYPE = 0; // column the deck type is located (starting with 0) Start string is used to check for Limited
|
||||||
public static final int COLUMN_INFO = 6;
|
public static final int COLUMN_INFO = 3;
|
||||||
public static final int ACTION_COLUMN = 9; // column the action is located (starting with 0)
|
public static final int ACTION_COLUMN = 6; // column the action is located (starting with 0)
|
||||||
|
|
||||||
private final String[] columnNames = new String[]{"Match Name", "Owner / Players", "Game Type", "Wins", "Free Mulligans", "Deck Type", "Info", "Status", "Created / Started", "Action"};
|
private final String[] columnNames = new String[]{"Deck Type", "Owner / Players", "Game Type", "Info", "Status", "Created / Started", "Action"};
|
||||||
private TableView[] tables = new TableView[0];
|
private TableView[] tables = new TableView[0];
|
||||||
private static final DateFormat timeFormatter = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
private static final DateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss");;
|
||||||
|
|
||||||
private Session session;
|
private Session session;
|
||||||
|
|
||||||
|
@ -738,24 +743,18 @@ class TableTableModel extends AbstractTableModel {
|
||||||
public Object getValueAt(int arg0, int arg1) {
|
public Object getValueAt(int arg0, int arg1) {
|
||||||
switch (arg1) {
|
switch (arg1) {
|
||||||
case 0:
|
case 0:
|
||||||
return tables[arg0].getTableName();
|
return tables[arg0].getDeckType();
|
||||||
case 1:
|
case 1:
|
||||||
return tables[arg0].getControllerName();
|
return tables[arg0].getControllerName();
|
||||||
case 2:
|
case 2:
|
||||||
return tables[arg0].getGameType();
|
return tables[arg0].getGameType();
|
||||||
case 3:
|
case 3:
|
||||||
return Integer.toString(tables[arg0].getWins());
|
|
||||||
case 4:
|
|
||||||
return Integer.toString(tables[arg0].getFreeMulligans());
|
|
||||||
case 5:
|
|
||||||
return tables[arg0].getDeckType();
|
|
||||||
case 6:
|
|
||||||
return tables[arg0].getAdditionalInfo();
|
return tables[arg0].getAdditionalInfo();
|
||||||
case 7:
|
case 4:
|
||||||
return tables[arg0].getTableState().toString();
|
return tables[arg0].getTableStateText();
|
||||||
case 8:
|
case 5:
|
||||||
return timeFormatter.format(tables[arg0].getCreateTime());
|
return timeFormatter.format(tables[arg0].getCreateTime());
|
||||||
case 9:
|
case 6:
|
||||||
switch (tables[arg0].getTableState()) {
|
switch (tables[arg0].getTableState()) {
|
||||||
|
|
||||||
case WAITING:
|
case WAITING:
|
||||||
|
@ -782,14 +781,14 @@ class TableTableModel extends AbstractTableModel {
|
||||||
default:
|
default:
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
case 10:
|
case 7:
|
||||||
return tables[arg0].isTournament();
|
return tables[arg0].isTournament();
|
||||||
case 11:
|
case 8:
|
||||||
if (!tables[arg0].getGames().isEmpty()) {
|
if (!tables[arg0].getGames().isEmpty()) {
|
||||||
return tables[arg0].getGames().get(0);
|
return tables[arg0].getGames().get(0);
|
||||||
}
|
}
|
||||||
return null;
|
return null;
|
||||||
case 12:
|
case 9:
|
||||||
return tables[arg0].getTableId();
|
return tables[arg0].getTableId();
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
@ -908,9 +907,9 @@ class UpdatePlayersTask extends SwingWorker<Void, Collection<RoomUsersView>> {
|
||||||
|
|
||||||
class MatchesTableModel extends AbstractTableModel {
|
class MatchesTableModel extends AbstractTableModel {
|
||||||
|
|
||||||
public static final int ACTION_COLUMN = 7; // column the action is located (starting with 0)
|
public static final int ACTION_COLUMN = 6; // column the action is located (starting with 0)
|
||||||
public static final int GAMES_LIST_COLUMN = 8;
|
public static final int GAMES_LIST_COLUMN = 7;
|
||||||
private final String[] columnNames = new String[]{"Match Name", "Game Type", "Deck Type", "Players", "Result", "Start Time", "End Time","Action"};
|
private final String[] columnNames = new String[]{"Deck Type", "Players", "Game Type", "Result", "Start Time", "End Time","Action"};
|
||||||
private MatchView[] matches = new MatchView[0];
|
private MatchView[] matches = new MatchView[0];
|
||||||
private static final DateFormat timeFormatter = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
private static final DateFormat timeFormatter = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||||
|
|
||||||
|
@ -933,28 +932,26 @@ class MatchesTableModel extends AbstractTableModel {
|
||||||
public Object getValueAt(int arg0, int arg1) {
|
public Object getValueAt(int arg0, int arg1) {
|
||||||
switch (arg1) {
|
switch (arg1) {
|
||||||
case 0:
|
case 0:
|
||||||
return matches[arg0].getName();
|
|
||||||
case 1:
|
|
||||||
return matches[arg0].getGameType();
|
|
||||||
case 2:
|
|
||||||
return matches[arg0].getDeckType();
|
return matches[arg0].getDeckType();
|
||||||
case 3:
|
case 1:
|
||||||
return matches[arg0].getPlayers();
|
return matches[arg0].getPlayers();
|
||||||
case 4:
|
case 2:
|
||||||
|
return matches[arg0].getGameType();
|
||||||
|
case 3:
|
||||||
return matches[arg0].getResult();
|
return matches[arg0].getResult();
|
||||||
case 5:
|
case 4:
|
||||||
if (matches[arg0].getStartTime() != null) {
|
if (matches[arg0].getStartTime() != null) {
|
||||||
return timeFormatter.format(matches[arg0].getStartTime());
|
return timeFormatter.format(matches[arg0].getStartTime());
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
case 6:
|
case 5:
|
||||||
if (matches[arg0].getEndTime() != null) {
|
if (matches[arg0].getEndTime() != null) {
|
||||||
return timeFormatter.format(matches[arg0].getEndTime());
|
return timeFormatter.format(matches[arg0].getEndTime());
|
||||||
} else {
|
} else {
|
||||||
return "";
|
return "";
|
||||||
}
|
}
|
||||||
case 7:
|
case 6:
|
||||||
if (matches[arg0].isTournament()) {
|
if (matches[arg0].isTournament()) {
|
||||||
return "Show";
|
return "Show";
|
||||||
} else {
|
} else {
|
||||||
|
@ -964,7 +961,7 @@ class MatchesTableModel extends AbstractTableModel {
|
||||||
return "None";
|
return "None";
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
case 8:
|
case 7:
|
||||||
return matches[arg0].getGames();
|
return matches[arg0].getGames();
|
||||||
}
|
}
|
||||||
return "";
|
return "";
|
||||||
|
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.client.util;
|
||||||
|
|
||||||
|
import java.util.List;
|
||||||
|
import javax.swing.SortOrder;
|
||||||
|
import javax.swing.table.TableModel;
|
||||||
|
import javax.swing.table.TableRowSorter;
|
||||||
|
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author LevelX2
|
||||||
|
*/
|
||||||
|
public class MageTableRowSorter extends TableRowSorter {
|
||||||
|
|
||||||
|
public MageTableRowSorter(TableModel m) {
|
||||||
|
super(m);
|
||||||
|
}
|
||||||
|
/**
|
||||||
|
* @param column
|
||||||
|
* @inherited <p>
|
||||||
|
*/
|
||||||
|
@Override
|
||||||
|
public void toggleSortOrder(int column) {
|
||||||
|
List<? extends SortKey> sortKeys = getSortKeys();
|
||||||
|
if (sortKeys.size() > 0) {
|
||||||
|
if (sortKeys.get(0).getSortOrder() == SortOrder.DESCENDING) {
|
||||||
|
setSortKeys(null);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
super.toggleSortOrder(column);
|
||||||
|
}
|
||||||
|
}
|
|
@ -75,7 +75,12 @@ public class MatchView implements Serializable {
|
||||||
this.matchId = match.getId();
|
this.matchId = match.getId();
|
||||||
this.matchName = match.getName();
|
this.matchName = match.getName();
|
||||||
this.gameType = match.getOptions().getGameType();
|
this.gameType = match.getOptions().getGameType();
|
||||||
|
|
||||||
|
if (table.getName() != null && !table.getName().isEmpty()) {
|
||||||
|
this.deckType = match.getOptions().getDeckType() + " [" + table.getName() + "]";
|
||||||
|
} else {
|
||||||
this.deckType = match.getOptions().getDeckType();
|
this.deckType = match.getOptions().getDeckType();
|
||||||
|
}
|
||||||
|
|
||||||
for (Game game: match.getGames()) {
|
for (Game game: match.getGames()) {
|
||||||
games.add(game.getId());
|
games.add(game.getId());
|
||||||
|
@ -123,8 +128,14 @@ public class MatchView implements Serializable {
|
||||||
if (table.getTournament().getOptions().getNumberRounds() > 0) {
|
if (table.getTournament().getOptions().getNumberRounds() > 0) {
|
||||||
this.gameType = new StringBuilder(this.gameType).append(" ").append(table.getTournament().getOptions().getNumberRounds()).append(" Rounds").toString();
|
this.gameType = new StringBuilder(this.gameType).append(" ").append(table.getTournament().getOptions().getNumberRounds()).append(" Rounds").toString();
|
||||||
}
|
}
|
||||||
this.deckType = new StringBuilder(table.getDeckType()).append(" ").append(table.getTournament().getBoosterInfo()).toString();
|
StringBuilder sbDeckType = new StringBuilder(table.getDeckType());
|
||||||
|
if (!table.getTournament().getBoosterInfo().isEmpty()) {
|
||||||
|
sbDeckType.append(" ").append(table.getTournament().getBoosterInfo());
|
||||||
|
}
|
||||||
|
if (table.getName() != null && !table.getName().isEmpty()) {
|
||||||
|
sbDeckType.append(table.getDeckType()).append(" [").append(table.getName()).append("]");
|
||||||
|
}
|
||||||
|
this.deckType = sbDeckType.toString();
|
||||||
StringBuilder sb1 = new StringBuilder();
|
StringBuilder sb1 = new StringBuilder();
|
||||||
for (TournamentPlayer tPlayer : table.getTournament().getPlayers()) {
|
for (TournamentPlayer tPlayer : table.getTournament().getPlayers()) {
|
||||||
sb1.append(tPlayer.getPlayer().getName()).append(" (").append(tPlayer.getPoints()).append(" P.) ");
|
sb1.append(tPlayer.getPlayer().getName()).append(" (").append(tPlayer.getPoints()).append(" P.) ");
|
||||||
|
|
|
@ -37,6 +37,7 @@ import mage.constants.TableState;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.Seat;
|
import mage.game.Seat;
|
||||||
import mage.game.Table;
|
import mage.game.Table;
|
||||||
|
import mage.game.draft.Draft;
|
||||||
import mage.game.match.MatchPlayer;
|
import mage.game.match.MatchPlayer;
|
||||||
import mage.game.tournament.TournamentPlayer;
|
import mage.game.tournament.TournamentPlayer;
|
||||||
|
|
||||||
|
@ -49,14 +50,13 @@ public class TableView implements Serializable {
|
||||||
|
|
||||||
private UUID tableId;
|
private UUID tableId;
|
||||||
private String gameType;
|
private String gameType;
|
||||||
private int wins;
|
|
||||||
private int freeMulligans;
|
|
||||||
private final String deckType;
|
private final String deckType;
|
||||||
private String tableName;
|
private String tableName;
|
||||||
private String controllerName;
|
private String controllerName;
|
||||||
private final String additionalInfo;
|
private final String additionalInfo;
|
||||||
private Date createTime;
|
private Date createTime;
|
||||||
private TableState tableState;
|
private TableState tableState;
|
||||||
|
private final String tableStateText;
|
||||||
private boolean isTournament;
|
private boolean isTournament;
|
||||||
private List<SeatView> seats = new ArrayList<>();
|
private List<SeatView> seats = new ArrayList<>();
|
||||||
private List<UUID> games = new ArrayList<>();
|
private List<UUID> games = new ArrayList<>();
|
||||||
|
@ -65,6 +65,10 @@ public class TableView implements Serializable {
|
||||||
this.tableId = table.getId();
|
this.tableId = table.getId();
|
||||||
this.gameType = table.getGameType();
|
this.gameType = table.getGameType();
|
||||||
this.tableName = table.getName();
|
this.tableName = table.getName();
|
||||||
|
String tableNameInfo = null;
|
||||||
|
if (tableName != null && !tableName.isEmpty()) {
|
||||||
|
tableNameInfo = " [" + table.getName() + "]";
|
||||||
|
}
|
||||||
this.controllerName = table.getControllerName();
|
this.controllerName = table.getControllerName();
|
||||||
this.tableState = table.getState();
|
this.tableState = table.getState();
|
||||||
if (table.getState().equals(TableState.WAITING) ||
|
if (table.getState().equals(TableState.WAITING) ||
|
||||||
|
@ -83,8 +87,13 @@ public class TableView implements Serializable {
|
||||||
seats.add(new SeatView(seat));
|
seats.add(new SeatView(seat));
|
||||||
}
|
}
|
||||||
if (!table.isTournament()) {
|
if (!table.isTournament()) {
|
||||||
this.wins = table.getMatch().getWinsNeeded();
|
// MATCH
|
||||||
this.freeMulligans = table.getMatch().getFreeMulligans();
|
if (table.getState().equals(TableState.WAITING) || table.getState().equals(TableState.READY_TO_START)) {
|
||||||
|
tableStateText = table.getState().toString() + " (" + table.getMatch().getPlayers().size() + "/"+ table.getSeats().length + ")" +
|
||||||
|
(table.getMatch().getOptions().getPassword().isEmpty() ? "":" PW");
|
||||||
|
} else {
|
||||||
|
tableStateText = table.getState().toString();
|
||||||
|
}
|
||||||
for (Game game: table.getMatch().getGames()) {
|
for (Game game: table.getMatch().getGames()) {
|
||||||
games.add(game.getId());
|
games.add(game.getId());
|
||||||
}
|
}
|
||||||
|
@ -105,23 +114,24 @@ public class TableView implements Serializable {
|
||||||
sbScore.append(" Draws: ").append(table.getMatch().getDraws());
|
sbScore.append(" Draws: ").append(table.getMatch().getDraws());
|
||||||
}
|
}
|
||||||
this.controllerName += sb.toString();
|
this.controllerName += sb.toString();
|
||||||
this.deckType = table.getDeckType();
|
this.deckType = table.getDeckType() + (tableNameInfo != null ? tableNameInfo : "");
|
||||||
StringBuilder addInfo = new StringBuilder();
|
StringBuilder addInfo = new StringBuilder();
|
||||||
if (table.getMatch().getGames().isEmpty()) {
|
if (table.getMatch().getGames().isEmpty()) {
|
||||||
if (!table.getMatch().getOptions().getPassword().isEmpty()) {
|
addInfo.append("Wins:").append(table.getMatch().getWinsNeeded());
|
||||||
addInfo.append("PW-");
|
|
||||||
}
|
|
||||||
addInfo.append(" Timer: ").append(table.getMatch().getOptions().getMatchTimeLimit().toString());
|
addInfo.append(" Timer: ").append(table.getMatch().getOptions().getMatchTimeLimit().toString());
|
||||||
|
if (table.getMatch().getFreeMulligans() > 0) {
|
||||||
|
addInfo.append(" Free Mul.: ").append(table.getMatch().getFreeMulligans());
|
||||||
|
}
|
||||||
} else {
|
} else {
|
||||||
|
addInfo.append("Wins:").append(table.getMatch().getWinsNeeded());
|
||||||
addInfo.append(sbScore.toString());
|
addInfo.append(sbScore.toString());
|
||||||
}
|
}
|
||||||
this.additionalInfo = addInfo.toString();
|
this.additionalInfo = addInfo.toString();
|
||||||
} else {
|
} else {
|
||||||
this.wins = table.getTournament().getOptions().getMatchOptions().getWinsNeeded();
|
// TOURNAMENT
|
||||||
if (table.getTournament().getOptions().getNumberRounds() > 0) {
|
if (table.getTournament().getOptions().getNumberRounds() > 0) {
|
||||||
this.gameType = new StringBuilder(this.gameType).append(" ").append(table.getTournament().getOptions().getNumberRounds()).append(" Rounds").toString();
|
this.gameType = new StringBuilder(this.gameType).append(" ").append(table.getTournament().getOptions().getNumberRounds()).append(" Rounds").toString();
|
||||||
}
|
}
|
||||||
this.freeMulligans = table.getTournament().getOptions().getMatchOptions().getFreeMulligans();
|
|
||||||
StringBuilder sb1 = new StringBuilder();
|
StringBuilder sb1 = new StringBuilder();
|
||||||
for (TournamentPlayer tp: table.getTournament().getPlayers()) {
|
for (TournamentPlayer tp: table.getTournament().getPlayers()) {
|
||||||
if (!tp.getPlayer().getName().equals(table.getControllerName())) {
|
if (!tp.getPlayer().getName().equals(table.getControllerName())) {
|
||||||
|
@ -129,26 +139,41 @@ public class TableView implements Serializable {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
this.controllerName += sb1.toString();
|
this.controllerName += sb1.toString();
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder infoText = new StringBuilder();
|
||||||
if (!table.getTournament().getOptions().getPassword().isEmpty()) {
|
StringBuilder stateText = new StringBuilder(table.getState().toString());
|
||||||
sb.append("PW-");
|
infoText.append("Wins:").append(table.getTournament().getOptions().getMatchOptions().getWinsNeeded()).append(" ");
|
||||||
|
if (!table.getState().equals(TableState.WAITING)) {
|
||||||
|
infoText.append("Seats: ").append(table.getTournament().getPlayers().size()).append("/").append(table.getNumberOfSeats());
|
||||||
}
|
}
|
||||||
sb.append("Seats: ").append(table.getTournament().getPlayers().size()).append("/").append(table.getNumberOfSeats());
|
|
||||||
switch (table.getState()) {
|
switch (table.getState()) {
|
||||||
case WAITING:
|
case WAITING:
|
||||||
|
stateText.append(" (").append(table.getTournament().getPlayers().size()).append("/").append(table.getNumberOfSeats()).append(")");
|
||||||
|
if (!table.getTournament().getOptions().getPassword().isEmpty()) {
|
||||||
|
infoText.append(" PW");
|
||||||
|
}
|
||||||
case READY_TO_START:
|
case READY_TO_START:
|
||||||
case STARTING:
|
case STARTING:
|
||||||
|
if (table.getTournament().getOptions().getMatchOptions().getFreeMulligans() > 0) {
|
||||||
|
infoText.append(" Free Mul.: ").append(table.getTournament().getOptions().getMatchOptions().getFreeMulligans());
|
||||||
|
}
|
||||||
if (table.getTournament().getTournamentType().isLimited()) {
|
if (table.getTournament().getTournamentType().isLimited()) {
|
||||||
sb.append(" Constr. Time: ").append(table.getTournament().getOptions().getLimitedOptions().getConstructionTime()/60).append(" Min.");
|
infoText.append(" Constr. Time: ").append(table.getTournament().getOptions().getLimitedOptions().getConstructionTime()/60).append(" Min.");
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
case DUELING:
|
case DUELING:
|
||||||
sb.append(" - Running round: ").append(table.getTournament().getRounds().size());
|
stateText.append(" Round: ").append(table.getTournament().getRounds().size());
|
||||||
break;
|
break;
|
||||||
|
case DRAFTING:
|
||||||
|
Draft draft = table.getTournament().getDraft();
|
||||||
|
if (draft != null) {
|
||||||
|
stateText.append(" ").append(draft.getBoosterNum()).append("/").append(draft.getCardNum() -1);
|
||||||
|
}
|
||||||
default:
|
default:
|
||||||
}
|
}
|
||||||
this.additionalInfo = sb.toString();
|
this.additionalInfo = infoText.toString();
|
||||||
this.deckType = new StringBuilder(table.getDeckType()).append(" ").append(table.getTournament().getBoosterInfo()).toString();
|
this.tableStateText = stateText.toString();
|
||||||
|
this.deckType = table.getDeckType() + " " + table.getTournament().getBoosterInfo() + (tableNameInfo != null ? tableNameInfo : "");
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -168,14 +193,6 @@ public class TableView implements Serializable {
|
||||||
return gameType;
|
return gameType;
|
||||||
}
|
}
|
||||||
|
|
||||||
public int getWins() {
|
|
||||||
return wins;
|
|
||||||
}
|
|
||||||
|
|
||||||
public int getFreeMulligans() {
|
|
||||||
return freeMulligans;
|
|
||||||
}
|
|
||||||
|
|
||||||
public String getDeckType() {
|
public String getDeckType() {
|
||||||
return deckType;
|
return deckType;
|
||||||
}
|
}
|
||||||
|
@ -203,4 +220,8 @@ public class TableView implements Serializable {
|
||||||
return this.additionalInfo;
|
return this.additionalInfo;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
public String getTableStateText() {
|
||||||
|
return tableStateText;
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
|
@ -30,7 +30,6 @@ package mage.tournament;
|
||||||
|
|
||||||
import mage.constants.TournamentPlayerState;
|
import mage.constants.TournamentPlayerState;
|
||||||
import mage.game.draft.BoosterDraft;
|
import mage.game.draft.BoosterDraft;
|
||||||
import mage.game.draft.Draft;
|
|
||||||
import mage.game.draft.DraftOptions;
|
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;
|
||||||
|
|
|
@ -248,6 +248,10 @@ public class TableController {
|
||||||
if (user == null) {
|
if (user == null) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (userPlayerMap.containsKey(userId) && playerType.equals("Human")){
|
||||||
|
user.showUserMessage("Join Table", new StringBuilder("You can join a table only one time.").toString());
|
||||||
|
return false;
|
||||||
|
}
|
||||||
if (table.getState() != TableState.WAITING) {
|
if (table.getState() != TableState.WAITING) {
|
||||||
user.showUserMessage("Join Table", "No available seats.");
|
user.showUserMessage("Join Table", "No available seats.");
|
||||||
return false;
|
return false;
|
||||||
|
@ -644,6 +648,7 @@ public class TableController {
|
||||||
public synchronized void startTournament(UUID userId) {
|
public synchronized void startTournament(UUID userId) {
|
||||||
try {
|
try {
|
||||||
if (userId.equals(this.userId) && table.getState().equals(TableState.STARTING)) {
|
if (userId.equals(this.userId) && table.getState().equals(TableState.STARTING)) {
|
||||||
|
tournament.setStartTime();
|
||||||
TournamentManager.getInstance().createTournamentSession(tournament, userPlayerMap, table.getId());
|
TournamentManager.getInstance().createTournamentSession(tournament, userPlayerMap, table.getId());
|
||||||
for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) {
|
for (Entry<UUID, UUID> entry: userPlayerMap.entrySet()) {
|
||||||
User user = UserManager.getInstance().getUser(entry.getKey());
|
User user = UserManager.getInstance().getUser(entry.getKey());
|
||||||
|
|
|
@ -377,7 +377,7 @@ public class User {
|
||||||
public String getGameInfo() {
|
public String getGameInfo() {
|
||||||
StringBuilder sb = new StringBuilder();
|
StringBuilder sb = new StringBuilder();
|
||||||
|
|
||||||
int draft = 0, match = 0, sideboard = 0, tournament = 0, construct = 0;
|
int draft = 0, match = 0, sideboard = 0, tournament = 0, construct = 0, waiting = 0;
|
||||||
|
|
||||||
for (Map.Entry<UUID, Table> tableEntry : tables.entrySet()) {
|
for (Map.Entry<UUID, Table> tableEntry : tables.entrySet()) {
|
||||||
if (tableEntry != null) {
|
if (tableEntry != null) {
|
||||||
|
@ -389,6 +389,11 @@ public class User {
|
||||||
if (tournamentPlayer != null) {
|
if (tournamentPlayer != null) {
|
||||||
if (!tournamentPlayer.isEliminated()) {
|
if (!tournamentPlayer.isEliminated()) {
|
||||||
switch (table.getState()) {
|
switch (table.getState()) {
|
||||||
|
case WAITING:
|
||||||
|
case STARTING:
|
||||||
|
case READY_TO_START:
|
||||||
|
waiting++;
|
||||||
|
break;
|
||||||
case CONSTRUCTING:
|
case CONSTRUCTING:
|
||||||
construct++;
|
construct++;
|
||||||
break;
|
break;
|
||||||
|
@ -415,6 +420,11 @@ public class User {
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
switch (table.getState()) {
|
switch (table.getState()) {
|
||||||
|
case WAITING:
|
||||||
|
case STARTING:
|
||||||
|
case READY_TO_START:
|
||||||
|
waiting++;
|
||||||
|
break;
|
||||||
case SIDEBOARDING:
|
case SIDEBOARDING:
|
||||||
sideboard++;
|
sideboard++;
|
||||||
break;
|
break;
|
||||||
|
@ -426,6 +436,9 @@ public class User {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
if (waiting > 0) {
|
||||||
|
sb.append("Wait: ").append(waiting).append(" ");
|
||||||
|
}
|
||||||
if (match > 0) {
|
if (match > 0) {
|
||||||
sb.append("Match: ").append(match).append(" ");
|
sb.append("Match: ").append(match).append(" ");
|
||||||
}
|
}
|
||||||
|
|
|
@ -224,36 +224,33 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
||||||
class TableListSorter implements Comparator<Table> {
|
class TableListSorter implements Comparator<Table> {
|
||||||
@Override
|
@Override
|
||||||
public int compare(Table one, Table two) {
|
public int compare(Table one, Table two) {
|
||||||
// priority 1 - Not started yet
|
if (!one.getState().equals(TableState.SIDEBOARDING) && !one.getState().equals(TableState.DUELING)) {
|
||||||
if (one.getState().equals(TableState.READY_TO_START) || one.getState().equals(TableState.WAITING) || one.getState().equals(TableState.STARTING)) {
|
if (one.getState().compareTo(two.getState()) != 0 ) {
|
||||||
if (two.getState().equals(TableState.READY_TO_START) || two.getState().equals(TableState.WAITING) || two.getState().equals(TableState.STARTING)) {
|
return one.getState().compareTo(two.getState());
|
||||||
return two.getCreateTime().compareTo(one.getCreateTime());
|
|
||||||
} else {
|
|
||||||
return -1; // one has higher priority
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
// priority 2 - Not finished yet -> Sorted by time started
|
if (two.getEndTime() != null) {
|
||||||
if (two.getState().equals(TableState.READY_TO_START) || two.getState().equals(TableState.WAITING) || two.getState().equals(TableState.STARTING)) {
|
if (one.getEndTime() == null) {
|
||||||
return 1; // two has higher priority
|
|
||||||
} else if (one.getEndTime() == null) {
|
|
||||||
if (two.getEndTime() == null) {
|
|
||||||
if (two.getStartTime() == null) {
|
|
||||||
return -1;
|
|
||||||
} else if (one.getStartTime() == null) {
|
|
||||||
return 1;
|
|
||||||
}
|
|
||||||
return two.getStartTime().compareTo(one.getStartTime());
|
|
||||||
} else {
|
|
||||||
return -1;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
// priority 3 - Finished tables -> Sorted by time finished
|
|
||||||
if (two.getEndTime() == null) {
|
|
||||||
return 1;
|
return 1;
|
||||||
} else {
|
} else {
|
||||||
return two.getEndTime().compareTo(one.getEndTime());
|
return two.getEndTime().compareTo(one.getEndTime());
|
||||||
}
|
}
|
||||||
|
}
|
||||||
|
if (two.getStartTime() != null) {
|
||||||
|
if (one.getStartTime() == null) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return two.getStartTime().compareTo(one.getStartTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (two.getCreateTime() != null) {
|
||||||
|
if (one.getCreateTime() == null) {
|
||||||
|
return 1;
|
||||||
|
} else {
|
||||||
|
return two.getCreateTime().compareTo(one.getCreateTime());
|
||||||
|
}
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -80,7 +80,7 @@ class BonfireOfTheDamnedEffect extends OneShotEffect {
|
||||||
|
|
||||||
public BonfireOfTheDamnedEffect() {
|
public BonfireOfTheDamnedEffect() {
|
||||||
super(Outcome.Damage);
|
super(Outcome.Damage);
|
||||||
staticText = "Bonfire of the Damned deals X damage to target player and each creature he or she controls";
|
staticText = "{this} deals X damage to target player and each creature he or she controls";
|
||||||
}
|
}
|
||||||
|
|
||||||
public BonfireOfTheDamnedEffect(final BonfireOfTheDamnedEffect effect) {
|
public BonfireOfTheDamnedEffect(final BonfireOfTheDamnedEffect effect) {
|
||||||
|
@ -97,8 +97,8 @@ class BonfireOfTheDamnedEffect extends OneShotEffect {
|
||||||
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
|
for (Permanent perm: game.getBattlefield().getAllActivePermanents(filter, player.getId(), game)) {
|
||||||
perm.damage(damage, source.getSourceId(), game, false, true);
|
perm.damage(damage, source.getSourceId(), game, false, true);
|
||||||
}
|
}
|
||||||
return true;
|
|
||||||
}
|
}
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
|
|
@ -9,9 +9,9 @@ public enum TableState {
|
||||||
READY_TO_START("Waiting to start"),
|
READY_TO_START("Waiting to start"),
|
||||||
STARTING ("Starting"),
|
STARTING ("Starting"),
|
||||||
DRAFTING ("Drafting"),
|
DRAFTING ("Drafting"),
|
||||||
|
CONSTRUCTING ("Constructing"),
|
||||||
DUELING ("Dueling"),
|
DUELING ("Dueling"),
|
||||||
SIDEBOARDING ("Sideboarding"),
|
SIDEBOARDING ("Sideboarding"),
|
||||||
CONSTRUCTING ("Constructing"),
|
|
||||||
FINISHED ("Finished");
|
FINISHED ("Finished");
|
||||||
|
|
||||||
private final String text;
|
private final String text;
|
||||||
|
|
|
@ -77,6 +77,7 @@ public interface Tournament {
|
||||||
TournamentOptions getOptions();
|
TournamentOptions getOptions();
|
||||||
|
|
||||||
// tournament times
|
// tournament times
|
||||||
|
void setStartTime();
|
||||||
Date getStartTime();
|
Date getStartTime();
|
||||||
Date getEndTime();
|
Date getEndTime();
|
||||||
|
|
||||||
|
|
|
@ -492,6 +492,12 @@ public abstract class TournamentImpl implements Tournament {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public void setStartTime() {
|
||||||
|
this.stepStartTime = new Date();
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void setStepStartTime(Date stepStartTime) {
|
public void setStepStartTime(Date stepStartTime) {
|
||||||
this.stepStartTime = stepStartTime;
|
this.stepStartTime = stepStartTime;
|
||||||
|
|
Loading…
Reference in a new issue