from django import forms


class LotterySimulatorForm(forms.Form):
    lottery_type = forms.ChoiceField(
        label="Loteria",
        choices=[],
        widget=forms.Select(
            attrs={
                "class": "form-select form-select-lg",
            }
        ),
    )
    draws_to_consider = forms.IntegerField(
        label="Ultimos sorteios",
        min_value=3,
        max_value=20,
        initial=10,
        widget=forms.NumberInput(
            attrs={
                "class": "form-control",
                "inputmode": "numeric",
            }
        ),
    )
    games_to_generate = forms.IntegerField(
        label="Jogos sugeridos",
        min_value=1,
        max_value=12,
        initial=4,
        widget=forms.NumberInput(
            attrs={
                "class": "form-control",
                "inputmode": "numeric",
            }
        ),
    )

    def __init__(self, *args, **kwargs):
        lottery_choices = kwargs.pop("lottery_choices", [])
        super().__init__(*args, **kwargs)
        self.fields["lottery_type"].choices = lottery_choices
