From e669cb21ca92dbb1724682381c3c9cda28497e43 Mon Sep 17 00:00:00 2001 From: AdrienLSH Date: Thu, 8 Feb 2024 09:17:56 +0100 Subject: [PATCH] offline game: fix: reset game doesnt duplicate scores display --- frontend/static/js/views/GameOfflineView.js | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/frontend/static/js/views/GameOfflineView.js b/frontend/static/js/views/GameOfflineView.js index 62c3066..a7dc96e 100644 --- a/frontend/static/js/views/GameOfflineView.js +++ b/frontend/static/js/views/GameOfflineView.js @@ -19,6 +19,10 @@ export default class extends AbstractView { document.getElementById('stopGameButton').onclick = this.stopGame.bind(this); } + async leavePage() { + this.game?.cleanup(); + } + startGame() { if (this.game == null) { document.getElementById('startGameButton').innerHTML = 'Reset Game'; @@ -26,6 +30,7 @@ export default class extends AbstractView { } else { document.getElementById('app').removeChild(this.game.canvas); + document.getElementById('app').removeChild(this.game.scoresDisplay); this.game.cleanup(); this.game = new Game; }