from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants class Introduction(Page): def vars_for_template(self): return dict( participant_treatment = self.participant.vars['treatment'], participant_endowment = self.participant.vars['endowment_in_stage2'] ) class WaitOthers(WaitPage): after_all_players_arrive = 'set_endowments' class Decision(Page): form_model = 'player' form_fields = ['decision'] def vars_for_template(self): me = self.player opponent = me.other_player() return dict( participant_treatment = self.participant.vars['treatment'], round_number = self.round_number, my_score = me.participant.vars['score_in_stage1'], opponent_score = opponent.participant.vars['score_in_stage1'] ) class ResultsWaitPage(WaitPage): after_all_players_arrive = 'set_payoffs' class Results(Page): def vars_for_template(self): me = self.player opponent = me.other_player() return dict( my_decision=me.decision, opponent_decision=opponent.decision, same_choice=me.decision == opponent.decision, ) def is_displayed(self): return self.round_number == 3 page_sequence = [Introduction, WaitOthers, Decision, ResultsWaitPage, Results]