some more drafting stuff

This commit is contained in:
BetaSteward 2011-01-07 15:41:09 -05:00
parent c67122b605
commit 98d8a428a7
11 changed files with 403 additions and 4 deletions

View file

@ -0,0 +1,41 @@
<?xml version="1.1" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JInternalFrameFormInfo">
<SyntheticProperties>
<SyntheticProperty name="formSizePolicy" type="int" value="1"/>
</SyntheticProperties>
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<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="0"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="394" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jScrollPane1" alignment="0" pref="282" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JScrollPane" name="jScrollPane1">
<Layout class="org.netbeans.modules.form.compat2.layouts.support.JScrollPaneSupportLayout"/>
<SubComponents>
<Component class="mage.client.draft.DraftPanel" name="draftPanel1">
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View file

@ -0,0 +1,84 @@
/*
* 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.
*/
/*
* DraftPane.java
*
* Created on Jan 7, 2011, 2:11:44 PM
*/
package mage.client.draft;
import mage.client.MagePane;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class DraftPane extends MagePane {
/** Creates new form DraftPane */
public DraftPane() {
initComponents();
}
/** 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">//GEN-BEGIN:initComponents
private void initComponents() {
jScrollPane1 = new javax.swing.JScrollPane();
draftPanel1 = new mage.client.draft.DraftPanel();
jScrollPane1.setViewportView(draftPanel1);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(getContentPane());
getContentPane().setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 394, Short.MAX_VALUE)
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jScrollPane1, javax.swing.GroupLayout.DEFAULT_SIZE, 282, Short.MAX_VALUE)
);
pack();
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
mage.client.draft.DraftPanel draftPanel1;
javax.swing.JScrollPane jScrollPane1;
// End of variables declaration//GEN-END:variables
}

View file

@ -0,0 +1,62 @@
<?xml version="1.1" encoding="UTF-8" ?>
<Form version="1.3" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
<AuxValue name="FormSettings_autoResourcing" type="java.lang.Integer" value="0"/>
<AuxValue name="FormSettings_autoSetComponentName" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_generateFQN" type="java.lang.Boolean" value="true"/>
<AuxValue name="FormSettings_generateMnemonicsCode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_i18nAutoMode" type="java.lang.Boolean" value="false"/>
<AuxValue name="FormSettings_layoutCodeTarget" type="java.lang.Integer" value="1"/>
<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"/>
</AuxValues>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="0" attributes="0">
<Component id="jPanel1" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="465" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="jPanel1" alignment="0" max="32767" attributes="0"/>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Container class="javax.swing.JPanel" name="jPanel1">
<Properties>
<Property name="border" type="javax.swing.border.Border" editor="org.netbeans.modules.form.editors2.BorderEditor">
<Border info="org.netbeans.modules.form.compat2.border.BevelBorderInfo">
<BevelBorder/>
</Border>
</Property>
</Properties>
<Layout>
<DimensionLayout dim="0">
<Group type="103" groupAlignment="0" attributes="0">
<Component id="bigCard" min="-2" max="-2" attributes="0"/>
</Group>
</DimensionLayout>
<DimensionLayout dim="1">
<Group type="103" groupAlignment="0" attributes="0">
<Group type="102" alignment="1" attributes="0">
<EmptySpace pref="85" max="32767" attributes="0"/>
<Component id="bigCard" min="-2" max="-2" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
</Layout>
<SubComponents>
<Component class="mage.client.cards.BigCard" name="bigCard">
</Component>
</SubComponents>
</Container>
</SubComponents>
</Form>

View file

@ -0,0 +1,104 @@
/*
* 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.
*/
/*
* DraftPanel.java
*
* Created on Jan 7, 2011, 2:15:48 PM
*/
package mage.client.draft;
import java.util.UUID;
import mage.client.cards.BigCard;
import mage.view.CardsView;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class DraftPanel extends javax.swing.JPanel {
/** Creates new form DraftPanel */
public DraftPanel() {
initComponents();
}
public void loadBooster(CardsView cards, UUID draftId) {
}
/** 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">//GEN-BEGIN:initComponents
private void initComponents() {
jPanel1 = new javax.swing.JPanel();
bigCard = new mage.client.cards.BigCard();
jPanel1.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(javax.swing.GroupLayout.Alignment.TRAILING, jPanel1Layout.createSequentialGroup()
.addContainerGap(85, Short.MAX_VALUE)
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
);
javax.swing.GroupLayout layout = new javax.swing.GroupLayout(this);
this.setLayout(layout);
layout.setHorizontalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addGroup(layout.createSequentialGroup()
.addComponent(jPanel1, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
.addContainerGap(465, Short.MAX_VALUE))
);
layout.setVerticalGroup(
layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
.addComponent(jPanel1, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, Short.MAX_VALUE)
);
}// </editor-fold>//GEN-END:initComponents
// Variables declaration - do not modify//GEN-BEGIN:variables
private mage.client.cards.BigCard bigCard;
private javax.swing.JPanel jPanel1;
// End of variables declaration//GEN-END:variables
}

View file

@ -44,6 +44,7 @@ import mage.interfaces.callback.ClientCallback;
import mage.util.Logging;
import mage.view.AbilityPickerView;
import mage.view.ChatMessage;
import mage.view.DraftClientMessage;
import mage.view.GameClientMessage;
import mage.view.GameView;
import mage.view.TableClientMessage;
@ -164,6 +165,21 @@ public class Client implements CallbackClient {
else if (callback.getMethod().equals("sideboard")) {
TableClientMessage message = (TableClientMessage) callback.getData();
sideboard(message.getDeck(), message.getTableId());
}
else if (callback.getMethod().equals("draftPick")) {
DraftClientMessage message = (DraftClientMessage) callback.getData();
}
else if (callback.getMethod().equals("draftInform")) {
if (callback.getMessageId() > messageId) {
DraftClientMessage message = (DraftClientMessage) callback.getData();
}
else {
logger.warning("message out of sequence - ignoring");
}
}
else if (callback.getMethod().equals("draftInit")) {
}
messageId = callback.getMessageId();
}

View file

@ -47,6 +47,7 @@ import mage.client.components.MageUI;
import mage.client.game.GamePanel;
import mage.client.util.Config;
import mage.game.GameException;
import mage.game.draft.DraftOptions;
import mage.interfaces.MageException;
import mage.game.match.MatchOptions;
import mage.interfaces.Server;
@ -261,6 +262,19 @@ public class Session {
return false;
}
public boolean joinDraftTable(UUID roomId, UUID tableId, String playerName) {
try {
return server.joinDraftTable(sessionId, roomId, tableId, playerName);
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
} catch (GameException ex) {
handleGameException(ex);
}
return false;
}
public Collection<TableView> getTables(UUID roomId) throws MageRemoteException {
try {
return server.getTables(roomId);
@ -418,6 +432,17 @@ public class Session {
return null;
}
public TableView createDraftTable(UUID roomId, DraftOptions draftOptions) {
try {
return server.createDraftTable(sessionId, roomId, draftOptions);
} catch (RemoteException ex) {
handleRemoteException(ex);
} catch (MageException ex) {
handleMageException(ex);
}
return null;
}
public boolean isTableOwner(UUID roomId, UUID tableId) {
try {
return server.isTableOwner(sessionId, roomId, tableId);

View file

@ -1,4 +1,4 @@
<?xml version="1.0" encoding="UTF-8" ?>
<?xml version="1.1" encoding="UTF-8" ?>
<Form version="1.5" maxVersion="1.7" type="org.netbeans.modules.form.forminfo.JPanelFormInfo">
<AuxValues>
@ -39,9 +39,11 @@
<Group type="102" alignment="0" attributes="0">
<EmptySpace max="-2" attributes="0"/>
<Component id="btnNewTable" min="-2" max="-2" attributes="0"/>
<EmptySpace min="-2" pref="6" max="-2" attributes="0"/>
<Component id="btnNewDraft" min="-2" max="-2" attributes="0"/>
<EmptySpace max="-2" attributes="0"/>
<Component id="btnQuickStart" min="-2" max="-2" attributes="0"/>
<EmptySpace pref="537" max="32767" attributes="0"/>
<EmptySpace pref="450" max="32767" attributes="0"/>
</Group>
</Group>
</DimensionLayout>
@ -52,6 +54,7 @@
<Group type="103" groupAlignment="3" attributes="0">
<Component id="btnNewTable" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnQuickStart" alignment="3" min="-2" max="-2" attributes="0"/>
<Component id="btnNewDraft" alignment="3" min="-2" max="-2" attributes="0"/>
</Group>
<EmptySpace pref="16" max="32767" attributes="0"/>
</Group>
@ -75,6 +78,14 @@
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnQuickStartActionPerformed"/>
</Events>
</Component>
<Component class="javax.swing.JButton" name="btnNewDraft">
<Properties>
<Property name="text" type="java.lang.String" value="New Draft"/>
</Properties>
<Events>
<EventHandler event="actionPerformed" listener="java.awt.event.ActionListener" parameters="java.awt.event.ActionEvent" handler="btnNewDraftActionPerformed"/>
</Events>
</Component>
</SubComponents>
</Container>
<Container class="javax.swing.JSplitPane" name="jSplitPane1">

View file

@ -62,6 +62,7 @@ import mage.client.dialog.TableWaitingDialog;
import mage.client.remote.MageRemoteException;
import mage.client.remote.Session;
import mage.client.util.ButtonColumn;
import mage.game.draft.DraftOptions;
import mage.game.match.MatchOptions;
import mage.sets.Sets;
import mage.util.Logging;
@ -203,6 +204,7 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
jPanel1 = new javax.swing.JPanel();
btnNewTable = new javax.swing.JButton();
btnQuickStart = new javax.swing.JButton();
btnNewDraft = new javax.swing.JButton();
jSplitPane1 = new javax.swing.JSplitPane();
chatPanel = new mage.client.chat.ChatPanel();
jScrollPane1 = new javax.swing.JScrollPane();
@ -222,6 +224,13 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
}
});
btnNewDraft.setText("New Draft");
btnNewDraft.addActionListener(new java.awt.event.ActionListener() {
public void actionPerformed(java.awt.event.ActionEvent evt) {
btnNewDraftActionPerformed(evt);
}
});
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
jPanel1.setLayout(jPanel1Layout);
jPanel1Layout.setHorizontalGroup(
@ -229,9 +238,11 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
.addGroup(jPanel1Layout.createSequentialGroup()
.addContainerGap()
.addComponent(btnNewTable)
.addGap(6, 6, 6)
.addComponent(btnNewDraft)
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
.addComponent(btnQuickStart)
.addContainerGap(537, Short.MAX_VALUE))
.addContainerGap(450, Short.MAX_VALUE))
);
jPanel1Layout.setVerticalGroup(
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
@ -239,7 +250,8 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
.addContainerGap()
.addGroup(jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.BASELINE)
.addComponent(btnNewTable)
.addComponent(btnQuickStart))
.addComponent(btnQuickStart)
.addComponent(btnNewDraft))
.addContainerGap(16, Short.MAX_VALUE))
);
@ -307,6 +319,32 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
}
}//GEN-LAST:event_btnQuickStartActionPerformed
private void btnNewDraftActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_btnNewDraftActionPerformed
DraftOptions options = new DraftOptions("testDraft");
options.getPlayerTypes().add("Human");
options.getPlayerTypes().add("Computer - default");
options.getPlayerTypes().add("Computer - default");
options.getPlayerTypes().add("Computer - default");
options.getPlayerTypes().add("Computer - default");
options.getPlayerTypes().add("Computer - default");
options.getPlayerTypes().add("Computer - default");
options.getPlayerTypes().add("Computer - default");
options.getSets().add(Sets.findSet("M11"));
options.getSets().add(Sets.findSet("M11"));
options.getSets().add(Sets.findSet("M11"));
TableView table = session.createDraftTable(roomId, options);
session.joinDraftTable(roomId, table.getTableId(), "Human");
session.joinDraftTable(roomId, table.getTableId(), "Computer 1");
session.joinDraftTable(roomId, table.getTableId(), "Computer 2");
session.joinDraftTable(roomId, table.getTableId(), "Computer 3");
session.joinDraftTable(roomId, table.getTableId(), "Computer 4");
session.joinDraftTable(roomId, table.getTableId(), "Computer 5");
session.joinDraftTable(roomId, table.getTableId(), "Computer 6");
session.joinDraftTable(roomId, table.getTableId(), "Computer 7");
hideTables();
session.startDraft(roomId, table.getTableId());
}//GEN-LAST:event_btnNewDraftActionPerformed
private void handleError(Exception ex) {
logger.log(Level.SEVERE, "Error loading deck", ex);
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error loading deck.", "Error", JOptionPane.ERROR_MESSAGE);
@ -314,6 +352,7 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
// Variables declaration - do not modify//GEN-BEGIN:variables
private javax.swing.JButton btnNewDraft;
private javax.swing.JButton btnNewTable;
private javax.swing.JButton btnQuickStart;
private mage.client.chat.ChatPanel chatPanel;