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 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 played = new ArrayList<>(games); played.add(finished); return new Series(id, played); } }