Search in sources :

Example 1 with PlayerType

use of mage.players.PlayerType in project mage by magefree.

the class GameChooser method createTestGame.

// GEN-LAST:event_btnNewTournamentActionPerformed
private void createTestGame(String gameName, String gameType, boolean useMonteCarloAI) {
    TableView table;
    try {
        String testDeckFile = "test.dck";
        File f = new File(testDeckFile);
        if (!f.exists()) {
            // default test deck
            testDeckFile = DeckUtil.writeTextToTempFile("" + "5 Swamp" + System.lineSeparator() + "5 Forest" + System.lineSeparator() + "5 Island" + System.lineSeparator() + "5 Mountain" + System.lineSeparator() + "5 Plains");
        }
        DeckCardLists testDeck = DeckImporter.importDeckFromFile(testDeckFile, false);
        PlayerType aiType = useMonteCarloAI ? PlayerType.COMPUTER_MONTE_CARLO : PlayerType.COMPUTER_MAD;
        MatchOptions options = new MatchOptions(gameName, gameType, false, 2);
        options.getPlayerTypes().add(PlayerType.HUMAN);
        options.getPlayerTypes().add(aiType);
        options.setDeckType("Limited");
        options.setAttackOption(MultiplayerAttackOption.LEFT);
        options.setRange(RangeOfInfluence.ALL);
        options.setWinsNeeded(1);
        options.setMatchTimeLimit(MatchTimeLimit.NONE);
        options.setFreeMulligans(2);
        options.setSkillLevel(SkillLevel.CASUAL);
        options.setRollbackTurnsAllowed(true);
        options.setQuitRatio(100);
        options.setMinimumRating(0);
        String serverAddress = SessionHandler.getSession().getServerHostname().orElse("");
        options.setBannedUsers(IgnoreList.getIgnoredUsers(serverAddress));
        table = SessionHandler.createTable(roomId, options);
        SessionHandler.joinTable(roomId, table.getTableId(), "Human", PlayerType.HUMAN, 1, testDeck, "");
        SessionHandler.joinTable(roomId, table.getTableId(), "Computer", aiType, 5, testDeck, "");
        SessionHandler.startMatch(roomId, table.getTableId());
    } catch (HeadlessException ex) {
        handleError(ex);
    }
}
Also used : DeckCardLists(mage.cards.decks.DeckCardLists) PlayerType(mage.players.PlayerType) MatchOptions(mage.game.match.MatchOptions) File(java.io.File) TableView(mage.view.TableView)

Example 2 with PlayerType

use of mage.players.PlayerType in project mage by magefree.

the class NewTableDialog method createPlayers.

private void createPlayers(int numPlayers) {
    // add missing player panels
    if (numPlayers > players.size()) {
        while (players.size() != numPlayers) {
            TablePlayerPanel playerPanel = new TablePlayerPanel();
            PlayerType playerType = PlayerType.HUMAN;
            if (prefPlayerTypes.size() >= players.size() && !players.isEmpty()) {
                playerType = prefPlayerTypes.get(players.size() - 1);
            }
            playerPanel.init(players.size() + 2, playerType);
            players.add(playerPanel);
            playerPanel.addPlayerTypeEventListener((Listener<Event>) event -> drawPlayers());
        }
    } else // remove player panels no longer needed
    if (numPlayers < players.size()) {
        while (players.size() != numPlayers) {
            players.remove(players.size() - 1);
        }
    }
    drawPlayers();
}
Also used : MageComponents(mage.client.components.MageComponents) SkillLevel(mage.constants.SkillLevel) MageFrame(mage.client.MageFrame) TableView(mage.view.TableView) TablePlayerPanel(mage.client.table.TablePlayerPanel) RangeOfInfluence(mage.constants.RangeOfInfluence) DeckImporter(mage.cards.decks.importer.DeckImporter) MultiplayerAttackOption(mage.constants.MultiplayerAttackOption) IOException(java.io.IOException) UUID(java.util.UUID) PlayerType(mage.players.PlayerType) FileNotFoundException(java.io.FileNotFoundException) ArrayList(java.util.ArrayList) Logger(org.apache.log4j.Logger) List(java.util.List) Event(mage.client.util.Event) IgnoreList(mage.client.util.IgnoreList) Listener(mage.client.util.Listener) MatchOptions(mage.game.match.MatchOptions) MulliganType(mage.game.mulligan.MulliganType) GameTypeView(mage.view.GameTypeView) SessionHandler(mage.client.SessionHandler) MatchTimeLimit(mage.constants.MatchTimeLimit) javax.swing(javax.swing) TablePlayerPanel(mage.client.table.TablePlayerPanel) PlayerType(mage.players.PlayerType) Event(mage.client.util.Event)

Example 3 with PlayerType

use of mage.players.PlayerType in project mage by magefree.

the class Table method createSeats.

private void createSeats(List<PlayerType> playerTypes) {
    int i = 0;
    seats = new Seat[numSeats];
    for (PlayerType playerType : playerTypes) {
        seats[i] = new Seat(playerType);
        i++;
    }
}
Also used : PlayerType(mage.players.PlayerType)

Example 4 with PlayerType

use of mage.players.PlayerType in project mage by magefree.

the class TableController method swapSeats.

public void swapSeats(int seatNum1, int seatNum2) {
    if (table.getState() == TableState.READY_TO_START) {
        if (seatNum1 >= 0 && seatNum2 >= 0 && seatNum1 < table.getSeats().length && seatNum2 < table.getSeats().length) {
            Player swapPlayer = table.getSeats()[seatNum1].getPlayer();
            PlayerType swapType = table.getSeats()[seatNum1].getPlayerType();
            table.getSeats()[seatNum1].setPlayer(table.getSeats()[seatNum2].getPlayer());
            table.getSeats()[seatNum1].setPlayerType(table.getSeats()[seatNum2].getPlayerType());
            table.getSeats()[seatNum2].setPlayer(swapPlayer);
            table.getSeats()[seatNum2].setPlayerType(swapType);
        }
    }
}
Also used : MatchPlayer(mage.game.match.MatchPlayer) Player(mage.players.Player) DraftPlayer(mage.game.draft.DraftPlayer) TournamentPlayer(mage.game.tournament.TournamentPlayer) PlayerType(mage.players.PlayerType)

Aggregations

PlayerType (mage.players.PlayerType)4 MatchOptions (mage.game.match.MatchOptions)2 TableView (mage.view.TableView)2 File (java.io.File)1 FileNotFoundException (java.io.FileNotFoundException)1 IOException (java.io.IOException)1 ArrayList (java.util.ArrayList)1 List (java.util.List)1 UUID (java.util.UUID)1 javax.swing (javax.swing)1 DeckCardLists (mage.cards.decks.DeckCardLists)1 DeckImporter (mage.cards.decks.importer.DeckImporter)1 MageFrame (mage.client.MageFrame)1 SessionHandler (mage.client.SessionHandler)1 MageComponents (mage.client.components.MageComponents)1 TablePlayerPanel (mage.client.table.TablePlayerPanel)1 Event (mage.client.util.Event)1 IgnoreList (mage.client.util.IgnoreList)1 Listener (mage.client.util.Listener)1 MatchTimeLimit (mage.constants.MatchTimeLimit)1