Sunday, 25 May 2025

Better get better Help

# Help Game in Ruby def start_game puts "Welcome to the Help Game!" puts "Your goal is to find the help you need by making the right choices." puts "Let's begin!\n\n" scene1 end def scene1 puts "You are in a dark room. There is a door to your left and right." puts "What do you do?" puts "1. Open the left door." puts "2. Open the right door." print "Enter 1 or 2: " choice = gets.chomp case choice when '1' scene_left when '2' scene_right else puts "Invalid choice. Please try again." scene1 end end def scene_left puts "\nYou entered the left door and see a box labeled 'Help'." puts "Do you want to open it? (yes/no)" print "> " choice = gets.chomp.downcase if choice == 'yes' help_box elsif choice == 'no' puts "You decide not to open the box and go back to the previous room.\n\n" scene1 else puts "Invalid input. Please respond with 'yes' or 'no'." scene_left end end def scene_right puts "\nYou entered the right door and find a puzzle on the wall." puts "Solve the riddle to get help:" puts "'I speak without a mouth and hear without ears. I have nobody, but I come alive with the wind. What am I?'" print "Your answer: " answer = gets.chomp.downcase if answer.include?("echo") puts "Correct! You receive a helpful hint." help_hint else puts "Incorrect. Maybe try again later.\n\n" scene1 end end def help_box puts "\nInside the box, you find a helpful guide!" puts "The guide says: 'Remember, in difficult times, take a deep breath and think clearly.'" puts "Congratulations! You've found the help you needed." end_game end def help_hint puts "\nThe hint is: 'Echo'." puts "Use this clue to guide your next steps." puts "You feel more prepared now.\n\n" end_game end def end_game puts "Thank you for playing the Help Game!" puts "Would you like to play again? (yes/no)" print "> " choice = gets.chomp.downcase if choice == 'yes' start_game else puts "Goodbye!" end end # Start the game start_game

No comments:

Post a Comment