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


Python Player.location方法代码示例

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


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

示例1: create_player

# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import location [as 别名]
	def create_player(self, name=None, password=None, workfactor=None, location=None, admin=False, sadmin=False, owner=False):
		""" Creates a new instance of a Player.

		Keyword arguments:
			name -- The name of the new Player instance to be used.
			password -- The password that is to be used for the Player.
			workfactor -- The work factor # to be used when hasing the Player's password.
			location -- The ID or instance of Room that the new Player is to be created at.
			admin -- A boolean representing whether or not this new Player is an administrator.
			sadmin -- A boolean representing whether or not this new Player is a super administrator.
			owner -- A boolean representing whether or not this new Player is an owner.

		"""
		if (name is None or password is None or workfactor is None or location is None):
			raise exception.WorldArgumentError('All of the arguments to create_player are mandatory! (or None was passed in)')

		try:
			if (type(location) is int):
					location = self.find_room(id=location)

			player_inventory = self.create_room('%s\'s Inventory' % (name))		
			player = Player(name, password, workfactor, location.id, 0, admin=admin, sadmin=sadmin, owner=owner)
			player.inventory_id = player_inventory.id

			connection = self.connect()
			self.session.add(player)

			location.players.append(player)
			self.session.add(location)

			self.session.add(player_inventory)
			self.session.commit()

			self.session.refresh(player)
			self.session.refresh(player_inventory)
		
			player.location = location
			player.inventory = player_inventory
			player.session = self.session
			player.engine = self.engine
			player.location.session = self.session
			player.location.engine = self.engine
			player.inventory = player_inventory
			player_inventory.session = self.session
			player_inventory.engine = self.engine
			connection.close()
			return player
		except exception.DatabaseError:
			self.session.rollback()
			self.database_status.send(sender=self, status=False)
开发者ID:Ragora,项目名称:ScalyMUCK,代码行数:52,代码来源:world.py

示例2: test_going_thru_red_light

# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import location [as 别名]
 def test_going_thru_red_light(self):
     player_1 = Player('Player 1')
     player_1.location = 3
     player_1.in_motion = True
     self.assertTrue(player_1.in_motion)
开发者ID:Edinunzio,项目名称:redlight,代码行数:7,代码来源:tests.py


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