The Clean Unity Handbook
This use case is a simple one to finish so I won’t explain it so much.
It is mandatory to provide a way to the user (or game testers) to reset their progress.
DTOs
Add the following code to the Objectives class:
public struct ResetRequest {
}
public struct ResetResponse {
}
Here we simply leave the structs empty for convenience if the programmer wants to add further improvements to the reset use case. It is often better to provide DTO objects even if your use case does not need any data yet.
Controller
Add the following code to the ObjectivesController class:
public void resetProgress()
{
var request = new Objectives.ResetRequest();
interactor.doReset(request); }
Interactor
Add the following code to the ObjectivesInteractor class:
public interface IObjectivesInteractor {
void doFetch(Objectives.FetchRequest request); void doFlush(Objectives.FlushRequest request); void doStep(Objectives.StepRequest request); void doClaim(Objectives.ClaimRequest request); void doReset(Objectives.ResetRequest request);
}
public void doReset(Objectives.ResetRequest request)
{
ObjectivesWorker.Reset();
//since we flushed data we fetch objectives again
var fetchRequest = new Objectives.FetchRequest(); fetchRequest.numberOfObjectives = numberOfObjectives; fetchRequest.set = fetchedSet;
doFetch(fetchRequest);
var response = new Objectives.ResetResponse(); presenter.presentReset(response);
}
Presenter
Add the following code to the ObjectivesPresenter class:
public void presentReset(Objectives.ResetResponse response) {
NotifierPresenter.Instance.PerformInstantaneousRequest("Progress Reset !");
}