|
@ -14,14 +14,11 @@ int checkAge(int age) { |
|
|
return age >= MIN_AGE ? 1 : 0; |
|
|
return age >= MIN_AGE ? 1 : 0; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int initializeRandomGenerator() { |
|
|
int initializeRandomGenerator() { |
|
|
srand(time(NULL)); |
|
|
srand(time(NULL)); |
|
|
return 1; // Erfolgreich initialisiert |
|
|
return 1; // Erfolgreich initialisiert |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
int decideGameType() { |
|
|
int decideGameType() { |
|
|
// Rückgabe einer zufälligen Zahl (1 für Schere-Stein-Papier, 2 für Münzwurf) |
|
|
// Rückgabe einer zufälligen Zahl (1 für Schere-Stein-Papier, 2 für Münzwurf) |
|
|
return (rand() % 2) + 1; |
|
|
return (rand() % 2) + 1; |
|
@ -33,9 +30,6 @@ Player playRockPaperScissors() { |
|
|
return (rand() % 3) == 0 ? PLAYER_X : ((rand() % 3) == 1 ? PLAYER_O : EMPTY); |
|
|
return (rand() % 3) == 0 ? PLAYER_X : ((rand() % 3) == 1 ? PLAYER_O : EMPTY); |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
GameResult initializeGame(TicTacToeGame* game) { |
|
|
GameResult initializeGame(TicTacToeGame* game) { |
|
|
// Initialisiere das Spielfeld |
|
|
// Initialisiere das Spielfeld |
|
|
for (int i = 0; i < 3; ++i) { |
|
|
for (int i = 0; i < 3; ++i) { |
|
@ -53,6 +47,7 @@ GameResult initializeGame(TicTacToeGame* game) { |
|
|
// Rückgabe des Ergebnisses |
|
|
// Rückgabe des Ergebnisses |
|
|
return SUCCESS; |
|
|
return SUCCESS; |
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
GameResult makeMove(TicTacToeGame* game, int row, int col) { |
|
|
GameResult makeMove(TicTacToeGame* game, int row, int col) { |
|
|
if (row < 0 || row >= 3 || col < 0 || col >= 3 || game->board[row][col] != EMPTY) { |
|
|
if (row < 0 || row >= 3 || col < 0 || col >= 3 || game->board[row][col] != EMPTY) { |
|
|
return INVALID_MOVE; |
|
|
return INVALID_MOVE; |
|
|