from otree.api import Currency as c, currency_range from . import pages from ._builtin import Bot from .models import Constants import time class PlayerBot(Bot): def play_round(self): if self.round_number == 1: yield (pages.grouping_and_cost) if self.participant.vars['group_id'] == (self.round_number % 3): yield (pages.start_of_round) if self.participant.vars['donation_cost'] > c(1): yield (pages.donation_decision, {'is_donor': False}) else: yield (pages.donation_decision, {'is_donor': True}) if self.round_number != 1 and self.participant.vars['group_id'] == ((self.round_number - 1) % 3): yield (pages.results_display_forSeniors) if self.participant.vars['group_id'] == (self.round_number % 3): yield (pages.results_display) if self.round_number == Constants.num_rounds: yield (pages.final_results) """ class PlayerBot(Bot): def play_round(self): if self.round_number == 1: yield (pages.grouping_and_cost) if self.participant.vars['group_id'] == (self.round_number % 3) \ and self.round_number <= self.session.vars['num_rounds'] \ and self.session.vars['diced'] != 0: if self.participant.vars['donation_cost'] > c(2): yield (pages.donation_decision, {'is_donor': False}) else: yield (pages.donation_decision, {'is_donor': True}) print('round_number: ', self.round_number) print('num_rounds: ', self.session.vars['num_rounds']) if self.participant.vars['group_id'] == (self.round_number % 3) \ and self.round_number <= self.session.vars['num_rounds'] \ and self.session.vars['diced'] != 0: yield (pages.results_display) if self.participant.vars['group_id'] == ((self.round_number-1) % 3) \ and self.round_number <= self.session.vars['num_rounds'] \ and self.session.vars['diced'] != 0: yield (pages.results_display) #if self.session.vars['expiry'] - time.time() < Constants.minutes_for_dice*60 \ if self.participant.vars['diced'] == 0: yield (pages.dice_final_round) print('num_rounds: ', self.session.vars['num_rounds']) #if self.round_number == self.session.vars['num_rounds'] and self.session.vars['diced'] == 1: if self.session.vars['diced'] == 1: yield (pages.final_results) """