Пример #1
0
        public void ButtonClicked(Point i_Location, EventArgs i_Event)
        {
            // if m_Move.IsEmpty -> We are in the first click
            if (m_Move.IsEmpty())
            {
                m_Move.Source = i_Location;
            }
            else
            {
                m_Move.Destination = i_Location;
                if (m_Player1.Turn)
                {
                    if (isLegalMove(m_Player1, m_Move))
                    {
                        giveTurnTo(ref m_Player1, ref m_Player2, m_Move);

                        if (m_Player2.Name == "PC" && !m_Player1.CanEatMore(m_GameBoard, m_Move.Source))
                        {
                            m_Move = choosePcMove(m_Player2);
                            if (!m_Move.IsEmpty())
                            {
                                ButtonClicked(m_Move.Destination, i_Event);
                            }
                        }
                    }
                }
                else
                {
                    if (isLegalMove(m_Player2, m_Move))
                    {
                        giveTurnTo(ref m_Player2, ref m_Player1, m_Move);
                    }
                }

                Player currentPlayer = m_Player1.Turn ? m_Player1 : m_Player2;

                if (isGameOver(currentPlayer))
                {
                    m_MyChecker.UpdateBoard();
                    GameOver(determineGameResult());
                }

                m_Move.MakeEmpty();
                m_MyChecker.UpdateBoard();
            }
        }