From 3e13e77d26784e6319b3d3aab2390735c0abc3af Mon Sep 17 00:00:00 2001 From: adrien <adrien@malingrey.fr> Date: Sun, 14 May 2023 21:22:23 +0200 Subject: [PATCH] restart --- app.js | 30 ++++++++++++++---------------- 1 file changed, 14 insertions(+), 16 deletions(-) diff --git a/app.js b/app.js index fb87dc7..13c558a 100644 --- a/app.js +++ b/app.js @@ -123,7 +123,6 @@ class MinoesTable { this.table = document.getElementById(id) this.rows = this.table.rows.length this.columns = this.table.rows[0].childElementCount - this.init() } init() { @@ -166,7 +165,6 @@ MinoesTable.prototype.init_center = [2, 2] class NextQueue extends MinoesTable { constructor() { super("nextTable") - this.init() } init() { @@ -205,6 +203,7 @@ class Matrix extends MinoesTable { init() { super.init() this.blocks = Array(this.rows).fill().map(() => Array(this.columns)) + this.redraw() } cellIsEmpty(position) { @@ -446,7 +445,6 @@ class Settings { settingsModal.addEventListener('shown.bs.modal', () => { resumeButton.focus() }) - this.init() } load() { @@ -519,7 +517,6 @@ class Stats { constructor() { this.modal = new bootstrap.Modal('#statsModal') this.load() - this.init() } load() { @@ -527,7 +524,7 @@ class Stats { } init() { - levelInput.value = localStorage["startLevel"] + levelInput.value = localStorage["startLevel"] || 1 this.score = 0 this.goal = 0 this.combo = 0 @@ -728,6 +725,18 @@ let nextQueue = new NextQueue() let playing = false let favicon = document.querySelector("link[rel~='icon']") +function restart() { + stats.modal.hide() + holdQueue.init() + stats.init() + matrix.init() + nextQueue.init() + settings.init() + pauseSettings() +} + +restart() + function pauseSettings() { scheduler.clearInterval(fall) scheduler.clearTimeout(lockDown) @@ -925,17 +934,6 @@ function gameOver() { stats.show() } -function restart() { - stats.modal.hide() - holdQueue.init() - stats.init() - matrix.init() - matrix.redraw() - nextQueue.init() - settings.init() - pauseSettings() -} - window.onbeforeunload = function(event) { stats.save() settings.save()