Skip to content

Commit fff180a

Browse files
committed
Separate locations into files
1 parent 90e3284 commit fff180a

File tree

4 files changed

+30
-22
lines changed

4 files changed

+30
-22
lines changed

Diff for: .gitignore

+3-1
Original file line numberDiff line numberDiff line change
@@ -1 +1,3 @@
1-
.DS_Store
1+
.DS_Store
2+
__pycache__
3+
test.py

Diff for: locations/entrance.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
entrance = {
2+
"look": {
3+
"output": "You are in the entrance area. Behind you is a broken elevator. In front of you a leather couch. The hallway continues to the [east].",
4+
"next_location_id": None
5+
},
6+
"east": {
7+
"output": "You go east.",
8+
"next_location_id": "hallway1"
9+
},
10+
}

Diff for: locations/hallway.py

+10
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,10 @@
1+
hallway = {
2+
"look": {
3+
"output": "You are in a hallway with a table. The table has a bowl of apples on it. Maybe you can [take] one? The way returns [west].",
4+
"next_location_id": None
5+
},
6+
"west": {
7+
"output": "You go west.",
8+
"next_location_id": "entrance"
9+
},
10+
}

Diff for: main.py

+7-21
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,6 @@
1+
from locations.entrance import entrance
2+
from locations.hallway import hallway
3+
14
welcome_message = """Welcome to CODE World Campus!
25
36
You can navigate with directions such as 'east'.
@@ -8,26 +11,8 @@
811
"""
912

1013
locations = {
11-
"entrance": {
12-
"look": {
13-
"output": "You are in the entrance area. Behind you is a broken elevator. In front of you a leather couch. The hallway continues to the [east].",
14-
"next_location_id": None
15-
},
16-
"east": {
17-
"output": "You go east.",
18-
"next_location_id": "hallway1"
19-
},
20-
},
21-
"hallway1": {
22-
"look": {
23-
"output": "You are in a hallway with a table. The table has a bowl of apples on it. Maybe you can [take] one? The way returns [west].",
24-
"next_location_id": None
25-
},
26-
"west": {
27-
"output": "You go west.",
28-
"next_location_id": "entrance"
29-
},
30-
}
14+
"entrance": entrance,
15+
"hallway1": hallway
3116
}
3217

3318
current_location = locations["entrance"]
@@ -52,4 +37,5 @@
5237
print(current_location["look"]["output"])
5338

5439
else:
55-
print("Please enter a valid command.")
40+
print("Please enter a valid command.")
41+

0 commit comments

Comments
 (0)