Skip to content

Commit

Permalink
GUI: lobby - improved details info about match (#11438)
Browse files Browse the repository at this point in the history
  • Loading branch information
ssk97 authored Dec 9, 2023
1 parent 414699f commit 6cd8649
Show file tree
Hide file tree
Showing 4 changed files with 148 additions and 108 deletions.
12 changes: 5 additions & 7 deletions Mage.Client/src/main/java/mage/client/table/TablesPanel.java
Original file line number Diff line number Diff line change
Expand Up @@ -94,15 +94,13 @@ public class TablesPanel extends javax.swing.JPanel {
.addColumn(5, 180, String.class, "Game Type",null)
.addColumn(6, 80, String.class, "Info",
"<b>Match / Tournament settings</b>"
+ "<br>Wins = Number of games you need to wins to win a match"
+ "<br>Time = Time limit per player"
+ "<br>FM: = Numbers of freee mulligans"
+ "<br>Constr.: = Construction time for limited tournament formats"
+ "<br>RB = Rollback allowed"
+ "<br>PC = Planechase active"
+ "<br>EC = One or more emblem cards in use"
+ "<br>Wins = Number of games you need to wins to win a match"
+ "<br>Time = Time limit per player"
+ "<br>Constr.: = Construction time for limited tournament formats"
+ "<br>RB = Rollbacks allowed"
+ "<br>SP = Spectators allowed"
+ "<br>Rng: Range of visibility for multiplayer matches"
+ "<br>Custom options: Nonstandard options, hover for details"
)
.addColumn(7, 120, String.class, "Status",
"<b>Table status</b><br>"
Expand Down
154 changes: 87 additions & 67 deletions Mage.Common/src/main/java/mage/view/TableView.java
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
package mage.view;

import mage.cards.decks.DeckCardInfo;
import mage.constants.MatchBufferTime;
import mage.constants.SkillLevel;
import mage.constants.TableState;
import mage.game.Game;
Expand Down Expand Up @@ -97,45 +99,30 @@ public TableView(Table table) {
}
this.controllerName += sb.toString();
this.deckType = table.getDeckType();
StringBuilder addInfo = new StringBuilder();
StringBuilder infoTextShort = new StringBuilder();
StringBuilder infoTextLong = new StringBuilder();
if (table.getMatch().getGames().isEmpty()) {
addInfo.append("Wins:").append(table.getMatch().getWinsNeeded());
addInfo.append(" Time: ").append(table.getMatch().getOptions().getMatchTimeLimit().toString());
addInfo.append(" Buffer: ").append(table.getMatch().getOptions().getMatchBufferTime().toString());
if (table.getMatch().getOptions().getMulliganType() != MulliganType.GAME_DEFAULT) {
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());
}
infoTextShort.append("Wins: ").append(table.getMatch().getWinsNeeded());
infoTextLong.append("Wins required: ").append(table.getMatch().getWinsNeeded())
.append(" (Best of ").append(table.getMatch().getWinsNeeded()*2-1).append(")");
buildMatchOptionsTextShared(table.getMatch().getOptions(),infoTextShort,infoTextLong);
} else {
addInfo.append("Wins:").append(table.getMatch().getWinsNeeded());
addInfo.append(sbScore.toString());
}
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");
infoTextShort.append("Wins: ").append(table.getMatch().getWinsNeeded()).append(sbScore);
infoTextLong.append("Wins required: ").append(table.getMatch().getWinsNeeded()).append(sbScore);
}
infoTextLong.append("<br>Seats: ").append(this.seatsInfo);
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) {
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.additionalInfoFull = addInfo.toString(); // TODO: add tooltip details here
this.additionalInfoShort = infoTextShort.toString();
this.additionalInfoFull = infoTextLong.toString();
this.skillLevel = table.getMatch().getOptions().getSkillLevel();
this.quitRatio = Integer.toString(table.getMatch().getOptions().getQuitRatio());
this.minimumRating = Integer.toString(table.getMatch().getOptions().getMinimumRating());
Expand All @@ -146,7 +133,7 @@ public TableView(Table table) {
} else {
// TOURNAMENT
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();
for (TournamentPlayer tp : table.getTournament().getPlayers()) {
Expand All @@ -156,53 +143,39 @@ public TableView(Table table) {
}
this.controllerName += sb1.toString();
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());
infoText.append("Wins:").append(table.getTournament().getOptions().getMatchOptions().getWinsNeeded());
infoText.append(" Seats: ").append(this.seatsInfo);
infoTextShort.append("Wins: ").append(table.getTournament().getOptions().getMatchOptions().getWinsNeeded());
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()) {
case WAITING:
case READY_TO_START:
case STARTING:
if (TableState.WAITING.equals(table.getState())) {
stateText.append(" (").append(table.getTournament().getPlayers().size()).append('/').append(table.getNumberOfSeats()).append(')');
}
MatchOptions tourneyMatchOptions = table.getTournament().getOptions().getMatchOptions();
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());
}
buildMatchOptionsTextShared(table.getTournament().getOptions().getMatchOptions(), infoTextShort, infoTextLong);
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) {
DraftOptions draftOptions = (DraftOptions) table.getTournament().getOptions().getLimitedOptions();
infoText.append(" Pick time: ").append(draftOptions.getTiming().getShortName());
}
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");
infoTextShort.append(", Pick time: ").append(draftOptions.getTiming().getShortName());
infoTextLong.append("<br>Pick time: ").append(draftOptions.getTiming().getName());
}
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;
case DUELING:
stateText.append(" Round: ").append(table.getTournament().getRounds().size());
Expand All @@ -215,8 +188,8 @@ public TableView(Table table) {
break;
default:
}
this.additionalInfoShort = infoText.toString();
this.additionalInfoFull = infoText.toString(); // TODO: add tooltip details here
this.additionalInfoShort = infoTextShort.toString();
this.additionalInfoFull = infoTextLong.toString();
this.tableStateText = stateText.toString();
this.deckType = table.getDeckType() + ' ' + table.getTournament().getBoosterInfo();
this.skillLevel = table.getTournament().getOptions().getMatchOptions().getSkillLevel();
Expand All @@ -229,6 +202,53 @@ public TableView(Table table) {
}
}

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() {
return tableId;
}
Expand Down
42 changes: 27 additions & 15 deletions Mage/src/main/java/mage/constants/MatchBufferTime.java
Original file line number Diff line number Diff line change
Expand Up @@ -10,35 +10,47 @@
* @author alexander-novo
*/
public enum MatchBufferTime {
NONE(0, "None"),
SEC__01(1, "1 Second"),
SEC__02(2, "2 Seconds"),
SEC__03(3, "3 Seconds"),
SEC__05(5, "5 Seconds"),
SEC__10(10, "10 Seconds"),
SEC__15(15, "15 Seconds"),
SEC__20(20, "20 Seconds"),
SEC__25(25, "25 Seconds"),
SEC__30(30, "30 Seconds");
NONE(0),
SEC__01(1),
SEC__02(2),
SEC__03(3),
SEC__05(5),
SEC__10(10),
SEC__15(15),
SEC__20(20),
SEC__25(25),
SEC__30(30);

private final int bufferSecs;
private final String name;

MatchBufferTime(int bufferSecs, String name) {
MatchBufferTime(int bufferSecs) {
this.bufferSecs = bufferSecs;
this.name = name;
}

public int getBufferSecs() {
return bufferSecs;
}

public String getName() {
return name;
if (this == NONE){
return "None";
} else if (this == SEC__01){
return "1 Second";
} else {
return bufferSecs + " Seconds";
}
}

@Override
public String toString() {
return name;
return getName();
}

public String getShortName() {
if (this == NONE){
return "None";
} else {
return bufferSecs + "s";
}
}
}
48 changes: 29 additions & 19 deletions Mage/src/main/java/mage/constants/MatchTimeLimit.java
Original file line number Diff line number Diff line change
Expand Up @@ -7,39 +7,49 @@
* @author LevelX2
*/
public enum MatchTimeLimit {
NONE(0,"None"),
MIN__10(600, "10 Minutes"),
MIN__15(900, "15 Minutes"),
MIN__20(1200, "20 Minutes"),
MIN__25(1500, "25 Minutes"),
MIN__30(1800, "30 Minutes"),
MIN__35(2100, "35 Minutes"),
MIN__40(2400, "40 Minutes"),
MIN__45(2700, "45 Minutes"),
MIN__50(3000, "50 Minutes"),
MIN__55(3300, "55 Minutes"),
MIN__60(3600, "60 Minutes"),
MIN__90(5400, "90 Minutes"),
MIN_120(7200, "120 Minutes");
NONE(0),
MIN__10(600),
MIN__15(900),
MIN__20(1200),
MIN__25(1500),
MIN__30(1800),
MIN__35(2100),
MIN__40(2400),
MIN__45(2700),
MIN__50(3000),
MIN__55(3300),
MIN__60(3600),
MIN__90(5400),
MIN_120(7200);

private final int prioritySecs;
private final String name;

MatchTimeLimit(int prioritySecs, String name) {
MatchTimeLimit(int prioritySecs) {
this.prioritySecs = prioritySecs;
this.name = name;
}

public int getPrioritySecs() {
return prioritySecs;
}

public String getName() {
return name;
if (this == NONE){
return "None";
} else {
return (prioritySecs/60)+" Minutes";
}
}

@Override
public String toString() {
return name;
return getName();
}

public String getShortName() {
if (this == NONE){
return "None";
} else {
return (prioritySecs/60) + "m";
}
}
}

0 comments on commit 6cd8649

Please sign in to comment.