from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Instructions(Page): def is_displayed(self): return self.round_number == 1 class Transfer(Page): form_model = 'group' form_fields = ['transfer'] def is_displayed(self): return self.player.id_in_group == 1 and not self.player.participant.vars['dead'] class FirstWaitPage(WaitPage): def is_displayed(self): return self.player.id_in_group == 2 and not self.player.participant.vars['dead'] class Accept(Page): form_model = 'group' form_fields = ['accept'] def is_displayed(self): return self.player.id_in_group == 2 and self.group.transfer != 0 and not self.player.participant.vars['dead'] def vars_for_template(self): return dict( full_transfer=self.group.transfer*Constants.multiplier ) class Choice(Page): form_model = 'group' form_fields = ['choice'] def is_displayed(self): return self.player.id_in_group == 2 and not self.player.participant.vars['dead'] def vars_for_template(self): if self.group.transfer == 0: no_transfer = True else: no_transfer = False return dict( no_transfer=no_transfer ) class ResultsWaitPage(WaitPage): def is_displayed(self): return not self.player.participant.vars['dead'] after_all_players_arrive = 'set_payoffs' class Results(Page): def is_displayed(self): return not self.player.participant.vars['dead'] class End(Page): def is_displayed(self): return self.round_number == Constants.num_rounds def vars_for_template(self): payoffs =[p.payoff for p in self.player.in_all_rounds()] total = sum(payoffs) dead = self.player.participant.vars['dead'] return dict( total=total, dead=dead ) page_sequence = [Instructions, Transfer, FirstWaitPage, Accept, Choice, ResultsWaitPage, Results, End]