Ejemplo n.º 1
0
        private void ButtonCellMakeAMoveClick_Click(object sender, EventArgs e)
        {
            Logic.Move move;
            string     endOfGameMessege = string.Empty;

            if (m_ChosenButton != null)
            {
                move = new B18_Ex05_Logic.Move(m_ChosenButton.CellLocation, (sender as ButtonCell).CellLocation);
                if (m_LogicGame.MakeAPlayerMove(ref move))
                {
                    updateBoard(sender as ButtonCell, move);
                    m_ChosenButton.IsClicked = false;
                    m_ChosenButton           = null;
                    if (m_LogicGame.IsGameOver(ref endOfGameMessege))
                    {
                        gameIsOver(endOfGameMessege);
                    }
                    else
                    {
                        playNextMove();
                    }
                }
                else
                {
                    MessageBox.Show("Move is not valid");
                }
            }
        }
Ejemplo n.º 2
0
        private void play()
        {
            bool   keepPlaying = true, moveIsValid = false;
            string isGameOverMessage = string.Empty;

            while (keepPlaying)
            {
                printBoard();
                printLastMoveAndTurn();
                while (!moveIsValid)
                {
                    moveIsValid = getAndHandleMove();
                }

                keepPlaying = !m_game.IsGameOver(ref isGameOverMessage);
                moveIsValid = false;
                Ex02.ConsoleUtils.Screen.Clear();
            }

            gameIsOver(isGameOverMessage);
        }