Skip to content

Commit 2401c52

Browse files
committed
Add new comments and update README
1 parent c7fd827 commit 2401c52

File tree

2 files changed

+39
-3
lines changed

2 files changed

+39
-3
lines changed

Zombie-House/README.md

Lines changed: 30 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,7 +9,11 @@ Remix from [original RPG project](https://projects.raspberrypi.org/en/projects/r
99
* Functions
1010
* Lists
1111
* Dictionaries
12-
* Game Loop
12+
* if / else
13+
* for loop
14+
* A "game loop" (using "while True:")
15+
* Formatted String Literals (f-strings)
16+
* try / except
1317

1418
**Objectives:**
1519

@@ -29,6 +33,31 @@ rooms = {
2933
}
3034
}
3135
```
36+
In order to improve the navigation and display the available directions the player can travel, a nested dictionary was introduced so that directions and items are separated (this also fixed a bug in the game).
37+
38+
```python
39+
rooms = {
40+
41+
'Hall' : {
42+
'directions' : {
43+
'south' : 'Kitchen',
44+
'east' : 'Dining Room',
45+
'north' : 'Atrium',
46+
'west' : 'Library'
47+
},
48+
'item' : 'key'
49+
},
50+
51+
'Kitchen' : {
52+
'directions' : {
53+
'north' : 'Hall',
54+
'east' : 'Pantry'
55+
},
56+
'monster' : 'Zombie',
57+
'item' : 'flower'
58+
},
59+
```
60+
3261
Going beyond the original project, this example introduces two new types of objects inside a room: *monster* and *poison* - each being displayed inside the room with the following code:
3362

3463
```python

Zombie-House/main.py

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -49,8 +49,15 @@ def showStatus():
4949
# An inventory, which is initially empty
5050
inventory = []
5151

52-
# A dictionary linking a room to other rooms
53-
# Rooms can contain a monster or poison
52+
'''
53+
A dictionary is used to link a room to other rooms and
54+
define what is contained inside the room.
55+
The directions a player can move are in a nested dictionary.
56+
Rooms can contain an item, monster or poison
57+
An item is something the player can use (protect/defend)
58+
whereas a monster or poison are non-playable (NPC), but can
59+
do damage to a player
60+
'''
5461
rooms = {
5562

5663
'Hall' : {

0 commit comments

Comments
 (0)