Skip to content

Commit 17e0db2

Browse files
committed
Add instructions for adding locations
1 parent 1452e77 commit 17e0db2

File tree

1 file changed

+35
-1
lines changed

1 file changed

+35
-1
lines changed

README.md

+35-1
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,37 @@
11
# CODE World Campus
22

3-
A silly little text adventure.
3+
A silly little text adventure.
4+
5+
## Adding a location
6+
7+
Locations are organized in files. Each location is its own file.
8+
9+
You can add a location by following these steps:
10+
11+
1. Add a file in the **/locations** directory.
12+
2. The file must include a variable defining a dictionary. That dictionary must follow the following structure:
13+
14+
```python
15+
location_variable = {
16+
"USER_INPUT": {
17+
"output": function_name,
18+
"next_location_id": None
19+
}
20+
}
21+
```
22+
23+
Replace the `location_variable` with a unique name.
24+
25+
For each possible user input, add a dictionary. The dictionary must have a `output` and `next_location_id` value.
26+
27+
The `output` should be assigned a function and `return` a string to display to the user.
28+
29+
The `next_location_id` should be any ID available in the `locations` dictionary in the **main.py** file if the user in put should change the location to that place. Use `None` if the location should not be changed.
30+
31+
Define a `"fallback"` as `USER_INPUT` for one of the dictionaries to catch all not-matched user inputs.
32+
33+
Once the room is defined:
34+
35+
1. Import the room's dictionary variable in the **main.py** file.
36+
2. Give the location an ID and define it as _key_ in the `locations` variable of the **main.py** file. Reference the imported room to that key (see other rooms as example).
37+
3. Ensure your room is accessible from anywhere in the existing game by adding its ID string (defined above) as `next_location_id` to another room.

0 commit comments

Comments
 (0)