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>
<groupId>org.mage</groupId>
<artifactId>mage-root</artifactId>
<version>0.7</version>
<version>0.7.2</version>
</parent>
<groupId>org.mage</groupId>

View file

@ -76,6 +76,7 @@ import mage.client.draft.DraftPane;
import mage.client.game.GamePane;
import mage.client.table.TablesPane;
import mage.client.tournament.TournamentPane;
import mage.utils.MageVersion;
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 JLabel title;
private Rectangle titleRectangle;
private static MageVersion version = new MageVersion(0, 7, 2);
/**
* @return the session
@ -106,12 +108,16 @@ public class MageFrame extends javax.swing.JFrame {
return prefs;
}
public static MageVersion getVersion() {
return version;
}
/**
* Creates new form MageFrame
*/
public MageFrame() {
setTitle("Mage, version 0.7.1");
setTitle("Mage, version " + version);
EDTExceptionHandler.registerExceptionHandler();
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">
<Properties>
@ -22,27 +22,28 @@
<Layout>
<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">
<Group type="102" alignment="0" attributes="0">
<Component id="jLabel3" max="32767" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
<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">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="lblVersion" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="109" max="32767" attributes="0"/>
<EmptySpace pref="311" max="32767" attributes="0"/>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="32767" attributes="0"/>
<EmptySpace pref="203" max="32767" attributes="0"/>
</Group>
</Group>
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="75" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -57,8 +58,8 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel2" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel3" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="23" max="32767" attributes="0"/>
<Component id="jLabel3" pref="40" max="32767" attributes="0"/>
<EmptySpace type="separate" max="-2" attributes="0"/>
<Component id="btnOk" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
</Group>
@ -81,7 +82,7 @@
</Component>
<Component class="javax.swing.JLabel" name="lblVersion">
<Properties>
<Property name="text" type="java.lang.String" value="version"/>
<Property name="text" type="java.lang.String" value="0.0.0"/>
</Properties>
</Component>
<Component class="javax.swing.JLabel" name="jLabel2">
@ -91,7 +92,7 @@
</Component>
<Component class="javax.swing.JLabel" name="jLabel3">
<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>
</Component>
</SubComponents>

View file

@ -34,6 +34,8 @@
package mage.client.dialog;
import mage.client.MageFrame;
/**
*
* @author BetaSteward_at_googlemail.com
@ -47,7 +49,7 @@ public class AboutDialog extends MageDialog {
}
public void showDialog() {
this.lblVersion.setText(MageDialog.class.getPackage().getImplementationVersion());
this.lblVersion.setText(MageFrame.getVersion().toString());
this.setLocation(100, 100);
this.setVisible(true);
}
@ -66,7 +68,6 @@ public class AboutDialog extends MageDialog {
lblVersion = new javax.swing.JLabel();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
jLabel4 = new javax.swing.JLabel();
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");
jLabel3.setText("Devs: BetaSteward, Nantuko84, Eugen.Rivniy, maurer.it");
//jLabel4.setText("Thanks: KLo, Cosmo & Fritz");
jLabel3.setText("Devs: BetaSteward, Nantuko84, Eugen.Rivniy, maurer.it, Viserion Dragonbourne");
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
.addContainerGap())
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, layout.createSequentialGroup()
.addContainerGap(159, Short.MAX_VALUE)
.addComponent(btnOk)
.addContainerGap())
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel1)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(lblVersion)
.addContainerGap(109, Short.MAX_VALUE))
.addContainerGap(311, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel2)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel3)
.addContainerGap(javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE))
.addGroup(layout.createSequentialGroup()
.addContainerGap()
.addComponent(jLabel4)
.addContainerGap(75, Short.MAX_VALUE))
.addContainerGap(203, Short.MAX_VALUE))))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -124,10 +118,8 @@ public class AboutDialog extends MageDialog {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel2)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel3)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel4)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 23, Short.MAX_VALUE)
.addComponent(jLabel3, javax.swing.GroupLayout.DEFAULT_SIZE, 40, Short.MAX_VALUE)
.addGap(18, 18, 18)
.addComponent(btnOk)
.addContainerGap())
);
@ -144,7 +136,6 @@ public class AboutDialog extends MageDialog {
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel jLabel4;
private javax.swing.JLabel lblVersion;
// 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
Session session = MageFrame.getSession();
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) {
handleError(ex);
}

View file

@ -310,7 +310,7 @@ public class NewTableDialog extends MageDialog {
options.setWinsNeeded((Integer)this.spnNumWins.getValue());
table = session.createTable(roomId, options);
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) {
if (!player.getPlayerType().equals("Human")) {
if (!player.joinTable(roomId, table.getTableId())) {

View file

@ -296,7 +296,7 @@ public class NewTournamentDialog extends MageDialog {
tOptions.getMatchOptions().setAttackOption(MultiplayerAttackOption.LEFT);
tOptions.getMatchOptions().setRange(RangeOfInfluence.ALL);
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) {
if (!player.getPlayerType().equals("Human")) {
if (!player.joinTournamentTable(roomId, table.getTableId())) {

View file

@ -97,7 +97,7 @@ public class Session {
this.server = (Server) reg.lookup(Config.remoteServer);
this.userName = 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);
serverState = server.getServerState();
logger.info("Connected to RMI server at " + serverName + ":" + port);
@ -262,9 +262,9 @@ public class Session {
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 {
return server.joinTable(sessionId, roomId, tableId, playerName, playerType, deckList);
return server.joinTable(sessionId, roomId, tableId, playerName, playerType, skill, deckList);
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
@ -275,9 +275,9 @@ public class Session {
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 {
return server.joinTournamentTable(sessionId, roomId, tableId, playerName, playerType);
return server.joinTournamentTable(sessionId, roomId, tableId, playerName, playerType, skill);
} catch (RemoteException ex) {
handleRemoteException(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">
<AuxValues>
@ -26,11 +26,22 @@
</Group>
<EmptySpace min="-2" max="-2" attributes="0"/>
<Group type="103" groupAlignment="0" attributes="0">
<Component id="txtPlayerName" alignment="0" pref="405" max="32767" attributes="1"/>
<Component id="txtPlayerDeck" alignment="0" pref="405" max="32767" attributes="1"/>
<Component id="txtPlayerName" pref="321" max="32767" attributes="2"/>
<Component id="txtPlayerDeck" alignment="0" pref="321" max="32767" attributes="2"/>
</Group>
<EmptySpace min="-2" 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>
</DimensionLayout>
@ -40,12 +51,15 @@
<Group type="103" groupAlignment="3" 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="lblLevel" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="cbLevel" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace min="-2" pref="3" max="-2" attributes="0"/>
<Group type="103" groupAlignment="3" 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="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>
@ -54,9 +68,6 @@
<SubComponents>
<Component class="javax.swing.JLabel" name="lblPlayerName">
<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:"/>
</Properties>
</Component>
@ -64,9 +75,6 @@
</Component>
<Component class="javax.swing.JLabel" name="lblPlayerDeck">
<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:"/>
</Properties>
</Component>
@ -80,5 +88,36 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnPlayerDeckActionPerformed"/>
</Events>
</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>
</Form>

View file

@ -36,10 +36,8 @@ package mage.client.table;
import java.io.File;
import java.io.IOException;
import javax.swing.JFileChooser;
import javax.swing.filechooser.FileFilter;
import mage.client.MageFrame;
import mage.client.deck.generator.DeckGenerator;
import mage.client.util.Config;
@ -98,14 +96,17 @@ public class NewPlayerPanel extends javax.swing.JPanel {
return this.txtPlayerDeck.getText();
}
public int getLevel() {
return Integer.valueOf((String)this.cbLevel.getSelectedItem());
}
/** This method is called from within the constructor to
* initialize the form.
* WARNING: Do NOT modify this code. The content of this method is
* always regenerated by the Form Editor.
*/
@SuppressWarnings("unchecked")
// <editor-fold defaultstate="collapsed" desc="Generated Code">
// </editor-fold>
// <editor-fold defaultstate="collapsed" desc="Generated Code">//GEN-BEGIN:initComponents
private void initComponents() {
lblPlayerName = new javax.swing.JLabel();
@ -114,11 +115,11 @@ public class NewPlayerPanel extends javax.swing.JPanel {
txtPlayerDeck = new javax.swing.JTextField();
btnPlayerDeck = 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:");
lblPlayerDeck.setLabelFor(txtPlayerDeck);
lblPlayerDeck.setText("Deck:");
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() {
public void actionPerformed(java.awt.event.ActionEvent 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);
this.setLayout(layout);
layout.setHorizontalGroup(
@ -147,50 +152,56 @@ public class NewPlayerPanel extends javax.swing.JPanel {
.addComponent(lblPlayerName))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(txtPlayerName, javax.swing.GroupLayout.DEFAULT_SIZE, 405, Short.MAX_VALUE)
.addComponent(txtPlayerDeck, 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, 321, Short.MAX_VALUE))
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(btnPlayerDeck, javax.swing.GroupLayout.PREFERRED_SIZE, 24, javax.swing.GroupLayout.PREFERRED_SIZE)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
)
.addComponent(btnGenerate)
.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.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.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(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)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(lblPlayerDeck)
.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))
.addGap(3, 3, 3)
.addGroup(layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnGenerate)
)
)
.addComponent(btnPlayerDeck, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(btnGenerate, javax.swing.GroupLayout.PREFERRED_SIZE, 21, javax.swing.GroupLayout.PREFERRED_SIZE)))
);
}
}// </editor-fold>//GEN-END:initComponents
private void btnPlayerDeckActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnPlayerDeckActionPerformed
playerLoadDeck();
}//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();
}
}//GEN-LAST:event_btnGenerateActionPerformed
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnGenerate;
private javax.swing.JButton btnPlayerDeck;
private javax.swing.JComboBox cbLevel;
private javax.swing.JLabel lblLevel;
private javax.swing.JLabel lblPlayerDeck;
private javax.swing.JLabel lblPlayerName;
private javax.swing.JTextField txtPlayerDeck;
private javax.swing.JTextField txtPlayerName;
// End of variables declaration//GEN-END:variables
private javax.swing.JButton btnGenerate;
}
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">
<AuxValues>
@ -11,45 +11,10 @@
<AuxValue name="FormSettings_listenerGenerationStyle" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_variablesLocal" type="java.lang.Boolean" value="false"/>
<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>
<Layout>
<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>
<Layout class="org.netbeans.modules.form.compat2.layouts.DesignFlowLayout"/>
<SubComponents>
<Component class="javax.swing.JLabel" name="lbPlayerType">
<Properties>
@ -61,8 +26,6 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="cbPlayerTypeActionPerformed"/>
</Events>
</Component>
<Component class="mage.client.table.NewPlayerPanel" name="newPlayerPanel">
</Component>
<Component class="javax.swing.JLabel" name="lblPlayerNum">
<Properties>
<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()));
this.lblPlayerNum.setText("Player " + playerNum);
if (Config.defaultOtherPlayerIndex != null) {
try {
if (Integer.valueOf(Config.defaultOtherPlayerIndex) >= cbPlayerType.getItemCount())
cbPlayerType.setSelectedIndex(cbPlayerType.getItemCount() - 1);
else {
Integer index = Integer.parseInt(Config.defaultOtherPlayerIndex);
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 {
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;
}

View file

@ -101,7 +101,7 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
if (state.equals("Join")) {
if (isTournament) {
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);
}
else {
@ -311,8 +311,8 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
options.setRange(RangeOfInfluence.ALL);
options.setWinsNeeded(1);
table = session.createTable(roomId, options);
session.joinTable(roomId, table.getTableId(), "Human", "Human", Sets.loadDeck("test.dck"));
session.joinTable(roomId, table.getTableId(), "Computer", "Computer - default", Sets.loadDeck("test.dck"));
session.joinTable(roomId, table.getTableId(), "Human", "Human", 1, Sets.loadDeck("test.dck"));
session.joinTable(roomId, table.getTableId(), "Computer", "Computer - default", 1, Sets.loadDeck("test.dck"));
hideTables();
session.startGame(roomId, table.getTableId());
} catch (Exception ex) {

View file

@ -21,7 +21,7 @@
<EmptySpace max="-2" attributes="0"/>
<Component id="jLabel1" min="-2" 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"/>
<Component id="pnlPlayerName" max="32767" attributes="0"/>
</Group>
@ -76,16 +76,22 @@
<DimensionLayout dim="0">
<Group type="103" groupAlignment="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"/>
<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>
</DimensionLayout>
<DimensionLayout dim="1">
<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="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"/>
</Group>
</Group>
@ -99,6 +105,29 @@
<Property name="text" type="java.lang.String" value="Name:"/>
</Properties>
</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>
</Container>
</SubComponents>

View file

@ -66,7 +66,7 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
public boolean joinTournamentTable(UUID roomId, UUID tableId) {
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;
}
@ -87,6 +87,8 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
pnlPlayerName = new javax.swing.JPanel();
txtPlayerName = new javax.swing.JTextField();
jLabel2 = new javax.swing.JLabel();
jLabel3 = new javax.swing.JLabel();
cbLevel = new javax.swing.JComboBox();
jLabel1.setLabelFor(cbPlayerType);
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:");
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);
pnlPlayerName.setLayout(pnlPlayerNameLayout);
pnlPlayerNameLayout.setHorizontalGroup(
pnlPlayerNameLayout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.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)
.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.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.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(cbLevel, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addComponent(jLabel3)
.addComponent(jLabel2))
);
@ -128,7 +140,7 @@ public class TournamentPlayerPanel extends javax.swing.JPanel {
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(jLabel1)
.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)
.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
private javax.swing.JComboBox cbLevel;
private javax.swing.JComboBox cbPlayerType;
private javax.swing.JLabel jLabel1;
private javax.swing.JLabel jLabel2;
private javax.swing.JLabel jLabel3;
private javax.swing.JLabel lblPlayerNum;
private javax.swing.JPanel pnlPlayerName;
private javax.swing.JTextField txtPlayerName;

View file

@ -49,15 +49,7 @@ public class Config {
public static final String remoteServer;
public static final String serverName;
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 boolean useResource;
public static final CardDimensions dimensions;
public static final String defaultGameType;
@ -75,8 +67,6 @@ public class Config {
serverName = p.getProperty("server-name");
port = Integer.parseInt(p.getProperty("port"));
remoteServer = p.getProperty("remote-server");
cardsResourcePath = p.getProperty("cards-resource-path");
resourcePath = p.getProperty("resource-path");
cardScalingFactor = Double.valueOf(p.getProperty("card-scaling-factor"));
defaultGameType = p.getProperty("default-game-type", "Human");
defaultDeckPath = p.getProperty("default-deck-path");
@ -84,23 +74,6 @@ public class Config {
defaultComputerName = p.getProperty("default-computer-name");
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 java.awt.Color;
import java.awt.Graphics2D;
import java.awt.Image;
import java.awt.RenderingHints;
@ -38,7 +37,6 @@ import java.awt.image.BufferedImage;
import java.awt.image.ImageObserver;
import java.awt.image.MemoryImageSource;
import java.awt.image.PixelGrabber;
import java.io.File;
import java.io.IOException;
import java.io.InputStream;
import java.util.HashMap;
@ -46,14 +44,9 @@ import java.util.List;
import javax.imageio.ImageIO;
import mage.Constants.CardType;
import mage.Constants.Rarity;
import mage.cards.CardDimensions;
import mage.client.components.arcane.UI;
import mage.sets.Sets;
import mage.view.AbilityView;
import mage.view.CardView;
import mage.view.StackAbilityView;
import com.mortennobel.imagescaling.ResampleOp;
@ -88,10 +81,7 @@ public class ImageHelper {
public static BufferedImage loadImage(String ref) {
if (!images.containsKey(ref)) {
try {
if (Config.useResource)
images.put(ref, ImageIO.read(ImageHelper.class.getResourceAsStream(ref)));
else
images.put(ref, ImageIO.read(new File(ref)));
} catch (Exception e) {
return null;
}
@ -105,139 +95,10 @@ public class ImageHelper {
}
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);
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) {
BufferedImage scaledImage = image;
@ -291,18 +152,11 @@ public class ImageHelper {
int costLeft = xOffset;
for (int i = costs.size() - 1; i >= 0; i--) {
String symbol = costs.get(i);
Image image = Symbols.getSymbol(symbol);
if (image != null) {
g.drawImage(image, costLeft, yOffset, o);
costLeft -= SYMBOL_MAX_SPACE;
}
else {
g.drawString(symbol, costLeft, yOffset + SYMBOL_MAX_SPACE);
costLeft -= SYMBOL_MAX_SPACE + 4;
}
}
}
}
/**
* Returns an image scaled to the size appropriate for the card picture

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>
<groupId>org.mage</groupId>
<artifactId>mage-root</artifactId>
<version>0.7</version>
<version>0.7.2</version>
</parent>
<artifactId>Mage-Common</artifactId>

View file

@ -37,6 +37,7 @@ import mage.cards.decks.DeckCardLists;
import mage.game.GameException;
import mage.game.tournament.TournamentOptions;
import mage.interfaces.callback.CallbackServer;
import mage.utils.MageVersion;
import mage.view.DraftPickView;
import mage.view.TableView;
import mage.view.GameView;
@ -48,7 +49,7 @@ import mage.view.TournamentView;
*/
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 ack(String message, UUID sessionId) throws RemoteException, MageException;
@ -57,8 +58,8 @@ public interface Server extends Remote, CallbackServer {
//table methods
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 boolean joinTable(UUID sessionId, UUID roomId, UUID tableId, String name, String playerType, 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 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, int skill) 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 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.util.List;
import mage.utils.MageVersion;
import mage.view.GameTypeView;
import mage.view.TournamentTypeView;
@ -44,13 +45,15 @@ public class ServerState implements Serializable {
private String[] playerTypes;
private String[] deckTypes;
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.tournamentTypes = tournamentTypes;
this.playerTypes = playerTypes;
this.deckTypes = deckTypes;
this.testMode = testMode;
this.version = version;
}
public List<GameTypeView> getGameTypes() {
@ -73,4 +76,7 @@ public class ServerState implements Serializable {
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>
<groupId>org.mage</groupId>
<artifactId>Mage-Plugins</artifactId>
<version>0.7</version>
<version>0.7.2</version>
</parent>
<artifactId>Mage-Card-Plugin</artifactId>

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

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

View file

@ -176,6 +176,7 @@ public class ComputerPlayer2 extends ComputerPlayer<ComputerPlayer2> implements
if (usedStack)
pass();
}
logger.info("Turn " + game.getTurnNum() + " Step " + game.getStep().toString() + " Player " + name + " Life " + life);
}
protected void calculateActions(Game game) {
@ -337,7 +338,11 @@ public class ComputerPlayer2 extends ComputerPlayer<ComputerPlayer2> implements
} catch (InterruptedException ex) {
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) {
logger.fatal("Simulation error", e);
task.cancel(true);

View file

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

View file

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

View file

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

View file

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

View file

@ -6,7 +6,7 @@
<parent>
<groupId>org.mage</groupId>
<artifactId>mage-root</artifactId>
<version>0.7</version>
<version>0.7.2</version>
</parent>
<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.GamePlugin;
import mage.util.Copier;
import mage.utils.MageVersion;
import org.apache.log4j.Logger;
/**
@ -55,7 +56,7 @@ public class Main {
private final static String testModeArg = "-testMode=";
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 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.TournamentManager;
import mage.server.util.ThreadExecutor;
import mage.utils.MageVersion;
import mage.view.ChatMessage.MessageColor;
import mage.view.DraftPickView;
import mage.view.GameView;
@ -105,10 +106,13 @@ public class ServerImpl extends RemoteServer implements Server {
}
@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 {
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());
} catch (Exception ex) {
handleException(ex);
@ -161,7 +165,7 @@ public class ServerImpl extends RemoteServer implements Server {
}
@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 {
boolean ret = GamesRoomManager.getInstance().getRoom(roomId).joinTable(sessionId, tableId, name, playerType, deckList);
logger.info("Session " + sessionId + " joined table " + tableId);
@ -176,7 +180,7 @@ public class ServerImpl extends RemoteServer implements Server {
}
@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 {
boolean ret = GamesRoomManager.getInstance().getRoom(roomId).joinTournamentTable(sessionId, tableId, name, playerType);
logger.info("Session " + sessionId + " joined table " + tableId);
@ -726,7 +730,8 @@ public class ServerImpl extends RemoteServer implements Server {
TournamentFactory.getInstance().getTournamentTypes(),
PlayerFactory.getInstance().getPlayerTypes().toArray(new String[0]),
DeckValidatorFactory.getInstance().getDeckTypes().toArray(new String[0]),
testMode);
testMode,
Main.getVersion());
}
catch (Exception ex) {
handleException(ex);

View file

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

View file

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

18
pom.xml
View file

@ -6,11 +6,23 @@
<groupId>org.mage</groupId>
<artifactId>mage-root</artifactId>
<version>0.7</version>
<version>0.7.2</version>
<packaging>pom</packaging>
<name>Mage Root</name>
<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>
<module>Mage</module>
<module>Mage.Common</module>
@ -34,6 +46,6 @@
</repositories>
<properties>
<mage-version>0.7</mage-version>
<mage-version>0.7.2</mage-version>
</properties>
</project>