public void UndoMove() { if (GameHistory.Count != 0) { List <int> move = GameHistory.Peek(); GameBoard.Board[move[0], move[1]] = move[2]; GameBoard.Board[move[3], move[4]] = move[5]; RedoStack.Push(GameHistory.Pop()); PlayerOnTurn = PlayerSwap(); if (!GameInProgress) { GameInProgress = true; } } }
private static void Main(string[] args) { var game = new GameEnvironment() { CowsCount = 10, MoneysCount = 100 }; var gameHistory = new GameHistory(); game.WriteToConsole(); gameHistory.Push(game.SaveState()); game.BuyCow(); game.WriteToConsole(); game.RestoreState(gameHistory.Pop()); game.WriteToConsole(); }