Ejemplo n.º 1
0
        private void Undo_Click(object sender, RoutedEventArgs e)
        {
            if (stackUndo.Count() > 0)
            {
                // push step on redo stack
                bool turn = isWhiteTurn;
                stackRedo.Push(new Tuple <int[], bool>(board.GetValues(), turn));

                // pull undo stack and apply
                Tuple <int[], bool> step = stackUndo.Pop();
                board.Values = step.Item1;
                isWhiteTurn  = step.Item2;
                board.UpdateNextPossibleMoves(isWhiteTurn ? 1 : -1);
                DisplayBoard();
                UpdateScore();
            }
            else
            {
                Console.WriteLine("UndoStack EMPTY");
            }
            lblTurn.Content = isWhiteTurn ? "It's White's turn !" : "It's Black's turn !";
        }