package com.atridad.openclimb.data.model

import androidx.room.Entity
import androidx.room.PrimaryKey
import kotlinx.serialization.Serializable
import java.time.LocalDateTime

@Entity(tableName = "gyms")
@Serializable
data class Gym(
    @PrimaryKey
    val id: String,
    val name: String,
    val location: String? = null,
    val supportedClimbTypes: List<ClimbType>,
    val difficultySystems: List<DifficultySystem>, // What systems this gym uses
    val customDifficultyGrades: List<String> = emptyList(), // For gyms using colors/custom names
    val notes: String? = null,
    val createdAt: String, // ISO string format for serialization
    val updatedAt: String
) {
    companion object {
        fun create(
            name: String,
            location: String? = null,
            supportedClimbTypes: List<ClimbType>,
            difficultySystems: List<DifficultySystem>,
            customDifficultyGrades: List<String> = emptyList(),
            notes: String? = null
        ): Gym {
            val now = LocalDateTime.now().toString()
            return Gym(
                id = java.util.UUID.randomUUID().toString(),
                name = name,
                location = location,
                supportedClimbTypes = supportedClimbTypes,
                difficultySystems = difficultySystems,
                customDifficultyGrades = customDifficultyGrades,
                notes = notes,
                createdAt = now,
                updatedAt = now
            )
        }
    }
}
