from otree.api import ( models, widgets, BaseConstants, BaseSubsession, BaseGroup, BasePlayer, Currency as c, currency_range ) doc = """ This bargaining game involves 2 players. Each demands for a portion of some available amount. If the sum of demands is no larger than the available amount, both players get demanded portions. Otherwise, both get nothing. """ class Constants(BaseConstants): name_in_url = 'invdec_debug1' players_per_group = None num_rounds = 1 instructions_template = 'bargaining/Instructions.html' amount_shared = c(100) class Subsession(BaseSubsession): pass class Group(BaseGroup): total_requests = models.IntegerField() def testing_shtuff(self): players = self.get_players() # self.total_requests = sum([p.request for p in players]) for p in players: p.my_request = p.request -2 p.payoff = p.my_request ## THIS DOESN'T WORK: #self.my_request = self.player.request # if self.total_requests <= Constants.amount_shared: # for p in players: # p.payoff = p.request # else: # for p in players: # p.payoff = c(0) class Player(BasePlayer): # request = models.IntegerField( # doc=""" # Amount requested by this player. # """, # min=0, max=Constants.amount_shared # ) request = models.IntegerField( choices=[ [1, 'test1'], [2, 'test2'], [3, 'test3'], [4, 'test4'], [5, 'test5'], [6, 'test6'] ], widget=widgets.RadioSelect ) my_request = models.IntegerField() # def really_trying_here(self): # self.my_request = self.request -1 # def other_player(self): # return self.get_others_in_group()[0]