mancala/apps/backend/src/main/java/app/playmancala/model/GameEndMessage.java

27 lines
1.2 KiB
Java
Raw Normal View History

package app.playmancala.model;
import com.fasterxml.jackson.annotation.JsonIgnore;
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
// 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" })
public record GameEndMessage(
String gameId,
GameResult result,
EndReason endReason,
GameClock clock,
@JsonInclude(JsonInclude.Include.NON_NULL) String winnerId,
@JsonInclude(JsonInclude.Include.NON_NULL) String leftUserId,
@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);
}
}