package com.robertx22.mine_and_slash.config.forge.specs;

import com.robertx22.mine_and_slash.config.forge.ServerContainer;
import net.minecraftforge.common.ForgeConfigSpec;

public final class ServerResourcesConfig {

    public static final ForgeConfigSpec SPEC;

    static {
        ForgeConfigSpec.Builder b = new ForgeConfigSpec.Builder();
        var s = ServerContainer.get();

        b.comment("Health / mana / ES regeneration multipliers and hunger cost").push("regen");
        s.IN_COMBAT_REGEN_MULTI = b.defineInRange("IN_COMBAT_REGEN_MULTI", 0.5D, 0D, 10D);
        s.OUT_OF_COMBAT_REGEN_MULTI = b.defineInRange("OUT_OF_COMBAT_REGEN_MULTI", 2.0D, 0.0D, 100.0D);
        s.REGEN_HUNGER_COST = b.defineInRange("REGEN_HUNGER_COST", 10D, 0D, 1000D);
        b.pop();

        b.comment("Energy costs").push("energy");
        s.UNARMED_ENERGY_COST = b.defineInRange("UNARMED_ENERGY_COST", 10D, 0D, 100D);
        b.pop();

        b.comment("Blocking action cost").push("block");
        s.BLOCK_COST = b.defineInRange("BLOCK_COST", 0.25D, 0D, 1000D);
        b.pop();

        b.comment("Combat-state tracking and vanilla weapon behaviour").push("combat_state");
        s.PERC_OFFHAND_WEP_STAT = b.defineInRange("PERC_OFFHAND_WEP_STAT", 25, 0, 100);
        s.REMOVE_ATK_SPEED_COOLDOWN = b.comment("MnS tries to replicate vanilla atk speed and reduces dmg of basic attacks if hit too often")
                .define("REMOVE_ATK_SPEED_COOLDOWN", false);
        s.COMBAT_EXIT_TICKS = b.comment("Ticks after the last damage event before the player is considered out-of-combat. 20 = 1s.")
                .defineInRange("COMBAT_EXIT_TICKS", 100, 20, 6000);
        b.pop();

        b.comment("Ailment timing — DOTs (burn/bleed/poison), Freeze, Electrify").push("ailments");
        s.DOT_MIN_DURATION_TICKS = b.comment("EntityAilmentData.java:113 — minimum lifetime for any DOT before it can expire (anti-instant-fizzle).")
                .defineInRange("DOT_MIN_DURATION_TICKS", 21, 1, 6000);
        s.FREEZE_SLOW_DURATION_TICKS = b.comment("EntityAilmentData.java:159 — duration of the Freeze-applied slow effect on target. 20 ticks = 1s.")
                .defineInRange("FREEZE_SLOW_DURATION_TICKS", 100, 20, 6000);
        s.STRENGTH_DECAY_INTERVAL_TICKS = b.comment("EntityAilmentData.java:179 — how often Freeze/Electrify strength decays. Lower = faster fade.")
                .defineInRange("STRENGTH_DECAY_INTERVAL_TICKS", 20, 1, 200);
        s.DOT_TICK_INTERVAL_TICKS = b.comment("EntityAilmentData.java:189 — how often DOTs tick their damage. Lower = more frequent ticks (smoother but more network).")
                .defineInRange("DOT_TICK_INTERVAL_TICKS", 20, 1, 200);
        s.CLEANUP_INTERVAL_TICKS = b.comment("EntityAilmentData.java:232 — how often the ailment-data cleanup pass runs to drop empty entries.")
                .defineInRange("CLEANUP_INTERVAL_TICKS", 400, 20, 12000);
        s.PCT_HP_FOR_FULL_STRENGTH = b.comment("Ailment.java:32 — % of target max HP needed in accumulated stacks before Freeze/Electrify reach full strength. 0.25 = 25%.")
                .defineInRange("PCT_HP_FOR_FULL_STRENGTH", 0.25D, 0.01D, 10.0D);
        b.pop();

        SPEC = b.build();
    }

    private ServerResourcesConfig() {
    }
}
