Пример #1
0
        public void PlayerData(Board board)
        {
            int x = 0;
            int y = 0;
            PlaceShipRequest request    = new PlaceShipRequest();
            Coordinate       Coordinate = new Coordinate(x, y);

            for (int currentShipIndex = 0; currentShipIndex < 5;)
            {
                while (true)
                {
                    request.ShipType = ConsoleInput.ProcessType(currentShipIndex);

                    _strCoordinate = ConsoleInput.GetCoor(Coordinate);

                    ConsoleInput.ProcessCoor(Coordinate, x, y, _strCoordinate);

                    request.Coordinate = Coordinate;

                    _direction = ConsoleInput.GetDirection(_direction);

                    request.Direction = ConsoleInput.ProcessDirection(_direction);

                    var shipPlaced = board.PlaceShip(request);

                    if (shipPlaced == ShipPlacement.NotEnoughSpace)
                    {
                        Console.WriteLine("There's not enough space for that ship. Try again");
                    }
                    else if (shipPlaced == ShipPlacement.Overlap)
                    {
                        Console.WriteLine("Ships are overlapping. Try again.");
                    }
                    else
                    {
                        break;
                    }
                }
                currentShipIndex++;
                Console.Clear();
            }
        }