<?php

namespace App\Http\Requests;

use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Support\Facades\Auth;

class StoreGameRequest extends FormRequest
{
    /**
     * Determine if the user is authorized to make this request.
     */
    public function authorize(): bool
    {
        // Só utilizadores autenticados podem criar jogos
        return Auth::check();
    }

    /**
     * Get the validation rules that apply to the request.
     *
     * @return array<string, \Illuminate\Contracts\Validation\ValidationRule|array<mixed>|string>
     */
    public function rules(): array
    {
        return [
            // Agora validamos diretamente '3' ou '9' para bater certo com a BD
            'type' => 'required|in:3,9',
        ];
    }

    /**
     * Mensagens personalizadas (Opcional)
     */
    public function messages(): array
    {
        return [
            'type.required' => 'You must choose a game type (Bisca de 3 or 9).',
            'type.in' => 'Invalid game type. Choose 3 or 9.',
        ];
    }
}