-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathadventure.py
57 lines (44 loc) · 1.83 KB
/
adventure.py
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
from world.locations import locations
from actions.go import go
from actions.look import look, print_location_info
from actions.show import show_inventory
from take import take
from actions.help import get_help, print_general_help
from replies import snarky_replies
import keywords
print_general_help()
location_name = keywords.Location.SCHOOLHOUSE_ENTRY
inventory = {}
show_new_location_info = True
while True:
if show_new_location_info:
print_location_info(location_name, locations[location_name])
show_new_location_info = False
command_string = ""
while command_string == "":
command_string = input("-- adventure -- # ")
if command_string == "exit":
print("\n\nsee ya later...\n\n")
exit()
command = command_string.lower().split()
action = command[0]
# ---- GO action ------------------------------------------------
if action in keywords.go_words:
show_new_location_info, new_location_name = go(location_name, command)
location_name = new_location_name
continue
# ---- LOOK action ------------------------------------------------
elif action in keywords.look_words:
look(location_name, command, inventory)
# ----- TAKE action -----------------------------------------------
elif action in keywords.take_words:
take(locations[location_name], command, inventory)
# ----- SHOW action -----------------------------------------------
elif action == keywords.Action.SHOW:
if len(command) > 1 and command[1] == keywords.General.INVENTORY:
show_inventory(inventory)
# ----- HELP action -----------------------------------------------
elif action == keywords.Action.HELP:
get_help(command)
else:
print(f"sorry it seems the developer has not implemented the action {action} yet!")