当前位置: 首页>>代码示例>>Python>>正文


Python Room.id方法代码示例

本文整理汇总了Python中room.Room.id方法的典型用法代码示例。如果您正苦于以下问题:Python Room.id方法的具体用法?Python Room.id怎么用?Python Room.id使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在room.Room的用法示例。


在下文中一共展示了Room.id方法的3个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。

示例1: loadRooms

# 需要导入模块: from room import Room [as 别名]
# 或者: from room.Room import id [as 别名]
	def loadRooms(self):
		import copy

		rooms = self.db.rooms.find()
		for i in range(0, rooms.count()):   # default is zero
			newRoom = Room(self, rooms[i])
			print newRoom
			print rooms[i]
			newRoom.id = rooms[i]['id']
			if 'items' in rooms[i]:
				for item in rooms[i]['items']:#
					newRoom.items.append(copy.deepcopy(self.items[item]))

			if 'npcs' in rooms[i]:
				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)

			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))
开发者ID:SrMeowMeow,项目名称:redemption-game,代码行数:31,代码来源:game.py

示例2: loadRooms

# 需要导入模块: from room import Room [as 别名]
# 或者: from room.Room import id [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))
开发者ID:SrMeowMeow,项目名称:rd,代码行数:43,代码来源:game.py

示例3: Room

# 需要导入模块: from room import Room [as 别名]
# 或者: from room.Room import id [as 别名]
# Input: 100 seats, lab, name BE
# Expected output: (100, 1, BE)
r1 = Room(100, True, 'BE')
r1.print_room()

# Input: 150 seats, lab, no name
# Expected output: (150, 1, None)
r1 = Room(150, True)
r1.print_room()


# Test setting the ID
# Input: 1
# Expected output: 1
r1.id = 1
print r1.get_id()

# Test default constructor's data population
# Input: just call Room()
# Expected output: TypeError (Insufficient data to print)
r2 = Room()
try:
	r2.print_room()
except TypeError:
	print "Exception caught: TypeError; test successful"

# Test manipulation functions
# Input: 200 seats, lab, name Baskin
# Expected output: (200, 1, Baskin)
r2.add_seats(200)
开发者ID:bpross,项目名称:MyCourses-Scheduler,代码行数:32,代码来源:room_test.py


注:本文中的room.Room.id方法示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。