mirror of
https://github.com/correl/mage.git
synced 2024-12-25 11:11:16 +00:00
Test framework: added default test deck (no more test.dck file required to start test game);
This commit is contained in:
parent
89cf3e3969
commit
24b221ff34
1 changed files with 15 additions and 5 deletions
|
@ -1,5 +1,6 @@
|
||||||
package mage.client.table;
|
package mage.client.table;
|
||||||
|
|
||||||
|
import mage.cards.decks.DeckCardLists;
|
||||||
import mage.cards.decks.importer.DeckImporter;
|
import mage.cards.decks.importer.DeckImporter;
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.client.SessionHandler;
|
import mage.client.SessionHandler;
|
||||||
|
@ -16,6 +17,7 @@ import mage.constants.*;
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
import mage.players.PlayerType;
|
import mage.players.PlayerType;
|
||||||
import mage.remote.MageRemoteException;
|
import mage.remote.MageRemoteException;
|
||||||
|
import mage.util.DeckUtil;
|
||||||
import mage.util.RandomUtil;
|
import mage.util.RandomUtil;
|
||||||
import mage.view.MatchView;
|
import mage.view.MatchView;
|
||||||
import mage.view.RoomUsersView;
|
import mage.view.RoomUsersView;
|
||||||
|
@ -1538,12 +1540,20 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
private void btnQuickStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuickStartActionPerformed
|
private void btnQuickStartActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnQuickStartActionPerformed
|
||||||
TableView table;
|
TableView table;
|
||||||
try {
|
try {
|
||||||
File f = new File("test.dck");
|
String testDeckFile = "test.dck";
|
||||||
|
File f = new File(testDeckFile);
|
||||||
if (!f.exists()) {
|
if (!f.exists()) {
|
||||||
JOptionPane.showMessageDialog(null, "Couldn't find test.dck file for quick game start", "Error", JOptionPane.ERROR_MESSAGE);
|
// default test deck
|
||||||
return;
|
testDeckFile = DeckUtil.writeTextToTempFile(""
|
||||||
|
+ "5 Swamp" + System.lineSeparator()
|
||||||
|
+ "5 Forest" + System.lineSeparator()
|
||||||
|
+ "5 Island" + System.lineSeparator()
|
||||||
|
+ "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("1", "Two Player Duel", false, 2);
|
||||||
options.getPlayerTypes().add(PlayerType.HUMAN);
|
options.getPlayerTypes().add(PlayerType.HUMAN);
|
||||||
options.getPlayerTypes().add(PlayerType.COMPUTER_MAD);
|
options.getPlayerTypes().add(PlayerType.COMPUTER_MAD);
|
||||||
|
@ -1561,8 +1571,8 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
options.setBannedUsers(IgnoreList.ignoreList(serverAddress));
|
options.setBannedUsers(IgnoreList.ignoreList(serverAddress));
|
||||||
table = SessionHandler.createTable(roomId, options);
|
table = SessionHandler.createTable(roomId, options);
|
||||||
|
|
||||||
SessionHandler.joinTable(roomId, table.getTableId(), "Human", PlayerType.HUMAN, 1, DeckImporter.importDeckFromFile("test.dck"), "");
|
SessionHandler.joinTable(roomId, table.getTableId(), "Human", PlayerType.HUMAN, 1, testDeck, "");
|
||||||
SessionHandler.joinTable(roomId, table.getTableId(), "Computer", PlayerType.COMPUTER_MAD, 5, DeckImporter.importDeckFromFile("test.dck"), "");
|
SessionHandler.joinTable(roomId, table.getTableId(), "Computer", PlayerType.COMPUTER_MAD, 5, testDeck, "");
|
||||||
SessionHandler.startMatch(roomId, table.getTableId());
|
SessionHandler.startMatch(roomId, table.getTableId());
|
||||||
} catch (HeadlessException ex) {
|
} catch (HeadlessException ex) {
|
||||||
handleError(ex);
|
handleError(ex);
|
||||||
|
|
Loading…
Reference in a new issue