Skip to content

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

Ivan Esau requested to merge feature/issue-5-us-05-save-load-and-resume-a-m into master

Implementation Summary

This merge request implements the save/load functionality for the Battleship game as specified in Issue #5.

Completed Features

Core Save/Load Functionality:

  • Complete match state persistence to file
  • File validation and error handling for corrupted/invalid files
  • Idempotent round-trip save/load operations
  • User-selected file locations and names

State Preservation:

  • Board size and both fleets' concealed layouts
  • All shots and results history
  • Ship sunk statuses
  • Current turn information
  • Difficulty/mode settings
  • Elapsed timer value
  • Hidden information remains hidden after load

🧪 Testing Status

Issue #5 Tests: ALL PASSING (27/27 tests)

  • SaveLoadServiceTest: 13 comprehensive test cases
  • Issue5AcceptanceCriteriaTest: 6 acceptance criteria tests
  • MatchTest serialization: 8 test cases

Pipeline Status: ⚠️ FAILED (due to Issue #3 test failures)

  • Compilation: SUCCESS
  • Issue #5 Tests: ALL PASSED (27/27)
  • Overall Pipeline: FAILED (14 failures from Issue #3)

📋 Acceptance Criteria Validation

Criterion 1: Mid-game state preservation - Save/load round-trip preserves exact state Criterion 2: Corrupted file handling - Errors shown, current game preserved Criterion 3: Finished game preservation - Game remains finished with same outcome

🔧 Technical Implementation

Files Modified:

  • src/main/java/org/example/battleship/service/SaveLoadService.java - Core save/load logic
  • src/main/java/org/example/battleship/model/Match.java - Serializable game state
  • src/main/java/org/example/battleship/view/GameView.java - UI integration

Files Created:

  • src/test/java/org/example/battleship/service/SaveLoadServiceTest.java - Service tests
  • src/test/java/org/example/battleship/Issue5AcceptanceCriteriaTest.java - Acceptance tests

⚠️ Important Note

While the pipeline shows overall failure, this is NOT due to Issue #5 implementation. The 14 failing tests are from Issue #3 (ship sinking detection and game over logic). Issue #5 implementation is complete and fully tested.

🚨 Merge Decision

BLOCKED - Cannot merge due to pipeline failures from Issue #3 tests. Issue #5 implementation is ready but dependent functionality from Issue #3 is not working correctly.

Closes #5

Merge request reports

Loading