from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) author = 'Damien Jourdain' doc = """ Wrapping all the results and chosing one of the game for final payment """ class Constants(BaseConstants): name_in_url = 'wrap' players_per_group = None num_rounds = 1 class Subsession(BaseSubsession): pass # def creating_session(self): # for p in self.get_players(): # p.is_mcf = p.participant.vars['is_mcf'] # # p.create_vars class Group(BaseGroup): pass # which_game = models.IntegerField() # def choose_game(self): # which_game = random.randint(0, 1) # selection of the game that will be paid # for p in self.get_players(): # p.which_game = which_game class Player(BasePlayer): # is_mcf = models.BooleanField() earning_1 = models.CurrencyField() earning_2 = models.CurrencyField() earning_3 = models.CurrencyField() # earning_bret = models.CurrencyField() which_game = models.IntegerField() final_earning = models.CurrencyField() def create_vars(self): self.earning_1 = self.participant.vars['earning_1'] self.earning_2 = self.participant.vars['earning_2'] self.earning_3 = self.participant.vars['earning_3'] # self.earning_bret = self.participant.vars['earning_bret'] self.which_game = self.participant.vars['which_game'] self.final_earning = ([self.earning_1, self.earning_2, self.earning_3][self.which_game]) self.participant.payoff = self.final_earning