from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants # In fact should not show but will serve as giving # the group a type class WaitGroup(WaitPage): after_all_players_arrive = 'set_group_type' title_text = 'Waiting Room' body_text = "Please just hang tight, we're waiting for other players to reach this stage of the game. Don't close this browser as you might have issues rejoining." class Introduction(Page): """Description of the game: How to play and returns expected""" def vars_for_template(self): gtype = " " if self.group.all_mcf: gtype = "All players of this group received a MCF Scholarship." if self.group.all_non_mcf: gtype = "None of the players of this group received a MCF Scholarship." if self.group.mixed_group: gtype = "In this group, some players received a MCF Scholarship, and some did not." return( dict(group_type = gtype ) ) class Contribute(Page): """Player: Choose how much to contribute""" form_model = 'player' form_fields = ['contribution'] def vars_for_template(self): gtype = " " if self.group.all_mcf: gtype = "All players of this group received a MCF Scholarship." if self.group.all_non_mcf: gtype = "None of the players of this group received a MCF Scholarship." if self.group.mixed_group: gtype = "In this group, some players received a MCF Scholarship, and some did not." return( dict(group_type = gtype ) ) class ResultsWaitPage(WaitPage): after_all_players_arrive = 'set_payoffs' body_text = "Waiting for other participants to contribute." class Results(Page): def vars_for_template(self): # fetch results from the dictator game earn_1 = self.participant.vars['earning_1'] if self.participant.vars['sender_1']: rol_1 = "sender" else: rol_1 = "receiver" #fetch results from the trust game earn_2 = self.participant.vars['earning_2'] if self.participant.vars['sender_2']: rol_2 = "initial sender" initial_sent_2 = self.participant.vars['initial_sent_2'] received_back_2 = self.participant.vars['received_back_2'] initial_received_2 = 0 sent_back_2 = 0 else: rol_2 = "initial receiver" initial_sent_2 = 0 received_back_2 = 0 initial_received_2 = self.participant.vars['received_2'] sent_back_2 = self.participant.vars['sent_back_2'] return dict( earning_1 = earn_1, role_1 = rol_1, earning_2 = earn_2, role_2 = rol_2, initial_sent_2 = initial_sent_2, received_back_2 = received_back_2, initial_received_2 = initial_received_2, sent_back_2 = sent_back_2, total_earnings = self.group.total_contribution * Constants.multiplier) page_sequence = [WaitGroup, Introduction, Contribute, ResultsWaitPage, Results]