diff --git a/cmake-build-debug/.ninja_deps b/cmake-build-debug/.ninja_deps index 7d5b5d0..b396b92 100644 Binary files a/cmake-build-debug/.ninja_deps and b/cmake-build-debug/.ninja_deps differ diff --git a/cmake-build-debug/.ninja_log b/cmake-build-debug/.ninja_log index d117789..5f3acae 100644 --- a/cmake-build-debug/.ninja_log +++ b/cmake-build-debug/.ninja_log @@ -13,3 +13,5 @@ 1 214 1706706276607344137 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/drawHangman.c.o de5f7edc6c2379d7 1 214 1706706276607374928 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/rules.c.o cdaff7b94c55641c 1 214 1706706276607365429 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/initializeHangman.c.o 7d64de4520ec9e97 +1 43 1706797998872539655 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/drawHangman.c.o de5f7edc6c2379d7 +2 56 1706797998885305995 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/playHangman.c.o f2e2af7048638ee6 diff --git a/cmake-build-debug/Testing/Temporary/LastTest.log b/cmake-build-debug/Testing/Temporary/LastTest.log index f24ee92..4dbb2b2 100644 --- a/cmake-build-debug/Testing/Temporary/LastTest.log +++ b/cmake-build-debug/Testing/Temporary/LastTest.log @@ -1,3 +1,3 @@ -Start testing: Jan 31 13:25 CET +Start testing: Feb 01 15:14 CET ---------------------------------------------------------- -End testing: Jan 31 13:25 CET +End testing: Feb 01 15:14 CET diff --git a/src/main/c/Hangman/currentState.c b/src/main/c/Hangman/currentState.c index 6ee9bac..e4bc459 100644 --- a/src/main/c/Hangman/currentState.c +++ b/src/main/c/Hangman/currentState.c @@ -3,4 +3,5 @@ void currentState(char *currentGuess, int mistakes) { printf("Current Word: %s \n", currentGuess); printf("Mistakes Made: %d/6 \n", mistakes); + drawHangman(mistakes); } \ No newline at end of file diff --git a/src/main/c/Hangman/currentState.h b/src/main/c/Hangman/currentState.h index 41a99ec..dbf10bf 100644 --- a/src/main/c/Hangman/currentState.h +++ b/src/main/c/Hangman/currentState.h @@ -1,4 +1,5 @@ #ifndef PMUW_PROJEKT_NOTEBINDER_CURRENTSTATE_H #define PMUW_PROJEKT_NOTEBINDER_CURRENTSTATE_H #include +#include "drawHangman.c" #endif //PMUW_PROJEKT_NOTEBINDER_CURRENTSTATE_H diff --git a/src/main/c/Hangman/drawHangman.c b/src/main/c/Hangman/drawHangman.c index 4a78ad5..46bed5b 100644 --- a/src/main/c/Hangman/drawHangman.c +++ b/src/main/c/Hangman/drawHangman.c @@ -72,7 +72,7 @@ void drawHangman(int incorrectGuesses) { printf("=========\n"); } - if (incorrectGuesses >= 7) { + if (incorrectGuesses >= 6) { printf(" \n"); printf(" __ _ __ _ _ __ ___ ___ _____ _____ _ __ \n"); printf(" / _` |/ _` | '_ ` _ \\ / _ \\ / _ \\ \\ / / _ \\ '__|\n"); diff --git a/src/main/c/Hangman/playHangman.c b/src/main/c/Hangman/playHangman.c index e90d030..31cfb79 100644 --- a/src/main/c/Hangman/playHangman.c +++ b/src/main/c/Hangman/playHangman.c @@ -1,9 +1,10 @@ #include "playHangman.h" + void playHangman(char *wordToGuess) { int mistakes = 0; - char guessedLetters[30]; //guessed letters - char currentGuess[50]; //current state of the guessed word + char guessedLetters[30]; //Guessed letters + char currentGuess[50]; //Current state of the guessed word // Initialize the current guess and print the rules initializeHangman(wordToGuess, currentGuess); @@ -17,7 +18,7 @@ void playHangman(char *wordToGuess) { printf("Enter your guess: \n"); scanf(" %c", &guess); - // check if the guess is lower case and is a letter (valid) + // Check if the guess is lower case and is a letter (valid) if (!isalpha(guess) || isupper(guess)) { printf("Please enter a valid lowercase alphabet.\n"); continue; @@ -42,19 +43,19 @@ void playHangman(char *wordToGuess) { } // Update mistakes (if the guess is wrong) - if(!found){ + if (!found) { mistakes++; } // Win: Check if the player guessed all the letters - if (strcmp(currentGuess,wordToGuess) == 0){ + if (strcmp(currentGuess, wordToGuess) == 0) { currentState(currentGuess, mistakes); printf("Bravo! You guessed the word: %s \n", wordToGuess); break; } // Lose: Print the answer + game over - if (mistakes == MAX_MISTAKES){ + if (mistakes == MAX_MISTAKES) { currentState(currentGuess, mistakes); printf("Oops! You have no more guesses :( \n The answer was: %s \n", wordToGuess); } diff --git a/src/main/c/Hangman/playHangman.h b/src/main/c/Hangman/playHangman.h index 6a96e42..ca1348e 100644 --- a/src/main/c/Hangman/playHangman.h +++ b/src/main/c/Hangman/playHangman.h @@ -1,7 +1,3 @@ -// -// Created by Saba Fazlali on 31.01.24. -// - #ifndef PMUW_PROJEKT_NOTEBINDER_PLAYHANGMAN_H #define PMUW_PROJEKT_NOTEBINDER_PLAYHANGMAN_H #include @@ -10,4 +6,5 @@ #include "rules.c" #include "currentState.c" #include "drawHangman.c" -#endif //PMUW_PROJEKT_NOTEBINDER_PLAYHANGMAN_H +#include "word_selector.c" +#endif //PMUW_PROJEKT_NOTEBINDER_PLAYHANGMAN_H \ No newline at end of file