from otree.api import (
    models,
    widgets,
    BaseConstants,
    BaseSubsession,
    BaseGroup,
    BasePlayer,
    Currency as c,
    currency_range,
)

doc = """
author = 'Wael Bousselmi'
Exp E4C
"""

class Constants(BaseConstants):
    name_in_url = 'v2_exp_e4c_x_fr_en_fin'
    players_per_group = None
    num_rounds = 1

class Subsession(BaseSubsession):

    def vars_for_admin_report(self):
        report = list()
        for p in self.get_players():
            report.append(dict(id=p.participant.id_in_session,
                               label=p.participant.label,
                               lastname = p.lastname,
                               firstname =p.firstname,
                               #email =p.email,
                               room =p.room ,
                               language =p.language,
                               treatmentname = p.treatmentname,
                               jeu_tire=p.jeu_tire,
                               jeuname = p.jeuname,
                               gainfinal=p.gainfinal,
                               gaineur=p.gaineur,
                               gainfinaleur=p.gainfinaleur,
                               gain_ff = p.gain_ff
                               ))
        return dict(report=report)


class Group(BaseGroup):
    pass

class Player(BasePlayer):
    id_in_group_nn = models.IntegerField()

    lastname = models.StringField(
        label="Nom",
        blank=False
    )

    firstname = models.StringField(
        label="Prénom",
        blank=False
    )

    email = models.StringField(
        label="Email",
        blank=False
    )

    room = models.StringField(
        label="Numéro de logement",
        blank=False
    )
    language = models.StringField()
    treatmentname = models.StringField()
    jeu_tire = models.IntegerField()
    jeuname = models.StringField()
    gainfinal = models.FloatField()
    gaineur = models.FloatField()
    gainfinaleur = models.FloatField()

    gain_ff = models.FloatField()





