From a6c12ae026290794ac6649cdae8e9da72d85f285 Mon Sep 17 00:00:00 2001 From: fdai7775 Date: Tue, 30 Jan 2024 17:43:49 +0000 Subject: [PATCH] refactoring: logic functions for player exchange --- src/main/c/GameTic_Tac_Toe/game.c | 5 +++++ 1 file changed, 5 insertions(+) diff --git a/src/main/c/GameTic_Tac_Toe/game.c b/src/main/c/GameTic_Tac_Toe/game.c index 215f890..a3f3ae2 100644 --- a/src/main/c/GameTic_Tac_Toe/game.c +++ b/src/main/c/GameTic_Tac_Toe/game.c @@ -56,6 +56,10 @@ int isBoardFull() { // Funktion zum Zug eines Spielers +char switchPlayer(char currentPlayer) { + return (currentPlayer == 'X') ? 'O' : 'X'; +} + void makeMove() { int choice; printf("Spieler %c, wähle eine Zahl (1-9): ", currentPlayer); @@ -71,6 +75,7 @@ void makeMove() { makeMove(); // Rekursiver Aufruf, bis ein gültiger Zug gemacht wird } else { board[row][col] = currentPlayer; + currentPlayer = switchPlayer(currentPlayer); } }