示例#1
0
文件: Form1.cs 项目: eNuoTiZ/Othello
        private void PlayAi()
        {
            if (!Game.GetInstance().TheEnd)
            {
//                Cursor = Cursors.WaitCursor;
//                loadingBox.Visible = true;
//                loadingBox.Refresh();

                int points = _players[_game.PlayerTurn].Play(new Game.Move(-1, -1));

                if (points == 0)
                {
                    // ai player cannot play, passes his turn

                    Game.GetInstance().InvertTurn();
                    Game.GetInstance().Turn++;
                }
                else
                {
                    _players[_game.PlayerTurn].Score += points + 1;

                    Game.GetInstance().InvertTurn();
                    Game.GetInstance().Turn++;

                    _players[_game.PlayerTurn].Score -= points;

//                    DrawBoard();
                }

                if (_game.NbPossibleMoves(_game.Board, _players[_game.PlayerTurn].ColorPlayer) == 0)
                {
                    if (_game.Block || _game.BoardFull(_game.Board))
                    {
                        _game.Winner(_players[0], _players[1]);
                    }
                    else
                    {
                        _game.Block = true;
                        MessageBox.Show(string.Format("Player {0} cannot play!", _players[_game.PlayerTurn].ColorPlayer));

                        Game.GetInstance().InvertTurn();
                        Game.GetInstance().Turn++;

                        PlayAi();
                    }
                }

//                loadingBox.Visible = false;
//                loadingBox.Refresh();
//                Cursor = Cursors.Default;
            }
            else
            {
                Game.GetInstance().Winner(_players[0], _players[1]);
            }
        }