Skip to content

Commit f9c6b68

Browse files
authored
Fix: Correct Stat Mode initialization and confirm stat registration (#5)
1 parent 8d40644 commit f9c6b68

1 file changed

Lines changed: 5 additions & 1 deletion

File tree

script.js

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -67,6 +67,7 @@ let statGuessActive = false;
6767
// Initialize stat guess mode toggle
6868
statModeToggle.checked = localStorage.getItem("statGuessMode") === "true";
6969
isStatGuessMode = statModeToggle.checked;
70+
setupGame();
7071

7172
// Add event listener for stat mode toggle
7273
statModeToggle.addEventListener("change", () => {
@@ -424,8 +425,11 @@ function updateStats(isWin, attempts) {
424425
stats.currentStreak++;
425426
stats.maxStreak = Math.max(stats.maxStreak, stats.currentStreak);
426427
stats.guessDistribution[attempts - 1]++;
427-
} else {
428+
} else { // Player lost
428429
stats.currentStreak = 0;
430+
// Add this line to record the loss in the guess distribution
431+
// 'attempts' will be maxAttempts when isWin is false, as per the calling context in submitGuess
432+
stats.guessDistribution[attempts - 1]++;
429433
}
430434
localStorage.setItem("stats", JSON.stringify(stats));
431435
displayStats();

0 commit comments

Comments
 (0)