Browse Source

refactoring: Ändere variabel currentPlayer zu Player

remotes/origin/Ahmad
fdai7726 11 months ago
parent
commit
e4024a180d
  1. 12
      src/main/c/VierGewinnt.c

12
src/main/c/VierGewinnt.c

@ -34,14 +34,14 @@ void showWinMessage(int player);
int main_function() { int main_function() {
char board[ROWS][COLS]; char board[ROWS][COLS];
int currentPlayer = 1;
int Player = 1;
initializeBoard(board); initializeBoard(board);
printBoard(board); printBoard(board);
int column; int column;
while (1) { while (1) {
printf(YELLOW"Spieler %d, wähle eine Spalte (1-7): "RESET_COLOR, currentPlayer);
printf(YELLOW"Spieler %d, wähle eine Spalte (1-7): "RESET_COLOR, Player);
scanf("%d", &column); scanf("%d", &column);
if (column < 1 || column > 7) { if (column < 1 || column > 7) {
@ -56,14 +56,14 @@ int main_function() {
continue; continue;
} }
if (dropPiece(board, column, (currentPlayer == 1) ? 'X' : 'O')) {
if (dropPiece(board, column, (Player == 1) ? 'X' : 'O')) {
printBoard(board); printBoard(board);
if (checkWin(board, (currentPlayer == 1) ? 'X' : 'O')) {
showWinMessage(currentPlayer);
if (checkWin(board, (Player == 1) ? 'X' : 'O')) {
showWinMessage(Player);
break; break;
} }
currentPlayer = (currentPlayer == 1) ? 2 : 1;
Player = (Player == 1) ? 2 : 1;
} }
} }

Loading…
Cancel
Save