using Domain;

namespace Presenter.SaveSystem {
	public class LoadGame {
		private readonly IGameRepository _repository;
		private readonly Score _score;
		private readonly IExpressionInput _expressionInput;
		private readonly IRoseSpawner _spawner;

		public LoadGame(IGameRepository repository, Score score, IExpressionInput expressionInput, IRoseSpawner spawner) {
			_repository = repository;
			_score = score;
			_expressionInput = expressionInput;
			_spawner = spawner;
		}

		public void Run() {
			Score newScore = _repository.LoadScore();
			_score.SetFromOtherScore(newScore);
			_expressionInput.UpdateView(_score.Value, _score.GrowPercentage);

			int roses = _score.Value / (_score.SpawnRate * _score.GrowIterations);
			for (int i = 0; i < roses; i++)
				_spawner.SpawnRose();
		}
	}
}