|
@ -2831,6 +2831,72 @@ void b_celebrity(){ |
|
|
|
|
|
|
|
|
} |
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
//Hangman |
|
|
|
|
|
|
|
|
|
|
|
void b_hangman() { |
|
|
|
|
|
char word[MAX_LEN + 1]; |
|
|
|
|
|
char display[MAX_LEN + 1]; |
|
|
|
|
|
char used[26]; |
|
|
|
|
|
int num_wrong_guesses; |
|
|
|
|
|
|
|
|
|
|
|
printf("Welcome to Hangman!\n"); |
|
|
|
|
|
|
|
|
|
|
|
strcpy(word, "hangman"); |
|
|
|
|
|
int i; |
|
|
|
|
|
for (i = 0; i < strlen(word); i++) { |
|
|
|
|
|
display[i] = '-'; |
|
|
|
|
|
} |
|
|
|
|
|
display[i] = '\0'; |
|
|
|
|
|
num_wrong_guesses = 0; |
|
|
|
|
|
memset(used, 0, sizeof used); |
|
|
|
|
|
|
|
|
|
|
|
char guess[MAX_LEN + 1]; |
|
|
|
|
|
int good_guess, already_guessed; |
|
|
|
|
|
while (num_wrong_guesses < MAX_GUESSES && strchr(display, '-') != NULL) { |
|
|
|
|
|
printf("Current word: %s\n", display); |
|
|
|
|
|
printf("You have %d incorrect guesses left.\n", MAX_GUESSES - num_wrong_guesses); |
|
|
|
|
|
printf("Used letters: %s\n", used); |
|
|
|
|
|
printf("Enter your guess: "); |
|
|
|
|
|
scanf("%s", guess); |
|
|
|
|
|
if (strlen(guess) != 1 || !isalpha(*guess)) { |
|
|
|
|
|
printf("Invalid guess. Please enter a single letter.\n"); |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
already_guessed = 0; |
|
|
|
|
|
for (i = 0; i < 26; i++) { |
|
|
|
|
|
if (tolower(guess[0]) == used[i]) { |
|
|
|
|
|
printf("You already used the letter '%c'.\n", tolower(guess[0])); |
|
|
|
|
|
already_guessed = 1; |
|
|
|
|
|
break; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (already_guessed) { |
|
|
|
|
|
continue; |
|
|
|
|
|
} |
|
|
|
|
|
used[i] = tolower(guess[0]); |
|
|
|
|
|
good_guess = 0; |
|
|
|
|
|
for (i = 0; i < strlen(word); i++) { |
|
|
|
|
|
if (tolower(guess[0]) == tolower(word[i])) { |
|
|
|
|
|
display[i] = word[i]; |
|
|
|
|
|
good_guess = 1; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (!good_guess) { |
|
|
|
|
|
printf("Incorrect! The letter '%c' is not in the word.\n", tolower(guess[0])); |
|
|
|
|
|
num_wrong_guesses++; |
|
|
|
|
|
} |
|
|
|
|
|
} |
|
|
|
|
|
if (num_wrong_guesses == MAX_GUESSES) { |
|
|
|
|
|
printf("You lose! The word was '%s'.\n", word); |
|
|
|
|
|
} else { |
|
|
|
|
|
printf("You win! The word was '%s'.\n", word); |
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
} |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
void v_play_rockpapersciss(){ |
|
|
void v_play_rockpapersciss(){ |
|
|
int player_choice, computer_choice, player_score = 0, computer_score = 0; |
|
|
int player_choice, computer_choice, player_score = 0, computer_score = 0; |
|
|
srand(time(NULL)); |
|
|
srand(time(NULL)); |
|
@ -3426,7 +3492,7 @@ int main(int argc, char *argv[]) { |
|
|
|
|
|
|
|
|
int jump_to_menu = 0; |
|
|
int jump_to_menu = 0; |
|
|
|
|
|
|
|
|
while (choice != 24 || jump_to_menu) { |
|
|
|
|
|
|
|
|
while (choice != 25 || jump_to_menu) { |
|
|
printf("Welcome to the Game Menu!\n"); |
|
|
printf("Welcome to the Game Menu!\n"); |
|
|
printf("1. QuizGame\n"); |
|
|
printf("1. QuizGame\n"); |
|
|
printf("2. Fact or Lie?\n"); |
|
|
printf("2. Fact or Lie?\n"); |
|
@ -3451,7 +3517,8 @@ int main(int argc, char *argv[]) { |
|
|
printf("21. Brain whiz\n"); |
|
|
printf("21. Brain whiz\n"); |
|
|
printf("22. Personality Quiz!\n"); |
|
|
printf("22. Personality Quiz!\n"); |
|
|
printf("23. Guess the Celebrity!\n"); |
|
|
printf("23. Guess the Celebrity!\n"); |
|
|
printf("24. Exit\n"); |
|
|
|
|
|
|
|
|
printf("24. Hangman!\n"); |
|
|
|
|
|
printf("25. Exit\n"); |
|
|
printf("Enter your choice: "); |
|
|
printf("Enter your choice: "); |
|
|
scanf("%d", &choice); |
|
|
scanf("%d", &choice); |
|
|
v_progress_bar(argc,argv); |
|
|
v_progress_bar(argc,argv); |
|
@ -3550,6 +3617,10 @@ int main(int argc, char *argv[]) { |
|
|
jump_to_menu = 1; |
|
|
jump_to_menu = 1; |
|
|
break; |
|
|
break; |
|
|
case 24: |
|
|
case 24: |
|
|
|
|
|
b_hangman(); |
|
|
|
|
|
jump_to_menu = 1; |
|
|
|
|
|
break; |
|
|
|
|
|
case 25: |
|
|
printf("\nThank you for trying our C code!\n"); |
|
|
printf("\nThank you for trying our C code!\n"); |
|
|
break; |
|
|
break; |
|
|
default: |
|
|
default: |
|
|