mirror of
https://github.com/2OOP/pism.git
synced 2026-02-04 19:04:49 +00:00
Tournament is now without admins
This commit is contained in:
@@ -120,19 +120,32 @@ public class NetworkingGameClientHandler extends ChannelInboundHandlerAdapter {
|
||||
IO.println(rec);
|
||||
|
||||
String gameTypeRaw = extract(rec, "GAMETYPE");
|
||||
String usersRaw = extract(rec, "USERS");
|
||||
String scoresRaw = extract(rec, "SCORES");
|
||||
String usersRaw = extract(rec, "USERS");
|
||||
String scoresRaw = extract(rec, "SCORES");
|
||||
|
||||
String[] users = Arrays.stream(usersRaw.substring(1, usersRaw.length() - 1).split(","))
|
||||
if (usersRaw == null) return;
|
||||
|
||||
String[] users;
|
||||
if (usersRaw.length() > 2) {
|
||||
users = Arrays.stream(usersRaw.substring(1, usersRaw.length() - 1).split(","))
|
||||
.map(s -> s.trim().replace("\"", ""))
|
||||
.toArray(String[]::new);
|
||||
} else {
|
||||
users = new String[]{};
|
||||
}
|
||||
|
||||
Integer[] scores = Arrays.stream(scoresRaw.substring(1, scoresRaw.length() - 1).split(","))
|
||||
.map(String::trim)
|
||||
.map(Integer::parseInt)
|
||||
.toArray(Integer[]::new);
|
||||
if (scoresRaw == null) return;
|
||||
if (scoresRaw.length() > 2) {
|
||||
Integer[] scores = Arrays.stream(scoresRaw.substring(1, scoresRaw.length() - 1).split(","))
|
||||
.map(String::trim)
|
||||
.map(Integer::parseInt)
|
||||
.toArray(Integer[]::new);
|
||||
|
||||
eventBus.post(new NetworkEvents.TournamentResultResponse(this.connectionId, gameTypeRaw, users, scores));
|
||||
} else {
|
||||
eventBus.post(new NetworkEvents.TournamentResultResponse(this.connectionId, gameTypeRaw, users, new Integer[]{}));
|
||||
}
|
||||
|
||||
eventBus.post(new NetworkEvents.TournamentResultResponse(this.connectionId, gameTypeRaw, users, scores));
|
||||
}
|
||||
|
||||
private void gameMoveHandler(String rec) {
|
||||
|
||||
@@ -279,11 +279,14 @@ public class Server implements GameServer<TurnBasedGame, NettyClient, Long> {
|
||||
return;
|
||||
}
|
||||
|
||||
var tournamentUsers = new ArrayList<>(onlineUsers());
|
||||
tournamentUsers.removeIf(admins::contains);
|
||||
|
||||
Tournament tournament = new BasicTournament(new TournamentBuilder(
|
||||
this,
|
||||
new BasicTournamentRunner(),
|
||||
new RoundRobinMatchMaker(onlineUsers()),
|
||||
new BasicScoreSystem(onlineUsers())
|
||||
new RoundRobinMatchMaker(tournamentUsers),
|
||||
new BasicScoreSystem(tournamentUsers)
|
||||
));
|
||||
|
||||
try {
|
||||
|
||||
Reference in New Issue
Block a user