// Codable structs mirroring the JSON level format

struct GridSizeDef: Codable {
    let width: Int
    let height: Int
}

struct BlockDef: Codable {
    let x: Int
    let y: Int
    let color: String
}

struct PositionDef: Codable {
    let x: Int
    let y: Int
}

struct ObjectiveDef: Codable {
    let type: String
    let color: String?
    let count: Int?
    let targets: [PositionDef]?
}

struct LevelDefinition: Codable {
    let id: String
    let world: Int
    let level: Int
    let title: String?
    let grid: GridSizeDef
    let blocks: [BlockDef]
    let walls: [PositionDef]?
    let specialTiles: [SpecialTileDef]?
    let objective: ObjectiveDef
    let par: Int
    let hints: [String]?

    enum CodingKeys: String, CodingKey {
        case id, world, level, title, grid, blocks, walls
        case specialTiles = "special_tiles"
        case objective, par, hints
    }
}

struct SpecialTileDef: Codable {
    let x: Int
    let y: Int
    let type: String
    // Additional fields ignored at MVP
}
