Exemplo n.º 1
0
        private Board GameBoard(string Playername)
        {
            Board board = new Board();

            for (ShipType s = ShipType.Destroyer; s <= ShipType.Carrier; s++)
            {
                bool IsPlacementValid = false;
                do
                {
                    PlaceShipRequest request = new PlaceShipRequest();
                    request.Coordinate = ConsoleInput.GetCoord(Playername);
                    request.Direction  = ConsoleInput.GetDirect(Playername);
                    request.ShipType   = s;

                    var result = board.PlaceShip(request);

                    if (result == ShipPlacement.NotEnoughSpace)
                    {
                        ConsoleOutput.Out();
                    }
                    else if (result == ShipPlacement.Overlap)
                    {
                        ConsoleOutput.Overlap();
                    }
                    else if (result == ShipPlacement.Ok)
                    {
                        ConsoleOutput.Ok();

                        IsPlacementValid = true;
                    }
                }while (!IsPlacementValid);
            }
            return(board);
        }