mirror of
https://github.com/magefree/mage.git
synced 2025-12-20 02:30:08 -08:00
GUI, table: added drafts with single multiplayer and multiple 1vs1 games support (#13701)
- new tourney's single game mode allow to play tourneys/drafts with all players in one game without multiple rounds; - it's allow to setup classic drafts with 1 vs 1 games and multiple rounds - added AI opponents supported including draft bots from a public servers;
This commit is contained in:
parent
a61851db09
commit
f2826cc676
22 changed files with 247 additions and 256 deletions
|
|
@ -208,9 +208,18 @@ public class TournamentController {
|
|||
}
|
||||
|
||||
private void endTournament() {
|
||||
for (TournamentPlayer player : tournament.getPlayers()) {
|
||||
player.setStateAtTournamentEnd();
|
||||
boolean setFinishPlayersStatus = true;
|
||||
if (tournament.getRounds().isEmpty() && tournament.getOptions().getMatchOptions().isSingleGameTourney()) {
|
||||
// single multiplayer game immediately finish the tourney, so keep dueling info all the time in tourney window
|
||||
setFinishPlayersStatus = false;
|
||||
}
|
||||
|
||||
if (setFinishPlayersStatus) {
|
||||
for (TournamentPlayer player : tournament.getPlayers()) {
|
||||
player.setStateAtTournamentEnd();
|
||||
}
|
||||
}
|
||||
|
||||
for (final TournamentSession tournamentSession : tournamentSessions.values()) {
|
||||
tournamentSession.tournamentOver();
|
||||
}
|
||||
|
|
@ -270,9 +279,14 @@ public class TournamentController {
|
|||
table.setTournamentSubTable(this.tableId);
|
||||
table.setTournament(tournament);
|
||||
table.setState(TableState.WAITING);
|
||||
if (round.getAllPlayers().stream().allMatch(tournamentPlayer -> getPlayerUserId(tournamentPlayer.getPlayer().getId()).isPresent())) {
|
||||
if (round.getAllPlayers().stream()
|
||||
.filter(t -> t.getPlayerType().equals(PlayerType.HUMAN))
|
||||
.allMatch(t -> getPlayerUserId(t.getPlayer().getId()).isPresent())
|
||||
) {
|
||||
for (TournamentPlayer player : round.getAllPlayers()) {
|
||||
tableManager.addPlayer(getPlayerUserId(player.getPlayer().getId()).get(), table.getId(), player);
|
||||
// userId = null - it's AI opponent
|
||||
UUID userId = getPlayerUserId(player.getPlayer().getId()).orElse(null);
|
||||
tableManager.addPlayer(userId, table.getId(), player);
|
||||
}
|
||||
table.setState(TableState.STARTING);
|
||||
tableManager.startTournamentSubMatch(null, table.getId());
|
||||
|
|
@ -284,9 +298,11 @@ public class TournamentController {
|
|||
player.setState(TournamentPlayerState.DUELING);
|
||||
}
|
||||
});
|
||||
} else {
|
||||
logger.error("tourney - startMultiplayerMatch can't start due disconnected players");
|
||||
}
|
||||
} catch (GameException ex) {
|
||||
logger.fatal("TournamentController startMatch error", ex);
|
||||
logger.fatal("tourney - startMultiplayerMatch error", ex);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue