public void PlaceShip(ShipLocation shipLocation) { _playerValidator.ValidateNumberOfPlacedShips(shipLocation.Ship, _ships); _ships.Add(shipLocation.Ship); OwnBoard.SetShip(shipLocation); }
public void FillArrays() { OwnSavedBoard = new Cell[OwnBoard.GetCells().Length]; AttackSavedBoard = new Cell[AttackBoard.GetCells().Length]; int iterator = 0; for (int x = 0; x < OwnBoard.Board.GetLength(0); x++) { for (int y = 0; y < OwnBoard.Board.GetLength(1); y++) { OwnSavedBoard[iterator] = OwnBoard.Board[x, y]; iterator++; } } iterator = 0; for (int x = 0; x < AttackBoard.Board.GetLength(0); x++) { for (int y = 0; y < AttackBoard.Board.GetLength(1); y++) { AttackSavedBoard[iterator] = AttackBoard.Board[x, y]; iterator++; } } }
public ShootResult Shoot(Coordinate coordinate) { var result = OwnBoard.Shoot(coordinate); MarkResultsOnOpponentsBoard(coordinate, result); if (result == ShootResult.Sunk && OwnBoard.AnyShipsLeftInBattle()) { return(ShootResult.Won); } return(result); }