//ShotResult is shot result on the PCs ShootingBoard public void ShortResult(Coordinates coordinates, ShotResult result) { var cell = ShootingBoard.CellAtCoordinate(coordinates.Row, coordinates.Column); switch (result) { case ShotResult.Hit: cell.OccupationType = OccupationType.Hit; break; case ShotResult.Miss: cell.OccupationType = OccupationType.Miss; break; } }
public Player() { // Each player has 1 Battleship & 2 Destroyers (currently) // TODO - Would be nice to have this as a configuration option Ships = new List <Ship>() { new Destroyer(), new Destroyer(), new Battleship(), }; // Each player has a board where the ships are placed GameBoard = new GameBoard(); // Each player has a board that keeps track of shots made at the opponents ships ShootingBoard = new ShootingBoard(); // Set up the players shooting strategy.. ShootingStrategy = new RandomShotStrategy(ShootingBoard); //TODO inject the shooting strategy ! }
public void PrintBoards() { Console.WriteLine("Player: " + Name); Console.WriteLine("Own SeaBoard: Firing Board:\n"); Console.WriteLine(" 1 2 3 4 5 6 7 8 9 10 1 2 3 4 5 6 7 8 9 10\n"); for (int row = 1; row <= 10; row++) { if (row < 10) { Console.Write(row + " "); } else { Console.Write(row + " "); } for (int ownColumn = 1; ownColumn <= 10; ownColumn++) { Console.Write(Ocean.CellAtCoordinate(row, ownColumn).Status + " "); } Console.Write(" "); if (row < 10) { Console.Write(row + " "); } else { Console.Write(row + " "); } for (int firingColumn = 1; firingColumn <= 10; firingColumn++) { Console.Write(ShootingBoard.CellAtCoordinate(row, firingColumn).Status + " "); } Console.WriteLine(Environment.NewLine); } Console.WriteLine(Environment.NewLine); }
/// <summary> /// Display the players boards /// </summary> public void DisplayBoards() { GameBoard.Display(); ShootingBoard.Display(); }
public RandomShotStrategy(ShootingBoard board) { _board = board; }