Feat: Add STATUS param to GET_LOBBY_STATUS and client parsing #276

Merged
jona.walpert merged 1 commits from feat/lobby-status into main 2026-04-12 13:55:58 +02:00
2 changed files with 26 additions and 1 deletions
@@ -32,7 +32,25 @@ public class LobbyClient {
* @return A string representing the current status of the lobby, as returned by the server. * @return A string representing the current status of the lobby, as returned by the server.
*/ */
public String fetchLobbyStatusString(int lobbyId) { public String fetchLobbyStatusString(int lobbyId) {
return client.processCommand("GET_LOBBY_STATUS ID=" + lobbyId).getFirst(); List<String> lines = client.processCommand("GET_LOBBY_STATUS ID=" + lobbyId);
// Prefer an explicit STATUS parameter if provided by the server
List<RequestParameter> params = ClientService.convertToRequestParameters(lines);
for (RequestParameter p : params) {
if ("STATUS".equalsIgnoreCase(p.key())) {
return p.value();
}
}
// Fallback: look for plain status tokens in the body
for (String l : lines) {
String t = l.trim();
if ("CREATED".equalsIgnoreCase(t) || "RUNNING".equalsIgnoreCase(t)) {
return t;
}
}
return null;
} }
/** /**
@@ -26,6 +26,13 @@ public class GetLobbyStatusResponse extends SuccessResponse {
"LOBBY", "LOBBY",
lb -> { lb -> {
lb.param("ID", lobby.getId().value()); lb.param("ID", lobby.getId().value());
// STATUS indicates whether a game has been started in this
// lobby
lb.param(
"STATUS",
lobby.getGameController() == null
? "CREATED"
: "RUNNING");
lb.param("NAME", lobby.getName()); lb.param("NAME", lobby.getName());
lb.block( lb.block(
"PLAYERS", "PLAYERS",