from typing import Tuple from otree.api import * def calculate_and_store_profit(player: BasePlayer): """ Based on the performance of the player in the CRT, the subtraction task, the audio task, Raven's test, and the strategy following task, his payoff is determined and stored. 'player.participant.payoff_performance' will contain the performance-based monetary payoff, 'player.payoff' the sum of this and the participation fee. participant.crt_pay, participant.subtraction_pay, participant.audio_pay, participant.raven_pay contain the payoffs for the respective apps. :param player: Player for which the payoff is to be determined and stored. """ participant = player.participant crt_pay = 0 subtraction_pay = 0 if participant.crt_score == 7: # Full score crt_pay = player.session.config["crt_points"] if participant.nr_correct_answers_subtractions == 5: # Full score subtraction_pay = player.session.config["subtraction_points"] audio_pay = participant.num_correct_words_delay * player.session.config["audio_points"] raven_pay = 0 if participant.raven_selection: raven_pay = player.session.config["raven_points"] session = player.session participant.points = ( crt_pay + subtraction_pay + audio_pay + participant.sft_pay + raven_pay ) participant.payoff_performance = participant.points * session.config["real_world_currency_per_point"] player.payoff = participant.payoff_performance +session.config["participation_fee"] participant.crt_pay = crt_pay participant.subtraction_pay = subtraction_pay participant.audio_pay = audio_pay participant.raven_pay = raven_pay