C# Class BattleshipUtility.BattleshipGame

An instance of a battleship game
Show file Open project: solium/hacklympics Class Usage Examples

Public Methods

Method Description
GameLoop ( string opponent, int width, int height, List ships, BattleshipPlayer player ) : void

Main battleship game loop

Seed ( string opponent ) : void

Private Methods

Method Description
Accept ( string s ) : CommandResult

Handles the 'accept' command

Exit ( string s ) : CommandResult

Handles the 'exit' command

Fire ( string s ) : CommandResult

Handles the 'fire' command - sends out the next shot

GetEnemyPositions ( ) : void

When a win/loss/tie command is received, it is followed with a list of enemy positions - read these

Hit ( string s ) : CommandResult

Handles the 'hit' command - records last coordinates shot at as a hit

Incoming ( string s ) : CommandResult

Handles the 'incoming' command

Loss ( string s ) : CommandResult

Handles the 'loss' command

Miss ( string s ) : CommandResult

Handles the 'miss' command - records the last coordinates shot at as a miss

Reject ( string s ) : CommandResult

Handles the 'reject' command

Sink ( string s ) : CommandResult

Handles the 'sink' command - records a ship as sunk

Tie ( string s ) : CommandResult

Handles the 'tie' command

Win ( string s ) : CommandResult

Handles the 'win' command

Method Details

GameLoop() public method

Main battleship game loop
public GameLoop ( string opponent, int width, int height, List ships, BattleshipPlayer player ) : void
opponent string Name of opponent
width int Width of board
height int Height of board
ships List Ships in play
player BattleshipPlayer
return void

Seed() public static method

public static Seed ( string opponent ) : void
opponent string
return void