from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Instructions(Page): def vars_for_template(self): showupfee = self.session.config['participation_fee'] max_bonus = self.session.config['max_bonus'] return {'showupfee': showupfee, 'max_bonus': max_bonus} class Dictator(Page): form_model = 'player' form_fields = ['kept'] def is_displayed(self): return self.player.game == 1 def vars_for_template(self): image = self.participant.vars['images'] car = self.participant.vars['car'] return {'img_to_show': image, 'car': car} class Trust(Page): form_model = 'player' form_fields = ['sent_amount', 'beliefs_sent_back_amount'] def is_displayed(self): return self.player.game == 2 def vars_for_template(self): image = self.participant.vars['images'] car = self.participant.vars['car'] return {'img_to_show': image, 'car': car} class PublicGood(Page): """Player: Choose how much to contribute""" form_model = 'player' form_fields = ['contribution'] def is_displayed(self): return self.player.game == 3 def vars_for_template(self): image = self.participant.vars['images'] suggested_contribution = self.participant.vars['suggested_contribution'] car = self.participant.vars['car'] return {'img_to_show': image, 'suggested_contribution': suggested_contribution, 'car': car} class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_payoffs() class Results(Page): def before_next_page(self): self.participant.vars['payoff_game2'] = self.player.payoff def vars_for_template(self): return{'iscore1': self.player.participant.vars['iscore1'], 'iscore2': self.player.participant.vars['iscore2'], 'iscore3': self.player.participant.vars['iscore3'], 'iscore4': self.player.participant.vars['iscore4'], 'iscore5': self.player.participant.vars['iscore5'], 'iscore6': self.player.participant.vars['iscore6'], 'iscore7': self.player.participant.vars['iscore7'], 'iscore8': self.player.participant.vars['iscore8'], 'bonus_section1': self.player.participant.vars['bonus_section1'], 'n_times_in_top3': self.player.participant.vars['n_times_in_top3'], 'is_top_one_third' : self.player.participant.vars['top_one_third']} page_sequence = [ Instructions, Dictator, Trust, PublicGood, ResultsWaitPage, Results ]