from ._builtin import Page, WaitPage from otree.api import Currency as c, currency_range from .models import Constants class Introduction(Page): """Description of the game: How to play and returns expected""" pass class BasicInfo(Page): form_model = 'player' form_fields = [ 'age', 'gender', 'typing'] class GameTrialInfo(Page): pass class Game0(Page): timeout_seconds = 50 form_model = 'player' form_fields = ['ans0A', 'ans0B', 'ans0C', 'ans0D', 'ans0E', 'ans0F', 'ans0G', 'ans0H', 'ans0I', 'ans0J', 'ans0K', 'ans0L', 'ans0M', 'ans0N', 'ans0O', 'ans0P', 'ans0Q', 'ans0R', 'ans0S', 'ans0T', 'ans0U', 'ans0V', 'ans0W', 'ans0X', 'ans0Y', 'ans0Z' ] def vars_for_template(self): return dict( ans0A_label = 'Type {}.'.format(self.player.que0A), ans0B_label = 'Type {}.'.format(self.player.que0B), ans0C_label = 'Type {}.'.format(self.player.que0C), ans0D_label = 'Type {}.'.format(self.player.que0D), ans0E_label = 'Type {}.'.format(self.player.que0E), ans0F_label = 'Type {}.'.format(self.player.que0F), ans0G_label = 'Type {}.'.format(self.player.que0G), ans0H_label = 'Type {}.'.format(self.player.que0H), ans0I_label = 'Type {}.'.format(self.player.que0I), ans0J_label = 'Type {}.'.format(self.player.que0J), ans0K_label = 'Type {}.'.format(self.player.que0K), ans0L_label = 'Type {}.'.format(self.player.que0L), ans0M_label = 'Type {}.'.format(self.player.que0M), ans0N_label = 'Type {}.'.format(self.player.que0N), ans0O_label = 'Type {}.'.format(self.player.que0O), ans0P_label = 'Type {}.'.format(self.player.que0P), ans0Q_label = 'Type {}.'.format(self.player.que0Q), ans0R_label = 'Type {}.'.format(self.player.que0R), ans0S_label = 'Type {}.'.format(self.player.que0S), ans0T_label = 'Type {}.'.format(self.player.que0T), ans0U_label = 'Type {}.'.format(self.player.que0U), ans0V_label = 'Type {}.'.format(self.player.que0V), ans0W_label = 'Type {}.'.format(self.player.que0W), ans0X_label = 'Type {}.'.format(self.player.que0X), ans0Y_label = 'Type {}.'.format(self.player.que0Y), ans0Z_label = 'Type {}.'.format(self.player.que0Z), ) class Game0Results(Page): def vars_for_template(self): return dict(earning0 = self.player.eaning0) class Question1(Page): """Q1""" form_model = 'player' form_fields = ['feelings1'] #1周目 class NextRound1(Page): pass class Waiting1(Page): timeout_seconds = 3 class victim1(Page): """You are the first victim""" pass class Question2(Page): """Q2""" form_model = 'player' form_fields = ['feelings2'] class Game1Info(Page): pass class Game1(Page): timeout_seconds = 50 form_model = 'player' form_fields = ['ans1A', 'ans1B', 'ans1C', 'ans1D', 'ans1E', 'ans1F', 'ans1G', 'ans1H', 'ans1I', 'ans1J', 'ans1K', 'ans1L', 'ans1M', 'ans1N', 'ans1O', 'ans1P', 'ans1Q', 'ans1R', 'ans1S', 'ans1T', 'ans1U', 'ans1V', 'ans1W', 'ans1X', 'ans1Y', 'ans1Z' ] def vars_for_template(self): return dict( ans1A_label = 'Type {}.'.format(self.player.que1A), ans1B_label = 'Type {}.'.format(self.player.que1B), ans1C_label = 'Type {}.'.format(self.player.que1C), ans1D_label = 'Type {}.'.format(self.player.que1D), ans1E_label = 'Type {}.'.format(self.player.que1E), ans1F_label = 'Type {}.'.format(self.player.que1F), ans1G_label = 'Type {}.'.format(self.player.que1G), ans1H_label = 'Type {}.'.format(self.player.que1H), ans1I_label = 'Type {}.'.format(self.player.que1I), ans1J_label = 'Type {}.'.format(self.player.que1J), ans1K_label = 'Type {}.'.format(self.player.que1K), ans1L_label = 'Type {}.'.format(self.player.que1L), ans1M_label = 'Type {}.'.format(self.player.que1M), ans1N_label = 'Type {}.'.format(self.player.que1N), ans1O_label = 'Type {}.'.format(self.player.que1O), ans1P_label = 'Type {}.'.format(self.player.que1P), ans1Q_label = 'Type {}.'.format(self.player.que1Q), ans1R_label = 'Type {}.'.format(self.player.que1R), ans1S_label = 'Type {}.'.format(self.player.que1S), ans1T_label = 'Type {}.'.format(self.player.que1T), ans1U_label = 'Type {}.'.format(self.player.que1U), ans1V_label = 'Type {}.'.format(self.player.que1V), ans1W_label = 'Type {}.'.format(self.player.que1W), ans1X_label = 'Type {}.'.format(self.player.que1X), ans1Y_label = 'Type {}.'.format(self.player.que1Y), ans1Z_label = 'Type {}.'.format(self.player.que1Z), ) class Game1Results(Page): def vars_for_template(self): return dict(earning1 = self.player.earning1) class Contribute1(Page): """Player: Choose how much to contribute and report your earning.""" form_model = 'player' form_fields = [ 'contribution1'] def vars_for_template(self): posession1 = Constants.endowment return dict(earning1 = self.player.earning1, posession1 = posession1) class ResultsWaitPage1(Page): timeout_seconds = 3 class Results1(Page): def vars_for_template(self): individual_share1 = (self.player.earning1 + c(40))*0.2 payoff1 = Constants.endowment - contribute1 + ((self.player.earning1 + c(40))*0.2) return dict(individual_share1=individual_share1, payoff1=payoff1) #2周目 class NextRound2(Page): pass class Waiting2(Page): timeout_seconds = 3 class victim2(Page): """A is the second victim""" pass class Question3(Page): """Q3""" form_model = 'player' form_fields = ['feelings3'] class Game2Info(Page): pass class Game2(Page): timeout_seconds = 50 form_model = 'player' form_fields = ['ans2A', 'ans2B', 'ans2C', 'ans2D', 'ans2E', 'ans2F', 'ans2G', 'ans2H', 'ans2I', 'ans2J', 'ans2K', 'ans2L', 'ans2M', 'ans2N', 'ans2O', 'ans2P', 'ans2Q', 'ans2R', 'ans2S', 'ans2T', 'ans2U', 'ans2V', 'ans2W', 'ans2X', 'ans2Y', 'ans2Z' ] def vars_for_template(self): return dict( ans2A_label = 'Type {}.'.format(self.player.que2A), ans2B_label = 'Type {}.'.format(self.player.que2B), ans2C_label = 'Type {}.'.format(self.player.que2C), ans2D_label = 'Type {}.'.format(self.player.que2D), ans2E_label = 'Type {}.'.format(self.player.que2E), ans2F_label = 'Type {}.'.format(self.player.que2F), ans2G_label = 'Type {}.'.format(self.player.que2G), ans2H_label = 'Type {}.'.format(self.player.que2H), ans2I_label = 'Type {}.'.format(self.player.que2I), ans2J_label = 'Type {}.'.format(self.player.que2J), ans2K_label = 'Type {}.'.format(self.player.que2K), ans2L_label = 'Type {}.'.format(self.player.que2L), ans2M_label = 'Type {}.'.format(self.player.que2M), ans2N_label = 'Type {}.'.format(self.player.que2N), ans2O_label = 'Type {}.'.format(self.player.que2O), ans2P_label = 'Type {}.'.format(self.player.que2P), ans2Q_label = 'Type {}.'.format(self.player.que2Q), ans2R_label = 'Type {}.'.format(self.player.que2R), ans2S_label = 'Type {}.'.format(self.player.que2S), ans2T_label = 'Type {}.'.format(self.player.que2T), ans2U_label = 'Type {}.'.format(self.player.que2U), ans2V_label = 'Type {}.'.format(self.player.que2V), ans2W_label = 'Type {}.'.format(self.player.que2W), ans2X_label = 'Type {}.'.format(self.player.que2X), ans2Y_label = 'Type {}.'.format(self.player.que2Y), ans2Z_label = 'Type {}.'.format(self.player.que2Z), ) class Game2Results(Page): def vars_for_template(self): return dict(earning2 = self.player.earning2) class Contribute2(Page): """Player: Choose how much to contribute and report your earning.""" form_model = 'player' form_fields = ['contribution2'] def vars_for_template(self): posession2 = self.player.earning2 + (2*Constants.endowment - self.player.contribution1) + ((self.player.earning1 + self.player.earning2 + 40*2)*0.4) return dict(earning2 = self.player.earning2, posession2 = posession2) class ResultsWaitPage2(Page): timeout_seconds = 3 class Results2(Page): """Players payoff: How much each person got""" def vars_for_template(self): individual_share2 = (self.player.earning2 + c(40))*0.4 payoff2 = self.player.earning2 + (2*Constants.endowment - self.player.contribution1 - self.player.contribution2) + ((self.player.earning1 + self.player.earning2+ 40*2)*0.4) return dict(individual_share2=individual_share2, payoff2=payoff2) #ゲーム3 class NextRound3(Page): pass class Game3Info(Page): pass class Game3(Page): timeout_seconds = 50 form_model = 'player' form_fields = ['ans3A', 'ans3B', 'ans3C', 'ans3D', 'ans3E', 'ans3F', 'ans3G', 'ans3H', 'ans3I', 'ans3J', 'ans3K', 'ans3L', 'ans3M', 'ans3N', 'ans3O', 'ans3P', 'ans3Q', 'ans3R', 'ans3S', 'ans3T', 'ans3U', 'ans3V', 'ans3W', 'ans3X', 'ans3Y', 'ans3Z' ] def vars_for_template(self): return dict( ans3A_label = 'Type {}.'.format(self.player.que3A), ans3B_label = 'Type {}.'.format(self.player.que3B), ans3C_label = 'Type {}.'.format(self.player.que3C), ans3D_label = 'Type {}.'.format(self.player.que3D), ans3E_label = 'Type {}.'.format(self.player.que3E), ans3F_label = 'Type {}.'.format(self.player.que3F), ans3G_label = 'Type {}.'.format(self.player.que3G), ans3H_label = 'Type {}.'.format(self.player.que3H), ans3I_label = 'Type {}.'.format(self.player.que3I), ans3J_label = 'Type {}.'.format(self.player.que3J), ans3K_label = 'Type {}.'.format(self.player.que3K), ans3L_label = 'Type {}.'.format(self.player.que3L), ans3M_label = 'Type {}.'.format(self.player.que3M), ans3N_label = 'Type {}.'.format(self.player.que3N), ans3O_label = 'Type {}.'.format(self.player.que3O), ans3P_label = 'Type {}.'.format(self.player.que3P), ans3Q_label = 'Type {}.'.format(self.player.que3Q), ans3R_label = 'Type {}.'.format(self.player.que3R), ans3S_label = 'Type {}.'.format(self.player.que3S), ans3T_label = 'Type {}.'.format(self.player.que3T), ans3U_label = 'Type {}.'.format(self.player.que3U), ans3V_label = 'Type {}.'.format(self.player.que3V), ans3W_label = 'Type {}.'.format(self.player.que3W), ans3X_label = 'Type {}.'.format(self.player.que3X), ans3Y_label = 'Type {}.'.format(self.player.que3Y), ans3Z_label = 'Type {}.'.format(self.player.que3Z), ) class Game3Results(Page): def vars_for_template(self): return dict(earning3 = self.player.earning3) class Contribute3(Page): """Player: Choose how much to contribute and report your earning.""" form_model = 'player' form_fields = ['contribution3'] def vars_for_template(self): posession3 = self.player.earning2 +self.player.earning3 + (3*Constants.endowment - self.player.contribution1 - self.player.contribution2) + ((self.player.earning1 + self.player.earning2 +self.player.earning3 + 40*3)*0.4) return dict(earning3 = self.player.earning3, posession3 = posession3) class ResultsWaitPage3(Page): timeout_seconds = 3 class Results3(Page): def vars_for_template(self): individual_share3 = (self.player.earning3 + c(40))*0.4 payoff3 = self.player.earning2 + self.player.earning3 + (3*Constants.endowment - self.player.contribution1 - self.player.contribution2 -self.player.contribution3) + ((self.player.earning1 + self.player.earning2 + self.player.earing3 + 40*3)*0.4) return dict(individual_share3=individual_share3, payoff3=payoff3) #ゲーム4 class NextRound4(Page): pass class Game4Info(Page): pass class Game4(Page): timeout_seconds = 50 form_model = 'player' form_fields = ['ans4A', 'ans4B', 'ans4C', 'ans4D', 'ans4E', 'ans4F', 'ans4G', 'ans4H', 'ans4I', 'ans4J', 'ans4K', 'ans4L', 'ans4M', 'ans4N', 'ans4O', 'ans4P', 'ans4Q', 'ans4R', 'ans4S', 'ans4T', 'ans4U', 'ans4V', 'ans4W', 'ans4X', 'ans4Y', 'ans4Z' ] def vars_for_template(self): return dict( ans4A_label = 'Type {}.'.format(self.player.que4A), ans4B_label = 'Type {}.'.format(self.player.que4B), ans4C_label = 'Type {}.'.format(self.player.que4C), ans4D_label = 'Type {}.'.format(self.player.que4D), ans4E_label = 'Type {}.'.format(self.player.que4E), ans4F_label = 'Type {}.'.format(self.player.que4F), ans4G_label = 'Type {}.'.format(self.player.que4G), ans4H_label = 'Type {}.'.format(self.player.que4H), ans4I_label = 'Type {}.'.format(self.player.que4I), ans4J_label = 'Type {}.'.format(self.player.que4J), ans4K_label = 'Type {}.'.format(self.player.que4K), ans4L_label = 'Type {}.'.format(self.player.que4L), ans4M_label = 'Type {}.'.format(self.player.que4M), ans4N_label = 'Type {}.'.format(self.player.que4N), ans4O_label = 'Type {}.'.format(self.player.que4O), ans4P_label = 'Type {}.'.format(self.player.que4P), ans4Q_label = 'Type {}.'.format(self.player.que4Q), ans4R_label = 'Type {}.'.format(self.player.que4R), ans4S_label = 'Type {}.'.format(self.player.que4S), ans4T_label = 'Type {}.'.format(self.player.que4T), ans4U_label = 'Type {}.'.format(self.player.que4U), ans4V_label = 'Type {}.'.format(self.player.que4V), ans4W_label = 'Type {}.'.format(self.player.que4W), ans4X_label = 'Type {}.'.format(self.player.que4X), ans4Y_label = 'Type {}.'.format(self.player.que4Y), ans4Z_label = 'Type {}.'.format(self.player.que4Z), ) class Game4Results(Page): def vars_for_template(self): return dict(earning4 = self.player.earning4) class Contribute4(Page): """Player: Choose how much to contribute and report your earning.""" form_model = 'player' form_fields = ['contribution4'] def vars_for_template(self): posession4 = self.player.earning2 +self.player.earning3 + self.player.earning4 + (4*Constants.endowment - self.player.contribution1 - self.player.contribution2 - self.player.contribution3) + ((self.player.earning1 + self.player.earning2 +self.player.earning3 + self.player.earning4 + 40*4)*0.4) return dict(earning4 = self.player.earning4, posession4 = posession4) class ResultsWaitPage4(Page): timeout_seconds = 3 class Results4(Page): """Players payoff: How much each person got""" def vars_for_template(self): individual_share4 = (self.player.earning4 + c(40))*0.4 payoff4 = self.player.earning2 + self.player.earning3 + self.player.earning4 + (4*Constants.endowment - self.player.contribution1 - self.player.contribution2 -self.player.contribution3 - self.player.contribution4) + ((self.player.earning1 + self.player.earning2 + self.player.earing3 + self.player.earning4 + 40*4)*0.4) return dict(individual_share4 = individual_share4, payoff4 = payoff4) #ゲーム5 class NextRound5(Page): pass class Game5Info(Page): pass class Game5(Page): timeout_seconds = 50 form_model = 'player' form_fields = ['ans5A', 'ans5B', 'ans5C', 'ans5D', 'ans5E', 'ans5F', 'ans5G', 'ans5H', 'ans5I', 'ans5J', 'ans5K', 'ans5L', 'ans5M', 'ans5N', 'ans5O', 'ans5P', 'ans5Q', 'ans5R', 'ans5S', 'ans5T', 'ans5U', 'ans5V', 'ans5W', 'ans5X', 'ans5Y', 'ans5Z' ] def vars_for_template(self): return dict( ans5A_label = 'Type {}.'.format(self.player.que5A), ans5B_label = 'Type {}.'.format(self.player.que5B), ans5C_label = 'Type {}.'.format(self.player.que5C), ans5D_label = 'Type {}.'.format(self.player.que5D), ans5E_label = 'Type {}.'.format(self.player.que5E), ans5F_label = 'Type {}.'.format(self.player.que5F), ans5G_label = 'Type {}.'.format(self.player.que5G), ans5H_label = 'Type {}.'.format(self.player.que5H), ans5I_label = 'Type {}.'.format(self.player.que5I), ans5J_label = 'Type {}.'.format(self.player.que5J), ans5K_label = 'Type {}.'.format(self.player.que5K), ans5L_label = 'Type {}.'.format(self.player.que5L), ans5M_label = 'Type {}.'.format(self.player.que5M), ans5N_label = 'Type {}.'.format(self.player.que5N), ans5O_label = 'Type {}.'.format(self.player.que5O), ans5P_label = 'Type {}.'.format(self.player.que5P), ans5Q_label = 'Type {}.'.format(self.player.que5Q), ans5R_label = 'Type {}.'.format(self.player.que5R), ans5S_label = 'Type {}.'.format(self.player.que5S), ans5T_label = 'Type {}.'.format(self.player.que5T), ans5U_label = 'Type {}.'.format(self.player.que5U), ans5V_label = 'Type {}.'.format(self.player.que5V), ans5W_label = 'Type {}.'.format(self.player.que5W), ans5X_label = 'Type {}.'.format(self.player.que5X), ans5Y_label = 'Type {}.'.format(self.player.que5Y), ans5Z_label = 'Type {}.'.format(self.player.que5Z), ) class Game5Results(Page): def vars_for_template(self): return dict(earning5 = self.player.earning5) class Contribute5(Page): """Player: Choose how much to contribute and report your earning.""" form_model = 'player' form_fields = ['contribution5'] def vars_for_template(self): posession5 = self.player.earning2 + self.player.earning3 + self.player.earning4 + self.player.earning5 + (5*Constants.endowment - self.player.contribution1 - self.player.contribution2 -self.player.contribution3 - self.player.contribution4) + ((self.player.earning1 + self.player.earning2 + self.player.earing3 + self.player.earning4 + self.player.earning5 + 40*5)*0.4) return dict(earning5 = self.player.earning5, posession5 = posession5) class ResultsWaitPage5(Page): timeout_seconds = 3 class Results5(Page): """Players payoff: How much each person got""" def vars_for_template(self): individual_share5 = (self.player.earning5 + c(40))*0.4 payoff5 = self.player.earning2 + self.player.earning3 + self.player.earning4 + self.player.earning5 + (5*Constants.endowment - self.player.contribution1 - self.player.contribution2 -self.player.contribution3 - self.player.contribution4 - self.player.contribution5) + ((self.player.earning1 + self.player.earning2 + self.player.earing3 + self.player.earning4 + self.player.earning5 + 40*5)*0.4) return dict(individual_share5 = individual_share5, payoff5 = payoff5) class Stealing_points(Page): """Player can steal in total of 20 points""" form_model = 'player' form_fields = ['Stealing_p_leader', 'Stealing_p_A', 'Stealing_p_B', 'Stealing_p_C'] def error_message(self,values): if values['Stealing_p_leader'] + values['Stealing_p_A'] + values['Stealing_p_B'] + values['Stealing_p_C'] != 20: return 'The numbers must add up to 20' page_sequence = [Introduction, BasicInfo, GameTrialInfo, Game0, Game0Results, Question1, NextRound1, Waiting1, victim1, Question2, Game1Info, Game1, Game1Results, Contribute1, ResultsWaitPage1, Results1, NextRound2, Waiting2, victim2, Question2, Game2Info, Game2, Game2Results, Contribute2, ResultsWaitPage2, Results2, NextRound3, Game3Info, Game3, Game3Results, Contribute3, ResultsWaitPage3, Results3, NextRound4, Game4Info, Game4, Game4Results, Contribute4, ResultsWaitPage4, Results4, NextRound5, Game5Info, Game5, Game5Results, Contribute5, ResultsWaitPage5, Results5, Stealing_points]