Exemple #1
0
        private bool UndoAStep()
        {
            if (StkUndoStep.Count <= 0)
            {
                return(false);
            }

            PlayInfo OldPos = StkUndoStep.Pop();

            StkRedoStep.Push(OldPos);

            Button btn = MatrixPositions[OldPos.Point.Y][OldPos.Point.X];

            btn.BackgroundImage = null;

            if (StkUndoStep.Count <= 0)
            {
                CurrentPlayer = 0;
            }
            else
            {
                OldPos = StkUndoStep.Peek();
            }

            ChangePlayer();

            return(true);
        }
Exemple #2
0
        public bool Undo()
        {
            if (StkUndoStep.Count <= 1)
            {
                return(false);
            }

            PlayInfo OldPos = StkUndoStep.Peek();

            CurrentPlayer = OldPos.CurrentPlayer == 1 ? 0 : 1;

            bool IsUndo1 = UndoAStep();
            bool IsUndo2 = UndoAStep();

            return(IsUndo1 && IsUndo2);
        }