stats.time

This commit is contained in:
Adrien MALINGREY 2023-04-22 11:25:21 +02:00
parent c0f38a55e0
commit 1a372a2d9f

11
app.js
View File

@ -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)
}