From 7eb078d865564b9ed152c238ceaa4a1c35084bbe Mon Sep 17 00:00:00 2001 From: AUnicornWithNoLife Date: Sun, 11 Apr 2021 21:39:45 +0100 Subject: [PATCH] Update code.js --- src/code.js | 37 +++++++++++++++++++++++++++++++++++++ 1 file changed, 37 insertions(+) diff --git a/src/code.js b/src/code.js index f797998..71805b8 100644 --- a/src/code.js +++ b/src/code.js @@ -63,4 +63,41 @@ function move(id) board[ids[id][0]][ids[id][1]][1].innerHTML = charater; board[ids[id][0]][ids[id][1]][0] = charater; +} + +function win() +{ + // row + + for (var x = 0; x >= 2; x++) + { + if (board[x][0][0] != 0) + { + if (board[x][0][0] == board[x][1][0]) + { + if (board[x][1][0] == board[x][2][0]) + { + return board[x][0][0]; + } + } + } + } + + // collum + + for (var y = 0; y >= 2; y++) + { + if (board[0][y][0] != 0) + { + if (board[0][y][0] == board[1][y][0]) + { + if (board[1][y][0] == board[2][y][0]) + { + return board[0][y][0]; + } + } + } + } + + return 0; } \ No newline at end of file