package com.livingworld.modules.atmosphere;

/**
 * The four ecological seasons, derived from absolute Minecraft day count.
 *
 * <p>One full year = 32 Minecraft days (8 days per season). Season drives the
 * rain target modifier in {@link AtmosphereModule} and seasonal soil effects in
 * the bootstrap post-sim pass.
 */
public enum Season {

    //                   rain    temp   drought  vegGrowth
    SPRING(             +0.10,  +0.02,   -0.05,   +0.04),
    SUMMER(             -0.15,  +0.05,   +0.03,   +0.02),
    AUTUMN(               0.0,  -0.01,    0.00,   -0.02),
    WINTER(             -0.25,  -0.05,   +0.02,   -0.06);

    private static final int SEASON_LENGTH_DAYS = 8;

    /** Additive modifier applied to the atmosphere rain target this season. */
    private final double rainModifier;
    /** Per-cycle soil-temperature effect (positive = warming, negative = cooling). */
    private final double temperatureMod;
    /** Per-cycle drought risk delta (positive = drought worsens, negative = eases). */
    private final double droughtMod;
    /** Per-cycle vegetation growth delta (positive = growth, negative = senescence). */
    private final double vegGrowthMod;

    Season(double rainModifier, double temperatureMod, double droughtMod, double vegGrowthMod) {
        this.rainModifier    = rainModifier;
        this.temperatureMod  = temperatureMod;
        this.droughtMod      = droughtMod;
        this.vegGrowthMod    = vegGrowthMod;
    }

    public double rainModifier()   { return rainModifier; }
    public double temperatureMod() { return temperatureMod; }
    public double droughtMod()     { return droughtMod; }
    public double vegGrowthMod()   { return vegGrowthMod; }

    public String displayName() {
        String n = name();
        return n.charAt(0) + n.substring(1).toLowerCase();
    }

    /** Returns the season for the given absolute Minecraft day number (gameTime / 24000). */
    public static Season fromAbsoluteDay(long absoluteDay) {
        return values()[(int) ((absoluteDay / SEASON_LENGTH_DAYS) % 4)];
    }
}
