|
|
@ -56,3 +56,44 @@ void showColumnFullMessage(); |
|
|
|
|
|
|
|
//Funktionsprototyp für showWinMessage |
|
|
|
void showWinMessage(int player); |
|
|
|
|
|
|
|
|
|
|
|
//Write starter function |
|
|
|
int main_function() { |
|
|
|
char board[ROWS][COLS]; |
|
|
|
int currentPlayer = 1; // Spieler 1 beginnt |
|
|
|
|
|
|
|
initializeBoard(board); |
|
|
|
printBoard(board); |
|
|
|
|
|
|
|
int column; |
|
|
|
while (1) { |
|
|
|
printf(YELLOW"Spieler %d, wähle eine Spalte (1-7): "RESET_COLOR, currentPlayer); |
|
|
|
|
|
|
|
scanf("%d", &column); |
|
|
|
if (column < 1 || column > 7) { |
|
|
|
showInvalidInputMessage(); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
column--; |
|
|
|
|
|
|
|
if (isColumnFull(board, column)) { |
|
|
|
showColumnFullMessage(); |
|
|
|
continue; |
|
|
|
} |
|
|
|
|
|
|
|
if (dropPiece(board, column, (currentPlayer == 1) ? 'X' : 'O')) { |
|
|
|
printBoard(board); |
|
|
|
if (checkWin(board, (currentPlayer == 1) ? 'X' : 'O')) { |
|
|
|
showWinMessage(currentPlayer); |
|
|
|
break; |
|
|
|
} |
|
|
|
|
|
|
|
currentPlayer = (currentPlayer == 1) ? 2 : 1; |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
return 0; |
|
|
|
} |
|
|
|
|