예제 #1
0
        public int[] UserInputTile()
        {
            _printer.Print("\nInput X coordinate of tile\n\n>>> ");
            int tileX = Int32.Parse(_printer.Read());

            _printer.Print("Input Y coordinate of tile\n\n>>> ");
            int tileY = Int32.Parse(_printer.Read());

            int[] TileCoords = new int[] { tileX, tileY };

            if (tileX < Math.Sqrt(board.Length) && tileY < Math.Sqrt(board.Length))
            {
                if (board[tileX, tileY] == 'E')
                {
                    return(TileCoords);
                }

                else
                {
                    return(null);
                }
            }
            else
            {
                return(null);
            }
        }
예제 #2
0
        public static bool ChooseStartingPlayer(IGameBoard gameBoard, IInputOutput printer)
        {
            printer.Print("\nWhich player starts first O or X\n\n>>> ");
            var  choice = 'E';
            bool completed;

            try
            {
                choice = (char)Convert.ChangeType(printer.Read(), typeof(char));
                if (char.ToUpper(choice) == 'O' || char.ToUpper(choice) == 'X')
                {
                    completed = true;
                    ((IGameBoardWinning)gameBoard).PlayerStarts(char.ToUpper(choice));
                }
                else
                {
                    gameBoard.PrintBoard();
                    printer.Print("\nPlease choose either O or X", true);
                    completed = false;
                }
            }
            catch
            {
                gameBoard.PrintBoard();
                printer.Print("\nPlease choose either O or X", true);
                completed = false;
            }
            return(completed);
        }
예제 #3
0
        public int[] UserInputTile()
        {
            string TestCoordsString;
            char   TestCoordX;
            char   TestCoordY;
            char   WhichGo;

            try
            {
                if (!userx.IsMyGo == true)
                {
                    WhichGo = 'O';
                }
                else
                {
                    WhichGo = 'X';
                }
                _printer.Print($"\n{WhichGo}'s turn, Enter coordinates of tile\n\n>>> ");
                TestCoordsString = _printer.Read();
                TestCoordX       = TestCoordsString.First();
                TestCoordY       = TestCoordsString.Last();

                Convert.ChangeType(Convert.ChangeType(TestCoordX, typeof(string)), typeof(int));
                Convert.ChangeType(Convert.ChangeType(TestCoordY, typeof(string)), typeof(int));

                int[] TestCoords = { (int)Convert.ChangeType(Convert.ChangeType(TestCoordX, typeof(string)), typeof(int)), (int)Convert.ChangeType(Convert.ChangeType(TestCoordY, typeof(string)), typeof(int)) };
            }

            catch
            {
                int[] incorrectcode = { 10, 10 };
                return(incorrectcode);
            }
            int[] TileCoords = { (int)Convert.ChangeType(Convert.ChangeType(TestCoordX, typeof(string)), typeof(int)), (int)Convert.ChangeType(Convert.ChangeType(TestCoordY, typeof(string)), typeof(int)) };

            if (TileCoords[0] < Math.Sqrt(GetBoard().Length) && TileCoords[1] < Math.Sqrt(GetBoard().Length))
            {
                if (GetBoard()[TileCoords[0], TileCoords[1]] == 'E')
                {
                    return(TileCoords);
                }

                else
                {
                    int[] incorrectcode = { 20, 20 };
                    return(incorrectcode);
                }
            }
            else
            {
                int[] incorrectcode = { 30, 30 };
                return(incorrectcode);
            }
        }
예제 #4
0
        public string GetTan(FinService aService)
        {
            FinTanProcessParameters tanProcess     = aService.TanProcess;
            FinChallengeInfo        aChallengeInfo = aService.ChallengeInfo;

            if ((tanProcess != null) && (aChallengeInfo != null))
            {
                io.Write(tanProcess.ChallengeLabel + ": ");
                io.Write(aChallengeInfo.Challenge);
            }

            io.Write("TAN:");

            string sTAN = io.Read();

            return(!string.IsNullOrEmpty(sTAN) ? sTAN : null);
        }
예제 #5
0
        public BoardCoordinate DetermineBest(IIntelligenceContext context)
        {
            var answer = _io.Read("Choose a position: ");

            return(context.Board.ToCoordinate(int.Parse(answer)));
        }
예제 #6
0
        public void Add()
        {
            var todo = IO.Read();

            Todos.Add(todo);
        }