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 Contribute(Page): form_model = 'player' form_fields = ['contribution'] def vars_for_template(self): player = self.player return dict(cumulative_payoff = sum([p.payoff for p in player.in_all_rounds()])) class ResultsWaitPage(WaitPage): after_all_players_arrive = 'set_payoffs' body_text = 'Waiting for other participants to contribute.' class Results(Page): form_model = 'player' def vars_for_template(self): player = self.player return dict(total_earnings=self.group.total_contribution * Constants.multiplier, latest_earnings=player.payoff+sum([p.payoff for p in player.in_previous_rounds()])) page_sequence = [Introduction, Contribute, ResultsWaitPage, Results]