from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants class InstructionsAndBid(Page): form_model = 'player' form_fields = ['bid_amount'] def vars_for_template(self): bids = [] if 'bids' in self.participant.vars: bids = self.participant.vars['bids'] payoffs = [] if 'payoffs' in self.participant.vars: payoffs = self.participant.vars['payoffs'] opponent_bids = [] if 'opponent_bids' in self.participant.vars: opponent_bids = self.participant.vars['opponent_bids'] return dict(opponent=self.player.other_player().bid_amount, bids=bids, payoffs=payoffs, opponent_bids=opponent_bids, should_display_opponent_bids=self.session.config['should_display_opponent_bids'], game_name=self.session.config['game_name']) class ResultsWaitPage(WaitPage): after_all_players_arrive = 'set_payoffs' class Results(Page): def vars_for_template(self): aggregate_data = self.subsession.vars_for_admin_report() return dict(opponent=self.player.other_player().bid_amount, game_name=self.session.config['game_name'], bid_data=aggregate_data['bids'], payoff_data=aggregate_data['payoffs'], round_number=self.round_number) def app_after_this_page(self, upcoming_apps): if self.session.config['rounds'] == self.round_number: data = self.subsession.get_all_moves() self.participant.vars['all_bids'] = data['bids'] self.participant.vars['all_payoffs'] = data['payoffs'] return 'thank_you' page_sequence = [InstructionsAndBid, ResultsWaitPage, Results]