コード例 #1
0
        private Move GetNextMove(Move m)
        {
            Moves children = Moves.GetChildren(m);

            if (children.Count == 0)
            {
                m = CurrentMove;
            }
            else if (children.Count == 1)
            {
                m = children[0];
            }
            else if (children.Count > 1)
            {
                if (SelectCurrentMoveChildren != null)
                {
                    SelectCurrentMoveChildrenEventArgs e = new SelectCurrentMoveChildrenEventArgs();
                    e.Move = m;
                    SelectCurrentMoveChildren(this, e);
                    m = e.Move;
                }
            }

            if (m == null)
            {
                m = CurrentMove;
            }

            return(m);
        }
コード例 #2
0
        private bool AddVariationMove(Move m)
        {
            if (GameMode == GameMode.Kibitzer)
            {
                CurrentMove = Moves.Last;
                return(false);
            }

            if (Flags.IsRetracMove)
            {
                this.VariationType = VariationTypeE.Overwrite;
                return(false);
            }

            if (!Flags.IsFirtMove)
            {
                Moves children = Moves.GetChildren(CurrentMove);

                if (children.Count > 0)
                {
                    if (m.Flags.MoveBy == MoveByE.Human)
                    {
                        if (m.From == children[0].From && m.To == children[0].To)
                        {
                            MoveTo(children[0]);
                            return(true);
                        }
                    }
                    else if (m.Flags.MoveBy == MoveByE.Book)
                    {
                        for (int i = 0; i < children.Count; i++)
                        {
                            if (m.From == children[i].From && m.To == children[i].To)
                            {
                                MoveTo(children[i]);
                                return(true);
                            }
                        }
                    }
                }
            }

            FormClosingEventArgs e = new FormClosingEventArgs(CloseReason.None, false);

            if (Flags.IsVariation)
            {
                if (m.Flags.MoveBy != MoveByE.Human)
                {
                    this.VariationType = VariationTypeE.Variation;
                    return(false);
                }

                if (AddNewVariation != null)
                {
                    AddNewVariation(this, e);
                }
            }

            if (e.Cancel)
            {
                SetFen(CurrentMove.Fen);
            }

            return(e.Cancel);
        }