-
Notifications
You must be signed in to change notification settings - Fork 0
Expand file tree
/
Copy pathadventure_game.py
More file actions
117 lines (95 loc) · 3.83 KB
/
Copy pathadventure_game.py
File metadata and controls
117 lines (95 loc) · 3.83 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
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
import time
import random
monsters = ["Gorgon", "Kikimora", "Bruxa"]
mymonster = random.choice(monsters)
item = []
def print_pause(message_to_print):
print(message_to_print)
time.sleep(2)
def intro():
print_pause("You find yourself standing in an open field, filled with "
"grass and yellow wildflowers.")
print_pause("Rumor has it that a " + mymonster + " is somewhere around "
"here, and has been terrifying the nearby village.")
print_pause("In front of you is a house.")
print_pause("To your right is a dark cave.")
print_pause("In your hand you hold your trusty (but not very effective) "
"dagger.")
def house():
print_pause("You approach the door of the house.")
print_pause("You are about to knock when the door "
"opens and out steps a " + mymonster + ".")
print_pause("Eep! This is the " + mymonster + "'s house!")
print_pause("The " + mymonster + " attacks you!\n")
if "sword" not in item:
print_pause("You feel a bit under-prepared for this, "
"what with only having a tiny dagger.")
while True:
choice2 = input("Would you like to (1) fight or (2) "
"run away?")
if choice2 == "1":
if "sword" in item:
print_pause("As the " + mymonster + " moves to attack, "
"you unsheath your new sword.")
print_pause("The Sword of Ogoroth shines brightly in "
"your hand as you brace yourself for the "
"attack.")
print_pause("But the " + mymonster + " takes one look at "
"your shiny new toy and runs away!")
print_pause("You have rid the town of the " + mymonster +
". You are victorious!")
else:
print_pause("You do your best...")
print_pause("but your dagger is no match for the "
+ mymonster + ".")
print_pause("You have been defeated!")
play_again()
break
if choice2 == "2":
print_pause("You run back into the field. "
"\nLuckily, you don't seem to have been "
"followed.")
field()
def cave():
if "sword" in item:
print_pause("\nYou peer cautiously into the cave.")
print_pause("You've been here before, and gotten all"
" the good stuff. It's just an empty cave"
" now.")
print_pause("You walk back to the field.")
else:
print_pause("You peer cautiously into the cave.")
print_pause("It turns out to be only a very small cave.")
print_pause("Your eye catches a glint of metal behind a "
"rock.")
print_pause("You have found the magical Sword of Ogoroth!")
print_pause("You discard your silly old dagger and take "
"the sword with you.")
print_pause("You walk back out to the field.")
item.append("sword")
field()
def field():
print_pause("Enter 1 to knock on the door of the house.")
print_pause("Enter 2 to peer into the cave.")
print_pause("What would you like to do?")
while True:
choice1 = input("(Please enter 1 or 2)")
if choice1 == "1":
house()
break
elif choice1 == "2":
cave()
break
def play_again():
again = input("Would you like to play again? (y/n)").lower()
if again == "y":
print_pause("Excellent! Restarting the game...")
play_game()
elif again == "n":
print_pause("Thanks for playing! See you next time.")
else:
play_again()
def play_game():
intro()
field()
play_game()