Only allow moves if there is no winner

This commit is contained in:
Manuel Thalmann 2022-12-15 01:13:49 +01:00
parent de2884c16d
commit 05c935d3fa
No known key found for this signature in database
GPG key ID: 5FD9AD3CCDDBD27B

View file

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