from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Intro(Page): pass class MyPage(Page): form_model = 'group' form_fields = ['sent_amount'] def is_displayed(self): return self.player.id_in_group == 1 class InstructTest1(Page): form_model = 'group' form_fields = ['test1', 'test3', 'test4'] def is_displayed(self): return self.player.id_in_group == 1 class InstructTest2(Page): form_model = 'group' form_fields = ['test1', 'test2', 'test4'] def is_displayed(self): return self.player.id_in_group == 2 class Offer(Page): form_model = 'group' form_fields = ['sent_back_amount'] def is_displayed(self): return self.player.id_in_group == 2 def vars_for_template(self): tripled_amount = self.group.sent_amount * Constants.multiplier return dict( tripled_amount=tripled_amount, prompt='Please select an amount from 0 to {}'.format(tripled_amount), ) class waitforp1(WaitPage): body_text = 'Waiting for player A to make an offer.' def is_displayed(self): return self.player.id_in_group == 2 class waitforp2(WaitPage): body_text = 'Waiting for player B to make an offer.' def is_displayed(self): return self.player.id_in_group == 1 class Accept(Page): form_model = 'group' form_fields = ['offer_accepted'] def is_displayed(self): return self.player.id_in_group == 1 class ResultsWaitPage(WaitPage): body_text = 'Waiting to finish up the game' after_all_players_arrive = 'set_payoffs' class Results(Page): form_model = 'player' def vars_for_template(self): return dict(tripled_amount=self.group.sent_amount * Constants.multiplier) page_sequence = [ Intro, InstructTest1, InstructTest2, MyPage, waitforp1, Offer, waitforp2, Accept, ResultsWaitPage, Results, ]