from otree.api import Currency as c, currency_range
from ._builtin import Page, WaitPage
from .models import Constants

import random
import time


class Bienvenue0(Page):
    form_model = 'player'
    form_fields = ['versionexp']

    def before_next_page(self):
        self.participant.vars['versionexp'] = self.player.versionexp
        self.player.secondexp = "Yes"
        if self.player.id_in_group % 2 == 1:
            self.player.id_in_group_nn = 1
        else :
            self.player.id_in_group_nn = 2

        self.player.participant.vars['role_nn'] = self.player.id_in_group_nn


class Bienvenue(Page): # version française
    form_model = 'player'
    form_fields = []

    def is_displayed(self):
        return self.participant.vars['versionexp'] == 1


    def before_next_page(self):
        self.player.language = "FR"
        self.player.participant.vars['language'] = self.player.language



        if self.player.id_in_group % 2 == 1:
            self.player.treatment = 1 # gneezy - BinsWanger
        else:
            self.player.treatment = 2 # BinsWanger -gneezy

        self.player.participant.vars['treatment'] = self.player.treatment

class BienvenueBis(Page): # version anglaise
        form_model = 'player'
        form_fields = []

        def is_displayed(self):
            return self.participant.vars['versionexp'] == 2

        def before_next_page(self):

            self.player.language = "EN"
            self.player.participant.vars['language'] = self.player.language

            if self.player.id_in_group % 2 == 1:
                self.player.treatment = 1  # gneezy - BinsWanger
            else:
                self.player.treatment = 2  # BinsWanger -gneezy

            self.player.participant.vars['treatment'] = self.player.treatment


page_sequence = [
    Bienvenue0,
    Bienvenue,
    BienvenueBis,

]
