mirror of
https://github.com/magefree/mage.git
synced 2025-12-24 20:41:58 -08:00
fixed multi-human drafting
This commit is contained in:
parent
5a785b9330
commit
e2fd0299c7
31 changed files with 160 additions and 107 deletions
|
|
@ -242,8 +242,10 @@ public class MageFrame extends javax.swing.JFrame {
|
|||
public void run() {
|
||||
if (autoConnect())
|
||||
enableButtons();
|
||||
else
|
||||
else {
|
||||
disableButtons();
|
||||
connectDialog.showDialog();
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
|
|
|
|||
|
|
@ -449,8 +449,8 @@ public class DeckEditorPanel extends javax.swing.JPanel {
|
|||
}//GEN-LAST:event_btnImportActionPerformed
|
||||
|
||||
private void btnSubmitActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
MageFrame.getSession().submitDeck(tableId, deck.getDeckCardLists());
|
||||
this.setVisible(false);
|
||||
if (MageFrame.getSession().submitDeck(tableId, deck.getDeckCardLists()))
|
||||
this.setVisible(false);
|
||||
}
|
||||
|
||||
private void btnAddLandActionPerformed(java.awt.event.ActionEvent evt) {
|
||||
|
|
|
|||
|
|
@ -40,9 +40,7 @@ import java.util.UUID;
|
|||
import java.util.logging.Level;
|
||||
import java.util.logging.Logger;
|
||||
import javax.swing.JOptionPane;
|
||||
import mage.cards.decks.DeckCardLists;
|
||||
import mage.client.remote.Session;
|
||||
import mage.client.util.PhaseManager;
|
||||
import mage.sets.Sets;
|
||||
import mage.util.Logging;
|
||||
|
||||
|
|
@ -138,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(), Sets.loadDeck(this.newPlayerPanel.getDeckFile()));
|
||||
joined = session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), "Human", Sets.loadDeck(this.newPlayerPanel.getDeckFile()));
|
||||
} catch (Exception ex) {
|
||||
handleError(ex);
|
||||
}
|
||||
|
|
|
|||
|
|
@ -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(), Sets.loadDeck(this.player1Panel.getDeckFile()))) {
|
||||
if (session.joinTable(roomId, table.getTableId(), this.player1Panel.getPlayerName(), "Human", Sets.loadDeck(this.player1Panel.getDeckFile()))) {
|
||||
for (TablePlayerPanel player: players) {
|
||||
if (!player.getPlayerType().equals("Human")) {
|
||||
if (!player.joinTable(roomId, table.getTableId())) {
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@
|
|||
<EmptySpace min="-2" pref="3" max="-2" attributes="0"/>
|
||||
<Component id="jLabel5" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace min="-2" pref="1" max="-2" attributes="0"/>
|
||||
<Component id="pnlPacks" pref="47" max="32767" attributes="0"/>
|
||||
<Component id="pnlPacks" pref="49" max="32767" attributes="0"/>
|
||||
<EmptySpace min="-2" max="-2" attributes="0"/>
|
||||
<Group type="103" groupAlignment="3" attributes="0">
|
||||
<Component id="spnNumPlayers" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
|
|
@ -164,7 +164,7 @@
|
|||
<Component id="txtPlayer1Name" alignment="3" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
<EmptySpace type="unrelated" max="-2" attributes="0"/>
|
||||
<Component id="pnlOtherPlayers" pref="58" max="32767" attributes="0"/>
|
||||
<Component id="pnlOtherPlayers" pref="60" max="32767" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
|
|
|
|||
|
|
@ -259,7 +259,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())) {
|
||||
if (session.joinTournamentTable(roomId, table.getTableId(), this.txtPlayer1Name.getText(), "Human")) {
|
||||
for (TournamentPlayerPanel player: players) {
|
||||
if (!player.getPlayerType().equals("Human")) {
|
||||
if (!player.joinTournamentTable(roomId, table.getTableId())) {
|
||||
|
|
|
|||
|
|
@ -87,14 +87,14 @@ public class TableWaitingDialog extends MageDialog implements Observer {
|
|||
this.btnMoveDown.setEnabled(true);
|
||||
this.btnMoveUp.setEnabled(true);
|
||||
break;
|
||||
case DUELING:
|
||||
closeDialog();
|
||||
return;
|
||||
default:
|
||||
case WAITING:
|
||||
this.btnStart.setEnabled(false);
|
||||
this.btnMoveDown.setEnabled(false);
|
||||
this.btnMoveUp.setEnabled(false);
|
||||
break;
|
||||
default:
|
||||
closeDialog();
|
||||
return;
|
||||
}
|
||||
int row = this.tableSeats.getSelectedRow();
|
||||
tableWaitModel.loadData(table);
|
||||
|
|
|
|||
|
|
@ -89,6 +89,11 @@
|
|||
<Component id="chkPack1" alignment="0" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
<Group type="102" alignment="0" attributes="0">
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblMessage" pref="236" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
</DimensionLayout>
|
||||
<DimensionLayout dim="1">
|
||||
|
|
@ -119,7 +124,9 @@
|
|||
</Group>
|
||||
<EmptySpace type="separate" max="-2" attributes="0"/>
|
||||
<Component id="txtTimeRemaining" min="-2" max="-2" attributes="0"/>
|
||||
<EmptySpace pref="41" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="lblMessage" pref="29" max="32767" attributes="0"/>
|
||||
<EmptySpace max="-2" attributes="0"/>
|
||||
<Component id="bigCard" min="-2" max="-2" attributes="0"/>
|
||||
</Group>
|
||||
</Group>
|
||||
|
|
@ -192,6 +199,11 @@
|
|||
</Property>
|
||||
</Properties>
|
||||
</Component>
|
||||
<Component class="javax.swing.JLabel" name="lblMessage">
|
||||
<Properties>
|
||||
<Property name="horizontalAlignment" type="int" value="0"/>
|
||||
</Properties>
|
||||
</Component>
|
||||
</SubComponents>
|
||||
</Container>
|
||||
<Container class="mage.client.cards.DraftGrid" name="draftBooster">
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
private Session session;
|
||||
private Timer countdown;
|
||||
private int timeout;
|
||||
private boolean picked;
|
||||
|
||||
/** Creates new form DraftPanel */
|
||||
public DraftPanel() {
|
||||
|
|
@ -103,12 +104,18 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
@Override
|
||||
public void event(Event event) {
|
||||
if (event.getEventName().equals("pick-a-card")) {
|
||||
countdown.stop();
|
||||
session.sendCardPick(draftId, (UUID)event.getSource());
|
||||
DraftPickView view = session.sendCardPick(draftId, (UUID)event.getSource());
|
||||
if (view != null) {
|
||||
draftBooster.loadBooster(view.getBooster(), bigCard);
|
||||
draftPicks.loadCards(view.getPicks(), bigCard, null);
|
||||
setMessage("Waiting for other players");
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
);
|
||||
setMessage("");
|
||||
countdown.stop();
|
||||
this.timeout = draftPickView.getTimeout();
|
||||
setTimeout(Integer.toString(timeout));
|
||||
if (timeout != 0) {
|
||||
|
|
@ -129,6 +136,10 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
c.setVisible(false);
|
||||
}
|
||||
|
||||
protected void setMessage(String message) {
|
||||
this.lblMessage.setText(message);
|
||||
}
|
||||
|
||||
/** This method is called from within the constructor to
|
||||
* initialize the form.
|
||||
* WARNING: Do NOT modify this code. The content of this method is
|
||||
|
|
@ -153,6 +164,7 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
chkPack2 = new javax.swing.JCheckBox();
|
||||
chkPack3 = new javax.swing.JCheckBox();
|
||||
txtTimeRemaining = new javax.swing.JTextField();
|
||||
lblMessage = new javax.swing.JLabel();
|
||||
draftBooster = new mage.client.cards.DraftGrid();
|
||||
draftPicks = new mage.client.cards.CardGrid();
|
||||
|
||||
|
|
@ -183,6 +195,8 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
txtTimeRemaining.setHorizontalAlignment(javax.swing.JTextField.CENTER);
|
||||
txtTimeRemaining.setBorder(javax.swing.BorderFactory.createBevelBorder(javax.swing.border.BevelBorder.RAISED));
|
||||
|
||||
lblMessage.setHorizontalAlignment(javax.swing.SwingConstants.CENTER);
|
||||
|
||||
javax.swing.GroupLayout jPanel1Layout = new javax.swing.GroupLayout(jPanel1);
|
||||
jPanel1.setLayout(jPanel1Layout);
|
||||
jPanel1Layout.setHorizontalGroup(
|
||||
|
|
@ -214,6 +228,10 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
.addComponent(chkPack3)
|
||||
.addComponent(chkPack2)
|
||||
.addComponent(chkPack1)))
|
||||
.addGroup(jPanel1Layout.createSequentialGroup()
|
||||
.addContainerGap()
|
||||
.addComponent(lblMessage, javax.swing.GroupLayout.DEFAULT_SIZE, 236, Short.MAX_VALUE)
|
||||
.addContainerGap())
|
||||
);
|
||||
jPanel1Layout.setVerticalGroup(
|
||||
jPanel1Layout.createParallelGroup(javax.swing.GroupLayout.Alignment.LEADING)
|
||||
|
|
@ -239,7 +257,9 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
.addComponent(txtCardNo, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
.addGap(18, 18, 18)
|
||||
.addComponent(txtTimeRemaining, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED, 41, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(lblMessage, javax.swing.GroupLayout.DEFAULT_SIZE, 29, Short.MAX_VALUE)
|
||||
.addPreferredGap(javax.swing.LayoutStyle.ComponentPlacement.RELATED)
|
||||
.addComponent(bigCard, javax.swing.GroupLayout.PREFERRED_SIZE, javax.swing.GroupLayout.DEFAULT_SIZE, javax.swing.GroupLayout.PREFERRED_SIZE))
|
||||
);
|
||||
|
||||
|
|
@ -290,6 +310,7 @@ public class DraftPanel extends javax.swing.JPanel {
|
|||
private javax.swing.JPanel jPanel1;
|
||||
private javax.swing.JSeparator jSeparator1;
|
||||
private javax.swing.JLabel lblCardNo;
|
||||
private javax.swing.JLabel lblMessage;
|
||||
private javax.swing.JLabel lblPack1;
|
||||
private javax.swing.JLabel lblPack2;
|
||||
private javax.swing.JLabel lblPack3;
|
||||
|
|
|
|||
|
|
@ -56,6 +56,7 @@ import mage.interfaces.Server;
|
|||
import mage.interfaces.ServerState;
|
||||
import mage.interfaces.callback.CallbackClientDaemon;
|
||||
import mage.util.Logging;
|
||||
import mage.view.DraftPickView;
|
||||
import mage.view.GameTypeView;
|
||||
import mage.view.TableView;
|
||||
import mage.view.TournamentTypeView;
|
||||
|
|
@ -105,6 +106,7 @@ public class Session {
|
|||
return true;
|
||||
} catch (MageException ex) {
|
||||
logger.log(Level.SEVERE, null, ex);
|
||||
disconnect();
|
||||
JOptionPane.showMessageDialog(frame, "Unable to connect to server. " + ex.getMessage());
|
||||
} catch (RemoteException ex) {
|
||||
logger.log(Level.SEVERE, "Unable to connect to server - ", ex);
|
||||
|
|
@ -272,9 +274,9 @@ public class Session {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean joinTable(UUID roomId, UUID tableId, String playerName, DeckCardLists deckList) {
|
||||
public boolean joinTable(UUID roomId, UUID tableId, String playerName, String playerType, DeckCardLists deckList) {
|
||||
try {
|
||||
return server.joinTable(sessionId, roomId, tableId, playerName, deckList);
|
||||
return server.joinTable(sessionId, roomId, tableId, playerName, playerType, deckList);
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
|
|
@ -285,9 +287,9 @@ public class Session {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName) {
|
||||
public boolean joinTournamentTable(UUID roomId, UUID tableId, String playerName, String playerType) {
|
||||
try {
|
||||
return server.joinTournamentTable(sessionId, roomId, tableId, playerName);
|
||||
return server.joinTournamentTable(sessionId, roomId, tableId, playerName, playerType);
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
|
|
@ -381,16 +383,15 @@ public class Session {
|
|||
return false;
|
||||
}
|
||||
|
||||
public boolean sendCardPick(UUID draftId, UUID cardId) {
|
||||
public DraftPickView sendCardPick(UUID draftId, UUID cardId) {
|
||||
try {
|
||||
server.sendCardPick(draftId, sessionId, cardId);
|
||||
return true;
|
||||
return server.sendCardPick(draftId, sessionId, cardId);
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
handleMageException(ex);
|
||||
}
|
||||
return false;
|
||||
return null;
|
||||
}
|
||||
|
||||
public boolean joinChat(UUID chatId, ChatPanel chat) {
|
||||
|
|
@ -586,8 +587,7 @@ public class Session {
|
|||
|
||||
public boolean submitDeck(UUID tableId, DeckCardLists deck) {
|
||||
try {
|
||||
server.submitDeck(sessionId, tableId, deck);
|
||||
return true;
|
||||
return server.submitDeck(sessionId, tableId, deck);
|
||||
} catch (RemoteException ex) {
|
||||
handleRemoteException(ex);
|
||||
} catch (MageException ex) {
|
||||
|
|
|
|||
|
|
@ -82,7 +82,7 @@ public class TablePlayerPanel extends javax.swing.JPanel {
|
|||
|
||||
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(), Sets.loadDeck(this.newPlayerPanel.getDeckFile()));
|
||||
return session.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), (String)this.cbPlayerType.getSelectedItem(), Sets.loadDeck(this.newPlayerPanel.getDeckFile()));
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
|
|
@ -97,13 +97,20 @@ public class TablesPanel extends javax.swing.JPanel implements Observer {
|
|||
int modelRow = Integer.valueOf( e.getActionCommand() );
|
||||
UUID tableId = UUID.fromString((String)tableModel.getValueAt(modelRow, 0));
|
||||
String state = (String)tableModel.getValueAt(modelRow, 4);
|
||||
boolean isTournament = (Boolean)tableModel.getValueAt(modelRow, 5);
|
||||
|
||||
if (state.equals("Join")) {
|
||||
logger.info("Joining table " + tableId);
|
||||
|
||||
joinTableDialog.showDialog(roomId, tableId);
|
||||
if (joinTableDialog.isJoined())
|
||||
tableWaitingDialog.showDialog(roomId, tableId, false);
|
||||
if (isTournament) {
|
||||
logger.info("Joining tournament " + tableId);
|
||||
if (session.joinTournamentTable(roomId, tableId, session.getUserName(), "Human"))
|
||||
tableWaitingDialog.showDialog(roomId, tableId, true);
|
||||
}
|
||||
else {
|
||||
logger.info("Joining table " + tableId);
|
||||
joinTableDialog.showDialog(roomId, tableId);
|
||||
if (joinTableDialog.isJoined())
|
||||
tableWaitingDialog.showDialog(roomId, tableId, false);
|
||||
}
|
||||
} else if (state.equals("Watch")) {
|
||||
logger.info("Watching table " + tableId);
|
||||
if (!session.watchTable(roomId, tableId))
|
||||
|
|
@ -305,18 +312,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",
|
||||
Sets.loadDeck("test.dck")
|
||||
);
|
||||
session.joinTable(
|
||||
roomId,
|
||||
table.getTableId(),
|
||||
"Computer",
|
||||
Sets.loadDeck("test.dck")
|
||||
);
|
||||
session.joinTable(roomId, table.getTableId(), "Human", "Human", Sets.loadDeck("test.dck"));
|
||||
session.joinTable(roomId, table.getTableId(), "Computer", "Computer - default", Sets.loadDeck("test.dck"));
|
||||
hideTables();
|
||||
session.startGame(roomId, table.getTableId());
|
||||
} catch (Exception ex) {
|
||||
|
|
@ -392,6 +389,8 @@ class TableTableModel extends AbstractTableModel {
|
|||
default:
|
||||
return "";
|
||||
}
|
||||
case 5:
|
||||
return tables[arg0].isTournament();
|
||||
}
|
||||
return "";
|
||||
}
|
||||
|
|
|
|||
|
|
@ -65,7 +65,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());
|
||||
return session.joinTournamentTable(roomId, tableId, this.txtPlayerName.getText(), (String)this.cbPlayerType.getSelectedItem());
|
||||
}
|
||||
return true;
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue