using GadgetCore.API;
using GadgetCore.API.ConfigMenu;
using GadgetCore.Util;
using RecipeMenuCore.API;
using System.Collections.Generic;

namespace UltimateRings
{

  [Gadget("UltimateRings", LoadAfter: new string[] { "RecipeMenuCore" }, Dependencies: new string[] { "RecipeMenuCore" })]
  public class UltimateRings : Gadget<UltimateRings>
  {
    public const string MOD_VERSION = "1.1"; // Set this to the version of your mod.
    public const string CONFIG_VERSION = "1.0"; // Increment this whenever you change your mod's config file.

    protected override void LoadConfig()
    {
      Config.Reset();
      Config.Save();
    }

    public override IGadgetConfigMenu GetConfigMenu() { return null; }

    public override string GetModDescription()
    {
      return "A mod that adds ultimate version of rings.";
    }

    protected override void Initialize()
    {
      Logger.Log("Ultimate Rings v" + Info.Mod.Version);
      Core.logger = Logger;
      List<ItemInfo> infoList = new List<ItemInfo>();

      infoList.Add(new ItemInfo(ItemType.RING, "Gear Ring", "", GadgetCoreAPI.LoadTexture2D("i900U1.png"), Stats: new EquipStats(1, 2, 1, 3, 0, 0)).Register("ring900U1"));
      infoList.Add(new ItemInfo(ItemType.RING, "Fit Ring", "", GadgetCoreAPI.LoadTexture2D("i900U2.png"), Stats: new EquipStats(1, 2, 4, 0, 0, 0)).Register("ring900U2"));
      infoList.Add(new ItemInfo(ItemType.RING, "Heart Ring", "", GadgetCoreAPI.LoadTexture2D("i900U3.png"), Stats: new EquipStats(4, 2, 1, 0, 0, 0)).Register("ring900U3"));

      infoList.Add(new ItemInfo(ItemType.RING, "Dragon Egg Ring", "", GadgetCoreAPI.LoadTexture2D("i901U1.png"), Stats: new EquipStats(2, 2, 0, 0, 3, 2)).Register("ring901U1"));
      infoList.Add(new ItemInfo(ItemType.RING, "Shattered Ring", "", GadgetCoreAPI.LoadTexture2D("i901U2.png"), Stats: new EquipStats(0, 0, 0, 2, 5, 0)).Register("ring901U2"));
      infoList.Add(new ItemInfo(ItemType.RING, "Space Ring", "", GadgetCoreAPI.LoadTexture2D("i901U3.png"), Stats: new EquipStats(1, 0, 0, 4, 2, 1)).Register("ring901U3"));

      infoList.Add(new ItemInfo(ItemType.RING, "Shine Ring", "", GadgetCoreAPI.LoadTexture2D("i902U1.png"), Stats: new EquipStats(1, 0, 0, 0, 2, 4)).Register("ring902U1"));
      infoList.Add(new ItemInfo(ItemType.RING, "Obsidian Ring", "", GadgetCoreAPI.LoadTexture2D("i902U2.png"), Stats: new EquipStats(2, 0, 0, 1, 2, 3)).Register("ring902U2"));
      infoList.Add(new ItemInfo(ItemType.RING, "Wing Ring", "", GadgetCoreAPI.LoadTexture2D("i902U3.png"), Stats: new EquipStats(0, 0, 2, 0, 1, 4)).Register("ring902U3"));

      infoList.Add(new ItemInfo(ItemType.RING, "Lucky 4 Ring", "", GadgetCoreAPI.LoadTexture2D("i903U1.png"), Stats: new EquipStats(0, 1, 4, 2, 0, 0)).Register("ring903U1"));
      infoList.Add(new ItemInfo(ItemType.RING, "Bomb Ring", "", GadgetCoreAPI.LoadTexture2D("i903U2.png"), Stats: new EquipStats(0, 2, 2, 4, 0, 0)).Register("ring903U2"));
      infoList.Add(new ItemInfo(ItemType.RING, "Banana Ring", "", GadgetCoreAPI.LoadTexture2D("i903U3.png"), Stats: new EquipStats(0, 1, 1, 1, 4, 1)).Register("ring903U3"));

      infoList.Add(new ItemInfo(ItemType.RING, "Gem Ring", "", GadgetCoreAPI.LoadTexture2D("i904U1.png"), Stats: new EquipStats(2, 2, 2, 2, 2, 2)).Register("ring904U1"));
      infoList.Add(new ItemInfo(ItemType.RING, "Void Ring", "", GadgetCoreAPI.LoadTexture2D("i904U2.png"), Stats: new EquipStats(2, 0, 4, 1, 0, 0)).Register("ring904U2"));
      infoList.Add(new ItemInfo(ItemType.RING, "Resonance Ring", "", GadgetCoreAPI.LoadTexture2D("i904U3.png"), Stats: new EquipStats(2, 0, 2, 4, 0, 0)).Register("ring904U3"));

      infoList.Add(new ItemInfo(ItemType.RING, "Forrest Ring", "", GadgetCoreAPI.LoadTexture2D("i905U1.png"), Stats: new EquipStats(2, 5, 2, 0, 0, 0)).Register("ring905U1"));
      infoList.Add(new ItemInfo(ItemType.RING, "Emptiness Ring", "", GadgetCoreAPI.LoadTexture2D("i905U2.png"), Stats: new EquipStats(0, 8, 2, 0, 0, 0)).Register("ring905U2"));
      infoList.Add(new ItemInfo(ItemType.RING, "Fresh Ring", "", GadgetCoreAPI.LoadTexture2D("i905U3.png"), Stats: new EquipStats(0, 4, 2, 0, 2, 1)).Register("ring905U3"));

      Core.infoList = infoList;

      GadgetCoreAPI.AddUltimateForgeRecipe(new Tuple<int, int>(900, 89), Core.infoList[0].GetID());
      GadgetCoreAPI.AddUltimateForgeRecipe(new Tuple<int, int>(900, 90), Core.infoList[1].GetID());
      GadgetCoreAPI.AddUltimateForgeRecipe(new Tuple<int, int>(900, 91), Core.infoList[2].GetID());

      GadgetCoreAPI.AddUltimateForgeRecipe(new Tuple<int, int>(901, 89), Core.infoList[3].GetID());
      GadgetCoreAPI.AddUltimateForgeRecipe(new Tuple<int, int>(901, 90), Core.infoList[4].GetID());
      GadgetCoreAPI.AddUltimateForgeRecipe(new Tuple<int, int>(901, 91), Core.infoList[5].GetID());

      GadgetCoreAPI.AddUltimateForgeRecipe(new Tuple<int, int>(902, 89), Core.infoList[6].GetID());
      GadgetCoreAPI.AddUltimateForgeRecipe(new Tuple<int, int>(902, 90), Core.infoList[7].GetID());
      GadgetCoreAPI.AddUltimateForgeRecipe(new Tuple<int, int>(902, 91), Core.infoList[8].GetID());

      GadgetCoreAPI.AddUltimateForgeRecipe(new Tuple<int, int>(903, 89), Core.infoList[9].GetID());
      GadgetCoreAPI.AddUltimateForgeRecipe(new Tuple<int, int>(903, 90), Core.infoList[10].GetID());
      GadgetCoreAPI.AddUltimateForgeRecipe(new Tuple<int, int>(903, 91), Core.infoList[11].GetID());

      GadgetCoreAPI.AddUltimateForgeRecipe(new Tuple<int, int>(904, 89), Core.infoList[12].GetID());
      GadgetCoreAPI.AddUltimateForgeRecipe(new Tuple<int, int>(904, 90), Core.infoList[13].GetID());
      GadgetCoreAPI.AddUltimateForgeRecipe(new Tuple<int, int>(904, 91), Core.infoList[14].GetID());

      GadgetCoreAPI.AddUltimateForgeRecipe(new Tuple<int, int>(905, 89), Core.infoList[15].GetID());
      GadgetCoreAPI.AddUltimateForgeRecipe(new Tuple<int, int>(905, 90), Core.infoList[16].GetID());
      GadgetCoreAPI.AddUltimateForgeRecipe(new Tuple<int, int>(905, 91), Core.infoList[17].GetID());

      RegisterRecipe();
    }

    private void RegisterRecipe()
    {
      var recipePage = new RecipePage(RecipePageType.UltimateForge, "Ultimate Rings", GadgetCoreAPI.LoadTexture2D("recipesRings.png")).Register();
      recipePage.AddRecipePageEntry(new RecipePageEntry(Core.infoList[0].GetID(), Core.infoList[1].GetID(), Core.infoList[2].GetID(), 900));
      recipePage.AddRecipePageEntry(new RecipePageEntry(Core.infoList[3].GetID(), Core.infoList[4].GetID(), Core.infoList[5].GetID(), 901));
      recipePage.AddRecipePageEntry(new RecipePageEntry(Core.infoList[6].GetID(), Core.infoList[7].GetID(), Core.infoList[8].GetID(), 902));
      recipePage.AddRecipePageEntry(new RecipePageEntry(Core.infoList[9].GetID(), Core.infoList[10].GetID(), Core.infoList[11].GetID(), 903));
      recipePage.AddRecipePageEntry(new RecipePageEntry(Core.infoList[12].GetID(), Core.infoList[13].GetID(), Core.infoList[14].GetID(), 904));
      recipePage.AddRecipePageEntry(new RecipePageEntry(Core.infoList[15].GetID(), Core.infoList[16].GetID(), Core.infoList[17].GetID(), 905));
    }
  }
}
