Example #1
0
        public void SetUpBoard()
        {
            var ships = new Dictionary <ShipType, int>()
            {
                { ShipType.Destroyer, 2 },
                { ShipType.Cruiser, 3 },
                { ShipType.Submarine, 3 },
                { ShipType.Battleship, 4 },
                { ShipType.Carrier, 5 }
            };

            foreach (KeyValuePair <ShipType, int> vessel in ships)
            {
                ShipPlacement response;
                do
                {
                    Console.Clear();
                    ConsoleOutput.DisplayBoard(this, false);
                    ConsoleOutput.DisplayPlacementMessage(this, vessel.Key, vessel.Value);
                    PlaceShipRequest request = GetPlaceShipRequest(vessel.Key);

                    response = Board.PlaceShip(request);

                    Console.Clear();
                    ConsoleOutput.DisplayBoard(this, false);
                    ConsoleOutput.DisplayShipResponse(request, response);
                    ConsoleInput.Continue();
                } while (response != ShipPlacement.Ok);
            }
            Console.Clear();
            ConsoleOutput.DisplayBoard(this, false);
            ConsoleOutput.ClearScreenPrompt();
        }
Example #2
0
        public static void SetUpBoard(User player)
        {
            ShipPlacement response;

            var ships = new Dictionary <ShipType, int>()
            {
                { ShipType.Destroyer, 2 },
                { ShipType.Cruiser, 3 },
                { ShipType.Submarine, 3 },
                { ShipType.Battleship, 4 },
                { ShipType.Carrier, 5 }
            };

            foreach (KeyValuePair <ShipType, int> vessel in ships)
            {
                do
                {
                    Console.Clear();
                    ConsoleOutput.DisplayBoard(player, false);
                    ConsoleOutput.DisplayPlacementMessage(player, vessel.Key, vessel.Value);
                    var request = new PlaceShipRequest()
                    {
                        Coordinate = ConsoleInput.GetCoordinate(),
                        Direction  = ConsoleInput.GetShipDirection(),
                        ShipType   = vessel.Key
                    };

                    response = player.Board.PlaceShip(request);
                    Console.Clear();
                    ConsoleOutput.DisplayBoard(player, false);
                    ConsoleOutput.DisplayShipResponse(request, response);
                    ConsoleInput.Continue();
                } while (response != ShipPlacement.Ok);
            }
            Console.Clear();
            ConsoleOutput.DisplayBoard(player, false);
            ClearScreenPrompt();
        }