from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants, Group, Player class Introduction(Page): """Description of the game: How to play and returns expected""" def is_displayed(player): return player.round_number == 1 def vars_for_template(self): if self.player.id_in_group == 1: return dict(NickName = 'ヤマアラシ') elif self.player.id_in_group == 2: return dict(NickName = 'オオカミ') else: return dict(NickName = 'ヒョウ') pass class Contribute(Page): """Player: Choose how much to contribute""" timeout_seconds = 120 form_model = 'player' form_fields = ['contribution'] def vars_for_template(self): if self.player.id_in_group == 1: return dict(NickName = 'ヤマアラシ') elif self.player.id_in_group == 2: return dict(NickName = 'オオカミ') else: return dict(NickName = 'ヒョウ') class ResultsWaitPage(WaitPage): after_all_players_arrive = 'set_payoffs' title_text = "計算中……" body_text = "他の参加者の投資が完了するまでお待ちください。" class Results(Page): """Players payoff: How much each has earned""" timeout_seconds = 60 def vars_for_template(self): return dict(total_earnings=self.group.total_contribution * Constants.multiplier) page_sequence = [Introduction, Contribute, ResultsWaitPage, Results]