from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Introduction(Page): def is_displayed(self): return self.round_number == 1 def vars_for_template(self): return dict( ppg=self.session.config['players_per_group'], ) class Decision(Page): form_model = 'player' form_fields = ['decision'] timeout_seconds = 60 def vars_for_template(self): if self.round_number> 1: my_decision_latest = self.player.in_round(self.round_number-1).decision count_red_latest = self.group.in_round(self.round_number-1).count_red count_black_latest = self.group.in_round(self.round_number-1).count_black profit_latest = self.group.in_round(self.round_number-1).profit profit_accumulation_latest = self.player.in_round(self.round_number-1).profit_accumulation else: my_decision_latest = '赤のコイン' count_red_latest = 0 count_black_latest = 0 profit_latest = 0 profit_accumulation_latest = 0 return dict( round_number=self.round_number, my_decision_latest = my_decision_latest, count_red_latest = count_red_latest, count_black_latest = count_black_latest, profit_latest=profit_latest, profit_accumulation_latest = profit_accumulation_latest, ) class ResultsWait(WaitPage): after_all_players_arrive = 'set_profits' class GameOver(Page): def is_displayed(self): return self.round_number == Constants.num_rounds # return self.round_number == self.session.config['num_rounds'] def vars_for_template(self): return dict( round_number = self.round_number, my_decision = self.player.decision, count_red = self.group.count_red, count_black = self.group.count_black, profit=self.group.profit, profit_accumulation = self.player.profit_accumulation, ) page_sequence = [Introduction, Decision, ResultsWait, GameOver, ]