|
@ -25,7 +25,22 @@ GameResult initializeGame(TicTacToeGame* game) { |
|
|
// Rückgabe des Ergebnisses |
|
|
// Rückgabe des Ergebnisses |
|
|
return SUCCESS; |
|
|
return SUCCESS; |
|
|
} |
|
|
} |
|
|
|
|
|
GameResult makeMove(TicTacToeGame* game, int row, int col) { |
|
|
|
|
|
if (row < 0 || row >= 3 || col < 0 || col >= 3 || game->board[row][col] != EMPTY) { |
|
|
|
|
|
return INVALID_MOVE; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
game->board[row][col] = game->currentPlayer; |
|
|
|
|
|
|
|
|
|
|
|
GameResult result = checkGameResult(game); |
|
|
|
|
|
|
|
|
|
|
|
if (result == SUCCESS) { |
|
|
|
|
|
// Spielerwechsel, wenn der Zug gültig ist und das Spiel noch läuft |
|
|
|
|
|
game->currentPlayer = (game->currentPlayer == PLAYER_X) ? PLAYER_O : PLAYER_X; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
return result; |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|