Skip to content

[US-02] Alternating shooting with feedback

Ivan Esau requested to merge feature/issue-2-us-02-alternating-shooting-wit into master

Description

Implements alternating shooting functionality for Battleship game with turn management, hit/miss feedback, and duplicate shot prevention.

Changes

  • Core Models: Added ShotResult enum, ShotTracker, GameState for turn management
  • Game Logic: Implemented shooting functionality in GameService with turn switching
  • UI Integration: Updated Main.java with shooting phase and turn-based gameplay
  • Testing: Comprehensive test suite covering all acceptance criteria

Acceptance Criteria Verified

When firing at A1 for the first time, a message should appear showing hit or miss, and that field should become marked.

  • Tested in GameServiceShootingTest.testPlayerShootingHit() and testPlayerShootingMiss()

When the same field is targeted again, the shot should not go through, and the next player should then act.

  • Tested in GameServiceShootingTest.testPlayerShootingAlreadyShot()

After one shot cycle finishes, the control changes so that only the other player can continue.

  • Tested in GameServiceShootingTest.testAlternatingTurns()

Technical Implementation

  • Turn-based shooting system with proper state management
  • Shot validation and duplicate prevention
  • Hit/miss detection with ship damage tracking
  • Game end detection when all ships are sunk
  • Comprehensive test coverage with 25+ test methods

Dependencies

  • Builds upon ship placement functionality from Issue #1 (closed)
  • Follows layered architecture pattern from planning documents

Closes #2

Merge request reports

Loading