예제 #1
0
파일: pandora.py 프로젝트: alex-games/a1
	def __init__(self, fileName):
		# iterate through the rooms in the database, creating an object for each room.
		self.rooms = {}
		for element in self.getElements(fileName, "room"):
			obj = Room()
			obj.id = element.get("id")
			obj.x = element.get("x")
			obj.y = element.get("y")
			obj.z = element.get("z")
			obj.region = element.get("region")
			obj.terrain = element.get("terrain", "UNDEFINED")
			obj.name = element.findtext("roomname")
			obj.desc = element.findtext("desc")
			obj.note = element.findtext("note")
			obj.exits = []
			for x in element.findall("./exits/exit"):
				newExit = Exit()
				newExit.dir = self.directionNames[x.get("dir")]
				newExit.to = x.get("to")
				newExit.door = x.get("door")
				obj.exits.append(newExit)
			obj.exits.sort(key=lambda k:self.directionNames.values().index(k.dir))
			obj.setCost(obj.terrain)
			# Add a reference to the room object to our self.rooms dict, using the room ID as the key.
			self.rooms[obj.id] = obj
예제 #2
0
 def __init__(self, fileName):
     # iterate through the rooms in the database, creating an object for each room.
     self.rooms = {}
     for element in self.getElements(fileName, "room"):
         obj = Room()
         obj.id = element.get("id")
         obj.x = element.get("x")
         obj.y = element.get("y")
         obj.z = element.get("z")
         obj.region = element.get("region")
         obj.terrain = element.get("terrain", "UNDEFINED")
         obj.name = element.findtext("roomname")
         obj.desc = element.findtext("desc")
         obj.note = element.findtext("note")
         obj.exits = []
         for x in element.findall("./exits/exit"):
             newExit = Exit()
             newExit.dir = self.directionNames[x.get("dir")]
             newExit.to = x.get("to")
             newExit.door = x.get("door")
             obj.exits.append(newExit)
         obj.exits.sort(
             key=lambda k: self.directionNames.values().index(k.dir))
         obj.setCost(obj.terrain)
         # Add a reference to the room object to our self.rooms dict, using the room ID as the key.
         self.rooms[obj.id] = obj
예제 #3
0
def read_room(version, infileobj):
	new_room = Room()
	new_room.name = read_qstring(infileobj)
	new_room.desc = read_qstring(infileobj)
	new_room.dynamicDesc = read_qstring(infileobj)
	new_room.id = str(read_uint32(infileobj))
	new_room.note = read_qstring(infileobj)
	new_room.terrain = terrain_type[read_uint8(infileobj)]
	new_room.light = light_type[read_uint8(infileobj)]
	new_room.align = align_type[read_uint8(infileobj)]
	new_room.portable = portable_type[read_uint8(infileobj)]
	if version >= 030:
		new_room.ridable = ridable_type[read_uint8(infileobj)]
	if version >= 041:
		new_room.sundeath = sundeath_type[read_uint8(infileobj)]
		new_room.mobFlags = mobflags.bits_to_flag_set(read_uint32(infileobj))
		new_room.loadFlags = loadflags.bits_to_flag_set(read_uint32(infileobj))
	else:
		new_room.mobFlags = mobflags.bits_to_flag_set(read_uint16(infileobj))
		new_room.loadFlags = loadflags.bits_to_flag_set(read_uint16(infileobj))
	new_room.updated = bool(read_uint8(infileobj))
	new_room.x = read_int32(infileobj)
	new_room.y = read_int32(infileobj)
	new_room.z = read_int32(infileobj)
	new_room.exits = read_exits(version, infileobj) #[x for x in read_exits(version, infileobj)]
	return new_room
예제 #4
0
파일: mmapper.py 프로젝트: alex-games/a1
def read_room(infileobj):
	new_room = Room()
	new_room.name = read_qstring(infileobj)
	new_room.desc = read_qstring(infileobj)
	new_room.dynamicDesc = read_qstring(infileobj)
	new_room.id = str(read_uint32(infileobj))
	new_room.note = read_qstring(infileobj)
	new_room.terrain = terrain_type[read_uint8(infileobj)]
	new_room.light = light_type[read_uint8(infileobj)]
	new_room.align = align_type[read_uint8(infileobj)]
	new_room.portable = portable_type[read_uint8(infileobj)]
	new_room.ridable = ridable_type[read_uint8(infileobj)]
	new_room.mobFlags = mobflags.bits_to_flag_set(read_uint16(infileobj))
	new_room.loadFlags = loadflags.bits_to_flag_set(read_uint16(infileobj))
	new_room.updated = bool(read_uint8(infileobj))
	new_room.x = read_int32(infileobj)
	new_room.y = read_int32(infileobj)
	new_room.z = read_int32(infileobj)
	new_room.exits = read_exits(infileobj) #[x for x in read_exits(infileobj)]
	return new_room