From 72cd0c6b44831a3749992ba0c7c66f9e543d8210 Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 20:57:49 +0100 Subject: [PATCH] =?UTF-8?q?Einige=20kleine=20Komfortabilit=C3=A4ts=C3=A4nd?= =?UTF-8?q?erung?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/Tim/hangman.c | 14 +++++++------- src/main/c/Tim/hangman.h | 2 +- 2 files changed, 8 insertions(+), 8 deletions(-) diff --git a/src/main/c/Tim/hangman.c b/src/main/c/Tim/hangman.c index 62f28ff..49b7035 100644 --- a/src/main/c/Tim/hangman.c +++ b/src/main/c/Tim/hangman.c @@ -114,12 +114,12 @@ void hangman() countWrongGuess++; printf("Der von dir getippte Buchstabe war falsch! Du hast noch %d Versuche.\n", POSSIBLE_TRYS-countWrongGuess); } - if(userSelection == '0'||wordGuessed(guessWord, displayWord)||noTrysLeft(countWrongGuess)) + changeLetter(userSelection, guessWord, length, displayWord); + drawHangman(countWrongGuess); + if(userSelection == '0'||wordGuessed(guessWord, displayWord)||noTrysLeft(countWrongGuess,guessWord)) { break; } - changeLetter(userSelection, guessWord, length, displayWord); - drawHangman(countWrongGuess); printf("\n\n%s\n", displayWord); } @@ -143,7 +143,7 @@ bool wordGuessed(char x[], char y[]) { if(strcmp(x,y) == 0) { - printf("Du hast gewonnen!\n"); + printf("Du hast gewonnen!\nDas gesuchte Wort war \"%s\"\n\nHier hast du ein neues Wort zum erraten.\n\n",x); return true; } else @@ -174,7 +174,7 @@ bool letterGuessed(char x, char y[], int length) } if(counter>0) { - printf("Dein gewaehlter Buchstabe %c war ein Treffer! Du hast noch %d Versuche.\n", x); + printf("Dein gewaehlter Buchstabe %c war ein Treffer!\n", x); return true; } else @@ -222,11 +222,11 @@ void drawHangman(int x) printf("%s", hangmanStages[x]); } -bool noTrysLeft(int x) +bool noTrysLeft(int x, char y[]) { if(x == POSSIBLE_TRYS) { - printf("Du hast verloren!\n\n"); + printf("Du hast verloren!\n\nDas gesuchte Wort war \"%s\"\n\nHier hast du ein neues Wort zum erraten.\n\n",y); return true; } else diff --git a/src/main/c/Tim/hangman.h b/src/main/c/Tim/hangman.h index a2d13ab..380e5ab 100644 --- a/src/main/c/Tim/hangman.h +++ b/src/main/c/Tim/hangman.h @@ -8,6 +8,6 @@ bool wordGuessed(char[],char[]); bool letterGuessed(char, char[], int); void changeLetter(char, char[], int, char[]); void drawHangman(int); -bool noTrysLeft(int); +bool noTrysLeft(int,char[]); #endif