A teammate’s pull request adds rematch (start the game again with the same players, from move 0) and watch (a spectator follows an open room). QA reports that after a rematch, the player who asked for it and the other player no longer see each other’s moves, and that rooms stay open after everyone has left as long as someone is watching. You are reviewing the pull request.
A rematch silently splits a game between two rooms. Spectators keep rooms open forever, use up the server’s capacity, and can open rooms for codes nobody is playing.
Reproduce
alice and bob join chess ABCD and play three moves; bob asks for a rematch. Both should then be in room #1 at moves=0, and a move by alice should show on bob’s side. Today bob gets a new room #2 and alice still sees 3.
Acceptance criteria
- After a rematch, every player who held the room still holds it, at move 0, and their moves reach each other; the room keeps its players, so it closes only after each of them leaves.
- A rematch works on a full server, and a rematch of a room that is not open is rejected.
- watch returns an open room as it is now, without counting the spectator as a player, using capacity or opening a room; watching a room that is not open, or with a bad request, is rejected.
- Everything MULTITON-101 and MULTITON-102 asked still holds.
Notes
- Cases print each join, rematch (rematch → game/CODE #number moves=n) and watch (watches → …), each leave, what a player sees, whether two players share a room, and how many rooms a server keeps open.
- Keep the names and signatures of rematch and watch, and of everything before them; each case makes its own servers.