<?php

namespace App\Http\Requests\Admin\Game;

use App\Enums\GameStatusEnum;
use Illuminate\Foundation\Http\FormRequest;
use Illuminate\Validation\Rule;

class UpdateGameRequest extends FormRequest
{
    public function authorize(): bool
    {
        return true;
    }

    public function rules(): array
    {
        return [
            'name'              => ['required', 'array'],
            'name.en'           => ['required', 'string', 'max:255'],
            'name.ar'           => ['nullable', 'string', 'max:255'],
            'description'       => ['nullable', 'array'],
            'description.en'    => ['nullable', 'string'],
            'description.ar'    => ['nullable', 'string'],
            'min_players'       => ['required', 'integer', 'min:1', 'lte:max_players'],
            'max_players'       => ['required', 'integer', 'min:1', 'gte:min_players'],
            'duration'          => ['required', 'integer', 'min:15'],
            'age_limit_min'     => ['nullable', 'integer', 'min:0'],
            'age_limit_max'     => ['nullable', 'integer', 'min:0', 'gte:age_limit_min'],
            'price_per_session' => ['nullable', 'numeric', 'min:0'],
            'status'            => ['required', 'integer', Rule::in(GameStatusEnum::values())],
            'image'             => ['nullable', 'image', 'max:2048'],
        ];
    }
}
