from otree.api import * c = cu doc = '' class C(BaseConstants): NAME_IN_URL = 'BG_INFO' PLAYERS_PER_GROUP = 4 NUM_ROUNDS = 5 INFOCOST = 3 ENDOWMENT = cu(20) MULTIPLIER = 2 INSTRUCTIONSUMPIRE_TEMPLATE = 'BG_INFO/instructionsumpire.html' INSTRUCTIONSPLAYER_TEMPLATE = 'BG_INFO/instructionsplayer.html' INSTRUCTIONSGENERIC_TEMPLATE = 'BG_INFO/instructionsgeneric.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() def my_function2(subsession: Subsession): session = subsession.session for g in subsession.get_groups(): if g.id_in_subsession == 1: subsession.corruzioneg1 = g.corruzioneround if g.id_in_subsession == 2: subsession.corruzioneg2 = g.corruzioneround if g.id_in_subsession == 3: subsession.corruzioneg3 = g.corruzioneround if g.id_in_subsession == 4: subsession.corruzioneg4 = g.corruzioneround subsession.corruzionesessione = subsession.corruzioneg1 + subsession.corruzioneg2 + subsession.corruzioneg3 + subsession.corruzioneg4 subsession.tuttacorruzione = sum([p.corruzionesessione for p in subsession.in_all_rounds()]) Subsession.my_function2 = my_function2 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): session = group.session subsession = group.subsession #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) p5 = group.get_player_by_id(5) for p in group.get_players(): # stinghe x pagine punishment arbitro/accettaz bribe 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 try: p.bribeplayer5 = 0 p1.bribeplayer5 = p5.bribe except TypeError: p5.bribe = None 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 try: p5.progettocomune = p5.contribution except TypeError: p5.contribution = None #stringhe x feedback da mostrare al player 2 (non faccio vedere le bribe) # if p3.progettocomune == "Uscita": try: p2.progettocomunepl3 = p3.progettocomune p1.progettocomunepl3 = p3.progettocomune p4.progettocomunepl3 = p3.progettocomune p5.progettocomunepl3 = p3.progettocomune except TypeError: p3.progettocomune = None try: p2.progettocomunepl4 = p4.progettocomune p1.progettocomunepl4 = p4.progettocomune p3.progettocomunepl4 = p4.progettocomune p5.progettocomunepl4 = p4.progettocomune except TypeError: p4.progettocomune = None try: p2.progettocomunepl5 = p5.progettocomune p1.progettocomunepl5 = p5.progettocomune p3.progettocomunepl5 = p5.progettocomune p4.progettocomunepl5 = p5.progettocomune except TypeError: p5.progettocomune = None try: p5.progettocomunepl2 = p2.progettocomune p1.progettocomunepl2 = p2.progettocomune p3.progettocomunepl2 = p2.progettocomune p4.progettocomunepl2 = p2.progettocomune except TypeError: p2.progettocomune = None #group number for p in group.get_players(): if group.id_in_subsession == 1: p1.numberg = 1 p2.numberg = 1 p3.numberg = 1 p4.numberg = 1 p5.numberg = 1 elif group.id_in_subsession == 2: p1.numberg = 2 p2.numberg = 2 p3.numberg = 2 p4.numberg = 2 p5.numberg = 2 elif group.id_in_subsession == 3: p1.numberg = 3 p2.numberg = 3 p3.numberg = 3 p4.numberg = 3 p5.numberg = 3 elif group.id_in_subsession == 4: p1.numberg = 4 p2.numberg = 4 p3.numberg = 4 p4.numberg = 4 p5.numberg = 4 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" if p5.Info == True: p5.infostringa = "Si" else: p5.infostringa = "No" except TypeError: p.Info = None partecipanti = 0 for p in group.get_players(): try: if p.contribution == 700: pass else: partecipanti = partecipanti + 1 except TypeError: p.contribution = None p.partecipantipg = partecipanti p1.partecipantipg = p5.partecipantipg p2.partecipantipg = p5.partecipantipg p3.partecipantipg = p5.partecipantipg p4.partecipantipg = p5.partecipantipg def set_payoff1(group: Group): contributions = 0 partecipanti= 0 bribe = 0 for p in group.get_players(): partecipanti = p.partecipantipg try: contributions = contributions + p.contribution bribe = bribe + p.bribe except TypeError: p.contribution = None p.bribe = None for p in group.get_players(): group.total_contribution= contributions * 2 group.individual_share = group.total_contribution / partecipanti #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) p5 = group.get_player_by_id(5) p1.mazzetta = bribe p.punizione2 = 0 if p1.punishment2 == 700: p1.punizione2 = 0 else: p.punizione2 = p.punizione2 + p1.punishment2 p.punizione3 = 0 if p1.punishment3 == 700: p1.punizione3 = 0 #pass else: p.punizione3 = p.punizione3 + p1.punishment3 p.punizione4 = 0 if p1.punishment4 == 700: p1.punizione4 = 0 # pass else: p.punizione4 = p.punizione4 + p1.punishment4 p.punizione5 = 0 if p1.punishment5 == 700: p1.punizione5 = 0 # pass else: p.punizione5 = p.punizione5 + p1.punishment5 p1.punizione2 = p5.punizione2 p1.punizione3 = p5.punizione3 p1.punizione4 = p5.punizione4 p1.punizione5 = p5.punizione5 p.punizione = 0 if p1.punishment2 == 700: p2.punizione = 0 else: p2.punizione = p.punizione2 if p1.punishment3 == 700: p3.punizione = 0 else: p3.punizione = p.punizione + p.punizione3 if p1.punishment4 == 700: p4.punizione = 0 else: p4.punizione = p.punizione + p.punizione4 if p1.punishment5 == 700: p5.punizione = 0 else: p5.punizione = p.punizione + p.punizione5 if p.punishment2 == 700: p1.punishment2 = 0 if p.punishment3 == 700: p1.punishment3 = 0 if p.punishment4 == 700: p1.punishment4 = 0 if p.punishment5 == 700: p1.punishment5 = 0 #payoff participants for p in group.get_players(): p2.payoff = C.ENDOWMENT - p2.contribution - p2.bribe + group.individual_share - p2.punizione p3.payoff = C.ENDOWMENT - p3.contribution - p3.bribe + group.individual_share - p3.punizione p4.payoff = C.ENDOWMENT - p4.contribution - p4.bribe + group.individual_share - p4.punizione p5.payoff = C.ENDOWMENT - p5.contribution - p5.bribe + group.individual_share - p5.punizione corruzione = 0 if partecipanti > 1: if p1.bribe2 > 0: corruzione = corruzione + 1 else: corruzione = corruzione + 0 if p1.bribe3 > 0: corruzione = corruzione + 1 else: corruzione = corruzione + 0 if p1.bribe4 > 0: corruzione = corruzione + 1 else: corruzione = corruzione + 0 if p1.bribe5 > 0: corruzione = corruzione + 1 else: corruzione = corruzione + 0 else: corruzione = corruzione + 0 p1.corruzione = corruzione p2.corruzione = corruzione p3.corruzione = corruzione p4.corruzione = corruzione p5.corruzione = corruzione #corruzioneround = corruzione nei gruppo corruzioneround = 0 if corruzione > 0: corruzioneround = 1 + corruzioneround else: corruzioneround = 0 + corruzioneround group.corruzioneround = corruzioneround 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 if p1.bribe5 == 1: p.bribepl5 = p1.bribeplayer5 else: p.bribepl5 = 0 p1.bribepl2 = p5.bribepl2 p1.bribepl3 = p5.bribepl3 p1.bribepl4 = p5.bribepl4 p1.bribepl5 = p5.bribepl5 #if p1.bribe2 == 1: # p1.bribepl2 = p1.bribeplayer2 #if p1.bribe3 == 1: # p1.bribepl3 = p1.bribeplayer3 #if p1.bribe4 == 1: # p1.bribepl4 = p1.bribeplayer4 #if p1.bribe5 == 1: # p1.bribepl5 = p1.bribeplayer5 p.valoremazzetta = p1.bribepl2 + p1.bribepl3 + p1.bribepl4 + p1.bribepl5 p1.valoremazzetta = p5.valoremazzetta corruttori = 0 for p in group.get_players(): if partecipanti > 1: try: if p.bribe > 0: corruttori = corruttori + 1 else: corruttori = corruttori + 0 except TypeError: p.bribe = None p1.corruttori = corruttori p2.corruttori = corruttori p3.corruttori = corruttori p4.corruttori = corruttori p5.corruttori = corruttori #payoff arbitro if partecipanti > 1: if group.total_contribution >= 54: p1.payoff = 17 + 8 + p.valoremazzetta p1.bonus = 8 else: p1.payoff = 17 + p.valoremazzetta p1.bonus = 0 else: p1.payoff = 17 p1.bonus = 0 def set_payoff2(group: Group): #payoff round > 1 contributions = 0 partecipanti= 0 bribe = 0 for p in group.get_players(): partecipanti = p.partecipantipg try: contributions = contributions + p.contribution bribe = bribe + p.bribe except TypeError: p.contribution = None p.bribe = None for p in group.get_players(): group.total_contribution= contributions * 2 group.individual_share = group.total_contribution / partecipanti 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) p5 = group.get_player_by_id(5) #p1.partecipantipg = partecipanti #p2.partecipantipg = partecipanti #p3.partecipantipg = partecipanti #p4.partecipantipg = partecipanti #p5.partecipantipg = partecipanti p1.mazzetta = bribe p.punizione2 = 0 if p1.punishment2 == 700: p1.punizione2 = 0 else: p.punizione2 = p.punizione2 + p1.punishment2 p.punizione3 = 0 if p1.punishment3 == 700: p1.punizione3 = 0 else: p.punizione3 = p.punizione3 + p1.punishment3 p.punizione4 = 0 if p1.punishment4 == 700: p1.punizione4 = 0 else: p.punizione4 = p.punizione4 + p1.punishment4 p.punizione5 = 0 if p1.punishment5 == 700: p1.punizione5 = 0 else: p.punizione5 = p.punizione5 + p1.punishment5 p1.punizione2 = p5.punizione2 p1.punizione3 = p5.punizione3 p1.punizione4 = p5.punizione4 p1.punizione5 = p5.punizione5 p.punizione = 0 if p1.punishment2 == 700: p2.punizione = 0 else: p2.punizione = p.punizione2 if p1.punishment3 == 700: p3.punizione = 0 else: p3.punizione = p.punizione + p.punizione3 if p1.punishment4 == 700: p4.punizione = 0 else: p4.punizione = p.punizione + p.punizione4 if p1.punishment5 == 700: p5.punizione = 0 else: p5.punizione = p.punizione + p.punizione5 if p.punishment2 == 700: p1.punishment2 = 0 if p.punishment3 == 700: p1.punishment3 = 0 if p.punishment4 == 700: p1.punishment4 = 0 if p.punishment5 == 700: p1.punishment5 = 0 for p in group.get_players(): if p2.Info == True: p2.payoff = C.ENDOWMENT - p2.contribution - p2.bribe + group.individual_share - p2.punizione - C.INFOCOST else: p2.payoff = C.ENDOWMENT - p2.contribution - p2.bribe + group.individual_share - p2.punizione #else: # p2.payoff = C.ENDOWMENT for p in group.get_players(): if p3.Info == True: p3.payoff = C.ENDOWMENT - p3.contribution - p3.bribe + group.individual_share - p3.punizione - C.INFOCOST else: p3.payoff = C.ENDOWMENT - p3.contribution - p3.bribe + group.individual_share - p3.punizione # else: # p3.payoff = C.ENDOWMENT for p in group.get_players(): if p4.Info == True: p4.payoff = C.ENDOWMENT - p4.contribution - p4.bribe + group.individual_share - p4.punizione - C.INFOCOST else: p4.payoff = C.ENDOWMENT - p4.contribution - p4.bribe + group.individual_share - p4.punizione #else: # p4.payoff = C.ENDOWMENT for p in group.get_players(): if p5.Info == True: p5.payoff = C.ENDOWMENT - p5.contribution - p5.bribe + group.individual_share - p5.punizione - C.INFOCOST else: p5.payoff = C.ENDOWMENT - p5.contribution - p5.bribe + group.individual_share - p5.punizione # else: # p5.payoff = C.ENDOWMENT corruzione = 0 if partecipanti > 1: if p1.bribe2 > 0: corruzione = corruzione + 1 else: corruzione = corruzione + 0 if p1.bribe3 > 0: corruzione = corruzione + 1 else: corruzione = corruzione + 0 if p1.bribe4 > 0: corruzione = corruzione + 1 else: corruzione = corruzione + 0 if p1.bribe5 > 0: corruzione = corruzione + 1 else: corruzione = corruzione + 0 else: corruzione = corruzione + 0 p1.corruzione = corruzione p2.corruzione = corruzione p3.corruzione = corruzione p4.corruzione = corruzione p5.corruzione = corruzione corruzioneround = 0 if corruzione >0: corruzioneround = 1 + corruzioneround else: corruzioneround = 0 + corruzioneround group.corruzioneround = corruzioneround 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 if p1.bribe5 == 1: p.bribepl5 = p1.bribeplayer5 else: p.bribepl5 = 0 p1.bribepl2 = p5.bribepl2 p1.bribepl3 = p5.bribepl3 p1.bribepl4 = p5.bribepl4 p1.bribepl5 = p5.bribepl5 #p2.bribepl2 = p.bribepl2 + p1.bribe2 #p3.bribepl3 = p.bribepl3 + p1.bribe3 #p4.bribepl4 = p.bribepl4 + p1.bribe4 #p5.bribepl5 = p.bribepl5 + p1.bribe5 #p1.bribepl2 = p5.bribepl2 #p1.bribepl3 = p5.bribepl3 #p1.bribepl4 = p5.bribepl4 #p1.bribepl5 = p5.bribepl5 p.valoremazzetta = 0 + p1.bribepl2 + p1.bribepl3 + p1.bribepl4 + p1.bribepl5 p1.valoremazzetta = p5.valoremazzetta corruttori = 0 for p in group.get_players(): if partecipanti > 1: try: if p.bribe > 0: corruttori = corruttori + 1 else: corruttori = corruttori + 0 except TypeError: p.bribe = None p1.corruttori = corruttori p2.corruttori = corruttori p3.corruttori = corruttori p4.corruttori = corruttori p5.corruttori = corruttori #payoff arbitro if partecipanti > 1: if group.total_contribution >= 54: p1.payoff= 17 + 8 + p.valoremazzetta p1.bonus = 8 else: p1.payoff = 17 + p.valoremazzetta p1.bonus = 0 else: p1.payoff = 17 p1.bonus = 0 def corruzione_prima(group: Group): #group number p1 = group.get_player_by_id(1) for p in group.get_players(): if p.in_round(group.round_number - 1).numberg == 1 and p1.in_round(group.round_number - 1).corruzione == 0: p.corruzioneprima = "0 volte" if p.in_round(group.round_number - 1).numberg == 1 and p1.in_round(group.round_number - 1).corruzione == 1: p.corruzioneprima = "1 volta" if p.in_round(group.round_number - 1).numberg == 1 and p1.in_round(group.round_number - 1).corruzione == 2: p.corruzioneprima = "2 volte" if p.in_round(group.round_number - 1).numberg == 1 and p1.in_round(group.round_number - 1).corruzione == 3: p.corruzioneprima = "3 volte" if p.in_round(group.round_number - 1).numberg == 1 and p1.in_round(group.round_number - 1).corruzione == 4: p.corruzioneprima = "4 volte" for p in group.get_players(): if p.in_round(group.round_number - 1).numberg == 2 and p1.in_round(group.round_number - 1).corruzione == 0: p.corruzioneprima = "0 volte" if p.in_round(group.round_number - 1).numberg == 2 and p1.in_round(group.round_number - 1).corruzione == 1: p.corruzioneprima = "1 volta" if p.in_round(group.round_number - 1).numberg == 2 and p1.in_round(group.round_number - 1).corruzione == 2: p.corruzioneprima = "2 volte" if p.in_round(group.round_number - 1).numberg == 2 and p1.in_round(group.round_number - 1).corruzione == 3: p.corruzioneprima = "3 volte" if p.in_round(group.round_number - 1).numberg == 2 and p1.in_round(group.round_number - 1).corruzione == 4: p.corruzioneprima = "4 volte" for p in group.get_players(): if p.in_round(group.round_number - 1).numberg == 3 and p1.in_round(group.round_number - 1).corruzione == 0: p.corruzioneprima = "0 volte" if p.in_round(group.round_number - 1).numberg == 3 and p1.in_round(group.round_number - 1).corruzione == 1: p.corruzioneprima = "1 volta" if p.in_round(group.round_number - 1).numberg == 3 and p1.in_round(group.round_number - 1).corruzione == 2: p.corruzioneprima = "2 volte" if p.in_round(group.round_number - 1).numberg == 3 and p1.in_round(group.round_number - 1).corruzione == 3: p.corruzioneprima = "3 volte" if p.in_round(group.round_number - 1).numberg == 3 and p1.in_round(group.round_number - 1).corruzione == 4: p.corruzioneprima = "4 volte" for p in group.get_players(): if p.in_round(group.round_number - 1).numberg == 4 and p1.in_round(group.round_number - 1).corruzione == 0: p.corruzioneprima = "0 volte" if p.in_round(group.round_number - 1).numberg == 4 and p1.in_round(group.round_number - 1).corruzione == 1: p.corruzioneprima = "1 volta" if p.in_round(group.round_number - 1).numberg == 4 and p1.in_round(group.round_number - 1).corruzione == 2: p.corruzioneprima = "2 volte" if p.in_round(group.round_number - 1).numberg == 4 and p1.in_round(group.round_number - 1).corruzione == 3: p.corruzioneprima = "3 volte" if p.in_round(group.round_number - 1).numberg == 4 and p1.in_round(group.round_number - 1).corruzione == 4: p.corruzioneprima = "4 volte" for p in group.get_players(): if p.in_round(group.round_number - 1).numberg == 5 and p1.in_round(group.round_number - 1).corruzione == 0: p.corruzioneprima = "0 volte" if p.in_round(group.round_number - 1).numberg == 5 and p1.in_round(group.round_number - 1).corruzione == 1: p.corruzioneprima = "1 volta" if p.in_round(group.round_number - 1).numberg == 5 and p1.in_round(group.round_number - 1).corruzione == 2: p.corruzioneprima = "2 volte" if p.in_round(group.round_number - 1).numberg == 5 and p1.in_round(group.round_number - 1).corruzione == 3: p.corruzioneprima = "3 volte" if p.in_round(group.round_number - 1).numberg == 5 and p1.in_round(group.round_number - 1).corruzione == 4: p.corruzioneprima = "4 volte" def corruttori_prima(group: Group): session = group.session subsession = group.subsession 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) p5 = group.get_player_by_id(5) for p in group.get_players(): if group.id_in_subsession == 1: p1.numberg = 1 p2.numberg = 1 p3.numberg = 1 p4.numberg = 1 p5.numberg = 1 elif group.id_in_subsession == 2: p1.numberg = 2 p2.numberg = 2 p3.numberg = 2 p4.numberg = 2 p5.numberg = 2 elif group.id_in_subsession == 3: p1.numberg = 3 p2.numberg = 3 p3.numberg = 3 p4.numberg = 3 p5.numberg = 3 elif group.id_in_subsession == 4: p1.numberg = 4 p2.numberg = 4 p3.numberg = 4 p4.numberg = 4 p5.numberg = 4 elif group.id_in_subsession == 5: p1.numberg = 5 p2.numberg = 5 p3.numberg = 5 p4.numberg = 5 p5.numberg = 5 for p in group.get_players(): if p1.in_round(group.round_number - 1).numberg == 1: p.umpirelastgroup = 1 if p1.in_round(group.round_number - 1).numberg == 2: p.umpirelastgroup = 2 if p1.in_round(group.round_number - 1).numberg == 3: p.umpirelastgroup = 3 if p1.in_round(group.round_number - 1).numberg == 4: p.umpirelastgroup = 4 if p1.in_round(group.round_number - 1).numberg == 5: p.umpirelastgroup = 5 for p in group.get_players(): if p.in_round(group.round_number - 1).numberg == 1 and p1.in_round(group.round_number - 1).corruttori == 0: p.corruttoriprima = "0 volte" if p.in_round(group.round_number - 1).numberg == 1 and p1.in_round(group.round_number - 1).corruttori == 1: p.corruttoriprima = "1 volta" if p.in_round(group.round_number - 1).numberg == 1 and p1.in_round(group.round_number - 1).corruttori == 2: p.corruttoriprima = "2 volte" if p.in_round(group.round_number - 1).numberg == 1 and p1.in_round(group.round_number - 1).corruttori == 3: p.corruttoriprima = "3 volte" if p.in_round(group.round_number - 1).numberg == 1 and p1.in_round(group.round_number - 1).corruttori == 4: p.corruttoriprima = "4 volte" for p in group.get_players(): if p.in_round(group.round_number - 1).numberg == 2 and p1.in_round(group.round_number - 1).corruttori == 0: p.corruttoriprima = "0 volte" if p.in_round(group.round_number - 1).numberg == 2 and p1.in_round(group.round_number - 1).corruttori == 1: p.corruttoriprima = "1 volta" if p.in_round(group.round_number - 1).numberg == 2 and p1.in_round(group.round_number - 1).corruttori == 2: p.corruttoriprima = "2 volte" if p.in_round(group.round_number - 1).numberg == 2 and p1.in_round(group.round_number - 1).corruttori == 3: p.corruttoriprima = "3 volte" if p.in_round(group.round_number - 1).numberg == 2 and p1.in_round(group.round_number - 1).corruttori == 4: p.corruttoriprima = "4 volte" for p in group.get_players(): if p.in_round(group.round_number - 1).numberg == 3 and p1.in_round(group.round_number - 1).corruttori == 0: p.corruttoriprima = "0 volte" if p.in_round(group.round_number - 1).numberg == 3 and p1.in_round(group.round_number - 1).corruttori == 1: p.corruttoriprima = "1 volta" if p.in_round(group.round_number - 1).numberg == 3 and p1.in_round(group.round_number - 1).corruttori == 2: p.corruttoriprima = "2 volte" if p.in_round(group.round_number - 1).numberg == 3 and p1.in_round(group.round_number - 1).corruttori == 3: p.corruttoriprima = "3 volte" if p.in_round(group.round_number - 1).numberg == 3 and p1.in_round(group.round_number - 1).corruttori == 4: p.corruttoriprima = "4 volte" for p in group.get_players(): if p.in_round(group.round_number - 1).numberg == 4 and p1.in_round(group.round_number - 1).corruttori == 0: p.corruttoriprima = "0 volte" if p.in_round(group.round_number - 1).numberg == 4 and p1.in_round(group.round_number - 1).corruttori == 1: p.corruttoriprima = "1 volta" if p.in_round(group.round_number - 1).numberg == 4 and p1.in_round(group.round_number - 1).corruttori == 2: p.corruttoriprima = "2 volte" if p.in_round(group.round_number - 1).numberg == 4 and p1.in_round(group.round_number - 1).corruttori == 3: p.corruttoriprima = "3 volte" if p.in_round(group.round_number - 1).numberg == 4 and p1.in_round(group.round_number - 1).corruttori == 4: p.corruttoriprima = "4 volte" for p in group.get_players(): if p.in_round(group.round_number - 1).numberg == 5 and p1.in_round(group.round_number - 1).corruttori == 0: p.corruttoriprima = "0 volte" if p.in_round(group.round_number - 1).numberg == 5 and p1.in_round(group.round_number - 1).corruttori == 1: p.corruttoriprima = "1 volta" if p.in_round(group.round_number - 1).numberg == 5 and p1.in_round(group.round_number - 1).corruttori == 2: p.corruttoriprima = "2 volte" if p.in_round(group.round_number - 1).numberg == 5 and p1.in_round(group.round_number - 1).corruttori == 3: p.corruttoriprima = "3 volte" if p.in_round(group.round_number - 1).numberg == 5 and p1.in_round(group.round_number - 1).corruttori == 4: p.corruttoriprima = "4 volte" def contribuzioni_gruppo_precedente_arbitro(group: Group): p2 = group.get_player_by_id(2) p3 = group.get_player_by_id(3) p4 = group.get_player_by_id(4) p1 = group.get_player_by_id(1) p5 = group.get_player_by_id(5) for p in group.get_players(): if p1.in_round(group.round_number - 1).numberg == 1: p.umpirelastgroup = 1 if p1.in_round(group.round_number - 1).numberg == 2: p.umpirelastgroup = 2 if p1.in_round(group.round_number - 1).numberg == 3: p.umpirelastgroup = 3 if p1.in_round(group.round_number - 1).numberg == 4: p.umpirelastgroup = 4 if p1.in_round(group.round_number - 1).numberg == 5: p.umpirelastgroup = 5 if p1.in_round(group.round_number - 1).numberg == 6: p.umpirelastgroup = 6 # giocate precedenti del gruppo dell'arbitro (registrate nel id dell'arbitro) for p in group.get_players(): if p.umpirelastgroup == 1: p2.g1pl2 = p1.in_round(group.round_number - 1).gruppo1pl2 p3.g1pl2 = p1.in_round(group.round_number - 1).gruppo1pl2 p4.g1pl2 = p1.in_round(group.round_number - 1).gruppo1pl2 p5.g1pl2 = p1.in_round(group.round_number - 1).gruppo1pl2 p2.g1pl3 = p1.in_round(group.round_number - 1).gruppo1pl3 p3.g1pl3 = p1.in_round(group.round_number - 1).gruppo1pl3 p4.g1pl3 = p1.in_round(group.round_number - 1).gruppo1pl3 p5.g1pl3 = p1.in_round(group.round_number - 1).gruppo1pl3 p2.g1pl4 = p1.in_round(group.round_number - 1).gruppo1pl4 p3.g1pl4 = p1.in_round(group.round_number - 1).gruppo1pl4 p4.g1pl4 = p1.in_round(group.round_number - 1).gruppo1pl4 p5.g1pl4 = p1.in_round(group.round_number - 1).gruppo1pl4 p2.g1pl5 = p1.in_round(group.round_number - 1).gruppo1pl5 p3.g1pl5 = p1.in_round(group.round_number - 1).gruppo1pl5 p4.g1pl5 = p1.in_round(group.round_number - 1).gruppo1pl5 p5.g1pl5 = p1.in_round(group.round_number - 1).gruppo1pl5 p2.partecipantiprima = p1.in_round(group.round_number - 1).partecipantipg1 p3.partecipantiprima = p1.in_round(group.round_number - 1).partecipantipg1 p4.partecipantiprima = p1.in_round(group.round_number - 1).partecipantipg1 p1.partecipantiprima = p1.in_round(group.round_number - 1).partecipantipg1 p5.partecipantiprima = p1.in_round(group.round_number - 1).partecipantipg1 for p in group.get_players(): if p.umpirelastgroup == 2: p2.g2pl2 = p1.in_round(group.round_number - 1).gruppo2pl2 p3.g2pl2 = p1.in_round(group.round_number - 1).gruppo2pl2 p4.g2pl2 = p1.in_round(group.round_number - 1).gruppo2pl2 p5.g2pl2 = p1.in_round(group.round_number - 1).gruppo2pl2 p2.g2pl3 = p1.in_round(group.round_number - 1).gruppo2pl3 p3.g2pl3 = p1.in_round(group.round_number - 1).gruppo2pl3 p4.g2pl3 = p1.in_round(group.round_number - 1).gruppo2pl3 p5.g2pl3 = p1.in_round(group.round_number - 1).gruppo2pl3 p2.g2pl4 = p1.in_round(group.round_number - 1).gruppo2pl4 p3.g2pl4 = p1.in_round(group.round_number - 1).gruppo2pl4 p4.g2pl4 = p1.in_round(group.round_number - 1).gruppo2pl4 p5.g2pl4 = p1.in_round(group.round_number - 1).gruppo2pl4 p2.g2pl5 = p1.in_round(group.round_number - 1).gruppo2pl5 p3.g2pl5 = p1.in_round(group.round_number - 1).gruppo2pl5 p4.g2pl5 = p1.in_round(group.round_number - 1).gruppo2pl5 p5.g2pl5 = p1.in_round(group.round_number - 1).gruppo2pl5 p2.partecipantiprima = p1.in_round(group.round_number - 1).partecipantipg2 p3.partecipantiprima = p1.in_round(group.round_number - 1).partecipantipg2 p4.partecipantiprima = p1.in_round(group.round_number - 1).partecipantipg2 p1.partecipantiprima = p1.in_round(group.round_number - 1).partecipantipg2 p5.partecipantiprima = p1.in_round(group.round_number - 1).partecipantipg2 for p in group.get_players(): if p.umpirelastgroup == 3: p2.g3pl2 = p1.in_round(group.round_number - 1).gruppo3pl2 p3.g3pl2 = p1.in_round(group.round_number - 1).gruppo3pl2 p4.g3pl2 = p1.in_round(group.round_number - 1).gruppo3pl2 p5.g3pl2 = p1.in_round(group.round_number - 1).gruppo3pl2 p2.g3pl3 = p1.in_round(group.round_number - 1).gruppo3pl3 p3.g3pl3 = p1.in_round(group.round_number - 1).gruppo3pl3 p4.g3pl3 = p1.in_round(group.round_number - 1).gruppo3pl3 p5.g3pl3 = p1.in_round(group.round_number - 1).gruppo3pl3 p2.g3pl4 = p1.in_round(group.round_number - 1).gruppo3pl4 p3.g3pl4 = p1.in_round(group.round_number - 1).gruppo3pl4 p4.g3pl4 = p1.in_round(group.round_number - 1).gruppo3pl4 p5.g3pl4 = p1.in_round(group.round_number - 1).gruppo3pl4 p2.g3pl5 = p1.in_round(group.round_number - 1).gruppo3pl5 p3.g3pl5 = p1.in_round(group.round_number - 1).gruppo3pl5 p4.g3pl5 = p1.in_round(group.round_number - 1).gruppo3pl5 p5.g3pl5 = p1.in_round(group.round_number - 1).gruppo3pl5 p2.partecipantiprima = p1.in_round(group.round_number - 1).partecipantipg3 p3.partecipantiprima = p1.in_round(group.round_number - 1).partecipantipg3 p4.partecipantiprima = p1.in_round(group.round_number - 1).partecipantipg3 p1.partecipantiprima = p1.in_round(group.round_number - 1).partecipantipg3 p5.partecipantiprima = p1.in_round(group.round_number - 1).partecipantipg3 for p in group.get_players(): if p.umpirelastgroup == 4: p2.g4pl2 = p1.in_round(group.round_number - 1).gruppo4pl2 p3.g4pl2 = p1.in_round(group.round_number - 1).gruppo4pl2 p4.g4pl2 = p1.in_round(group.round_number - 1).gruppo4pl2 p5.g4pl2 = p1.in_round(group.round_number - 1).gruppo4pl2 p2.g4pl3 = p1.in_round(group.round_number - 1).gruppo4pl3 p3.g4pl3 = p1.in_round(group.round_number - 1).gruppo4pl3 p4.g4pl3 = p1.in_round(group.round_number - 1).gruppo4pl3 p5.g4pl3 = p1.in_round(group.round_number - 1).gruppo4pl3 p2.g4pl4 = p1.in_round(group.round_number - 1).gruppo4pl4 p3.g4pl4 = p1.in_round(group.round_number - 1).gruppo4pl4 p4.g4pl4 = p1.in_round(group.round_number - 1).gruppo4pl4 p5.g4pl4 = p1.in_round(group.round_number - 1).gruppo4pl4 p2.g4pl5 = p1.in_round(group.round_number - 1).gruppo4pl5 p3.g4pl5 = p1.in_round(group.round_number - 1).gruppo4pl5 p4.g4pl5 = p1.in_round(group.round_number - 1).gruppo4pl5 p5.g4pl5 = p1.in_round(group.round_number - 1).gruppo4pl5 p2.partecipantiprima = p1.in_round(group.round_number - 1).partecipantipg4 p3.partecipantiprima = p1.in_round(group.round_number - 1).partecipantipg4 p4.partecipantiprima = p1.in_round(group.round_number - 1).partecipantipg4 p1.partecipantiprima = p1.in_round(group.round_number - 1).partecipantipg4 p5.partecipantiprima = p1.in_round(group.round_number - 1).partecipantipg4 def punizioni_gruppo_precedente_arbitro(group: Group): p2 = group.get_player_by_id(2) p3 = group.get_player_by_id(3) p4 = group.get_player_by_id(4) p1 = group.get_player_by_id(1) p5 = group.get_player_by_id(5) #puizioni passate gruppo 1 for p in group.get_players(): if p.umpirelastgroup == 1: p2.p1pl2 = p1.in_round(group.round_number - 1).punizgruppo1pl2 p3.p1pl2 = p1.in_round(group.round_number - 1).punizgruppo1pl2 p4.p1pl2 = p1.in_round(group.round_number - 1).punizgruppo1pl2 p5.p1pl2 = p1.in_round(group.round_number - 1).punizgruppo1pl2 p2.p1pl3 = p1.in_round(group.round_number - 1).punizgruppo1pl3 p3.p1pl3 = p1.in_round(group.round_number - 1).punizgruppo1pl3 p4.p1pl3 = p1.in_round(group.round_number - 1).punizgruppo1pl3 p5.p1pl3 = p1.in_round(group.round_number - 1).punizgruppo1pl3 p2.p1pl4 = p1.in_round(group.round_number - 1).punizgruppo1pl4 p3.p1pl4 = p1.in_round(group.round_number - 1).punizgruppo1pl4 p4.p1pl4 = p1.in_round(group.round_number - 1).punizgruppo1pl4 p5.p1pl4 = p1.in_round(group.round_number - 1).punizgruppo1pl4 p2.p1pl5 = p1.in_round(group.round_number - 1).punizgruppo1pl5 p3.p1pl5 = p1.in_round(group.round_number - 1).punizgruppo1pl5 p4.p1pl5 = p1.in_round(group.round_number - 1).punizgruppo1pl5 p5.p1pl5 = p1.in_round(group.round_number - 1).punizgruppo1pl5 for p in group.get_players(): if p.umpirelastgroup == 2: p2.p2pl2 = p1.in_round(group.round_number - 1).punizgruppo2pl2 p3.p2pl2 = p1.in_round(group.round_number - 1).punizgruppo2pl2 p4.p2pl2 = p1.in_round(group.round_number - 1).punizgruppo2pl2 p5.p2pl2 = p1.in_round(group.round_number - 1).punizgruppo2pl2 p2.p2pl3 = p1.in_round(group.round_number - 1).punizgruppo2pl3 p3.p2pl3 = p1.in_round(group.round_number - 1).punizgruppo2pl3 p4.p2pl3 = p1.in_round(group.round_number - 1).punizgruppo2pl3 p5.p2pl3 = p1.in_round(group.round_number - 1).punizgruppo2pl3 p2.p2pl4 = p1.in_round(group.round_number - 1).punizgruppo2pl4 p3.p2pl4 = p1.in_round(group.round_number - 1).punizgruppo2pl4 p4.p2pl4 = p1.in_round(group.round_number - 1).punizgruppo2pl4 p5.p2pl4 = p1.in_round(group.round_number - 1).punizgruppo2pl4 p2.p2pl5 = p1.in_round(group.round_number - 1).punizgruppo2pl5 p3.p2pl5 = p1.in_round(group.round_number - 1).punizgruppo2pl5 p4.p2pl5 = p1.in_round(group.round_number - 1).punizgruppo2pl5 p5.p2pl5 = p1.in_round(group.round_number - 1).punizgruppo2pl5 for p in group.get_players(): if p.umpirelastgroup == 3: p2.p3pl2 = p1.in_round(group.round_number - 1).punizgruppo3pl2 p3.p3pl2 = p1.in_round(group.round_number - 1).punizgruppo3pl2 p4.p3pl2 = p1.in_round(group.round_number - 1).punizgruppo3pl2 p5.p3pl2 = p1.in_round(group.round_number - 1).punizgruppo3pl2 p2.p3pl3 = p1.in_round(group.round_number - 1).punizgruppo3pl3 p3.p3pl3 = p1.in_round(group.round_number - 1).punizgruppo3pl3 p4.p3pl3 = p1.in_round(group.round_number - 1).punizgruppo3pl3 p5.p3pl3 = p1.in_round(group.round_number - 1).punizgruppo3pl3 p2.p3pl4 = p1.in_round(group.round_number - 1).punizgruppo3pl4 p3.p3pl4 = p1.in_round(group.round_number - 1).punizgruppo3pl4 p4.p3pl4 = p1.in_round(group.round_number - 1).punizgruppo3pl4 p5.p3pl4 = p1.in_round(group.round_number - 1).punizgruppo3pl4 p2.p3pl5 = p1.in_round(group.round_number - 1).punizgruppo3pl5 p3.p3pl5 = p1.in_round(group.round_number - 1).punizgruppo3pl5 p4.p3pl5 = p1.in_round(group.round_number - 1).punizgruppo3pl5 p5.p3pl5 = p1.in_round(group.round_number - 1).punizgruppo3pl5 for p in group.get_players(): if p.umpirelastgroup == 4: p2.p4pl2 = p1.in_round(group.round_number - 1).punizgruppo4pl2 p3.p4pl2 = p1.in_round(group.round_number - 1).punizgruppo4pl2 p4.p4pl2 = p1.in_round(group.round_number - 1).punizgruppo4pl2 p5.p4pl2 = p1.in_round(group.round_number - 1).punizgruppo4pl2 p2.p4pl3 = p1.in_round(group.round_number - 1).punizgruppo4pl3 p3.p4pl3 = p1.in_round(group.round_number - 1).punizgruppo4pl3 p4.p4pl3 = p1.in_round(group.round_number - 1).punizgruppo4pl3 p5.p4pl3 = p1.in_round(group.round_number - 1).punizgruppo4pl3 p2.p4pl4 = p1.in_round(group.round_number - 1).punizgruppo4pl4 p3.p4pl4 = p1.in_round(group.round_number - 1).punizgruppo4pl4 p4.p4pl4 = p1.in_round(group.round_number - 1).punizgruppo4pl4 p5.p4pl4 = p1.in_round(group.round_number - 1).punizgruppo4pl4 p2.p4pl5 = p1.in_round(group.round_number - 1).punizgruppo4pl5 p3.p4pl5 = p1.in_round(group.round_number - 1).punizgruppo4pl5 p4.p4pl5 = p1.in_round(group.round_number - 1).punizgruppo4pl5 p5.p4pl5 = p1.in_round(group.round_number - 1).punizgruppo4pl5 def punizioni_gruppi(group: Group): #registro le punizioni per poterle ripescare al momento dell'acquisto dell'info p2 = group.get_player_by_id(2) p3 = group.get_player_by_id(3) p4 = group.get_player_by_id(4) p1 = group.get_player_by_id(1) p5 = group.get_player_by_id(5) #punizioni gruppo 1 #check for exit? for p in group.get_players(): if p2.numberg == 1: p1.punizgruppo1pl2 = p2.punizione if p3.numberg == 1: p1.punizgruppo1pl3 = p3.punizione if p4.numberg == 1: p1.punizgruppo1pl4 = p4.punizione if p5.numberg == 1: p1.punizgruppo1pl5 = p5.punizione #for p in group.get_players(): #for p in group.get_players(): # if p4.numberg == 1: # p1.punizgruppo1pl4 = p4.punizione #for p in group.get_players(): #puizioni gruppo 2 for p in group.get_players(): if p2.numberg == 2: p1.punizgruppo2pl2 = p2.punizione if p3.numberg == 2: p1.punizgruppo2pl3 = p3.punizione if p4.numberg == 2: p1.punizgruppo2pl4 = p4.punizione if p5.numberg == 2: p1.punizgruppo2pl5 = p5.punizione #for p in group.get_players(): #for p in group.get_players(): #for p in group.get_players(): #puizioni passate gruppo 3 for p in group.get_players(): if p2.numberg == 3 : p1.punizgruppo3pl2 = p2.punizione if p3.numberg == 3: p1.punizgruppo3pl3 = p3.punizione if p4.numberg == 3: p1.punizgruppo3pl4 = p4.punizione if p5.numberg == 3: p1.punizgruppo3pl5 = p5.punizione #puizioni passate gruppo 4 for p in group.get_players(): if p2.numberg == 4: p1.punizgruppo4pl2 = p2.punizione if p3.numberg == 4: p1.punizgruppo4pl3 = p3.punizione if p4.numberg == 4 : p1.punizgruppo4pl4 = p4.punizione if p5.numberg == 4: p1.punizgruppo4pl5 = p5.punizione #partecipanti for p in group.get_players(): if p.numberg == 1 and p.partecipantipg == 0: p.partecipantipg1 = 0 elif p.numberg == 1 and p.partecipantipg == 1: p.partecipantipg1 = 0 else: p.partecipantipg1 = 100 for p in group.get_players(): if p.numberg == 2 and p.partecipantipg == 0: p.partecipantipg2 = 0 elif p.numberg == 2 and p.partecipantipg == 1: p.partecipantipg2 = 0 else: p.partecipantipg2 = 100 for p in group.get_players(): if p.numberg == 3 and p.partecipantipg == 0: p.partecipantipg3 = 0 elif p.numberg == 3 and p.partecipantipg == 1: p.partecipantipg3 = 0 else: p.partecipantipg3 = 100 for p in group.get_players(): if p.numberg == 4 and p.partecipantipg == 0: p.partecipantipg4 = 0 elif p.numberg == 4 and p.partecipantipg == 1: p.partecipantipg4 = 0 else: p.partecipantipg4 = 100 def giocate(group: Group): 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) p5 = group.get_player_by_id(5) # registro le giocate gruppo 1 for p in group.get_players(): try: if p2.numberg == 1: p1.gruppo1pl2 = p2.contribution except TypeError: p2.contribution = None try: if p3.numberg == 1: #if p3.contribution == 700: # p1.gruppo1pl3 = "Uscita" #else: p1.gruppo1pl3 = p3.contribution except TypeError: p3.contribution = None try: if p4.numberg == 1: # if p1.gruppo1pl4 == 700: # p1.gruppo1pl4 = "Uscita" # else: p1.gruppo1pl4 = p4.contribution except TypeError: p3.contribution = None try: if p5.numberg == 1: # if p1.gruppo1pl5 == 700: # p1.gruppo1pl5 = "Uscita" # else: p1.gruppo1pl5 = p5.contribution except TypeError: p5.contribution = None # registro le giocate gruppo 2 for p in group.get_players(): try: if p2.numberg == 2: # if p2.contribution == 700: # p1.gruppo2pl2 = "Uscita" # else: p1.gruppo2pl2 = p2.contribution except TypeError: p2.contribution = None try: if p3.numberg == 2: # if p3.contribution == 700: # p1.gruppo2pl3 = "Uscita" # else: p1.gruppo2pl3 = p3.contribution except TypeError: p3.contribution = None try: if p4.numberg == 2: # if p4.contribution == 700: # p1.gruppo2pl4 = "Uscita" # else: p1.gruppo2pl4 = p4.contribution except TypeError: p3.contribution = None try: if p4.numberg == 2: # if p5.contribution == 700: # p1.gruppo2pl5 = "Uscita" # else: p1.gruppo2pl5 = p5.contribution except TypeError: p5.contribution = None # registro le giocate gruppo 3 for p in group.get_players(): try: # if p2.numberg == 3: # if p2.contribution == 700: # p1.gruppo3pl2 = "Uscita" # else: p1.gruppo3pl2 = p2.contribution except TypeError: p2.contribution = None try: if p3.numberg == 3: # if p3.contribution == 700: # p1.gruppo3pl3 = "Uscita" # else: p1.gruppo3pl3 = p3.contribution except TypeError: p3.contribution = None try: if p4.numberg == 3: # if p4.contribution == 700: # p1.gruppo3pl4 = "Uscita" # else: p1.gruppo3pl4 = p4.contribution except TypeError: p4.contribution = None try: if p5.numberg == 3: # if p5.contribution == 700: # p1.gruppo3pl5 = "Uscita" # else: p1.gruppo3pl5 = p5.contribution except TypeError: p5.contribution = None # registro le giocate gruppo 4 for p in group.get_players(): try: if p2.numberg == 4: # if p2.contribution == 700: # p1.gruppo4pl2 = "Uscita" # else: p1.gruppo4pl2 = p2.contribution except TypeError: p2.contribution = None try: if p3.numberg == 4: # if p3.contribution == 700: # p1.gruppo4pl3 = "Uscita" # else: p1.gruppo4pl3 = p3.contribution except TypeError: p3.contribution = None try: if p4.numberg == 4: #if p4.contribution == 700: # p1.gruppo4pl4 = "Uscita" # else: p1.gruppo4pl4 = p4.contribution except TypeError: p4.contribution = None try: if p5.numberg == 4: # if p5.contribution == 700: # p1.gruppo4pl5 = "Uscita" # else: p1.gruppo4pl5 = p5.contribution except TypeError: p5.contribution = None def giocate_gruppi(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) p5 = group.get_player_by_id(5) # registro le giocate gruppo 1 if p2.numberg == 1 and p2.contribution == 700: p1.gruppo1pl2 = "Uscita" elif p2.numberg == 1 and p2.contribution == 0: p1.gruppo1pl2 = "0 punti" elif p2.numberg == 1 and p2.contribution == 9: p1.gruppo1pl2 = "9 punti" elif p2.numberg == 1 and p2.contribution == 100: p1.gruppo1pl2 = "0 punti e 2 punti all'arbitro" else: pass if p3.numberg == 1 and p3.contribution == 700: p1.gruppo1pl3 = "Uscita" elif p3.numberg == 1 and p3.contribution == 0: p1.gruppo1pl3 = "0 punti" elif p3.numberg == 1 and p3.contribution == 9: p1.gruppo1pl3 = "9 punti" elif p3.numberg == 1 and p3.contribution == 100: p1.gruppo1pl3 = "0 punti e 2 punti all'arbitro" else: pass if p4.numberg == 1 and p4.contribution == 700: p1.gruppo1pl4 = "Uscita" elif p4.numberg == 1 and p4.contribution == 0: p1.gruppo1pl4 = "0 punti" elif p4.numberg == 1 and p4.contribution == 9: p1.gruppo1pl4 = "9 punti" elif p4.numberg == 1 and p4.contribution == 100: p1.gruppo1pl4 = "0 punti e 2 punti all'arbitro" else: pass if p5.numberg == 1 and p5.contribution == 700: p1.gruppo1pl5 = "Uscita" elif p5.numberg == 1 and p5.contribution == 0: p1.gruppo1pl5 = "0 punti" elif p5.numberg == 1 and p5.contribution == 9: p1.gruppo1pl5 = "9 punti" elif p5.numberg == 1 and p5.contribution == 100: p1.gruppo1pl5 = "0 punti e 2 punti all'arbitro" else: pass # registro le giocate gruppo 2 if p2.numberg == 2 and p2.contribution == 700: p1.gruppo2pl2 = "Uscita" elif p2.numberg == 2 and p2.contribution == 0: p1.gruppo2pl2 = "0 punti" elif p2.numberg == 2 and p2.contribution == 9: p1.gruppo2pl2 = "9 punti" elif p2.numberg == 2 and p2.contribution == 100: p1.gruppo2pl2 = "0 punti e 2 punti all'arbitro" else: pass if p3.numberg == 2 and p3.contribution == 700: p1.gruppo2pl3 = "Uscita" elif p3.numberg == 2 and p3.contribution == 0: p1.gruppo2pl3 = "0 punti" elif p3.numberg == 2 and p3.contribution == 9: p1.gruppo2pl3 = "9 punti" elif p3.numberg == 2 and p3.contribution == 100: p1.gruppo2pl3 = "0 punti e 2 punti all'arbitro" else: pass if p4.numberg == 2 and p4.contribution == 700: p1.gruppo2pl4 = "Uscita" elif p4.numberg == 2 and p4.contribution == 0: p1.gruppo2pl4 = "0 punti" elif p4.numberg == 2 and p4.contribution == 9: p1.gruppo2pl4 = "9 punti" elif p4.numberg == 2 and p4.contribution == 100: p1.gruppo2pl4 = "0 punti e 2 punti all'arbitro" else: pass if p5.numberg == 2 and p5.contribution == 700: p1.gruppo2pl5 = "Uscita" elif p5.numberg == 2 and p5.contribution == 0: p1.gruppo2pl5 = "0 punti" elif p5.numberg == 2 and p5.contribution == 9: p1.gruppo2pl5 = "9 punti" elif p5.numberg == 2 and p5.contribution == 100: p1.gruppo2pl5 = "0 punti e 2 punti all'arbitro" else: pass # registro le giocate gruppo 3 if p2.numberg == 3 and p2.contribution == 700: p1.gruppo3pl2 = "Uscita" elif p2.numberg == 3 and p2.contribution == 0: p1.gruppo3pl2 = "0 punti" elif p2.numberg == 3 and p2.contribution == 9: p1.gruppo3pl2 = "9 punti" elif p2.numberg == 3 and p2.contribution == 100: p1.gruppo3pl2 = "0 punti e 2 punti all'arbitro" else: pass if p3.numberg == 3 and p3.contribution == 700: p1.gruppo3pl3 = "Uscita" elif p3.numberg == 3 and p3.contribution == 0: p1.gruppo3pl3 = "0 punti" elif p3.numberg == 3 and p3.contribution == 9: p1.gruppo3pl3 = "9 punti" elif p3.numberg == 3 and p3.contribution == 100: p1.gruppo3pl3 = "0 punti e 2 punti all'arbitro" else: pass if p4.numberg == 3 and p4.contribution == 700: p1.gruppo3pl4 = "Uscita" elif p4.numberg == 3 and p4.contribution == 0: p1.gruppo3pl4 = "0 punti" elif p4.numberg == 3 and p4.contribution == 9: p1.gruppo3pl4 = "9 punti" elif p4.numberg == 3 and p4.contribution == 100: p1.gruppo3pl4 = "0 punti e 2 punti all'arbitro" else: pass if p5.numberg == 3 and p5.contribution == 700: p1.gruppo3pl5 = "Uscita" elif p5.numberg == 3 and p5.contribution == 0: p1.gruppo3pl5 = "0 punti" elif p5.numberg == 3 and p5.contribution == 9: p1.gruppo3pl5 = "9 punti" elif p5.numberg == 3 and p5.contribution == 100: p1.gruppo3pl5 = "0 punti e 2 punti all'arbitro" else: pass # registro le giocate gruppo 4 if p2.numberg == 4 and p2.contribution == 700: p1.gruppo4pl2 = "Uscita" elif p2.numberg == 4 and p2.contribution == 0: p1.gruppo4pl2 = "0 punti" elif p2.numberg == 4 and p2.contribution == 9: p1.gruppo4pl2 = "9 punti" elif p2.numberg == 4 and p2.contribution == 100: p1.gruppo4pl2 = "0 punti e 2 punti all'arbitro" else: pass if p3.numberg == 4 and p3.contribution == 700: p1.gruppo4pl3 = "Uscita" elif p3.numberg == 4 and p3.contribution == 0: p1.gruppo4pl3 = "0 punti" elif p3.numberg == 4 and p3.contribution == 9: p1.gruppo4pl3 = "9 punti" elif p3.numberg == 4 and p3.contribution == 100: p1.gruppo4pl3 = "0 punti e 2 punti all'arbitro" else: pass if p4.numberg == 4 and p4.contribution == 700: p1.gruppo4pl4 = "Uscita" elif p4.numberg == 4 and p4.contribution == 0: p1.gruppo4pl4 = "0 punti" elif p4.numberg == 4 and p4.contribution == 9: p1.gruppo4pl4 = "9 punti" elif p4.numberg == 4 and p4.contribution == 100: p1.gruppo4pl4 = "0 punti e 2 punti all'arbitro" else: pass if p5.numberg == 4 and p5.contribution == 700: p1.gruppo4pl5 = "Uscita" elif p5.numberg == 4 and p5.contribution == 0: p1.gruppo4pl5 = "0 punti" elif p5.numberg == 4 and p5.contribution == 9: p1.gruppo4pl5 = "9 punti" elif p5.numberg == 4 and p5.contribution == 100: p1.gruppo4pl5 = "0 punti e 2 punti all'arbitro" else: pass 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 Group.after_all_players_arrive = after_all_players_arrive Group.set_payoff1 = set_payoff1 Group.set_payoff2 = set_payoff2 Group.corruzione_prima = corruzione_prima Group.corruttori_prima = corruttori_prima Group.contribuzioni_gruppo_precedente_arbitro = contribuzioni_gruppo_precedente_arbitro Group.punizioni_gruppo_precedente_arbitro = punizioni_gruppo_precedente_arbitro Group.punizioni_gruppi = punizioni_gruppi Group.giocate = giocate Group.giocate_gruppi = giocate_gruppi class Player(BasePlayer): QuestionPG = models.IntegerField(choices=[[27, '9 (contribuzione) + 9 (contribuzione) + 9 (contribuzione) + 0 (contribuzione) = 27 punti.'], [54, '9 (contribuzione) + 9 (contribuzione) + 9 (contribuzione) + 0 (contribuzione) = 27 punti. 27 x 2 (moltiplicatore progetto comune) = 54 punti']], label='1) Quanto vale il progetto comune?', widget=widgets.RadioSelect) Questionme = models.IntegerField(choices=[[19, '54 : 4 (partecipanti) = 14 punti (quota individuale progetto comune). 14 (dotazione iniziale) - 9 (contribuzione) + 14 = 19 punti'], [28, '54 : 4 (partecipanti) = 14 punti (quota individuale progetto comune). 14 (dotazione iniziale) + 14 = 28 punti']], label="2) Quanti punti ottieni complessivamente, se l'arbitro non ti toglie nessun punto?", widget=widgets.RadioSelect) Question3 = models.IntegerField(choices=[[16, "14 + 12 (quota individuale progetto comune) - 3 (contribuzione) - 7 (punti tolti dall'arbitro) = 16 punti"], [19, "14 + 12 (quota individuale progetto comune) - 7 (punti tolti dall'arbitro) = 19 punti"]], label="3) Quanti punti ottiene complessivamente il partecipante che ha messo 3 punti nel progetto comune, se l'arbitro gli ha tolto 7 punti?", widget=widgets.RadioSelect) QuestionUmp = models.IntegerField(choices=[[17, '17 punti'], [25, '17 + 8 (punti ottenuti grazie al progetto comune) = 25 punti se non accetti i punti offerti '], [27, '17 + 8 (punti ottenuti grazie al progetto comune) + 2 (punti offerti) = 27 punti se accetti i punti offerti']], label='2) Quanti punti ottieni complessivamente?', 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'], [11, '11'], [12, '12'], [13, '13'], [14, '14'], [15, '15']], 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'], [11, '11'], [12, '12'], [13, '13'], [14, '14'], [15, '15']], 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'], [11, '11'], [12, '12'], [13, '13'], [14, '14'], [15, '15']], initial=700, label='Indica se e quanti punti vuoi togliere al partecipante') punishment5 = 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'], [11, '11'], [12, '12'], [13, '13'], [14, '14'], [15, '15']], 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 offerto il partecipante?', widget=widgets.RadioSelectHorizontal) bribe3 = models.IntegerField(choices=[[1, 'Si'], [0, 'No']], initial=700, label='Vuoi accettare i punti che ti ha offerto il partecipante?', widget=widgets.RadioSelectHorizontal) bribe4 = models.IntegerField(choices=[[1, 'Si'], [0, 'No']], initial=700, label='Vuoi accettare i punti che ti ha offerto il partecipante?', widget=widgets.RadioSelectHorizontal) bribe5 = models.IntegerField(choices=[[1, 'Si'], [0, 'No']], initial=700, label='Vuoi accettare i punti che ti ha offerto 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 dall'arbitro nel round 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=[]) punizione5 = models.IntegerField(choices=[]) valoremazzetta = models.IntegerField() punizione = models.IntegerField() numberg = models.IntegerField(choices=[[1, '1'], [2, '2'], [3, '3']]) exit0 = models.IntegerField(initial=0) exitpl2 = models.IntegerField(initial=0) exitpl3 = models.IntegerField(initial=0) exitpl4 = models.IntegerField(initial=0) exitpl5 = 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() umpirelastgroup = models.IntegerField() corruttoriprima = models.StringField() corruzioneprima = models.StringField() bribeplayer2 = models.IntegerField() bribeplayer3 = models.IntegerField() bribeplayer4 = models.IntegerField() bribeplayer5 = 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']], initial=700, label='Quanto vuoi mettere nel progetto comune?') bribe = models.IntegerField(blank=True, choices=[[0, 'Nessun punto'], [1, '1'], [2, '2'], [3, '3'], [4, '4'], [5, '5'], [6, '6'], [7, '7'], [8, '8'], [9, '9'], [10, '10']], label="Vuoi offrire dei punti all'aribtro? Quanti?") errore = models.BooleanField(initial=False) sommacontribbribe = models.IntegerField(initial=0) punizgruppo1pl2 = models.IntegerField() punizgruppo1pl3 = models.IntegerField() punizgruppo1pl4 = models.IntegerField() punizgruppo1pl5 = models.IntegerField() punizgruppo2pl2 = models.IntegerField() punizgruppo2pl3 = models.IntegerField() punizgruppo2pl4 = models.IntegerField() punizgruppo2pl5 = models.IntegerField() punizgruppo3pl2 = models.IntegerField() punizgruppo3pl3 = models.IntegerField() punizgruppo3pl4 = models.IntegerField() punizgruppo3pl5 = models.IntegerField() punizgruppo4pl2 = models.IntegerField() punizgruppo4pl3 = models.IntegerField() punizgruppo4pl4 = models.IntegerField() punizgruppo4pl5 = models.IntegerField() punizgruppo5pl2 = models.IntegerField() punizgruppo5pl3 = models.IntegerField() punizgruppo5pl4 = models.IntegerField() punizgruppo5pl5 = models.IntegerField() progettocomunepl2 = models.IntegerField() progettocomunepl3 = models.IntegerField() progettocomunepl4 = models.IntegerField() progettocomunepl5 = models.IntegerField() gruppo1pl2 = models.IntegerField() gruppo1pl3 = models.IntegerField() gruppo1pl4 = models.IntegerField() gruppo2pl2 = models.IntegerField() gruppo2pl3 = models.IntegerField() gruppo2pl4 = models.IntegerField() gruppo3pl2 = models.IntegerField() gruppo3pl3 = models.IntegerField() gruppo3pl4 = models.IntegerField() gruppo4pl2 = models.IntegerField() gruppo4pl3 = models.IntegerField() gruppo4pl4 = models.IntegerField() gruppo5pl2 = models.IntegerField() gruppo5pl3 = models.IntegerField() gruppo5pl4 = models.IntegerField() gruppo1pl5 = models.IntegerField() gruppo2pl5 = models.IntegerField() gruppo3pl5 = models.IntegerField() gruppo4pl5 = models.IntegerField() g1pl2 = models.IntegerField() g1pl3 = models.IntegerField() g1pl4 = models.IntegerField() g2pl2 = models.IntegerField() g2pl3 = models.IntegerField() g2pl4 = models.IntegerField() g3pl2 = models.IntegerField() g3pl3 = models.IntegerField() g3pl4 = models.IntegerField() g4pl2 = models.IntegerField() g4pl3 = models.IntegerField() g4pl4 = models.IntegerField() g5pl2 = models.IntegerField() g5pl3 = models.IntegerField() g5pl4 = models.IntegerField() p1pl2 = models.IntegerField() p1pl3 = models.IntegerField() p1pl4 = models.IntegerField() p2pl2 = models.IntegerField() p2pl3 = models.IntegerField() p2pl4 = models.IntegerField() p3pl2 = models.IntegerField() p3pl3 = models.IntegerField() p3pl4 = models.IntegerField() p4pl2 = models.IntegerField() p4pl3 = models.IntegerField() p4pl4 = models.IntegerField() p5pl2 = models.IntegerField() p5pl3 = models.IntegerField() p5pl4 = models.IntegerField() g1pl5 = models.IntegerField() g2pl5 = models.IntegerField() g3pl5 = models.IntegerField() g4pl5 = models.IntegerField() p1pl5 = models.IntegerField() p2pl5 = models.IntegerField() p3pl5 = models.IntegerField() p4pl5 = models.IntegerField() def setglobals(player: Player): session = player.session subsession = player.subsession participant = player.participant participant.vars['Human_umpire_payoff'] = participant.payoff session.vars['corruzionetot'] = subsession.tuttacorruzione 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 Role(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): return player.round_number == 1 class IstruzioniPlayer(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): group = player.group return player.round_number == 1 and player.id_in_group != 1 class IstruzioniUmpire(Page): form_model = 'player' @staticmethod def is_displayed(player: Player): group = player.group return player.round_number == 1 and player.id_in_group == 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 = contribuzioni_gruppo_precedente_arbitro title_text = 'Attendi che le informazioni vengano elaborate' @staticmethod def is_displayed(player: Player): group = player.group return player.round_number != 1 #and player.id_in_group != 1 class Elaboratinginfo2(WaitPage): after_all_players_arrive = punizioni_gruppo_precedente_arbitro @staticmethod def is_displayed(player: Player): group = player.group return player.round_number != 1 #and player.id_in_group != 1 class Elaoratinginfo3(WaitPage): after_all_players_arrive = corruttori_prima @staticmethod def is_displayed(player: Player): group = player.group return player.round_number != 1 #and player.id_in_group != 1 class Elaboratinginfo4(WaitPage): after_all_players_arrive = corruzione_prima @staticmethod def is_displayed(player: Player): group = player.group return player.round_number != 1 #and player.id_in_group != 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', 'bribe'] @staticmethod def is_displayed(player: Player): group = player.group return player.id_in_group != 1 class CheckingForErrors(WaitPage): after_all_players_arrive = verify @staticmethod def is_displayed(player: Player): group = player.group return player.id_in_group != 1 class Error(Page): form_model = 'player' form_fields = ['contribution', 'bribe'] @staticmethod def is_displayed(player: Player): group = player.group return player.id_in_group != 1 and player.errore == 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): 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 Punishment2(Page): form_model = 'player' form_fields = ['punishment2'] @staticmethod def is_displayed(player: Player): group = player.group return player.id_in_group == 1 and player.bribeplayer2 == 0 class Punishment2bribe(Page): form_model = 'player' form_fields = ['bribe2', 'punishment2'] @staticmethod def is_displayed(player: Player): group = player.group return player.id_in_group == 1 and player.bribeplayer2 != 0 class Punishment3(Page): form_model = 'player' form_fields = ['punishment3'] @staticmethod def is_displayed(player: Player): group = player.group return player.id_in_group == 1 and player.bribeplayer3 == 0 class Punishment3bribe(Page): form_model = 'player' form_fields = ['bribe3', 'punishment3'] @staticmethod def is_displayed(player: Player): group = player.group return player.id_in_group == 1 and player.bribeplayer3 !=0 class Punishment4(Page): form_model = 'player' form_fields = ['punishment4'] @staticmethod def is_displayed(player: Player): group = player.group return player.id_in_group == 1 and player.bribeplayer4 == 0 class Punishment4bribe(Page): form_model = 'player' form_fields = ['bribe4', 'punishment4'] @staticmethod def is_displayed(player: Player): group = player.group return player.id_in_group == 1 and player.bribeplayer4 != 0 class Punishment5(Page): form_model = 'player' form_fields = ['punishment5'] @staticmethod def is_displayed(player: Player): group = player.group return player.id_in_group == 1 and player.bribeplayer5 == 0 class Punishment5bribe(Page): form_model = 'player' form_fields = ['bribe5', 'punishment5'] @staticmethod def is_displayed(player: Player): group = player.group return player.id_in_group == 1 and player.bribeplayer5 !=0 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 Punizioni(WaitPage): after_all_players_arrive = punizioni_gruppi class Giocate(WaitPage): after_all_players_arrive = giocate class Punizioni2(WaitPage): after_all_players_arrive = punizioni_gruppi @staticmethod def is_displayed(player: Player): return player.round_number != 1 class Corruzionesessione(WaitPage): wait_for_all_groups = True after_all_players_arrive = my_function2 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 == 5 page_sequence = [Attesagruppixpartire, Role, IstruzioniPlayer, IstruzioniUmpire, Start, Info, Elaboratinginfo, Elaboratinginfo2, Elaoratinginfo3, Elaboratinginfo4, DiscoveryUmpire, Contribuzione, CheckingForErrors, Error, Giocatori, WaitingUmpire, Punishment2, Punishment2bribe, Punishment3, Punishment3bribe, Punishment4, Punishment4bribe, Punishment5, Punishment5bribe, Attesagiocatori, ExecutingPayoffRound1, ExecutingPayoff2, Punizioni, Giocate, Punizioni2, Corruzionesessione, PayoffRound1, Payoff2, Ringraziamento]