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
评论列表
文章目录