win checks not working yer

This commit is contained in:
AUnicornWithNoLife 2021-04-11 21:45:25 +01:00
parent 7eb078d865
commit b79a8c4a14

View File

@ -63,6 +63,13 @@ function move(id)
board[ids[id][0]][ids[id][1]][1].innerHTML = charater; board[ids[id][0]][ids[id][1]][1].innerHTML = charater;
board[ids[id][0]][ids[id][1]][0] = charater; board[ids[id][0]][ids[id][1]][0] = charater;
var winner = win();
if (winner != 0)
{
alert(winner);
}
} }
function win() 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; return 0;
} }