示例#1
0
        public void ShipSetup()
        {
            ResetBoard();
            UserIO.WriteLine($"Alright {Name}, let's setup your ships.");
            ShipType currentShip;

            for (int i = 0; i < 5; i++)
            {
                currentShip = (ShipType)i;
                UserIO.WriteLine($"Place your {currentShip.ToString()}.");

                PlaceShipRequest request = new PlaceShipRequest()
                {
                    Coordinate = UserIO.GetCoord(),
                    Direction  = UserIO.GetDirection(),
                    ShipType   = currentShip
                };

                ShipPlacement spotValidity = board.PlaceShip(request);
                switch (spotValidity)
                {
                case ShipPlacement.NotEnoughSpace:
                    i--;
                    UserIO.WriteLine("Not enough space to place a ship there!");
                    continue;

                case ShipPlacement.Overlap:
                    i--;
                    UserIO.WriteLine("This spot overlaps with another ship!");
                    break;

                case ShipPlacement.Ok:
                    UserIO.WriteLine("Ship placement works!");
                    break;

                default:
                    break;
                }
            }
            UserIO.Continue();
        }