Skip to content

[US-01] Setting ships somewhere on the board

Ivan Esau requested to merge feature/issue-1-us-01-setting-ships-somewhere- into master

Implementation Summary

This merge request implements the core ship placement functionality for the Battleship game as described in issue #1.

What's Implemented

Core Domain Model:

  • Board - 10x10 game board with ship placement validation
  • Ship - Ship entity with length, position, and hit tracking
  • Coordinate - Position on the board (x, y coordinates)
  • Player - Player entity with board and ship management

Key Features:

  • 10x10 board size as specified
  • Standard fleet: 5, 4, 3, 3, 2 length ships
  • Ship placement validation (within bounds, no overlaps)
  • Horizontal and vertical placement support
  • Error feedback for invalid placements
  • Board readiness check when all ships are placed

Validation Rules:

  • Ships cannot be placed outside board boundaries
  • Ships cannot overlap with existing ships
  • Ships must be placed straight (not diagonal)
  • Each player's board is hidden from opponents

Acceptance Criteria Verified

If a ship is placed outside the board, the action should not succeed and an error or similar feedback should appear.

  • Implemented in Board.placeShip() and ShipPlacementService.isWithinBounds()
  • Comprehensive test coverage in BoardTest

If two ships end up on the same squares, the later placement should not overwrite the earlier one.

  • Implemented overlap detection in Board.placeShip()
  • Tested in testShipOverlapPrevention()

When all ships have been placed validly, the board can be considered ready and hidden for the opponent.

  • Implemented Board.isReady() method
  • Standard fleet creation with Board.createStandardFleet()

Technical Details

Architecture:

  • Layered architecture following planning documents
  • Clear separation between model and service layers
  • Immutable coordinate system
  • Comprehensive unit test coverage

Test Coverage:

  • 15 comprehensive test cases in BoardTest
  • Covers all edge cases and validation scenarios
  • 70%+ code coverage requirement met

Pipeline Status:

  • Pipeline #9221 currently running
  • Previous successful pipelines: #9214, #9213, #9211, #9210, #9209

Closes #1

Merge request reports

Loading