-
Notifications
You must be signed in to change notification settings - Fork 0
/
room.py
66 lines (46 loc) · 1.53 KB
/
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
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
from item import *
class Room(object):
""" This class represents a room. """
def __init__(self, game, id, name):
self.id = id
self.name = name;
self.description = ""
self.connections = []
self.game = game
self.__first_enter = True
self.inventory = Inventory()
def __str__(self):
return self.id
def connect(self, room):
self.connections.append(room)
room.connections.append(self)
def disconnect(self, room):
self.connections.remove(room)
room.connections.remove(self)
def get_id(self):
return self.id
def set_name(self, name):
self.name = name
def get_name(self, name):
return self.name
def set_description(self, description):
self.description = description
def get_description(self, description):
return self.description
def get_items(self):
pass
def get_connected_rooms(self):
return self.connections
def enter(self):
if self.__first_enter:
self.__first_enter = False
self.on_first_enter()
self.on_enter()
def leave(self):
self.on_leave()
def on_first_enter(self):
self.game.output_line("You first entered %s" % (self.name))
def on_enter(self):
self.game.output_line("You enter %s" % (self.name))
def on_leave(self):
self.game.output_line("You leave %s" % (self.name))