|
@ -194,6 +194,27 @@ void handleGame(){ |
|
|
} |
|
|
} |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
bool playerHasWon( bool board[BORAD_SIZE][BORAD_SIZE]){ |
|
|
|
|
|
bool player = 1; |
|
|
|
|
|
// Überprüfe Zeilen und Spalten |
|
|
|
|
|
for (int i = 0; i < 3; i++) { |
|
|
|
|
|
// Überprüfe Zeilen |
|
|
|
|
|
if ((board[i][0] == player && board[i][1] == player && board[i][2] == player) || |
|
|
|
|
|
// Überprüfe Spalten |
|
|
|
|
|
(board[0][i] == player && board[1][i] == player && board[2][i] == player)) { |
|
|
|
|
|
return true; // Spieler hat gewonnen |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
// Überprüfe Diagonalen |
|
|
|
|
|
if ((board[0][0] == player && board[1][1] == player && board[2][2] == player) || |
|
|
|
|
|
(board[0][2] == player && board[1][1] == player && board[2][0] == player)) { |
|
|
|
|
|
return true; // Spieler hat gewonnen |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return false; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
int startGame( int code ){ |
|
|
int startGame( int code ){ |
|
|
if( code == -1 ){ // command test |
|
|
if( code == -1 ){ // command test |
|
|
return 1; |
|
|
return 1; |
|
|