2026-10-16 11:09:16 +03:00
|
|
|
package app.playmancala.model;
|
|
|
|
|
|
2026-10-17 02:03:16 +03:00
|
|
|
import com.fasterxml.jackson.annotation.JsonIgnore;
|
2026-10-16 11:09:16 +03:00
|
|
|
import com.fasterxml.jackson.annotation.JsonInclude;
|
|
|
|
|
import com.fasterxml.jackson.annotation.JsonPropertyOrder;
|
|
|
|
|
|
|
|
|
|
// on_game_end, sent to the players and spectators of a live game when it ends for any reason. `result` is null (and
|
2026-10-17 02:03:16 +03:00
|
|
|
// sent as null) when the game ended without a winner. `series` includes the game that ended; `rematch` is "available"
|
|
|
|
|
// when the players can ask for a rematch, i.e. unless a player left.
|
|
|
|
|
@JsonPropertyOrder({ "gameId", "result", "endReason", "clock", "winnerId", "leftUserId", "series", "rematch" })
|
2026-10-16 11:09:16 +03:00
|
|
|
public record GameEndMessage(
|
|
|
|
|
String gameId,
|
|
|
|
|
GameResult result,
|
|
|
|
|
EndReason endReason,
|
|
|
|
|
GameClock clock,
|
|
|
|
|
@JsonInclude(JsonInclude.Include.NON_NULL) String winnerId,
|
2026-10-17 02:00:44 +03:00
|
|
|
@JsonInclude(JsonInclude.Include.NON_NULL) String leftUserId,
|
2026-10-17 02:03:16 +03:00
|
|
|
@JsonInclude(JsonInclude.Include.NON_NULL) Series series,
|
|
|
|
|
@JsonInclude(JsonInclude.Include.NON_NULL) String rematch) {
|
|
|
|
|
public static final String REMATCH_AVAILABLE = "available";
|
|
|
|
|
|
|
|
|
|
@JsonIgnore
|
|
|
|
|
public boolean isRematchAvailable() {
|
|
|
|
|
return REMATCH_AVAILABLE.equals(rematch);
|
|
|
|
|
}
|
2026-10-16 11:09:16 +03:00
|
|
|
}
|