from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Intro(Page): def is_displayed(self): return self.round_number in Constants.switching_rounds #Intro will only be shown in round 1 and 6 class Contribution(Page): form_model = 'player' form_fields = ['contribution'] def vars_for_template(self): #generate variables that we can use later return {'mylabel': f'Invest something from 0 to {self.player.endowment}'} # variable will only exist on this specific page! def contribution_max(self): return self.player.endowment #players cannot insert more than they have as an endowment class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_payoffs() #says that here we will calculate the payoffs class Results(Page): def is_displayed(self): return self.round_number == Constants.num_rounds class FinalResults(Page): def is_displayed(self): return self.round_number == Constants.num_rounds page_sequence = [ Intro, Contribution, ResultsWaitPage, Results, FinalResults ]