import time
import random
def display_intro():
print("You are standing at the entrance of a dark cave.")
print("Your objective is to explore the cave and find the hidden treasure.")
print()
def choose_path():
path = ""
while path.lower() not in ["left", "right", "l", "r"]:
path = input("Will you go left or right? ").lower()
if path == "l":
path = "left"
if path == "r":
path = "right"
return path
def encounter_scenario():
scenarios = [
"You stumbled upon a colony of bats. They startle you but eventually fly away.",
"You found a pile of glittering gems. You collect a few for good luck.",
"A sudden gust of wind blows out your torch. You're left in darkness.",
"You encounter a friendly troll who gives you directions to the treasure.",
"You slip on a wet rock and twist your ankle. You need to rest for a while.",
"You find a hidden passage that leads deeper into the cave.",
"You triggered a trap and rocks start falling. You narrowly escape.",
"You discover a clue that leads you closer to the hidden treasure.",
"You hear distant growls, and decide it's best to turn back for now.",
"You stumble upon a wolf, and he decides to eat you.",
"You found a big cave room without anything inside.",
"You hear a chant in the next rooms but you decide to not go there.",
]
return random.choice(scenarios)
def explore_cave():
display_intro()
encounter_count = 0
while encounter_count < 4:
print("You reach a fork in the cave.")
path = choose_path()
print(f"You venture {path}.")
scenario = encounter_scenario()
print(scenario)
encounter_count += 1
if "treasure" in scenario:
print("Congratulations! You found the hidden treasure!")
break
if "eat" in scenario:
print("You died. Try again!")
break
print()
else:
print("You couldn't find the treasure in time and starved to death.")
if __name__ == "__main__":
explore_cave()