Example #1
0
        private void PlayMove(IBoardState newBoard,bool needToContinueEating)
        {
            currBoard = newBoard;

            GameState stateAfterMove = currBoard.GetGameState(player);
            this.PaintBoard();
            if (stateAfterMove == GameState.Won)
            {
                MessageBox.Show(player.ToString()+" "+Resources.Won);
                players = null;
                return;
            }
            if (stateAfterMove == GameState.Lost)
            {
                MessageBox.Show(player.ToString() + " " + Resources.Lost);
                players = null;
                return;
            }
            if (stateAfterMove == GameState.Draw)
            {
                MessageBox.Show(Resources.Draw);
                players = null;
                return;
            }

            // check if player needs to continue eating
            if (needToContinueEating)
            {
                return;
            }

            // switch players

            if (player == Player.White)
            {
                player = Player.Black;
            }
            else
            {
                player = Player.White;
            }
            playersTurn.BackColor = this.ConvertToColor();

            if (players[player] is UserPlayer)
            {
                return;
            }
            else
            {
                InteractivePause(new TimeSpan(0,0,0,0,1000));
            }

            int depth;
            try
            {
                depth = int.Parse(depthCombo.Text);
            }
            catch (Exception)
            {
                depth = 4;
            }
            IMove pcMove = players[player].GetBoardMove(currBoard,depth);
            this.PlayMove(pcMove.Board,false);
        }