From b79a8c4a14113b1b7a42f23c63f3cb1db2887d3a Mon Sep 17 00:00:00 2001 From: AUnicornWithNoLife Date: Sun, 11 Apr 2021 21:45:25 +0100 Subject: [PATCH] win checks not working yer --- src/code.js | 33 +++++++++++++++++++++++++++++++++ 1 file changed, 33 insertions(+) diff --git a/src/code.js b/src/code.js index 71805b8..9d7e998 100644 --- a/src/code.js +++ b/src/code.js @@ -63,6 +63,13 @@ function move(id) board[ids[id][0]][ids[id][1]][1].innerHTML = charater; board[ids[id][0]][ids[id][1]][0] = charater; + + var winner = win(); + + if (winner != 0) + { + alert(winner); + } } function win() @@ -99,5 +106,31 @@ function win() } } + // tr bl line + + if (board[0][0][0] != 0) + { + if (board[0][0][0] == board[1][1][0]) + { + if (board[1][1][0] == board[2][2][0]) + { + return board[0][0][0]; + } + } + } + + // tl br line + + if (board[0][2][0] != 0) + { + if (board[0][2][0] == board[1][1][0]) + { + if (board[1][1][0] == board[2][0][0]) + { + return board[0][2][0]; + } + } + } + return 0; } \ No newline at end of file