private void OnSlideHappened(SlideHappened message) { if (this.Status == SolveStatus.NotStarted) { this.Status = SolveStatus.InProgress; this.startedAt = DateTime.UtcNow; this.timer.Start(); } if (this.Status == SolveStatus.InProgress) { this.StepCount++; if (message.BoardSolved) { this.Status = SolveStatus.Completed; this.completedAt = DateTime.UtcNow; this.timer.Stop(); this.Duration = this.completedAt - this.startedAt; SolveStatistics solveStatistics = new SolveStatistics(this.Duration, this.StepCount, this.OptimalStepCount); this.messageBus.Publish(new SolveCompleted(solveStatistics)); } } }
private void OnSlideHappened(SlideHappened message) { if (this.Solutions == null) { return; } this.Status = SolverServiceStatus.NotSolved; if (this.nextStepIndex >= this.SolutionLength) { return; } foreach (IReadOnlyList<SolutionStep> solution in this.Solutions) { if (solution[this.nextStepIndex].Status == SolutionStepStatus.Misstepped) { continue; } if (solution[this.nextStepIndex].Step == message.Step) { solution[this.nextStepIndex].Status = SolutionStepStatus.Stepped; } else { for (int i = this.nextStepIndex; i < solution.Count; i++) { solution[i].Status = SolutionStepStatus.Misstepped; } } } this.nextStepIndex++; }