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 # class Update(WaitPage): # pass class Decision(Page): form_model = 'player' form_fields = ['decision'] def vars_for_template(self): if self.round_number> 1: my_decision_latest = self.player.in_round(self.round_number-1).decision opponent_decision_latest = self.player.in_round(self.round_number-1).decision_AI profit_latest = self.player.in_round(self.round_number-1).profit AI_profit_latest = self.player.in_round(self.round_number - 1).AI_profit profit_accumulation_latest = self.player.in_round(self.round_number-1).profit_accumulation AI_profit_accumulation_latest = self.player.in_round(self.round_number - 1).AI_profit_accumulation else: my_decision_latest = 'パー' opponent_decision_latest = 'パー' profit_latest = 0 AI_profit_latest = 0 profit_accumulation_latest = 0 AI_profit_accumulation_latest = 0 return dict( round_number=self.round_number, my_decision_latest = my_decision_latest, opponent_decision_latest = opponent_decision_latest, profit_latest = profit_latest, AI_profit_latest = AI_profit_latest, profit_accumulation_latest = profit_accumulation_latest, AI_profit_accumulation_latest = AI_profit_accumulation_latest, my_decision = self.player.decision, opponent_decision = self.player.decision_AI, same_choice = self.player.decision == self.player.decision_AI, ) class ResultsWait(WaitPage): after_all_players_arrive = 'set_profits' class GameEnd(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, opponent_decision = self.player.decision_AI, profit = self.player.profit, AI_profit = self.player.AI_profit, profit_accumulation = self.player.profit_accumulation, AI_profit_accumulation = self.player.AI_profit_accumulation, ) page_sequence = [Introduction, # Update, Decision, ResultsWait, GameEnd, ]