from django.utils import timezone
from parks.models import Park, ParkLocation
from rides.models import Ride, RideModel, RollerCoasterStats
from rides.models import Manufacturer

# Create Cedar Point
park, _ = Park.objects.get_or_create(
    name="Cedar Point",
    slug="cedar-point",
    defaults={
        "description": (
            "Cedar Point is a 364-acre amusement park located on a Lake Erie "
            "peninsula in Sandusky, Ohio."
        ),
        "website": "https://www.cedarpoint.com",
        "size_acres": 364,
        "opening_date": timezone.datetime(
            1870, 1, 1
        ).date(),  # Cedar Point opened in 1870
    },
)

# Create location for Cedar Point
location, _ = ParkLocation.objects.get_or_create(
    park=park,
    defaults={
        "street_address": "1 Cedar Point Dr",
        "city": "Sandusky",
        "state": "OH",
        "postal_code": "44870",
        "country": "USA",
    },
)
# Set coordinates using the helper method
location.set_coordinates(-82.6839, 41.4822)  # longitude, latitude
location.save()

# Create Intamin as manufacturer
bm, _ = Manufacturer.objects.get_or_create(
    name="Intamin",
    slug="intamin",
    defaults={
        "description": (
            "Intamin Amusement Rides is a design company known for creating "
            "some of the most thrilling and innovative roller coasters in the world."
        ),
        "website": "https://www.intaminworldwide.com",
    },
)

# Create Giga Coaster model
giga_model, _ = RideModel.objects.get_or_create(
    name="Giga Coaster",
    manufacturer=bm,
    defaults={
        "description": (
            "A roller coaster type characterized by a height between 300–399 feet "
            "and a complete circuit."
        ),
        "category": "RC",  # Roller Coaster
    },
)

# Create Millennium Force
millennium, _ = Ride.objects.get_or_create(
    name="Millennium Force",
    slug="millennium-force",
    defaults={
        "description": (
            "Millennium Force is a steel roller coaster located at Cedar Point "
            "amusement park in Sandusky, Ohio. It was built by Intamin of "
            "Switzerland and opened on May 13, 2000 as the world's first giga "
            "coaster, a class of roller coasters having a height between 300 "
            "and 399 feet and a complete circuit."
        ),
        "park": park,
        "category": "RC",
        "manufacturer": bm,
        "ride_model": giga_model,
        "status": "OPERATING",
        "opening_date": timezone.datetime(2000, 5, 13).date(),
        "min_height_in": 48,  # 48 inches minimum height
        "capacity_per_hour": 1300,
        "ride_duration_seconds": 120,  # 2 minutes
    },
)

# Create stats for Millennium Force
RollerCoasterStats.objects.get_or_create(
    ride=millennium,
    defaults={
        "height_ft": 310,
        "length_ft": 6595,
        "speed_mph": 93,
        "inversions": 0,
        "ride_time_seconds": 120,
        "track_material": "STEEL",
        "roller_coaster_type": "SITDOWN",
        "max_drop_height_ft": 300,
        "launch_type": "CHAIN",
        "train_style": "Open-air stadium seating",
        "trains_count": 3,
        "cars_per_train": 9,
        "seats_per_car": 4,
    },
)

print("Initial data created successfully!")
