Search in sources :

Example 11 with MatchOptions

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());
}
Also used : MatchOptions(mage.game.match.MatchOptions)

Example 12 with MatchOptions

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;
}
Also used : TablePlayerPanel(mage.client.table.TablePlayerPanel) MatchOptions(mage.game.match.MatchOptions) IOException(java.io.IOException)

Example 13 with MatchOptions

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;
}
Also used : TablePlayerPanel(mage.client.table.TablePlayerPanel) MatchOptions(mage.game.match.MatchOptions) GameTypeView(mage.view.GameTypeView)

Aggregations

MatchOptions (mage.game.match.MatchOptions)13 Test (org.junit.Test)4 DeckCardLists (mage.cards.decks.DeckCardLists)3 FreeformUnlimitedCommanderMatch (mage.game.FreeformUnlimitedCommanderMatch)3 Match (mage.game.match.Match)3 UUID (java.util.UUID)2 TablePlayerPanel (mage.client.table.TablePlayerPanel)2 PlayerType (mage.players.PlayerType)2 File (java.io.File)1 IOException (java.io.IOException)1 Date (java.util.Date)1 Entry (java.util.Map.Entry)1 Optional (java.util.Optional)1 ConcurrentHashMap (java.util.concurrent.ConcurrentHashMap)1 ConcurrentMap (java.util.concurrent.ConcurrentMap)1 MageException (mage.MageException)1 Deck (mage.cards.decks.Deck)1 TableState (mage.constants.TableState)1 TournamentPlayerState (mage.constants.TournamentPlayerState)1 GameException (mage.game.GameException)1