from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants import random class Exeriment_ID(Page): form_model = "player" form_fields = ["Experiment_ID"] class Instructions(Page): pass class Instructions_Wait(WaitPage): def after_all_players_arrive(self): pass class Task1_Instrucitions(Page): pass class Task1_Instrucitions_Wait(WaitPage): def after_all_players_arrive(self): pass class Task1_solved(Page): form_model = "player" form_fields = ["Nsolved1NEW"] def before_next_page(self): player = self.player player.payout_round1 = player.Nsolved1NEW * Constants.Win_rate_Self_tournament / 2 pass class Task1_Wait(WaitPage): def after_all_players_arrive(self): pass class Task2_Instructions(Page): pass class Task2_Instructions_Wait(WaitPage): def after_all_players_arrive(self): pass class Task2_solved(Page): form_model = "player" form_fields = ["Nsolved2NEW"] def before_next_page(self): player = self.player # flipping coin if equal result like task before player.coinflip_if_equal_task2 = random.randint(0, 1) # wenn variable coinflip 0 also coinflip ausgeschaltet if Constants.coinflip == 0: player.coinflip_if_equal_task2 = 0.5 # next should select payout as solved * tournament rate if won, what if equal, 0 if lost if player.Nsolved2NEW > player.Nsolved1NEW: player.payout_round2 = player.Nsolved2NEW * Constants.Win_rate_Self_tournament elif player.Nsolved2NEW == player.Nsolved1NEW: player.payout_round2 = ( player.Nsolved2NEW * Constants.Win_rate_Self_tournament * player.coinflip_if_equal_task2 ) else: player.payout_round2 = 0 pass class Task2_Wait(WaitPage): def after_all_players_arrive(self): pass class Task3_Instructions(Page): form_model = "player" form_fields = ["Choice"] class Choice_For_Task3(Page): pass class Task3_Instructions_Wait(WaitPage): def after_all_players_arrive(self): pass class Task3_solved(Page): form_model = "player" form_fields = ["Nsolved3NEW"] def before_next_page(self): player = self.player # flipping coin if equal result like task before player.coinflip_if_equal_task3 = random.randint(0, 1) if Constants.coinflip == 0: player.coinflip_if_equal_task3 = 0.5 # if choice piecerate like task1 if player.Choice == "1": player.payout_round3 = player.Nsolved3NEW * Constants.Win_rate_Piecerate elif player.Choice == "2": # if selftournamet like task 2 if player.Nsolved3NEW > player.Nsolved2NEW: player.payout_round3 = ( player.Nsolved3NEW * Constants.Win_rate_Self_tournament ) elif player.Nsolved3NEW == player.Nsolved2NEW: player.payout_round3 = ( player.Nsolved3NEW * Constants.Win_rate_Self_tournament * player.coinflip_if_equal_task3 ) else: player.payout_round3 = 0 # Select wish round gets payed player.paying_round = random.randint(1, Constants.num_tasks) if player.paying_round == 1: player.participant.payoff=player.payout_round1 if player.paying_round == 2: player.participant.payoff=player.payout_round2 if player.paying_round == 3: player.participant.payoff = player.payout_round3 pass class WaitPageResults(WaitPage): wait_for_all_groups = True body_text = "Waiting for all players to report there results" def after_all_players_arrive(self): pass class Compensation(Page): pass page_sequence = [ Exeriment_ID, Instructions, Instructions_Wait, Task1_Instrucitions, Task1_Instrucitions_Wait, Task1_solved, Task1_Wait, Task2_Instructions, Task2_Instructions_Wait, Task2_solved, Task2_Wait, Task3_Instructions, Choice_For_Task3, Task3_Instructions_Wait, Task3_solved, WaitPageResults, Compensation, ]