from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Exchange(Page): timeout_seconds = 100 form_model = 'group' form_fields = ['kept'] def is_displayed(self): #if it's an even numbered round then player 1 goes first # otherwise, player 2 goes first # this ensures that the two players take turns being the donor # NOTE: this assumes that both players' round number is always equal if self.player.round_number % 2 == 0: return self.player.id_in_group == 1 else: return self.player.id_in_group == 2 class ResultsWaitPage(WaitPage): after_all_players_arrive = 'set_payoffs' class ExchangeResults(Page): def vars_for_template(self): return dict(offer=Constants.endowment - self.group.kept) #return dict(offer=Constants.endowment - self.group.kept) #the page order page_sequence = [Exchange, ResultsWaitPage, ExchangeResults]