mancala/apps/backend/src/main/java/app/playmancala/model/Series.java
Halit Aksoy ee9e5261eb feat(backend): keep the series a live game belongs to
Every game starts a series; a game created in a series gets its seat to
move first. Clients get the series and the first seat with the game, the
end message the series with the ended game; snapshots keep the series.
2026-10-17 02:00:44 +03:00

25 lines
744 B
Java

package app.playmancala.model;
import java.util.ArrayList;
import java.util.List;
import java.util.UUID;
// The series a live game belongs to: its id and the games played before this one, oldest first. A game that is not a
// rematch starts a series of its own (docs/specs/rematch).
public record Series(String id, List<SeriesGame> games) {
public Series {
games = List.copyOf(games);
}
public static Series start() {
return new Series(UUID.randomUUID().toString(), List.of());
}
// The same series with `finished` played.
public Series next(SeriesGame finished) {
List<SeriesGame> played = new ArrayList<>(games);
played.add(finished);
return new Series(id, played);
}
}