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


Python Player.gql方法代码示例

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


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

示例1: action

# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import gql [as 别名]
def action(request):
    player = Player.gql("WHERE imei = :1", request.GET['imei']).get()
    
     
    if not player:
        return HttpResponseRedirect("/api/newgame/?imei=%s"%request.GET['imei'])
    player.game_requested = datetime.now()
        
    game = player.game

    if not game:
        return HttpResponseRedirect("/api/newgame/?imei=%s"%request.GET['imei'])

    game.setup(player)

    if request.GET.has_key('queue'):
        game.apply_turn_queue(request.GET['queue'])

    game.check_over()

    if game.is_over: player.game = None

    game.save()
    player.put()
    return HttpResponse(sj.dumps(game.to_response()))
开发者ID:LongMan,项目名称:moubail-checkers,代码行数:27,代码来源:views.py

示例2: new_game

# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import gql [as 别名]
def new_game(request):
    player = Player.gql("WHERE imei = :1", request.GET['imei']).get()
    if not player:
        player = Player(imei = request.GET['imei'])
    player.game_requested = datetime.now()
    player.put()
    # Because there cant be two inequals in one query
    opponents = Player.gql("WHERE game_requested > :1 ", datetime.now() - timedelta(0, 45)).fetch(2)
    opponents = filter(lambda x: x.imei != request.GET['imei'], opponents)
    if opponents:
        opponent = opponents[0]
        player.game_requested, opponent.game_requested = None, None
        game = CheckersGame.create(player1 = opponent, player2 = player)
        player.game, opponent.game = game, game
        game.setup()
        game.put()
        
        player.put()
        opponent.put()
        return HttpResponseRedirect("/api/action/?imei=%s"%request.GET['imei'])
    return HttpResponse(sj.dumps({'status' : 'waiting'}))
开发者ID:LongMan,项目名称:moubail-checkers,代码行数:23,代码来源:views.py

示例3: login

# 需要导入模块: from models import Player [as 别名]
# 或者: from models.Player import gql [as 别名]
def login():
    error = None
    if request.method == 'POST':
        check_user = Player.gql("WHERE username = :username", username=request.form['username'])
        if check_user.count() == 0:
            error = 'Username does not exist'
        elif not verify_password(request.form['password'], check_user.get().password_hash):
            error = "Invalid password"
        else:
            session['logged_in'] = True
            flash('You were logged in')
            return redirect(url_for('show_games'))
    return render_template('login.html', error=error)
开发者ID:keeeeenw,项目名称:AssassinServerAPI,代码行数:15,代码来源:views.py


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