package com.livingworld.config;

/**
 * Tuning constants for the Living World ecosystem simulation.
 *
 * <p>Populated from {@code config/livingworld-server.toml} at server startup via
 * {@link com.livingworld.platform.neoforge.NeoForgeModConfig}. Modules access this
 * via {@link com.livingworld.core.services.CoreServices#TUNING} from the service
 * registry during {@code initialize()}.
 *
 * <p>Default values match the hardcoded constants they replaced, so a missing
 * config file produces identical simulation behaviour to earlier versions.
 */
public final class EcosystemTuning {

    // -- Pollution --
    private double pollutionDecayRate  = 0.002;
    private double groundToWaterLeach  = 0.005;
    private double pollutionSpreadRate = 0.02;
    private double windBoost           = 0.5;

    // -- Vegetation growth (per soil-quality unit above threshold per tick) --
    private double grassGrowthRate  = 0.06;
    private double flowerGrowthRate = 0.03;
    private double shrubGrowthRate  = 0.02;
    private double treeGrowthRate   = 0.008;

    // -- Vegetation die-off (flat reduction per tick under bad conditions) --
    private double grassDieoffRate  = 1.00;
    private double flowerDieoffRate = 0.50;
    private double shrubDieoffRate  = 0.25;
    private double treeDieoffRate   = 0.10;

    // -- Ecological succession --
    private double baseProgressPerTick = 2.0;
    private double damagePerBadTick    = 5.0;
    private double damageDecayRate     = 0.03;

    // -- Seed dispersal (new ecological corridors feature) --
    /** Fraction of vegetation pressure emitted as seeds to each neighbour per tick. */
    private double seedEmissionRate        = 0.01;
    /** Seed multiplier when the target region has 2+ healthy neighbours (corridor effect). */
    private double corridorBoostMultiplier = 3.5;
    /** Seeds blocked per unit of pollution score in the target region. */
    private double seedPollutionBlock      = 0.015;

    public EcosystemTuning() {}

    // -- Pollution getters/setters --
    public double getPollutionDecayRate()  { return pollutionDecayRate; }
    public double getGroundToWaterLeach()  { return groundToWaterLeach; }
    public double getPollutionSpreadRate() { return pollutionSpreadRate; }
    public double getWindBoost()           { return windBoost; }
    public void setPollutionDecayRate(double v)  { pollutionDecayRate  = v; }
    public void setGroundToWaterLeach(double v)  { groundToWaterLeach  = v; }
    public void setPollutionSpreadRate(double v) { pollutionSpreadRate = v; }
    public void setWindBoost(double v)           { windBoost           = v; }

    // -- Vegetation growth getters/setters --
    public double getGrassGrowthRate()  { return grassGrowthRate; }
    public double getFlowerGrowthRate() { return flowerGrowthRate; }
    public double getShrubGrowthRate()  { return shrubGrowthRate; }
    public double getTreeGrowthRate()   { return treeGrowthRate; }
    public void setGrassGrowthRate(double v)  { grassGrowthRate  = v; }
    public void setFlowerGrowthRate(double v) { flowerGrowthRate = v; }
    public void setShrubGrowthRate(double v)  { shrubGrowthRate  = v; }
    public void setTreeGrowthRate(double v)   { treeGrowthRate   = v; }

    // -- Vegetation die-off getters/setters --
    public double getGrassDieoffRate()  { return grassDieoffRate; }
    public double getFlowerDieoffRate() { return flowerDieoffRate; }
    public double getShrubDieoffRate()  { return shrubDieoffRate; }
    public double getTreeDieoffRate()   { return treeDieoffRate; }
    public void setGrassDieoffRate(double v)  { grassDieoffRate  = v; }
    public void setFlowerDieoffRate(double v) { flowerDieoffRate = v; }
    public void setShrubDieoffRate(double v)  { shrubDieoffRate  = v; }
    public void setTreeDieoffRate(double v)   { treeDieoffRate   = v; }

    // -- Succession getters/setters --
    public double getBaseProgressPerTick() { return baseProgressPerTick; }
    public double getDamagePerBadTick()    { return damagePerBadTick; }
    public double getDamageDecayRate()     { return damageDecayRate; }
    public void setBaseProgressPerTick(double v) { baseProgressPerTick = v; }
    public void setDamagePerBadTick(double v)    { damagePerBadTick    = v; }
    public void setDamageDecayRate(double v)     { damageDecayRate     = v; }

    // -- Seed dispersal getters/setters --
    public double getSeedEmissionRate()        { return seedEmissionRate; }
    public double getCorridorBoostMultiplier() { return corridorBoostMultiplier; }
    public double getSeedPollutionBlock()      { return seedPollutionBlock; }
    public void setSeedEmissionRate(double v)        { seedEmissionRate        = v; }
    public void setCorridorBoostMultiplier(double v) { corridorBoostMultiplier = v; }
    public void setSeedPollutionBlock(double v)      { seedPollutionBlock      = v; }
}
