本文整理汇总了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)
示例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)