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""" def is_displayed(self): return self.round_number == 1 pass class LeaderTask(Page): """This page is only for Leader Leader sends message to employee Leader: send a message and choose how much to contribute""" form_model = 'group' form_fields = ['suggested_amount', 'message'] def is_displayed(self): return self.player.role() == 'leader' class EmployeeTask(Page): """This page is only for Employee Employee received the message from leader and make a contribution""" pass def is_displayed(self): return self.player.role() == 'employee' class Contribute(Page): form_model = 'player' form_fields = ['contribution'] def vars_for_template(self): return { 'player_in_previous_rounds': self.player.in_previous_rounds(), } class LeaderMessageWaitPage(WaitPage): body_text = "Please wait for the leader to send a message." def is_displayed(self): return self.player.role() == 'employee' pass class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.set_payoffs() body_text = "Waiting for other participants to contribute." class ResultsSummary(Page): def is_displayed(self): return self.round_number == Constants.num_rounds def vars_for_template(self): return { 'total_payoffs': sum([p.payoff for p in self.player.in_all_rounds()]), 'player_in_all_rounds': self.player.in_all_rounds(), } page_sequence = [ Introduction, LeaderTask, LeaderMessageWaitPage, EmployeeTask, Contribute, ResultsWaitPage, ResultsSummary ]