Skip to content

Commit c93eda6

Browse files
committed
working on items
1 parent e0446d2 commit c93eda6

3 files changed

Lines changed: 26 additions & 18 deletions

File tree

‎src/adv.py‎

Lines changed: 21 additions & 14 deletions
Original file line numberDiff line numberDiff line change
@@ -60,6 +60,10 @@
6060
#
6161
# * Prints the current room name
6262
print(player.room.name)
63+
print('current items:')
64+
print(player.bag)
65+
print('avalible items:')
66+
print(player.room.items)
6367
# * Prints the current description (the textwrap module might be useful here).
6468
print(player.room.description)
6569
# * Waits for user input and decides what to do.
@@ -68,20 +72,23 @@
6872
print(direction)
6973
#
7074
# 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
7984
# 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')
8291
# Print an error message if the movement isn't allowed.
8392
#
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.')

‎src/player.py‎

Lines changed: 3 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,10 +2,11 @@
22
# currently.
33

44
class Player:
5-
def __init__ (self, name, room) :
5+
def __init__ (self, name, room, bag) :
66
self.name = name
77
self.room = room
8+
self.bag = bag
89

9-
player1 = Player("John Snow", "beyondthewall")
10+
player1 = Player("John Snow", "beyondthewall", [])
1011

1112
print(player1.name)

‎src/room.py‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,7 @@
22
# description attributes.
33

44
class Room:
5-
def __init__ (self, name, description) :
5+
def __init__ (self, name, description, items) :
66
self.name = name
77
self.description = description
8-
self.items = []
8+
self.items = items

0 commit comments

Comments
 (0)