Skip to content

Commit 79d1dab

Browse files
Merge pull request #2478 from avinashkranjan/deepsource-transform-1dfa4b6f
format code with autopep8
2 parents 5c197cb + 802ef00 commit 79d1dab

File tree

1 file changed

+18
-5
lines changed

1 file changed

+18
-5
lines changed

Text-based Adventure Game/text_based_adv_game.py

Lines changed: 18 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -1,21 +1,25 @@
11
import time
22

3+
34
def print_delay(text, delay=1):
45
print(text)
56
time.sleep(delay)
67

8+
79
def intro():
810
print_delay("You wake up in a dark, mysterious room.")
911
print_delay("You can't remember how you got here.")
1012
print_delay("As you look around, you see two doors in front of you.")
1113
print_delay("One door is red, and the other door is blue.")
1214

15+
1316
def choose_door():
1417
door = ""
1518
while door != "red" and door != "blue":
1619
door = input("Which door do you choose? (red/blue): ").lower()
1720
return door
1821

22+
1923
def red_door_scenario():
2024
print_delay("You open the red door and find yourself in a fiery cave.")
2125
print_delay("There's a dragon sleeping in the middle of the cave!")
@@ -41,6 +45,7 @@ def red_door_scenario():
4145
print_delay("Invalid choice. Please enter 1 or 2.")
4246
red_door_scenario()
4347

48+
4449
def blue_door_scenario():
4550
print_delay("You open the blue door and find yourself in a peaceful garden.")
4651
print_delay("There's a friendly fairy sitting on a bench.")
@@ -61,12 +66,14 @@ def blue_door_scenario():
6166
print_delay("You politely decline the potion.")
6267
print_delay("The fairy understands and smiles at you.")
6368
print_delay("You feel a sense of peace in the garden.")
64-
print_delay("You've chosen a different path, but it's still a happy ending.")
69+
print_delay(
70+
"You've chosen a different path, but it's still a happy ending.")
6571
print_delay("Congratulations! You win!")
6672
else:
6773
print_delay("Invalid choice. Please enter 1 or 2.")
6874
blue_door_scenario()
6975

76+
7077
def secret_room_scenario():
7178
print_delay("You find a hidden passage behind the bookshelf.")
7279
print_delay("You enter a mysterious room filled with ancient artifacts.")
@@ -78,19 +85,22 @@ def secret_room_scenario():
7885
choice = input("Enter 1 or 2: ")
7986

8087
if choice == "1":
81-
print_delay("You take the amulet, and it starts to shine even brighter.")
88+
print_delay(
89+
"You take the amulet, and it starts to shine even brighter.")
8290
print_delay("Suddenly, you feel a surge of power flowing through you.")
8391
print_delay("You've unlocked hidden abilities!")
8492
print_delay("Congratulations! You win!")
8593
elif choice == "2":
8694
print_delay("You decide not to touch anything and leave the room.")
8795
print_delay("As you exit the secret room, you feel a sense of relief.")
88-
print_delay("You've chosen a different path, but it's still a happy ending.")
96+
print_delay(
97+
"You've chosen a different path, but it's still a happy ending.")
8998
print_delay("Congratulations! You win!")
9099
else:
91100
print_delay("Invalid choice. Please enter 1 or 2.")
92101
secret_room_scenario()
93102

103+
94104
def play_game():
95105
intro()
96106
chosen_door = choose_door()
@@ -100,14 +110,17 @@ def play_game():
100110
elif chosen_door == "blue":
101111
blue_door_scenario()
102112

103-
print_delay("You continue exploring and find a hidden door behind a bookshelf.")
113+
print_delay(
114+
"You continue exploring and find a hidden door behind a bookshelf.")
104115
print_delay("Do you want to open the door?")
105116
hidden_door_choice = input("Enter 'yes' or 'no': ").lower()
106117

107118
if hidden_door_choice == "yes":
108119
secret_room_scenario()
109120
else:
110-
print_delay("You decide not to open the hidden door and continue your adventure.")
121+
print_delay(
122+
"You decide not to open the hidden door and continue your adventure.")
123+
111124

112125
if __name__ == "__main__":
113126
play_game()

0 commit comments

Comments
 (0)