-
Notifications
You must be signed in to change notification settings - Fork 0
/
room.py
34 lines (25 loc) · 816 Bytes
/
room.py
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
from item import Item
# Having location class at side in case if we have inventory subclass
class Location:
def __init__(self, id, name):
self.id = id
self.name = name
def __repr__(self):
return self.__str__()
def __str__(self):
pass
class Room(Location):
def __init__(self,id,name,short_desc,long_desc):
super().__init__(id,name)
self.short_desc = short_desc
self.long_desc = long_desc
self.neighbours = {
"north" : None,
"east" : None,
"south" : None,
"west" : None }
@property
def items(self):
return [item for item in Item.instances if item.location == self]
def __str__(self):
return "Room: " + self.name