Example #1
0
        public void MoveTo(MoveToE moveTo, bool moveFromBook)
        {
            Move m = null;

            if ((Flags.IsFirstMoveSelected || Flags.IsRootMoveSelected) && (moveTo == MoveToE.Previous || moveTo == MoveToE.First))
            {
                if (Flags.IsRootMoveSelected)
                {
                    return;
                }

                SetInitialPosition();
                return;
            }

            if (moveFromBook && moveTo == MoveToE.Next)
            {
                Book.MoveTo(moveTo, true);
                return;
            }

            if (Flags.IsFirtMove && moveTo == MoveToE.Next)
            {
                return;
            }

            switch (moveTo)
            {
            case MoveToE.First:
                m = Moves.First;
                break;

            case MoveToE.Last:
                m = Moves.Last;
                break;

            case MoveToE.Next:
                m = GetNextMove(CurrentMove);
                break;

            case MoveToE.Previous:
                m = Moves.Prev(CurrentMove);
                break;

            case MoveToE.Up:
                break;

            case MoveToE.Down:
                break;

            default:
                break;
            }


            Flags.IsRetracMove = false;

            CurrentMove = m.Clone();

            Clock.MoveTo(moveTo);
            Notations.MoveTo(moveTo);
            Book.MoveTo(moveTo, false);
            CapturedPieces.MoveTo(moveTo);

            SetFen(CurrentMove.Fen);
            SwapPlayersIfNeeded();
        }
Example #2
0
        public void MoveTo(MoveToE moveTo)
        {
            Move m = null;

            switch (moveTo)
            {
            case MoveToE.First:
                m = Moves.First;
                //Notations.MoveTo(moveTo);
                break;

            case MoveToE.Last:
                m = Moves.Last;
                break;

            case MoveToE.Next:
                m = Moves.Next(CurrentMove);
                //Notations.MoveTo(moveTo);
                break;

            case MoveToE.Previous:
                m = Moves.Prev(CurrentMove);
                //Notations.MoveTo(moveTo);
                break;

            case MoveToE.Up:
                break;

            case MoveToE.Down:
                break;

            default:
                break;
            }


            if (m == null && moveTo == MoveToE.Previous)
            {
                return;
            }

            if (m == null)
            {
                Book.MoveTo(moveTo, true);
                return;
            }

            if (CurrentMove.Id == m.Id)
            {
                Book.MoveTo(moveTo, true);
            }
            else
            {
                CurrentMove = m.Clone();

                Flags.IsMoveInProgress = true;
                Flags.IsClickedByUser  = true;

                Clock.Stop();
                Clock.SetClock(CurrentMove);

                Flags.IsRetracMove     = false;
                Flags.IsMoveInProgress = false;

                Notations.Set();
                Book.MoveTo(moveTo, false);
                SetCapturedPiecesParameters();
                CapturedPieces.MoveTo(moveTo);

                SetFen(CurrentMove.Fen);
            }
        }