|
|
@ -69,59 +69,59 @@ int wasGameWon(char field[3][3]){ |
|
|
|
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]){ |
|
|
|
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]){ |
|
|
|
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] == '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]){ |
|
|
|
if (field[2][2] == field[1][2] && field[1][2] == field[0][2]){ |
|
|
|
winner = PLAYER; |
|
|
|
} |
|
|
|
} |
|
|
|
else if(field[1][1] == 'O'){ |
|
|
|
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]){ |
|
|
|
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]){ |
|
|
|
if (field[2][0] == field[1][1] && field[1][1] == field[0][2]){ |
|
|
|
winner = PLAYER; |
|
|
|
} |
|
|
|
} |
|
|
|
else if(field[0][0] == 'X'){ |
|
|
|
if(field[0][0] == 'X'){ |
|
|
|
if (field[0][0] == field[0][1] && field[0][2] == field[0][1]){ |
|
|
|
winner = COMPUTER; |
|
|
|
} |
|
|
|
else if (field[0][0] == field[1][0] && field[1][0] == field[2][0]){ |
|
|
|
if (field[0][0] == field[1][0] && field[1][0] == field[2][0]){ |
|
|
|
winner = COMPUTER; |
|
|
|
} |
|
|
|
else if (field[0][0] == field[1][1] && field[1][1] == field[2][2]){ |
|
|
|
if (field[0][0] == field[1][1] && field[1][1] == field[2][2]){ |
|
|
|
winner = COMPUTER; |
|
|
|
} |
|
|
|
} |
|
|
|
else if(field[2][2] == 'X'){ |
|
|
|
if(field[2][2] == 'X'){ |
|
|
|
if (field[2][2] == field[2][1] && field[2][2] == field[2][0]){ |
|
|
|
winner = COMPUTER; |
|
|
|
} |
|
|
|
else if (field[2][2] == field[1][2] && field[1][2] == field[0][2]){ |
|
|
|
if (field[2][2] == field[1][2] && field[1][2] == field[0][2]){ |
|
|
|
winner = COMPUTER; |
|
|
|
} |
|
|
|
} |
|
|
|
else if(field[1][1] == 'X'){ |
|
|
|
if(field[1][1] == 'X'){ |
|
|
|
if (field[1][1] == field[0][1] && field[0][1] == field[2][1]){ |
|
|
|
winner = COMPUTER; |
|
|
|
} |
|
|
|
else if (field[1][1] == field[1][0] && field[1][0] == field[1][2]){ |
|
|
|
if (field[1][1] == field[1][0] && field[1][0] == field[1][2]){ |
|
|
|
winner = COMPUTER; |
|
|
|
} |
|
|
|
else if (field[2][0] == field[1][1] && field[1][1] == field[0][2]){ |
|
|
|
if (field[2][0] == field[1][1] && field[1][1] == field[0][2]){ |
|
|
|
winner = COMPUTER; |
|
|
|
} |
|
|
|
} |
|
|
|