fixed two lines to allow playing human-human tables

This commit is contained in:
ingmargoudt 2017-04-11 07:54:05 +02:00
parent a08155341e
commit fea477dd04
2 changed files with 183 additions and 184 deletions

View file

@ -53,7 +53,6 @@ import java.util.List;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class NewTableDialog extends MageDialog {
@ -408,7 +407,7 @@ public class NewTableDialog extends MageDialog {
DeckImporterUtil.importDeck(this.player1Panel.getDeckFile()),
this.txtPassword.getText())) {
for (TablePlayerPanel player : players) {
if (!player.getPlayerType().equals("Human")) {
if (player.getPlayerType() != PlayerType.HUMAN) {
if (!player.joinTable(roomId, table.getTableId())) {
// error message must be send by the server
SessionHandler.removeTable(roomId, table.getTableId());
@ -597,7 +596,7 @@ public class NewTableDialog extends MageDialog {
String playerTypes = PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_PLAYER_TYPES, "Human");
prefPlayerTypes.clear();
for(String pType : playerTypes.split(",")) {
for (String pType : playerTypes.split(",")) {
prefPlayerTypes.add(PlayerType.getByDescription(pType));
}
this.spnNumPlayers.setValue(Integer.parseInt(PreferencesDialog.getCachedValue(PreferencesDialog.KEY_NEW_TABLE_NUMBER_PLAYERS, "2")));

View file

@ -46,7 +46,6 @@ import java.io.IOException;
import java.util.UUID;
/**
*
* @author BetaSteward_at_googlemail.com
*/
public class TablePlayerPanel extends javax.swing.JPanel {
@ -54,7 +53,9 @@ public class TablePlayerPanel extends javax.swing.JPanel {
protected final PlayerTypeEventSource playerTypeEventSource = new PlayerTypeEventSource();
/** Creates new form TablePlayerPanel */
/**
* Creates new form TablePlayerPanel
*/
public TablePlayerPanel() {
initComponents();
this.newPlayerPanel.setVisible(false);
@ -66,8 +67,7 @@ public class TablePlayerPanel extends javax.swing.JPanel {
if (Config.defaultOtherPlayerIndex != null) {
if (Integer.valueOf(Config.defaultOtherPlayerIndex) >= cbPlayerType.getItemCount()) {
cbPlayerType.setSelectedIndex(cbPlayerType.getItemCount() - 1);
}
else {
} else {
Integer index = Integer.parseInt(Config.defaultOtherPlayerIndex);
cbPlayerType.setSelectedIndex(index);
}
@ -79,7 +79,7 @@ public class TablePlayerPanel extends javax.swing.JPanel {
public boolean joinTable(UUID roomId, UUID tableId) throws IOException, ClassNotFoundException {
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
return SessionHandler.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), (PlayerType) this.cbPlayerType.getSelectedItem(), this.newPlayerPanel.getLevel(), DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()),"");
return SessionHandler.joinTable(roomId, tableId, this.newPlayerPanel.getPlayerName(), (PlayerType) this.cbPlayerType.getSelectedItem(), this.newPlayerPanel.getLevel(), DeckImporterUtil.importDeck(this.newPlayerPanel.getDeckFile()), "");
}
return true;
}
@ -97,7 +97,8 @@ public class TablePlayerPanel extends javax.swing.JPanel {
}
/** This method is called from within the constructor to
/**
* 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.
@ -149,10 +150,9 @@ public class TablePlayerPanel extends javax.swing.JPanel {
}// </editor-fold>//GEN-END:initComponents
private void cbPlayerTypeActionPerformed(java.awt.event.ActionEvent evt) {//GEN-FIRST:event_cbPlayerTypeActionPerformed
if (!this.cbPlayerType.getSelectedItem().equals("Human")) {
if (getPlayerType() != PlayerType.HUMAN) {
this.newPlayerPanel.setVisible(true);
}
else {
} else {
this.newPlayerPanel.setVisible(false);
}
this.revalidate();