Ejemplo n.º 1
0
        /// <summary>
        /// Event handler for when a move is ready for a player
        /// </summary>
        /// <param name="move">Move</param>
        public void OnMoveFound(Move move)
        {
            if (move != null)
            {
                if (!currentPlayer.IsHuman)
                {
                    if (AnalysisView != null)
                    {
                        AnalysisView.Algorithm = (currentPlayer as ComputerPlayer).GetAlgorithm();
                    }

                    Variation[] comEval = ((ComputerPlayer)currentPlayer).LastEvaluation;
                    if (comEval != null && AnalysisView != null)
                    {
                        AnalysisView.Variations = comEval;
                    }
                }

                animationOver = false;
                moveHistory.Add(move);

                if (NotationView != null)
                {
                    NotationView.AddMove(move);
                }

                //Create variable because current player changes during internals
                bool isHuman = currentPlayer.IsHuman;

                //If is a human since we skipped the animation, tell the engine we're done
                if (isHuman)
                {
                    //Perform the internals, without animations
                    for (int j = 0; j < move.Pieces; j++)
                    {
                        DoMoveInternals(move[j], move.Team);
                    }

                    OnMoveAnimationDone();
                }

                DoMove(move, !isHuman, false);

                //Rest of function is continued in OnMoveAnimationDone() since DoMove is async
                //and if we call nextplayer too early it will interrupt the current animation
            }
            else
            {
                ProcessRoll();
                SetReadyForRoll();
            }
        }
Ejemplo n.º 2
0
        private bool AddNewNotationViewRow(Move m)
        {
            int c = GetC(m.Pid);

            if (c == MaxColumnIndex || NotationView.Rows.Count == 0 || IsPrevMoveMainLine(m) || m.Flags.VariationType == VariationTypeE.Variation)
            {
                DataRow dr = NotationView.NewRow();
                NotationView.Rows.Add(dr);

                if (ResultRowId > 0)
                {
                    NotationView.Rows[NotationView.Rows.Count - 1][0] = NotationView.Rows[ResultRowId][0];
                    NotationView.Rows[ResultRowId][0] = "";
                    ResultRowId = NotationView.Rows.Count - 1;
                }

                return(true);
            }

            return(false);
        }