from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Choice(Page): form_model = 'player' form_fields = ['choice'] def vars_for_template(self): return { 'payoff_I_call': Constants.payoff_others_call, 'payoff_others_call': Constants.payoff_I_call, 'payoff_no_call': Constants.payoff_no_call, 'players_in_my_group': len(self.group.get_players()), } class DecisionWaitPage(WaitPage): wait_for_all_groups = True class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.subsession.set_payoffs() class Results(Page): def vars_for_template(self): #self.participant.vars['exp08_my_choice'] = self.player.choice #self.participant.vars['exp08_others_choice'] = self.group.get_player_by_id(self.player.id_in_group % 2 + 1).choice #self.participant.vars['exp08_my_payoff'] = self.player.payoff return { 'my_choice': self.player.choice, 'others_choice': [p.choice for p in self.get_others_in_group()], 'my_payoff': self.player.payoff, } class EmptyPage(Page): pass page_sequence = [ Choice, DecisionWaitPage, ResultsWaitPage, EmptyPage, #Results ]