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""" pass class Contribute(Page): """Player: Choose how much to contribute""" form_model = 'player' form_fields = ['contribution'] def vars_for_template(self): return { 'player_in_previous_rounds': self.player.in_previous_rounds(), } class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_payoffs() body_text = "Waiting for other participants to contribute." class Results(Page): """Players payoff: How much each has earned""" def is_displayed(self): return self.round_number == Constants.num_rounds def vars_for_template(self): player_in_all_rounds = self.player.in_all_rounds() return { 'total_payoff': sum( [p.payoff for p in player_in_all_rounds]), 'paying_round': self.session.vars['paying_round'], 'player_in_all_rounds': player_in_all_rounds, } # def vars_for_template(self): # return { # 'total_earnings': self.group.total_contribution * Constants.multiplier, # } page_sequence = [ Introduction, Contribute, ResultsWaitPage, Results ]