コード例 #1
0
 private static void GameLaunher()
 {
     UIOrginaizer ui = new UIOrginaizer();
     ui.WelcomeMsg();
     GameLogic game = new GameLogic(ui.ColumnOrRowSelection("Rows"), ui.ColumnOrRowSelection("Columns"), ui.VerusPlayerOrComputer());
     game.InitialysBorad();
     ui.DrawBoard(game.GetRow, game.GetColumn, game.GetBoard);
     GameManager(ui, game);
 }
コード例 #2
0
        private static void GameLaunher()
        {
            UIOrginaizer ui = new UIOrginaizer();

            ui.WelcomeMsg();
            GameLogic game = new GameLogic(ui.ColumnOrRowSelection("Rows"), ui.ColumnOrRowSelection("Columns"), ui.VerusPlayerOrComputer());

            game.InitialysBorad();
            ui.DrawBoard(game.GetRow, game.GetColumn, game.GetBoard);
            GameManager(ui, game);
        }
コード例 #3
0
        private static void GameManager(UIOrginaizer io_UI, GameLogic io_Game)
        {
            int  MyTurn;
            bool isQuitPressed = false;
            bool isWinner      = false;
            bool isBoardFull   = false;
            bool isNextRound   = true;

            while (isNextRound)
            {
                // Setting primary randomly turn
                MyTurn = new Random().Next(1, 3);
                while (!isBoardFull)
                {
                    if (io_Game.GetNumberOfPlayers == 1)
                    {
                        if (MyTurn == 1)
                        {
                            isQuitPressed = PlayTurnByUser(io_Game, io_UI, MyTurn);
                            isWinner      = io_Game.CheckIfWinner(MyTurn);
                        }
                        else
                        {
                            PlayTurnByComputer(io_Game, io_UI);
                            isWinner = io_Game.CheckIfWinner(MyTurn);
                        }
                    }
                    else
                    {
                        isQuitPressed = PlayTurnByUser(io_Game, io_UI, MyTurn);
                        isWinner      = io_Game.CheckIfWinner(MyTurn);
                    }
                    isBoardFull = io_Game.CheckIfBoardIsFull();
                    if (isBoardFull || isWinner || isQuitPressed)
                    {
                        break;
                    }
                    if (MyTurn == 1)
                    {
                        MyTurn = 2;
                    }
                    else
                    {
                        MyTurn = 1;
                    }
                }

                if (isWinner)
                {
                    Console.WriteLine("Player Number {0} wins!!!", MyTurn);
                }
                else
                {
                    if (isBoardFull)
                    {
                        Console.WriteLine("Game board is full. Draw!");
                    }
                    else
                    {
                        Console.WriteLine("You chose to quit the game.");
                    }
                }
                io_Game.ShowScoreBoard();
                isNextRound = io_UI.CheckIfNextRound();
                if (isNextRound)
                {
                    io_Game.InitialysBorad();
                    io_UI.DrawBoard(io_Game.GetRow, io_Game.GetColumn, io_Game.GetBoard);
                }
            }
            Ex02.ConsoleUtils.Screen.Clear();
            Console.WriteLine("========= Final Score =========" + Environment.NewLine);
            io_Game.ShowScoreBoard();
        }
コード例 #4
0
        private static void GameManager(UIOrginaizer io_UI, GameLogic io_Game)
        {
            int MyTurn;
            bool isQuitPressed = false;
            bool isWinner = false;
            bool isBoardFull = false;
            bool isNextRound = true;

            while (isNextRound)
            {

                // Setting primary randomly turn
                MyTurn = new Random().Next(1, 3);
                while (!isBoardFull)
                {
                    if (io_Game.GetNumberOfPlayers == 1)
                    {
                        if (MyTurn == 1)
                        {
                            isQuitPressed = PlayTurnByUser(io_Game, io_UI, MyTurn);
                            isWinner = io_Game.CheckIfWinner(MyTurn);
                        }
                        else
                        {
                            PlayTurnByComputer(io_Game, io_UI);
                            isWinner = io_Game.CheckIfWinner(MyTurn);
                        }
                    }
                    else
                    {
                        isQuitPressed = PlayTurnByUser(io_Game, io_UI, MyTurn);
                        isWinner = io_Game.CheckIfWinner(MyTurn);
                    }
                    isBoardFull = io_Game.CheckIfBoardIsFull();
                    if (isBoardFull || isWinner || isQuitPressed)
                    {
                        break;
                    }
                    if (MyTurn == 1)
                    {
                        MyTurn = 2;
                    }
                    else
                    {
                        MyTurn = 1;
                    }
                }

                if (isWinner)
                {
                    Console.WriteLine("Player Number {0} wins!!!", MyTurn);
                }
                else
                {
                    if (isBoardFull)
                    {
                        Console.WriteLine("Game board is full. Draw!");
                    }
                    else
                    {
                        Console.WriteLine("You chose to quit the game.");
                    }
                }
                io_Game.ShowScoreBoard();
                isNextRound = io_UI.CheckIfNextRound();
                if (isNextRound)
                {
                    io_Game.InitialysBorad();
                    io_UI.DrawBoard(io_Game.GetRow, io_Game.GetColumn, io_Game.GetBoard);
                }
            }
            Ex02.ConsoleUtils.Screen.Clear();
            Console.WriteLine("========= Final Score =========" + Environment.NewLine);
            io_Game.ShowScoreBoard();
        }