GUI, table: allow unlimited draft bots amount, fixed computer names in 10+ tables (part of #13701)

This commit is contained in:
Oleg Agafonov 2025-05-31 13:10:03 +04:00
parent 336ab738f0
commit 2e7e78d1e5
10 changed files with 40 additions and 27 deletions

View file

@ -41,7 +41,7 @@ public class NewTournamentDialog extends MageDialog {
private static final Logger logger = Logger.getLogger(NewTournamentDialog.class);
// it's ok to have 4 players at the screen, 6 is fine for big screens too
private static final int MAX_PLAYERS_PER_GAME = 6;
private static final int MAX_WORKABLE_PLAYERS_PER_GAME = 6;
// temp settings on loading players list
private final List<PlayerType> prefPlayerTypes = new ArrayList<>();
@ -699,12 +699,12 @@ public class NewTournamentDialog extends MageDialog {
// draft bots are loses and hide at the start, so count only human and AI
if (tOptions.getMatchOptions().isSingleGameTourney()) {
int workablePlayers = tOptions.getPlayerTypes().stream()
.mapToInt(p -> p.equals(PlayerType.COMPUTER_DRAFT_BOT) ? 0 : 1)
.mapToInt(p -> p.isWorkablePlayer() ? 1 : 0)
.sum();
if (workablePlayers > MAX_PLAYERS_PER_GAME) {
if (workablePlayers > MAX_WORKABLE_PLAYERS_PER_GAME) {
JOptionPane.showMessageDialog(
MageFrame.getDesktop(),
String.format("Warning, in single game mode you can choose %d human/ai players but selected %d", MAX_PLAYERS_PER_GAME, workablePlayers),
String.format("Warning, in single game mode you can choose %d human/ai players but selected %d", MAX_WORKABLE_PLAYERS_PER_GAME, workablePlayers),
"Warning",
JOptionPane.WARNING_MESSAGE
);

View file

@ -41,6 +41,10 @@ public class TablePlayerPanel extends javax.swing.JPanel {
this.newPlayerPanel.setSkillLevel(playerSkill);
}
public static String extractAiPlayerNumberFromLabel(String label) {
return ClientDefaultSettings.computerName + " " + label.substring(Math.max(0, label.length() - 2)).trim();
}
public boolean joinTable(UUID roomId, UUID tableId) throws IOException, ClassNotFoundException {
if (this.cbPlayerType.getSelectedItem() != PlayerType.HUMAN) {
return SessionHandler.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), (PlayerType) this.cbPlayerType.getSelectedItem(), this.newPlayerPanel.getSkillLevel(), DeckImporter.importDeckFromFile(this.newPlayerPanel.getDeckFile(), true), "");
@ -124,7 +128,7 @@ public class TablePlayerPanel extends javax.swing.JPanel {
private void cbPlayerTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbPlayerTypeActionPerformed
if (getPlayerType() != PlayerType.HUMAN) {
this.newPlayerPanel.setVisible(true);
this.newPlayerPanel.setPlayerName(ClientDefaultSettings.computerName + " " + this.lblPlayerNum.getText().charAt(this.lblPlayerNum.getText().length() - 1));
this.newPlayerPanel.setPlayerName(extractAiPlayerNumberFromLabel(this.lblPlayerNum.getText()));
} else {
this.newPlayerPanel.setVisible(false);
}

View file

@ -201,7 +201,7 @@
<Component class="javax.swing.JToggleButton" name="btnTypeTourneyConstructed">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Constructed tourn."/>
<Property name="text" type="java.lang.String" value="Constructed tourney"/>
<Property name="toolTipText" type="java.lang.String" value="Shows all constructed tournament tables."/>
<Property name="actionCommand" type="java.lang.String" value="typeTourneyConstructed"/>
<Property name="focusPainted" type="boolean" value="false"/>
@ -216,7 +216,7 @@
<Component class="javax.swing.JToggleButton" name="btnTypeTourneyLimited">
<Properties>
<Property name="selected" type="boolean" value="true"/>
<Property name="text" type="java.lang.String" value="Limited tourn."/>
<Property name="text" type="java.lang.String" value="Limited tourney"/>
<Property name="toolTipText" type="java.lang.String" value="Shows all limited tournament tables."/>
<Property name="actionCommand" type="java.lang.String" value="typeTourneyLimited"/>
<Property name="focusPainted" type="boolean" value="false"/>

View file

@ -1163,7 +1163,7 @@ public class TablesPanel extends javax.swing.JPanel {
filterBar1.add(btnTypeMatch);
btnTypeTourneyConstructed.setSelected(true);
btnTypeTourneyConstructed.setText("Constructed tourn.");
btnTypeTourneyConstructed.setText("Constructed tourney");
btnTypeTourneyConstructed.setToolTipText("Shows all constructed tournament tables.");
btnTypeTourneyConstructed.setActionCommand("typeTourneyConstructed");
btnTypeTourneyConstructed.setFocusPainted(false);
@ -1178,7 +1178,7 @@ public class TablesPanel extends javax.swing.JPanel {
filterBar1.add(btnTypeTourneyConstructed);
btnTypeTourneyLimited.setSelected(true);
btnTypeTourneyLimited.setText("Limited tourn.");
btnTypeTourneyLimited.setText("Limited tourney");
btnTypeTourneyLimited.setToolTipText("Shows all limited tournament tables.");
btnTypeTourneyLimited.setActionCommand("typeTourneyLimited");
btnTypeTourneyLimited.setFocusPainted(false);

View file

@ -145,7 +145,7 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
private void cbPlayerTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbPlayerTypeActionPerformed
if (this.cbPlayerType.getSelectedItem() != PlayerType.HUMAN) {
this.pnlPlayerName.setVisible(true);
this.txtPlayerName.setText(ClientDefaultSettings.computerName + " " + this.lblPlayerNum.getText().charAt(this.lblPlayerNum.getText().length() - 1));
this.txtPlayerName.setText(TablePlayerPanel.extractAiPlayerNumberFromLabel(this.lblPlayerNum.getText()));
this.txtPlayerName.setEditable(false);
this.txtPlayerName.setEnabled(false);
} else {