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

import random
import time



class Pass(Page):
    timeout_seconds = 0  # WB

    form_model = 'player'

    def before_next_page(self):


        self.player.treatmentname = self.player.participant.vars['treatmentname']
        self.player.jeu_tire = self.player.participant.vars['jeu_tire']
        self.player.jeuname = self.player.participant.vars['jeuname']
        self.player.gainfinal = self.player.participant.vars['gainfinal']
        self.player.gaineur = self.player.participant.vars['gaineur']
        self.player.gainfinaleur = self.player.participant.vars['gainfinaleur']


        self.player.lastname = self.player.participant.vars['lastname']
        self.player.firstname = self.player.participant.vars['firstname']
        self.player.email = self.player.participant.vars['email']
        self.player.room = self.player.participant.vars['room']
        self.player.language = self.player.participant.vars['language']



        if  (self.player.gainfinaleur * 100) % 100 <= 50 and (self.player.gainfinaleur * 100) % 100  > 0 :
            self.player.gain_ff = (round(((self.player.gainfinaleur * 100) - ((self.player.gainfinaleur * 100) % 100)), 0) + 50) / 100
        else:
            self.player.gain_ff = round((self.player.gainfinaleur), 0)

class Fin(Page):
    timeout_seconds = 300  # WB

    form_model = 'player'


page_sequence = [
    Pass,
    Fin,


]
