from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import random def vars_for_all_templates(self): return { 'amount': self.player.participant.vars['amount'], 'list_M3': self.player.participant.vars['list_M3'], 'list_M3_choice': self.player.participant.vars['list_M3_choice'], 'round_number' : self.round_number, 'result_M3': self.player.participant.vars['result_M3'], 'result_M3_choice': self.player.participant.vars['result_M3_choice'], } class Static(Page): form_model = 'player' form_fields = ['Choice'] def vars_for_template(self): return { 'list': self.player.participant.vars['amount'][self.round_number-1], 'money1': self.player.participant.vars['amount'][self.round_number - 1][0], 'money2': self.player.participant.vars['amount'][self.round_number - 1][1], 'money3': self.player.participant.vars['amount'][self.round_number - 1][2], } def before_next_page(self): self.player.lottery= ' '.join(str(e) for e in self.player.participant.vars['amount'][self.round_number-1]) self.player.participant.vars['choice_M3'].append(self.player.Choice) if self.player.Choice == 3: self.player.Choice =1 if self.player.round_number == 2: self.player.participant.vars['result_M3'] = self.player.participant.vars['amount'][self.round_number-1] self.player.participant.vars['result_M3_choice'] = self.player.Choice class Next(Page): def is_displayed(self): return self.round_number < Constants.num_rounds def vars_for_template(self): return { 'round_number': self.round_number +1, } class Next_2(Page): def is_displayed(self): return self.round_number == Constants.num_rounds page_sequence = [Static, Next, Next_2]