diff --git a/src/main/c/Tim/hangman.c b/src/main/c/Tim/hangman.c index 1a52a87..ab0255d 100644 --- a/src/main/c/Tim/hangman.c +++ b/src/main/c/Tim/hangman.c @@ -104,20 +104,20 @@ void hangman() } printf("\n\n%s\n", displayWord); - while(!wordGuessed(guessWord, displayWord)) + while(1) { printf("Bitte gib einen Buchstaben ein!\n"); scanf(" %c", &userSelection); - if(userSelection == '0') - { - break; - } if(!letterGuessed(userSelection, guessWord, length)) { countWrongGuess++; printf("Der von dir getippte Buchstabe war falsch! Du hast noch %d Versuche.\n", 6-countWrongGuess); } + if(userSelection == '0'||wordGuessed(guessWord, displayWord)||noTrysLeft(countWrongGuess)) + { + break; + } changeLetter(userSelection, guessWord, length, displayWord); drawHangman(countWrongGuess); printf("\n\n%s\n", displayWord); @@ -152,7 +152,6 @@ bool wordGuessed(char x[], char y[]) } } - bool letterGuessed(char x, char y[], int length) { int counter = 0; @@ -185,7 +184,6 @@ bool letterGuessed(char x, char y[], int length) } - void changeLetter(char x, char y[], int length, char ptr[]) { for(int i = 0; i