-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadventure.py
More file actions
64 lines (56 loc) · 2.08 KB
/
adventure.py
File metadata and controls
64 lines (56 loc) · 2.08 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
def get_player_name():
name = input("Welcome, adventurer! What is your name? ")
print(f"Good luck escaping the digital world, {name}!")
return name
def show_inventory(inventory):
if not inventory:
print("Your inventory is empty.")
else:
print("Your inventory contains:")
for item in inventory:
print(f"- {item}")
def cave_level(player_name, inventory):
print("\nYou have entered the mysterious Cave...")
# Add cave level logic here: tasks, choices, puzzles
# Return True if the level is completed, False otherwise
return False # Placeholder
def jungle_level(player_name, inventory):
print("\nYou have stumbled into a dense Jungle...")
# Add jungle level logic here
return False # Placeholder
def city_level(player_name, inventory):
print("\nYou have reached the sprawling City...")
# Add city level logic here
return False # Placeholder
def main():
player_name = get_player_name()
inventory = []
lives = 3
current_level = 1
while lives > 0:
if current_level == 1:
if cave_level(player_name, inventory):
current_level = 2
else:
lives -= 1
print(f"\nOh no! You failed the Cave. You have {lives} lives remaining.")
elif current_level == 2:
if jungle_level(player_name, inventory):
current_level = 3
else:
lives -= 1
print(f"\nUh oh! The Jungle proved too difficult. You have {lives} lives remaining.")
elif current_level == 3:
if city_level(player_name, inventory):
print(f"\nCongratulations, {player_name}! You have escaped the digital world!")
break
else:
lives -= 1
print(f"\nThe City was a dead end! You have {lives} lives remaining.")
else:
print("Error: Invalid level reached.")
break
if lives == 0:
print("\nGame Over. You failed to escape the digital world.")
if __name__ == "__main__":
main()