detect client version + client changes for AI skill level

This commit is contained in:
BetaSteward 2011-04-28 22:52:52 -04:00
parent 0968d4c00a
commit 86f708b17a
46 changed files with 362 additions and 540 deletions

View file

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>mage-root</artifactId> <artifactId>mage-root</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>

View file

@ -76,6 +76,7 @@ import mage.client.draft.DraftPane;
import mage.client.game.GamePane; import mage.client.game.GamePane;
import mage.client.table.TablesPane; import mage.client.table.TablesPane;
import mage.client.tournament.TournamentPane; import mage.client.tournament.TournamentPane;
import mage.utils.MageVersion;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
@ -90,6 +91,7 @@ public class MageFrame extends javax.swing.JFrame {
private static Preferences prefs = Preferences.userNodeForPackage(MageFrame.class); private static Preferences prefs = Preferences.userNodeForPackage(MageFrame.class);
private JLabel title; private JLabel title;
private Rectangle titleRectangle; private Rectangle titleRectangle;
private static MageVersion version = new MageVersion(0, 7, 2);
/** /**
* @return the session * @return the session
@ -106,12 +108,16 @@ public class MageFrame extends javax.swing.JFrame {
return prefs; return prefs;
} }
public static MageVersion getVersion() {
return version;
}
/** /**
* Creates new form MageFrame * Creates new form MageFrame
*/ */
public MageFrame() { public MageFrame() {
setTitle("Mage, version 0.7.1"); setTitle("Mage, version " + version);
EDTExceptionHandler.registerExceptionHandler(); EDTExceptionHandler.registerExceptionHandler();
addWindowListener(new WindowAdapter() { addWindowListener(new WindowAdapter() {

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.1" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo"> <Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<Properties> <Properties>
@ -22,27 +22,28 @@
<Layout> <Layout>
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace pref="159" max="32767" attributes="0"/>
<Component id="btnOk" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/> <Group type="102" alignment="0" attributes="0">
<Component id="lblVersion" min="-2" max="-2" attributes="0"/> <Component id="jLabel3" max="32767" attributes="0"/>
<EmptySpace pref="109" max="32767" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="1" attributes="0">
<EmptySpace max="-2" attributes="0"/> <Component id="btnOk" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/> </Group>
</Group> <Group type="102" alignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jLabel3" min="-2" max="-2" attributes="0"/> <Component id="lblVersion" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="75" max="32767" attributes="0"/> <EmptySpace pref="311" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="203" max="32767" attributes="0"/>
</Group>
</Group>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -57,8 +58,8 @@
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/> <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jLabel3" min="-2" max="-2" attributes="0"/> <Component id="jLabel3" pref="40" max="32767" attributes="0"/>
<EmptySpace pref="23" max="32767" attributes="0"/> <EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="btnOk" min="-2" max="-2" attributes="0"/> <Component id="btnOk" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
</Group> </Group>
@ -81,7 +82,7 @@
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblVersion"> <Component class="javax.swing.JLabel" name="lblVersion">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="version"/> <Property name="text" type="java.lang.String" value="0.0.0"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="jLabel2"> <Component class="javax.swing.JLabel" name="jLabel2">
@ -91,7 +92,7 @@
</Component> </Component>
<Component class="javax.swing.JLabel" name="jLabel3"> <Component class="javax.swing.JLabel" name="jLabel3">
<Properties> <Properties>
<Property name="text" type="java.lang.String" value="Thanks: KLo, Cosmo &amp; Fritz"/> <Property name="text" type="java.lang.String" value="Devs: BetaSteward, Nantuko84, Eugen.Rivniy, maurer.it, Viserion Dragonbourne"/>
</Properties> </Properties>
</Component> </Component>
</SubComponents> </SubComponents>

View file

@ -34,6 +34,8 @@
package mage.client.dialog; package mage.client.dialog;
import mage.client.MageFrame;
/** /**
* *
* @author BetaSteward_at_googlemail.com * @author BetaSteward_at_googlemail.com
@ -47,7 +49,7 @@ public class AboutDialog extends MageDialog {
} }
public void showDialog() { public void showDialog() {
this.lblVersion.setText(MageDialog.class.getPackage().getImplementationVersion()); this.lblVersion.setText(MageFrame.getVersion().toString());
this.setLocation(100, 100); this.setLocation(100, 100);
this.setVisible(true); this.setVisible(true);
} }
@ -66,7 +68,6 @@ public class AboutDialog extends MageDialog {
lblVersion = new javax.swing.JLabel(); lblVersion = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel(); jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
setTitle("About MAGE"); setTitle("About MAGE");
@ -77,42 +78,35 @@ public class AboutDialog extends MageDialog {
} }
}); });
jLabel1.setText("MAGE client, version 0.7.1"); jLabel1.setText("MAGE client");
lblVersion.setText("version"); lblVersion.setText("0.0.0");
jLabel2.setText("Courtesy: BetaSteward@googlemail.com"); jLabel2.setText("Courtesy: BetaSteward@googlemail.com");
jLabel3.setText("Devs: BetaSteward, Nantuko84, Eugen.Rivniy, maurer.it"); jLabel3.setText("Devs: BetaSteward, Nantuko84, Eugen.Rivniy, maurer.it, Viserion Dragonbourne");
//jLabel4.setText("Thanks: KLo, Cosmo & Fritz");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane()); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout); getContentPane().setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(159, Short.MAX_VALUE)
.addComponent(btnOk)
.addContainerGap())
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addContainerGap()
.addComponent(jLabel1) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createSequentialGroup()
.addComponent(lblVersion) .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap(109, Short.MAX_VALUE)) .addContainerGap())
.addGroup(layout.createSequentialGroup() .addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap() .addComponent(btnOk)
.addComponent(jLabel2) .addContainerGap())
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addGroup(layout.createSequentialGroup()
.addGroup(layout.createSequentialGroup() .addComponent(jLabel1)
.addContainerGap() .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel3) .addComponent(lblVersion)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addContainerGap(311, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addContainerGap() .addComponent(jLabel2)
.addComponent(jLabel4) .addContainerGap(203, Short.MAX_VALUE))))
.addContainerGap(75, Short.MAX_VALUE))
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -124,10 +118,8 @@ public class AboutDialog extends MageDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2) .addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel3) .addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 40, Short.MAX_VALUE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGap(18, 18, 18)
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
.addComponent(btnOk) .addComponent(btnOk)
.addContainerGap()) .addContainerGap())
); );
@ -144,7 +136,6 @@ public class AboutDialog extends MageDialog {
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3; private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel lblVersion; private javax.swing.JLabel lblVersion;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables

View file

@ -136,7 +136,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", Sets.loadDeck(this.newPlayerPanel.getDeckFile())); joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", 1, Sets.loadDeck(this.newPlayerPanel.getDeckFile()));
} catch (Exception ex) { } catch (Exception ex) {
handleError(ex); handleError(ex);
} }

View file

@ -310,7 +310,7 @@ public class NewTableDialog extends MageDialog {
options.setWinsNeeded((Integer)this.spnNumWins.getValue()); options.setWinsNeeded((Integer)this.spnNumWins.getValue());
table = session.createTable(roomId, options); table = session.createTable(roomId, options);
try { try {
if (session.joinTable(roomId, table.getTableId(), this.player1Panel.getPlayerName(), "Human", Sets.loadDeck(this.player1Panel.getDeckFile()))) { if (session.joinTable(roomId, table.getTableId(), this.player1Panel.getPlayerName(), "Human", 1, Sets.loadDeck(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())) {

View file

@ -296,7 +296,7 @@ public class NewTournamentDialog extends MageDialog {
tOptions.getMatchOptions().setAttackOption(MultiplayerAttackOption.LEFT); tOptions.getMatchOptions().setAttackOption(MultiplayerAttackOption.LEFT);
tOptions.getMatchOptions().setRange(RangeOfInfluence.ALL); tOptions.getMatchOptions().setRange(RangeOfInfluence.ALL);
table = session.createTournamentTable(roomId, tOptions); table = session.createTournamentTable(roomId, tOptions);
if (session.joinTournamentTable(roomId, table.getTableId(), this.txtPlayer1Name.getText(), "Human")) { if (session.joinTournamentTable(roomId, table.getTableId(), this.txtPlayer1Name.getText(), "Human", 1)) {
for (TournamentPlayerPanel player: players) { for (TournamentPlayerPanel player: players) {
if (!player.getPlayerType().equals("Human")) { if (!player.getPlayerType().equals("Human")) {
if (!player.joinTournamentTable(roomId, table.getTableId())) { if (!player.joinTournamentTable(roomId, table.getTableId())) {

View file

@ -97,7 +97,7 @@ public class Session {
this.server = (Server) reg.lookup(Config.remoteServer); this.server = (Server) reg.lookup(Config.remoteServer);
this.userName = userName; this.userName = userName;
this.client = new Client(this, frame, userName); this.client = new Client(this, frame, userName);
sessionId = server.registerClient(userName, client.getId()); sessionId = server.registerClient(userName, client.getId(), frame.getVersion());
callbackDaemon = new CallbackClientDaemon(sessionId, client, server); callbackDaemon = new CallbackClientDaemon(sessionId, client, server);
serverState = server.getServerState(); serverState = server.getServerState();
logger.info("Connected to RMI server at " + serverName + ":" + port); logger.info("Connected to RMI server at " + serverName + ":" + port);
@ -262,9 +262,9 @@ public class Session {
return false; return false;
} }
public boolean joinTable(UUID roomId, UUID tableId, String playerName, String playerType, DeckCardLists deckList) { public boolean joinTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill, DeckCardLists deckList) {
try { try {
return server.joinTable(sessionId, roomId, tableId, playerName, playerType, deckList); return server.joinTable(sessionId, roomId, tableId, playerName, playerType, skill, deckList);
} catch (RemoteException ex) { } catch (RemoteException ex) {
handleRemoteException(ex); handleRemoteException(ex);
} catch (MageException ex) { } catch (MageException ex) {
@ -275,9 +275,9 @@ public class Session {
return false; return false;
} }
public boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, String playerType) { public boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, String playerType, int skill) {
try { try {
return server.joinTournamentTable(sessionId, roomId, tableId, playerName, playerType); return server.joinTournamentTable(sessionId, roomId, tableId, playerName, playerType, skill);
} catch (RemoteException ex) { } catch (RemoteException ex) {
handleRemoteException(ex); handleRemoteException(ex);
} catch (MageException ex) { } catch (MageException ex) {

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.1" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> <Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues> <AuxValues>
@ -26,11 +26,22 @@
</Group> </Group>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Component id="txtPlayerName" alignment="0" pref="405" max="32767" attributes="1"/> <Component id="txtPlayerName" pref="321" max="32767" attributes="2"/>
<Component id="txtPlayerDeck" alignment="0" pref="405" max="32767" attributes="1"/> <Component id="txtPlayerDeck" alignment="0" pref="321" max="32767" attributes="2"/>
</Group> </Group>
<EmptySpace min="-2" max="-2" attributes="0"/> <EmptySpace min="-2" max="-2" attributes="0"/>
<Component id="btnPlayerDeck" min="-2" pref="24" max="-2" attributes="0"/> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Component id="btnPlayerDeck" min="-2" pref="24" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnGenerate" min="-2" pref="87" max="-2" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<Component id="lblLevel" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbLevel" min="-2" pref="45" max="-2" attributes="0"/>
</Group>
</Group>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
@ -40,12 +51,15 @@
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="txtPlayerName" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="txtPlayerName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblPlayerName" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblPlayerName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lblLevel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbLevel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
<EmptySpace min="-2" pref="3" max="-2" attributes="0"/> <EmptySpace min="-2" pref="3" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" groupAlignment="3" attributes="0">
<Component id="lblPlayerDeck" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="lblPlayerDeck" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="txtPlayerDeck" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="txtPlayerDeck" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnPlayerDeck" alignment="3" min="-2" pref="19" max="-2" attributes="0"/> <Component id="btnPlayerDeck" alignment="3" min="-2" pref="21" max="-2" attributes="0"/>
<Component id="btnGenerate" alignment="3" min="-2" pref="21" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
</Group> </Group>
@ -54,9 +68,6 @@
<SubComponents> <SubComponents>
<Component class="javax.swing.JLabel" name="lblPlayerName"> <Component class="javax.swing.JLabel" name="lblPlayerName">
<Properties> <Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="txtPlayerName"/>
</Property>
<Property name="text" type="java.lang.String" value="Name:"/> <Property name="text" type="java.lang.String" value="Name:"/>
</Properties> </Properties>
</Component> </Component>
@ -64,9 +75,6 @@
</Component> </Component>
<Component class="javax.swing.JLabel" name="lblPlayerDeck"> <Component class="javax.swing.JLabel" name="lblPlayerDeck">
<Properties> <Properties>
<Property name="labelFor" type="java.awt.Component" editor="org.netbeans.modules.form.ComponentChooserEditor">
<ComponentRef name="txtPlayerDeck"/>
</Property>
<Property name="text" type="java.lang.String" value="Deck:"/> <Property name="text" type="java.lang.String" value="Deck:"/>
</Properties> </Properties>
</Component> </Component>
@ -80,5 +88,36 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnPlayerDeckActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnPlayerDeckActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="javax.swing.JButton" name="btnGenerate">
<Properties>
<Property name="text" type="java.lang.String" value="Generate"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnGenerateActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JLabel" name="lblLevel">
<Properties>
<Property name="text" type="java.lang.String" value="Skill:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="cbLevel">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="10">
<StringItem index="0" value="1"/>
<StringItem index="1" value="2"/>
<StringItem index="2" value="3"/>
<StringItem index="3" value="4"/>
<StringItem index="4" value="5"/>
<StringItem index="5" value="6"/>
<StringItem index="6" value="7"/>
<StringItem index="7" value="8"/>
<StringItem index="8" value="9"/>
<StringItem index="9" value="10"/>
</StringArray>
</Property>
</Properties>
</Component>
</SubComponents> </SubComponents>
</Form> </Form>

View file

@ -36,10 +36,8 @@ package mage.client.table;
import java.io.File; import java.io.File;
import java.io.IOException; import java.io.IOException;
import javax.swing.JFileChooser; import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter; import javax.swing.filechooser.FileFilter;
import mage.client.MageFrame; import mage.client.MageFrame;
import mage.client.deck.generator.DeckGenerator; import mage.client.deck.generator.DeckGenerator;
import mage.client.util.Config; import mage.client.util.Config;
@ -62,7 +60,7 @@ public class NewPlayerPanel extends javax.swing.JPanel {
if (Config.defaultComputerName != null) this.txtPlayerName.setText(Config.defaultComputerName); if (Config.defaultComputerName != null) this.txtPlayerName.setText(Config.defaultComputerName);
} }
public void setPlayerName(String playerName) { public void setPlayerName(String playerName) {
this.txtPlayerName.setText(playerName); this.txtPlayerName.setText(playerName);
this.txtPlayerName.setEditable(false); this.txtPlayerName.setEditable(false);
this.txtPlayerName.setEnabled(false); this.txtPlayerName.setEnabled(false);
@ -98,14 +96,17 @@ public class NewPlayerPanel extends javax.swing.JPanel {
return this.txtPlayerDeck.getText(); return this.txtPlayerDeck.getText();
} }
public int getLevel() {
return Integer.valueOf((String)this.cbLevel.getSelectedItem());
}
/** This method is called from within the constructor to /** This method is called from within the constructor to
* initialize the form. * initialize the form.
* WARNING: Do NOT modify this code. The content of this method is * WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor. * always regenerated by the Form Editor.
*/ */
@SuppressWarnings("unchecked") @SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code"> // <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
// </editor-fold>
private void initComponents() { private void initComponents() {
lblPlayerName = new javax.swing.JLabel(); lblPlayerName = new javax.swing.JLabel();
@ -114,11 +115,11 @@ public class NewPlayerPanel extends javax.swing.JPanel {
txtPlayerDeck = new javax.swing.JTextField(); txtPlayerDeck = new javax.swing.JTextField();
btnPlayerDeck = new javax.swing.JButton(); btnPlayerDeck = new javax.swing.JButton();
btnGenerate = new javax.swing.JButton(); btnGenerate = new javax.swing.JButton();
lblLevel = new javax.swing.JLabel();
cbLevel = new javax.swing.JComboBox();
lblPlayerName.setLabelFor(txtPlayerName);
lblPlayerName.setText("Name:"); lblPlayerName.setText("Name:");
lblPlayerDeck.setLabelFor(txtPlayerDeck);
lblPlayerDeck.setText("Deck:"); lblPlayerDeck.setText("Deck:");
btnPlayerDeck.setText("..."); btnPlayerDeck.setText("...");
@ -128,13 +129,17 @@ public class NewPlayerPanel extends javax.swing.JPanel {
} }
}); });
btnGenerate.setText("Generate deck"); btnGenerate.setText("Generate");
btnGenerate.addActionListener(new java.awt.event.ActionListener() { btnGenerate.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) { public void actionPerformed(java.awt.event.ActionEvent evt) {
btnGenerateActionPerformed(evt); btnGenerateActionPerformed(evt);
} }
}); });
lblLevel.setText("Skill:");
cbLevel.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this); javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout); this.setLayout(layout);
layout.setHorizontalGroup( layout.setHorizontalGroup(
@ -147,50 +152,56 @@ public class NewPlayerPanel extends javax.swing.JPanel {
.addComponent(lblPlayerName)) .addComponent(lblPlayerName))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtPlayerName, javax.swing.GroupLayout.DEFAULT_SIZE, 405, Short.MAX_VALUE) .addComponent(txtPlayerName, javax.swing.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE)
.addComponent(txtPlayerDeck, javax.swing.GroupLayout.DEFAULT_SIZE, 405, Short.MAX_VALUE)) .addComponent(txtPlayerDeck, javax.swing.GroupLayout.DEFAULT_SIZE, 321, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnPlayerDeck, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addGroup(layout.createSequentialGroup()
) .addComponent(btnPlayerDeck, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnGenerate) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnGenerate, javax.swing.GroupLayout.PREFERRED_SIZE, 87, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGroup(layout.createSequentialGroup()
.addComponent(lblLevel)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 45, javax.swing.GroupLayout.PREFERRED_SIZE))))
); );
layout.setVerticalGroup( layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup() .addGroup(layout.createSequentialGroup()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtPlayerName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtPlayerName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(lblPlayerName)) .addComponent(lblPlayerName)
.addComponent(lblLevel)
.addComponent(cbLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
.addGap(3, 3, 3) .addGap(3, 3, 3)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblPlayerDeck) .addComponent(lblPlayerDeck)
.addComponent(txtPlayerDeck, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtPlayerDeck, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnPlayerDeck, javax.swing.GroupLayout.PREFERRED_SIZE, 19, javax.swing.GroupLayout.PREFERRED_SIZE)) .addComponent(btnPlayerDeck, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
.addGap(3, 3, 3) .addComponent(btnGenerate, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)))
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnGenerate)
)
)
); );
} }// </editor-fold>//GEN-END:initComponents
private void btnPlayerDeckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPlayerDeckActionPerformed private void btnPlayerDeckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPlayerDeckActionPerformed
playerLoadDeck(); playerLoadDeck();
}//GEN-LAST:event_btnPlayerDeckActionPerformed }//GEN-LAST:event_btnPlayerDeckActionPerformed
private void btnGenerateActionPerformed(java.awt.event.ActionEvent evt) { private void btnGenerateActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnGenerateActionPerformed
generateDeck(); generateDeck();
} }//GEN-LAST:event_btnGenerateActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnGenerate;
private javax.swing.JButton btnPlayerDeck; private javax.swing.JButton btnPlayerDeck;
private javax.swing.JComboBox cbLevel;
private javax.swing.JLabel lblLevel;
private javax.swing.JLabel lblPlayerDeck; private javax.swing.JLabel lblPlayerDeck;
private javax.swing.JLabel lblPlayerName; private javax.swing.JLabel lblPlayerName;
private javax.swing.JTextField txtPlayerDeck; private javax.swing.JTextField txtPlayerDeck;
private javax.swing.JTextField txtPlayerName; private javax.swing.JTextField txtPlayerName;
// End of variables declaration//GEN-END:variables // End of variables declaration//GEN-END:variables
private javax.swing.JButton btnGenerate;
} }
class DeckFilter extends FileFilter { class DeckFilter extends FileFilter {

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?> <?xml version="1.1" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo"> <Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues> <AuxValues>
@ -11,45 +11,10 @@
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/> <AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/> <AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/> <AuxValue name="FormSettings_variablesModifier" type="java.lang.Integer" value="2"/>
<AuxValue name="designerSize" type="java.awt.Dimension" value="-84,-19,0,5,115,114,0,18,106,97,118,97,46,97,119,116,46,68,105,109,101,110,115,105,111,110,65,-114,-39,-41,-84,95,68,20,2,0,2,73,0,6,104,101,105,103,104,116,73,0,5,119,105,100,116,104,120,112,0,0,1,44,0,0,1,-112"/>
</AuxValues> </AuxValues>
<Layout> <Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="lblPlayerNum" min="-2" max="-2" attributes="0"/>
<Group type="102" alignment="0" attributes="0">
<Component id="lbPlayerType" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbPlayerType" min="-2" pref="166" max="-2" attributes="1"/>
</Group>
</Group>
<EmptySpace max="-2" attributes="0"/>
<Component id="newPlayerPanel" pref="318" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" attributes="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="lblPlayerNum" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" attributes="0">
<Component id="cbPlayerType" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="lbPlayerType" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
<Component id="newPlayerPanel" alignment="0" pref="43" max="32767" attributes="0"/>
</Group>
<EmptySpace max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents> <SubComponents>
<Component class="javax.swing.JLabel" name="lbPlayerType"> <Component class="javax.swing.JLabel" name="lbPlayerType">
<Properties> <Properties>
@ -61,8 +26,6 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbPlayerTypeActionPerformed"/> <EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbPlayerTypeActionPerformed"/>
</Events> </Events>
</Component> </Component>
<Component class="mage.client.table.NewPlayerPanel" name="newPlayerPanel">
</Component>
<Component class="javax.swing.JLabel" name="lblPlayerNum"> <Component class="javax.swing.JLabel" name="lblPlayerNum">
<Properties> <Properties>
<Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor"> <Property name="font" type="java.awt.Font" editor="org.netbeans.beaninfo.editors.FontEditor">

View file

@ -73,20 +73,18 @@ public class TablePlayerPanel extends javax.swing.JPanel {
cbPlayerType.setModel(new DefaultComboBoxModel(session.getPlayerTypes())); cbPlayerType.setModel(new DefaultComboBoxModel(session.getPlayerTypes()));
this.lblPlayerNum.setText("Player " + playerNum); this.lblPlayerNum.setText("Player " + playerNum);
if (Config.defaultOtherPlayerIndex != null) { if (Config.defaultOtherPlayerIndex != null) {
try { if (Integer.valueOf(Config.defaultOtherPlayerIndex) >= cbPlayerType.getItemCount())
cbPlayerType.setSelectedIndex(cbPlayerType.getItemCount() - 1);
else {
Integer index = Integer.parseInt(Config.defaultOtherPlayerIndex); Integer index = Integer.parseInt(Config.defaultOtherPlayerIndex);
cbPlayerType.setSelectedIndex(index); cbPlayerType.setSelectedIndex(index);
} }
catch (NumberFormatException e) {}
catch (IllegalArgumentException iae) {
logger.warning("Wrong parameter for default AI type in config.");
}
} }
} }
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(), Sets.loadDeck(this.newPlayerPanel.getDeckFile())); return session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), (String)this.cbPlayerType.getSelectedItem(), this.newPlayerPanel.getLevel(), Sets.loadDeck(this.newPlayerPanel.getDeckFile()));
} }
return true; return true;
} }

View file

@ -101,7 +101,7 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
if (state.equals("Join")) { if (state.equals("Join")) {
if (isTournament) { if (isTournament) {
logger.info("Joining tournament " + tableId); logger.info("Joining tournament " + tableId);
if (session.joinTournamentTable(roomId, tableId, session.getUserName(), "Human")) if (session.joinTournamentTable(roomId, tableId, session.getUserName(), "Human", 1))
tableWaitingDialog.showDialog(roomId, tableId, true); tableWaitingDialog.showDialog(roomId, tableId, true);
} }
else { else {
@ -311,8 +311,8 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
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", Sets.loadDeck("test.dck")); session.joinTable(roomId, table.getTableId(), "Human", "Human", 1, Sets.loadDeck("test.dck"));
session.joinTable(roomId, table.getTableId(), "Computer", "Computer - default", Sets.loadDeck("test.dck")); session.joinTable(roomId, table.getTableId(), "Computer", "Computer - default", 1, Sets.loadDeck("test.dck"));
hideTables(); hideTables();
session.startGame(roomId, table.getTableId()); session.startGame(roomId, table.getTableId());
} catch (Exception ex) { } catch (Exception ex) {

View file

@ -21,7 +21,7 @@
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/> <Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="cbPlayerType" min="-2" pref="175" max="-2" attributes="0"/> <Component id="cbPlayerType" min="-2" pref="138" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="pnlPlayerName" max="32767" attributes="0"/> <Component id="pnlPlayerName" max="32767" attributes="0"/>
</Group> </Group>
@ -76,16 +76,22 @@
<DimensionLayout dim="0"> <DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0"> <Group type="102" alignment="0" attributes="0">
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="cbLevel" min="-2" pref="31" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/> <Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/> <EmptySpace max="-2" attributes="0"/>
<Component id="txtPlayerName" pref="189" max="32767" attributes="0"/> <Component id="txtPlayerName" pref="225" max="32767" attributes="0"/>
</Group> </Group>
</Group> </Group>
</DimensionLayout> </DimensionLayout>
<DimensionLayout dim="1"> <DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0"> <Group type="103" groupAlignment="0" attributes="0">
<Group type="103" groupAlignment="3" attributes="0"> <Group type="103" alignment="0" groupAlignment="3" attributes="0">
<Component id="txtPlayerName" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="txtPlayerName" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbLevel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel3" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/> <Component id="jLabel2" alignment="3" min="-2" max="-2" attributes="0"/>
</Group> </Group>
</Group> </Group>
@ -99,6 +105,29 @@
<Property name="text" type="java.lang.String" value="Name:"/> <Property name="text" type="java.lang.String" value="Name:"/>
</Properties> </Properties>
</Component> </Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<Properties>
<Property name="text" type="java.lang.String" value="Skill:"/>
</Properties>
</Component>
<Component class="javax.swing.JComboBox" name="cbLevel">
<Properties>
<Property name="model" type="javax.swing.ComboBoxModel" editor="org.netbeans.modules.form.editors2.ComboBoxModelEditor">
<StringArray count="10">
<StringItem index="0" value="1"/>
<StringItem index="1" value="2"/>
<StringItem index="2" value="3"/>
<StringItem index="3" value="4"/>
<StringItem index="4" value="5"/>
<StringItem index="5" value="6"/>
<StringItem index="6" value="7"/>
<StringItem index="7" value="8"/>
<StringItem index="8" value="9"/>
<StringItem index="9" value="10"/>
</StringArray>
</Property>
</Properties>
</Component>
</SubComponents> </SubComponents>
</Container> </Container>
</SubComponents> </SubComponents>

View file

@ -66,7 +66,7 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
public boolean joinTournamentTable(UUID roomId, UUID tableId) { public boolean joinTournamentTable(UUID roomId, UUID tableId) {
if (!this.cbPlayerType.getSelectedItem().equals("Human")) { if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
return session.joinTournamentTable(roomId, tableId, this.txtPlayerName.getText(), (String)this.cbPlayerType.getSelectedItem()); return session.joinTournamentTable(roomId, tableId, this.txtPlayerName.getText(), (String)this.cbPlayerType.getSelectedItem(), Integer.valueOf((String)this.cbLevel.getSelectedItem()));
} }
return true; return true;
} }
@ -87,6 +87,8 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
pnlPlayerName = new javax.swing.JPanel(); pnlPlayerName = new javax.swing.JPanel();
txtPlayerName = new javax.swing.JTextField(); txtPlayerName = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel(); jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
cbLevel = new javax.swing.JComboBox();
jLabel1.setLabelFor(cbPlayerType); jLabel1.setLabelFor(cbPlayerType);
jLabel1.setText("Type:"); jLabel1.setText("Type:");
@ -98,24 +100,34 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
} }
}); });
lblPlayerNum.setFont(new java.awt.Font("Tahoma", 1, 11)); // NOI18N lblPlayerNum.setFont(new java.awt.Font("Tahoma", 1, 11));
lblPlayerNum.setText("Player Num:"); lblPlayerNum.setText("Player Num:");
jLabel2.setText("Name:"); jLabel2.setText("Name:");
jLabel3.setText("Skill:");
cbLevel.setModel(new javax.swing.DefaultComboBoxModel(new String[] { "1", "2", "3", "4", "5", "6", "7", "8", "9", "10" }));
javax.swing.GroupLayout pnlPlayerNameLayout = new javax.swing.GroupLayout(pnlPlayerName); javax.swing.GroupLayout pnlPlayerNameLayout = new javax.swing.GroupLayout(pnlPlayerName);
pnlPlayerName.setLayout(pnlPlayerNameLayout); pnlPlayerName.setLayout(pnlPlayerNameLayout);
pnlPlayerNameLayout.setHorizontalGroup( pnlPlayerNameLayout.setHorizontalGroup(
pnlPlayerNameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) pnlPlayerNameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlPlayerNameLayout.createSequentialGroup() .addGroup(pnlPlayerNameLayout.createSequentialGroup()
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbLevel, javax.swing.GroupLayout.PREFERRED_SIZE, 31, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2) .addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(txtPlayerName, javax.swing.GroupLayout.DEFAULT_SIZE, 189, Short.MAX_VALUE)) .addComponent(txtPlayerName, javax.swing.GroupLayout.DEFAULT_SIZE, 225, Short.MAX_VALUE))
); );
pnlPlayerNameLayout.setVerticalGroup( pnlPlayerNameLayout.setVerticalGroup(
pnlPlayerNameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING) pnlPlayerNameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(pnlPlayerNameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE) .addGroup(pnlPlayerNameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(txtPlayerName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(txtPlayerName, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(cbLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(jLabel2)) .addComponent(jLabel2))
); );
@ -128,7 +140,7 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel1) .addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(cbPlayerType, javax.swing.GroupLayout.PREFERRED_SIZE, 175, javax.swing.GroupLayout.PREFERRED_SIZE) .addComponent(cbPlayerType, javax.swing.GroupLayout.PREFERRED_SIZE, 138, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED) .addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(pnlPlayerName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)) .addComponent(pnlPlayerName, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
); );
@ -158,9 +170,11 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
// Variables declaration - do not modify//GEN-BEGIN:variables // Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JComboBox cbLevel;
private javax.swing.JComboBox cbPlayerType; private javax.swing.JComboBox cbPlayerType;
private javax.swing.JLabel jLabel1; private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2; private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel lblPlayerNum; private javax.swing.JLabel lblPlayerNum;
private javax.swing.JPanel pnlPlayerName; private javax.swing.JPanel pnlPlayerName;
private javax.swing.JTextField txtPlayerName; private javax.swing.JTextField txtPlayerName;

View file

@ -49,15 +49,7 @@ public class Config {
public static final String remoteServer; public static final String remoteServer;
public static final String serverName; public static final String serverName;
public static final int port; public static final int port;
public static final String cardsResourcePath;
public static final String frameResourcePath;
public static final String powerboxResourcePath;
public static final String cardArtResourcePath;
public static final String symbolsResourcePath;
public static final String setIconsResourcePath;
public static final String resourcePath;
public static final double cardScalingFactor; public static final double cardScalingFactor;
public static final boolean useResource;
public static final CardDimensions dimensions; public static final CardDimensions dimensions;
public static final String defaultGameType; public static final String defaultGameType;
@ -75,8 +67,6 @@ public class Config {
serverName = p.getProperty("server-name"); serverName = p.getProperty("server-name");
port = Integer.parseInt(p.getProperty("port")); port = Integer.parseInt(p.getProperty("port"));
remoteServer = p.getProperty("remote-server"); remoteServer = p.getProperty("remote-server");
cardsResourcePath = p.getProperty("cards-resource-path");
resourcePath = p.getProperty("resource-path");
cardScalingFactor = Double.valueOf(p.getProperty("card-scaling-factor")); cardScalingFactor = Double.valueOf(p.getProperty("card-scaling-factor"));
defaultGameType = p.getProperty("default-game-type", "Human"); defaultGameType = p.getProperty("default-game-type", "Human");
defaultDeckPath = p.getProperty("default-deck-path"); defaultDeckPath = p.getProperty("default-deck-path");
@ -84,23 +74,6 @@ public class Config {
defaultComputerName = p.getProperty("default-computer-name"); defaultComputerName = p.getProperty("default-computer-name");
dimensions = new CardDimensions(cardScalingFactor); dimensions = new CardDimensions(cardScalingFactor);
File test = new File(cardsResourcePath);
if (test.isDirectory()) {
useResource = false;
frameResourcePath = cardsResourcePath + "Frame" + File.separator;
powerboxResourcePath = cardsResourcePath + "PowerBox" + File.separator;
cardArtResourcePath = cardsResourcePath + "Pics" + File.separator;
setIconsResourcePath = cardsResourcePath + "Icon" + File.separator;
symbolsResourcePath = p.getProperty("symbols-resource-path");
}
else {
useResource = true;
frameResourcePath = resourcePath + "cards/frame/";
powerboxResourcePath = resourcePath + "cards/powerbox/";
cardArtResourcePath = resourcePath + "cards/art/";
setIconsResourcePath = resourcePath + "cards/icon/";
symbolsResourcePath = resourcePath + "symbols/";
}
} }
} }

View file

@ -1,72 +0,0 @@
/*
* 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.client.util;
import static mage.constants.Constants.*;
import java.awt.image.BufferedImage;
import java.io.File;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class Frames {
public static BufferedImage Black = ImageHelper.loadImage(Config.frameResourcePath + "8 black.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage Blue = ImageHelper.loadImage(Config.frameResourcePath + "8 blue.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage Gold = ImageHelper.loadImage(Config.frameResourcePath + "8 gold.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage Green = ImageHelper.loadImage(Config.frameResourcePath + "8 green.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage Grey = ImageHelper.loadImage(Config.frameResourcePath + "8 grey.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage Red = ImageHelper.loadImage(Config.frameResourcePath + "8 red.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage White = ImageHelper.loadImage(Config.frameResourcePath + "8 white.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage BlackRed = ImageHelper.loadImage(Config.frameResourcePath + "black to red hybrid.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage BlackGreen = ImageHelper.loadImage(Config.frameResourcePath + "eve hybrid black to green.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage BlueBlack = ImageHelper.loadImage(Config.frameResourcePath + "blue_to_black_hybrid.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage BlueRed = ImageHelper.loadImage(Config.frameResourcePath + "eve hybrid blue to red.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage GreenBlue = ImageHelper.loadImage(Config.frameResourcePath + "eve hybrid green to blue.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage GreenWhite = ImageHelper.loadImage(Config.frameResourcePath + "green_to_white_hybrid.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage RedGreen = ImageHelper.loadImage(Config.frameResourcePath + "red_to_green_hybrid.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage RedWhite = ImageHelper.loadImage(Config.frameResourcePath + "eve hybrid red to white.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage WhiteBlack = ImageHelper.loadImage(Config.frameResourcePath + "eve hybrid white to black.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage WhiteBlue = ImageHelper.loadImage(Config.frameResourcePath + "white_to_blue_hybrid.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage Forest = ImageHelper.loadImage(Config.frameResourcePath + "8 land mana green.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage Island = ImageHelper.loadImage(Config.frameResourcePath + "8 land mana blue.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage Mountain = ImageHelper.loadImage(Config.frameResourcePath + "8 land mana red.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage Plains = ImageHelper.loadImage(Config.frameResourcePath + "8 land mana white.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage Swamp = ImageHelper.loadImage(Config.frameResourcePath + "8 land mana black.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage Land = ImageHelper.loadImage(Config.frameResourcePath + "8 multiland nomana colorless.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage Effect = ImageHelper.loadImage(Config.frameResourcePath + "Effects" + File.separator +"effect0.png", FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
public static BufferedImage PowBoxLeft = ImageHelper.loadImage(Config.powerboxResourcePath + "graphic_card_powerbox_a_left.png");
public static BufferedImage PowBoxMid = ImageHelper.loadImage(Config.powerboxResourcePath + "graphic_card_powerbox_a_middle.png");
public static BufferedImage PowBoxRight = ImageHelper.loadImage(Config.powerboxResourcePath + "graphic_card_powerbox_a_right.png");
}

View file

@ -30,7 +30,6 @@ package mage.client.util;
import static mage.constants.Constants.*; import static mage.constants.Constants.*;
import java.awt.Color;
import java.awt.Graphics2D; import java.awt.Graphics2D;
import java.awt.Image; import java.awt.Image;
import java.awt.RenderingHints; import java.awt.RenderingHints;
@ -38,7 +37,6 @@ import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver; import java.awt.image.ImageObserver;
import java.awt.image.MemoryImageSource; import java.awt.image.MemoryImageSource;
import java.awt.image.PixelGrabber; import java.awt.image.PixelGrabber;
import java.io.File;
import java.io.IOException; import java.io.IOException;
import java.io.InputStream; import java.io.InputStream;
import java.util.HashMap; import java.util.HashMap;
@ -46,14 +44,9 @@ import java.util.List;
import javax.imageio.ImageIO; import javax.imageio.ImageIO;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.cards.CardDimensions; import mage.cards.CardDimensions;
import mage.client.components.arcane.UI; import mage.client.components.arcane.UI;
import mage.sets.Sets;
import mage.view.AbilityView;
import mage.view.CardView; import mage.view.CardView;
import mage.view.StackAbilityView;
import com.mortennobel.imagescaling.ResampleOp; import com.mortennobel.imagescaling.ResampleOp;
@ -88,10 +81,7 @@ public class ImageHelper {
public static BufferedImage loadImage(String ref) { public static BufferedImage loadImage(String ref) {
if (!images.containsKey(ref)) { if (!images.containsKey(ref)) {
try { try {
if (Config.useResource) images.put(ref, ImageIO.read(ImageHelper.class.getResourceAsStream(ref)));
images.put(ref, ImageIO.read(ImageHelper.class.getResourceAsStream(ref)));
else
images.put(ref, ImageIO.read(new File(ref)));
} catch (Exception e) { } catch (Exception e) {
return null; return null;
} }
@ -105,139 +95,10 @@ public class ImageHelper {
} }
BufferedImage background = new BufferedImage(FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT, BufferedImage.TYPE_INT_RGB); BufferedImage background = new BufferedImage(FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT, BufferedImage.TYPE_INT_RGB);
Graphics2D g = (Graphics2D) background.getGraphics();
g.setRenderingHint(RenderingHints.KEY_ANTIALIASING, RenderingHints.VALUE_ANTIALIAS_ON);
g.setColor(Color.WHITE);
g.fillRect(0, 0, FRAME_MAX_WIDTH, FRAME_MAX_HEIGHT);
if (card instanceof StackAbilityView || card instanceof AbilityView) {
g.drawImage(Frames.Effect, 0, 0, Color.WHITE, null);
}
else {
g.drawImage(getFrame(card), 0, 0, Color.WHITE, null);
if (card.getArt() != null && !card.getArt().equals("")) {
BufferedImage art = loadImage(Config.cardArtResourcePath + card.getArt(), ART_MAX_WIDTH, ART_MAX_HEIGHT);
g.drawImage(art, CONTENT_MAX_XOFFSET, ART_MAX_YOFFSET, null);
}
if (card.getExpansionSetCode() != null && card.getExpansionSetCode().length() > 0 && card.getRarity() != null && card.getRarity() != Rarity.NA) {
try {
String symbolCode = Sets.getInstance().get(card.getExpansionSetCode()).getSymbolCode();
if (symbolCode != null && symbolCode.length() > 0) {
StringBuilder sb = new StringBuilder();
sb.append(Config.setIconsResourcePath).append("graphic_").append(symbolCode).append("_").append(card.getRarity().getSymbolCode()).append(".png");
BufferedImage icon = loadImage(sb.toString(), ICON_MAX_HEIGHT);
if (icon != null)
g.drawImage(icon, ICON_MAX_XOFFSET - icon.getWidth(), ICON_MAX_YOFFSET, null);
}
} catch (Exception e) {
e.printStackTrace();
} catch (Error er) {
er.printStackTrace();
}
}
if (card.getCardTypes() != null && (card.getCardTypes().contains(CardType.CREATURE) || card.getCardTypes().contains(CardType.PLANESWALKER))) {
g.drawImage(Frames.PowBoxLeft, POWBOX_MAX_LEFT, POWBOX_MAX_TOP, null);
g.drawImage(Frames.PowBoxMid, POWBOX_MAX_LEFT + 7, POWBOX_MAX_TOP, null);
g.drawImage(Frames.PowBoxRight, POWBOX_MAX_LEFT + 38, POWBOX_MAX_TOP, null);
}
}
g.dispose();
backgrounds.put(backgroundName, background); backgrounds.put(backgroundName, background);
return background; return background;
} }
protected static BufferedImage getFrame(CardView card) {
if (card.getCardTypes().contains(CardType.LAND)) {
return getLandFrame(card);
}
else {
if (card.getColor().isColorless()) {
return Frames.Grey;
} else if (card.getColor().isMulticolored()) {
if (card.getColor().getColorCount() > 2)
return Frames.Gold;
if (card.getColor().isBlack() && card.getColor().isRed()) {
if (Frames.BlackRed != null)
return Frames.BlackRed;
}
else if (card.getColor().isBlack() && card.getColor().isGreen()) {
if (Frames.BlackGreen != null)
return Frames.BlackGreen;
}
else if (card.getColor().isBlack() && card.getColor().isBlue()) {
if (Frames.BlueBlack != null)
return Frames.BlueBlack;
}
else if (card.getColor().isRed() && card.getColor().isBlue()) {
if (Frames.BlueRed != null)
return Frames.BlueRed;
}
else if (card.getColor().isGreen() && card.getColor().isBlue()) {
if (Frames.GreenBlue != null)
return Frames.GreenBlue;
}
else if (card.getColor().isGreen() && card.getColor().isWhite()) {
if (Frames.GreenWhite != null)
return Frames.GreenWhite;
}
else if (card.getColor().isRed() && card.getColor().isGreen()) {
if (Frames.RedGreen != null)
return Frames.RedGreen;
}
else if (card.getColor().isRed() && card.getColor().isWhite()) {
if (Frames.RedWhite != null)
return Frames.RedWhite;
}
else if (card.getColor().isWhite() && card.getColor().isBlack()) {
if (Frames.WhiteBlack != null)
return Frames.WhiteBlack;
}
else if (card.getColor().isWhite() && card.getColor().isBlue()) {
if (Frames.WhiteBlue != null)
return Frames.WhiteBlue;
}
return Frames.Gold;
} else {
if (card.getColor().isBlack()) {
return Frames.Black;
} else if (card.getColor().isBlue()) {
return Frames.Blue;
} else if (card.getColor().isRed()) {
return Frames.Red;
} else if (card.getColor().isGreen()) {
return Frames.Green;
} else if (card.getColor().isWhite()) {
return Frames.White;
}
}
}
return Frames.Grey;
}
protected static BufferedImage getLandFrame(CardView card) {
if (card.getSuperTypes().contains("Basic")) {
if (card.getSubTypes().contains("Forest")) {
return Frames.Forest;
}
else if (card.getSubTypes().contains("Island")) {
return Frames.Island;
}
else if (card.getSubTypes().contains("Mountain")) {
return Frames.Mountain;
}
else if (card.getSubTypes().contains("Plains")) {
return Frames.Plains;
}
else if (card.getSubTypes().contains("Swamp")) {
return Frames.Swamp;
}
}
return Frames.Land;
}
public static BufferedImage scaleImage(BufferedImage image, int width, int height) { public static BufferedImage scaleImage(BufferedImage image, int width, int height) {
BufferedImage scaledImage = image; BufferedImage scaledImage = image;
@ -291,15 +152,8 @@ public class ImageHelper {
int costLeft = xOffset; int costLeft = xOffset;
for (int i = costs.size() - 1; i >= 0; i--) { for (int i = costs.size() - 1; i >= 0; i--) {
String symbol = costs.get(i); String symbol = costs.get(i);
Image image = Symbols.getSymbol(symbol); g.drawString(symbol, costLeft, yOffset + SYMBOL_MAX_SPACE);
if (image != null) { costLeft -= SYMBOL_MAX_SPACE + 4;
g.drawImage(image, costLeft, yOffset, o);
costLeft -= SYMBOL_MAX_SPACE;
}
else {
g.drawString(symbol, costLeft, yOffset + SYMBOL_MAX_SPACE);
costLeft -= SYMBOL_MAX_SPACE + 4;
}
} }
} }
} }

View file

@ -1,96 +0,0 @@
/*
* 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.client.util;
import java.awt.Image;
import java.util.HashMap;
import java.util.Map;
import static mage.constants.Constants.*;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class Symbols {
public static Map<String, Image> symbols = new HashMap<String, Image>();
static {
symbols.put("{B}", ImageHelper.loadImage(Config.symbolsResourcePath + "mana_black.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{U}", ImageHelper.loadImage(Config.symbolsResourcePath + "mana_blue.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{G}", ImageHelper.loadImage(Config.symbolsResourcePath + "mana_green.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{R}", ImageHelper.loadImage(Config.symbolsResourcePath + "mana_red.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{W}", ImageHelper.loadImage(Config.symbolsResourcePath + "mana_white.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{0}", ImageHelper.loadImage(Config.symbolsResourcePath + "colorless_0.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{1}", ImageHelper.loadImage(Config.symbolsResourcePath + "colorless_1.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{2}", ImageHelper.loadImage(Config.symbolsResourcePath + "colorless_2.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{3}", ImageHelper.loadImage(Config.symbolsResourcePath + "colorless_3.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{4}", ImageHelper.loadImage(Config.symbolsResourcePath + "colorless_4.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{5}", ImageHelper.loadImage(Config.symbolsResourcePath + "colorless_5.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{6}", ImageHelper.loadImage(Config.symbolsResourcePath + "colorless_6.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{7}", ImageHelper.loadImage(Config.symbolsResourcePath + "colorless_7.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{8}", ImageHelper.loadImage(Config.symbolsResourcePath + "colorless_8.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{9}", ImageHelper.loadImage(Config.symbolsResourcePath + "colorless_9.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{10}", ImageHelper.loadImage(Config.symbolsResourcePath + "colorless_10.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{11}", ImageHelper.loadImage(Config.symbolsResourcePath + "colorless_11.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{12}", ImageHelper.loadImage(Config.symbolsResourcePath + "colorless_12.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{13}", ImageHelper.loadImage(Config.symbolsResourcePath + "colorless_13.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{14}", ImageHelper.loadImage(Config.symbolsResourcePath + "colorless_14.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{15}", ImageHelper.loadImage(Config.symbolsResourcePath + "colorless_15.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{16}", ImageHelper.loadImage(Config.symbolsResourcePath + "colorless_16.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{X}", ImageHelper.loadImage(Config.symbolsResourcePath + "colorless_x.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{B/G}", ImageHelper.loadImage(Config.symbolsResourcePath + "black_green.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{B/R}", ImageHelper.loadImage(Config.symbolsResourcePath + "black_red.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{U/B}", ImageHelper.loadImage(Config.symbolsResourcePath + "blue_black.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{U/R}", ImageHelper.loadImage(Config.symbolsResourcePath + "blue_red.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{G/B}", ImageHelper.loadImage(Config.symbolsResourcePath + "green_blue.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{G/W}", ImageHelper.loadImage(Config.symbolsResourcePath + "green_white.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{R/G}", ImageHelper.loadImage(Config.symbolsResourcePath + "red_green.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{R/W}", ImageHelper.loadImage(Config.symbolsResourcePath + "red_white.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{W/B}", ImageHelper.loadImage(Config.symbolsResourcePath + "white_black.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{W/U}", ImageHelper.loadImage(Config.symbolsResourcePath + "white_blue.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{2/B}", ImageHelper.loadImage(Config.symbolsResourcePath + "two_black.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{2/U}", ImageHelper.loadImage(Config.symbolsResourcePath + "two_blue.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{2/G}", ImageHelper.loadImage(Config.symbolsResourcePath + "two_green.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{2/R}", ImageHelper.loadImage(Config.symbolsResourcePath + "two_red.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
symbols.put("{2/W}", ImageHelper.loadImage(Config.symbolsResourcePath + "two_white.png", SYMBOL_MAX_WIDTH, SYMBOL_MAX_HEIGHT));
}
public static Image getSymbol(String symbol) {
if (symbols.containsKey(symbol))
return(symbols.get(symbol));
return null;
}
}

View file

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>mage-root</artifactId> <artifactId>mage-root</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>Mage-Common</artifactId> <artifactId>Mage-Common</artifactId>

View file

@ -37,6 +37,7 @@ import mage.cards.decks.DeckCardLists;
import mage.game.GameException; import mage.game.GameException;
import mage.game.tournament.TournamentOptions; import mage.game.tournament.TournamentOptions;
import mage.interfaces.callback.CallbackServer; import mage.interfaces.callback.CallbackServer;
import mage.utils.MageVersion;
import mage.view.DraftPickView; import mage.view.DraftPickView;
import mage.view.TableView; import mage.view.TableView;
import mage.view.GameView; import mage.view.GameView;
@ -48,7 +49,7 @@ import mage.view.TournamentView;
*/ */
public interface Server extends Remote, CallbackServer { public interface Server extends Remote, CallbackServer {
public UUID registerClient(String userName, UUID clientId) throws RemoteException, MageException; public UUID registerClient(String userName, UUID clientId, MageVersion version) throws RemoteException, MageException;
public void deregisterClient(UUID sessionId) throws RemoteException, MageException; public void deregisterClient(UUID sessionId) throws RemoteException, MageException;
public void ack(String message, UUID sessionId) throws RemoteException, MageException; public void ack(String message, UUID sessionId) throws RemoteException, MageException;
@ -57,8 +58,8 @@ public interface Server extends Remote, CallbackServer {
//table methods //table methods
public TableView createTable(UUID sessionId, UUID roomId, MatchOptions matchOptions) throws RemoteException, MageException; public TableView createTable(UUID sessionId, UUID roomId, MatchOptions matchOptions) throws RemoteException, MageException;
public TableView createTournamentTable(UUID sessionId, UUID roomId, TournamentOptions tournamentOptions) throws RemoteException, MageException; public TableView createTournamentTable(UUID sessionId, UUID roomId, TournamentOptions tournamentOptions) throws RemoteException, MageException;
public boolean joinTable(UUID sessionId, UUID roomId, UUID tableId, String name, String playerType, DeckCardLists deckList) throws RemoteException, MageException, GameException; public boolean joinTable(UUID sessionId, UUID roomId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList) throws RemoteException, MageException, GameException;
public boolean joinTournamentTable(UUID sessionId, UUID roomId, UUID tableId, String name, String playerType) throws RemoteException, MageException, GameException; public boolean joinTournamentTable(UUID sessionId, UUID roomId, UUID tableId, String name, String playerType, int skill) throws RemoteException, MageException, GameException;
public boolean submitDeck(UUID sessionId, UUID tableId, DeckCardLists deckList) throws RemoteException, MageException, GameException; public boolean submitDeck(UUID sessionId, UUID tableId, DeckCardLists deckList) throws RemoteException, MageException, GameException;
public boolean watchTable(UUID sessionId, UUID roomId, UUID tableId) throws RemoteException, MageException; public boolean watchTable(UUID sessionId, UUID roomId, UUID tableId) throws RemoteException, MageException;
public void leaveTable(UUID sessionId, UUID roomId, UUID tableId) throws RemoteException, MageException; public void leaveTable(UUID sessionId, UUID roomId, UUID tableId) throws RemoteException, MageException;

View file

@ -30,6 +30,7 @@ package mage.interfaces;
import java.io.Serializable; import java.io.Serializable;
import java.util.List; import java.util.List;
import mage.utils.MageVersion;
import mage.view.GameTypeView; import mage.view.GameTypeView;
import mage.view.TournamentTypeView; import mage.view.TournamentTypeView;
@ -44,13 +45,15 @@ public class ServerState implements Serializable {
private String[] playerTypes; private String[] playerTypes;
private String[] deckTypes; private String[] deckTypes;
private boolean testMode; private boolean testMode;
private MageVersion version;
public ServerState(List<GameTypeView> gameTypes, List<TournamentTypeView> tournamentTypes, String[] playerTypes, String[] deckTypes, boolean testMode) { public ServerState(List<GameTypeView> gameTypes, List<TournamentTypeView> tournamentTypes, String[] playerTypes, String[] deckTypes, boolean testMode, MageVersion version) {
this.gameTypes = gameTypes; this.gameTypes = gameTypes;
this.tournamentTypes = tournamentTypes; this.tournamentTypes = tournamentTypes;
this.playerTypes = playerTypes; this.playerTypes = playerTypes;
this.deckTypes = deckTypes; this.deckTypes = deckTypes;
this.testMode = testMode; this.testMode = testMode;
this.version = version;
} }
public List<GameTypeView> getGameTypes() { public List<GameTypeView> getGameTypes() {
@ -73,4 +76,7 @@ public class ServerState implements Serializable {
return testMode; return testMode;
} }
public MageVersion getVersion() {
return version;
}
} }

View file

@ -0,0 +1,77 @@
/*
* Copyright 2011 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.utils;
import java.io.Serializable;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class MageVersion implements Serializable, Comparable<MageVersion> {
private int major;
private int minor;
private int patch;
public MageVersion(int major, int minor, int patch) {
this.major = major;
this.minor = minor;
this.patch = patch;
}
public int getMajor() {
return major;
}
public int getMinor() {
return minor;
}
public int getPatch() {
return patch;
}
@Override
public String toString() {
return major + "." + minor + "." + patch;
}
@Override
public int compareTo(MageVersion o) {
if (major != o.major)
return major - o.major;
if (minor != o.minor)
return minor - o.minor;
if (patch != o.patch)
return patch - o.patch;
return 0;
}
}

View file

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>Mage-Plugins</artifactId> <artifactId>Mage-Plugins</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>Mage-Card-Plugin</artifactId> <artifactId>Mage-Card-Plugin</artifactId>

View file

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>Mage-Plugins</artifactId> <artifactId>Mage-Plugins</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>Mage-Counter-Plugin</artifactId> <artifactId>Mage-Counter-Plugin</artifactId>

View file

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>Mage-Plugins</artifactId> <artifactId>Mage-Plugins</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>

View file

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>Mage-Plugins</artifactId> <artifactId>Mage-Plugins</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>Mage-Theme-Plugin</artifactId> <artifactId>Mage-Theme-Plugin</artifactId>

View file

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>mage-root</artifactId> <artifactId>mage-root</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>Mage-Plugins</artifactId> <artifactId>Mage-Plugins</artifactId>

View file

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>Mage-Server-Plugins</artifactId> <artifactId>Mage-Server-Plugins</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>Mage-Deck-Constructed</artifactId> <artifactId>Mage-Deck-Constructed</artifactId>

View file

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>Mage-Server-Plugins</artifactId> <artifactId>Mage-Server-Plugins</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>Mage-Deck-Limited</artifactId> <artifactId>Mage-Deck-Limited</artifactId>

View file

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>Mage-Server-Plugins</artifactId> <artifactId>Mage-Server-Plugins</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>Mage-Game-FreeForAll</artifactId> <artifactId>Mage-Game-FreeForAll</artifactId>

View file

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>Mage-Server-Plugins</artifactId> <artifactId>Mage-Server-Plugins</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>Mage-Game-TwoPlayerDuel</artifactId> <artifactId>Mage-Game-TwoPlayerDuel</artifactId>

View file

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>Mage-Server-Plugins</artifactId> <artifactId>Mage-Server-Plugins</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>Mage-Player-AI-MA</artifactId> <artifactId>Mage-Player-AI-MA</artifactId>

View file

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>Mage-Server-Plugins</artifactId> <artifactId>Mage-Server-Plugins</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>Mage-Player-AI</artifactId> <artifactId>Mage-Player-AI</artifactId>

View file

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>Mage-Server-Plugins</artifactId> <artifactId>Mage-Server-Plugins</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>Mage-Player-AIMinimax</artifactId> <artifactId>Mage-Player-AIMinimax</artifactId>

View file

@ -176,6 +176,7 @@ public class ComputerPlayer2 extends ComputerPlayer<ComputerPlayer2> implements
if (usedStack) if (usedStack)
pass(); pass();
} }
logger.info("Turn " + game.getTurnNum() + " Step " + game.getStep().toString() + " Player " + name + " Life " + life);
} }
protected void calculateActions(Game game) { protected void calculateActions(Game game) {
@ -337,7 +338,11 @@ public class ComputerPlayer2 extends ComputerPlayer<ComputerPlayer2> implements
} catch (InterruptedException ex) { } catch (InterruptedException ex) {
logger.fatal("can't sleep"); logger.fatal("can't sleep");
} }
logger.info("Calculated " + root.nodeCount + " nodes in 30s"); long endTime = System.nanoTime();
long duration = endTime - startTime;
logger.info("Timeout - Calculated " + root.nodeCount + " nodes in " + duration/1000000000.0 + "s");
nodeCount += root.nodeCount;
thinkTime += duration;
} catch (ExecutionException e) { } catch (ExecutionException e) {
logger.fatal("Simulation error", e); logger.fatal("Simulation error", e);
task.cancel(true); task.cancel(true);

View file

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>Mage-Server-Plugins</artifactId> <artifactId>Mage-Server-Plugins</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>Mage-Player-Human</artifactId> <artifactId>Mage-Player-Human</artifactId>

View file

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>Mage-Server-Plugins</artifactId> <artifactId>Mage-Server-Plugins</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>Mage-Tournament-BoosterDraft</artifactId> <artifactId>Mage-Tournament-BoosterDraft</artifactId>

View file

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>Mage-Server-Plugins</artifactId> <artifactId>Mage-Server-Plugins</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>Mage-Tournament-Sealed</artifactId> <artifactId>Mage-Tournament-Sealed</artifactId>

View file

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>mage-root</artifactId> <artifactId>mage-root</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>Mage-Server-Plugins</artifactId> <artifactId>Mage-Server-Plugins</artifactId>

View file

@ -6,7 +6,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>mage-root</artifactId> <artifactId>mage-root</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>Mage-Server</artifactId> <artifactId>Mage-Server</artifactId>

View file

@ -43,6 +43,7 @@ import mage.server.util.ConfigSettings;
import mage.server.util.config.Plugin; import mage.server.util.config.Plugin;
import mage.server.util.config.GamePlugin; import mage.server.util.config.GamePlugin;
import mage.util.Copier; import mage.util.Copier;
import mage.utils.MageVersion;
import org.apache.log4j.Logger; import org.apache.log4j.Logger;
/** /**
@ -55,7 +56,7 @@ public class Main {
private final static String testModeArg = "-testMode="; private final static String testModeArg = "-testMode=";
private final static String pluginFolder = "plugins"; private final static String pluginFolder = "plugins";
private final static String version = "0.7.1"; private static MageVersion version = new MageVersion(0, 7, 2);
public static PluginClassLoader classLoader = new PluginClassLoader(); public static PluginClassLoader classLoader = new PluginClassLoader();
public static ServerImpl server; public static ServerImpl server;
@ -166,4 +167,8 @@ public class Main {
} }
} }
public static MageVersion getVersion() {
return version;
}
} }

View file

@ -55,6 +55,7 @@ import mage.server.game.ReplayManager;
import mage.server.tournament.TournamentFactory; import mage.server.tournament.TournamentFactory;
import mage.server.tournament.TournamentManager; import mage.server.tournament.TournamentManager;
import mage.server.util.ThreadExecutor; import mage.server.util.ThreadExecutor;
import mage.utils.MageVersion;
import mage.view.ChatMessage.MessageColor; import mage.view.ChatMessage.MessageColor;
import mage.view.DraftPickView; import mage.view.DraftPickView;
import mage.view.GameView; import mage.view.GameView;
@ -105,10 +106,13 @@ public class ServerImpl extends RemoteServer implements Server {
} }
@Override @Override
public UUID registerClient(String userName, UUID clientId) throws MageException, RemoteException { public UUID registerClient(String userName, UUID clientId, MageVersion version) throws MageException, RemoteException {
UUID sessionId = SessionManager.getInstance().createSession(userName, clientId); UUID sessionId = null;
try { try {
if (version.compareTo(Main.getVersion()) != 0)
throw new MageException("Wrong client version " + version + ", expecting version " + Main.getVersion());
sessionId = SessionManager.getInstance().createSession(userName, clientId);
logger.info("Session " + sessionId + " created for user " + userName + " at " + getClientHost()); logger.info("Session " + sessionId + " created for user " + userName + " at " + getClientHost());
} catch (Exception ex) { } catch (Exception ex) {
handleException(ex); handleException(ex);
@ -161,7 +165,7 @@ public class ServerImpl extends RemoteServer implements Server {
} }
@Override @Override
public boolean joinTable(UUID sessionId, UUID roomId, UUID tableId, String name, String playerType, DeckCardLists deckList) throws MageException, GameException { public boolean joinTable(UUID sessionId, UUID roomId, UUID tableId, String name, String playerType, int skill, DeckCardLists deckList) throws MageException, GameException {
try { try {
boolean ret = GamesRoomManager.getInstance().getRoom(roomId).joinTable(sessionId, tableId, name, playerType, deckList); boolean ret = GamesRoomManager.getInstance().getRoom(roomId).joinTable(sessionId, tableId, name, playerType, deckList);
logger.info("Session " + sessionId + " joined table " + tableId); logger.info("Session " + sessionId + " joined table " + tableId);
@ -176,7 +180,7 @@ public class ServerImpl extends RemoteServer implements Server {
} }
@Override @Override
public boolean joinTournamentTable(UUID sessionId, UUID roomId, UUID tableId, String name, String playerType) throws MageException, GameException { public boolean joinTournamentTable(UUID sessionId, UUID roomId, UUID tableId, String name, String playerType, int skill) throws MageException, GameException {
try { try {
boolean ret = GamesRoomManager.getInstance().getRoom(roomId).joinTournamentTable(sessionId, tableId, name, playerType); boolean ret = GamesRoomManager.getInstance().getRoom(roomId).joinTournamentTable(sessionId, tableId, name, playerType);
logger.info("Session " + sessionId + " joined table " + tableId); logger.info("Session " + sessionId + " joined table " + tableId);
@ -726,7 +730,8 @@ public class ServerImpl extends RemoteServer implements Server {
TournamentFactory.getInstance().getTournamentTypes(), TournamentFactory.getInstance().getTournamentTypes(),
PlayerFactory.getInstance().getPlayerTypes().toArray(new String[0]), PlayerFactory.getInstance().getPlayerTypes().toArray(new String[0]),
DeckValidatorFactory.getInstance().getDeckTypes().toArray(new String[0]), DeckValidatorFactory.getInstance().getDeckTypes().toArray(new String[0]),
testMode); testMode,
Main.getVersion());
} }
catch (Exception ex) { catch (Exception ex) {
handleException(ex); handleException(ex);

View file

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>mage-root</artifactId> <artifactId>mage-root</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>

View file

@ -7,7 +7,7 @@
<parent> <parent>
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>mage-root</artifactId> <artifactId>mage-root</artifactId>
<version>0.7</version> <version>0.7.2</version>
</parent> </parent>
<artifactId>Mage</artifactId> <artifactId>Mage</artifactId>

18
pom.xml
View file

@ -6,11 +6,23 @@
<groupId>org.mage</groupId> <groupId>org.mage</groupId>
<artifactId>mage-root</artifactId> <artifactId>mage-root</artifactId>
<version>0.7</version> <version>0.7.2</version>
<packaging>pom</packaging> <packaging>pom</packaging>
<name>Mage Root</name> <name>Mage Root</name>
<description>Mage Root POM</description> <description>Mage Root POM</description>
<build>
<plugins>
<plugin>
<groupId>org.apache.maven.plugins</groupId>
<artifactId>maven-compiler-plugin</artifactId>
<version>2.0.2</version>
<configuration>
<source>1.6</source>
<target>1.6</target>
</configuration>
</plugin>
</plugins>
</build>
<modules> <modules>
<module>Mage</module> <module>Mage</module>
<module>Mage.Common</module> <module>Mage.Common</module>
@ -34,6 +46,6 @@
</repositories> </repositories>
<properties> <properties>
<mage-version>0.7</mage-version> <mage-version>0.7.2</mage-version>
</properties> </properties>
</project> </project>