from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) import random author = 'Avineil Jain' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'allocate_payoffs' players_per_group = 4 num_rounds = 1 section = ['1', '2.1', '2.2', '3'] class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): def set_payoff(self): self.paying_game = random.randint(1,4) self.participant.vars['paying_game'] = self.paying_game self.final_payoff = int(self.participant.vars['game%d_payoff'%(self.paying_game)]) self.participant.vars['final_payoff'] = self.final_payoff self.participant.vars['paying_section'] = Constants.section[self.paying_game -1] paying_game = models.IntegerField(initial=0) final_payoff = models.IntegerField()