#[derive(Debug, Clone, Copy, PartialEq)]
pub enum CloudBiome {
    UpperHaze,
    MethaneIceCloud,
    H2SCloud,
    DeepCloud,
    ClearBand,
    StormRegion,
    PolarVortex,
}

pub struct SplatWeights {
    pub weights: [(CloudBiome, f32); 4],
}

pub struct CloudBiomeClassifier {
    pub onebarlevel: f64,
}

impl Default for CloudBiomeClassifier {
    fn default() -> Self {
        Self { onebarlevel: 0.0 }
    }
}

impl CloudBiomeClassifier {
    pub fn classify(&self, altitudem: f64, latitudedeg: f64, windspeedms: f64) -> CloudBiome {
        let abslat = latitudedeg.abs();
        if abslat > 80.0 {
            return CloudBiome::PolarVortex;
        }
        if windspeedms > 500.0 {
            return CloudBiome::StormRegion;
        }
        if altitudem > self.onebarlevel + 50000.0 {
            return CloudBiome::UpperHaze;
        }
        if altitudem > self.onebarlevel + 30000.0 {
            return CloudBiome::MethaneIceCloud;
        }
        if altitudem > self.onebarlevel + 10000.0 {
            return CloudBiome::H2SCloud;
        }
        if altitudem > self.onebarlevel - 50000.0 {
            return CloudBiome::DeepCloud;
        }
        CloudBiome::ClearBand
    }

    pub fn splat(&self, altitudem: f64, latitudedeg: f64, windspeedms: f64) -> SplatWeights {
        let primary = self.classify(altitudem, latitudedeg, windspeedms);
        SplatWeights {
            weights: [
                (primary, 1.0),
                (CloudBiome::ClearBand, 0.0),
                (CloudBiome::ClearBand, 0.0),
                (CloudBiome::ClearBand, 0.0),
            ],
        }
    }
}
