|
60 | 60 | # |
61 | 61 | # * Prints the current room name |
62 | 62 | print(player.room.name) |
| 63 | + print('current items:') |
| 64 | + print(player.bag) |
| 65 | + print('avalible items:') |
| 66 | + print(player.room.items) |
63 | 67 | # * Prints the current description (the textwrap module might be useful here). |
64 | 68 | print(player.room.description) |
65 | 69 | # * Waits for user input and decides what to do. |
|
68 | 72 | print(direction) |
69 | 73 | # |
70 | 74 | # If the user enters a cardinal direction, attempt to move to the room there. |
71 | | - if direction == "n": |
72 | | - player.room = player.room.n_to |
73 | | - elif direction == "s": |
74 | | - player.room = player.room.s_to |
75 | | - elif direction == "e": |
76 | | - player.room = player.room.e_to |
77 | | - elif direction == "w": |
78 | | - player.room = player.room.w_to |
| 75 | + if direction == 'n' or direction == 's' or direction == 'e' or direction == 'w' or direction == 'q': |
| 76 | + if direction == "n": |
| 77 | + player.room = player.room.n_to |
| 78 | + elif direction == "s": |
| 79 | + player.room = player.room.s_to |
| 80 | + elif direction == "e": |
| 81 | + player.room = player.room.e_to |
| 82 | + elif direction == "w": |
| 83 | + player.room = player.room.w_to |
79 | 84 | # If the user enters "q", quit the game. |
80 | | - elif direction == "q": |
81 | | - break |
| 85 | + elif direction == "q": |
| 86 | + print("you've ended the game") |
| 87 | + break |
| 88 | + elif direction == 'get': |
| 89 | + player.bag.append(direction) |
| 90 | + print('You just picked up an item') |
82 | 91 | # Print an error message if the movement isn't allowed. |
83 | 92 | # |
84 | | - else: |
85 | | - print('not a valid direction, please use n, s, e, or w.') |
86 | | - |
87 | | - |
| 93 | + else: |
| 94 | + print('not a valid direction, please use n, s, e, or w.') |
0 commit comments