From 05c935d3fae288a30011932d11d13b13fb13a57a Mon Sep 17 00:00:00 2001 From: Manuel Thalmann Date: Thu, 15 Dec 2022 01:13:49 +0100 Subject: [PATCH] Only allow moves if there is no winner --- src/js/Game.js | 11 +++++++---- 1 file changed, 7 insertions(+), 4 deletions(-) diff --git a/src/js/Game.js b/src/js/Game.js index 1ea794d..d795d81 100644 --- a/src/js/Game.js +++ b/src/js/Game.js @@ -257,12 +257,15 @@ export class Game */ addChip(x, y) { - for (let i = Game.#height - 1; i >= 0; i--) + if (!this.winner) { - if (this.board[i][x] === "") + for (let i = Game.#height - 1; i >= 0; i--) { - this.board[i][x] = this.state.currentPlayer; - return true; + if (this.board[i][x] === "") + { + this.board[i][x] = this.state.currentPlayer; + return true; + } } }