from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import random class Instruction(Page): def is_displayed(self): return self.round_number==1 class Choice(Page): form_model='player' form_fields=['choice'] def before_next_page(self): self.player.result_calculater() class Results(Page): def vars_for_template(self): choice = '2 or lower' if self.player.choice==0 else '3 or higher' return { 'choice': choice, 'outcome': self.player.dice, 'your_earning': self.player.earning } class Final(Page): def is_displayed(self): return self.round_number==Constants.num_rounds def vars_for_template(self): prev_player = self.player.in_round(Constants.chosen_round) yourpay=prev_player.earning money=yourpay/10 return {'round':Constants.chosen_round, 'final_earning':yourpay, 'money':money } page_sequence = [Instruction, Choice, Results, Final]