from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range, ) import random from datetime import date from django import forms class Constants(BaseConstants): name_in_url = 'PremierLeague_UK_Part2' players_per_group = None # tasks = ['A', 'B', 'C', 'D'] # num_rounds = len(tasks) num_rounds = 1 class Subsession(BaseSubsession): def creating_session(self): # randomize wedge # if self.round_number == 1: # for player in self.get_players(): # player.wedge1 = random.choice([-2.5, -1.5, -0.5, 0, 0.5, 1.5, 2.5]) # player.wedge2 = random.choice([-2.5, -1.5, -0.5, 0, 0.5, 1.5, 2.5]) # player.wedge3 = random.choice([-2.5, -1.5, -0.5, 0, 0.5, 1.5, 2.5]) # player.wedge4 = random.choice([-2.5, -1.5, -0.5, 0, 0.5, 1.5, 2.5]) # player.participant.vars['wedge1'] = player.wedge1 # player.participant.vars['wedge2'] = player.wedge2 # player.participant.vars['wedge3'] = player.wedge3 # player.participant.vars['wedge4'] = player.wedge4 for player in self.get_players(): wedge_list = [-2.5, -1.5, -0.5, 0, 0.5, 1.5, 2.5] player.wedge1 = random.choice(wedge_list) player.wedge2 = random.choice(wedge_list) player.wedge3 = random.choice(wedge_list) player.wedge4 = random.choice(wedge_list) # player.wedge5 = random.choice(wedge_list) # player.wedge6 = random.choice(wedge_list) # player.wedge = random.choice(wedge_list) player.participant.vars['wedge1'] = player.wedge1 player.participant.vars['wedge2'] = player.wedge2 player.participant.vars['wedge3'] = player.wedge3 player.participant.vars['wedge4'] = player.wedge4 # player.participant.vars['wedge5'] = player.wedge5 # player.participant.vars['wedge6'] = player.wedge6 pass class Group(BaseGroup): pass class Player(BasePlayer): wedge1 = models.FloatField() wedge2 = models.FloatField() wedge3 = models.FloatField() wedge4 = models.FloatField() # wedge5 = models.FloatField() # wedge6 = models.FloatField() matchbet_1_win = models.IntegerField(min=0, max=100, initial=0) matchbet_1_draw = models.IntegerField(min=0, max=100, initial=0) matchbet_1_lose = models.IntegerField(min=0, max=100, initial=0) matchbet_1_winodds = models.FloatField() matchbet_1_drawodds = models.FloatField() matchbet_1_loseodds = models.FloatField() matchbet_1_sum = models.IntegerField() def matchbet_1_sum_error_message(player, value): print('value is', value) if value != 100: return 'Tokens need to sum to 100' # matchbet_2_win = models.IntegerField(min=0, max=100, initial=0) # matchbet_2_draw = models.IntegerField(min=0, max=100, initial=0) # matchbet_2_lose = models.IntegerField(min=0, max=100, initial=0) # matchbet_2_winodds = models.FloatField() # matchbet_2_drawodds = models.FloatField() # matchbet_2_loseodds = models.FloatField() # matchbet_2_sum = models.IntegerField() # def matchbet_2_sum_error_message(player, value): # print('value is', value) # if value != 100: # return 'Tokens need to sum to 100' # matchbet_3_win = models.IntegerField(min=0, max=100, initial=0) # matchbet_3_draw = models.IntegerField(min=0, max=100, initial=0) # matchbet_3_lose = models.IntegerField(min=0, max=100, initial=0) # matchbet_3_winodds = models.FloatField() # matchbet_3_drawodds = models.FloatField() # matchbet_3_loseodds = models.FloatField() # matchbet_3_sum = models.IntegerField() # def matchbet_3_sum_error_message(player, value): # print('value is', value) # if value != 100: # return 'Tokens need to sum to 100' # matchbet_4_win = models.IntegerField(min=0, max=100, initial=0) # matchbet_4_draw = models.IntegerField(min=0, max=100, initial=0) # matchbet_4_lose = models.IntegerField(min=0, max=100, initial=0) # matchbet_4_winodds = models.FloatField() # matchbet_4_drawodds = models.FloatField() # matchbet_4_loseodds = models.FloatField() # matchbet_4_sum = models.IntegerField() # def matchbet_4_sum_error_message(player, value): # print('value is', value) # if value != 100: # return 'Tokens need to sum to 100' # matchbet_5_win = models.IntegerField(min=0, max=100, initial=0) # matchbet_5_draw = models.IntegerField(min=0, max=100, initial=0) # matchbet_5_lose = models.IntegerField(min=0, max=100, initial=0) # matchbet_5_winodds = models.FloatField() # matchbet_5_drawodds = models.FloatField() # matchbet_5_loseodds = models.FloatField() # matchbet_5_sum = models.IntegerField() # def matchbet_5_sum_error_message(player, value): # print('value is', value) # if value != 100: # return 'Tokens need to sum to 100' # matchbet_6_win = models.IntegerField(min=0, max=100, initial=0) # matchbet_6_draw = models.IntegerField(min=0, max=100, initial=0) # matchbet_6_lose = models.IntegerField(min=0, max=100, initial=0) # matchbet_6_winodds = models.FloatField() # matchbet_6_drawodds = models.FloatField() # matchbet_6_loseodds = models.FloatField() # matchbet_6_sum = models.IntegerField() # def matchbet_6_sum_error_message(player, value): # print('value is', value) # if value != 100: # return 'Tokens need to sum to 100' match_1_watch = models.StringField(choices=['Yes', 'No'], label='Are you planning to watch this match?', widget=widgets.RadioSelect) # match_2_watch = models.StringField(choices=['Yes', 'No'], label='Are you planning to watch this match?', # widget=widgets.RadioSelect) # match_3_watch = models.StringField(choices=['Yes', 'No'], label='Are you planning to watch this match?', # widget=widgets.RadioSelect) # match_4_watch = models.StringField(choices=['Yes', 'No'], label='Are you planning to watch this match?', # widget=widgets.RadioSelect) # match_5_watch = models.StringField(choices=['Yes', 'No'], label='Are you planning to watch this match?', # widget=widgets.RadioSelect) # match_6_watch = models.StringField(choices=['Yes', 'No'], label='Are you planning to watch this match?', # widget=widgets.RadioSelect) # match_1_desiredresult = models.StringField(choices=['Win Southampton', 'Draw', 'Win Spurs', 'I don\'t care'], # label='What result would you like to see?', # widget=widgets.RadioSelect) # match_2_desiredresult = models.StringField(choices=['Win Leicester', 'Draw', 'Win Liverpool', 'I don\'t care'], # label='What result would you like to see?', # widget=widgets.RadioSelect) # match_3_desiredresult = models.StringField(choices=['Win Chelsea', 'Draw', 'Win Brighton', 'I don\'t care'], # label='What result would you like to see?', # widget=widgets.RadioSelect) # match_4_desiredresult = models.StringField(choices=['Win Man United', 'Draw', 'Win Burnley', 'I don\'t care'], # label='What result would you like to see?', # widget=widgets.RadioSelect) MatchBet_a_time = models.FloatField() # MatchBet_b_time = models.FloatField() # MatchBet_c_time = models.FloatField() # MatchBet_d_time = models.FloatField() # MatchBet_e_time = models.FloatField() # MatchBet_f_time = models.FloatField()