offline game: fix: reset game doesnt duplicate scores display

This commit is contained in:
AdrienLSH 2024-02-08 09:17:56 +01:00
parent 9e86af9826
commit e669cb21ca

View File

@ -19,6 +19,10 @@ export default class extends AbstractView {
document.getElementById('stopGameButton').onclick = this.stopGame.bind(this); document.getElementById('stopGameButton').onclick = this.stopGame.bind(this);
} }
async leavePage() {
this.game?.cleanup();
}
startGame() { startGame() {
if (this.game == null) { if (this.game == null) {
document.getElementById('startGameButton').innerHTML = 'Reset Game'; document.getElementById('startGameButton').innerHTML = 'Reset Game';
@ -26,6 +30,7 @@ export default class extends AbstractView {
} }
else { else {
document.getElementById('app').removeChild(this.game.canvas); document.getElementById('app').removeChild(this.game.canvas);
document.getElementById('app').removeChild(this.game.scoresDisplay);
this.game.cleanup(); this.game.cleanup();
this.game = new Game; this.game = new Game;
} }