/*
 *  Copyright 2025-2026 R3944Realms
 *
 *    Licensed under the Apache License, Version 2.0 (the "License");
 *    you may not use this file except in compliance with the License.
 *    You may obtain a copy of the License at
 *
 *        http://www.apache.org/licenses/LICENSE-2.0
 *
 *    Unless required by applicable law or agreed to in writing, software
 *    distributed under the License is distributed on an "AS IS" BASIS,
 *    WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
 *    See the License for the specific language governing permissions and
 *    limitations under the License.
 */

package top.r3944realms.eroticdungeongame.config;

import net.minecraftforge.common.ForgeConfigSpec;

public class EDGConfig {
    public static final ForgeConfigSpec.Builder COMMON_BUILDER = new ForgeConfigSpec.Builder();
    /**
     * The constant SPEC.
     */
    public static final ForgeConfigSpec COMMON_SPEC;
    public static final ForgeConfigSpec.Builder SERVER_BUILDER = new ForgeConfigSpec.Builder();
    /**
     * The constant SPEC.
     */
    public static final ForgeConfigSpec SERVER_SPEC;
    /**
     * The constant COMMON.
     */
    public static final Common COMMON;

    public static final Server SERVER;
    static {
        COMMON_BUILDER.comment("EroticDungeon Common Configuration / 通用配置").push("EroticDungeon");
        COMMON = new Common(COMMON_BUILDER);
        COMMON_BUILDER.pop();
        COMMON_SPEC = COMMON_BUILDER.build();

        SERVER_BUILDER.comment("EroticDungeon Server Configuration / 服务器用配置").push("EroticDungeon");
        SERVER = new Server(SERVER_BUILDER);
        SERVER_BUILDER.pop();
        SERVER_SPEC = SERVER_BUILDER.build();
    }

    public static class Common {
        // NORP相关配置
        public final ForgeConfigSpec.BooleanValue ENABLE_NORP;
        public final ForgeConfigSpec.IntValue NORP_INTERVAL_TIME;
        public final ForgeConfigSpec.IntValue NORP_SUCCESSFUL_COOLDOWN;

        // 爱机相关配置
        public final ForgeConfigSpec.BooleanValue ENABLE_LOVE_MACHINE_DAMAGE;
        public final ForgeConfigSpec.DoubleValue LOVE_MACHINE_DAMAGE_FACTOR;

        public final ForgeConfigSpec.BooleanValue SHOW_LOCK_OVERLAY;

        public Common(ForgeConfigSpec.Builder builder) {

            // NORP配置组 - 中英文说明
            builder.comment(
                    "NORP (No Role Play) Mode Settings / NORP（非角色扮演）模式设置",
                    "----------------------------------------",
                    "EN: Settings related to No Role Play mode functionality",
                    "CN: 与非角色扮演模式功能相关的设置"
            ).push("norp_settings");

            ENABLE_NORP = builder
                    .comment(
                            "EN: Enable No Role Play mode",
                            "    If set to true, NORP mode will be enabled",
                            "    Default: true",
                            "",
                            "CN: 启用非角色扮演模式",
                            "    如果设为true，将启用NORP模式",
                            "    默认值: true"
                    )
                    .define("enableNorp", true);

            NORP_INTERVAL_TIME = builder
                    .comment(
                            "EN: NORP interval time (in seconds)",
                            "    Time between NORP interactions",
                            "    Default: 30 seconds",
                            "    Min: 5, Max: 3600",
                            "",
                            "CN: NORP间隔时间（秒）",
                            "    NORP交互之间的间隔时间",
                            "    默认值: 30秒",
                            "    最小值: 5, 最大值: 3600"
                    )
                    .defineInRange("norpIntervalTime", 30, 5, 3600);

            NORP_SUCCESSFUL_COOLDOWN = builder
                    .comment(
                            "EN: NORP cooldown time after successful interaction (in seconds)",
                            "    Time before another NORP interaction can occur",
                            "    Default: 60 seconds",
                            "    Min: 10, Max: 7200",
                            "",
                            "CN: NORP成功交互后的冷却时间（秒）",
                            "    进行下一次NORP交互前需要等待的时间",
                            "    默认值: 60秒",
                            "    最小值: 10, 最大值: 7200"
                    )
                    .defineInRange("norpSuccessfulCooldown", 60, 10, 7200);

            builder.pop(); // 退出NORP配置组

            // 爱机配置组 - 中英文说明
            builder.comment(
                    "Love Machine Settings / 爱机设置",
                    "----------------------------------------",
                    "EN: Settings related to Love Machine functionality",
                    "CN: 与爱机功能相关的设置"
            ).push("love_machine_settings");

            ENABLE_LOVE_MACHINE_DAMAGE = builder
                    .comment(
                            "EN: Enable Love Machine damage",
                            "    If set to true, love machines can deal damage",
                            "    Default: false",
                            "",
                            "CN: 启用爱机伤害",
                            "    如果设为true，爱机可以造成伤害",
                            "    默认值: false"
                    )
                    .define("enableLoveMachineDamage", false);

            LOVE_MACHINE_DAMAGE_FACTOR = builder
                    .comment(
                            "EN: Love Machine damage factor",
                            "    Damage multiplier for love machines",
                            "    Default: 1.0",
                            "    Min: 0.1, Max: 10.0",
                            "",
                            "CN: 爱机伤害系数",
                            "    爱机的伤害倍率",
                            "    默认值: 1.0",
                            "    最小值: 0.1, 最大值: 10.0"
                    )
                    .defineInRange("loveMachineDamageFactor", 1.0, 0.1, 10.0);

            builder.pop(); // 退出爱机配置组

            // UI配置组 - 中英文说明
            builder.comment(
                    "UI Settings / 界面设置",
                    "----------------------------------------",
                    "EN: Settings related to user interface display",
                    "CN: 与用户界面显示相关的设置"
            ).push("ui_settings");

            SHOW_LOCK_OVERLAY = builder
                    .comment(
                            "EN: Show lock overlay on devices",
                            "    If set to true, shows 'Device Locked' text when looking at locked devices",
                            "    Default: true",
                            "",
                            "CN: 在设备上显示锁提示",
                            "    如果设为true，看向锁定的设备时会显示'设备已锁定'文字",
                            "    默认值: true"
                    )
                    .define("showLockOverlay", true);

            builder.pop(); // 退出UI配置组

            // 添加更多配置组
            builder.comment(
                    "General Settings / 通用设置",
                    "----------------------------------------",
                    "EN: General mod settings",
                    "CN: 模组通用设置"
            ).push("general_settings");

            // 这里可以添加其他通用配置

            builder.pop(); // 退出通用配置组
        }
    }

    public static class Server {
        public final ForgeConfigSpec.DoubleValue ANCHORING_MAX_CHAIN_LENGTH;
        public final ForgeConfigSpec.DoubleValue ANCHORING_SUFFOCATION_LENGTH;
        public final ForgeConfigSpec.BooleanValue ANCHORING_ALLOW_ANCHORING_TO_WEIGHTED_ANCHORS;
        public Server(ForgeConfigSpec.Builder builder) {
            builder.comment(
                    "Anchoring System Settings / 锚定系统设置",
                    "----------------------------------------",
                    "EN: Settings for entity anchoring mechanics",
                    "CN: 实体锚定机制设置"
            ).push("anchoring_settings");

            ANCHORING_MAX_CHAIN_LENGTH = builder
                    .comment(
                            "EN: Maximum chain length for anchoring",
                            "    Maximum distance between anchor and anchored entity",
                            "    Default: 10.0 blocks",
                            "    Min: 1.0, Max: 50.0",
                            "",
                            "CN: 锚定最大链长度",
                            "    锚点与锚定实体之间的最大距离",
                            "    默认值: 10.0格",
                            "    最小值: 1.0, 最大值: 50.0"
                    )
                    .defineInRange("anchoringMaxChainLength", 10.0, 1.0, 50.0);

            ANCHORING_SUFFOCATION_LENGTH = builder
                    .comment(
                            "EN: Suffocation length for anchoring",
                            "    Distance at which anchored entity starts taking damage",
                            "    Default: 15.0 blocks",
                            "    Min: 5.0, Max: 30.0",
                            "",
                            "CN: 锚定窒息长度",
                            "    锚定实体开始受到伤害的距离",
                            "    默认值: 15.0格",
                            "    最小值: 5.0, 最大值: 30.0"
                    )
                    .defineInRange("anchoringSuffocationLength", 15.0, 5.0, 30.0);

            ANCHORING_ALLOW_ANCHORING_TO_WEIGHTED_ANCHORS = builder
                    .comment(
                            "EN: Allow anchoring to weighted anchors",
                            "    If set to true, entities can be anchored to weighted anchors",
                            "    Default: true",
                            "",
                            "CN: 允许锚定到加重锚点",
                            "    如果设为true，实体可以锚定到加重锚点",
                            "    默认值: true"
                    )
                    .define("anchoringAllowAnchoringToWeightedAnchors", true);

        }
    }
}
