GUI: lobby - improved details info about match (#11438)

This commit is contained in:
ssk97 2023-12-09 04:35:09 -08:00 committed by GitHub
parent 414699f7d4
commit 6cd8649857
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
4 changed files with 148 additions and 108 deletions

View file

@ -96,13 +96,11 @@ public class TablesPanel extends javax.swing.JPanel {
"<b>Match / Tournament settings</b>" "<b>Match / Tournament settings</b>"
+ "<br>Wins = Number of games you need to wins to win a match" + "<br>Wins = Number of games you need to wins to win a match"
+ "<br>Time = Time limit per player" + "<br>Time = Time limit per player"
+ "<br>FM: = Numbers of freee mulligans"
+ "<br>Constr.: = Construction time for limited tournament formats" + "<br>Constr.: = Construction time for limited tournament formats"
+ "<br>RB = Rollback allowed" + "<br>RB = Rollbacks allowed"
+ "<br>PC = Planechase active"
+ "<br>EC = One or more emblem cards in use"
+ "<br>SP = Spectators allowed" + "<br>SP = Spectators allowed"
+ "<br>Rng: Range of visibility for multiplayer matches" + "<br>Rng: Range of visibility for multiplayer matches"
+ "<br>Custom options: Nonstandard options, hover for details"
) )
.addColumn(7, 120, String.class, "Status", .addColumn(7, 120, String.class, "Status",
"<b>Table status</b><br>" "<b>Table status</b><br>"

View file

@ -1,5 +1,7 @@
package mage.view; package mage.view;
import mage.cards.decks.DeckCardInfo;
import mage.constants.MatchBufferTime;
import mage.constants.SkillLevel; import mage.constants.SkillLevel;
import mage.constants.TableState; import mage.constants.TableState;
import mage.game.Game; import mage.game.Game;
@ -97,45 +99,30 @@ public class TableView implements Serializable {
} }
this.controllerName += sb.toString(); this.controllerName += sb.toString();
this.deckType = table.getDeckType(); this.deckType = table.getDeckType();
StringBuilder addInfo = new StringBuilder(); StringBuilder infoTextShort = new StringBuilder();
StringBuilder infoTextLong = new StringBuilder();
if (table.getMatch().getGames().isEmpty()) { if (table.getMatch().getGames().isEmpty()) {
addInfo.append("Wins:").append(table.getMatch().getWinsNeeded()); infoTextShort.append("Wins: ").append(table.getMatch().getWinsNeeded());
addInfo.append(" Time: ").append(table.getMatch().getOptions().getMatchTimeLimit().toString()); infoTextLong.append("Wins required: ").append(table.getMatch().getWinsNeeded())
addInfo.append(" Buffer: ").append(table.getMatch().getOptions().getMatchBufferTime().toString()); .append(" (Best of ").append(table.getMatch().getWinsNeeded()*2-1).append(")");
if (table.getMatch().getOptions().getMulliganType() != MulliganType.GAME_DEFAULT) { buildMatchOptionsTextShared(table.getMatch().getOptions(),infoTextShort,infoTextLong);
addInfo.append(" Mulligan: \"").append(table.getMatch().getOptions().getMulliganType().toString()).append("\"");
}
if (table.getMatch().getFreeMulligans() > 0) {
addInfo.append(" FM: ").append(table.getMatch().getFreeMulligans());
}
if (table.getMatch().getOptions().isCustomStartLifeEnabled()) {
addInfo.append(" StartLife: ").append(table.getMatch().getOptions().getCustomStartLife());
}
if (table.getMatch().getOptions().isCustomStartHandSizeEnabled()) {
addInfo.append(" StartHandSize: ").append(table.getMatch().getOptions().getCustomStartHandSize());
}
} else { } else {
addInfo.append("Wins:").append(table.getMatch().getWinsNeeded()); infoTextShort.append("Wins: ").append(table.getMatch().getWinsNeeded()).append(sbScore);
addInfo.append(sbScore.toString()); infoTextLong.append("Wins required: ").append(table.getMatch().getWinsNeeded()).append(sbScore);
}
if (table.getMatch().getOptions().isRollbackTurnsAllowed()) {
addInfo.append(" RB");
}
if (table.getMatch().getOptions().isPlaneChase()) {
addInfo.append(" PC");
}
if (!(table.getMatch().getOptions().getPerPlayerEmblemCards().isEmpty())
|| !(table.getMatch().getOptions().getGlobalEmblemCards().isEmpty())) {
addInfo.append(" EC");
} }
infoTextLong.append("<br>Seats: ").append(this.seatsInfo);
if (table.getMatch().getOptions().isSpectatorsAllowed()) { if (table.getMatch().getOptions().isSpectatorsAllowed()) {
addInfo.append(" SP"); infoTextShort.append(", SP");
infoTextLong.append("<br>Spectators allowed (SP)");
} }
infoTextLong.append("<br>Game type: ").append(table.getGameType());
infoTextLong.append("<br>Deck type: ").append(table.getDeckType());
if (table.getNumberOfSeats() > 3) { if (table.getNumberOfSeats() > 3) {
addInfo.append(" Rng: ").append(table.getMatch().getOptions().getRange().toString()); infoTextShort.append(", Rng: ").append(table.getMatch().getOptions().getRange().toString());
infoTextLong.append("<br>Range of Influence: ").append(table.getMatch().getOptions().getRange().toString());
} }
this.additionalInfoShort = addInfo.toString(); this.additionalInfoShort = infoTextShort.toString();
this.additionalInfoFull = addInfo.toString(); // TODO: add tooltip details here this.additionalInfoFull = infoTextLong.toString();
this.skillLevel = table.getMatch().getOptions().getSkillLevel(); this.skillLevel = table.getMatch().getOptions().getSkillLevel();
this.quitRatio = Integer.toString(table.getMatch().getOptions().getQuitRatio()); this.quitRatio = Integer.toString(table.getMatch().getOptions().getQuitRatio());
this.minimumRating = Integer.toString(table.getMatch().getOptions().getMinimumRating()); this.minimumRating = Integer.toString(table.getMatch().getOptions().getMinimumRating());
@ -146,7 +133,7 @@ public class TableView implements Serializable {
} else { } else {
// TOURNAMENT // 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 = this.gameType + ' ' + table.getTournament().getOptions().getNumberRounds() + " Rounds";
} }
StringBuilder sb1 = new StringBuilder(); StringBuilder sb1 = new StringBuilder();
for (TournamentPlayer tp : table.getTournament().getPlayers()) { for (TournamentPlayer tp : table.getTournament().getPlayers()) {
@ -156,10 +143,13 @@ public class TableView implements Serializable {
} }
this.controllerName += sb1.toString(); this.controllerName += sb1.toString();
this.seatsInfo = "" + table.getTournament().getPlayers().size() + "/" + table.getNumberOfSeats(); this.seatsInfo = "" + table.getTournament().getPlayers().size() + "/" + table.getNumberOfSeats();
StringBuilder infoText = new StringBuilder(); StringBuilder infoTextShort = new StringBuilder();
StringBuilder infoTextLong = new StringBuilder();
StringBuilder stateText = new StringBuilder(table.getState().toString()); StringBuilder stateText = new StringBuilder(table.getState().toString());
infoText.append("Wins:").append(table.getTournament().getOptions().getMatchOptions().getWinsNeeded()); infoTextShort.append("Wins: ").append(table.getTournament().getOptions().getMatchOptions().getWinsNeeded());
infoText.append(" Seats: ").append(this.seatsInfo); infoTextLong.append("Wins required: ").append(table.getTournament().getOptions().getMatchOptions().getWinsNeeded())
.append(" (Best of ").append(table.getTournament().getOptions().getMatchOptions().getWinsNeeded()*2-1).append(")");
infoTextLong.append("<br>Seats: ").append(this.seatsInfo);
switch (table.getState()) { switch (table.getState()) {
case WAITING: case WAITING:
case READY_TO_START: case READY_TO_START:
@ -167,42 +157,25 @@ public class TableView implements Serializable {
if (TableState.WAITING.equals(table.getState())) { if (TableState.WAITING.equals(table.getState())) {
stateText.append(" (").append(table.getTournament().getPlayers().size()).append('/').append(table.getNumberOfSeats()).append(')'); stateText.append(" (").append(table.getTournament().getPlayers().size()).append('/').append(table.getNumberOfSeats()).append(')');
} }
MatchOptions tourneyMatchOptions = table.getTournament().getOptions().getMatchOptions(); buildMatchOptionsTextShared(table.getTournament().getOptions().getMatchOptions(), infoTextShort, infoTextLong);
infoText.append(" Time: ").append(tourneyMatchOptions.getMatchTimeLimit().toString());
infoText.append(" Buffer: ").append(tourneyMatchOptions.getMatchBufferTime().toString());
if (tourneyMatchOptions.getMulliganType() != MulliganType.GAME_DEFAULT) {
infoText.append(" Mulligan: \"").append(tourneyMatchOptions.getMulliganType().toString()).append("\"");
}
if (tourneyMatchOptions.getFreeMulligans() > 0) {
infoText.append(" FM: ").append(tourneyMatchOptions.getFreeMulligans());
}
if (tourneyMatchOptions.isCustomStartLifeEnabled()) {
infoText.append(" StartLife: ").append(tourneyMatchOptions.getCustomStartLife());
}
if (tourneyMatchOptions.isCustomStartHandSizeEnabled()) {
infoText.append(" StartHandSize: ").append(tourneyMatchOptions.getCustomStartHandSize());
}
if (table.getTournament().getTournamentType().isLimited()) { if (table.getTournament().getTournamentType().isLimited()) {
infoText.append(" Constr.: ").append(table.getTournament().getOptions().getLimitedOptions().getConstructionTime() / 60).append(" Min."); infoTextShort.append(", Constr.: ").append(table.getTournament().getOptions().getLimitedOptions().getConstructionTime() / 60).append("m");
infoTextLong.append("<br>Construction time: ").append(table.getTournament().getOptions().getLimitedOptions().getConstructionTime() / 60).append(" Minutes");
} }
if (table.getTournament().getOptions().getLimitedOptions() instanceof DraftOptions) { if (table.getTournament().getOptions().getLimitedOptions() instanceof DraftOptions) {
DraftOptions draftOptions = (DraftOptions) table.getTournament().getOptions().getLimitedOptions(); DraftOptions draftOptions = (DraftOptions) table.getTournament().getOptions().getLimitedOptions();
infoText.append(" Pick time: ").append(draftOptions.getTiming().getShortName()); infoTextShort.append(", Pick time: ").append(draftOptions.getTiming().getShortName());
} infoTextLong.append("<br>Pick time: ").append(draftOptions.getTiming().getName());
if (tourneyMatchOptions.isRollbackTurnsAllowed()) {
infoText.append(" RB");
}
if (tourneyMatchOptions.isPlaneChase()) {
infoText.append(" PC");
}
if (!(table.getTournament().getOptions().getMatchOptions().getPerPlayerEmblemCards().isEmpty())
|| !(table.getTournament().getOptions().getMatchOptions().getGlobalEmblemCards().isEmpty())) {
infoText.append(" EC");
} }
if (table.getTournament().getOptions().isWatchingAllowed()) { if (table.getTournament().getOptions().isWatchingAllowed()) {
infoText.append(" SP"); infoTextShort.append(", SP");
infoTextLong.append("<br>Spectators allowed (SP)");
}
infoTextLong.append("<br>Game type: ").append(table.getGameType());
infoTextLong.append("<br>Deck type: ").append(table.getDeckType());
if (!table.getTournament().getBoosterInfo().isEmpty()){
infoTextLong.append("<br>Boosters: ").append(table.getTournament().getBoosterInfo());
} }
break; break;
case DUELING: case DUELING:
stateText.append(" Round: ").append(table.getTournament().getRounds().size()); stateText.append(" Round: ").append(table.getTournament().getRounds().size());
@ -215,8 +188,8 @@ public class TableView implements Serializable {
break; break;
default: default:
} }
this.additionalInfoShort = infoText.toString(); this.additionalInfoShort = infoTextShort.toString();
this.additionalInfoFull = infoText.toString(); // TODO: add tooltip details here this.additionalInfoFull = infoTextLong.toString();
this.tableStateText = stateText.toString(); this.tableStateText = stateText.toString();
this.deckType = table.getDeckType() + ' ' + table.getTournament().getBoosterInfo(); this.deckType = table.getDeckType() + ' ' + table.getTournament().getBoosterInfo();
this.skillLevel = table.getTournament().getOptions().getMatchOptions().getSkillLevel(); this.skillLevel = table.getTournament().getOptions().getMatchOptions().getSkillLevel();
@ -229,6 +202,53 @@ public class TableView implements Serializable {
} }
} }
private void buildMatchOptionsTextShared(MatchOptions options, StringBuilder shortBuilder, StringBuilder longBuilder){
longBuilder.append("<br>Time: ").append(options.getMatchTimeLimit().toString());
shortBuilder.append(", Time: ").append(options.getMatchTimeLimit().getShortName());
if (options.getMatchBufferTime() != MatchBufferTime.NONE){
shortBuilder.append("(+").append(options.getMatchBufferTime().getShortName()).append(")");
longBuilder.append("<br>Buffer time: ").append(options.getMatchBufferTime().toString());
}
int customOptions = 0;
if (options.getMulliganType() != MulliganType.GAME_DEFAULT) {
longBuilder.append("<br>Mulligan: \"").append(options.getMulliganType().toString()).append("\"");
customOptions += 1;
}
if (options.getFreeMulligans() > 0) {
longBuilder.append("<br>Free Mulligans: ").append(options.getFreeMulligans());
customOptions += 1;
}
if (options.isCustomStartLifeEnabled()) {
longBuilder.append("<br>Starting Life: ").append(options.getCustomStartLife());
customOptions += 1;
}
if (options.isCustomStartHandSizeEnabled()) {
longBuilder.append("<br>Starting Hand Size: ").append(options.getCustomStartHandSize());
customOptions += 1;
}
if (options.isPlaneChase()) {
longBuilder.append("<br>Planechase");
customOptions += 1;
}
if (!(options.getPerPlayerEmblemCards().isEmpty())
|| !(options.getGlobalEmblemCards().isEmpty())) {
longBuilder.append("<br>Emblem cards:");
for(DeckCardInfo card: options.getPerPlayerEmblemCards()){
longBuilder.append("<br>* <b>").append(card.getCardName()).append("</b> (per player)");
}
for(DeckCardInfo card: options.getGlobalEmblemCards()){
longBuilder.append("<br>* <b>").append(card.getCardName()).append("</b> (global)");
}
customOptions += 1;
}
if (customOptions > 0){
shortBuilder.append(", Custom options (").append(customOptions).append(")");
}
if (options.isRollbackTurnsAllowed()) {
shortBuilder.append(", RB");
longBuilder.append("<br>Rollbacks allowed (RB)");
}
}
public UUID getTableId() { public UUID getTableId() {
return tableId; return tableId;
} }

View file

@ -10,23 +10,21 @@ package mage.constants;
* @author alexander-novo * @author alexander-novo
*/ */
public enum MatchBufferTime { public enum MatchBufferTime {
NONE(0, "None"), NONE(0),
SEC__01(1, "1 Second"), SEC__01(1),
SEC__02(2, "2 Seconds"), SEC__02(2),
SEC__03(3, "3 Seconds"), SEC__03(3),
SEC__05(5, "5 Seconds"), SEC__05(5),
SEC__10(10, "10 Seconds"), SEC__10(10),
SEC__15(15, "15 Seconds"), SEC__15(15),
SEC__20(20, "20 Seconds"), SEC__20(20),
SEC__25(25, "25 Seconds"), SEC__25(25),
SEC__30(30, "30 Seconds"); SEC__30(30);
private final int bufferSecs; private final int bufferSecs;
private final String name;
MatchBufferTime(int bufferSecs, String name) { MatchBufferTime(int bufferSecs) {
this.bufferSecs = bufferSecs; this.bufferSecs = bufferSecs;
this.name = name;
} }
public int getBufferSecs() { public int getBufferSecs() {
@ -34,11 +32,25 @@ public enum MatchBufferTime {
} }
public String getName() { public String getName() {
return name; if (this == NONE){
return "None";
} else if (this == SEC__01){
return "1 Second";
} else {
return bufferSecs + " Seconds";
}
} }
@Override @Override
public String toString() { public String toString() {
return name; return getName();
}
public String getShortName() {
if (this == NONE){
return "None";
} else {
return bufferSecs + "s";
}
} }
} }

View file

@ -7,27 +7,25 @@ package mage.constants;
* @author LevelX2 * @author LevelX2
*/ */
public enum MatchTimeLimit { public enum MatchTimeLimit {
NONE(0,"None"), NONE(0),
MIN__10(600, "10 Minutes"), MIN__10(600),
MIN__15(900, "15 Minutes"), MIN__15(900),
MIN__20(1200, "20 Minutes"), MIN__20(1200),
MIN__25(1500, "25 Minutes"), MIN__25(1500),
MIN__30(1800, "30 Minutes"), MIN__30(1800),
MIN__35(2100, "35 Minutes"), MIN__35(2100),
MIN__40(2400, "40 Minutes"), MIN__40(2400),
MIN__45(2700, "45 Minutes"), MIN__45(2700),
MIN__50(3000, "50 Minutes"), MIN__50(3000),
MIN__55(3300, "55 Minutes"), MIN__55(3300),
MIN__60(3600, "60 Minutes"), MIN__60(3600),
MIN__90(5400, "90 Minutes"), MIN__90(5400),
MIN_120(7200, "120 Minutes"); MIN_120(7200);
private final int prioritySecs; private final int prioritySecs;
private final String name;
MatchTimeLimit(int prioritySecs, String name) { MatchTimeLimit(int prioritySecs) {
this.prioritySecs = prioritySecs; this.prioritySecs = prioritySecs;
this.name = name;
} }
public int getPrioritySecs() { public int getPrioritySecs() {
@ -35,11 +33,23 @@ public enum MatchTimeLimit {
} }
public String getName() { public String getName() {
return name; if (this == NONE){
return "None";
} else {
return (prioritySecs/60)+" Minutes";
}
} }
@Override @Override
public String toString() { public String toString() {
return name; return getName();
}
public String getShortName() {
if (this == NONE){
return "None";
} else {
return (prioritySecs/60) + "m";
}
} }
} }