mirror of
https://github.com/magefree/mage.git
synced 2025-12-22 11:32:00 -08:00
Test framework: added commander games support (quick start button, "commander" command to put card as commander);
This commit is contained in:
parent
24b221ff34
commit
8448afc709
6 changed files with 104 additions and 42 deletions
|
|
@ -43,8 +43,11 @@
|
|||
<Component id="filterBar2" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="btnQuickStart" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="792" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="btnQuickStartDuel" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="btnQuickStartCommander" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace pref="734" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
|
|
@ -60,10 +63,16 @@
|
|||
<Group type="102" alignment="0" attributes="0">
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="filterBar1" max="32767" attributes="0"/>
|
||||
<Component id="btnQuickStart" min="-2" max="-2" attributes="0"/>
|
||||
<Component id="btnQuickStartDuel" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="filterBar2" max="32767" attributes="0"/>
|
||||
<Group type="103" groupAlignment="0" attributes="0">
|
||||
<Component id="filterBar2" max="32767" attributes="0"/>
|
||||
<Group type="102" attributes="0">
|
||||
<Component id="btnQuickStartCommander" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="0" pref="0" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
</Group>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
|
|
@ -506,15 +515,26 @@
|
|||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Component class="javax.swing.JButton" name="btnQuickStart">
|
||||
<Component class="javax.swing.JButton" name="btnQuickStartDuel">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Quick Start"/>
|
||||
<Property name="text" type="java.lang.String" value="Quick start duel"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnQuickStartActionPerformed"/>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnQuickStartDuelActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
<Component class="javax.swing.JButton" name="btnQuickStartCommander">
|
||||
<Properties>
|
||||
<Property name="text" type="java.lang.String" value="Quick start commander"/>
|
||||
<Property name="focusable" type="boolean" value="false"/>
|
||||
<Property name="horizontalTextPosition" type="int" value="0"/>
|
||||
<Property name="verticalTextPosition" type="int" value="3"/>
|
||||
</Properties>
|
||||
<Events>
|
||||
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnQuickStartCommanderActionPerformed"/>
|
||||
</Events>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
|
|
|
|||
|
|
@ -688,7 +688,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
this.roomId = roomId;
|
||||
UUID chatRoomId = null;
|
||||
if (SessionHandler.getSession() != null) {
|
||||
btnQuickStart.setVisible(SessionHandler.isTestMode());
|
||||
btnQuickStartDuel.setVisible(SessionHandler.isTestMode());
|
||||
gameChooser.init();
|
||||
chatRoomId = SessionHandler.getRoomChatId(roomId).orElse(null);
|
||||
}
|
||||
|
|
@ -973,7 +973,8 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
jSeparator5 = new javax.swing.JToolBar.Separator();
|
||||
btnOpen = new javax.swing.JToggleButton();
|
||||
btnPassword = new javax.swing.JToggleButton();
|
||||
btnQuickStart = new javax.swing.JButton();
|
||||
btnQuickStartDuel = new javax.swing.JButton();
|
||||
btnQuickStartCommander = new javax.swing.JButton();
|
||||
jSplitPane1 = new javax.swing.JSplitPane();
|
||||
jPanelTables = new javax.swing.JPanel();
|
||||
jSplitPaneTables = new javax.swing.JSplitPane();
|
||||
|
|
@ -1393,13 +1394,23 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
});
|
||||
filterBar2.add(btnPassword);
|
||||
|
||||
btnQuickStart.setText("Quick Start");
|
||||
btnQuickStart.setFocusable(false);
|
||||
btnQuickStart.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
btnQuickStart.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
btnQuickStart.addActionListener(new java.awt.event.ActionListener() {
|
||||
btnQuickStartDuel.setText("Quick start duel");
|
||||
btnQuickStartDuel.setFocusable(false);
|
||||
btnQuickStartDuel.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
btnQuickStartDuel.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
btnQuickStartDuel.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnQuickStartActionPerformed(evt);
|
||||
btnQuickStartDuelActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
btnQuickStartCommander.setText("Quick start commander");
|
||||
btnQuickStartCommander.setFocusable(false);
|
||||
btnQuickStartCommander.setHorizontalTextPosition(javax.swing.SwingConstants.CENTER);
|
||||
btnQuickStartCommander.setVerticalTextPosition(javax.swing.SwingConstants.BOTTOM);
|
||||
btnQuickStartCommander.addActionListener(new java.awt.event.ActionListener() {
|
||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||
btnQuickStartCommanderActionPerformed(evt);
|
||||
}
|
||||
});
|
||||
|
||||
|
|
@ -1417,8 +1428,10 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
.addComponent(filterBar1, 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))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(btnQuickStart)
|
||||
.addContainerGap(792, Short.MAX_VALUE))
|
||||
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(btnQuickStartDuel)
|
||||
.addComponent(btnQuickStartCommander))
|
||||
.addContainerGap(734, Short.MAX_VALUE))
|
||||
);
|
||||
jPanelTopLayout.setVerticalGroup(
|
||||
jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
|
|
@ -1431,9 +1444,13 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
.addGroup(jPanelTopLayout.createSequentialGroup()
|
||||
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(filterBar1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addComponent(btnQuickStart))
|
||||
.addComponent(btnQuickStartDuel))
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(filterBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)))
|
||||
.addGroup(jPanelTopLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
.addComponent(filterBar2, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
|
||||
.addGroup(jPanelTopLayout.createSequentialGroup()
|
||||
.addComponent(btnQuickStartCommander)
|
||||
.addGap(0, 0, Short.MAX_VALUE)))))
|
||||
.addContainerGap())
|
||||
);
|
||||
|
||||
|
|
@ -1537,7 +1554,7 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
newTournamentDialog.showDialog(roomId);
|
||||
}//GEN-LAST:event_btnNewTournamentActionPerformed
|
||||
|
||||
private void btnQuickStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuickStartActionPerformed
|
||||
private void createTestGame(String gameName, String gameType) {
|
||||
TableView table;
|
||||
try {
|
||||
String testDeckFile = "test.dck";
|
||||
|
|
@ -1551,10 +1568,9 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
+ "5 Mountain" + System.lineSeparator()
|
||||
+ "5 Plains");
|
||||
}
|
||||
|
||||
DeckCardLists testDeck = DeckImporter.importDeckFromFile(testDeckFile);
|
||||
|
||||
MatchOptions options = new MatchOptions("1", "Two Player Duel", false, 2);
|
||||
MatchOptions options = new MatchOptions(gameName, gameType, false, 2);
|
||||
options.getPlayerTypes().add(PlayerType.HUMAN);
|
||||
options.getPlayerTypes().add(PlayerType.COMPUTER_MAD);
|
||||
options.setDeckType("Limited");
|
||||
|
|
@ -1577,7 +1593,11 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
} catch (HeadlessException ex) {
|
||||
handleError(ex);
|
||||
}
|
||||
}//GEN-LAST:event_btnQuickStartActionPerformed
|
||||
}
|
||||
|
||||
private void btnQuickStartDuelActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuickStartDuelActionPerformed
|
||||
createTestGame("Test duel", "Two Player Duel");
|
||||
}//GEN-LAST:event_btnQuickStartDuelActionPerformed
|
||||
|
||||
private void btnNewTableActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewTableActionPerformed
|
||||
newTableDialog.showDialog(roomId);
|
||||
|
|
@ -1630,6 +1650,10 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
MageFrame.getInstance().showWhatsNewDialog(true);
|
||||
}//GEN-LAST:event_buttonWhatsNewActionPerformed
|
||||
|
||||
private void btnQuickStartCommanderActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuickStartCommanderActionPerformed
|
||||
createTestGame("Test commander", "Commander Two Player Duel");
|
||||
}//GEN-LAST:event_btnQuickStartCommanderActionPerformed
|
||||
|
||||
private void handleError(Exception ex) {
|
||||
LOGGER.fatal("Error loading deck: ", ex);
|
||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error loading deck.", "Error", JOptionPane.ERROR_MESSAGE);
|
||||
|
|
@ -1650,7 +1674,8 @@ public class TablesPanel extends javax.swing.JPanel {
|
|||
private javax.swing.JButton btnNewTournament;
|
||||
private javax.swing.JToggleButton btnOpen;
|
||||
private javax.swing.JToggleButton btnPassword;
|
||||
private javax.swing.JButton btnQuickStart;
|
||||
private javax.swing.JButton btnQuickStartCommander;
|
||||
private javax.swing.JButton btnQuickStartDuel;
|
||||
private javax.swing.JToggleButton btnRated;
|
||||
private javax.swing.JToggleButton btnSkillBeginner;
|
||||
private javax.swing.JToggleButton btnSkillCasual;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue