本文整理汇总了Python中models.Player.order方法的典型用法代码示例。如果您正苦于以下问题:Python Player.order方法的具体用法?Python Player.order怎么用?Python Player.order使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Player
的用法示例。
在下文中一共展示了Player.order方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: join
# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import order [as 别名]
def join():
# get username, gameId from POST
if request.method == 'POST':
username = request.form['username']
session['username'] = username
clientId = random.randrange(0, 10000)
session['clientId'] = clientId #TODO(junjun): random id
gameId = session['gameId']
# create player
player = Player(name=username, clientId=clientId)
curSize = Player.query.filter_by(game_id = gameId).count()
player.order = curSize
db.session.add(player)
# add player to game
game = Game.query.filter_by(id = gameId).first()
game.players.append(player)
game.numRounds = game.numRounds + 1
db.session.commit()
p['game' + str(gameId)].trigger('playerJoin', {'newPlayer': {'name': username}})
return "joined"
abort(401)