[US-03] Track ship damage, announce sunk, and end the game
Description
This merge request implements the third user story for the Battleship game: tracking ship damage, announcing when ships are sunk, and ending the game when a fleet is destroyed.
Requirements Implemented
- Track hits per ship - Implemented damage tracking for each ship
- Announce ship as 'sunk' - Added logic to detect when all squares of a ship are hit
- End game when fleet destroyed - Added victory detection and game end logic
- Provide New Game functionality - Implemented game reset capability
Acceptance Criteria Verified
-
✅ Given the last undamaged square of a ship is hit, when the result is processed, then that ship is announced 'sunk'. -
✅ Given the final enemy ship is sunk, when the board updates, then the match ends, the winner is indicated, and no further shots are allowed. -
✅ Given a finished match, when New Game is chosen, then both boards reset to covered, unplaced state.
Technical Implementation
- Added
Shipentity with damage tracking and sunk status - Enhanced
Gameclass with victory detection logic - Implemented game state management for end-game scenarios
- Added comprehensive test coverage for all acceptance criteria
Testing
All acceptance criteria are covered by unit tests in Issue3AcceptanceCriteriaTest.java:
- Test for ship sinking detection
- Test for game end condition
- Test for new game functionality
Closes #3