views.py 文件源码

python
阅读 22 收藏 0 点赞 0 评论 0

项目:TeleGiphy 作者: JessicaNgo 项目源码 文件源码
def gameplay_context(game, token):
    if game.current_round > 1:
        # gif from last player
        received_gif = game.gameround_set.get(round_number=game.current_round - 1).giphy_url
    else:
        # if roundnumber of game is 1 (first turn)
        received_gif = ""
    try:
        game_round = game.gameround_set.get(round_number=game.current_round)
        gif = game_round.giphy_url
        phrase = game_round.user_text
    # no phrase has been entered by the player yet
    except:
        gif = static('img/giphy_static.gif')
        phrase = ""

    context = {
        'token': token,
        'game': game,
        'gif': gif,
        'phrase': phrase,
        'received_gif': received_gif
    }
    return context


# Creates context for multiplayer games
评论列表
文章目录


问题


面经


文章

微信
公众号

扫码关注公众号