from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class Info(Page): # 課題の説明ページ def is_displayed(self): return self.round_number == 1 class Throw(Page): form_model = 'player' form_fields = ['throw'] def is_displayed(self): # PCがボールを持っているときに表示しない if self.round_number >= 2: if self.player.in_round(self.round_number-1).location == 'Y' or self.player.in_round(self.round_number-1).location == 'X': return False else: return True else: return True def before_next_page(self): # loc_ball を使ってボールの位置情報を変更 while self.round_number ==1: self.player.location = self.player.throw return self.player.location, print('location has been changed to ', self.player.location) else: return self.player.loc_ball(), print('loc_ball was applied, location change ', self.player.location) class ThrowXY(Page): def is_displayed(self): if self.subsession.round_number ==1: return False elif self.round_number >=2 and self.player.in_round(self.round_number-1).location == 'Y': return True elif self.round_number >=2 and self.player.in_round(self.round_number-1).location == 'X': return True else: return False def get_timeout_seconds(self): # ページの提示時間をpに合わせて流す return self.player.p def before_next_page(self): # ボールの位置情報を変更 return self.player.loc_ball() def vars_for_template(self): # 参加者に見せる情報を取得 return self.player.vars_for_template() class Animation(Page): timeout_seconds = 4 class Result(Page): form_model = 'player' form_fields = ['exit_game'] def vars_for_template(self): return self.player.vars_for_template() def app_after_this_page(self, upcoming_apps): if self.player.exit_game == False: return upcoming_apps[0] page_sequence = [Info, Throw, ThrowXY, Animation, Result]