Search in sources :

Example 6 with DraftOptions

use of mage.game.draft.DraftOptions in project mage by magefree.

the class NewTournamentDialog method btnOkActionPerformed.

// GEN-LAST:event_cbTournamentTypeActionPerformed
private void btnOkActionPerformed(java.awt.event.ActionEvent evt) {
    // GEN-FIRST:event_btnOkActionPerformed
    // get settings
    TournamentOptions tOptions = getTournamentOptions();
    // CHECKS
    TournamentTypeView tournamentType = (TournamentTypeView) cbTournamentType.getSelectedItem();
    if (tournamentType.isRandom() || tournamentType.isRichMan()) {
        if (tOptions.getLimitedOptions().getSetCodes().isEmpty()) {
            JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Warning, you must select packs for the pool", "Warning", JOptionPane.WARNING_MESSAGE);
            return;
        }
    }
    if (tournamentType.isDraft() && tOptions.getLimitedOptions() instanceof DraftOptions) {
        DraftOptions draftOptions = (DraftOptions) tOptions.getLimitedOptions();
        if (draftOptions.getTiming() == TimingOption.NONE) {
            JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Warning, you must select draft timing option", "Warning", JOptionPane.WARNING_MESSAGE);
            return;
        }
    }
    // save last settings
    onSaveSettings(0, tOptions);
    // run
    table = SessionHandler.createTournamentTable(roomId, tOptions);
    if (table == null) {
        // message must be send by server!
        return;
    }
    // join AI
    for (TournamentPlayerPanel player : players) {
        if (player.getPlayerType().getSelectedItem() != PlayerType.HUMAN) {
            if (!player.joinTournamentTable(roomId, table.getTableId(), DeckImporter.importDeckFromFile(this.player1Panel.getDeckFile(), true))) {
                // error message must be send by sever
                SessionHandler.removeTable(roomId, table.getTableId());
                table = null;
                return;
            }
        }
    }
    // join itself
    if (SessionHandler.joinTournamentTable(roomId, table.getTableId(), this.player1Panel.getPlayerName(), PlayerType.HUMAN, 1, DeckImporter.importDeckFromFile(this.player1Panel.getDeckFile(), true), tOptions.getPassword())) {
        // all fine, can close create dialog (join dialog will be opened after feedback from server)
        this.hideDialog();
        return;
    }
    JOptionPane.showMessageDialog(MageFrame.getDesktop(), "Error joining tournament.", "Error", JOptionPane.ERROR_MESSAGE);
    SessionHandler.removeTable(roomId, table.getTableId());
    table = null;
}
Also used : TournamentPlayerPanel(mage.client.table.TournamentPlayerPanel) TournamentOptions(mage.game.tournament.TournamentOptions) TournamentTypeView(mage.view.TournamentTypeView) DraftOptions(mage.game.draft.DraftOptions)

Example 7 with DraftOptions

use of mage.game.draft.DraftOptions in project mage by magefree.

the class BoosterDraftSwissTournament method draft.

protected void draft() {
    draft = new BoosterDraft((DraftOptions) options.getLimitedOptions(), getSets());
    for (TournamentPlayer player : players.values()) {
        draft.addPlayer(player.getPlayer());
        player.setState(TournamentPlayerState.DRAFTING);
    }
    tableEventSource.fireTableEvent(TableEvent.EventType.START_DRAFT, null, draft);
}
Also used : BoosterDraft(mage.game.draft.BoosterDraft) TournamentPlayer(mage.game.tournament.TournamentPlayer) DraftOptions(mage.game.draft.DraftOptions)

Example 8 with DraftOptions

use of mage.game.draft.DraftOptions in project mage by magefree.

the class RandomBoosterDraftEliminationTournament method draft.

@Override
protected void draft() {
    draft = new RandomBoosterDraft((DraftOptions) options.getLimitedOptions(), getSets());
    for (TournamentPlayer player : players.values()) {
        draft.addPlayer(player.getPlayer());
        player.setState(TournamentPlayerState.DRAFTING);
    }
    tableEventSource.fireTableEvent(EventType.START_DRAFT, null, draft);
}
Also used : RandomBoosterDraft(mage.game.draft.RandomBoosterDraft) TournamentPlayer(mage.game.tournament.TournamentPlayer) DraftOptions(mage.game.draft.DraftOptions)

Example 9 with DraftOptions

use of mage.game.draft.DraftOptions in project mage by magefree.

the class RichManCubeDraftEliminationTournament method draft.

protected void draft() {
    draft = new RichManCubeBoosterDraft((DraftOptions) options.getLimitedOptions(), getSets());
    for (TournamentPlayer player : players.values()) {
        draft.addPlayer(player.getPlayer());
        player.setState(TournamentPlayerState.DRAFTING);
    }
    tableEventSource.fireTableEvent(EventType.START_DRAFT, null, draft);
}
Also used : TournamentPlayer(mage.game.tournament.TournamentPlayer) DraftOptions(mage.game.draft.DraftOptions) RichManCubeBoosterDraft(mage.game.draft.RichManCubeBoosterDraft)

Aggregations

DraftOptions (mage.game.draft.DraftOptions)9 TournamentPlayer (mage.game.tournament.TournamentPlayer)6 TournamentPlayerPanel (mage.client.table.TournamentPlayerPanel)2 BoosterDraft (mage.game.draft.BoosterDraft)2 RandomBoosterDraft (mage.game.draft.RandomBoosterDraft)2 TournamentOptions (mage.game.tournament.TournamentOptions)2 TournamentTypeView (mage.view.TournamentTypeView)2 IOException (java.io.IOException)1 Deck (mage.cards.decks.Deck)1 ExpansionInfo (mage.cards.repository.ExpansionInfo)1 IgnoreList (mage.client.util.IgnoreList)1 GameException (mage.game.GameException)1 RichManBoosterDraft (mage.game.draft.RichManBoosterDraft)1 RichManCubeBoosterDraft (mage.game.draft.RichManCubeBoosterDraft)1 LimitedOptions (mage.game.tournament.LimitedOptions)1