from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants class PaymentInfo(Page): def vars_for_template(self): participant = self.participant bids = [] if 'bids' in self.participant.vars: bids = self.participant.vars['bids'] payoffs = [] if 'payoffs' in self.participant.vars: payoffs = self.participant.vars['payoffs'] accumulated_payoff = 'Unknown' if 'accumulated_payoffs' in self.participant.vars: accumulated_payoff = self.participant.vars['accumulated_payoffs'][-1] opponent_bids = [] if 'opponent_bids' in self.participant.vars: opponent_bids = self.participant.vars['opponent_bids'] all_bids = [] if 'all_bids' in self.participant.vars: all_bids = self.participant.vars['all_bids'] all_payoffs = [] if 'all_payoffs' in self.participant.vars: all_payoffs = self.participant.vars['all_payoffs'] opponent_payoff = self.player.get_others_in_subsession()[0].participant.vars['name'] if 'accumulated_payoffs' in self.player.get_others_in_subsession()[0].participant.vars: opponent_payoff = self.player.get_others_in_subsession()[0].participant.vars['accumulated_payoffs'][-1] opponent_name = self.player.get_others_in_subsession()[0].participant.vars['name'] return dict(redemption_code=participant.label or participant.code, bids=bids, payoffs=payoffs, accumulated_payoff=accumulated_payoff, opponent_bids=opponent_bids, should_display_opponent_bids=True, all_bids=all_bids, all_payoffs=all_payoffs, num_rounds=self.session.config['rounds'], opponent_name=opponent_name, opponent_payoff=opponent_payoff) page_sequence = [PaymentInfo]