from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants class Introduction(Page): """Description of the game: How to play and returns expected""" timeout_seconds = 40 pass class Contribute(Page): """Player: Choose how much to contribute""" timeout_seconds = 30 form_model = 'player' form_fields = ['contribution'] class ResultsWaitPage(WaitPage): after_all_players_arrive = 'set_payoffs' body_text = "Waiting for other participants to contribute." class Results(Page): """Players payoff: How much each has earned""" timeout_seconds = 30 def vars_for_template(self): return dict(total_earnings=self.group.total_contribution * Constants.multiplier) class Punishplayer(Page): """Would you like to punish a player ?\"""" form_model = 'player' form_fields = ['punishment'] timeout_seconds = 30 class smallPunishedplayer(Page): """Punished player:""" timeout_seconds = 30 class BeforeRound(WaitPage): after_all_players_arrive = 'set_endowment' body_text = "Waiting for other participants to arrive." class WaitPunishmentPage(WaitPage): after_all_players_arrive = 'set_punishment' body_text = "Waiting for other participants to arrive." page_sequence = [Introduction, BeforeRound, Contribute, ResultsWaitPage, Results, Punishplayer, WaitPunishmentPage, smallPunishedplayer]