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);
}
}
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();
}
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++;
}
}
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);
}
}
}
Aggregations