Skip to content

[US-02] Take turns firing with hit/miss feedback

Ivan Esau requested to merge feature/issue-2-us-02-take-turns-firing-with-h into master

Implementation Summary

This merge request implements the turn-based firing system for the Battleship game as specified in issue #2.

Core Features Implemented:

Turn Management:

  • Alternating turns between players enforced
  • Current player tracking with automatic turn switching
  • Validation to ensure only current player can act

Shot System:

  • Target coordinate selection on opponent's grid
  • Hit/miss detection and immediate feedback
  • Prevention of firing at same coordinate twice
  • Shot result tracking with ship sinking detection

Game Logic:

  • Game state management (PLACEMENT, IN_PROGRESS, FINISHED)
  • Winner detection when all ships are sunk
  • Game over conditions and validation

Technical Implementation:

Model Layer:

  • Game class manages turn state and game flow
  • Board class handles shot tracking and ship placement
  • Player class represents individual players
  • GameService orchestrates turn-based gameplay

Service Layer:

  • GameService validates shots and processes results
  • Comprehensive error handling for invalid actions
  • Shot result tracking with hit/miss/ship sunk status

Test Coverage:

  • Unit tests for all core functionality
  • Acceptance criteria tests for issue requirements
  • Integration tests for game flow

Acceptance Criteria Validation:

AC1: Given A1 has not been targeted, when the player fires at A1, then the result is shown (hit/miss) and A1 becomes marked as used. AC2: Given A1 is already targeted, when the player attempts A1 again, then the system blocks the action and preserves turn order rules. AC3: Given a turn completes, when control passes, then only the next player can act.

Current Status:

  • Pipeline Status: FAILED - Test failures need resolution
  • Implementation: Complete - Core functionality implemented
  • Tests: Failing - Issues with ship placement validation

Note: Pipeline is currently failing due to test issues that need to be resolved before merge.

Closes #2

Merge request reports

Loading