Created
July 24, 2018 10:21
-
-
Save ZeroPivot/0d104c9ea10d2fa39bb662696d33498e to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
integer checkWinner(key playingPlayer) | |
{ | |
integer wonOrNot = FALSE; | |
llSay(4, "wait"); | |
//Eight Possibilities | |
if (llList2Key(row1, 0) == playingPlayer && llList2Key(row1, 1) == playingPlayer && llList2Key(row1, 2) == playingPlayer) //Possibility 1 | |
{ | |
llSay(0, llKey2Name(playingPlayer) + " won!"); | |
wonOrNot = TRUE; | |
llSay(4, "ready"); | |
} | |
else | |
if (llList2Key(row2, 0) == playingPlayer && llList2Key(row2, 1) == playingPlayer && llList2Key(row2, 2) == playingPlayer) //Possibility 2 | |
{ | |
llSay(0, llKey2Name(playingPlayer) + " won!"); | |
wonOrNot = TRUE; | |
llSay(4, "ready"); | |
} | |
else | |
if (llList2Key(row3, 0) == playingPlayer && llList2Key(row3, 1) == playingPlayer && llList2Key(row3, 2) == playingPlayer) //Possibility 3 | |
{ | |
llSay(0, llKey2Name(playingPlayer) + " won!"); | |
wonOrNot = TRUE; | |
llSay(4, "ready"); | |
} | |
else | |
if (llList2Key(row1, 0) == playingPlayer && llList2Key(row2, 0) == playingPlayer && llList2Key(row3, 0) == playingPlayer) | |
{ | |
llSay(0, llKey2Name(playingPlayer) + " won!"); | |
wonOrNot = TRUE; | |
llSay(4, "ready"); | |
} | |
else | |
if (llList2Key(row1, 1) == playingPlayer && llList2Key(row2, 1) == playingPlayer && llList2Key(row3, 1) == playingPlayer) | |
{ | |
llSay(0, llKey2Name(playingPlayer) + " won!"); | |
wonOrNot = TRUE; | |
llSay(4, "ready"); | |
} | |
else | |
if (llList2Key(row1, 2) == playingPlayer && llList2Key(row2, 2) == playingPlayer && llList2Key(row3, 2) == playingPlayer) | |
{ | |
llSay(0, llKey2Name(playingPlayer) + " won!"); | |
wonOrNot = TRUE; | |
llSay(4, "ready"); | |
} | |
else | |
if (llList2Key(row1, 0) == playingPlayer && llList2Key(row2, 1) == playingPlayer && llList2Key(row3, 2) == playingPlayer) | |
{ | |
llSay(0, llKey2Name(playingPlayer) + " won!"); | |
wonOrNot = TRUE; | |
llSay(4, "ready"); | |
} | |
else | |
if (llList2Key(row3, 0) == playingPlayer && llList2Key(row2, 1) == playingPlayer && llList2Key(row1, 2) == playingPlayer) | |
{ | |
llSay(0, llKey2Name(playingPlayer) + " won!"); | |
wonOrNot = TRUE; | |
llSay(4, "ready"); | |
} | |
else | |
if (llList2Key(row1, 0) != NULL_KEY && llList2Key(row1, 1) != NULL_KEY && llList2Key(row1, 2) != NULL_KEY && llList2Key(row2, 0) != NULL_KEY && llList2Key(row2, 1) != NULL_KEY && llList2Key(row2, 2) != NULL_KEY && llList2Key(row3, 0) != NULL_KEY && llList2Key(row3, 1) != NULL_KEY && llList2Key(row3, 2) != NULL_KEY) | |
{ | |
llSay(0, "Nobody Won... Resetting Board."); | |
resetGame(); | |
llSay(0, "/reset"); | |
llSay(4, "ready"); | |
} | |
llSay(4, "ready"); | |
return wonOrNot; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment