from otree.api import Currency as c, currency_range from . import models from ._builtin import Page, WaitPage from .models import Constants class TGInstructions(Page): pass class TG_WaitForSender(CustomWaitPage): def is_displayed(self): return self.player.role() == 'Receiver' class TG_Send(Page): form_model = models.Group form_fields = ['sent_amount'] def is_displayed(self): return self.player.role() == 'Sender' class TG_SendBack(Page): form_model = models.Group form_fields = ['sent_back_amount'] def is_displayed(self): return self.player.role() == 'Receiver' def vars_for_template(self): tripled_amount = self.group.sent_amount * Constants.multiplication_factor return { 'tripled_amount': tripled_amount, 'prompt': 'Please choose an amount from 0 to %s:' % tripled_amount} def sent_back_amount_max(self): tripled_amount = self.group.sent_amount * Constants.multiplication_factor return tripled_amount class TGResultsWaitPage(WaitPage): def after_all_players_arrive(self): self.group.tg_payoffs() class TGResults(Page): """This page displays the earnings of each player""" def vars_for_template(self): return { 'tripled_amount': self.group.sent_amount * Constants.multiplication_factor } page_sequence = [ TGInstructions, TG_Send, WaitPage, TG_SendBack, TGResultsWaitPage, TGResults ]