<<<<<<< HEAD from otree.api import Currency as c, currency_range, SubmissionMustFail, expect ======= from otree.api import Currency as c, currency_range, SubmissionMustFail >>>>>>> 0982dc5566ffb7cb2176b6338e4f4497a3d00fc3 from . import pages from ._builtin import Bot from .models import Constants <<<<<<< HEAD ======= >>>>>>> 0982dc5566ffb7cb2176b6338e4f4497a3d00fc3 class PlayerBot(Bot): cases = ['p1_wins', 'p1_and_p2_win'] def play_round(self): if self.round_number == 1: <<<<<<< HEAD yield pages.Introduction ======= yield (pages.Introduction) >>>>>>> 0982dc5566ffb7cb2176b6338e4f4497a3d00fc3 if self.case == 'p1_wins': if self.player.id_in_group == 1: for invalid_guess in [-1, 101]: <<<<<<< HEAD yield SubmissionMustFail(pages.Guess, dict(guess=invalid_guess)) yield pages.Guess, dict(guess=9) expect(self.player.payoff, Constants.jackpot) expect('you win', 'in', self.html) else: yield pages.Guess, dict(guess=10) expect(self.player.payoff, 0) expect('you did not win', 'in', self.html) else: if self.player.id_in_group in [1, 2]: yield pages.Guess, dict(guess=9) expect(self.player.payoff, Constants.jackpot / 2) expect('you are one of the 2 winners', 'in', self.html) else: yield pages.Guess, dict(guess=10) expect(self.player.payoff, 0) expect('you did not win', 'in', self.html) yield pages.Results ======= yield SubmissionMustFail(pages.Guess, {"guess": invalid_guess}) yield (pages.Guess, {"guess": 9}) assert self.player.payoff == Constants.jackpot assert 'you win' in self.html else: yield (pages.Guess, {"guess": 10}) assert self.player.payoff == 0 assert 'you did not win' in self.html else: if self.player.id_in_group in [1, 2]: yield (pages.Guess, {"guess": 9}) assert self.player.payoff == Constants.jackpot / 2 assert 'you are one of the 2 winners' in self.html else: yield (pages.Guess, {"guess": 10}) assert self.player.payoff == 0 assert 'you did not win' in self.html yield (pages.Results) >>>>>>> 0982dc5566ffb7cb2176b6338e4f4497a3d00fc3