Beispiel #1
0
        public static int FindNumberAxis(int i_boardsize, string i_whichAxis, Player i_NowPlaying)
        {
            bool   stillCheck = true;
            int    ans        = 0;
            string axisNumberStr;
            int    axisNumberInt;

            axisNumberStr = TicTacToeReverse.AskAxisNumber(i_boardsize, i_whichAxis, i_NowPlaying);
            axisNumberInt = Cell.ValidInputAxis(axisNumberStr, i_boardsize);
            while (stillCheck)
            {
                if (axisNumberInt == -1)
                {
                    if (axisNumberStr == "Q")
                    {
                        stillCheck = false;
                        ans        = -1;
                        break;
                    }
                    else
                    {
                        axisNumberStr = TicTacToeReverse.AskAxisNumber(i_boardsize, i_whichAxis, i_NowPlaying);
                        axisNumberInt = Cell.ValidInputAxis(axisNumberStr, i_boardsize);
                    }
                }
                else
                {
                    stillCheck = false;
                    ans        = axisNumberInt;
                    break;
                }
            }

            return(ans);
        }
        public static Cell FindValidCell(Player i_NowPlaying, Board i_Board)
        {
            Cell optionalCell;

            optionalCell = TicTacToeReverse.FindCell(i_NowPlaying, i_Board);
            while (!IsEmpty(optionalCell))
            {
                if (Player.GetPlayerType(i_NowPlaying) == "p")
                {
                    Console.WriteLine("The cell is not avilable, please enter another cell");
                }

                optionalCell = TicTacToeReverse.FindCell(i_NowPlaying, i_Board);
            }

            return(optionalCell);
        }