From e095b6f8dafaa2f261877ee0feb19d93f31fe9dc Mon Sep 17 00:00:00 2001 From: Luis Hahn Date: Mon, 5 Feb 2024 19:09:45 +0100 Subject: [PATCH] =?UTF-8?q?Hinzuf=C3=BCgen=20einer=20Sicherheitsabfrage=20?= =?UTF-8?q?bei=20Bauernumwandlung,=20Luis=20Hahn?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/Bauernumwandlung.c | 11 ++++++++--- 1 file changed, 8 insertions(+), 3 deletions(-) diff --git a/src/Bauernumwandlung.c b/src/Bauernumwandlung.c index 60be6d2..a8a0055 100644 --- a/src/Bauernumwandlung.c +++ b/src/Bauernumwandlung.c @@ -30,7 +30,7 @@ char* bauer_umwandel_abfrage(char** Brett, int startX, int startY, int endX, int printf("q für Dame, r für Turm, b für Läufer oder n für Springer"); Figur = getUserInput(); } - + if((player == PLAYER_WHITE && (Figur == 'Q' || Figur == 'R' || Figur == 'B' || Figur == 'N')) || (player == PLAYER_BLACK && (Figur == 'q' || Figur == 'r' || Figur == 'b' || Figur == 'n'))){ return Figur; @@ -43,7 +43,12 @@ char* bauer_umwandel_abfrage(char** Brett, int startX, int startY, int endX, int void bauer_umwandeln(char** Brett, int startX, int startY, int endX, int endY, Player player){ - Brett[endY][endX] = bauer_umwandel_abfrage(Brett,startX,startY,endX,endY,player); - Brett[startY][startX] = ' '; + char* Figur = bauer_umwandel_abfrage(Brett,startX,startY,endX,endY,player); + if(Figur != 'W'){ + Brett[endY][endX] = Figur; + Brett[startY][startX] = ' '; + }else{ + printf("Zug ungültig"); + } }