mirror of
https://github.com/correl/mage.git
synced 2024-12-29 19:15:06 +00:00
Add rating to the client (#1498)
This commit is contained in:
parent
972d59aa37
commit
c781728b97
16 changed files with 234 additions and 52 deletions
|
@ -34,9 +34,8 @@ import java.util.Arrays;
|
|||
import java.util.List;
|
||||
import java.util.ListIterator;
|
||||
import java.util.UUID;
|
||||
import javax.swing.DefaultComboBoxModel;
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.SpinnerNumberModel;
|
||||
import javax.swing.*;
|
||||
|
||||
import mage.cards.decks.importer.DeckImporterUtil;
|
||||
import mage.client.MageFrame;
|
||||
import mage.client.components.MageComponents;
|
||||
|
@ -105,6 +104,7 @@ public class NewTableDialog extends MageDialog {
|
|||
lblGameType = new javax.swing.JLabel();
|
||||
cbGameType = new javax.swing.JComboBox();
|
||||
chkRollbackTurnsAllowed = new javax.swing.JCheckBox();
|
||||
chkRated = new javax.swing.JCheckBox();
|
||||
lblFreeMulligans = new javax.swing.JLabel();
|
||||
spnFreeMulligans = new javax.swing.JSpinner();
|
||||
lblNumPlayers = new javax.swing.JLabel();
|
||||
|
@ -153,6 +153,9 @@ public class NewTableDialog extends MageDialog {
|
|||
chkRollbackTurnsAllowed.setText("Allow rollbacks");
|
||||
chkRollbackTurnsAllowed.setToolTipText("<HTML>Allow to rollback to the start of previous turns<br>\nif all players agree.\n");
|
||||
|
||||
chkRated.setText("Rated");
|
||||
chkRated.setToolTipText("Indicates if matches will be rated.");
|
||||
|
||||
lblFreeMulligans.setText("Free Mulligans:");
|
||||
lblFreeMulligans.setToolTipText("The number of mulligans a player can use without decreasing the number of drawn cards.");
|
||||
|
||||
|
@ -250,7 +253,9 @@ public class NewTableDialog extends MageDialog {
|
|||
.addComponent(txtPassword, javax.swing.GroupLayout.PREFERRED_SIZE, 125, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, 332, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(chkRated)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(lblQuitRatio)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))))
|
||||
|
@ -310,6 +315,7 @@ public class NewTableDialog extends MageDialog {
|
|||
.addComponent(cbDeckType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lbDeckType)
|
||||
.addComponent(lblQuitRatio)
|
||||
.addComponent(chkRated)
|
||||
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
|
@ -387,6 +393,7 @@ public class NewTableDialog extends MageDialog {
|
|||
options.setRange((RangeOfInfluence) this.cbRange.getSelectedItem());
|
||||
options.setWinsNeeded((Integer) this.spnNumWins.getValue());
|
||||
options.setRollbackTurnsAllowed(chkRollbackTurnsAllowed.isSelected());
|
||||
options.setRated(chkRated.isSelected());
|
||||
options.setFreeMulligans((Integer) this.spnFreeMulligans.getValue());
|
||||
options.setPassword(this.txtPassword.getText());
|
||||
options.setQuitRatio((Integer) this.spnQuitRatio.getValue());
|
||||
|
@ -627,6 +634,7 @@ public class NewTableDialog extends MageDialog {
|
|||
}
|
||||
this.spnNumWins.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_WINS, "2")));
|
||||
this.chkRollbackTurnsAllowed.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED, "Yes").equals("Yes"));
|
||||
this.chkRated.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_RATED, "No").equals("Yes"));
|
||||
this.spnFreeMulligans.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS, "0")));
|
||||
|
||||
int range = Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_RANGE, "1"));
|
||||
|
@ -669,6 +677,7 @@ public class NewTableDialog extends MageDialog {
|
|||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_GAME_TYPE, options.getGameType());
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_WINS, Integer.toString(options.getWinsNeeded()));
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_ROLLBACK_TURNS_ALLOWED, options.isRollbackTurnsAllowed() ? "Yes" : "No");
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_RATED, options.isRated() ? "Yes" : "No");
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_OF_FREE_MULLIGANS, Integer.toString(options.getFreeMulligans()));
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_DECK_FILE, deckFile);
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_PLAYERS, spnNumPlayers.getValue().toString());
|
||||
|
@ -698,6 +707,7 @@ public class NewTableDialog extends MageDialog {
|
|||
private javax.swing.JComboBox cbSkillLevel;
|
||||
private javax.swing.JComboBox cbTimeLimit;
|
||||
private javax.swing.JCheckBox chkRollbackTurnsAllowed;
|
||||
private javax.swing.JCheckBox chkRated;
|
||||
private javax.swing.JLabel jLabel1;
|
||||
private javax.swing.JLabel jLabel2;
|
||||
private javax.swing.JSeparator jSeparator1;
|
||||
|
|
|
@ -175,6 +175,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
lblPlayer1 = new javax.swing.JLabel();
|
||||
lblConstructionTime = new javax.swing.JLabel();
|
||||
chkRollbackTurnsAllowed = new javax.swing.JCheckBox();
|
||||
chkRated = new javax.swing.JCheckBox();
|
||||
spnConstructTime = new javax.swing.JSpinner();
|
||||
player1Panel = new mage.client.table.NewPlayerPanel();
|
||||
pnlPlayers = new javax.swing.JPanel();
|
||||
|
@ -314,6 +315,9 @@ public class NewTournamentDialog extends MageDialog {
|
|||
chkRollbackTurnsAllowed.setText("Allow rollbacks");
|
||||
chkRollbackTurnsAllowed.setToolTipText("<HTML>Allow to rollback to the start of previous turns<br> if all players agree. ");
|
||||
|
||||
chkRated.setText("Rated");
|
||||
chkRated.setToolTipText("Indicates if matches will be rated.");
|
||||
|
||||
spnConstructTime.setToolTipText("The time players have to build their deck.");
|
||||
|
||||
player1Panel.setPreferredSize(new java.awt.Dimension(400, 44));
|
||||
|
@ -416,7 +420,9 @@ public class NewTournamentDialog extends MageDialog {
|
|||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblQuitRatio)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, 60, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.UNRELATED)
|
||||
.addComponent(chkRated))
|
||||
.addComponent(cbTournamentType, javax.swing.GroupLayout.PREFERRED_SIZE, 290, javax.swing.GroupLayout.PREFERRED_SIZE)))
|
||||
.addGroup(layout.createSequentialGroup()
|
||||
.addComponent(lblName)
|
||||
|
@ -462,7 +468,8 @@ public class NewTournamentDialog extends MageDialog {
|
|||
.addComponent(lblNumWins)
|
||||
.addComponent(spnNumWins, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(lblQuitRatio)
|
||||
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addComponent(spnQuitRatio, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addComponent(chkRated))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
|
||||
.addComponent(cbTournamentType, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
|
@ -594,6 +601,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
tOptions.getMatchOptions().setAttackOption(MultiplayerAttackOption.LEFT);
|
||||
tOptions.getMatchOptions().setRange(RangeOfInfluence.ALL);
|
||||
tOptions.getMatchOptions().setRollbackTurnsAllowed(this.chkRollbackTurnsAllowed.isSelected());
|
||||
tOptions.getMatchOptions().setRated(this.chkRated.isSelected());
|
||||
saveTournamentSettingsToPrefs(tOptions);
|
||||
|
||||
table = session.createTournamentTable(roomId, tOptions);
|
||||
|
@ -969,6 +977,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
}
|
||||
this.cbAllowSpectators.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_SPECTATORS, "Yes").equals("Yes"));
|
||||
this.chkRollbackTurnsAllowed.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_ROLLBACKS, "Yes").equals("Yes"));
|
||||
this.chkRated.setSelected(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TOURNAMENT_RATED, "No").equals("Yes"));
|
||||
}
|
||||
|
||||
private void loadBoosterPacks(String packString) {
|
||||
|
@ -1041,6 +1050,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
}
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_SPECTATORS, (tOptions.isWatchingAllowed()?"Yes":"No"));
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_ALLOW_ROLLBACKS, (tOptions.getMatchOptions().isRollbackTurnsAllowed()?"Yes":"No"));
|
||||
PreferencesDialog.saveValue(PreferencesDialog.KEY_NEW_TOURNAMENT_RATED, (tOptions.getMatchOptions().isRated() ? "Yes" : "No"));
|
||||
}
|
||||
|
||||
|
||||
|
@ -1061,6 +1071,7 @@ public class NewTournamentDialog extends MageDialog {
|
|||
private javax.swing.JComboBox cbTimeLimit;
|
||||
private javax.swing.JComboBox cbTournamentType;
|
||||
private javax.swing.JCheckBox chkRollbackTurnsAllowed;
|
||||
private javax.swing.JCheckBox chkRated;
|
||||
private javax.swing.JLabel jLabel6;
|
||||
private javax.swing.JLabel lbDeckType;
|
||||
private javax.swing.JLabel lbSkillLevel;
|
||||
|
|
|
@ -210,6 +210,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
public static final String KEY_NEW_TABLE_NUMBER_PLAYERS = "newTableNumberPlayers";
|
||||
public static final String KEY_NEW_TABLE_PLAYER_TYPES = "newTablePlayerTypes";
|
||||
public static final String KEY_NEW_TABLE_QUIT_RATIO = "newTableQuitRatio";
|
||||
public static final String KEY_NEW_TABLE_RATED = "newTableRated";
|
||||
|
||||
// pref setting for new tournament dialog
|
||||
public static final String KEY_NEW_TOURNAMENT_NAME = "newTournamentName";
|
||||
|
@ -229,6 +230,7 @@ public class PreferencesDialog extends javax.swing.JDialog {
|
|||
public static final String KEY_NEW_TOURNAMENT_ALLOW_ROLLBACKS = "newTournamentAllowRollbacks";
|
||||
public static final String KEY_NEW_TOURNAMENT_DECK_FILE = "newTournamentDeckFile";
|
||||
public static final String KEY_NEW_TOURNAMENT_QUIT_RATIO = "newTournamentQuitRatio";
|
||||
public static final String KEY_NEW_TOURNAMENT_RATED = "newTournamentRated";
|
||||
|
||||
// pref setting for deck generator
|
||||
public static final String KEY_NEW_DECK_GENERATOR_DECK_SIZE = "newDeckGeneratorDeckSize";
|
||||
|
|
|
@ -335,11 +335,17 @@ public class TableWaitingDialog extends MageDialog {
|
|||
|
||||
class TableWaitModel extends AbstractTableModel {
|
||||
|
||||
private final String[] columnNames = new String[]{"Seat", "Loc", "Player Name", "Player Type", "History"};
|
||||
private final String[] columnNames = new String[]{"Seat", "Loc", "Player Name", "Constructed Rating", "Player Type", "History"};
|
||||
private SeatView[] seats = new SeatView[0];
|
||||
private boolean limited;
|
||||
|
||||
public void loadData(TableView table) {
|
||||
seats = table.getSeats().toArray(new SeatView[0]);
|
||||
if (limited != table.isLimited()) {
|
||||
limited = table.isLimited();
|
||||
columnNames[3] = limited ? "Limited Rating" : "Constructed Rating";
|
||||
this.fireTableStructureChanged();
|
||||
}
|
||||
this.fireTableDataChanged();
|
||||
}
|
||||
|
||||
|
@ -368,8 +374,10 @@ class TableWaitModel extends AbstractTableModel {
|
|||
case 2:
|
||||
return seats[arg0].getPlayerName();
|
||||
case 3:
|
||||
return seats[arg0].getPlayerType();
|
||||
return limited ? seats[arg0].getLimitedRating() : seats[arg0].getConstructedRating();
|
||||
case 4:
|
||||
return seats[arg0].getPlayerType();
|
||||
case 5:
|
||||
return seats[arg0].getHistory();
|
||||
}
|
||||
}
|
||||
|
@ -392,6 +400,8 @@ class TableWaitModel extends AbstractTableModel {
|
|||
switch (columnIndex) {
|
||||
case 1:
|
||||
return Icon.class;
|
||||
case 3:
|
||||
return Integer.class;
|
||||
default:
|
||||
return String.class;
|
||||
}
|
||||
|
|
|
@ -316,6 +316,8 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
|||
}
|
||||
basicTooltipText = "<HTML>Name: " + player.getName()
|
||||
+ "<br/>Country: " + countryname
|
||||
+ "<br/>Constructed rating: " + player.getUserData().getConstructedRating()
|
||||
+ "<br/>Limited rating: " + player.getUserData().getLimitedRating()
|
||||
+ "<br/>Deck hash code: " + player.getDeckHashCode()
|
||||
+ "<br/>This match wins: " + player.getWins() + " of " + player.getWinsNeeded() + " (to win the match)"
|
||||
+ (player.getUserData() == null ? "" : "<br/>History: " + player.getUserData().getHistory());
|
||||
|
|
|
@ -72,7 +72,7 @@ public class PlayersChatPanel extends javax.swing.JPanel {
|
|||
|
||||
private final List<String> players = new ArrayList<>();
|
||||
private final UserTableModel userTableModel;
|
||||
private static final int[] DEFAULT_COLUMNS_WIDTH = {20, 100, 40, 100, 40, 100, 80, 80};
|
||||
private static final int[] DEFAULT_COLUMNS_WIDTH = {20, 100, 40, 40, 40, 100, 40, 100, 80, 80};
|
||||
|
||||
|
||||
/*
|
||||
|
@ -152,7 +152,7 @@ public class PlayersChatPanel extends javax.swing.JPanel {
|
|||
|
||||
class UserTableModel extends AbstractTableModel {
|
||||
|
||||
private final String[] columnNames = new String[]{"Loc", "Players", "Matches", "MQP", "Tourneys", "TQP", "Games", "Connection"};
|
||||
private final String[] columnNames = new String[]{"Loc", "Players", "Constructed Rating", "Limited Rating", "Matches", "MQP", "Tourneys", "TQP", "Games", "Connection"};
|
||||
private UsersView[] players = new UsersView[0];
|
||||
|
||||
public void loadData(Collection<RoomUsersView> roomUserInfoList) throws MageRemoteException {
|
||||
|
@ -162,7 +162,7 @@ public class PlayersChatPanel extends javax.swing.JPanel {
|
|||
TableColumnModel tcm = th.getColumnModel();
|
||||
|
||||
tcm.getColumn(jTablePlayers.convertColumnIndexToView(1)).setHeaderValue("Players (" + this.players.length + ")");
|
||||
tcm.getColumn(jTablePlayers.convertColumnIndexToView(6)).setHeaderValue(
|
||||
tcm.getColumn(jTablePlayers.convertColumnIndexToView(8)).setHeaderValue(
|
||||
"Games " + roomUserInfo.getNumberActiveGames()
|
||||
+ (roomUserInfo.getNumberActiveGames() != roomUserInfo.getNumberGameThreads() ? " (T:" + roomUserInfo.getNumberGameThreads() : " (")
|
||||
+ " limit: " + roomUserInfo.getNumberMaxGames() + ")");
|
||||
|
@ -188,16 +188,20 @@ public class PlayersChatPanel extends javax.swing.JPanel {
|
|||
case 1:
|
||||
return players[arg0].getUserName();
|
||||
case 2:
|
||||
return players[arg0].getMatchHistory();
|
||||
return players[arg0].getConstructedRating();
|
||||
case 3:
|
||||
return players[arg0].getMatchQuitRatio();
|
||||
return players[arg0].getLimitedRating();
|
||||
case 4:
|
||||
return players[arg0].getTourneyHistory();
|
||||
return players[arg0].getMatchHistory();
|
||||
case 5:
|
||||
return players[arg0].getTourneyQuitRatio();
|
||||
return players[arg0].getMatchQuitRatio();
|
||||
case 6:
|
||||
return players[arg0].getInfoGames();
|
||||
return players[arg0].getTourneyHistory();
|
||||
case 7:
|
||||
return players[arg0].getTourneyQuitRatio();
|
||||
case 8:
|
||||
return players[arg0].getInfoGames();
|
||||
case 9:
|
||||
return players[arg0].getInfoPing();
|
||||
}
|
||||
return "";
|
||||
|
@ -217,26 +221,32 @@ public class PlayersChatPanel extends javax.swing.JPanel {
|
|||
+ "<br>(the number behind the header text is the number of currently connected users to the server)";
|
||||
break;
|
||||
case 2:
|
||||
tooltipText = "<HTML><b>Constructed player rating</b>";
|
||||
break;
|
||||
case 3:
|
||||
tooltipText = "<HTML><b>Limited player rating</b>";
|
||||
break;
|
||||
case 4:
|
||||
tooltipText = "<HTML><b>Number of matches the user played so far</b>"
|
||||
+ "<br>Q = number of matches quit"
|
||||
+ "<br>I = number of matches lost because of idle timeout"
|
||||
+ "<br>T = number of matches lost because of match timeout";
|
||||
break;
|
||||
case 3:
|
||||
case 5:
|
||||
tooltipText = "<HTML><b>Percent-Ratio of matches played related to matches quit</b>"
|
||||
+ "<br>this calculation does not include tournament matches";
|
||||
break;
|
||||
case 4:
|
||||
case 6:
|
||||
tooltipText = "<HTML><b>Number of tournaments the user played so far</b>"
|
||||
+ "<br>D = number of tournaments left during draft phase"
|
||||
+ "<br>C = number of tournaments left during constructing phase"
|
||||
+ "<br>R = number of tournaments left during rounds";
|
||||
break;
|
||||
case 5:
|
||||
case 7:
|
||||
tooltipText = "<HTML><b>Percent-Ratio of tournament matches played related to tournament matches quit</b>"
|
||||
+ "<br>this calculation does not include non tournament matches";
|
||||
break;
|
||||
case 6:
|
||||
case 8:
|
||||
tooltipText = "<HTML><b>Current activities of the player</b>"
|
||||
+ "<BR>the header itself shows the number of currently active games"
|
||||
+ "<BR>T: = number of games threads "
|
||||
|
@ -245,7 +255,7 @@ public class PlayersChatPanel extends javax.swing.JPanel {
|
|||
+ "<BR><i>(if the number of started games exceed that limit, the games have to wait"
|
||||
+ "<BR>until active games end)</i>";
|
||||
break;
|
||||
case 7:
|
||||
case 9:
|
||||
tooltipText = "<HTML><b>Latency of the user's connection to the server</b>";
|
||||
break;
|
||||
}
|
||||
|
@ -270,8 +280,10 @@ public class PlayersChatPanel extends javax.swing.JPanel {
|
|||
switch (columnIndex) {
|
||||
case 0:
|
||||
return Icon.class;
|
||||
case 2:
|
||||
case 3:
|
||||
case 5:
|
||||
case 7:
|
||||
return Integer.class;
|
||||
default:
|
||||
return String.class;
|
||||
|
|
|
@ -107,7 +107,7 @@ import org.apache.log4j.Logger;
|
|||
public class TablesPanel extends javax.swing.JPanel {
|
||||
|
||||
private static final Logger LOGGER = Logger.getLogger(TablesPanel.class);
|
||||
private static final int[] DEFAULT_COLUMNS_WIDTH = {35, 150, 120, 180, 80, 120, 80, 60, 40, 60};
|
||||
private static final int[] DEFAULT_COLUMNS_WIDTH = {35, 150, 120, 180, 80, 120, 80, 60, 40, 40, 60};
|
||||
|
||||
private TableTableModel tableModel;
|
||||
private MatchesTableModel matchesModel;
|
||||
|
@ -158,7 +158,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
filterButtons = new JToggleButton[]{btnStateWaiting, btnStateActive, btnStateFinished,
|
||||
btnTypeMatch, btnTypeTourneyConstructed, btnTypeTourneyLimited,
|
||||
btnFormatBlock, btnFormatStandard, btnFormatModern, btnFormatLegacy, btnFormatVintage, btnFormatCommander, btnFormatTinyLeader, btnFormatLimited, btnFormatOther,
|
||||
btnSkillBeginner, btnSkillCasual, btnSkillSerious};
|
||||
btnSkillBeginner, btnSkillCasual, btnSkillSerious, btnRated, btnUnrated};
|
||||
|
||||
JComponent[] components = new JComponent[]{chatPanelMain, jSplitPane1, jScrollPaneTablesActive, jScrollPaneTablesFinished, jPanelTop, jPanelTables};
|
||||
for (JComponent component : components) {
|
||||
|
@ -618,7 +618,16 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
skillFilterList.add(RowFilter.regexFilter(SkillLevel.SERIOUS.toString(), TableTableModel.COLUMN_SKILL));
|
||||
}
|
||||
|
||||
if (stateFilterList.isEmpty() || typeFilterList.isEmpty() || formatFilterList.isEmpty() || skillFilterList.isEmpty()) { // no selection
|
||||
List<RowFilter<Object, Object>> ratingFilterList = new ArrayList<>();
|
||||
if (btnRated.isSelected()){
|
||||
ratingFilterList.add(RowFilter.regexFilter("^Rated", TableTableModel.COLUMN_RATING));
|
||||
}
|
||||
if (btnUnrated.isSelected()){
|
||||
ratingFilterList.add(RowFilter.regexFilter("^Unrated", TableTableModel.COLUMN_RATING));
|
||||
}
|
||||
|
||||
if (stateFilterList.isEmpty() || typeFilterList.isEmpty() || formatFilterList.isEmpty()
|
||||
|| skillFilterList.isEmpty() || ratingFilterList.isEmpty()) { // no selection
|
||||
activeTablesSorter.setRowFilter(RowFilter.regexFilter("Nothing", TableTableModel.COLUMN_SKILL));
|
||||
} else {
|
||||
List<RowFilter<Object, Object>> filterList = new ArrayList<>();
|
||||
|
@ -647,6 +656,12 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
filterList.addAll(skillFilterList);
|
||||
}
|
||||
|
||||
if (ratingFilterList.size() > 1) {
|
||||
filterList.add(RowFilter.orFilter(ratingFilterList));
|
||||
} else if (ratingFilterList.size() == 1) {
|
||||
filterList.addAll(ratingFilterList);
|
||||
}
|
||||
|
||||
if (filterList.size() == 1) {
|
||||
activeTablesSorter.setRowFilter(filterList.get(0));
|
||||
} else {
|
||||
|
@ -680,6 +695,9 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
btnSkillBeginner = new javax.swing.JToggleButton();
|
||||
btnSkillCasual = new javax.swing.JToggleButton();
|
||||
btnSkillSerious = new javax.swing.JToggleButton();
|
||||
jSeparator5 = new javax.swing.JToolBar.Separator();
|
||||
btnRated = new javax.swing.JToggleButton();
|
||||
btnUnrated = new javax.swing.JToggleButton();
|
||||
filterBar2 = new javax.swing.JToolBar();
|
||||
btnFormatBlock = new javax.swing.JToggleButton();
|
||||
btnFormatStandard = new javax.swing.JToggleButton();
|
||||
|
@ -883,6 +901,41 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
});
|
||||
filterBar1.add(btnSkillSerious);
|
||||
|
||||
filterBar1.add(jSeparator4);
|
||||
|
||||
btnRated.setSelected(true);
|
||||
btnRated.setText("Rated");
|
||||
btnRated.setToolTipText("Shows all rated tables.");
|
||||
btnRated.setFocusPainted(false);
|
||||
btnRated.setFocusable(false);
|
||||
btnRated.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
btnRated.setRequestFocusEnabled(false);
|
||||
btnRated.setVerifyInputWhenFocusTarget(false);
|
||||
btnRated.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
btnRated.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnFilterActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
filterBar1.add(btnRated);
|
||||
|
||||
btnUnrated.setSelected(true);
|
||||
btnUnrated.setText("Unrated");
|
||||
btnUnrated.setToolTipText("Shows all unrated tables.");
|
||||
btnUnrated.setFocusPainted(false);
|
||||
btnUnrated.setFocusable(false);
|
||||
btnUnrated.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
btnUnrated.setRequestFocusEnabled(false);
|
||||
btnUnrated.setVerifyInputWhenFocusTarget(false);
|
||||
btnUnrated.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
btnUnrated.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnFilterActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
filterBar1.add(btnUnrated);
|
||||
|
||||
// second filter line
|
||||
filterBar2.setFloatable(false);
|
||||
filterBar2.setFocusable(false);
|
||||
filterBar2.setOpaque(false);
|
||||
|
@ -1241,6 +1294,8 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
private javax.swing.JToggleButton btnSkillBeginner;
|
||||
private javax.swing.JToggleButton btnSkillCasual;
|
||||
private javax.swing.JToggleButton btnSkillSerious;
|
||||
private javax.swing.JToggleButton btnRated;
|
||||
private javax.swing.JToggleButton btnUnrated;
|
||||
private javax.swing.JToggleButton btnStateActive;
|
||||
private javax.swing.JToggleButton btnStateFinished;
|
||||
private javax.swing.JToggleButton btnStateWaiting;
|
||||
|
@ -1262,6 +1317,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
private javax.swing.JToolBar.Separator jSeparator2;
|
||||
private javax.swing.JToolBar.Separator jSeparator3;
|
||||
private javax.swing.JToolBar.Separator jSeparator4;
|
||||
private javax.swing.JToolBar.Separator jSeparator5;
|
||||
private javax.swing.JSplitPane jSplitPane1;
|
||||
private javax.swing.JSplitPane jSplitPaneTables;
|
||||
private javax.swing.JTable tableCompleted;
|
||||
|
@ -1282,10 +1338,11 @@ class TableTableModel extends AbstractTableModel {
|
|||
public static final int COLUMN_INFO = 4;
|
||||
public static final int COLUMN_STATUS = 5;
|
||||
public static final int COLUMN_SKILL = 7;
|
||||
public static final int COLUMN_QUIT_RATIO = 8;
|
||||
public static final int ACTION_COLUMN = 9; // column the action is located (starting with 0)
|
||||
public static final int COLUMN_RATING = 8;
|
||||
public static final int COLUMN_QUIT_RATIO = 9;
|
||||
public static final int ACTION_COLUMN = 10; // column the action is located (starting with 0)
|
||||
|
||||
private final String[] columnNames = new String[]{"M/T", "Deck Type", "Owner / Players", "Game Type", "Info", "Status", "Created / Started", "Skill Level", "Quit %", "Action"};
|
||||
private final String[] columnNames = new String[]{"M/T", "Deck Type", "Owner / Players", "Game Type", "Info", "Status", "Created / Started", "Skill Level", "Rating", "Quit %", "Action"};
|
||||
|
||||
private TableView[] tables = new TableView[0];
|
||||
private static final DateFormat timeFormatter = new SimpleDateFormat("HH:mm:ss");
|
||||
|
@ -1332,8 +1389,10 @@ class TableTableModel extends AbstractTableModel {
|
|||
case 7:
|
||||
return tables[arg0].getSkillLevel();
|
||||
case 8:
|
||||
return tables[arg0].getQuitRatio();
|
||||
return tables[arg0].isRated() ? "Rated" : "Unrated";
|
||||
case 9:
|
||||
return tables[arg0].getQuitRatio();
|
||||
case 10:
|
||||
switch (tables[arg0].getTableState()) {
|
||||
|
||||
case WAITING:
|
||||
|
@ -1360,14 +1419,14 @@ class TableTableModel extends AbstractTableModel {
|
|||
default:
|
||||
return "";
|
||||
}
|
||||
case 10:
|
||||
return tables[arg0].isTournament();
|
||||
case 11:
|
||||
return tables[arg0].isTournament();
|
||||
case 12:
|
||||
if (!tables[arg0].getGames().isEmpty()) {
|
||||
return tables[arg0].getGames().get(0);
|
||||
}
|
||||
return null;
|
||||
case 12:
|
||||
case 13:
|
||||
return tables[arg0].getTableId();
|
||||
}
|
||||
return "";
|
||||
|
@ -1495,9 +1554,9 @@ class UpdatePlayersTask extends SwingWorker<Void, Collection<RoomUsersView>> {
|
|||
|
||||
class MatchesTableModel extends AbstractTableModel {
|
||||
|
||||
public static final int ACTION_COLUMN = 6; // column the action is located (starting with 0)
|
||||
public static final int GAMES_LIST_COLUMN = 7;
|
||||
private final String[] columnNames = new String[]{"Deck Type", "Players", "Game Type", "Result", "Start Time", "End Time", "Action"};
|
||||
public static final int ACTION_COLUMN = 7; // column the action is located (starting with 0)
|
||||
public static final int GAMES_LIST_COLUMN = 8;
|
||||
private final String[] columnNames = new String[]{"Deck Type", "Players", "Game Type", "Rating", "Result", "Start Time", "End Time", "Action"};
|
||||
private MatchView[] matches = new MatchView[0];
|
||||
private static final DateFormat timeFormatter = SimpleDateFormat.getDateTimeInstance(DateFormat.SHORT, DateFormat.SHORT);
|
||||
|
||||
|
@ -1526,20 +1585,22 @@ class MatchesTableModel extends AbstractTableModel {
|
|||
case 2:
|
||||
return matches[arg0].getGameType();
|
||||
case 3:
|
||||
return matches[arg0].getResult();
|
||||
return matches[arg0].isRated() ? "Rated" : "Unrated";
|
||||
case 4:
|
||||
return matches[arg0].getResult();
|
||||
case 5:
|
||||
if (matches[arg0].getStartTime() != null) {
|
||||
return timeFormatter.format(matches[arg0].getStartTime());
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
case 5:
|
||||
case 6:
|
||||
if (matches[arg0].getEndTime() != null) {
|
||||
return timeFormatter.format(matches[arg0].getEndTime());
|
||||
} else {
|
||||
return "";
|
||||
}
|
||||
case 6:
|
||||
case 7:
|
||||
if (matches[arg0].isTournament()) {
|
||||
return "Show";
|
||||
} else if (matches[arg0].isReplayAvailable()) {
|
||||
|
@ -1547,7 +1608,7 @@ class MatchesTableModel extends AbstractTableModel {
|
|||
} else {
|
||||
return "None";
|
||||
}
|
||||
case 7:
|
||||
case 8:
|
||||
return matches[arg0].getGames();
|
||||
}
|
||||
return "";
|
||||
|
|
|
@ -58,6 +58,7 @@ public class MatchView implements Serializable {
|
|||
private Date endTime;
|
||||
private boolean replayAvailable;
|
||||
private final boolean isTournament;
|
||||
private boolean rated;
|
||||
|
||||
public MatchView(Table table) {
|
||||
this.tableId = table.getId();
|
||||
|
@ -117,7 +118,7 @@ public class MatchView implements Serializable {
|
|||
this.startTime = match.getStartTime();
|
||||
this.endTime = match.getEndTime();
|
||||
this.replayAvailable = match.isReplayAvailable();
|
||||
|
||||
this.rated = match.getOptions().isRated();
|
||||
}
|
||||
|
||||
// used for tournaments
|
||||
|
@ -153,6 +154,7 @@ public class MatchView implements Serializable {
|
|||
this.startTime = table.getTournament().getStartTime();
|
||||
this.endTime = table.getTournament().getEndTime();
|
||||
this.replayAvailable = false;
|
||||
this.rated = table.getTournament().getOptions().getMatchOptions().isRated();
|
||||
}
|
||||
|
||||
public UUID getMatchId() {
|
||||
|
@ -207,4 +209,7 @@ public class MatchView implements Serializable {
|
|||
return tableId;
|
||||
}
|
||||
|
||||
public boolean isRated() {
|
||||
return rated;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,6 +45,9 @@ public class SeatView implements Serializable {
|
|||
private final String playerName;
|
||||
private final String playerType;
|
||||
private final String history;
|
||||
private final int generalRating;
|
||||
private final int constructedRating;
|
||||
private final int limitedRating;
|
||||
|
||||
public SeatView(Seat seat) {
|
||||
if (seat.getPlayer() != null) {
|
||||
|
@ -53,15 +56,24 @@ public class SeatView implements Serializable {
|
|||
if (seat.getPlayer().getUserData() == null) {
|
||||
this.flagName = UserData.getDefaultFlagName();
|
||||
this.history = "";
|
||||
this.generalRating = 0;
|
||||
this.constructedRating = 0;
|
||||
this.limitedRating = 0;
|
||||
} else {
|
||||
this.flagName = seat.getPlayer().getUserData().getFlagName();
|
||||
this.history = seat.getPlayer().getUserData().getHistory();
|
||||
this.generalRating = seat.getPlayer().getUserData().getGeneralRating();
|
||||
this.constructedRating = seat.getPlayer().getUserData().getConstructedRating();
|
||||
this.limitedRating = seat.getPlayer().getUserData().getLimitedRating();
|
||||
}
|
||||
} else {
|
||||
// Empty seat
|
||||
this.playerName = "";
|
||||
this.flagName = "";
|
||||
this.history = "";
|
||||
this.generalRating = 0;
|
||||
this.constructedRating = 0;
|
||||
this.limitedRating = 0;
|
||||
}
|
||||
this.playerType = seat.getPlayerType();
|
||||
}
|
||||
|
@ -86,4 +98,15 @@ public class SeatView implements Serializable {
|
|||
return history;
|
||||
}
|
||||
|
||||
public int getGeneralRating() {
|
||||
return generalRating;
|
||||
}
|
||||
|
||||
public int getConstructedRating() {
|
||||
return constructedRating;
|
||||
}
|
||||
|
||||
public int getLimitedRating() {
|
||||
return limitedRating;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -63,6 +63,8 @@ public class TableView implements Serializable {
|
|||
private List<SeatView> seats = new ArrayList<>();
|
||||
private List<UUID> games = new ArrayList<>();
|
||||
private final String quitRatio;
|
||||
private final boolean limited;
|
||||
private final boolean rated;
|
||||
|
||||
public TableView(Table table) {
|
||||
this.tableId = table.getId();
|
||||
|
@ -132,6 +134,8 @@ public class TableView implements Serializable {
|
|||
this.additionalInfo = addInfo.toString();
|
||||
this.skillLevel = table.getMatch().getOptions().getSkillLevel();
|
||||
this.quitRatio = Integer.toString(table.getMatch().getOptions().getQuitRatio());
|
||||
this.limited = table.getMatch().getOptions().isLimited();
|
||||
this.rated = table.getMatch().getOptions().isRated();
|
||||
} else {
|
||||
// TOURNAMENT
|
||||
if (table.getTournament().getOptions().getNumberRounds() > 0) {
|
||||
|
@ -179,6 +183,8 @@ public class TableView implements Serializable {
|
|||
this.deckType = table.getDeckType() + " " + table.getTournament().getBoosterInfo() + (tableNameInfo != null ? tableNameInfo : "");
|
||||
this.skillLevel = table.getTournament().getOptions().getMatchOptions().getSkillLevel();
|
||||
this.quitRatio = Integer.toString(table.getTournament().getOptions().getQuitRatio());
|
||||
this.limited = table.getTournament().getOptions().getMatchOptions().isLimited();
|
||||
this.rated = table.getTournament().getOptions().getMatchOptions().isRated();
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -236,4 +242,12 @@ public class TableView implements Serializable {
|
|||
public String getQuitRatio() {
|
||||
return quitRatio;
|
||||
}
|
||||
|
||||
public boolean isLimited() {
|
||||
return limited;
|
||||
}
|
||||
|
||||
public boolean isRated() {
|
||||
return rated;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -45,9 +45,13 @@ public class UsersView implements Serializable {
|
|||
private final int tourneyQuitRatio;
|
||||
private final String infoGames;
|
||||
private final String infoPing;
|
||||
private final int generalRating;
|
||||
private final int constructedRating;
|
||||
private final int limitedRating;
|
||||
|
||||
public UsersView(String flagName, String userName, String matchHistory, int matchQuitRatio,
|
||||
String tourneyHistory, int tourneyQuitRatio, String infoGames, String infoPing) {
|
||||
String tourneyHistory, int tourneyQuitRatio, String infoGames, String infoPing,
|
||||
int generalRating, int constructedRating, int limitedRating) {
|
||||
this.flagName = flagName;
|
||||
this.matchHistory = matchHistory;
|
||||
this.matchQuitRatio = matchQuitRatio;
|
||||
|
@ -56,6 +60,9 @@ public class UsersView implements Serializable {
|
|||
this.userName = userName;
|
||||
this.infoGames = infoGames;
|
||||
this.infoPing = infoPing;
|
||||
this.generalRating = generalRating;
|
||||
this.constructedRating = constructedRating;
|
||||
this.limitedRating = limitedRating;
|
||||
}
|
||||
|
||||
public String getFlagName() {
|
||||
|
@ -90,4 +97,15 @@ public class UsersView implements Serializable {
|
|||
return infoPing;
|
||||
}
|
||||
|
||||
public int getGeneralRating() {
|
||||
return generalRating;
|
||||
}
|
||||
|
||||
public int getConstructedRating() {
|
||||
return constructedRating;
|
||||
}
|
||||
|
||||
public int getLimitedRating() {
|
||||
return limitedRating;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -578,8 +578,11 @@ public class User {
|
|||
}
|
||||
|
||||
public static String userStatsToHistory(ResultProtos.UserStatsProto proto) {
|
||||
// todo: add preference to hide rating?
|
||||
return "Matches:" + userStatsToMatchHistory(proto)
|
||||
+ " Tourneys: " + userStatsToTourneyHistory(proto);
|
||||
+ ", Tourneys: " + userStatsToTourneyHistory(proto)
|
||||
+ ", Constructed Rating: " + userStatsToConstructedRating(proto)
|
||||
+ ", Limited Rating: " + userStatsToLimitedRating(proto);
|
||||
}
|
||||
|
||||
public int getTourneyQuitRatio() {
|
||||
|
|
|
@ -199,14 +199,16 @@ public class UserManager {
|
|||
|
||||
public String getUserHistory(String userName) {
|
||||
User user = getUserByName(userName);
|
||||
if (user == null) {
|
||||
UserStats userStats = UserStatsRepository.instance.getUser(userName);
|
||||
if (userStats == null) {
|
||||
return "User " + userName + " not found";
|
||||
}
|
||||
return "History of user " + userName + ": " + User.userStatsToHistory(userStats.getProto());
|
||||
if (user != null) {
|
||||
return "History of user " + userName + " - " + user.getUserData().getHistory();
|
||||
}
|
||||
return "History of user " + userName + ": " + user.getUserData().getHistory();
|
||||
|
||||
UserStats userStats = UserStatsRepository.instance.getUser(userName);
|
||||
if (userStats != null) {
|
||||
return "History of user " + userName + " - " + User.userStatsToHistory(userStats.getProto());
|
||||
}
|
||||
|
||||
return "User " + userName + " not found";
|
||||
}
|
||||
|
||||
public void updateUserHistory() {
|
||||
|
|
|
@ -116,7 +116,9 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
|||
try {
|
||||
users.add(new UsersView(user.getUserData().getFlagName(), user.getName(),
|
||||
user.getMatchHistory(), user.getMatchQuitRatio(), user.getTourneyHistory(),
|
||||
user.getTourneyQuitRatio(), user.getGameInfo(), user.getPingInfo()));
|
||||
user.getTourneyQuitRatio(), user.getGameInfo(), user.getPingInfo(),
|
||||
user.getUserData().getGeneralRating(), user.getUserData().getConstructedRating(),
|
||||
user.getUserData().getLimitedRating()));
|
||||
} catch (Exception ex) {
|
||||
LOGGER.fatal("User update exception: " + user.getName() + " - " + ex.toString(), ex);
|
||||
users.add(new UsersView(
|
||||
|
@ -127,7 +129,10 @@ public class GamesRoomImpl extends RoomImpl implements GamesRoom, Serializable {
|
|||
user.getTourneyHistory() != null ? user.getTourneyHistory() : "<no tourney history>",
|
||||
user.getTourneyQuitRatio(),
|
||||
"[exception]",
|
||||
user.getPingInfo() != null ? user.getPingInfo() : "<no ping>"));
|
||||
user.getPingInfo() != null ? user.getPingInfo() : "<no ping>",
|
||||
user.getUserData() != null ? user.getUserData().getGeneralRating() : 0,
|
||||
user.getUserData() != null ? user.getUserData().getConstructedRating() : 0,
|
||||
user.getUserData() != null ? user.getUserData().getLimitedRating() : 0));
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -431,7 +431,8 @@ public abstract class MatchImpl implements Match {
|
|||
if (getDraws() > 0) {
|
||||
sb.append(" Draws: ").append(getDraws()).append("<br/>");
|
||||
}
|
||||
sb.append("<br/>").append("You have to win ").append(this.getWinsNeeded()).append(this.getWinsNeeded() == 1 ? " game" : " games").append(" to win the complete match<br/>");
|
||||
sb.append("<br/>").append("Match is ").append(this.getOptions().isRated() ? "" : "not ").append("rated<br/>");
|
||||
sb.append("You have to win ").append(this.getWinsNeeded()).append(this.getWinsNeeded() == 1 ? " game" : " games").append(" to win the complete match<br/>");
|
||||
sb.append("<br/>Game has started<br/><br/>");
|
||||
return sb.toString();
|
||||
}
|
||||
|
|
|
@ -195,7 +195,10 @@ public class UserData implements Serializable {
|
|||
if (UserGroup.COMPUTER.equals(this.groupId)) {
|
||||
return "";
|
||||
}
|
||||
return "Matches: " + this.matchHistory + " (" + this.matchQuitRatio + "%) Tourneys: " + this.tourneyHistory + " (" + this.tourneyQuitRatio + "%)";
|
||||
// todo: add preference to hide rating?
|
||||
return "Matches: " + this.matchHistory + " (" + this.matchQuitRatio + "%), Tourneys: " + this.tourneyHistory + " (" + this.tourneyQuitRatio + "%)"
|
||||
+ ", Constructed Rating: " + getConstructedRating()
|
||||
+ ", Limited Rating: " + getLimitedRating();
|
||||
}
|
||||
|
||||
public void setMatchHistory(String history) {
|
||||
|
|
Loading…
Reference in a new issue