mirror of
https://github.com/correl/mage.git
synced 2025-04-13 09:11:06 -09:00
[refactoring] Moved Sets.loadDeck to a DeckImporterImplementation
This commit is contained in:
parent
e9ac5a180b
commit
47bd74a24c
17 changed files with 218 additions and 172 deletions
Mage.Client/src/main/java/mage/client
deckeditor
dialog
game
table
Mage.Sets/src/mage
cards/decks/importer
DckDeckImporter.javaDecDeckImporter.javaDeckImporter.javaDeckImporterImpl.javaDeckImporterUtil.javaMWSDeckImporter.javaTxtDeckImporter.java
sets
Mage.Tests/src/test/java/org/mage/test/serverside/base
|
@ -25,15 +25,10 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
* DeckEditorPanel.java
|
|
||||||
*
|
|
||||||
* Created on Feb 18, 2010, 2:47:04 PM
|
|
||||||
*/
|
|
||||||
|
|
||||||
package mage.client.deckeditor;
|
package mage.client.deckeditor;
|
||||||
|
|
||||||
|
import mage.cards.decks.importer.DeckImporter;
|
||||||
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import java.awt.*;
|
import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
|
@ -334,6 +329,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
btnSave.setText("Save");
|
btnSave.setText("Save");
|
||||||
btnSave.addActionListener(new java.awt.event.ActionListener() {
|
btnSave.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
@Override
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
btnSaveActionPerformed(evt);
|
btnSaveActionPerformed(evt);
|
||||||
}
|
}
|
||||||
|
@ -341,6 +337,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
btnLoad.setText("Load");
|
btnLoad.setText("Load");
|
||||||
btnLoad.addActionListener(new java.awt.event.ActionListener() {
|
btnLoad.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
@Override
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
btnLoadActionPerformed(evt);
|
btnLoadActionPerformed(evt);
|
||||||
}
|
}
|
||||||
|
@ -348,6 +345,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
btnNew.setText("New");
|
btnNew.setText("New");
|
||||||
btnNew.addActionListener(new java.awt.event.ActionListener() {
|
btnNew.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
@Override
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
btnNewActionPerformed(evt);
|
btnNewActionPerformed(evt);
|
||||||
}
|
}
|
||||||
|
@ -355,6 +353,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
btnExit.setText("Exit");
|
btnExit.setText("Exit");
|
||||||
btnExit.addActionListener(new java.awt.event.ActionListener() {
|
btnExit.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
@Override
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
btnExitActionPerformed(evt);
|
btnExitActionPerformed(evt);
|
||||||
}
|
}
|
||||||
|
@ -363,6 +362,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
btnImport.setText("Import");
|
btnImport.setText("Import");
|
||||||
btnImport.setName("btnImport"); // NOI18N
|
btnImport.setName("btnImport"); // NOI18N
|
||||||
btnImport.addActionListener(new java.awt.event.ActionListener() {
|
btnImport.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
@Override
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
btnImportActionPerformed(evt);
|
btnImportActionPerformed(evt);
|
||||||
}
|
}
|
||||||
|
@ -371,6 +371,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
btnSubmit.setText("Submit");
|
btnSubmit.setText("Submit");
|
||||||
btnSubmit.setName("btnSubmit"); // NOI18N
|
btnSubmit.setName("btnSubmit"); // NOI18N
|
||||||
btnSubmit.addActionListener(new java.awt.event.ActionListener() {
|
btnSubmit.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
@Override
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
btnSubmitActionPerformed(evt);
|
btnSubmitActionPerformed(evt);
|
||||||
}
|
}
|
||||||
|
@ -379,6 +380,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
btnAddLand.setText("Add Land");
|
btnAddLand.setText("Add Land");
|
||||||
btnAddLand.setName("btnAddLand"); // NOI18N
|
btnAddLand.setName("btnAddLand"); // NOI18N
|
||||||
btnAddLand.addActionListener(new java.awt.event.ActionListener() {
|
btnAddLand.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
@Override
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
btnAddLandActionPerformed(evt);
|
btnAddLandActionPerformed(evt);
|
||||||
}
|
}
|
||||||
|
@ -480,7 +482,7 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
File file = fcSelectDeck.getSelectedFile();
|
File file = fcSelectDeck.getSelectedFile();
|
||||||
try {
|
try {
|
||||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||||
deck = Deck.load(Sets.loadDeck(file.getPath()), true);
|
deck = Deck.load(DeckImporterUtil.importDeck(file.getPath()), true);
|
||||||
} catch (GameException ex) {
|
} catch (GameException ex) {
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error loading deck", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error loading deck", JOptionPane.ERROR_MESSAGE);
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
|
@ -550,9 +552,13 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
File file = fcImportDeck.getSelectedFile();
|
File file = fcImportDeck.getSelectedFile();
|
||||||
try {
|
try {
|
||||||
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
setCursor(new Cursor(Cursor.WAIT_CURSOR));
|
||||||
DeckImporter importer = getDeckImporter(file.getPath());
|
DeckImporter importer = DeckImporterUtil.getDeckImporter(file.getPath());
|
||||||
if (importer != null) {
|
if (importer != null) {
|
||||||
deck = Deck.load(importer.importDeck(file.getPath()));
|
deck = Deck.load(importer.importDeck(file.getPath()));
|
||||||
|
String errors = importer.getErrors();
|
||||||
|
if(!errors.isEmpty()){
|
||||||
|
JOptionPane.showMessageDialog(MageFrame.getDesktop(), errors, "Error importing deck", JOptionPane.ERROR_MESSAGE);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
else {
|
else {
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Unknown deck format", "Error importing deck", JOptionPane.ERROR_MESSAGE);
|
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Unknown deck format", "Error importing deck", JOptionPane.ERROR_MESSAGE);
|
||||||
|
@ -586,17 +592,6 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
||||||
refreshDeck();
|
refreshDeck();
|
||||||
}
|
}
|
||||||
|
|
||||||
public DeckImporter getDeckImporter(String file) {
|
|
||||||
if (file.toLowerCase().endsWith("dec"))
|
|
||||||
return new DecDeckImporter();
|
|
||||||
else if (file.toLowerCase().endsWith("mwdeck"))
|
|
||||||
return new MWSDeckImporter();
|
|
||||||
else if (file.toLowerCase().endsWith("txt"))
|
|
||||||
return new TxtDeckImporter();
|
|
||||||
else
|
|
||||||
return null;
|
|
||||||
}
|
|
||||||
|
|
||||||
// Variables declaration - do not modify//GEN-BEGIN:variables
|
// Variables declaration - do not modify//GEN-BEGIN:variables
|
||||||
private mage.client.cards.BigCard bigCard;
|
private mage.client.cards.BigCard bigCard;
|
||||||
private javax.swing.JButton btnExit;
|
private javax.swing.JButton btnExit;
|
||||||
|
|
|
@ -25,21 +25,13 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
|
|
||||||
/*
|
|
||||||
* JoinTableDialog.java
|
|
||||||
*
|
|
||||||
* Created on 15-Dec-2009, 11:18:48 PM
|
|
||||||
*/
|
|
||||||
|
|
||||||
package mage.client.dialog;
|
package mage.client.dialog;
|
||||||
|
|
||||||
import mage.client.*;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
|
import mage.client.MageFrame;
|
||||||
import mage.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.sets.Sets;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -136,7 +128,7 @@ public class JoinTableDialog extends MageDialog {
|
||||||
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnOKActionPerformed
|
||||||
Session session = MageFrame.getSession();
|
Session session = MageFrame.getSession();
|
||||||
try {
|
try {
|
||||||
joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, Sets.loadDeck(this.newPlayerPanel.getDeckFile()));
|
joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()));
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
handleError(ex);
|
handleError(ex);
|
||||||
}
|
}
|
||||||
|
|
|
@ -25,18 +25,10 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
* NewTableDialog.java
|
|
||||||
*
|
|
||||||
* Created on 15-Dec-2009, 10:35:42 PM
|
|
||||||
*/
|
|
||||||
|
|
||||||
package mage.client.dialog;
|
package mage.client.dialog;
|
||||||
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import mage.client.*;
|
|
||||||
import java.util.ArrayList;
|
import java.util.ArrayList;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
@ -45,12 +37,14 @@ import javax.swing.JOptionPane;
|
||||||
import javax.swing.SpinnerNumberModel;
|
import javax.swing.SpinnerNumberModel;
|
||||||
import mage.Constants.MultiplayerAttackOption;
|
import mage.Constants.MultiplayerAttackOption;
|
||||||
import mage.Constants.RangeOfInfluence;
|
import mage.Constants.RangeOfInfluence;
|
||||||
|
import mage.client.MageFrame;
|
||||||
import mage.client.components.MageComponents;
|
import mage.client.components.MageComponents;
|
||||||
import mage.remote.Session;
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.client.table.TablePlayerPanel;
|
import mage.client.table.TablePlayerPanel;
|
||||||
import mage.client.util.Event;
|
import mage.client.util.Event;
|
||||||
import mage.client.util.Listener;
|
import mage.client.util.Listener;
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
|
import mage.remote.Session;
|
||||||
import mage.sets.Sets;
|
import mage.sets.Sets;
|
||||||
import mage.view.GameTypeView;
|
import mage.view.GameTypeView;
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
|
@ -322,7 +316,7 @@ public class NewTableDialog extends MageDialog {
|
||||||
return;
|
return;
|
||||||
}
|
}
|
||||||
try {
|
try {
|
||||||
if (session.joinTable(roomId, table.getTableId(), this.player1Panel.getPlayerName(), "Human", 1, Sets.loadDeck(this.player1Panel.getDeckFile()))) {
|
if (session.joinTable(roomId, table.getTableId(), this.player1Panel.getPlayerName(), "Human", 1, DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()))) {
|
||||||
for (TablePlayerPanel player: players) {
|
for (TablePlayerPanel player: players) {
|
||||||
if (!player.getPlayerType().equals("Human")) {
|
if (!player.getPlayerType().equals("Human")) {
|
||||||
if (!player.joinTable(roomId, table.getTableId())) {
|
if (!player.joinTable(roomId, table.getTableId())) {
|
||||||
|
|
|
@ -25,32 +25,21 @@
|
||||||
* authors and should not be interpreted as representing official policies, either expressed
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
/*
|
|
||||||
* PlayAreaPanel.java
|
|
||||||
*
|
|
||||||
* Created on Dec 22, 2009, 10:41:54 AM
|
|
||||||
*/
|
|
||||||
|
|
||||||
package mage.client.game;
|
package mage.client.game;
|
||||||
|
|
||||||
import java.awt.*;
|
import java.awt.Color;
|
||||||
import java.io.FileNotFoundException;
|
import java.awt.Dimension;
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import javax.swing.BorderFactory;
|
||||||
import java.util.logging.Logger;
|
import javax.swing.GroupLayout;
|
||||||
|
|
||||||
import mage.client.MageFrame;
|
|
||||||
import mage.client.cards.BigCard;
|
|
||||||
import mage.sets.Sets;
|
|
||||||
import mage.view.PlayerView;
|
|
||||||
|
|
||||||
import javax.swing.*;
|
|
||||||
import javax.swing.border.Border;
|
|
||||||
import javax.swing.border.EmptyBorder;
|
|
||||||
import javax.swing.GroupLayout.Alignment;
|
import javax.swing.GroupLayout.Alignment;
|
||||||
import javax.swing.LayoutStyle.ComponentPlacement;
|
import javax.swing.LayoutStyle.ComponentPlacement;
|
||||||
|
import javax.swing.border.Border;
|
||||||
|
import javax.swing.border.EmptyBorder;
|
||||||
|
import mage.client.MageFrame;
|
||||||
|
import mage.client.cards.BigCard;
|
||||||
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
|
import mage.view.PlayerView;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -76,7 +65,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
update(player);
|
update(player);
|
||||||
}
|
}
|
||||||
|
|
||||||
public void init(PlayerView player, BigCard bigCard, UUID gameId) {
|
public final void init(PlayerView player, BigCard bigCard, UUID gameId) {
|
||||||
this.playerPanel.init(gameId, player.getPlayerId(), bigCard);
|
this.playerPanel.init(gameId, player.getPlayerId(), bigCard);
|
||||||
this.battlefieldPanel.init(gameId, bigCard);
|
this.battlefieldPanel.init(gameId, bigCard);
|
||||||
if (MageFrame.getSession().isTestMode()) {
|
if (MageFrame.getSession().isTestMode()) {
|
||||||
|
@ -89,7 +78,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
public void update(PlayerView player) {
|
public final void update(PlayerView player) {
|
||||||
this.playerPanel.update(player);
|
this.playerPanel.update(player);
|
||||||
this.battlefieldPanel.update(player.getBattlefield());
|
this.battlefieldPanel.update(player.getBattlefield());
|
||||||
}
|
}
|
||||||
|
@ -107,6 +96,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
btnCheat.setText("Cheat");
|
btnCheat.setText("Cheat");
|
||||||
btnCheat.addActionListener(new java.awt.event.ActionListener() {
|
btnCheat.addActionListener(new java.awt.event.ActionListener() {
|
||||||
|
@Override
|
||||||
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
public void actionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
btnCheatActionPerformed(evt);
|
btnCheatActionPerformed(evt);
|
||||||
}
|
}
|
||||||
|
@ -145,13 +135,7 @@ public class PlayAreaPanel extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {
|
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {
|
||||||
try {
|
MageFrame.getSession().cheat(gameId, playerId, DeckImporterUtil.importDeck("cheat.dck"));
|
||||||
MageFrame.getSession().cheat(gameId, playerId, Sets.loadDeck("cheat.dck"));
|
|
||||||
} catch (FileNotFoundException ex) {
|
|
||||||
Logger.getLogger(PlayAreaPanel.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
Logger.getLogger(PlayAreaPanel.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
||||||
|
|
|
@ -64,13 +64,10 @@ import java.awt.*;
|
||||||
import java.awt.event.ActionEvent;
|
import java.awt.event.ActionEvent;
|
||||||
import java.awt.event.ActionListener;
|
import java.awt.event.ActionListener;
|
||||||
import java.awt.image.BufferedImage;
|
import java.awt.image.BufferedImage;
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import java.io.IOException;
|
|
||||||
import java.util.HashMap;
|
import java.util.HashMap;
|
||||||
import java.util.Map;
|
import java.util.Map;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
import java.util.logging.Level;
|
import mage.cards.decks.importer.DckDeckImporter;
|
||||||
import java.util.logging.Logger;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Enhanced player pane.
|
* Enhanced player pane.
|
||||||
|
@ -520,13 +517,8 @@ public class PlayerPanelExt extends javax.swing.JPanel {
|
||||||
}
|
}
|
||||||
|
|
||||||
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheatActionPerformed
|
private void btnCheatActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnCheatActionPerformed
|
||||||
try {
|
DckDeckImporter deckImporter = new DckDeckImporter();
|
||||||
session.cheat(gameId, playerId, Sets.loadDeck("cheat.dck"));
|
session.cheat(gameId, playerId, deckImporter.importDeck("cheat.dck"));
|
||||||
} catch (FileNotFoundException ex) {
|
|
||||||
Logger.getLogger(PlayAreaPanel.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
} catch (IOException ex) {
|
|
||||||
Logger.getLogger(PlayAreaPanel.class.getName()).log(Level.SEVERE, null, ex);
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
private HoverButton avatar;
|
private HoverButton avatar;
|
||||||
|
|
|
@ -37,15 +37,13 @@ package mage.client.table;
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.IOException;
|
import java.io.IOException;
|
||||||
import java.util.UUID;
|
import java.util.UUID;
|
||||||
|
|
||||||
import javax.swing.DefaultComboBoxModel;
|
import javax.swing.DefaultComboBoxModel;
|
||||||
|
|
||||||
import mage.client.MageFrame;
|
import mage.client.MageFrame;
|
||||||
import mage.remote.Session;
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.client.util.Config;
|
import mage.client.util.Config;
|
||||||
import mage.client.util.Event;
|
import mage.client.util.Event;
|
||||||
import mage.client.util.Listener;
|
import mage.client.util.Listener;
|
||||||
import mage.sets.Sets;
|
import mage.remote.Session;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
*
|
*
|
||||||
|
@ -79,7 +77,7 @@ public class TablePlayerPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
public boolean joinTable(UUID roomId, UUID tableId) throws FileNotFoundException, IOException, ClassNotFoundException {
|
public boolean joinTable(UUID roomId, UUID tableId) throws FileNotFoundException, IOException, ClassNotFoundException {
|
||||||
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
|
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
|
||||||
return session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), (String)this.cbPlayerType.getSelectedItem(), this.newPlayerPanel.getLevel(), Sets.loadDeck(this.newPlayerPanel.getDeckFile()));
|
return session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), (String)this.cbPlayerType.getSelectedItem(), this.newPlayerPanel.getLevel(), DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()));
|
||||||
}
|
}
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
|
@ -47,7 +47,6 @@ import mage.remote.MageRemoteException;
|
||||||
import mage.remote.Session;
|
import mage.remote.Session;
|
||||||
import mage.client.util.ButtonColumn;
|
import mage.client.util.ButtonColumn;
|
||||||
import mage.game.match.MatchOptions;
|
import mage.game.match.MatchOptions;
|
||||||
import mage.sets.Sets;
|
|
||||||
import mage.view.TableView;
|
import mage.view.TableView;
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
|
@ -62,6 +61,7 @@ import java.util.*;
|
||||||
import java.util.List;
|
import java.util.List;
|
||||||
import java.util.concurrent.CancellationException;
|
import java.util.concurrent.CancellationException;
|
||||||
import java.util.concurrent.ExecutionException;
|
import java.util.concurrent.ExecutionException;
|
||||||
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.client.util.gui.GuiDisplayUtil;
|
import mage.client.util.gui.GuiDisplayUtil;
|
||||||
import mage.view.MatchView;
|
import mage.view.MatchView;
|
||||||
|
|
||||||
|
@ -283,17 +283,17 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
|
|
||||||
protected void reloadMessages() {
|
protected void reloadMessages() {
|
||||||
// reload server messages
|
// reload server messages
|
||||||
List<String> messages = session.getServerMessages();
|
List<String> serverMessages = session.getServerMessages();
|
||||||
synchronized (this) {
|
synchronized (this) {
|
||||||
this.messages = messages;
|
this.messages = serverMessages;
|
||||||
this.currentMessage = 0;
|
this.currentMessage = 0;
|
||||||
}
|
}
|
||||||
if (messages == null || messages.isEmpty()) {
|
if (serverMessages == null || serverMessages.isEmpty()) {
|
||||||
this.jPanel2.setVisible(false);
|
this.jPanel2.setVisible(false);
|
||||||
} else {
|
} else {
|
||||||
this.jPanel2.setVisible(true);
|
this.jPanel2.setVisible(true);
|
||||||
this.jLabel2.setText(messages.get(0));
|
this.jLabel2.setText(serverMessages.get(0));
|
||||||
this.jButton1.setVisible(messages.size() > 1);
|
this.jButton1.setVisible(serverMessages.size() > 1);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -513,8 +513,8 @@ public class TablesPanel extends javax.swing.JPanel {
|
||||||
options.setRange(RangeOfInfluence.ALL);
|
options.setRange(RangeOfInfluence.ALL);
|
||||||
options.setWinsNeeded(1);
|
options.setWinsNeeded(1);
|
||||||
table = session.createTable(roomId, options);
|
table = session.createTable(roomId, options);
|
||||||
session.joinTable(roomId, table.getTableId(), "Human", "Human", 1, Sets.loadDeck("test.dck"));
|
session.joinTable(roomId, table.getTableId(), "Human", "Human", 1, DeckImporterUtil.importDeck("test.dck"));
|
||||||
session.joinTable(roomId, table.getTableId(), "Computer", "Computer - minimax", 5, Sets.loadDeck("test.dck"));
|
session.joinTable(roomId, table.getTableId(), "Computer", "Computer - minimax", 5, DeckImporterUtil.importDeck("test.dck"));
|
||||||
session.startGame(roomId, table.getTableId());
|
session.startGame(roomId, table.getTableId());
|
||||||
} catch (Exception ex) {
|
} catch (Exception ex) {
|
||||||
handleError(ex);
|
handleError(ex);
|
||||||
|
|
82
Mage.Sets/src/mage/cards/decks/importer/DckDeckImporter.java
Normal file
82
Mage.Sets/src/mage/cards/decks/importer/DckDeckImporter.java
Normal file
|
@ -0,0 +1,82 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.cards.decks.importer;
|
||||||
|
|
||||||
|
import java.util.regex.Matcher;
|
||||||
|
import java.util.regex.Pattern;
|
||||||
|
import mage.cards.ExpansionSet;
|
||||||
|
import mage.cards.decks.DeckCardLists;
|
||||||
|
import mage.sets.Sets;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author North
|
||||||
|
*/
|
||||||
|
public class DckDeckImporter extends DeckImporterImpl {
|
||||||
|
|
||||||
|
private static final Pattern pattern = Pattern.compile("(SB:)?\\s*(\\d*)\\s*\\[([a-zA-Z0-9]{3}):(\\d*)\\].*");
|
||||||
|
|
||||||
|
@Override
|
||||||
|
protected void readLine(String line, DeckCardLists deckList) {
|
||||||
|
|
||||||
|
if (line.length() == 0 || line.startsWith("#")) {
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
Matcher m = pattern.matcher(line);
|
||||||
|
if (m.matches()) {
|
||||||
|
boolean sideboard = false;
|
||||||
|
if ("SB:".equals(m.group(1))) {
|
||||||
|
sideboard = true;
|
||||||
|
}
|
||||||
|
int count = Integer.parseInt(m.group(2));
|
||||||
|
String setCode = m.group(3);
|
||||||
|
int cardNum = Integer.parseInt(m.group(4));
|
||||||
|
ExpansionSet set = Sets.findSet(setCode);
|
||||||
|
String card = null;
|
||||||
|
if (set != null) {
|
||||||
|
card = set.findCardName(cardNum);
|
||||||
|
}
|
||||||
|
if (card != null) {
|
||||||
|
for (int i = 0; i < count; i++) {
|
||||||
|
if (!sideboard) {
|
||||||
|
deckList.getCards().add(card);
|
||||||
|
} else {
|
||||||
|
deckList.getSideboard().add(card);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
sbMessage.append("Could not find card '").append("' at line ").append(lineCount).append(": ").append(line).append("\n");
|
||||||
|
}
|
||||||
|
} else if (line.startsWith("NAME:")) {
|
||||||
|
deckList.setName(line.substring(5, line.length()));
|
||||||
|
} else if (line.startsWith("AUTHOR:")) {
|
||||||
|
deckList.setAuthor(line.substring(7, line.length()));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,7 +26,7 @@
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.client.deckeditor;
|
package mage.cards.decks.importer;
|
||||||
|
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
|
@ -26,7 +26,7 @@
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.client.deckeditor;
|
package mage.cards.decks.importer;
|
||||||
|
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
|
|
||||||
|
@ -37,5 +37,6 @@ import mage.cards.decks.DeckCardLists;
|
||||||
public interface DeckImporter {
|
public interface DeckImporter {
|
||||||
|
|
||||||
public DeckCardLists importDeck(String file);
|
public DeckCardLists importDeck(String file);
|
||||||
|
public String getErrors();
|
||||||
|
|
||||||
}
|
}
|
|
@ -26,13 +26,11 @@
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.client.deckeditor;
|
package mage.cards.decks.importer;
|
||||||
|
|
||||||
import java.io.File;
|
import java.io.File;
|
||||||
import java.util.Scanner;
|
import java.util.Scanner;
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
import mage.client.MageFrame;
|
|
||||||
import org.apache.log4j.Logger;
|
import org.apache.log4j.Logger;
|
||||||
|
|
||||||
/**
|
/**
|
||||||
|
@ -61,11 +59,9 @@ public abstract class DeckImporterImpl implements DeckImporter {
|
||||||
}
|
}
|
||||||
if (sbMessage.length() > 0) {
|
if (sbMessage.length() > 0) {
|
||||||
logger.fatal(sbMessage);
|
logger.fatal(sbMessage);
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), sbMessage.toString(), "Error importing deck", JOptionPane.ERROR_MESSAGE);
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
catch (Exception ex) {
|
catch (Exception ex) {
|
||||||
JOptionPane.showMessageDialog(MageFrame.getDesktop(), ex.getMessage(), "Error importing deck", JOptionPane.ERROR_MESSAGE);
|
|
||||||
logger.fatal(null, ex);
|
logger.fatal(null, ex);
|
||||||
}
|
}
|
||||||
finally {
|
finally {
|
||||||
|
@ -77,5 +73,10 @@ public abstract class DeckImporterImpl implements DeckImporter {
|
||||||
return deckList;
|
return deckList;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public String getErrors(){
|
||||||
|
return sbMessage.toString();
|
||||||
|
}
|
||||||
|
|
||||||
protected abstract void readLine(String line, DeckCardLists deckList);
|
protected abstract void readLine(String line, DeckCardLists deckList);
|
||||||
}
|
}
|
|
@ -0,0 +1,60 @@
|
||||||
|
/*
|
||||||
|
* Copyright 2010 BetaSteward_at_googlemail.com. All rights reserved.
|
||||||
|
*
|
||||||
|
* Redistribution and use in source and binary forms, with or without modification, are
|
||||||
|
* permitted provided that the following conditions are met:
|
||||||
|
*
|
||||||
|
* 1. Redistributions of source code must retain the above copyright notice, this list of
|
||||||
|
* conditions and the following disclaimer.
|
||||||
|
*
|
||||||
|
* 2. Redistributions in binary form must reproduce the above copyright notice, this list
|
||||||
|
* of conditions and the following disclaimer in the documentation and/or other materials
|
||||||
|
* provided with the distribution.
|
||||||
|
*
|
||||||
|
* THIS SOFTWARE IS PROVIDED BY BetaSteward_at_googlemail.com ``AS IS'' AND ANY EXPRESS OR IMPLIED
|
||||||
|
* WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND
|
||||||
|
* FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL BetaSteward_at_googlemail.com OR
|
||||||
|
* CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
|
||||||
|
* CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR
|
||||||
|
* SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON
|
||||||
|
* ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING
|
||||||
|
* NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF
|
||||||
|
* ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
||||||
|
*
|
||||||
|
* The views and conclusions contained in the software and documentation are those of the
|
||||||
|
* authors and should not be interpreted as representing official policies, either expressed
|
||||||
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
|
*/
|
||||||
|
package mage.cards.decks.importer;
|
||||||
|
|
||||||
|
import mage.cards.decks.DeckCardLists;
|
||||||
|
|
||||||
|
/**
|
||||||
|
*
|
||||||
|
* @author North
|
||||||
|
*/
|
||||||
|
public class DeckImporterUtil {
|
||||||
|
|
||||||
|
public static DeckImporter getDeckImporter(String file) {
|
||||||
|
if (file.toLowerCase().endsWith("dec")) {
|
||||||
|
return new DecDeckImporter();
|
||||||
|
} else if (file.toLowerCase().endsWith("mwdeck")) {
|
||||||
|
return new MWSDeckImporter();
|
||||||
|
} else if (file.toLowerCase().endsWith("txt")) {
|
||||||
|
return new TxtDeckImporter();
|
||||||
|
} else if (file.toLowerCase().endsWith("dck")) {
|
||||||
|
return new DckDeckImporter();
|
||||||
|
} else {
|
||||||
|
return null;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
public static DeckCardLists importDeck(String file) {
|
||||||
|
DeckImporter deckImporter = getDeckImporter(file);
|
||||||
|
if (deckImporter != null) {
|
||||||
|
return deckImporter.importDeck(file);
|
||||||
|
} else {
|
||||||
|
return new DeckCardLists();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
|
@ -26,13 +26,11 @@
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.client.deckeditor;
|
package mage.cards.decks.importer;
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.ExpansionSet;
|
import mage.cards.ExpansionSet;
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
||||||
import mage.client.MageFrame;
|
|
||||||
import mage.sets.Sets;
|
import mage.sets.Sets;
|
||||||
|
|
||||||
/**
|
/**
|
|
@ -26,7 +26,7 @@
|
||||||
* or implied, of BetaSteward_at_googlemail.com.
|
* or implied, of BetaSteward_at_googlemail.com.
|
||||||
*/
|
*/
|
||||||
|
|
||||||
package mage.client.deckeditor;
|
package mage.cards.decks.importer;
|
||||||
|
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.decks.DeckCardLists;
|
import mage.cards.decks.DeckCardLists;
|
|
@ -28,13 +28,10 @@
|
||||||
|
|
||||||
package mage.sets;
|
package mage.sets;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
import java.io.FileNotFoundException;
|
||||||
import java.io.PrintWriter;
|
import java.io.PrintWriter;
|
||||||
import java.lang.reflect.Constructor;
|
import java.lang.reflect.Constructor;
|
||||||
import java.util.*;
|
import java.util.*;
|
||||||
import java.util.regex.Matcher;
|
|
||||||
import java.util.regex.Pattern;
|
|
||||||
import mage.Constants.CardType;
|
import mage.Constants.CardType;
|
||||||
import mage.Constants.ColoredManaSymbol;
|
import mage.Constants.ColoredManaSymbol;
|
||||||
import mage.Mana;
|
import mage.Mana;
|
||||||
|
@ -297,50 +294,6 @@ public class Sets extends HashMap<String, ExpansionSet> {
|
||||||
return null;
|
return null;
|
||||||
}
|
}
|
||||||
|
|
||||||
public static DeckCardLists loadDeck(String file) throws FileNotFoundException {
|
|
||||||
DeckCardLists deckList = new DeckCardLists();
|
|
||||||
|
|
||||||
File f = new File(file);
|
|
||||||
Scanner scanner = new Scanner(f);
|
|
||||||
Pattern pattern = Pattern.compile("(SB:)?\\s*(\\d*)\\s*\\[([a-zA-Z0-9]{3}):(\\d*)\\].*");
|
|
||||||
try {
|
|
||||||
while (scanner.hasNextLine()) {
|
|
||||||
String line = scanner.nextLine().trim();
|
|
||||||
if (line.startsWith("#")) continue;
|
|
||||||
Matcher m = pattern.matcher(line);
|
|
||||||
if (m.matches()) {
|
|
||||||
boolean sideboard = false;
|
|
||||||
if (m.group(1) != null && m.group(1).equals("SB:"))
|
|
||||||
sideboard = true;
|
|
||||||
int count = Integer.parseInt(m.group(2));
|
|
||||||
String setCode = m.group(3);
|
|
||||||
int cardNum = Integer.parseInt(m.group(4));
|
|
||||||
ExpansionSet set = Sets.findSet(setCode);
|
|
||||||
String card = set.findCardName(cardNum);
|
|
||||||
for (int i = 0; i < count; i++) {
|
|
||||||
if (!sideboard) {
|
|
||||||
deckList.getCards().add(card);
|
|
||||||
}
|
|
||||||
else {
|
|
||||||
deckList.getSideboard().add(card);
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (line.startsWith("NAME:")) {
|
|
||||||
deckList.setName(line.substring(5, line.length()));
|
|
||||||
}
|
|
||||||
else if (line.startsWith("AUTHOR:")) {
|
|
||||||
deckList.setAuthor(line.substring(7, line.length()));
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
finally {
|
|
||||||
scanner.close();
|
|
||||||
}
|
|
||||||
|
|
||||||
return deckList;
|
|
||||||
}
|
|
||||||
|
|
||||||
public static void saveDeck(String file, DeckCardLists deck) throws FileNotFoundException {
|
public static void saveDeck(String file, DeckCardLists deck) throws FileNotFoundException {
|
||||||
PrintWriter out = new PrintWriter(file);
|
PrintWriter out = new PrintWriter(file);
|
||||||
Map<String, Integer> deckCards = new HashMap<String, Integer>();
|
Map<String, Integer> deckCards = new HashMap<String, Integer>();
|
||||||
|
|
|
@ -1,8 +1,12 @@
|
||||||
package org.mage.test.serverside.base;
|
package org.mage.test.serverside.base;
|
||||||
|
|
||||||
|
import java.io.File;
|
||||||
|
import java.io.FileNotFoundException;
|
||||||
import mage.Constants;
|
import mage.Constants;
|
||||||
|
import mage.Constants.PhaseStep;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.filter.Filter;
|
import mage.filter.Filter;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.GameException;
|
import mage.game.GameException;
|
||||||
|
@ -10,15 +14,10 @@ import mage.game.GameOptions;
|
||||||
import mage.game.TwoPlayerDuel;
|
import mage.game.TwoPlayerDuel;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.sets.Sets;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.mage.test.serverside.base.impl.CardTestAPIImpl;
|
import org.mage.test.serverside.base.impl.CardTestAPIImpl;
|
||||||
|
|
||||||
import java.io.File;
|
|
||||||
import java.io.FileNotFoundException;
|
|
||||||
import mage.Constants.PhaseStep;
|
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Base class for testing single cards and effects.
|
* Base class for testing single cards and effects.
|
||||||
*
|
*
|
||||||
|
@ -86,7 +85,7 @@ public abstract class CardTestBase extends CardTestAPIImpl {
|
||||||
playerA = createNewPlayer("PlayerA", aiTypeA);
|
playerA = createNewPlayer("PlayerA", aiTypeA);
|
||||||
playerA.setTestMode(true);
|
playerA.setTestMode(true);
|
||||||
logger.info("Loading deck...");
|
logger.info("Loading deck...");
|
||||||
Deck deck = Deck.load(Sets.loadDeck("RB Aggro.dck"));
|
Deck deck = Deck.load(DeckImporterUtil.importDeck("RB Aggro.dck"));
|
||||||
logger.info("Done!");
|
logger.info("Done!");
|
||||||
if (deck.getCards().size() < 40) {
|
if (deck.getCards().size() < 40) {
|
||||||
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck.getCards().size());
|
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck.getCards().size());
|
||||||
|
@ -96,7 +95,7 @@ public abstract class CardTestBase extends CardTestAPIImpl {
|
||||||
|
|
||||||
playerB = createNewPlayer("PlayerB", aiTypeB);
|
playerB = createNewPlayer("PlayerB", aiTypeB);
|
||||||
playerB.setTestMode(true);
|
playerB.setTestMode(true);
|
||||||
Deck deck2 = Deck.load(Sets.loadDeck("RB Aggro.dck"));
|
Deck deck2 = Deck.load(DeckImporterUtil.importDeck("RB Aggro.dck"));
|
||||||
if (deck2.getCards().size() < 40) {
|
if (deck2.getCards().size() < 40) {
|
||||||
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck2.getCards().size());
|
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck2.getCards().size());
|
||||||
}
|
}
|
||||||
|
@ -144,7 +143,7 @@ public abstract class CardTestBase extends CardTestAPIImpl {
|
||||||
playerA = createNewPlayer("ComputerA", aiTypeA);
|
playerA = createNewPlayer("ComputerA", aiTypeA);
|
||||||
playerA.setTestMode(true);
|
playerA.setTestMode(true);
|
||||||
|
|
||||||
Deck deck = Deck.load(Sets.loadDeck("RB Aggro.dck"));
|
Deck deck = Deck.load(DeckImporterUtil.importDeck("RB Aggro.dck"));
|
||||||
|
|
||||||
if (deck.getCards().size() < 40) {
|
if (deck.getCards().size() < 40) {
|
||||||
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck.getCards().size());
|
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck.getCards().size());
|
||||||
|
@ -154,7 +153,7 @@ public abstract class CardTestBase extends CardTestAPIImpl {
|
||||||
|
|
||||||
playerB = createNewPlayer("ComputerB", aiTypeB);
|
playerB = createNewPlayer("ComputerB", aiTypeB);
|
||||||
playerB.setTestMode(true);
|
playerB.setTestMode(true);
|
||||||
Deck deck2 = Deck.load(Sets.loadDeck("RB Aggro.dck"));
|
Deck deck2 = Deck.load(DeckImporterUtil.importDeck("RB Aggro.dck"));
|
||||||
if (deck2.getCards().size() < 40) {
|
if (deck2.getCards().size() < 40) {
|
||||||
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck2.getCards().size());
|
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck2.getCards().size());
|
||||||
}
|
}
|
||||||
|
@ -308,7 +307,6 @@ public abstract class CardTestBase extends CardTestAPIImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Assert.assertEquals("(Graveyard) Card counts are not equal (" + cardName + ")", expectedCount, actualCount);
|
Assert.assertEquals("(Graveyard) Card counts are not equal (" + cardName + ")", expectedCount, actualCount);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|
|
@ -6,6 +6,7 @@ import mage.Constants;
|
||||||
import mage.Constants.PhaseStep;
|
import mage.Constants.PhaseStep;
|
||||||
import mage.cards.Card;
|
import mage.cards.Card;
|
||||||
import mage.cards.decks.Deck;
|
import mage.cards.decks.Deck;
|
||||||
|
import mage.cards.decks.importer.DeckImporterUtil;
|
||||||
import mage.filter.Filter;
|
import mage.filter.Filter;
|
||||||
import mage.game.Game;
|
import mage.game.Game;
|
||||||
import mage.game.GameException;
|
import mage.game.GameException;
|
||||||
|
@ -13,7 +14,6 @@ import mage.game.GameOptions;
|
||||||
import mage.game.TwoPlayerDuel;
|
import mage.game.TwoPlayerDuel;
|
||||||
import mage.game.permanent.Permanent;
|
import mage.game.permanent.Permanent;
|
||||||
import mage.players.Player;
|
import mage.players.Player;
|
||||||
import mage.sets.Sets;
|
|
||||||
import org.junit.Assert;
|
import org.junit.Assert;
|
||||||
import org.junit.Before;
|
import org.junit.Before;
|
||||||
import org.mage.test.player.TestPlayer;
|
import org.mage.test.player.TestPlayer;
|
||||||
|
@ -57,7 +57,7 @@ public abstract class CardTestPlayerBase extends CardTestPlayerAPIImpl {
|
||||||
playerA = createNewPlayer("PlayerA");
|
playerA = createNewPlayer("PlayerA");
|
||||||
playerA.setTestMode(true);
|
playerA.setTestMode(true);
|
||||||
logger.info("Loading deck...");
|
logger.info("Loading deck...");
|
||||||
Deck deck = Deck.load(Sets.loadDeck("RB Aggro.dck"));
|
Deck deck = Deck.load(DeckImporterUtil.importDeck("RB Aggro.dck"));
|
||||||
logger.info("Done!");
|
logger.info("Done!");
|
||||||
if (deck.getCards().size() < 40) {
|
if (deck.getCards().size() < 40) {
|
||||||
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck.getCards().size());
|
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck.getCards().size());
|
||||||
|
@ -67,7 +67,7 @@ public abstract class CardTestPlayerBase extends CardTestPlayerAPIImpl {
|
||||||
|
|
||||||
playerB = createNewPlayer("PlayerB");
|
playerB = createNewPlayer("PlayerB");
|
||||||
playerB.setTestMode(true);
|
playerB.setTestMode(true);
|
||||||
Deck deck2 = Deck.load(Sets.loadDeck("RB Aggro.dck"));
|
Deck deck2 = Deck.load(DeckImporterUtil.importDeck("RB Aggro.dck"));
|
||||||
if (deck2.getCards().size() < 40) {
|
if (deck2.getCards().size() < 40) {
|
||||||
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck2.getCards().size());
|
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck2.getCards().size());
|
||||||
}
|
}
|
||||||
|
@ -113,7 +113,7 @@ public abstract class CardTestPlayerBase extends CardTestPlayerAPIImpl {
|
||||||
playerA = createNewPlayer("ComputerA");
|
playerA = createNewPlayer("ComputerA");
|
||||||
playerA.setTestMode(true);
|
playerA.setTestMode(true);
|
||||||
|
|
||||||
Deck deck = Deck.load(Sets.loadDeck("RB Aggro.dck"));
|
Deck deck = Deck.load(DeckImporterUtil.importDeck("RB Aggro.dck"));
|
||||||
|
|
||||||
if (deck.getCards().size() < 40) {
|
if (deck.getCards().size() < 40) {
|
||||||
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck.getCards().size());
|
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck.getCards().size());
|
||||||
|
@ -123,7 +123,7 @@ public abstract class CardTestPlayerBase extends CardTestPlayerAPIImpl {
|
||||||
|
|
||||||
playerB = createNewPlayer("ComputerB");
|
playerB = createNewPlayer("ComputerB");
|
||||||
playerB.setTestMode(true);
|
playerB.setTestMode(true);
|
||||||
Deck deck2 = Deck.load(Sets.loadDeck("RB Aggro.dck"));
|
Deck deck2 = Deck.load(DeckImporterUtil.importDeck("RB Aggro.dck"));
|
||||||
if (deck2.getCards().size() < 40) {
|
if (deck2.getCards().size() < 40) {
|
||||||
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck2.getCards().size());
|
throw new IllegalArgumentException("Couldn't load deck, deck size=" + deck2.getCards().size());
|
||||||
}
|
}
|
||||||
|
@ -277,7 +277,6 @@ public abstract class CardTestPlayerBase extends CardTestPlayerAPIImpl {
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
Assert.assertEquals("(Graveyard) Card counts are not equal (" + cardName + ")", expectedCount, actualCount);
|
Assert.assertEquals("(Graveyard) Card counts are not equal (" + cardName + ")", expectedCount, actualCount);
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -304,8 +303,7 @@ public abstract class CardTestPlayerBase extends CardTestPlayerAPIImpl {
|
||||||
if (scope.equals(Filter.ComparisonScope.All)) {
|
if (scope.equals(Filter.ComparisonScope.All)) {
|
||||||
throw new UnsupportedOperationException("ComparisonScope.All is not implemented.");
|
throw new UnsupportedOperationException("ComparisonScope.All is not implemented.");
|
||||||
}
|
}
|
||||||
int count = 0;
|
|
||||||
int fit = 0;
|
|
||||||
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(player.getId())) {
|
for (Permanent permanent : currentGame.getBattlefield().getAllActivePermanents(player.getId())) {
|
||||||
if (permanent.getName().equals(cardName)) {
|
if (permanent.getName().equals(cardName)) {
|
||||||
Assert.assertEquals("Power is not the same", power, permanent.getPower().getValue());
|
Assert.assertEquals("Power is not the same", power, permanent.getPower().getValue());
|
||||||
|
|
Loading…
Add table
Reference in a new issue