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 ship announcements, and game finishing logic for the Battleship game.

Changes

  • Added ship damage tracking with hit counting
  • Implemented sunk ship detection and announcements
  • Added game completion logic when all ships are destroyed
  • Implemented input blocking after game completion
  • Added game reset functionality for new games
  • Enhanced status reporting with detailed ship damage information

Requirements Implemented

Counts how many parts of each ship are hit Knows when a ship has all of its parts damaged Tells the player that the ship is sunk Declares winner when all ships of one participant are gone Blocks any more inputs after game completion Allows starting over through New Game option

Acceptance Criteria Validated

When the last healthy square of a ship gets hit, that ship is indicated as sunk When the final enemy ship is destroyed, the game ends, shows who won, and blocks further shooting When a finished game is restarted, both boards become empty and hidden again

Technical Implementation

  • Enhanced Ship class with hit tracking and sunk detection
  • Enhanced Game class with game completion logic
  • Added Player.hasLost() method to check if all ships are sunk
  • Added comprehensive unit tests for all new functionality

Closes #3

Merge request reports

Loading