from otree.api import * c = cu doc = 'endogenous information with buffat and senn deisgn' class C(BaseConstants): NAME_IN_URL = 'BG_INFO_B_and_S13Rounds' PLAYERS_PER_GROUP = 4 NUM_ROUNDS = 13 INFOCOST = 3 ENDOWMENT = cu(20) MULTIPLIER = 2 INSTRUCTIONSUMPIRE_TEMPLATE = 'BG_INFO_B_and_S13Rounds/instructionsumpire.html' INSTRUCTIONSPLAYER_TEMPLATE = 'BG_INFO_B_and_S13Rounds/instructionsplayer.html' INSTRUCTIONSGENERIC_TEMPLATE = 'BG_INFO_B_and_S13Rounds/instructionsgeneric.html' INSTRUCTIONSSLIM1_TEMPLATE = 'BG_INFO_B_and_S13Rounds/instructionsslim1.html' class Subsession(BaseSubsession): corruzione = models.IntegerField() corruzionesessione = models.IntegerField() robotcorrupt = models.IntegerField() corruzionegruppi = models.IntegerField() corruzioneround = models.IntegerField() corruzioneg1 = models.IntegerField(initial=0) corruzioneg2 = models.IntegerField(initial=0) corruzioneg3 = models.IntegerField(initial=0) corruzioneg4 = models.IntegerField(initial=0) tuttacorruzione = models.IntegerField() class Group(BaseGroup): contributions = models.IntegerField() partecipanti = models.IntegerField() umpirelastgroup = models.IntegerField() total_contribution = models.CurrencyField() individual_share = models.CurrencyField() corruzioneround = models.IntegerField() total_corruzione = models.IntegerField() total = models.IntegerField() corruzione = models.IntegerField() def after_all_players_arrive(group: Group): #creazione delle stringhe p1 = group.get_player_by_id(1) p2 = group.get_player_by_id(2) p3 = group.get_player_by_id(3) p4 = group.get_player_by_id(4) for p in group.get_players(): # stinghe x feedback try: p.bribeplayer2 = 0 p1.bribeplayer2 = p2.bribe except TypeError: p2.bribe = None try: p.bribeplayer3 = 0 p1.bribeplayer3 = p3.bribe except TypeError: p3.bribe = None try: p.bribeplayer4 = 0 p1.bribeplayer4 = p4.bribe except TypeError: p4.bribe = None #why group.round_number == 1? for p in group.get_players(): try: p2.progettocomune = p2.contribution except TypeError: p2.contribution = None try: p3.progettocomune = p3.contribution except TypeError: p3.contribution = None try: p4.progettocomune = p4.contribution except TypeError: p4.contribution = None #stringhe x feedback da mostrare al player 2 # if p3.progettocomune == "Uscita": try: p2.progettocomunepl3 = p3.progettocomune p1.progettocomunepl3 = p3.progettocomune p4.progettocomunepl3 = p3.progettocomune except TypeError: p3.progettocomune = None try: p2.progettocomunepl4 = p4.progettocomune p1.progettocomunepl4 = p4.progettocomune p3.progettocomunepl4 = p4.progettocomune except TypeError: p4.progettocomune = None try: p1.progettocomunepl2 = p2.progettocomune p3.progettocomunepl2 = p2.progettocomune p4.progettocomunepl2 = p2.progettocomune except TypeError: p2.progettocomune = None try: if p2.Info == True: p2.infostringa = "Si" else: p2.infostringa = "No" if p3.Info == True: p3.infostringa = "Si" else: p3.infostringa = "No" if p4.Info == True: p4.infostringa = "Si" else: p4.infostringa = "No" except TypeError: p.Info = None def set_payoff1(group: Group): contributions = 0 bribe = 0 for p in group.get_players(): try: contributions = contributions + p.contribution bribe = bribe + p.bribe except TypeError: p.contribution = None p.bribe = None for p in group.get_players(): group.individual_share = contributions * 0.4 #modifica variabile punizione ai fini del calcolo payoff (la variabile punishment è al livllo del player, ma l'arbitro punisce con ogni variabile un solo giocatore: devo perciò "cancellare" i casi vuoti for p in group.get_players(): p1 = group.get_player_by_id(1) p2 = group.get_player_by_id(2) p3 = group.get_player_by_id(3) p4 = group.get_player_by_id(4) p1.mazzetta = bribe p.punizione2 = p1.punishment2 * 3 p.punizione3 = p1.punishment3 * 3 p.punizione4 = p1.punishment4 * 3 p2.punizione = p4.punizione2 p3.punizione = p4.punizione3 p4.punizione = p4.punizione4 p1.punizione2 = p4.punizione2 p2.punizione2 = p4.punizione2 p3.punizione2 = p4.punizione2 p4.punizione2 = p4.punizione2 p1.punizione3 = p4.punizione3 p2.punizione3 = p4.punizione3 p3.punizione3 = p4.punizione3 p4.punizione3 = p4.punizione3 p1.punizione4 = p4.punizione4 p2.punizione4 = p4.punizione4 p3.punizione4 = p4.punizione4 p4.punizione4 = p4.punizione4 p2.bribeplayer2 = p1.bribeplayer2 p3.bribeplayer2 = p1.bribeplayer2 p4.bribeplayer2 = p1.bribeplayer2 p2.bribeplayer3 = p1.bribeplayer3 p3.bribeplayer3 = p1.bribeplayer3 p4.bribeplayer3 = p1.bribeplayer3 p2.bribeplayer4 = p1.bribeplayer4 p3.bribeplayer4 = p1.bribeplayer4 p4.bribeplayer4 = p1.bribeplayer4 p.contribuzionepl2 = p2.contribution p.contribuzionepl3 = p3.contribution p.contribuzionepl4 = p4.contribution p2.contribuzionepl2 = p4.contribuzionepl2 p3.contribuzionepl2 = p4.contribuzionepl2 p2.contribuzionepl3 = p4.contribuzionepl3 p3.contribuzionepl3 = p4.contribuzionepl3 p2.contribuzionepl4 = p4.contribuzionepl4 p3.contribuzionepl4 = p4.contribuzionepl4 #payoff participants for p in group.get_players(): if p1.bribe2 == 0: p2.payoff = C.ENDOWMENT - p2.contribution + 5 + group.individual_share - p2.punizione if p1.bribe2 == 1: p2.payoff = C.ENDOWMENT - p2.contribution + (5 - p2.bribe) + group.individual_share - p2.punizione if p1.bribe3 == 1: p3.payoff = C.ENDOWMENT - p3.contribution + (5 - p3.bribe) + group.individual_share - p3.punizione if p1.bribe3 == 0: p3.payoff = C.ENDOWMENT - p3.contribution + 5 + group.individual_share - p3.punizione if p1.bribe4 == 0: p4.payoff = C.ENDOWMENT - p4.contribution + 5 + group.individual_share - p4.punizione if p1.bribe4 == 1: p4.payoff = C.ENDOWMENT - p4.contribution + (5 - p4.bribe) + group.individual_share - p4.punizione if p1.bribe2 == 1: p.bribepl2 = p1.bribeplayer2 p2.bribe2 = p1.bribe2 else: p.bribepl2 = 0 p2.bribe2 = p1.bribe2 if p1.bribe3 == 1: p.bribepl3 = p1.bribeplayer3 p3.bribe3 = p1.bribe3 else: p.bribepl3 = 0 p3.bribe3 = p1.bribe3 if p1.bribe4 == 1: p.bribepl4 = p1.bribeplayer4 p4.bribe4 = p1.bribe4 else: p.bribepl4 = 0 p4.bribe4 = p1.bribe4 p1.bribepl2 = p4.bribepl2 #check p1.bribepl3 = p4.bribepl3 p1.bribepl4 = p4.bribepl4 p2.bribe3 = p1.bribe3 p2.bribe4 = p1.bribe4 p3.bribe2 = p1.bribe2 p3.bribe4 = p1.bribe4 p4.bribe2 = p1.bribe2 p4.bribe3 = p1.bribe3 p.valoremazzetta = p1.bribepl2 + p1.bribepl3 + p1.bribepl4 p1.valoremazzetta = p4.valoremazzetta #payoff arbitro p1.payoff = 20 + group.individual_share + 15 - (p1.punishment2 + p1.punishment3 + p1.punishment4) + p.valoremazzetta def set_payoff2(group: Group): #payoff round > 1 contributions = 0 bribe = 0 for p in group.get_players(): try: contributions = contributions + p.contribution bribe = bribe + p.bribe except TypeError: p.contribution = None p.bribe = None for p in group.get_players(): group.individual_share = contributions * 0.4 #modifica variabile punizione ai fini del calcolo payoff (la variabile punishment è al livllo del player, ma l'arbitro punisce con ogni variabile un solo giocatore: devo perciò "cancellare" i casi vuoti for p in group.get_players(): p1 = group.get_player_by_id(1) p2 = group.get_player_by_id(2) p3 = group.get_player_by_id(3) p4 = group.get_player_by_id(4) p1.mazzetta = bribe p.punizione2 = p1.punishment2 * 3 p.punizione3 = p1.punishment3 * 3 p.punizione4 = p1.punishment4 * 3 p2.punizione = p4.punizione2 p3.punizione = p4.punizione3 p4.punizione = p4.punizione4 p1.punizione2 = p4.punizione2 p2.punizione2 = p4.punizione2 p3.punizione2 = p4.punizione2 p4.punizione2 = p4.punizione2 p1.punizione3 = p4.punizione3 p2.punizione3 = p4.punizione3 p3.punizione3 = p4.punizione3 p4.punizione3 = p4.punizione3 p1.punizione4 = p4.punizione4 p2.punizione4 = p4.punizione4 p3.punizione4 = p4.punizione4 p4.punizione4 = p4.punizione4 p2.bribeplayer2 = p1.bribeplayer2 p3.bribeplayer2 = p1.bribeplayer2 p4.bribeplayer2 = p1.bribeplayer2 p2.bribeplayer3 = p1.bribeplayer3 p3.bribeplayer3 = p1.bribeplayer3 p4.bribeplayer3 = p1.bribeplayer3 p2.bribeplayer4 = p1.bribeplayer4 p3.bribeplayer4 = p1.bribeplayer4 p4.bribeplayer4 = p1.bribeplayer4 p.contribuzionepl2 = p2.contribution p.contribuzionepl3 = p3.contribution p.contribuzionepl4 = p4.contribution p2.contribuzionepl2 = p4.contribuzionepl2 p3.contribuzionepl2 = p4.contribuzionepl2 p2.contribuzionepl3 = p4.contribuzionepl3 p3.contribuzionepl3 = p4.contribuzionepl3 p2.contribuzionepl4 = p4.contribuzionepl4 p3.contribuzionepl4 = p4.contribuzionepl4 #payoff participants for p in group.get_players(): if p2.Info == True: if p1.bribe2 == 0: p2.payoff = C.ENDOWMENT - p2.contribution + 5 + group.individual_share - p2.punizione - C.INFOCOST if p1.bribe2 == 1: p2.payoff = C.ENDOWMENT - p2.contribution + (5 - p2.bribe) + group.individual_share - p2.punizione - C.INFOCOST else: if p1.bribe2 == 0: p2.payoff = C.ENDOWMENT - p2.contribution + 5 + group.individual_share - p2.punizione - C.INFOCOST if p1.bribe2 == 1: p2.payoff = C.ENDOWMENT - p2.contribution + (5 - p2.bribe) + group.individual_share - p2.punizione - C.INFOCOST if p3.Info == True: if p1.bribe3 == 1: p3.payoff = C.ENDOWMENT - p3.contribution + (5 - p3.bribe) + group.individual_share - p3.punizione - C.INFOCOST if p1.bribe3 == 0: p3.payoff = C.ENDOWMENT - p3.contribution + 5 + group.individual_share - p3.punizione - C.INFOCOST else: if p1.bribe3 == 1: p3.payoff = C.ENDOWMENT - p3.contribution + (5 - p3.bribe) + group.individual_share - p3.punizione if p1.bribe3 == 0: p3.payoff = C.ENDOWMENT - p3.contribution + 5 + group.individual_share - p3.punizione if p4.Info == True: if p1.bribe4 == 0: p4.payoff = C.ENDOWMENT - p4.contribution + 5 + group.individual_share - p4.punizione - C.INFOCOST if p1.bribe4 == 1: p4.payoff = C.ENDOWMENT - p4.contribution + (5 - p4.bribe) + group.individual_share - p4.punizione - C.INFOCOST else: if p1.bribe4 == 0: p4.payoff = C.ENDOWMENT - p4.contribution + 5 + group.individual_share - p4.punizione if p1.bribe4 == 1: p4.payoff = C.ENDOWMENT - p4.contribution + (5 - p4.bribe) + group.individual_share - p4.punizione if p1.bribe2 == 1: p.bribepl2 = p1.bribeplayer2 p2.bribe2 = p1.bribe2 else: p.bribepl2 = 0 p2.bribe2 = p1.bribe2 if p1.bribe3 == 1: p.bribepl3 = p1.bribeplayer3 p3.bribe3 = p1.bribe3 else: p.bribepl3 = 0 p3.bribe3 = p1.bribe3 if p1.bribe4 == 1: p.bribepl4 = p1.bribeplayer4 p4.bribe4 = p1.bribe4 else: p.bribepl4 = 0 p4.bribe4 = p1.bribe4 p1.bribepl2 = p4.bribepl2 #check p1.bribepl3 = p4.bribepl3 p1.bribepl4 = p4.bribepl4 p2.bribe3 = p1.bribe3 p2.bribe4 = p1.bribe4 p3.bribe2 = p1.bribe2 p3.bribe4 = p1.bribe4 p4.bribe2 = p1.bribe2 p4.bribe3 = p1.bribe3 p.valoremazzetta = p1.bribepl2 + p1.bribepl3 + p1.bribepl4 p1.valoremazzetta = p4.valoremazzetta #payoff arbitro p1.payoff = 20 + group.individual_share + 15 - (p1.punishment2 + p1.punishment3 + p1.punishment4) + p.valoremazzetta if p1.bribe2 == 1: p.bribepl2 = p1.bribeplayer2 else: p.bribepl2 = 0 if p1.bribe3 == 1: p.bribepl3 = p1.bribeplayer3 else: p.bribepl3 = 0 if p1.bribe4 == 1: p.bribepl4 = p1.bribeplayer4 else: p.bribepl4 = 0 def verify(group: Group): for p in group.get_players(): try: p.sommacontribbribe = p.contribution + p.bribe except TypeError: p.contribution = None try: if p.sommacontribbribe > 10: p.errore = 1 else: p.errore = 0 except TypeError: p.contribution = None def fase_uno(group: Group): for p in group.get_players(): p1 = group.get_player_by_id(1) p2 = group.get_player_by_id(2) p3 = group.get_player_by_id(3) p4 = group.get_player_by_id(4) contributions = 0 for p in group.get_players(): try: contributions = contributions + p.contribution except TypeError: p.contribution = None for p in group.get_players(): group.total_contribution = contributions * 1.6 group.individual_share = contributions * 0.4 #payoff participants for p in group.get_players(): p2.faseuno = 20 - p2.contribution + group.individual_share p3.faseuno = 20 - p3.contribution + group.individual_share p4.faseuno = 20 - p4.contribution + group.individual_share p1.faseuno = 0 for p in group.get_players(): p2.redditoprivato = C.ENDOWMENT - p2.contribution p3.redditoprivato = C.ENDOWMENT - p3.contribution p4.redditoprivato = C.ENDOWMENT - p4.contribution p1.redditoprivato = 0 def info(group: Group): for p in group.get_players(): p2 = group.get_player_by_id(2) p3 = group.get_player_by_id(3) p4 = group.get_player_by_id(4) p.contributionbeforepl2 = p2.in_round(group.round_number - 1).contribuzionepl2 p.contributionbeforepl3 = p3.in_round(group.round_number - 1).contribuzionepl3 p.contributionbeforepl4 = p4.in_round(group.round_number - 1).contribuzionepl4 p.bribeacceptancepl2 = p2.in_round(group.round_number - 1).bribe2 p.bribeacceptancepl3 = p3.in_round(group.round_number - 1).bribe3 p.bribeacceptancepl4 = p4.in_round(group.round_number - 1).bribe4 p.punizionebeforepl2 = p.in_round(group.round_number - 1).punizione2 p.punizionebeforepl3 = p.in_round(group.round_number - 1).punizione3 p.punizionebeforepl4 = p.in_round(group.round_number - 1).punizione4 p.bribebeforepl2 = p.in_round(group.round_number - 1).bribeplayer2 p.bribebeforepl3 = p.in_round(group.round_number - 1).bribeplayer3 p.bribebeforepl4 = p.in_round(group.round_number - 1).bribeplayer4 Group.after_all_players_arrive = after_all_players_arrive Group.set_payoff1 = set_payoff1 Group.set_payoff2 = set_payoff2 class Player(BasePlayer): Questionbribe = models.IntegerField(choices=[[25, '20 - 10 + 12 + 5 - 2 = 25'], [20, '20 - 10 + 12 - 2 = 20']], label='3) Quanti punti ottieni se trasferisci 2 punti al partecipante B?', widget=widgets.RadioSelect) Questionme = models.IntegerField(choices=[[32, '30 x 1.6 = 48. 48: 4 = 12. 20 + 12 = 32'], [27, '30 x 1.6 = 48. 48 : 4 = 12. 20 - 10 + 12 + 5 = 27']], label='1) Quanti punti ottieni, se il partecipante B non ti toglie nessun punto?', widget=widgets.RadioSelect) Question3 = models.IntegerField(choices=[[23, '20 + 12 - 9 = 23'], [18, '20 - 10 = 10. 10 + 12 + 5 - 9 = 18']], label='2) Quanti punti ottieni complessivamente, se il partecipante B ti toglie 9 punti?', widget=widgets.RadioSelect) QuestionUmp = models.IntegerField(choices=[[46, '20 + 15 - 3 + 2 + 12 = 46'], [34, '20 + 15 - 3 + 2 = 34']], label='4) Quanti punti ottiene il Partecipamte B, se ti ha tolto 9 punti ed ha accettato i 2 punti che gli hai trasferito?', widget=widgets.RadioSelect) mazzetta = models.IntegerField() bonus = models.IntegerField() punishment2 = models.IntegerField(choices=[[0, 'Nessun punto'], [1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, '10']], initial=700, label='Indica se e quanti punti vuoi togliere al partecipante') punishment3 = models.IntegerField(choices=[[0, 'Nessun punto'], [1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, '10']], initial=700, label='Indica se e quanti punti vuoi togliere al partecipante') punishment4 = models.IntegerField(choices=[[0, 'Nessun punto'], [1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, '10']], initial=700, label='Indica se e quanti punti vuoi togliere al partecipante') bribe2 = models.IntegerField(choices=[[1, 'Si'], [0, 'No']], initial=700, label='Vuoi accettare i punti che ti ha trasferito il partecipante?', widget=widgets.RadioSelectHorizontal) bribe3 = models.IntegerField(choices=[[1, 'Si'], [0, 'No']], initial=700, label='Vuoi accettare i punti che ti ha trasferito il partecipante?', widget=widgets.RadioSelectHorizontal) bribe4 = models.IntegerField(choices=[[1, 'Si'], [0, 'No']], initial=700, label='Vuoi accettare i punti che ti ha trasferito il partecipante?', widget=widgets.RadioSelectHorizontal) bribepl2 = models.IntegerField(choices=[], initial=0) bribepl3 = models.IntegerField(initial=0) bribepl4 = models.IntegerField(initial=0) bribepl5 = models.IntegerField(initial=0) Infonew = models.IntegerField(choices=[[1, 'Si'], [0, 'No']], initial=700, label="Vuoi comprare un'informazione sulle decisioni prese dall'arbitro nel round precedente, al costo di 3 punti?", widget=widgets.RadioSelect) Info = models.BooleanField(choices=[[True, 'Si'], [False, 'No']], label="Vuoi comprare un'informazione sulle decisioni prese dal Partecipante B nel periodo precedente, al costo di 3 punti?", widget=widgets.RadioSelect) infostringa = models.StringField(initial='-') punizione2 = models.IntegerField(choices=[]) punizione3 = models.IntegerField(choices=[]) punizione4 = models.IntegerField(choices=[]) valoremazzetta = models.IntegerField() punizione = models.IntegerField() progettocomune = models.IntegerField() infopunizione = models.IntegerField(choices=[[0, '0'], [7, '7'], [11, '11']]) infocontribution = models.IntegerField(choices=[[0, '0'], [3, '3'], [100, '100'], [300, '300'], [6, '6'], [9, '9'], [99, '99']]) my_field2 = models.IntegerField() corruzione = models.IntegerField() corruttori = models.IntegerField() corruttoriprima = models.StringField() corruzioneprima = models.StringField() bribeplayer2 = models.IntegerField() bribeplayer3 = models.IntegerField() bribeplayer4 = models.IntegerField() partecipantiprima = models.IntegerField() partecipantipg1 = models.IntegerField() partecipantipg2 = models.IntegerField() partecipantipg3 = models.IntegerField() partecipantipg4 = models.IntegerField() partecipantipg5 = models.IntegerField() partecipantipg = models.IntegerField() contribution = models.IntegerField(choices=[[0, '0'], [1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, '10'], [11, '11'], [12, '12'], [13, '13'], [14, '14'], [15, '15'], [16, '16'], [17, '17'], [18, '18'], [19, '19'], [20, '20']], label='Quanto vuoi mettere nel progetto comune?') bribe = models.IntegerField(choices=[[0, 'Nessun punto'], [1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5']], label='Hai a disposizione 5 punti. Indica se e quanti punti vuoi trasferire al Partecipante B ') errore = models.BooleanField(initial=False) sommacontribbribe = models.IntegerField(initial=0) progettocomunepl2 = models.IntegerField() progettocomunepl3 = models.IntegerField() progettocomunepl4 = models.IntegerField() sumpunishment = models.IntegerField() faseuno = models.CurrencyField() redditoprivato = models.CurrencyField() errorecomprensione = models.IntegerField() contributionbeforepl2 = models.IntegerField() bribebeforepl2 = models.IntegerField() contributionbeforepl3 = models.IntegerField() contributionbeforepl4 = models.IntegerField() bribebeforepl3 = models.IntegerField() bribebeforepl4 = models.IntegerField() punizionebeforepl2 = models.IntegerField() punizionebeforepl3 = models.IntegerField() punizionebeforepl4 = models.IntegerField() bribeacceptancepl2 = models.IntegerField() bribeacceptancepl3 = models.IntegerField() bribeacceptancepl4 = models.IntegerField() contribuzionepl2 = models.IntegerField() contribuzionepl3 = models.IntegerField() contribuzionepl4 = models.IntegerField() my_field = models.StringField() def setglobals(player: Player): participant = player.participant participant.vars['BG_INFO_B_and_S_payoff'] = participant.payoff return(participant.vars) Player.setglobals = setglobals class Attesagruppixpartire(WaitPage): wait_for_all_groups = True @staticmethod def is_displayed(player: Player): return player.round_number == 1 class Istruzioni(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number == 1 class Instruction_II(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number == 1 class Instruction_III(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number == 1 class Instruction_IV(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number == 1 class Questions(Page): form_model = 'player' form_fields = ['Questionme', 'Question3', 'Questionbribe'] @staticmethod def is_displayed(player: Player): return player.round_number == 1 @staticmethod def error_message(player: Player, values): print ('values is', values) if values['Questionme'] != 27 or values['Questionbribe'] !=25 or values['Question3'] != 18: return 'Attenzione: Per procedere è necessario rispondere correttamente a tutte le domande. Per favore controlla le tue risposte.' class Role(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number == 1 class Start(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number == 1 class Info(Page): form_model = 'player' form_fields = ['Info'] @staticmethod def is_displayed(player: Player): group = player.group return player.id_in_group != 1 and player.round_number != 1 class ElaboratingInfo(WaitPage): after_all_players_arrive = info @staticmethod def is_displayed(player: Player): return player.round_number != 1 class DiscoveryUmpire(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): group = player.group return player.round_number != 1 and player.id_in_group != 1 and player.Info == True class Contribuzione(Page): form_model = 'player' form_fields = ['contribution'] @staticmethod def is_displayed(player: Player): group = player.group return player.id_in_group != 1 class Bribe_Fase2(Page): form_model = 'player' form_fields = ['bribe'] @staticmethod def is_displayed(player: Player): group = player.group return player.id_in_group != 1 class Giocatori(WaitPage): after_all_players_arrive = after_all_players_arrive @staticmethod def is_displayed(player: Player): group = player.group return player.id_in_group != 1 class WaitingUmpire(WaitPage): after_all_players_arrive = after_all_players_arrive body_text = 'Attendi che i partecipanti facciano le loro scelte' @staticmethod def is_displayed(player: Player): group = player.group return group.get_player_by_id(1) class Punishment2bribe(Page): form_model = 'player' form_fields = ['bribe2', 'punishment2', 'bribe3', 'punishment3', 'bribe4', 'punishment4'] @staticmethod def is_displayed(player: Player): group = player.group return player.id_in_group == 1 @staticmethod def error_message(player: Player, values): print ('values is', values) if values['punishment2'] + values['punishment3'] + values['punishment4'] > 15: return 'Attenzione: Puoi rimuovere in totale 15 punti e non piu di 10 punti per ciascun giocatore. Per favore effettua nuovamente la tua scelta.' class Attesagiocatori(WaitPage): after_all_players_arrive = after_all_players_arrive @staticmethod def is_displayed(player: Player): group = player.group return player.id_in_group != 1 class ExecutingPayoffRound1(WaitPage): after_all_players_arrive = set_payoff1 @staticmethod def is_displayed(player: Player): return player.round_number == 1 class ExecutingPayoff2(WaitPage): after_all_players_arrive = set_payoff2 @staticmethod def is_displayed(player: Player): return player.round_number != 1 class PayoffRound1(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number == 1 @staticmethod def before_next_page(player: Player, timeout_happened): player.setglobals() class Payoff2(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number != 1 @staticmethod def before_next_page(player: Player, timeout_happened): player.setglobals() class Ringraziamento(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number == 13 page_sequence = [Attesagruppixpartire, Istruzioni, Instruction_II, Instruction_III, Instruction_IV, Questions, Role, Start, Info, ElaboratingInfo, DiscoveryUmpire, Contribuzione, Bribe_Fase2, Giocatori, WaitingUmpire, Punishment2bribe, Attesagiocatori, ExecutingPayoffRound1, ExecutingPayoff2, PayoffRound1, Payoff2, Ringraziamento]