From 1a372a2d9f497eb28007480d5a30a1faa53fcc09 Mon Sep 17 00:00:00 2001
From: adrien <adrien@malingrey.fr>
Date: Sat, 22 Apr 2023 11:25:21 +0200
Subject: [PATCH] stats.time

---
 app.js | 11 +++++++----
 1 file changed, 7 insertions(+), 4 deletions(-)

diff --git a/app.js b/app.js
index d5d77dc..1c615f3 100644
--- a/app.js
+++ b/app.js
@@ -470,8 +470,12 @@ class Stats {
         return this._goal
     }
 
+    get time() {
+        return new Date() - this.startTime
+    }
+
     clock() {
-        timeCell.innerText = this.timeFormat.format(new Date() - this.startTime)
+        timeCell.innerText = this.timeFormat.format(this.time)
     }
 
     lockDown(nbClearedLines, tSpin) {
@@ -563,7 +567,7 @@ function pause() {
     scheduler.clearTimeout(repeat)
     scheduler.clearInterval(autorepeat)
     scheduler.clearInterval(clock)
-    stats.startTime = new Date() - stats.startTime
+    stats.startTime = stats.time
     resumeButton.disabled = false
     settings.modal.show()
 }
@@ -579,7 +583,6 @@ function newGame(event) {
     levelInput.disabled = true
     resumeButton.innerHTML = "Reprendre"
     event.target.onsubmit = resume
-    settingsModal["data-bs-backdrop"] = ""
     stats.score = 0
     stats.goal = 0
     stats.level = levelInput.valueAsNumber
@@ -595,7 +598,7 @@ function resume(event) {
     document.onkeydown = onkeydown
     document.onkeyup = onkeyup
 
-    stats.startTime = new Date() - stats.startTime
+    stats.startTime = stats.time
     scheduler.setInterval(clock, 1000)
     if (stats.fallPeriod) scheduler.setInterval(fall, stats.fallPeriod)
 }