本文整理汇总了Python中room.Room.items方法的典型用法代码示例。如果您正苦于以下问题:Python Room.items方法的具体用法?Python Room.items怎么用?Python Room.items使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类room.Room
的用法示例。
在下文中一共展示了Room.items方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: loadRooms
# 需要导入模块: from room import Room [as 别名]
# 或者: from room.Room import items [as 别名]
def loadRooms(self):
rooms = self.db.rooms.find()
for i in range(0, rooms.count()): # default is zero
exists = [r for r in self.rooms if r.id == rooms[i]['id']]
if len(exists) > 0:
newRoom = exists[0]
newRoom.bg = rooms[i]['bg'] if 'bg' in rooms[i] else newRoom.bg
newRoom.desc = rooms[i]['description'] if 'description' in rooms[i] else newRoom.desc
else:
newRoom = Room(self, rooms[i])
newRoom.id = rooms[i]['id']
if newRoom.bg:
print "Has a background!", newRoom.bg
newRoom.items = []
newRoom.exits = []
if 'items' in rooms[i]:
for item in rooms[i]['items']:#
newRoom.items.append(Item(self.items[item]))
if 'npcs' in rooms[i]:
# only respawn if there is NO combat going on in the room to avoid insane duplications! FIX ME
currentMobiles = [mobile for mobile in self.mobiles if mobile.room == newRoom and mobile.combat and not mobile.is_player]
if not len(currentMobiles) > 0:
for mobile in rooms[i]['npcs']:
m = Mobile(self.mobile_list[mobile]['name'], self, self.mobile_list[mobile])
m.room = newRoom
self.mobiles.append(m)
if len(exists) <= 0:
self.rooms.append(newRoom)
# have to load all the rooms BEFORE loading the exits
for i in range(0, rooms.count()):
exits = rooms[i]['exits']
for e in exits:
exit = exits[e]
target_room = next(room for room in self.rooms if room.id == exit['target'])
direction = exit['direction']
self.rooms[i].exits.append(Exit(direction.lower(), target_room))