from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import random class WTP_Croc(Page): form_model = 'player' form_fields = ['WTP_ca', 'WTP_ce', 'WTP_ch'] def before_next_page(self): self.player.offer_c = random.uniform(-75, 75) self.player.infodraw_c = random.randint(1, 3) if self.player.infodraw_c == 1: self.player.WTP_drawn_c = self.player.WTP_ca self.player.info_draw_c_string = "animal treatment" elif self.player.infodraw_c == 2: self.player.WTP_drawn_c = self.player.WTP_ce self.player.info_draw_c_string = "environmental impact" else: self.player.WTP_drawn_c = self.player.WTP_ch self.player.info_draw_c_string = "health" if self.player.offer_c >= self.player.WTP_drawn_c: self.participant.payoff += self.player.offer_c self.player.aor_c = '''Because the offer was higher than your minimum acceptable payoff, the offer was accepted. You will receive the payoff and information about crocodile and ''' + self.player.info_draw_c_string else: self.player.aor_c = '''Because the offer was lower than your minimum acceptable payoff, the offer was refused. You will not receive the payoff or the information. You will however receive equally long information about another unrelated topic''' self.participant.vars['infodraw_c'] = self.player.infodraw_c self.participant.vars['offer_c'] = self.player.offer_c self.participant.vars['WTP_drawn_c'] = self.player.WTP_drawn_c self.participant.vars['info_draw_c_string'] = self.player.info_draw_c_string self.participant.vars['aor_c'] = self.player.aor_c page_sequence = [WTP_Croc]