from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Introduction(Page): form_model = 'player' class Color_B(Page): form_model = 'group' form_fields = ['Color_Second'] def is_displayed(self): if self.player.id_in_group == 2 and self.group.Iden == 'Min': return True class Color_AWaitPage(WaitPage): pass class Color_A(Page): form_model = 'group' form_fields = ['Color_First'] def is_displayed(self): if self.player.id_in_group == 1 and self.group.Iden == 'Min': return True class Political_B(Page): form_model = 'group' form_fields = ['Political_Second'] def is_displayed(self): if self.player.id_in_group == 2 and self.group.Iden == 'Pol': return True class Political_AWaitPage(WaitPage): pass class Political_A(Page): form_model = 'group' form_fields = ['Political_First'] def is_displayed(self): if self.player.id_in_group == 1 and self.group.Iden == 'Pol': return True class Send(Page): form_model = 'group' form_fields = ['sent_amount'] def is_displayed(self): if self.group.Type == 'treatment' and self.player.id_in_group == 1 and self.group.Iden == 'Min': return True class SendT(Page): form_model = 'group' form_fields = ['sent_amount'] def is_displayed(self): if self.group.Type == 'treatment' and self.player.id_in_group == 1 and self.group.Iden == 'Pol': return True class SendC(Page): form_model = 'group' form_fields = ['sent_amount'] def is_displayed(self): if self.group.Type == 'control' and self.player.id_in_group == 1 and self.group.Iden == 'Min': return True class SendCP(Page): form_model = 'group' form_fields = ['sent_amount'] def is_displayed(self): if self.group.Type == 'control' and self.player.id_in_group == 1 and self.group.Iden == 'Pol': return True class SendBackWaitPage(WaitPage): pass class SentBackTWaitPage(WaitPage): pass class SendBack(Page): form_model = 'group' form_fields = ['sent_back_amount'] def is_displayed(self): if self.group.Type == 'treatment' and self.player.id_in_group == 2 and self.group.Iden == 'Min': return True 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 SendBackT(Page): form_model = 'group' form_fields = ['sent_back_amount'] def is_displayed(self): if self.group.Type == 'treatment' and self.player.id_in_group == 2 and self.group.Iden == 'Pol': return True 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 SendBackC(Page): form_model = 'group' form_fields = ['sent_back_amount'] def is_displayed(self): if self.group.Type == 'control' and self.player.id_in_group == 2 and self.group.Iden == 'Min': return True 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 SendBackCP(Page): form_model = 'group' form_fields = ['sent_back_amount'] def is_displayed(self): if self.group.Type == 'control' and self.player.id_in_group == 2 and self.group.Iden == 'Pol': return True 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 ResultsWaitPage(WaitPage): 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 = [Introduction, Color_B, Color_AWaitPage, Color_A, Political_B, Political_AWaitPage, Political_A, Send, SendT, SendC, SendCP, SendBackWaitPage, SentBackTWaitPage, SendBack, SendBackT, SendBackC, SendBackCP, ResultsWaitPage, Results]