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

@ -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;
@ -97,45 +99,30 @@ public class TableView implements Serializable {
}
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());
@ -146,7 +133,7 @@ public class TableView implements Serializable {
} 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()) {
@ -156,10 +143,13 @@ public class TableView implements Serializable {
}
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:
@ -167,42 +157,25 @@ public class TableView implements Serializable {
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());
@ -215,8 +188,8 @@ public class TableView implements Serializable {
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();
@ -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() {
return tableId;
}