From fbe98a9f624723744e1b8add7c101ed83b395d3d Mon Sep 17 00:00:00 2001 From: Saba Fazlali Date: Wed, 31 Jan 2024 14:11:25 +0100 Subject: [PATCH] Game Over --- cmake-build-debug/.ninja_deps | Bin 10232 -> 12840 bytes cmake-build-debug/.ninja_log | 6 ++++++ .../src/main/c/Hangman/word_selector.c.o | Bin 3072 -> 3072 bytes src/main/c/Hangman/playHangman.c | 9 ++++++--- src/main/c/Hangman/playHangman.h | 1 + 5 files changed, 13 insertions(+), 3 deletions(-) diff --git a/cmake-build-debug/.ninja_deps b/cmake-build-debug/.ninja_deps index 884aefbf537551877b2baf6c41e2bbd0018e5860..7d5b5d0938bbe3b64c05a200b6d3367d5925ad09 100644 GIT binary patch delta 565 zcmez2zanMB4|UN3Muvs}1_lNnIhmIM1?$BFf$X5o3uVn2CqGb06HYEIDoV{O2`))2 zN!3f%%V%JiJ6TuWM*vlvVGc-814S@{VfO$3|CcZ@G$a9y+@Aw6J{ibPnY>VTGGo9* zLDR{0svN=vIf<1XiFxU{iFptk7-oU3KoMtPm&V zVoqjND%`B;Fi8SZuYo%qp*1In2)xslDAx2QBP6)MRvdGbV_ zaL)3~yps45y^Kj{HsvkhFrUJdE;Gqi+$uuB49pqJ3paO=>$!}Gp zJ+pwUY#`17VhLFV#v%vrW delta 7 OcmZ3H^22|_4|M<$G6W+4 diff --git a/cmake-build-debug/.ninja_log b/cmake-build-debug/.ninja_log index 0a3593e..d117789 100644 --- a/cmake-build-debug/.ninja_log +++ b/cmake-build-debug/.ninja_log @@ -7,3 +7,9 @@ 0 106 1706551301992114407 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/drawHangman.c.o de5f7edc6c2379d7 1 44 1706122039878920765 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Template/game100.c.o 69a5bcd8c57a43b3 106 195 1706551302079685763 pmuw_projekt_notebinder fbb48fd3bf0b96c1 +0 213 1706706276607336012 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/word_selector.c.o fab41de4b8cc0421 +1 214 1706706276607356095 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/currentState.c.o c4eef1ff589ab182 +1 214 1706706276608460832 CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/playHangman.c.o f2e2af7048638ee6 +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 diff --git a/cmake-build-debug/CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/word_selector.c.o b/cmake-build-debug/CMakeFiles/pmuw_projekt_notebinder.dir/src/main/c/Hangman/word_selector.c.o index d4f2c70953be0c024e5cd4578c85474bcb7f1b00..a81ae5130f1cae010503c93b8dbee5158b1c90e5 100644 GIT binary patch delta 41 xcmZpWXpq>z&(6p^S%BS(Uurf30|O`1#F{`x1_nmC&6(_x%#4zo4|CZv0syla2$KK+ delta 41 xcmZpWXpq>z&(6p`S%BS(Uv4%70|O`1#F{`x1_nl@&6(_x%#5;|4|CZv0sypC2%`W1 diff --git a/src/main/c/Hangman/playHangman.c b/src/main/c/Hangman/playHangman.c index 178c872..e90d030 100644 --- a/src/main/c/Hangman/playHangman.c +++ b/src/main/c/Hangman/playHangman.c @@ -46,14 +46,17 @@ void playHangman(char *wordToGuess) { mistakes++; } - // Check if the player guessed all the letters + // Win: Check if the player guessed all the letters 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){ + currentState(currentGuess, mistakes); + printf("Oops! You have no more guesses :( \n The answer was: %s \n", wordToGuess); + } } } \ No newline at end of file diff --git a/src/main/c/Hangman/playHangman.h b/src/main/c/Hangman/playHangman.h index c28fb46..6a96e42 100644 --- a/src/main/c/Hangman/playHangman.h +++ b/src/main/c/Hangman/playHangman.h @@ -9,4 +9,5 @@ #include "initializeHangman.c" #include "rules.c" #include "currentState.c" +#include "drawHangman.c" #endif //PMUW_PROJEKT_NOTEBINDER_PLAYHANGMAN_H