diff --git a/MemoryGame/Pages/Home.razor b/MemoryGame/Pages/Home.razor
index 207d9ee..ca05a22 100644
--- a/MemoryGame/Pages/Home.razor
+++ b/MemoryGame/Pages/Home.razor
@@ -21,7 +21,7 @@
}
- else if (_currentSession.IsComplete)
+ else if (_currentSession.IsComplete && !_showStatistics)
{
Spiel beendet!
@@ -36,6 +36,68 @@
+
+
+ }
+ else if (_currentSession.IsComplete && _showStatistics)
+ {
+ var words = GameService.GetWords()
+ .OrderBy(w => w.CorrectCount + w.IncorrectCount == 0 ? 1 : 0)
+ .ThenBy(w => w.CorrectCount + w.IncorrectCount == 0
+ ? 0
+ : (double)w.CorrectCount / (w.CorrectCount + w.IncorrectCount))
+ .ToList();
+
+ var playedWords = words.Where(w => w.CorrectCount + w.IncorrectCount > 0).ToList();
+ var overallAccuracy = playedWords.Count == 0
+ ? 0
+ : (int)Math.Round(100.0 * playedWords.Sum(w => w.CorrectCount) / playedWords.Sum(w => w.CorrectCount + w.IncorrectCount));
+
+
+
Statistik
+
+
+ @playedWords.Count von @words.Count Wörtern geübt
+ @if (playedWords.Count > 0)
+ {
+ · @overallAccuracy% richtig
+ }
+
+
+
+ @foreach (var word in words)
+ {
+ var total = word.CorrectCount + word.IncorrectCount;
+ var accuracy = total == 0 ? 0 : (int)Math.Round(100.0 * word.CorrectCount / total);
+ var barClass = total == 0 ? "bar-unplayed" : accuracy >= 70 ? "bar-green" : accuracy >= 40 ? "bar-orange" : "bar-red";
+
+
+

+
+
@(total == 0 ? "—" : $"{accuracy}% richtig")
+
+ }
+
+
+ @if (_confirmReset)
+ {
+
+ Alle Statistiken wirklich zurücksetzen?
+
+
+
+ }
+ else
+ {
+
+ }
+
+
}
else
@@ -96,6 +158,8 @@
private bool _showFeedback;
private string _feedbackMessage = "";
private string _feedbackClass = "";
+ private bool _showStatistics;
+ private bool _confirmReset;
protected override async Task OnInitializedAsync()
{
@@ -144,5 +208,23 @@
StateHasChanged();
}
-}
+ private void ShowStatistics()
+ {
+ _showStatistics = true;
+ }
+
+ private void GoToStart()
+ {
+ _currentSession = null;
+ _showStatistics = false;
+ _confirmReset = false;
+ }
+
+ private async Task ConfirmReset()
+ {
+ await GameService.ResetStatisticsAsync();
+ _confirmReset = false;
+ StateHasChanged();
+ }
+}