from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Intro(Page): pass class DelegationChoice(Page): form_model = 'player' form_fields = ['delegation_choice'] def is_displayed(self): return self.player.id_in_group == 1 class DistributionChoice(Page): form_model = 'player' form_fields = ['distribution_choice'] def is_displayed(self): if self.group.get_player_by_id(1).delegation_choice: return self.player.id_in_group == 2 class PunishmentChoice(Page): form_model = 'player' form_fields = ['request_punishment'] def is_displayed(self): return self.player.id_in_group >= 3 class PunishmentLevel(Page): form_model = 'player' form_fields = ['punishment_A', 'punishment_B', 'punishment_C'] def is_displayed(self): if self.player.request_punishment: return self.player.id_in_group >= 3 def error_message(self, values): print('values is', values) if values['punishment_A'] + values['punishment_B'] + values['punishment_C'] > 7: return 'You can subtract maximum 7 points among all players' class ResultsWaitPage(WaitPage): after_all_players_arrive = 'set_payoffs' class Results(Page): pass page_sequence = [Intro, DelegationChoice, DistributionChoice, PunishmentChoice, PunishmentLevel, ResultsWaitPage, Results]