Exemple #1
0
        public void Run()
        {
            getParticipantInfo();
            while (m_RestartGame)
            {
                getGameBoardSize();

                m_GameLogic = new GameLogic(m_PlayerName, m_SecondPlayerName, m_TableGameRows, m_TableGameCols);
                drawGameTable();

                if (m_IsSinglePlayer)
                {
                    m_GameLogic.InitAi(m_TableGameRows, m_TableGameCols);
                }

                while (!m_GameLogic.IsGameOver())
                {
                    if (m_IsSinglePlayer && !m_FirstPlayerTurn)
                    {
                        pcTurn();
                    }
                    else
                    {
                        playerTurn();
                    }

                    if (m_IsQuitKeyPressed)
                    {
                        break;
                    }

                    if (!m_GameLogic.AreCardsEqual(m_FirstPlayerTurn))
                    {
                        // wait 2 sec if cards are not equal
                        Console.WriteLine(":( , Not a match");
                        System.Threading.Thread.Sleep(2000);
                        drawGameTable();
                        m_FirstPlayerTurn = !m_FirstPlayerTurn;
                    }
                    else
                    {
                        Console.WriteLine(":) , Match!");
                    }
                }

                printStats();
            }
        }