|
|
@ -52,4 +52,39 @@ bool validateUserInput(int row, int col){ |
|
|
|
} |
|
|
|
} |
|
|
|
return false; |
|
|
|
} |
|
|
|
|
|
|
|
int wasGameWon(char field[3][3]){ |
|
|
|
int winner = NOWINNERYET; |
|
|
|
if(field[0][0] == 'O'){ |
|
|
|
if (field[0][0] == field[0][1] && field[0][2] == field[0][1]){ |
|
|
|
winner = PLAYER; |
|
|
|
} |
|
|
|
else if (field[0][0] == field[1][0] && field[1][0] == field[2][0]){ |
|
|
|
winner = PLAYER; |
|
|
|
} |
|
|
|
else if (field[0][0] == field[1][1] && field[1][1] == field[2][2]){ |
|
|
|
winner = PLAYER; |
|
|
|
} |
|
|
|
} |
|
|
|
else if(field[2][2] == 'O'){ |
|
|
|
if (field[2][2] == field[2][1] && field[2][2] == field[2][0]){ |
|
|
|
winner = PLAYER; |
|
|
|
} |
|
|
|
else if (field[2][2] == field[1][2] && field[1][2] == field[0][2]){ |
|
|
|
winner = PLAYER; |
|
|
|
} |
|
|
|
} |
|
|
|
if(field[1][1] == 'O'){ |
|
|
|
if (field[1][1] == field[0][1] && field[0][1] == field[2][1]){ |
|
|
|
winner = PLAYER; |
|
|
|
} |
|
|
|
else if (field[1][1] == field[1][0] && field[1][0] == field[1][2]){ |
|
|
|
winner = PLAYER; |
|
|
|
} |
|
|
|
else if (field[2][0] == field[1][1] && field[1][1] == field[0][2]){ |
|
|
|
winner = PLAYER; |
|
|
|
} |
|
|
|
} |
|
|
|
return winner; |
|
|
|
} |