Provides easy functions to create a battleships plugin.
How to use
- The plugin creator is able to create a game by instantiating a new Game object from the API package (com.github.cc007.battleshipsapi)
- The game object contains two battleships Player objects (will maybe change to BSPlayer in the future to prevent bukkit Player confusion). The players are accessable through <gameobject>.getPlayer1() and <gameobject>.getPlayer2().
- The game starts in a ship setup state, where ships can be set up. This can be done through <playerobject>.placeShip(<kind of ship>, <letter of column>, <number of row>, <direction of ship>). The coordinate given is the top most or left most point (dependent on the vertical or horizontal direction) of the ship.
- Before the <playerobject>.ready() command is issued , player ships can be moved. This is done using the method moveShip with the same parameters as placeShip uses.
- Issueing the ready() method will check if all ships are placed. Only then the command will set the player to ready. If both players are set to ready, the game will start.
- Players are able to alternate shooting, starting with player1, using <playerobject>.shootOpponent(<letter of column>, <number of row>)
- Players are able to see their own board data by using <playerobject>.getOwnGrid() They check coordinate values by using <gridobject>.get(<letter of column).get(<number of row>). This returns a FieldState object that is EMPTY or OCCUPIED when not shot and HIT or MISS when shot.
- Players can also see what they know of the enemy grid. You can get the coodinate values in the same way as above. It will show EMPTY for unknown fields and HIT or MISS for fields that were shot.
- The game will end automatically when one of the players has lost all ships. You can ask the game if the game is over with <gameobject>.isGameOver() and check which player won with <playerobject>.hasWon(), both methods returning a boolean
- When a game is done you can either create a new Game object to start a new game, or you could call <gameobject.reset() to reset the game.
An example implementation for this api is BattleConsole, a windows command prompt/unix shell based implementation using this api.
Possible implementations for minecraft
- Using inventories to display the boards and select the fields to shoot
- Using blocks to display the boards and commands to shoot
- Using custom skinned heads to display the boards and punching a head to shoot.