public MultiplayerRound createMultiplayerRound() { List<TournamentPlayer> roundPlayers = getActivePlayers(); boolean isLastRound = (rounds.size() + 1 == getNumberRounds()); MultiplayerRound round = null; if (options.matchOptions.getNumSeats() > 2) { options.matchOptions.setAttackOption(MultiplayerAttackOption.MULTIPLE); RoundPairings roundPairings; if (roundPlayers.size() <= 16) { SwissPairingMinimalWeightMatching swissPairing = new SwissPairingMinimalWeightMatching(roundPlayers, rounds, isLastRound); roundPairings = swissPairing.getRoundPairings(); } else { SwissPairingSimple swissPairing = new SwissPairingSimple(roundPlayers, rounds); roundPairings = swissPairing.getRoundPairings(); } round = new MultiplayerRound(rounds.size() + 1, this, options.matchOptions.getNumSeats()); for (TournamentPairing pairing : roundPairings.getPairings()) { round.addPairing(pairing); } } return round; } }
@Override protected void runTournament() { for (Map.Entry<UUID, TournamentPlayer> entry: players.entrySet()) { if (entry.getValue().getPlayer().autoLoseGame()) { entry.getValue().setEliminated(); entry.getValue().setResults("Auto Eliminated"); } } if (options.matchOptions.getNumSeats() == 2) { while (this.getActivePlayers().size() > 1) { // check if some player got killed / disconnected meanwhile and update their state tableEventSource.fireTableEvent(TableEvent.EventType.CHECK_STATE_PLAYERS); Round round = createRoundRandom(); playRound(round); eliminatePlayers(round); } } else { options.matchOptions.setAttackOption(MultiplayerAttackOption.MULTIPLE); MultiplayerRound round = new MultiplayerRound(0, this, options.matchOptions.getNumSeats()); for (TournamentPlayer player : getActivePlayers()) { round.addPlayer(player); } playMultiplayerRound(round); } nextStep(); }
private void startMultiplayerMatch(MultiplayerRound round, MatchOptions matchOptions) { try { TableManager tableManager = TableManager.instance; Table table = tableManager.createTable(GamesRoomManager.instance.getMainRoomId(), matchOptions); table.setTournamentSubTable(true); table.setTournament(tournament); table.setState(TableState.WAITING); if (round.getAllPlayers().stream().allMatch(tournamentPlayer -> getPlayerUserId(tournamentPlayer.getPlayer().getId()).isPresent())) { for (TournamentPlayer player : round.getAllPlayers()) { tableManager.addPlayer(getPlayerUserId(player.getPlayer().getId()).get(), table.getId(), player); } table.setState(TableState.STARTING); tableManager.startTournamentSubMatch(null, table.getId()); tableManager.getMatch(table.getId()).ifPresent(match -> { match.setTableId(tableId); round.setMatch(match); round.setTableId(table.getId()); for (TournamentPlayer player : round.getAllPlayers()) { player.setState(TournamentPlayerState.DUELING); } }); } } catch (GameException ex) { logger.fatal("TournamentController startMatch error", ex); } }
for (TournamentPlayer player : event.getMultiplayerRound().getAllPlayers()) { matchOptions.getPlayerTypes().add(player.getPlayerType());