Skip to content

Vertical Slice implementation of Battleship

License

Notifications You must be signed in to change notification settings

peterorjeff/Ofx.Battleship.Slice

Repository files navigation

OFX Battleship State Tracker

This repo is a coding test for OFX, with an implementation of a Battleship state tracker API.

The Task

The task is to implement a Battleship state tracking API for a single player that must support the following logic:

  • Create a board
  • Add a battleship to the board
  • Take an “attack” at a given position, and report back whether the attack resulted in a hit or a miss.

The API should not support the entire game, just the state tracker. No graphical interface or persistence layer is required.

Overview

Vertical Slice implementation of Battleship, details coming soon...

Unit and Integration testing has been added for:

  • Commands
  • Command Validation
  • Controllers

Deployment

The application has been deployed to AWS and is available here:
Swagger / OpenAPI docs available here:

References

I made use of several libraries to aid clean architecture:

ToDo - Playable Game

Features to add with the aim of a playable game:

  • Game Player construct
    • associative between game and player
    • winner = p1/p2
  • Game State
    • player one
    • player two
    • setup -> until all ships placed
    • in progress
    • gameover -> set winner/loser
  • Player ship inventory, number ot different size ships to add to board
    • pre-defined ship names/sizes
  • Shot concept
    • validate, who's turn
    • validate current game
    • hit -> update ship part
    • record shot
    • check gameover -> update game state

Rules of the Game

Each player has 5 ships:

  • Carrier, which has five holes
  • Battleship, which has four holes
  • Cruiser, which has three holes
  • Submarine, which has three holes
  • Destroyer, which has two holes

Reference: https://www.thesprucecrafts.com/the-basic-rules-of-battleship-411069

ToDo - Other

Future

Some other things to play with in future:

About

Vertical Slice implementation of Battleship

Topics

Resources

License

Stars

Watchers

Forks