Made quick start commander be multiplayer (#9200)

This commit is contained in:
Alex Vasile 2022-07-08 21:59:10 -04:00 committed by GitHub
parent 96f6fbefc8
commit 4f0e0a2ec6
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 53 additions and 44 deletions

View file

@ -45,11 +45,11 @@
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Component id="btnQuickStartDuel" min="-2" max="-2" attributes="0"/> <Component id="btnQuickStart2Player" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="btnQuickStartMCTS" min="-2" max="-2" attributes="0"/> <Component id="btnQuickStartMCTS" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<Component id="btnQuickStartCommander" min="-2" max="-2" attributes="0"/> <Component id="btnQuickStart4Player" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace pref="540" max="32767" attributes="0"/> <EmptySpace pref="540" max="32767" attributes="0"/>
</Group> </Group>
@ -69,7 +69,7 @@
<Component id="filterBar1" max="32767" attributes="0"/> <Component id="filterBar1" max="32767" attributes="0"/>
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="btnQuickStartDuel" min="-2" max="-2" attributes="0"/> <Component id="btnQuickStart2Player" min="-2" max="-2" attributes="0"/>
<Component id="btnQuickStartMCTS" min="-2" max="-2" attributes="0"/> <Component id="btnQuickStartMCTS" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/> <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
@ -79,7 +79,7 @@
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="filterBar2" max="32767" attributes="0"/> <Component id="filterBar2" max="32767" attributes="0"/>
<Group type="102" attributes="0"> <Group type="102" attributes="0">
<Component id="btnQuickStartCommander" min="-2" max="-2" attributes="0"/> <Component id="btnQuickStart4Player" min="-2" max="-2" attributes="0"/>
<EmptySpace min="0" pref="0" max="32767" attributes="0"/> <EmptySpace min="0" pref="0" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
@ -555,26 +555,26 @@
</Component> </Component>
</SubComponents> </SubComponents>
</Container> </Container>
<Component class="javax.swing.JButton" name="btnQuickStartDuel"> <Component class="javax.swing.JButton" name="btnQuickStart2Player">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Quick start duel"/> <Property name="text" type="java.lang.String" value="Quick 2 player"/>
<Property name="focusable" type="boolean" value="false"/> <Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/> <Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/> <Property name="verticalTextPosition" type="int" value="3"/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnQuickStartDuelActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnQuickStart2Player"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JButton" name="btnQuickStartCommander"> <Component class="javax.swing.JButton" name="btnQuickStart4Player">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Quick start commander"/> <Property name="text" type="java.lang.String" value="Quick 4 player"/>
<Property name="focusable" type="boolean" value="false"/> <Property name="focusable" type="boolean" value="false"/>
<Property name="horizontalTextPosition" type="int" value="0"/> <Property name="horizontalTextPosition" type="int" value="0"/>
<Property name="verticalTextPosition" type="int" value="3"/> <Property name="verticalTextPosition" type="int" value="3"/>
</Properties> </Properties>
<Events> <Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnQuickStartCommanderActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnQuickStart4PlayerActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JButton" name="btnQuickStartMCTS"> <Component class="javax.swing.JButton" name="btnQuickStartMCTS">

View file

@ -756,8 +756,8 @@ public class TablesPanel extends javax.swing.JPanel {
this.roomId = roomId; this.roomId = roomId;
UUID chatRoomId = null; UUID chatRoomId = null;
if (SessionHandler.getSession() != null) { if (SessionHandler.getSession() != null) {
btnQuickStartDuel.setVisible(SessionHandler.isTestMode()); btnQuickStart2Player.setVisible(SessionHandler.isTestMode());
btnQuickStartCommander.setVisible(SessionHandler.isTestMode()); btnQuickStart4Player.setVisible(SessionHandler.isTestMode());
btnQuickStartMCTS.setVisible(SessionHandler.isTestMode()); btnQuickStartMCTS.setVisible(SessionHandler.isTestMode());
gameChooser.init(); gameChooser.init();
chatRoomId = SessionHandler.getRoomChatId(roomId).orElse(null); chatRoomId = SessionHandler.getRoomChatId(roomId).orElse(null);
@ -1051,8 +1051,8 @@ public class TablesPanel extends javax.swing.JPanel {
jSeparator5 = new javax.swing.JToolBar.Separator(); jSeparator5 = new javax.swing.JToolBar.Separator();
btnOpen = new javax.swing.JToggleButton(); btnOpen = new javax.swing.JToggleButton();
btnPassword = new javax.swing.JToggleButton(); btnPassword = new javax.swing.JToggleButton();
btnQuickStartDuel = new javax.swing.JButton(); btnQuickStart2Player = new javax.swing.JButton();
btnQuickStartCommander = new javax.swing.JButton(); btnQuickStart4Player = new javax.swing.JButton();
btnQuickStartMCTS = new javax.swing.JButton(); btnQuickStartMCTS = new javax.swing.JButton();
jSplitPane1 = new javax.swing.JSplitPane(); jSplitPane1 = new javax.swing.JSplitPane();
jPanelTables = new javax.swing.JPanel(); jPanelTables = new javax.swing.JPanel();
@ -1503,23 +1503,23 @@ public class TablesPanel extends javax.swing.JPanel {
}); });
filterBar2.add(btnPassword); filterBar2.add(btnPassword);
btnQuickStartDuel.setText("Quick start duel"); btnQuickStart2Player.setText("Quick 2 player");
btnQuickStartDuel.setFocusable(false); btnQuickStart2Player.setFocusable(false);
btnQuickStartDuel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); btnQuickStart2Player.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnQuickStartDuel.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); btnQuickStart2Player.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnQuickStartDuel.addActionListener(new java.awt.event.ActionListener() { btnQuickStart2Player.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
btnQuickStartDuelActionPerformed(evt); btnQuickStart2PlayerActionPerformed(evt);
} }
}); });
btnQuickStartCommander.setText("Quick start commander"); btnQuickStart4Player.setText("Quick 4 player");
btnQuickStartCommander.setFocusable(false); btnQuickStart4Player.setFocusable(false);
btnQuickStartCommander.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER); btnQuickStart4Player.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
btnQuickStartCommander.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM); btnQuickStart4Player.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
btnQuickStartCommander.addActionListener(new java.awt.event.ActionListener() { btnQuickStart4Player.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
btnQuickStartCommanderActionPerformed(evt); btnQuickStart4PlayerActionPerformed(evt);
} }
}); });
@ -1546,10 +1546,10 @@ public class TablesPanel extends javax.swing.JPanel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(jPanelTopLayout.createSequentialGroup() .addGroup(jPanelTopLayout.createSequentialGroup()
.addComponent(btnQuickStartDuel) .addComponent(btnQuickStart2Player)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnQuickStartMCTS)) .addComponent(btnQuickStartMCTS))
.addComponent(btnQuickStartCommander)) .addComponent(btnQuickStart4Player))
.addContainerGap(540, Short.MAX_VALUE)) .addContainerGap(540, Short.MAX_VALUE))
); );
jPanelTopLayout.setVerticalGroup( jPanelTopLayout.setVerticalGroup(
@ -1565,14 +1565,14 @@ public class TablesPanel extends javax.swing.JPanel {
.addComponent(filterBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(filterBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanelTopLayout.createSequentialGroup() .addGroup(jPanelTopLayout.createSequentialGroup()
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(btnQuickStartDuel) .addComponent(btnQuickStart2Player)
.addComponent(btnQuickStartMCTS)) .addComponent(btnQuickStartMCTS))
.addGap(0, 0, Short.MAX_VALUE))) .addGap(0, 0, Short.MAX_VALUE)))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(filterBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE) .addComponent(filterBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addGroup(jPanelTopLayout.createSequentialGroup() .addGroup(jPanelTopLayout.createSequentialGroup()
.addComponent(btnQuickStartCommander) .addComponent(btnQuickStart4Player)
.addGap(0, 0, Short.MAX_VALUE))))) .addGap(0, 0, Short.MAX_VALUE)))))
.addContainerGap()) .addContainerGap())
); );
@ -1694,13 +1694,19 @@ public class TablesPanel extends javax.swing.JPanel {
DeckCardLists testDeck = DeckImporter.importDeckFromFile(testDeckFile, false); DeckCardLists testDeck = DeckImporter.importDeckFromFile(testDeckFile, false);
PlayerType aiType = useMonteCarloAI ? PlayerType.COMPUTER_MONTE_CARLO : PlayerType.COMPUTER_MAD; PlayerType aiType = useMonteCarloAI ? PlayerType.COMPUTER_MONTE_CARLO : PlayerType.COMPUTER_MAD;
MatchOptions options = new MatchOptions(gameName, gameType, false, 2); int numSeats = gameName.contains("2") ? 2 : 4;
boolean multiPlayer = numSeats > 2;
MatchOptions options = new MatchOptions(gameName, gameType, multiPlayer, numSeats);
options.getPlayerTypes().add(PlayerType.HUMAN); options.getPlayerTypes().add(PlayerType.HUMAN);
options.getPlayerTypes().add(aiType); options.getPlayerTypes().add(aiType);
options.setDeckType("Limited"); for (int i=2 ; i < numSeats ; i++) {
options.setAttackOption(MultiplayerAttackOption.LEFT); options.getPlayerTypes().add(aiType);
options.setRange(RangeOfInfluence.ALL); }
options.setWinsNeeded(1); options.setDeckType("Variant Magic - Freeform Commander");
options.setAttackOption(MultiplayerAttackOption.MULTIPLE);
options.setRange(RangeOfInfluence.ONE);
options.setWinsNeeded(2);
options.setMatchTimeLimit(MatchTimeLimit.NONE); options.setMatchTimeLimit(MatchTimeLimit.NONE);
options.setFreeMulligans(2); options.setFreeMulligans(2);
options.setSkillLevel(SkillLevel.CASUAL); options.setSkillLevel(SkillLevel.CASUAL);
@ -1712,17 +1718,16 @@ public class TablesPanel extends javax.swing.JPanel {
table = SessionHandler.createTable(roomId, options); table = SessionHandler.createTable(roomId, options);
SessionHandler.joinTable(roomId, table.getTableId(), "Human", PlayerType.HUMAN, 1, testDeck, ""); SessionHandler.joinTable(roomId, table.getTableId(), "Human", PlayerType.HUMAN, 1, testDeck, "");
SessionHandler.joinTable(roomId, table.getTableId(), "Computer", aiType, 5, testDeck, ""); SessionHandler.joinTable(roomId, table.getTableId(), "Computer 0", aiType, 5, testDeck, "");
for (int i=2 ; i < numSeats ; i++) {
SessionHandler.joinTable(roomId, table.getTableId(), "Computer " + i, aiType, 5, testDeck, "");
}
SessionHandler.startMatch(roomId, table.getTableId()); SessionHandler.startMatch(roomId, table.getTableId());
} catch (HeadlessException ex) { } catch (HeadlessException ex) {
handleError(ex); handleError(ex);
} }
} }
private void btnQuickStartDuelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuickStartDuelActionPerformed
createTestGame("Test duel", "Two Player Duel", false);
}//GEN-LAST:event_btnQuickStartDuelActionPerformed
private void btnNewTableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewTableActionPerformed private void btnNewTableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewTableActionPerformed
newTableDialog.showDialog(roomId); newTableDialog.showDialog(roomId);
}//GEN-LAST:event_btnNewTableActionPerformed }//GEN-LAST:event_btnNewTableActionPerformed
@ -1758,8 +1763,12 @@ public class TablesPanel extends javax.swing.JPanel {
MageFrame.getInstance().showWhatsNewDialog(true); MageFrame.getInstance().showWhatsNewDialog(true);
}//GEN-LAST:event_buttonWhatsNewActionPerformed }//GEN-LAST:event_buttonWhatsNewActionPerformed
private void btnQuickStartCommanderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuickStartCommanderActionPerformed private void btnQuickStart2PlayerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuickStartDuelActionPerformed
createTestGame("Test commander", "Commander Two Player Duel", false); createTestGame("Test 2 player", "Commander Free For All", false);
}//GEN-LAST:event_btnQuickStartDuelActionPerformed
private void btnQuickStart4PlayerActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuickStartCommanderActionPerformed
createTestGame("Test 4 player", "Commander Free For All", false);
}//GEN-LAST:event_btnQuickStartCommanderActionPerformed }//GEN-LAST:event_btnQuickStartCommanderActionPerformed
private void btnQuickStartMCTSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuickStartMCTSActionPerformed private void btnQuickStartMCTSActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuickStartMCTSActionPerformed
@ -1788,8 +1797,8 @@ public class TablesPanel extends javax.swing.JPanel {
private javax.swing.JButton btnNewTournament; private javax.swing.JButton btnNewTournament;
private javax.swing.JToggleButton btnOpen; private javax.swing.JToggleButton btnOpen;
private javax.swing.JToggleButton btnPassword; private javax.swing.JToggleButton btnPassword;
private javax.swing.JButton btnQuickStartCommander; private javax.swing.JButton btnQuickStart4Player;
private javax.swing.JButton btnQuickStartDuel; private javax.swing.JButton btnQuickStart2Player;
private javax.swing.JButton btnQuickStartMCTS; private javax.swing.JButton btnQuickStartMCTS;
private javax.swing.JToggleButton btnRated; private javax.swing.JToggleButton btnRated;
private javax.swing.JToggleButton btnSkillBeginner; private javax.swing.JToggleButton btnSkillBeginner;