from ._builtin import Page, WaitPage from .models import Constants from .models import Player from .models import Group import random class Welcome(Page): """Player: Choose how much to contribute""" def is_displayed(self): return self.round_number == 1 class Introduction(Page): """Description of the game: How to play and returns expected""" def is_displayed(self): return self.round_number == 1 class TrialEnd(Page): """Description of the game: How to play and returns expected""" def is_displayed(self): return self.round_number == Constants.trialrounds class Decision(Page): """Player: Choose how much to contribute""" def vars_for_template(self): return dict( round_count=self.round_number, round_count2=self.round_number-Constants.trialrounds, trialcheck=self.round_number <= Constants.trialrounds, ) def js_vars(self): return dict( beta1=self.player.beta, ) form_model = 'player' form_fields = ['decision'] class ResultsWaitPage(WaitPage): after_all_players_arrive = 'set_payoffs' body_text = "Waiting for other participants to decide." class SyncronizationWaitPage(WaitPage): body_text = "Waiting for other participants to decide." wait_for_all_groups = True class OutputGenerationPage(WaitPage): wait_for_all_groups = True after_all_players_arrive = 'custom_export' def is_displayed(self): return self.round_number == Constants.trialrounds + Constants.actualrounds class Results(Page): """Players payoff: How much each has earned""" def vars_for_template(self): return dict(total_earnings=round(self.player.payoff2,2), round_count=self.round_number, round_count2=self.round_number - Constants.trialrounds, choseneffort=self.player.decision, trialcheck=self.round_number<=Constants.trialrounds) class Combined_Results(Page): """Players payoff: How much each has earned""" def is_displayed(self): return self.round_number == Constants.trialrounds+Constants.actualrounds def vars_for_template(self): return dict(part1_final_payment=self.player.part1_final_payment, selected_round=Constants.index) class ThankYou(Page): """Player: Choose how much to contribute""" def is_displayed(self): return self.round_number == Constants.trialrounds+Constants.actualrounds page_sequence = [Welcome,Introduction, SyncronizationWaitPage,Decision, ResultsWaitPage, Results,TrialEnd,OutputGenerationPage,Combined_Results,ThankYou]