RematchOffers keeps an offer open for ten minutes after a game nobody left. A request goes to the opponent; when both have asked the next game of the series starts with the other player moving first. Requests end on no, withdrawal, a minute without answer, going offline or looking for another game. The bot accepts at once.
27 lines
1.2 KiB
Java
27 lines
1.2 KiB
Java
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);
|
|
}
|
|
}
|