import Foundation

enum Difficulty: String, CaseIterable, Codable, Identifiable, Sendable {
    case easy, medium, hard, expert

    var id: String { rawValue }

    var displayName: String { rawValue.capitalized }

    var settings: DifficultySettings {
        switch self {
        case .easy:
            DifficultySettings(
                drawCount: 1,
                maxUndos: .max,
                hintsEnabled: true,
                scoreMultiplier: 0.5,
                timePenalty: 0,
                autoFlipDelay: 0.5
            )
        case .medium:
            DifficultySettings(
                drawCount: 3,
                maxUndos: 20,
                hintsEnabled: true,
                scoreMultiplier: 1.0,
                timePenalty: 2,
                autoFlipDelay: 0.3
            )
        case .hard:
            DifficultySettings(
                drawCount: 3,
                maxUndos: 10,
                hintsEnabled: false,
                scoreMultiplier: 1.5,
                timePenalty: 5,
                autoFlipDelay: 0.2
            )
        case .expert:
            DifficultySettings(
                drawCount: 3,
                maxUndos: 5,
                hintsEnabled: false,
                scoreMultiplier: 2.0,
                timePenalty: 10,
                autoFlipDelay: 0.1
            )
        }
    }
}

struct DifficultySettings: Sendable {
    let drawCount: Int
    let maxUndos: Int
    let hintsEnabled: Bool
    let scoreMultiplier: Double
    let timePenalty: Int
    let autoFlipDelay: TimeInterval
}
