import random from ._builtin import Page, WaitPage from .models import Constants class WTP_Beef(Page): form_model = 'player' form_fields = ['WTP_ba', 'WTP_be', 'WTP_bh'] def before_next_page(self): self.player.offer_b = random.uniform(-75, 75) self.player.infodraw_b = random.randint(1, 3) if self.player.infodraw_b == 1: self.player.WTP_drawn_b = self.player.WTP_ba self.player.info_draw_b_string = "animal treatment" elif self.player.infodraw_b == 2: self.player.WTP_drawn_b = self.player.WTP_be self.player.info_draw_b_string = "environmental impact" else: self.player.WTP_drawn_b = self.player.WTP_bh self.player.info_draw_b_string = "health" if self.player.offer_b >= self.player.WTP_drawn_b: self.participant.payoff += self.player.offer_b self.player.aor_b = '''Because the offer was higher than your minimum acceptable payoff, the offer was accepted. You will receive the payoff and information about beef and ''' + self.player.info_draw_b_string else: self.player.aor_b = '''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_b'] = self.player.infodraw_b self.participant.vars['offer_b'] = self.player.offer_b self.participant.vars['WTP_drawn_b'] = self.player.WTP_drawn_b self.participant.vars['info_draw_b_string'] = self.player.info_draw_b_string self.participant.vars['aor_b'] = self.player.aor_b page_sequence = [WTP_Beef]