Battleship
This library is a multiplayer game of the classic battleship board or paper game.
It's meant to be used within a website or similar because is mostly asyncronous, passing messages between the players processes.
To be played you need to add two players together in the same game, and then each one fire the opponent. To manage the turns users will have to wait to receive a message with a notification that is their turn.
To get a sample of how it works take a look a sample game in file
test/battleship_test.exs
.
Supervisor structure
Battleship and Game.Supervisor are supervisors. GameDispatcher pairs players together. GameSupervisor is a DynamicSupervisor. Game and Board are simple GenServers.
Battleship
/ \
GameDispatcher Game.Supervisor
/ | \
Game Game ...
/ / | \
Board Board Board Board
Installation
If available in Hex, the package can be installed
by adding battleship
to your list of dependencies in mix.exs
:
def deps do
[
{:battleship, "~> 0.1"}
]
end
Documentation can be generated with ExDoc and published on HexDocs. Once published, the docs can be found at https://hexdocs.pm/battleship.