def game_state_checker(game, state, round_data, users_plots, counter=0):
if counter == SECONDS:
# move to the next state
if state == 'initial':
start_interactive(game, round_data, users_plots)
elif state == 'interactive':
start_outcome(game, round_data, users_plots)
else:
start_initial(game)
return
if state == 'initial':
r = InteractiveRound.objects.filter(game=game, round_order=round_data.get('current_round'), guess=None).count()
if r == 0:
start_interactive(game, round_data, users_plots)
return
elif state == 'interactive':
r = InteractiveRound.objects.filter(game=game, round_order=round_data.get('current_round'),
influenced_guess=None).count()
if r == 0:
start_outcome(game, round_data, users_plots)
return
elif state == 'outcome':
r = InteractiveRound.objects.filter(game=game, round_order=round_data.get('current_round'),
outcome=False).count()
if r == 0:
start_initial(game)
return
counter += 1
task.deferLater(reactor, 1, game_state_checker, game, state, round_data, users_plots, counter).addErrback(
twisted_error)
评论列表
文章目录