<?php

namespace Database\Factories;

use App\Models\Park;
use App\Models\Operator;
use App\Enums\ParkStatus;
use Illuminate\Database\Eloquent\Factories\Factory;

class ParkFactory extends Factory
{
    protected $model = Park::class;

    public function definition(): array
    {
        return [
            'name' => fake()->unique()->company() . ' Theme Park',
            'slug' => fake()->unique()->slug(3),
            'description' => fake()->paragraph(),
            'status' => fake()->randomElement(ParkStatus::cases()),
            'opening_date' => fake()->dateTimeBetween('-50 years', '-1 year'),
            'operating_season' => 'Year-round',
            'size_acres' => fake()->numberBetween(20, 500),
            'website' => fake()->url(),
            'operator_id' => Operator::factory(),
            'total_areas' => fake()->numberBetween(3, 8),
            'operating_areas' => fake()->numberBetween(2, 8),
            'closed_areas' => fake()->numberBetween(0, 2),
            'ride_count' => fake()->numberBetween(20, 60),
            'coaster_count' => fake()->numberBetween(2, 15),
            'total_flat_rides' => fake()->numberBetween(10, 30),
            'total_water_rides' => fake()->numberBetween(1, 5),
            'total_daily_capacity' => fake()->numberBetween(10000, 50000),
            'average_wait_time' => fake()->numberBetween(15, 90),
            'average_rating' => fake()->randomFloat(1, 3.0, 5.0),
            'total_rides_operated' => fake()->numberBetween(20, 100),
            'total_rides_retired' => fake()->numberBetween(0, 20),
            'last_expansion_date' => fake()->dateTimeBetween('-5 years', 'now'),
            'last_major_update' => fake()->dateTimeBetween('-1 year', 'now'),
            'utilization_rate' => fake()->randomFloat(2, 0.50, 0.95),
            'peak_daily_attendance' => fake()->numberBetween(15000, 100000),
            'guest_satisfaction' => fake()->randomFloat(1, 3.0, 5.0),
        ];
    }

    /**
     * Configure the model factory.
     *
     * @return $this
     */
    public function operating()
    {
        return $this->state(function (array $attributes) {
            return [
                'status' => ParkStatus::OPERATING,
            ];
        });
    }

    /**
     * Configure the model factory.
     *
     * @return $this
     */
    public function closed()
    {
        return $this->state(function (array $attributes) {
            return [
                'status' => ParkStatus::CLOSED_PERM,
            ];
        });
    }
}