package com.livingworld.modules.atmosphere;

/**
 * Per-region atmospheric state tracked by {@link AtmosphereModule}.
 *
 * <p>Both values smoothly interpolate toward ecosystem-derived targets each
 * simulation cycle and are used to drive per-player weather packets.
 *
 * <ul>
 *   <li><b>rainLevel</b>   – 0.0 = drought, 1.0 = heavy rainfall
 *   <li><b>thunderLevel</b> – 0.0 = calm, 1.0 = heavy storm (acid rain above 0.4)
 * </ul>
 */
public final class AtmosphereRegionData {

    private double rainLevel;
    private double thunderLevel;

    public AtmosphereRegionData(double rainLevel, double thunderLevel) {
        this.rainLevel    = clamp(rainLevel);
        this.thunderLevel = clamp(thunderLevel);
    }

    public static AtmosphereRegionData defaults() {
        return new AtmosphereRegionData(0.4, 0.0);
    }

    public double getRainLevel()    { return rainLevel; }
    public double getThunderLevel() { return thunderLevel; }

    public void setRainLevel(double v)    { this.rainLevel    = clamp(v); }
    public void setThunderLevel(double v) { this.thunderLevel = clamp(v); }

    public AtmosphereRegionData copy() {
        return new AtmosphereRegionData(rainLevel, thunderLevel);
    }

    private static double clamp(double v) { return Math.min(1.0, Math.max(0.0, v)); }

    @Override
    public String toString() {
        return "AtmosphereRegionData{rain=" + rainLevel + ", thunder=" + thunderLevel + "}";
    }
}
