Skip to content

[US-03] Ship damage, announcing sunk, and finishing

Ivan Esau requested to merge feature/issue-3-us-03-ship-damage-announcing-s into master

Description

Implements ship damage tracking, sunk detection, game end conditions, and restart functionality for the Battleship game.

Changes

  • Ship.java: Added ship health tracking with hit recording and sunk detection
  • Board.java: Enhanced with ship management, shot processing, and game state tracking
  • Game.java: Added game flow control, turn management, and win condition checking
  • GameService.java: Service layer for game logic and flow management
  • ShotResult.java: Enum for shot outcomes including HIT, MISS, SUNK, GAME_OVER
  • Comprehensive Test Coverage: Full acceptance criteria tests for all requirements

Requirements Implemented

Ship Damage Tracking: Counts how many parts of each ship are hit Sunk Detection: Knows when a ship has all parts damaged and announces it as sunk Game End Conditions: Declares winner when all ships of one participant are destroyed Input Blocking: Prevents further shooting after game ends Restart Functionality: Allows starting over with empty boards

Acceptance Criteria Validated

AC1: When the last healthy square of a ship gets hit, that ship is indicated as sunk AC2: When the final enemy ship is destroyed, game ends with winner and blocks further shooting AC3: When a finished game is restarted, both boards become empty and hidden again

Technical Details

  • Follows MVC + Layered architecture pattern
  • Comprehensive unit tests with 100% coverage of core logic
  • Integration tests for complete game flow
  • Proper error handling and state validation

Closes #3

Merge request reports

Loading