Example #1
0
        private void buttonChosen(object sender, EventArgs e)
        {
            int[] chosenLocation = { (sender as GameButton).Row, (sender as GameButton).Line };

            if (m_gameLogics.isCellEmpty(chosenLocation[0], chosenLocation[1]))
            {
                if (m_gameLogics.m_PlayerTurn == 1)
                {
                    m_gameLogics.DrawInCell(m_gameLogics.m_Player1, chosenLocation[0], chosenLocation[1]);
                    m_gameLogics.NewMoveLogic(m_gameLogics.m_Player1, m_gameLogics.m_Player2, chosenLocation[0], chosenLocation[1]);
                }
                else if (m_Settings.isVsAI == false)
                {
                    m_gameLogics.DrawInCell(m_gameLogics.m_Player2, chosenLocation[0], chosenLocation[1]);
                    m_gameLogics.NewMoveLogic(m_gameLogics.m_Player2, m_gameLogics.m_Player1, chosenLocation[0], chosenLocation[1]);
                }
            }
            else
            {
                MessageBox.Show("This cell is already taken !", "Othello", MessageBoxButtons.OK, MessageBoxIcon.Error);
                m_gameLogics.m_PlayerTurn *= -1;
            }

            anyValidMoves();
            disableButtons();
            enableLegalMoves();
        }