from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random author = 'Your name here' doc = """ Your app description """ class Constants(BaseConstants): name_in_url = 'payoffApp' players_per_group = 6 num_rounds = 1 class Subsession(BaseSubsession): pass class Group(BaseGroup): pass class Player(BasePlayer): payoff_round = models.IntegerField() final_payoff = models.FloatField() def set_final_payoff(self): self.payoff_round = random.randint(1, 2) if self.payoff_round == 1: self.final_payoff = self.participant.vars['t1'] self.payoff = c(round(self.final_payoff * 0.02, 2)) else: self.final_payoff = self.participant.vars['t2'] self.payoff = c(round(self.final_payoff * 0.02, 2))