From cbf15a5e395272e36b3471a88fa3ea15ffbcd3e9 Mon Sep 17 00:00:00 2001 From: fdai7727 Date: Thu, 25 Jan 2024 20:55:17 +0100 Subject: [PATCH] =?UTF-8?q?refactoring:=20Einf=C3=BChren=20der=20konstante?= =?UTF-8?q?n=20Variable=20POSSIBLE=5FTRYS?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- src/main/c/Tim/hangman.c | 6 +++--- 1 file changed, 3 insertions(+), 3 deletions(-) diff --git a/src/main/c/Tim/hangman.c b/src/main/c/Tim/hangman.c index ab0255d..62f28ff 100644 --- a/src/main/c/Tim/hangman.c +++ b/src/main/c/Tim/hangman.c @@ -10,6 +10,7 @@ #define MAX_WORD_LENGTH 30 #define STAGENUM 7 #define ASCII_ART_SIZE 1000 +#define POSSIBLE_TRYS 6 char wordlist[LISTSIZE][MAX_WORD_LENGTH] = { @@ -87,7 +88,6 @@ void hangman() int countWrongGuess=0; strcpy(guessWord,getWordFromList(rand() % LISTSIZE)); length = strlen(guessWord); - printf("%s %d\n",guessWord, length); char displayWord[MAX_WORD_LENGTH]; drawHangman(countWrongGuess); @@ -112,7 +112,7 @@ void hangman() if(!letterGuessed(userSelection, guessWord, length)) { countWrongGuess++; - printf("Der von dir getippte Buchstabe war falsch! Du hast noch %d Versuche.\n", 6-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)) { @@ -224,7 +224,7 @@ void drawHangman(int x) bool noTrysLeft(int x) { - if(x == 6) + if(x == POSSIBLE_TRYS) { printf("Du hast verloren!\n\n"); return true;