private void buttonUndo_Click(object sender, EventArgs e)
{
if (madeMoves.Count > 0)
{
watch.Stop();
List<TimedMove> h = new List<TimedMove>();
foreach (TimedMove m in moveHistory)
h.Add(new TimedMove(m));
TimedMove tmove = TimedMove.CreateUndoMove((int)watch.ElapsedMilliseconds, 0);
moves.Add(new GameStateMoveAction(currentGameState.Clone(), originalGameState, watch.ElapsedMilliseconds, tmove, h));
moveHistory.Add(tmove);
Move move = madeMoves.Pop();
currentGameState.Board.UndoMove(currentGameState.PlayerOnRoll, move);
int[] dice = currentGameState.Dice;
unusedDice.Add(usedDice.Pop());
}
if (madeMoves.Count == 0)
{
buttonUndo.Visible = false;
buttonUndo.Enabled = false;
}
UpdateControls();
}