diff --git a/js/game.js b/js/game.js index 753bf42..5126763 100644 --- a/js/game.js +++ b/js/game.js @@ -8,7 +8,7 @@ var nextCpu; var localStats; export async function main() { - localStats = new Stats(); + localStats = new Stats("highScore_cpu"); await (fetch('./js/data.json') .then((response) => response.json()) @@ -42,7 +42,7 @@ function showResult(isCorrect) { document.getElementById("col2").style.backgroundColor = isCorrect ? "lightgreen" : "#FF4444"; - void(isCorrect && (localStats.incrementScore())) + isCorrect ? localStats.incrementScore() : localStats.resetScore(); document.getElementById("highScore").innerText = localStats.highScore; document.getElementById("score").innerText = localStats.score; diff --git a/js/statistics.js b/js/statistics.js index f44c017..b28ed5a 100644 --- a/js/statistics.js +++ b/js/statistics.js @@ -21,6 +21,10 @@ export class Stats { } } + resetScore() { + this.#score = 0; + } + get highScore() { return this.#highScore; }