from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants # Page 1: Waiting page, waiting for enough active players to form a group class GameWaitPage(WaitPage): template_name = 'waiting_room/GameWaitPage.html' group_by_arrival_time = True def after_all_players_arrive(self): pass # Page 2: Entering the actual game class ActivePage(Page): timeout_seconds = 3 def is_displayed(self) -> bool: return self.player.is_active and self.player.is_in # Page 2: Game over class PassivePage(Page): def is_displayed(self) -> bool: return not self.player.is_active or not self.player.is_in def vars_for_template(self) -> dict: self.player.payoff = c(Constants.basic_payment) return \ { "completion_code":Constants.completion_code, "finalpay": self.player.payoff } page_sequence = [GameWaitPage, ActivePage, PassivePage]