use of mage.game.match.MatchOptions in project mage by magefree.
the class NewTableDialog method onSaveSettings.
private void onSaveSettings(int version) {
MatchOptions options = getMatchOptions();
onSaveSettings(version, options, this.player1Panel.getDeckFile());
}
use of mage.game.match.MatchOptions in project mage by magefree.
the class NewTableDialog method btnOKActionPerformed.
// GEN-LAST:event_btnPreviousConfigurationActionPerformed
private void btnOKActionPerformed(java.awt.event.ActionEvent evt) {
// GEN-FIRST:event_btnOKActionPerformed
MatchOptions options = getMatchOptions();
if (!checkMatchOptions(options)) {
return;
}
// save last used
onSaveSettings(0, options, this.player1Panel.getDeckFile());
// run
table = SessionHandler.createTable(roomId, options);
if (table == null) {
JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error creating table.", "Error", JOptionPane.ERROR_MESSAGE);
return;
}
try {
// join AI
for (TablePlayerPanel player : players) {
if (player.getPlayerType() != PlayerType.HUMAN) {
if (!player.joinTable(roomId, table.getTableId())) {
// error message must be send by the server
SessionHandler.removeTable(roomId, table.getTableId());
table = null;
return;
}
}
}
// join itself
if (SessionHandler.joinTable(roomId, table.getTableId(), this.player1Panel.getPlayerName(), PlayerType.HUMAN, 1, DeckImporter.importDeckFromFile(this.player1Panel.getDeckFile(), true), this.txtPassword.getText())) {
// all fine, can close create dialog (join dialog will be opened after feedback from server)
this.hideDialog();
return;
}
} catch (ClassNotFoundException | IOException ex) {
handleError(ex);
}
// JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining table.", "Error", JOptionPane.ERROR_MESSAGE);
SessionHandler.removeTable(roomId, table.getTableId());
table = null;
}
use of mage.game.match.MatchOptions in project mage by magefree.
the class NewTableDialog method getMatchOptions.
// GEN-LAST:event_menuLoadSettingsDefaultActionPerformed
private MatchOptions getMatchOptions() {
// current settings
GameTypeView gameType = (GameTypeView) cbGameType.getSelectedItem();
MatchOptions options = new MatchOptions(this.txtName.getText(), gameType.getName(), false, 2);
options.getPlayerTypes().add(PlayerType.HUMAN);
for (TablePlayerPanel player : players) {
options.getPlayerTypes().add(player.getPlayerType());
}
options.setDeckType((String) this.cbDeckType.getSelectedItem());
options.setLimited(false);
options.setMatchTimeLimit((MatchTimeLimit) this.cbTimeLimit.getSelectedItem());
options.setAttackOption((MultiplayerAttackOption) this.cbAttackOption.getSelectedItem());
options.setSkillLevel((SkillLevel) this.cbSkillLevel.getSelectedItem());
options.setRange((RangeOfInfluence) this.cbRange.getSelectedItem());
options.setWinsNeeded((Integer) this.spnNumWins.getValue());
options.setRollbackTurnsAllowed(chkRollbackTurnsAllowed.isSelected());
options.setSpectatorsAllowed(chkSpectatorsAllowed.isSelected());
options.setPlaneChase(chkPlaneChase.isSelected());
options.setRated(chkRated.isSelected());
options.setFreeMulligans((Integer) this.spnFreeMulligans.getValue());
options.setPassword(this.txtPassword.getText());
options.setQuitRatio((Integer) this.spnQuitRatio.getValue());
options.setMinimumRating((Integer) this.spnMinimumRating.getValue());
options.setEdhPowerLevel((Integer) this.spnEdhPowerLevel.getValue());
options.setMullgianType((MulliganType) this.cbMulligan.getSelectedItem());
String serverAddress = SessionHandler.getSession().getServerHostname().orElse("");
options.setBannedUsers(IgnoreList.getIgnoredUsers(serverAddress));
return options;
}
Aggregations