Esempio n. 1
0
        //public static Player PlayAgain(string name)
        //{
        //    Player player = new Player(name);
        //    player.PlayerBoard = SetUpBoard(player.Name);

        //    return player;
        //}

        public static Board SetUpBoard(string name)
        {
            Console.WriteLine($"{name}, set up your ships.");
            Board board = new Board();

            ConsoleOutput.DrawBoard(board);
            for (ShipType s = ShipType.Destroyer; s <= ShipType.Carrier; s++)
            {
                Console.WriteLine("Place your " + s);
                PlaceShipRequest request = new PlaceShipRequest();
                request.ShipType   = s;
                request.Coordinate = ConsoleInput.EnterCoords();
                request.Direction  = ConsoleInput.EnterDirection();

                ShipPlacement result = board.PlaceShip(request);

                if (result != ShipPlacement.Ok)
                {
                    Console.WriteLine("Invalid location, try again.");
                    s--; //could do error too
                }
            }
            Console.WriteLine("You are finished.");
            Console.ReadLine();
            return(board);
        }