package com.zivilon.cinder_loe;

import cpw.mods.fml.common.event.FMLPreInitializationEvent;

import java.io.File;

import lotr.common.fac.LOTRFaction;
import net.minecraftforge.common.config.Configuration;

public class CinderLoE_Config {
    public static Configuration config;
    public static float enchantment_color_red;
    public static float enchantment_color_green;
    public static float enchantment_color_blue;
    public static String corrupt_faction;
    public static String skeleton_faction;
    public static String ulukai_faction;

    public static boolean objective_lindon;
    public static boolean objective_arnor;
    public static boolean objective_angmar;
    public static boolean objective_durin;
    public static boolean objective_dolguldur;
    public static boolean objective_woodelf;
    public static boolean objective_lothlorien;
    public static boolean objective_dale;
    public static boolean objective_rhudaur;

    public static boolean warbands_enabled;
    public static boolean unit_conversion_enabled;

    public static void init(FMLPreInitializationEvent event) {
        File configFile = new File(event.getModConfigurationDirectory(), "CinderLoE.cfg");
        config = new Configuration(configFile);
        syncConfig();
    }

    public static void syncConfig() {
        try {
            // Load the configuration file
            config.load();

            // Read properties, define categories and keys
            enchantment_color_red = config.getFloat("EnchantmentColorRed", Configuration.CATEGORY_GENERAL, 0.38f, 0.0f, 1.0f, "Configure red color for enchantments");
            enchantment_color_green = config.getFloat("EnchantmentColorGreen", Configuration.CATEGORY_GENERAL, 0.19f, 0.0f, 1.0f, "Configure green color for enchantments");
            enchantment_color_blue = config.getFloat("EnchantmentColorBlue", Configuration.CATEGORY_GENERAL, 0.608f, 0.0f, 1.0f, "Configure blue color for enchantments");

            corrupt_faction = config.getString("CorruptFaction", Configuration.CATEGORY_GENERAL, "UTUMNO", "Configure the alignment the Corrupt npcs follow");
            skeleton_faction = config.getString("SkeletonFaction", Configuration.CATEGORY_GENERAL, "UTUMNO", "Configure the alignment the Skeleton npcs follow");

            ulukai_faction = config.getString("UlukaiFaction", Configuration.CATEGORY_GENERAL, "GUNDABAD", "Configure the faction the Ulukai Assists");

            objective_lindon = config.getBoolean("Lindon", Configuration.CATEGORY_GENERAL, false, "set true if Lindon Objective Complete");
            objective_arnor = config.getBoolean("Arnor", Configuration.CATEGORY_GENERAL, false,"set true if Arnor Objective Complete");
            objective_angmar = config.getBoolean("Angmar", Configuration.CATEGORY_GENERAL, false, "set true if Angmar Objective Complete");
            objective_durin = config.getBoolean("Durin", Configuration.CATEGORY_GENERAL, false, "set true if Durin Objective Complete");
            objective_dolguldur = config.getBoolean("Dol_Guldur", Configuration.CATEGORY_GENERAL, false,"set true if Dol Guldur Objective Complete");
            objective_woodelf = config.getBoolean("Wood_Elf", Configuration.CATEGORY_GENERAL, false,  "set true if Wood Elf Objective Complete");
            objective_lothlorien = config.getBoolean("Lothlorien", Configuration.CATEGORY_GENERAL, false, "set true if Lothlorien Objective Complete");
            objective_dale = config.getBoolean("Dale", Configuration.CATEGORY_GENERAL, false, "set true if Dalish Objective Complete");
            objective_rhudaur = config.getBoolean("Rhudaur", Configuration.CATEGORY_GENERAL, false, "set true if Rhudaur Objective Complete");

            warbands_enabled = config.getBoolean("Warbands", Configuration.CATEGORY_GENERAL, true, "Set false to disable warbands");
            unit_conversion_enabled = config.getBoolean("Unit conversion", Configuration.CATEGORY_GENERAL, false, "Set false to disable unit stat updates when units are readied");
            // Save the configuration if it has changed
            if (config.hasChanged()) {
                config.save();
            }
        } catch (Exception e) {
        }
    }
}
