Browse Source

Commit 27 - gewonnen funktionalitt in hauptspiel einbinden

remotes/origin/peter^2
Peter Wiebe 11 months ago
parent
commit
d8b150ea54
  1. 21
      src/main/c/hangman.c

21
src/main/c/hangman.c

@ -20,6 +20,7 @@ char eingabe_buchstabe();
void lade_secret_word(char* secret_word, int level, char* path);
void show_letters(char secret_word[100], char guessed_letters[100]);
int letter_in_secret_word(char guessed_letter, char secret_word[100]);
int has_won(char secret_word[100], char guessed_letters[100]);
void protokoll(){
clear_screen();
@ -176,7 +177,7 @@ void hauptSpiel(int level){
lade_secret_word(secret_word, level, path);
while (attempts < 6) { //um gewinnen erweitern
while (attempts < 6 && won == 0) {
draw_hangman(attempts);
show_letters(secret_word, guessed_letters);
guessed_letter = eingabe_buchstabe();
@ -187,7 +188,7 @@ void hauptSpiel(int level){
else {
attempts++;
}
//gewonnen erweitern
won = has_won(secret_word, guessed_letters);
}
}
@ -325,4 +326,20 @@ int letter_in_secret_word(char guessed_letter, char secret_word[100]){
}
}
return 1;
}
int has_won(char secret_word[100], char guessed_letters[100]){
int occured;
for (int i = 0; i < strlen(secret_word); i++){
occured = 0;
for (int k = 0; k < strlen(guessed_letters); k++){
if (secret_word[i] == guessed_letters[k]){
occured = 1;
}
}
if (occured == 0){
return 0;
}
}
return 1;
}
Loading…
Cancel
Save