Skip to content

Commit 8b09d36

Browse files
style: format code with autopep8
Format code with autopep8 This commit fixes the style issues introduced in e0de1a2 according to the output from Autopep8. Details: None
1 parent 4a92320 commit 8b09d36

File tree

1 file changed

+41
-21
lines changed

1 file changed

+41
-21
lines changed
Lines changed: 41 additions & 21 deletions
Original file line numberDiff line numberDiff line change
@@ -1,97 +1,117 @@
11
import time
22
import random
33

4+
45
def print_slow(text):
56
for char in text:
67
print(char, end='', flush=True)
78
time.sleep(0.05)
89
print()
910

11+
1012
def get_choice(prompt, options):
1113
while True:
1214
print(prompt)
1315
for i, option in enumerate(options, 1):
1416
print(f"{i}. {option}")
1517
try:
16-
choice = int(input("Enter your choice (1-{}): ".format(len(options))))
18+
choice = int(
19+
input("Enter your choice (1-{}): ".format(len(options))))
1720
if 1 <= choice <= len(options):
1821
return choice
1922
else:
2023
print("Invalid input. Please choose a valid option.")
2124
except ValueError:
2225
print("Invalid input. Please enter a number.")
2326

27+
2428
def time_travel_adventure():
2529
print_slow("Welcome to the Time Travel Adventure!\n")
2630
print_slow("You find a mysterious time machine and decide to give it a try.")
27-
31+
2832
inventory = []
2933
health_points = 100
30-
34+
3135
# Starting point - Present
3236
print_slow("\nYou are in the present time.")
33-
choice = get_choice("Where would you like to travel?", ["Go to the past", "Go to the future", "Go to the Medieval Era", "Go to the Space Age"])
34-
37+
choice = get_choice("Where would you like to travel?", [
38+
"Go to the past", "Go to the future", "Go to the Medieval Era", "Go to the Space Age"])
39+
3540
if choice == 1:
3641
print_slow("\nYou traveled to the past.")
3742
# Past storyline and choices here
3843
print_slow("You encountered dinosaurs in the past.")
39-
choice = get_choice("What do you do?", ["Try to befriend them", "Run away"])
44+
choice = get_choice("What do you do?", [
45+
"Try to befriend them", "Run away"])
4046
if choice == 1:
41-
print_slow("You manage to befriend a baby dinosaur. It's a heartwarming moment!")
47+
print_slow(
48+
"You manage to befriend a baby dinosaur. It's a heartwarming moment!")
4249
inventory.append("Dinosaur Egg")
4350
else:
44-
print_slow("You ran away from the dinosaurs and found yourself back in the present.")
51+
print_slow(
52+
"You ran away from the dinosaurs and found yourself back in the present.")
4553
elif choice == 2:
4654
print_slow("\nYou traveled to the future.")
4755
# Future storyline and choices here
4856
print_slow("You arrived in a futuristic city.")
49-
choice = get_choice("What do you do?", ["Explore the city", "Seek help from locals"])
57+
choice = get_choice("What do you do?", [
58+
"Explore the city", "Seek help from locals"])
5059
if choice == 1:
51-
print_slow("You explored the city and had a fascinating experience in the future.")
60+
print_slow(
61+
"You explored the city and had a fascinating experience in the future.")
5262
health_points -= 20
5363
else:
54-
print_slow("The locals are friendly and offer you a tour of their advanced technology.")
64+
print_slow(
65+
"The locals are friendly and offer you a tour of their advanced technology.")
5566
inventory.append("Futuristic Device")
5667
elif choice == 3:
5768
print_slow("\nYou traveled to the Medieval Era.")
5869
# Medieval storyline and choices here
5970
print_slow("You find yourself in a medieval kingdom.")
60-
choice = get_choice("What do you do?", ["Attend a royal feast", "Help a poor villager"])
71+
choice = get_choice("What do you do?", [
72+
"Attend a royal feast", "Help a poor villager"])
6173
if choice == 1:
62-
print_slow("You attended a grand feast at the castle. The king was impressed by your presence.")
74+
print_slow(
75+
"You attended a grand feast at the castle. The king was impressed by your presence.")
6376
inventory.append("Royal Medal")
6477
else:
65-
print_slow("You helped the villager, who turned out to be a powerful sorcerer. He grants you a magical amulet.")
78+
print_slow(
79+
"You helped the villager, who turned out to be a powerful sorcerer. He grants you a magical amulet.")
6680
inventory.append("Amulet of Power")
6781
else:
6882
print_slow("\nYou traveled to the Space Age.")
6983
# Space Age storyline and choices here
7084
print_slow("You are on a space station orbiting a distant planet.")
71-
choice = get_choice("What do you do?", ["Investigate the planet", "Repair the space station"])
85+
choice = get_choice("What do you do?", [
86+
"Investigate the planet", "Repair the space station"])
7287
if choice == 1:
73-
print_slow("You embarked on a planetary exploration mission and made significant scientific discoveries.")
88+
print_slow(
89+
"You embarked on a planetary exploration mission and made significant scientific discoveries.")
7490
inventory.append("Alien Artifact")
7591
else:
76-
print_slow("You successfully repaired the space station and gained the respect of the space crew.")
92+
print_slow(
93+
"You successfully repaired the space station and gained the respect of the space crew.")
7794
inventory.append("Space Suit")
78-
95+
7996
if health_points <= 0:
8097
print_slow("\nYour health is too low to continue the journey. Game Over!")
8198
else:
8299
# Random event during time travel
83100
if random.random() < 0.3:
84-
print_slow("\nDuring your time travel, you encounter a time vortex!")
101+
print_slow(
102+
"\nDuring your time travel, you encounter a time vortex!")
85103
print_slow("You got disoriented but managed to find your way back.")
86104
health_points -= 10
87-
105+
88106
print_slow("\nYou are back in the present time.")
89-
choice = get_choice("What would you like to do?", ["End the game", "Continue the adventure"])
107+
choice = get_choice("What would you like to do?", [
108+
"End the game", "Continue the adventure"])
90109
if choice == 1:
91110
print_slow("\nThanks for playing the Time Travel Adventure!")
92111
else:
93112
print_slow("You decide to embark on another time travel adventure!")
94113
time_travel_adventure()
95114

115+
96116
if __name__ == "__main__":
97117
time_travel_adventure()

0 commit comments

Comments
 (0)