public void RestoreFromMemento(IGameMemento memento) { var newMemento = (GameMemento)memento; Playfield = newMemento.Playfield; Settings = newMemento.Settings; Moves = newMemento.Moves; NotifyOnPlayfieldChange?.Invoke(Playfield.Board); }
public void Execute() { _savedMemento = _game.SaveGameMemento(); bool isMoveValid = _manipulator.MakeMove(_game.Playfield, _direction, _game.Settings.IsRandomActionsEnabled); if (isMoveValid) { _history.SaveCommand(this); _game.IncrementMovesNumber(); _game.IsSolved(); } }