Esempio n. 1
0
        internal void CheckPlayerInput(string playerInput, ref Player player)
        {
            // Convert string coordinates to array based coordinates.
            int[] convertedInput = ConvertPlayerInput(playerInput);

            // Check if ship is in board boundaries and if it's nearby any other ships.
            CheckingService checkingService = new CheckingService();

            if (checkingService.CheckBoardBoundaries(convertedInput, ref player) == true && checkingService.CheckNearbyCells(convertedInput, ref player) == true)
            {
                BoardService boardService = new BoardService();

                boardService.PlaceShipOnBoard(convertedInput, ref player);
            }
            else
            {
                Console.Write("Something went wrong:\n" +
                              "- Did you use wrong coordinates?\n" +
                              "- Did you placed your ship outside the board boundaries?\n" +
                              "- Did you placed your ship near another already placed ship?\n\n");
            }
        }