本文整理汇总了Python中models.Score.recid方法的典型用法代码示例。如果您正苦于以下问题:Python Score.recid方法的具体用法?Python Score.recid怎么用?Python Score.recid使用的例子?那么恭喜您, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类models.Score
的用法示例。
在下文中一共展示了Score.recid方法的1个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: snake_enter_score
# 需要导入模块: from models import Score [as 别名]
# 或者: from models.Score import recid [as 别名]
def snake_enter_score():
status = 'no response'
# make sure scorehash is correct for the given score
score = int(request.form['score'])
scorehash = int(request.form['scorehash'])
if math.sqrt(scorehash - 1337) == score:
if request.form['SNAKE_BLOCK'] == '1':
# create recording string
recTurn = request.form['recTurn']
recFrame = request.form['recFrame']
recFood = request.form['recFood']
recData = urlencode({ 'recTurn':recTurn, 'recFrame':recFrame, 'recFood':recFood })
# add the new score
playerName = g.user.username#request.form['playerName']#re.sub('[&=#<>]', '', request.form['playerName'])
score = Score(player=playerName, score=score, recording=recData)
db.session.add(score)
db.session.commit()
# reset the high scores. the game requests rec#.txt files 0-9 by
# default, so the recid field must be updated for the high scores
# clear out current high scores
for score in Score.query.all():
score.recid = None
db.session.add(score)
db.session.commit()
# update the recid field to set the new high scores
scores = Score.query.order_by(Score.score.desc()).limit(10).all()
for i in range(0, len(scores)):
scores[i].recid = i
db.session.add(scores[i])
db.session.commit()
status = 'ok'
else:
status = 'snake block not present'
else:
status = 'invalid scorehash'
return urlencode({'status':status})