def __init__(self, ref, node): self.location = ref self.characters = [] self.exits = [None] * NUM_DIRS self.altmsg = [None] * NUM_DIRS self.doors = [None] * NUM_DIRS self.foci = {} self.contents = [] self.capacity = 0 self.name = strip_whitespace(required_child(node, 'name').text) self.desc = wordwrap(strip_whitespace(required_child(node, 'desc').text)) for focus in node.findall('focus'): name = required_attribute(focus, 'name') description = wordwrap(strip_whitespace(focus.text)) self.foci[name] = description for exit_node in node.findall('exit'): exit_dir = required_attribute(exit_node, 'dir') exit_target = required_attribute(exit_node, 'target') direction = libsigma.txt2dir(exit_dir) if direction == -1: log('FATAL', "Bad exit direction: '%s'" % exit_dir, exit_code=1) self.exits[direction] = exit_target altmsg = exit_node.get('altmsg') if altmsg: self.altmsg[direction] = altmsg
def __init__(self, ref, node): self.location = ref self.characters = [] self.exits = [None] * NUM_DIRS self.altmsg = [None] * NUM_DIRS self.doors = [None] * NUM_DIRS self.foci = {} self.contents = [] self.capacity = 0 self.name = strip_whitespace(required_child(node, 'name').text) self.desc = wordwrap( strip_whitespace(required_child(node, 'desc').text)) for focus in node.findall('focus'): name = required_attribute(focus, 'name') description = wordwrap(strip_whitespace(focus.text)) self.foci[name] = description for exit_node in node.findall('exit'): exit_dir = required_attribute(exit_node, 'dir') exit_target = required_attribute(exit_node, 'target') direction = libsigma.txt2dir(exit_dir) if direction == -1: log('FATAL', "Bad exit direction: '%s'" % exit_dir, exit_code=1) self.exits[direction] = exit_target altmsg = exit_node.get('altmsg') if altmsg: self.altmsg[direction] = altmsg
def __init__(self, node, area_name): self.exits = {} self.status = DOOR_CLOSED self.lockable = False self.keys = {} for door_exit in node.findall('exit'): exit_room = required_attribute(door_exit, 'room') exit_dir = required_attribute(door_exit, 'dir') if exit_room.find(':') != -1: room_id = exit_room else: room_id = '%s:%s' % (area_name, exit_room) w = World() if not w.rooms.has_key(room_id): log("FATAL", "Invalid room value in door tag", exit_code=1) elif w.rooms[room_id].exits[libsigma.txt2dir(exit_dir)] == None: log("FATAL", "Invalid dir value in door tag", exit_code=1) w.rooms[room_id].doors[libsigma.txt2dir(exit_dir)] = self