from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants class WaitPage1(WaitPage): wait_for_all_groups = True class Introduction(Page): """Description of the game: How to play and returns expected""" pass class ContributeSmallA(Page): """Player: Choose how much to contribute""" def is_displayed(self): return self.player.id_in_group == 1 form_model = 'player' form_fields = ['contribution_small'] class ContributeSmallB(Page): """Player: Choose how much to contribute""" def is_displayed(self): return self.player.id_in_group == 2 form_model = 'player' form_fields = ['contribution_small'] class ContributeMiddleC(Page): """Player: Choose how much to contribute""" def is_displayed(self): return self.player.id_in_group == 3 form_model = 'player' form_fields = ['contribution_middle'] class ContributeLargeD(Page): """Player: Choose how much to contribute""" def is_displayed(self): return self.player.id_in_group == 4 form_model = 'player' form_fields = ['contribution_large'] class ContributeLargeE(Page): """Player: Choose how much to contribute""" def is_displayed(self): return self.player.id_in_group == 5 form_model = 'player' form_fields = ['contribution_large'] class ResultsWaitPage(WaitPage): after_all_players_arrive = 'set_payoffs' body_text = "Waiting for other participants to contribute." class ResultsSmall(Page): """Players payoff: How much each has earned""" def is_displayed(self): return self.player.id_in_group == 1 or self.player.id_in_group == 2 def vars_for_template(self): return dict(total_earnings=self.group.total_contribution * Constants.multiplier) class ResultsMiddle(Page): """Players payoff: How much each has earned""" def is_displayed(self): return self.player.id_in_group == 3 def vars_for_template(self): return dict(total_earnings=self.group.total_contribution * Constants.multiplier) class ResultsLarge(Page): """Players payoff: How much each has earned""" def is_displayed(self): return self.player.id_in_group == 4 or self.player.id_in_group == 5 def vars_for_template(self): return dict(total_earnings=self.group.total_contribution * Constants.multiplier) page_sequence = [WaitPage1, Introduction, ContributeSmallA, ContributeSmallB, ContributeMiddleC, ContributeLargeD, ContributeLargeE, ResultsWaitPage, ResultsSmall, ResultsMiddle, ResultsLarge]