Skip to content

[US-05] Save, load, and resume a match

As a player I want to save the current match and later load it to resume exactly where I left off So that I can pause and continue the game without losing progress.

The system shall:

  1. Persist the complete match state to a single file chosen by the user, including: board size, both fleets’ concealed layouts, all shots and results, sunk statuses, whose turn it is, difficulty/mode, and the elapsed timer value. Hidden information shall remain hidden to the opponent after load.
  2. Load a previously saved match file and restore the game to the exact same externally observable state (boards, indicators, whose turn, timer, difficulty/mode).
  3. Validate the file and version; on missing/invalid/corrupted/incompatible files the system shall report an error and shall not modify the current in-memory game.
  4. Ensure idempotent round-trip: a save immediately followed by a load shall not change any part of the match state observable to the player.
  5. Allow the user to choose the location and filename when saving or loading.

Acceptance criteria (verifiable):

  • Given a mid-game state S (defined test fixture), when the user saves and immediately loads that file, then the restored game equals S in: shot history & results, visible cell states on both grids, sunk indicators, whose turn, difficulty/mode, and timer value.
  • Given a deliberately corrupted or incompatible file, when the user attempts to load it, then an error is shown and the current game remains unchanged.
  • Given a finished game (win or loss), when it is saved and later loaded, then the game remains finished with the same outcome and inputs are disabled until a new game is started.