Skip to content

v1.0.0

Latest
Compare
Choose a tag to compare
@profcturner profcturner released this 04 Apr 23:09
· 16 commits to master since this release
0dbdb94

Initial Release

This initial formal release of battleships provides a very simple API to run a battleships server intended to allow students to be able to build basic clients against. It runs on Python Django and currently need Python >= 3.6.

The API is deliberately simple, and a framework is not used again to keep the code relatively simple and easy to understand.

The game permits players and games to be registered on the server, and ships can then be generated which players can take turns to attempt to hit.

The summary reference for the API is below, but the enclosed README.md contains a far more detailed discussion.

API 1.0

In version 1.0 of the API, all URLs are prefixed with api/1.0/. URLs are shown below, where data to be passed is shown like so. And a brief description of the function shown. More details to be added. All data is serialised using JSON. It is possible to use the response status code in many places to determine if the request is successful.

While this document records the current API, it may still have bugs and need tweaks, and should be considered experimental.

URL Function
players/index/ List current registered players
players/register/name/ Register a player with text name
players/delete/name/secret Delete a player
games/index/ List current registered games
games/register/name/ Create a new game
games/delete/name/secret/ Delete a game
games/addplayer/game/name/ Add a player to a game
games/start/game/ Generate ships and start game
games/history/game/ Show actions so far in game
games/getships/game/player/secret/ Get all the ships for a given player in a game
games/getwinner/game/ Returns a winner, used to detect game over
strike/game/player/(x,y)/secret/ Attempt to hit a grid square