from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Send(Page): form_model = "group" form_fields = ["sent_amount"] def is_displayed(self): return self.player.id_in_group == 1 class P1motivation(Page): form_model = "player" form_fields = [ "twentyone", "twentytwo", "twentythree", "twentyfour", "twentyfive", "twentysix", "twentyseven", "twentyeight", ] def is_displayed(self): return self.player.id_in_group == 1 class SendBackWaitPage(WaitPage): pass class SendBack(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 an amount from 0 to {}".format(tripled_amount), ) class P2motivation(Page): form_model = "player" form_fields = ["twentynine", "thirty", "thirtyone", "thirtytwo", "thirtythree"] def is_displayed(self): return self.player.id_in_group == 2 class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_payoffs() class Results(Page): def vars_for_template(self): return dict(tripled_amount=self.group.sent_amount * Constants.multiplier) page_sequence = [ Send, P1motivation, SendBackWaitPage, SendBack, P2motivation, ResultsWaitPage, Results, ]