from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class maininstructions(Page): def is_displayed(self): return self.round_number ==1 class instructions(Page): def is_displayed(self): return self.round_number == 1 class Practice(Page): form_model = 'group' form_fields = ['sent_amount'] def is_displayed(self): return self.player.id_in_group == 1 def vars_for_template(self): participant = self.participant return { 'redemption_code': participant.label, } class WaitForP1(WaitPage): pass class PracticeBack(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): participant = self.participant return { 'tripled_amount': self.group.sent_amount * Constants.multiplication_factor, 'less_endowment': Constants.endowment - self.group.sent_amount, 'redemption_code': participant.label, 'total_amount': Constants.endowment + self.group.sent_amount * Constants.multiplication_factor, } def sent_back_amount_choices(self): return currency_range( c(0), self.group.sent_amount * Constants.multiplication_factor, c(1) ) #title_text = "Waiting for your partner to make a decision" #body_text = "Once they have made a decision, this page will disappear and you will be asked to make a different decision" class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): group = self.group p1 = group.get_player_by_id(1) p2 = group.get_player_by_id(2) p1.payoff = Constants.endowment - group.sent_amount + group.sent_back_amount p2.payoff = Constants.endowment + group.sent_amount * Constants.multiplication_factor - group.sent_back_amount class Pracresults(Page): def vars_for_template(self): participant = self.participant return { 'tripled_amount': self.group.sent_amount * Constants.multiplication_factor, 'less_endowment': Constants.endowment - self.group.sent_amount, 'redemption_code': participant.label, 'total_amount': Constants.endowment + self.group.sent_amount * Constants.multiplication_factor, } page_sequence = [ instructions, Practice, WaitForP1, PracticeBack, ResultsWaitPage, Pracresults, ]