Пример #1
0
        static void Game()
        {
            do
            {
                Console.Clear();
                GameboardDisplay();
                UserTurn();

                Console.Clear();

                //checks to see if the current player is the winner and processes the result.
                if (GameStatusChecker.IsWon(gameBoard.GameSpaces, xOrO))
                {
                    string endText = " " + xOrO + "'s Win!\n";
                    EndGame(endText);
                    continue;
                }

                if (GameStatusChecker.IsTied(gameBoard.GameSpaces))
                {
                    string endText = " Cat's Game!\n";
                    EndGame(endText);
                    continue;
                }

                SwitchPlayer();
            } while (true);
        }
Пример #2
0
        static void Game(Func <GameBoard, char, bool> positionSelector)
        {
            do
            {
                Console.Clear();
                GameboardDisplay();

                if (isUserTurn)
                {
                    UserTurn();
                    isUserTurn = false;
                }

                else if (!isUserTurn)
                {
                    positionSelector(gameBoard, xOrO);
                    isUserTurn = true;
                }

                Console.Clear();

                //checks to see if the current player is the winner and processes the result.
                if (GameStatusChecker.IsWon(gameBoard.GameSpaces, xOrO))
                {
                    string endText = " " + xOrO + "'s Win!\n";
                    EndGame(endText);
                    continue;
                }

                if (GameStatusChecker.IsTied(gameBoard.GameSpaces))
                {
                    string endText = " Cat's Game!\n";
                    EndGame(endText);
                    continue;
                }
                SwitchPlayer();
            } while (true);
        }