[US-02] Alternating shooting with feedback
Implementation Summary
This merge request implements the alternating shooting system for the Battleship game as described in Issue #2.
Features Implemented:
Core Game Logic:
- Turn-based shooting system with automatic alternation
- Hit/miss detection with proper feedback messages
- Duplicate shot prevention (cannot shoot same coordinate twice)
- Game over detection when all ships are sunk
User Interface:
- Console-based game interface with board display
- Real-time feedback for shots (HIT/MISS messages)
- Turn indication and game state display
Technical Implementation:
- Complete MVC architecture with model, service, and view layers
- Comprehensive test coverage for all acceptance criteria
- Proper error handling for invalid coordinates
- Game state management with player switching
Acceptance Criteria Verified:
- Implemented in
Game.shoot()method with proper hit detection - Verified by
Issue2AcceptanceCriteriaTest.testFirstShotAtA1_ShowsHitMissAndMarksField()
- Implemented duplicate shot prevention in
Game.shoot() - Verified by
Issue2AcceptanceCriteriaTest.testDuplicateShotAtSameField_ShouldNotGoThrough()
- Implemented automatic turn switching in
Game.shoot() - Verified by
Issue2AcceptanceCriteriaTest.testControlChangesToOtherPlayer_AfterShotCycle()
Test Coverage:
- All acceptance criteria covered by dedicated test class
- Unit tests for individual components (Board, Game, Player, Ship)
- Integration tests for game flow
- Pipeline verification:
✅ Success (Pipeline #7357)
Files Modified/Created:
Model Layer:
-
Game.java- Core game logic with turn management -
Player.java- Player state and board management -
Board.java- Board state and shot tracking -
Ship.java- Ship placement and health tracking -
Coordinate.java- Coordinate validation and conversion
Service Layer:
-
GameService.java- Game flow and user interaction
View Layer:
-
ConsoleView.java- CLI interface for game display
Test Coverage:
-
Issue2AcceptanceCriteriaTest.java- All acceptance criteria -
GameTest.java- Game logic unit tests -
BoardTest.java- Board functionality tests -
CoordinateTest.java- Coordinate validation tests
Closes #2