from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import random class Instructions(Page): form_model = 'player' def is_displayed(self): return self.round_number == 1 class Stage1(Page): form_model = 'player' form_fields = ['option_choice_1'] def vars_for_template(self): self.player.stage_1() class Stage2(Page): form_model = 'player' form_fields = ['option_choice_2'] def vars_for_template(self): self.player.stage_2() class Round_Results(Page): form_model = 'player' def vars_for_template(self): self.player.final_result() class Final_Results(Page): form_model = 'player' # def is_displayed(self): # return self.round_number == Constants.num_rounds def vars_for_template(self): player_in_all_rounds = self.player.in_all_rounds() return { 'previous_payoffs': [p.final for p in player_in_all_rounds], #'paying_round': self.session.vars['paying_round'], 'player_in_all_rounds': player_in_all_rounds, } class Payment(Page): form_model = 'player' def is_displayed(self): return self.round_number == Constants.num_rounds def vars_for_template(self): player_in_all_rounds = self.player.in_all_rounds() winning_round = self.session.vars['paying_round_pract2'] # winning_player = player_in_all_rounds[winning_round] # final_payment = self.winning_player.final return { 'previous_payoffs': [p.final for p in player_in_all_rounds], 'paying_round': self.session.vars['paying_round_pract2'], 'player_in_all_rounds': player_in_all_rounds, 'winning_round': winning_round } page_sequence = [ Instructions, Stage1, Stage2, Round_Results, Final_Results, Payment ]