from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Instruction(Page): timeout_seconds = 60 def is_displayed(self): return self.round_number == 1 class Group_random(Page): timeout_seconds = 20 def is_displayed(self): return self.round_number == 9 class Introduction(Page): timeout_seconds = 60 class Decision1(Page): timeout_seconds = 60 form_model = 'group' form_fields = ['p1_sent_amount'] def is_displayed(self): return self.player.id_in_group == 1 class DecisionWaitPage(WaitPage): pass class Decision2(Page): timeout_seconds = 60 form_model = 'group' form_fields = ['p2_accept'] def is_displayed(self): return self.player.id_in_group == 2 class DecisionWaitPage2(WaitPage): pass class Introduction2(Page): timeout_seconds = 60 def is_displayed(self): return self.group.p2_accept == 'R' class Decision3(Page): timeout_seconds = 60 form_model = 'group' form_fields = ['p2_sent_amount'] def is_displayed(self): if self.group.p2_accept == 'A': flag = False elif self.player.id_in_group == 2 and self.group.p2_accept == 'R': flag = True else: flag = False return flag class DecisionWaitPage3(WaitPage): pass class Decision4(Page): timeout_seconds = 60 form_model = 'group' form_fields = ['p1_accept'] def is_displayed(self): if self.group.p2_accept == 'A': flag = False elif self.player.id_in_group == 1 and self.group.p2_accept == 'R': flag = True else: flag = False return flag class ResultsWaitPage(WaitPage): after_all_players_arrive = 'set_payoffs' class Results(Page): timeout_seconds = 60 page_sequence = [ Instruction, Group_random, Introduction, Decision1, DecisionWaitPage, Decision2, DecisionWaitPage2, Introduction2, Decision3, DecisionWaitPage3, Decision4, ResultsWaitPage, Results, ]