from otree.api import Currency as c, currency_range from ._builtin import Page, WaitPage from .models import Constants class sender(Page): form_model = 'player' form_fields = ['count'] def is_displayed(self): return self.player.role() == 'red' class receiver(Page): form_model = 'player' form_fields = ['response'] def is_displayed(self): return self.player.role() == 'blue' class results(Page): def is_displayed(self): return False class ResultsWaitPage(WaitPage): def after_all_players_arrive(self): group = self.group players = group.get_players() for p in players: if p.role() == "red": if p.count == group.count: group.accurate = True else: pass if p.role() == "blue": if p.response == "Rely": group.blue_decision = "Rely" else: group.blue_decision = "Verify" for p in players: if p.role() == "red": if group.accurate == True and group.blue_decision == "Rely": p.payoff += 75 elif group.accurate == True and group.blue_decision == "Verify": p.payoff += 50 elif group.accurate == False and group.blue_decision == "Rely": p.payoff += 150 else: p.payoff += 0 if p.role() == "blue": if group.accurate == True and group.blue_decision == "Rely": p.payoff += 150 elif group.accurate == True and group.blue_decision == "Verify": p.payoff += 100 elif group.accurate == False and group.blue_decision == "Rely": p.payoff += 0 else: p.payoff += 100 class receiverwait(WaitPage): def after_all_players_arrive(self): group = self.group players = group.get_players() for p in players: if p.role() == 'red': group.red_message = p.count if p.role() == 'blue': pass class senderwait(WaitPage): pass page_sequence = [sender, receiverwait, receiver, senderwait, ResultsWaitPage, results]