Exemple #1
0
        public void FinalizeImport(Main main)
        {
            for (int i = 0; i < main.Achievements.Count; i++)
            {
                double      cur = i, max = main.Achievements.Count;
                Achievement achievement = main.Achievements[i];
                if (achievement.PrerequisiteID.Count > 0)
                {
                    for (int a = 0; a < achievement.PrerequisiteID.Count; a++)
                    {
                        int achiID = achievement.PrerequisiteID[a];
                        achievement.Prerequisites.Add(main.Achievements.FirstOrDefault(ac => ac.ID == achiID));
                    }
                }
                if (achievement.Rewards.Count > 0)
                {
                    for (int a = 0; a < achievement.Rewards.Count; a++)
                    {
                        if (achievement.Rewards[a].RewardType == Reward.Type.Item)
                        {
                            ItemReward reward = (ItemReward)achievement.Rewards[a];
                            int        itemID = reward.ItemID;
                            reward.RewardItem      = main.Items.FirstOrDefault(it => it.ID == itemID);
                            achievement.Rewards[a] = reward;
                        }
                        if (achievement.Rewards[a].RewardType == Reward.Type.Title)
                        {
                            TitleReward reward  = (TitleReward)achievement.Rewards[a];
                            int         titleID = reward.TitleID;
                            reward.RewardTitle     = main.Titles.FirstOrDefault(it => it.ID == titleID);
                            achievement.Rewards[a] = reward;
                        }
                    }
                }
                if (achievement.Bits.Count > 0)
                {
                    for (int a = 0; a < achievement.Bits.Count; a++)
                    {
                        if (achievement.Bits[a].BitType == Bit.Type.Item)
                        {
                            ItemBit bit    = (ItemBit)achievement.Bits[a];
                            int     itemID = bit.ItemID;
                            bit.BitItem         = main.Items.FirstOrDefault(it => it.ID == itemID);
                            achievement.Bits[a] = bit;
                        }
                        if (achievement.Bits[a].BitType == Bit.Type.Minipet)
                        {
                            MinipetBit bit    = (MinipetBit)achievement.Bits[a];
                            int        miniID = bit.MiniID;
                            bit.BitMini         = main.Minis.FirstOrDefault(mi => mi.ID == miniID);
                            achievement.Bits[a] = bit;
                        }
                        if (achievement.Bits[a].BitType == Bit.Type.Skin)
                        {
                            SkinBit bit    = (SkinBit)achievement.Bits[a];
                            int     skinID = bit.SkinID;
                            bit.BitSkin         = main.Skins.FirstOrDefault(sk => sk.ID == skinID);
                            achievement.Bits[a] = bit;
                        }
                    }
                }
                main.OnCharStatusUpdate("Finalizing Achievements;" + ((cur != 0) ? Math.Round((double)(cur / max), 2) * 100 : 0).ToString() + "%");
            }
            for (int i = 0; i < main.BackstoryAnswers.Count; i++)
            {
                double cur = i, max = main.BackstoryAnswers.Count;
                int    questionID = main.BackstoryAnswers[i].QuestionID;
                main.BackstoryAnswers[i].Question = main.BackstoryQuestions.FirstOrDefault(bs => bs.ID == questionID);
                main.OnCharStatusUpdate("Finalizing Backstory Answers;" + ((cur != 0) ? Math.Round((double)(cur / max), 2) * 100 : 0).ToString() + "%");
            }
            for (int i = 0; i < main.BackstoryQuestions.Count; i++)
            {
                double cur = i, max = main.BackstoryQuestions.Count;
                for (int a = 0; a < main.BackstoryQuestions[i].AnswerID.Count; a++)
                {
                    string answerID = main.BackstoryQuestions[i].AnswerID[a];
                    main.BackstoryQuestions[i].Answers.Add(main.BackstoryAnswers.FirstOrDefault(bs => bs.ID == answerID));
                }
                main.OnCharStatusUpdate("Finalizing Backstory Questions;" + ((cur != 0) ? Math.Round((double)(cur / max), 2) * 100 : 0).ToString() + "%");
            }
            for (int i = 0; i < main.GuildUpgrades.Count; i++)
            {
                double cur = i, max = main.GuildUpgrades.Count;
                if (main.GuildUpgrades[i].Costs.Count > 0)
                {
                    for (int a = 0; a < main.GuildUpgrades[i].Costs.Count; a++)
                    {
                        if (main.GuildUpgrades[i].Costs[a].ItemID.HasValue)
                        {
                            int itemID = main.GuildUpgrades[i].Costs[a].ItemID.Value;
                            main.GuildUpgrades[i].Costs[a].RequiredItem = main.Items.FirstOrDefault(it => it.ID == itemID);
                        }
                    }
                }
                if (main.GuildUpgrades[i].PrerequisiteID.Count > 0)
                {
                    for (int a = 0; a < main.GuildUpgrades[i].PrerequisiteID.Count; a++)
                    {
                        int uID = main.GuildUpgrades[i].PrerequisiteID[a];
                        main.GuildUpgrades[i].Prerequisites.Add(main.GuildUpgrades.FirstOrDefault(gu => gu.ID == uID));
                    }
                }
                main.OnCharStatusUpdate("Finalizing Guild Upgrades;" + ((cur != 0) ? Math.Round((double)(cur / max), 2) * 100 : 0).ToString() + "%");
            }
            for (int i = 0; i < main.Items.Count; i++)
            {
                double cur = i, max = main.Items.Count;
                if (main.Items[i].SkinID.HasValue)
                {
                    int skinID = main.Items[i].SkinID.Value;
                    main.Items[i].ItemSkin = main.Skins.FirstOrDefault(sk => sk.ID == skinID);
                }

                if (main.Items[i].ItemType == Item.Type.Armor)
                {
                    ArmorItemDetail detail = (ArmorItemDetail)main.Items[i].Details;
                    if (detail.InfixUpgrades != null)
                    {
                        if (detail.InfixUpgrades.Buff != null)
                        {
                            int skillID = detail.InfixUpgrades.Buff.SkillID.Value;
                            detail.InfixUpgrades.Buff.BuffSkill = main.Skills.FirstOrDefault(sk => sk.ID == skillID);
                        }
                    }
                    if (detail.Infusions.Count > 0)
                    {
                        for (int a = 0; a < detail.Infusions.Count; a++)
                        {
                            if (detail.Infusions[a].ItemID.HasValue)
                            {
                                int itemID = detail.Infusions[a].ItemID.Value;
                                detail.Infusions[a].ExistingItem = main.Items.FirstOrDefault(it => it.ID == itemID);
                            }
                        }
                    }
                    if (detail.ItemID.HasValue)
                    {
                        int itemID = detail.ItemID.Value;
                        detail.SuffixItem = main.Items.FirstOrDefault(it => it.ID == itemID);
                    }
                    main.Items[i].Details = detail;
                }
                if (main.Items[i].ItemType == Item.Type.Back)
                {
                    BackItemDetail detail = (BackItemDetail)main.Items[i].Details;
                    if (detail.InfixUpgrades != null)
                    {
                        if (detail.InfixUpgrades.Buff != null)
                        {
                            int skillID = detail.InfixUpgrades.Buff.SkillID.Value;
                            detail.InfixUpgrades.Buff.BuffSkill = main.Skills.FirstOrDefault(sk => sk.ID == skillID);
                        }
                    }
                    if (detail.Infusions.Count > 0)
                    {
                        for (int a = 0; a < detail.Infusions.Count; a++)
                        {
                            if (detail.Infusions[a].ItemID.HasValue)
                            {
                                int itemID = detail.Infusions[a].ItemID.Value;
                                detail.Infusions[a].ExistingItem = main.Items.FirstOrDefault(it => it.ID == itemID);
                            }
                        }
                    }
                    if (detail.ItemID.HasValue)
                    {
                        int itemID = detail.ItemID.Value;
                        detail.SuffixItem = main.Items.FirstOrDefault(it => it.ID == itemID);
                    }
                    main.Items[i].Details = detail;
                }
                if (main.Items[i].ItemType == Item.Type.Consumable)
                {
                    ConsumableItemDetail detail = (ConsumableItemDetail)main.Items[i].Details;
                    if (detail.RecipeID.HasValue)
                    {
                        int recipeID = detail.RecipeID.Value;
                        detail.ConsumableRecipe = main.Recipes.FirstOrDefault(re => re.ID == recipeID);
                    }
                    for (int a = 0; a < detail.SkinID.Count; a++)
                    {
                        int skinID = detail.SkinID[a];
                        detail.Skins.Add(main.Skins.FirstOrDefault(sk => sk.ID == skinID));
                    }
                    main.Items[i].Details = detail;
                }
                if (main.Items[i].ItemType == Item.Type.MiniPet)
                {
                    MiniItemDetail detail = (MiniItemDetail)main.Items[i].Details;
                    if (detail.MiniID.HasValue)
                    {
                        int miniID = detail.MiniID.Value;
                        detail.Mini = main.Minis.FirstOrDefault(mi => mi.ID == miniID);
                    }
                    main.Items[i].Details = detail;
                }
                if (main.Items[i].ItemType == Item.Type.Trinket)
                {
                    TrinketItemDetail detail = (TrinketItemDetail)main.Items[i].Details;
                    if (detail.InfixUpgrades != null)
                    {
                        if (detail.InfixUpgrades.Buff != null)
                        {
                            int skillID = detail.InfixUpgrades.Buff.SkillID.Value;
                            detail.InfixUpgrades.Buff.BuffSkill = main.Skills.FirstOrDefault(sk => sk.ID == skillID);
                        }
                    }
                    if (detail.Infusions.Count > 0)
                    {
                        for (int a = 0; a < detail.Infusions.Count; a++)
                        {
                            if (detail.Infusions[a].ItemID.HasValue)
                            {
                                int itemID = detail.Infusions[a].ItemID.Value;
                                detail.Infusions[a].ExistingItem = main.Items.FirstOrDefault(it => it.ID == itemID);
                            }
                        }
                    }
                    if (detail.ItemID.HasValue)
                    {
                        int itemID = detail.ItemID.Value;
                        detail.SuffixItem = main.Items.FirstOrDefault(it => it.ID == itemID);
                    }
                    main.Items[i].Details = detail;
                }
                if (main.Items[i].ItemType == Item.Type.UpgradeComponent)
                {
                    UpgradeItemDetail detail = (UpgradeItemDetail)main.Items[i].Details;
                    if (detail.InfixUpgrades != null)
                    {
                        if (detail.InfixUpgrades.Buff != null)
                        {
                            int skillID = detail.InfixUpgrades.Buff.SkillID.Value;
                            detail.InfixUpgrades.Buff.BuffSkill = main.Skills.FirstOrDefault(sk => sk.ID == skillID);
                        }
                    }
                    main.Items[i].Details = detail;
                }
                if (main.Items[i].ItemType == Item.Type.Weapon)
                {
                    WeaponItemDetail detail = (WeaponItemDetail)main.Items[i].Details;
                    if (detail.InfixUpgrades != null)
                    {
                        if (detail.InfixUpgrades.Buff != null)
                        {
                            int skillID = detail.InfixUpgrades.Buff.SkillID.Value;
                            detail.InfixUpgrades.Buff.BuffSkill = main.Skills.FirstOrDefault(sk => sk.ID == skillID);
                        }
                    }
                    if (detail.Infusions.Count > 0)
                    {
                        for (int a = 0; a < detail.Infusions.Count; a++)
                        {
                            if (detail.Infusions[a].ItemID.HasValue)
                            {
                                int itemID = detail.Infusions[a].ItemID.Value;
                                detail.Infusions[a].ExistingItem = main.Items.FirstOrDefault(it => it.ID == itemID);
                            }
                        }
                    }
                    if (detail.ItemID.HasValue)
                    {
                        int itemID = detail.ItemID.Value;
                        detail.SuffixItem = main.Items.FirstOrDefault(it => it.ID == itemID);
                    }
                    main.Items[i].Details = detail;
                }
                main.OnCharStatusUpdate("Finalizing Items;" + ((cur != 0) ? Math.Round((double)(cur / max), 2) * 100 : 0).ToString() + "%");
            }
            for (int i = 0; i < main.Minis.Count; i++)
            {
                double cur = i, max = main.Minis.Count;
                int    itemID = main.Minis[i].ItemID;
                main.Minis[i].UnlockItem = main.Items.FirstOrDefault(it => it.ID == itemID);
                main.OnCharStatusUpdate("Finalizing Minipets;" + ((cur != 0) ? Math.Round((double)(cur / max), 2) * 100 : 0).ToString() + "%");
            }
            for (int i = 0; i < main.Recipes.Count; i++)
            {
                double cur = i, max = main.Recipes.Count;
                if (main.Recipes[i].ItemID.HasValue)
                {
                    int itemID = main.Recipes[i].ItemID.Value;
                    main.Recipes[i].ResultItem = main.Items.FirstOrDefault(it => it.ID == itemID);
                }
                if (main.Recipes[i].UpgradeID.HasValue)
                {
                    int uID = main.Recipes[i].UpgradeID.Value;
                    main.Recipes[i].ResultUpgrade = main.GuildUpgrades.FirstOrDefault(gu => gu.ID == uID);
                }
                if (main.Recipes[i].Ingredients.Count > 0)
                {
                    for (int a = 0; a < main.Recipes[i].Ingredients.Count; a++)
                    {
                        int itemID = main.Recipes[i].Ingredients[a].ItemID;
                        main.Recipes[i].Ingredients[a].IngredientItem = main.Items.FirstOrDefault(it => it.ID == itemID);
                    }
                }
                if (main.Recipes[i].GuildIngredients.Count > 0)
                {
                    for (int a = 0; a < main.Recipes[i].GuildIngredients.Count; a++)
                    {
                        int uID = main.Recipes[i].GuildIngredients[a].UpgradeID;
                        main.Recipes[i].GuildIngredients[a].IngredientUpgrade = main.GuildUpgrades.FirstOrDefault(gu => gu.ID == uID);
                    }
                }
                main.OnCharStatusUpdate("Finalizing Recipes;" + ((cur != 0) ? Math.Round((double)(cur / max), 2) * 100 : 0).ToString() + "%");
            }
            for (int i = 0; i < main.Skills.Count; i++)
            {
                double cur = i, max = main.Skills.Count;
                for (int a = 0; a < main.Skills[i].TransformSkillID.Count; a++)
                {
                    int skillID = main.Skills[i].TransformSkillID[a];
                    main.Skills[i].TransformSkills.Add(main.Skills.FirstOrDefault(sk => sk.ID == skillID));
                }
                for (int a = 0; a < main.Skills[i].BundleSkillID.Count; a++)
                {
                    int skillID = main.Skills[i].BundleSkillID[a];
                    main.Skills[i].BundleSkills.Add(main.Skills.FirstOrDefault(sk => sk.ID == skillID));
                }
                if (main.Skills[i].ToolbeltSkillID.HasValue)
                {
                    int skillID = main.Skills[i].ToolbeltSkillID.Value;
                    main.Skills[i].ToolbeltSkill = main.Skills.FirstOrDefault(sk => sk.ID == skillID);
                }
                main.OnCharStatusUpdate("Finalizing Skills;" + ((cur != 0) ? Math.Round((double)(cur / max), 2) * 100 : 0).ToString() + "%");
            }
            for (int i = 0; i < main.Titles.Count; i++)
            {
                double cur = i, max = main.Titles.Count;
                for (int a = 0; a < main.Titles[i].AchievementID.Count; a++)
                {
                    int achieveID = main.Titles[i].AchievementID[a];
                    main.Titles[i].Achievements.Add(main.Achievements.FirstOrDefault(ac => ac.ID == achieveID));
                }
                main.OnCharStatusUpdate("Finalizing Titles;" + ((cur != 0) ? Math.Round((double)(cur / max), 2) * 100 : 0).ToString() + "%");
            }
        }
Exemple #2
0
        public static void GetItemsFromJSON(string json, Main main)
        {
            ItemRAW[] rawItems = new ItemRAW[1];
            try
            {
                rawItems = JsonConvert.DeserializeObject <ItemRAW[]>(json);
            }
            catch (Exception e)
            {
                rawItems[0] = JsonConvert.DeserializeObject <ItemRAW>(json);
            }
            for (int a = 0; a < rawItems.Length; a++)
            {
                double  cur = a, max = rawItems.Length;
                ItemRAW itemRAW = rawItems[a];
                main.JSON.Add(new KeyValuePair <string, string>("Item", JsonConvert.SerializeObject(itemRAW)));
                Item newItem = new Item
                {
                    ID           = itemRAW.id,
                    Name         = itemRAW.name,
                    Description  = itemRAW.description,
                    ItemType     = (Type)Enum.Parse(typeof(Type), itemRAW.type),
                    ItemRarity   = (Rarity)Enum.Parse(typeof(Rarity), itemRAW.rarity),
                    Level        = itemRAW.level,
                    VendorValue  = itemRAW.vendor_value,
                    Flags        = new List <Flag>(),
                    GameTypes    = new List <GameType>(),
                    Restrictions = new List <Restriction>()
                };

                string fileName = string.Empty;

                if (!string.IsNullOrEmpty(itemRAW.icon))
                {
                    fileName = string.Empty;
                    using (WebClient client = new WebClient())
                    {
                        fileName = itemRAW.icon.Substring(itemRAW.icon.LastIndexOf("/") + 1);
                        Directory.CreateDirectory(AppDomain.CurrentDomain.BaseDirectory + @"images\items\");
                        if (!File.Exists(AppDomain.CurrentDomain.BaseDirectory + @"images\items\" + fileName))
                        {
                            client.DownloadFileAsync(new Uri(itemRAW.icon), AppDomain.CurrentDomain.BaseDirectory + @"\images\items\" + fileName);
                        }
                    }
                    newItem.Image = AppDomain.CurrentDomain.BaseDirectory + @"images\items\" + fileName;
                }
                for (int i = 0; i < itemRAW.flags.Length; i++)
                {
                    newItem.Flags.Add((Flag)Enum.Parse(typeof(Flag), itemRAW.flags[i]));
                }
                for (int i = 0; i < itemRAW.game_types.Length; i++)
                {
                    newItem.GameTypes.Add((GameType)Enum.Parse(typeof(GameType), itemRAW.game_types[i]));
                }
                for (int i = 0; i < itemRAW.restrictions.Length; i++)
                {
                    newItem.Restrictions.Add((Restriction)Enum.Parse(typeof(Restriction), itemRAW.restrictions[i]));
                }
                if (itemRAW.default_skin.HasValue)
                {
                    newItem.SkinID = itemRAW.default_skin.Value;
                }

                if (newItem.ItemType == Type.Armor)
                {
                    ArmorItemDetail newItemDetail = new ArmorItemDetail
                    {
                        Type        = (ArmorItemDetail.ArmorType)Enum.Parse(typeof(ArmorItemDetail.ArmorType), itemRAW.details.type),
                        Weight      = (ArmorItemDetail.WeightClass)Enum.Parse(typeof(ArmorItemDetail.WeightClass), itemRAW.details.weight_class),
                        Defense     = itemRAW.details.defense.Value,
                        Infusions   = new List <Infusion>(),
                        StatChoices = new List <ItemStat>()
                    };

                    if (itemRAW.details.infix_upgrade != null)
                    {
                        InfixUpgrade newInfixUpgrade = new InfixUpgrade();

                        if (itemRAW.details.infix_upgrade.buff != null)
                        {
                            int      skillID = itemRAW.details.infix_upgrade.buff.skill_id;
                            ItemBuff newBuff = new ItemBuff
                            {
                                SkillID     = itemRAW.details.infix_upgrade.buff.skill_id,
                                Description = itemRAW.details.infix_upgrade.buff.description
                            };
                            newInfixUpgrade.Buff = newBuff;
                        }
                        if (itemRAW.details.infix_upgrade.attributes != null)
                        {
                            List <ItemAttribute> newAttributes = new List <ItemAttribute>();
                            for (int i = 0; i < itemRAW.details.infix_upgrade.attributes.Length; i++)
                            {
                                ItemAttribute newAttribute = new ItemAttribute
                                {
                                    Att      = (ItemAttribute.Attribute)Enum.Parse(typeof(ItemAttribute.Attribute), itemRAW.details.infix_upgrade.attributes[i].attribute),
                                    Modifier = itemRAW.details.infix_upgrade.attributes[i].modifier
                                };
                                newAttributes.Add(newAttribute);
                            }
                            newInfixUpgrade.Attributes = newAttributes;
                        }

                        newItemDetail.InfixUpgrades = newInfixUpgrade;
                    }

                    if (itemRAW.details.infusion_slots.Length > 0)
                    {
                        List <Infusion> newInfusions = new List <Infusion>();
                        for (int i = 0; i < itemRAW.details.infusion_slots.Length; i++)
                        {
                            Infusion newInfusion = new Infusion
                            {
                                Flags = new List <Infusion.Flag>()
                            };
                            for (int j = 0; j < itemRAW.details.infusion_slots[i].flags.Length; j++)
                            {
                                newInfusion.Flags.Add((Infusion.Flag)Enum.Parse(typeof(Infusion.Flag), itemRAW.details.infusion_slots[i].flags[j]));
                            }
                            if (itemRAW.details.infusion_slots[i].item_id.HasValue)
                            {
                                newInfusion.ItemID = itemRAW.details.infusion_slots[i].item_id.Value;
                            }

                            newInfusions.Add(newInfusion);
                        }
                        newItemDetail.Infusions = newInfusions;
                    }

                    if (itemRAW.details.suffix_item_id.HasValue)
                    {
                        newItemDetail.ItemID = itemRAW.details.suffix_item_id.Value;
                    }

                    if (itemRAW.details.stat_choices != null)
                    {
                        for (int i = 0; i < itemRAW.details.stat_choices.Length; i++)
                        {
                            int      statID  = int.Parse(itemRAW.details.stat_choices[i]);
                            ItemStat newStat = main.ItemStats.FirstOrDefault(st => st.ID == statID);
                            newItemDetail.StatChoices.Add(newStat);
                        }
                    }

                    newItem.Details = newItemDetail;
                }
                if (newItem.ItemType == Type.Back)
                {
                    BackItemDetail newItemDetail = new BackItemDetail
                    {
                        Infusions   = new List <Infusion>(),
                        StatChoices = new List <ItemStat>()
                    };

                    if (itemRAW.details.infix_upgrade != null)
                    {
                        InfixUpgrade newInfixUpgrade = new InfixUpgrade();

                        if (itemRAW.details.infix_upgrade.buff != null)
                        {
                            int      skillID = itemRAW.details.infix_upgrade.buff.skill_id;
                            ItemBuff newBuff = new ItemBuff
                            {
                                SkillID     = itemRAW.details.infix_upgrade.buff.skill_id,
                                Description = itemRAW.details.infix_upgrade.buff.description
                            };
                            newInfixUpgrade.Buff = newBuff;
                        }
                        if (itemRAW.details.infix_upgrade.attributes != null)
                        {
                            List <ItemAttribute> newAttributes = new List <ItemAttribute>();
                            for (int i = 0; i < itemRAW.details.infix_upgrade.attributes.Length; i++)
                            {
                                ItemAttribute newAttribute = new ItemAttribute
                                {
                                    Att      = (ItemAttribute.Attribute)Enum.Parse(typeof(ItemAttribute.Attribute), itemRAW.details.infix_upgrade.attributes[i].attribute),
                                    Modifier = itemRAW.details.infix_upgrade.attributes[i].modifier
                                };
                                newAttributes.Add(newAttribute);
                            }
                            newInfixUpgrade.Attributes = newAttributes;
                        }

                        newItemDetail.InfixUpgrades = newInfixUpgrade;
                    }

                    if (itemRAW.details.infusion_slots.Length > 0)
                    {
                        List <Infusion> newInfusions = new List <Infusion>();
                        for (int i = 0; i < itemRAW.details.infusion_slots.Length; i++)
                        {
                            Infusion newInfusion = new Infusion
                            {
                                Flags = new List <Infusion.Flag>()
                            };
                            for (int j = 0; j < itemRAW.details.infusion_slots[i].flags.Length; j++)
                            {
                                newInfusion.Flags.Add((Infusion.Flag)Enum.Parse(typeof(Infusion.Flag), itemRAW.details.infusion_slots[i].flags[j]));
                            }
                            if (itemRAW.details.infusion_slots[i].item_id.HasValue)
                            {
                                newInfusion.ItemID = itemRAW.details.infusion_slots[i].item_id.Value;
                            }

                            newInfusions.Add(newInfusion);
                        }
                        newItemDetail.Infusions = newInfusions;
                    }

                    if (itemRAW.details.suffix_item_id.HasValue)
                    {
                        newItemDetail.ItemID = itemRAW.details.suffix_item_id.Value;
                    }

                    if (itemRAW.details.stat_choices != null)
                    {
                        for (int i = 0; i < itemRAW.details.stat_choices.Length; i++)
                        {
                            int      statID  = int.Parse(itemRAW.details.stat_choices[i]);
                            ItemStat newStat = main.ItemStats.FirstOrDefault(st => st.ID == statID);
                            newItemDetail.StatChoices.Add(newStat);
                        }
                    }

                    newItem.Details = newItemDetail;
                }
                if (newItem.ItemType == Type.Bag)
                {
                    BagItemDetail newItemDetail = new BagItemDetail
                    {
                        Size       = itemRAW.details.size.Value,
                        NoSellSort = itemRAW.details.no_sell_or_sort.Value
                    };
                    newItem.Details = newItemDetail;
                }
                if (newItem.ItemType == Type.Consumable)
                {
                    ConsumableItemDetail newItemDetail = new ConsumableItemDetail
                    {
                        ConsType               = (ConsumableItemDetail.ConsumableType)Enum.Parse(typeof(ConsumableItemDetail.ConsumableType), itemRAW.details.type),
                        Description            = itemRAW.details.description,
                        DurationInMilliseconds = (itemRAW.details.duration_ms.HasValue) ? itemRAW.details.duration_ms.Value : 0,
                        StackCount             = (itemRAW.details.apply_count.HasValue) ? itemRAW.details.apply_count.Value : 0,
                        Name   = itemRAW.details.name,
                        Skins  = new List <Skin>(),
                        SkinID = new List <int>()
                    };
                    if (itemRAW.details.unlock_type != null)
                    {
                        newItemDetail.UnType = (ConsumableItemDetail.UnlockType)Enum.Parse(typeof(ConsumableItemDetail.UnlockType), itemRAW.details.unlock_type);
                    }

                    if (itemRAW.details.color_id.HasValue)
                    {
                        int    colourID  = itemRAW.details.color_id.Value;
                        Colour newColour = main.Colours.FirstOrDefault(co => co.ID == colourID);
                        newItemDetail.ConsumableColour = newColour;
                    }
                    if (itemRAW.details.recipe_id.HasValue)
                    {
                        newItemDetail.RecipeID = itemRAW.details.recipe_id.Value;
                    }
                    if (itemRAW.details.skins != null)
                    {
                        for (int i = 0; i < itemRAW.details.skins.Length; i++)
                        {
                            newItemDetail.SkinID.Add(itemRAW.details.skins[i].Value);
                        }
                    }
                    newItem.Details = newItemDetail;
                }
                if (newItem.ItemType == Type.Container)
                {
                    ContainerItemDetail newItemDetail = new ContainerItemDetail
                    {
                        ContType = (ContainerItemDetail.ContainerType)Enum.Parse(typeof(ContainerItemDetail.ContainerType), itemRAW.details.type)
                    };
                    newItem.Details = newItemDetail;
                }
                if (newItem.ItemType == Type.Gathering)
                {
                    GatheringToolItemDetail newItemDetail = new GatheringToolItemDetail
                    {
                        GatType = (GatheringToolItemDetail.GatheringToolType)Enum.Parse(typeof(GatheringToolItemDetail.GatheringToolType), itemRAW.details.type)
                    };
                    newItem.Details = newItemDetail;
                }
                if (newItem.ItemType == Type.Gizmo)
                {
                    GizmoItemDetail newItemDetail = new GizmoItemDetail
                    {
                        GizType = (GizmoItemDetail.GizmoType)Enum.Parse(typeof(GizmoItemDetail.GizmoType), itemRAW.details.type)
                    };
                    newItem.Details = newItemDetail;
                }
                if (newItem.ItemType == Type.MiniPet)
                {
                    MiniItemDetail newItemDetail = new MiniItemDetail
                    {
                        MiniID = itemRAW.details.minipet_id.Value
                    };

                    newItem.Details = newItemDetail;
                }
                if (newItem.ItemType == Type.Tool)
                {
                    SalvageKitItemDetail newItemDetail = new SalvageKitItemDetail
                    {
                        SalType = SalvageKitItemDetail.SalvageType.Salvage,
                        Charges = itemRAW.details.charges.Value
                    };
                }
                if (newItem.ItemType == Type.Trinket)
                {
                    TrinketItemDetail newItemDetail = new TrinketItemDetail
                    {
                        TrinkType   = (TrinketItemDetail.TrinketType)Enum.Parse(typeof(TrinketItemDetail.TrinketType), itemRAW.details.type),
                        Infusions   = new List <Infusion>(),
                        StatChoices = new List <ItemStat>()
                    };

                    if (itemRAW.details.infix_upgrade != null)
                    {
                        InfixUpgrade newInfixUpgrade = new InfixUpgrade();

                        if (itemRAW.details.infix_upgrade.buff != null)
                        {
                            int      skillID = itemRAW.details.infix_upgrade.buff.skill_id;
                            ItemBuff newBuff = new ItemBuff
                            {
                                SkillID     = itemRAW.details.infix_upgrade.buff.skill_id,
                                Description = itemRAW.details.infix_upgrade.buff.description
                            };
                            newInfixUpgrade.Buff = newBuff;
                        }
                        if (itemRAW.details.infix_upgrade.attributes != null)
                        {
                            List <ItemAttribute> newAttributes = new List <ItemAttribute>();
                            for (int i = 0; i < itemRAW.details.infix_upgrade.attributes.Length; i++)
                            {
                                ItemAttribute newAttribute = new ItemAttribute
                                {
                                    Att      = (ItemAttribute.Attribute)Enum.Parse(typeof(ItemAttribute.Attribute), itemRAW.details.infix_upgrade.attributes[i].attribute),
                                    Modifier = itemRAW.details.infix_upgrade.attributes[i].modifier
                                };
                                newAttributes.Add(newAttribute);
                            }
                            newInfixUpgrade.Attributes = newAttributes;
                        }

                        newItemDetail.InfixUpgrades = newInfixUpgrade;
                    }

                    if (itemRAW.details.infusion_slots.Length > 0)
                    {
                        List <Infusion> newInfusions = new List <Infusion>();
                        for (int i = 0; i < itemRAW.details.infusion_slots.Length; i++)
                        {
                            Infusion newInfusion = new Infusion
                            {
                                Flags = new List <Infusion.Flag>()
                            };
                            for (int j = 0; j < itemRAW.details.infusion_slots[i].flags.Length; j++)
                            {
                                newInfusion.Flags.Add((Infusion.Flag)Enum.Parse(typeof(Infusion.Flag), itemRAW.details.infusion_slots[i].flags[j]));
                            }
                            if (itemRAW.details.infusion_slots[i].item_id.HasValue)
                            {
                                newInfusion.ItemID = itemRAW.details.infusion_slots[i].item_id.Value;
                            }

                            newInfusions.Add(newInfusion);
                        }
                        newItemDetail.Infusions = newInfusions;
                    }

                    if (itemRAW.details.suffix_item_id.HasValue)
                    {
                        newItemDetail.ItemID = itemRAW.details.suffix_item_id.Value;
                    }

                    if (itemRAW.details.stat_choices != null)
                    {
                        for (int i = 0; i < itemRAW.details.stat_choices.Length; i++)
                        {
                            int      statID  = int.Parse(itemRAW.details.stat_choices[i]);
                            ItemStat newStat = main.ItemStats.FirstOrDefault(st => st.ID == statID);
                            newItemDetail.StatChoices.Add(newStat);
                        }
                    }

                    newItem.Details = newItemDetail;
                }
                if (newItem.ItemType == Type.UpgradeComponent)
                {
                    UpgradeItemDetail newItemDetail = new UpgradeItemDetail
                    {
                        UpType    = (UpgradeItemDetail.UpgradeType)Enum.Parse(typeof(UpgradeItemDetail.UpgradeType), itemRAW.details.type),
                        Flags     = new List <UpgradeItemDetail.Flag>(),
                        Infusions = new List <UpgradeItemDetail.InfusionFlag>(),
                        Suffix    = itemRAW.details.suffix
                    };
                    if (itemRAW.details.bonuses != null)
                    {
                        newItemDetail.Bonuses = itemRAW.details.bonuses.ToList();
                    }
                    if (itemRAW.details.infusion_upgrade_flags != null)
                    {
                        for (int i = 0; i < itemRAW.details.infusion_upgrade_flags.Length; i++)
                        {
                            newItemDetail.Infusions.Add((UpgradeItemDetail.InfusionFlag)Enum.Parse(typeof(UpgradeItemDetail.InfusionFlag), itemRAW.details.infusion_upgrade_flags[i]));
                        }
                    }
                    if (itemRAW.details.infix_upgrade != null)
                    {
                        InfixUpgrade newInfixUpgrade = new InfixUpgrade();

                        if (itemRAW.details.infix_upgrade.buff != null)
                        {
                            int      skillID = itemRAW.details.infix_upgrade.buff.skill_id;
                            ItemBuff newBuff = new ItemBuff
                            {
                                SkillID     = itemRAW.details.infix_upgrade.buff.skill_id,
                                Description = itemRAW.details.infix_upgrade.buff.description
                            };
                            newInfixUpgrade.Buff = newBuff;
                        }
                        if (itemRAW.details.infix_upgrade.attributes != null)
                        {
                            List <ItemAttribute> newAttributes = new List <ItemAttribute>();
                            for (int i = 0; i < itemRAW.details.infix_upgrade.attributes.Length; i++)
                            {
                                ItemAttribute newAttribute = new ItemAttribute
                                {
                                    Att      = (ItemAttribute.Attribute)Enum.Parse(typeof(ItemAttribute.Attribute), itemRAW.details.infix_upgrade.attributes[i].attribute),
                                    Modifier = itemRAW.details.infix_upgrade.attributes[i].modifier
                                };
                                newAttributes.Add(newAttribute);
                            }
                            newInfixUpgrade.Attributes = newAttributes;
                        }

                        newItemDetail.InfixUpgrades = newInfixUpgrade;
                    }
                    if (itemRAW.details.flags != null)
                    {
                        for (int i = 0; i < itemRAW.details.flags.Length; i++)
                        {
                            newItemDetail.Flags.Add((UpgradeItemDetail.Flag)Enum.Parse(typeof(UpgradeItemDetail.Flag), itemRAW.details.flags[i]));
                        }
                    }

                    newItem.Details = newItemDetail;
                }
                if (newItem.ItemType == Type.Weapon)
                {
                    WeaponItemDetail newItemDetail = new WeaponItemDetail
                    {
                        WeapType    = (WeaponItemDetail.WeaponType)Enum.Parse(typeof(WeaponItemDetail.WeaponType), itemRAW.details.type),
                        DamType     = (WeaponItemDetail.DamageType)Enum.Parse(typeof(WeaponItemDetail.DamageType), itemRAW.details.damage_type),
                        MIN         = itemRAW.details.min_power.Value,
                        MAX         = itemRAW.details.max_power.Value,
                        Defense     = itemRAW.details.defense.Value,
                        Infusions   = new List <Infusion>(),
                        StatChoices = new List <ItemStat>()
                    };

                    if (itemRAW.details.infix_upgrade != null)
                    {
                        InfixUpgrade newInfixUpgrade = new InfixUpgrade();

                        if (itemRAW.details.infix_upgrade.buff != null)
                        {
                            int      skillID = itemRAW.details.infix_upgrade.buff.skill_id;
                            ItemBuff newBuff = new ItemBuff
                            {
                                SkillID     = itemRAW.details.infix_upgrade.buff.skill_id,
                                Description = itemRAW.details.infix_upgrade.buff.description
                            };
                            newInfixUpgrade.Buff = newBuff;
                        }
                        if (itemRAW.details.infix_upgrade.attributes != null)
                        {
                            List <ItemAttribute> newAttributes = new List <ItemAttribute>();
                            for (int i = 0; i < itemRAW.details.infix_upgrade.attributes.Length; i++)
                            {
                                ItemAttribute newAttribute = new ItemAttribute
                                {
                                    Att      = (ItemAttribute.Attribute)Enum.Parse(typeof(ItemAttribute.Attribute), itemRAW.details.infix_upgrade.attributes[i].attribute),
                                    Modifier = itemRAW.details.infix_upgrade.attributes[i].modifier
                                };
                                newAttributes.Add(newAttribute);
                            }
                            newInfixUpgrade.Attributes = newAttributes;
                        }

                        newItemDetail.InfixUpgrades = newInfixUpgrade;
                    }

                    if (itemRAW.details.infusion_slots.Length > 0)
                    {
                        List <Infusion> newInfusions = new List <Infusion>();
                        for (int i = 0; i < itemRAW.details.infusion_slots.Length; i++)
                        {
                            Infusion newInfusion = new Infusion
                            {
                                Flags = new List <Infusion.Flag>()
                            };
                            for (int j = 0; j < itemRAW.details.infusion_slots[i].flags.Length; j++)
                            {
                                newInfusion.Flags.Add((Infusion.Flag)Enum.Parse(typeof(Infusion.Flag), itemRAW.details.infusion_slots[i].flags[j]));
                            }
                            if (itemRAW.details.infusion_slots[i].item_id.HasValue)
                            {
                                newInfusion.ItemID = itemRAW.details.infusion_slots[i].item_id.Value;
                            }

                            newInfusions.Add(newInfusion);
                        }
                        newItemDetail.Infusions = newInfusions;
                    }

                    if (itemRAW.details.suffix_item_id.HasValue)
                    {
                        newItemDetail.ItemID = itemRAW.details.suffix_item_id.Value;
                    }

                    if (itemRAW.details.stat_choices != null)
                    {
                        for (int i = 0; i < itemRAW.details.stat_choices.Length; i++)
                        {
                            int      statID  = int.Parse(itemRAW.details.stat_choices[i]);
                            ItemStat newStat = main.ItemStats.FirstOrDefault(st => st.ID == statID);
                            newItemDetail.StatChoices.Add(newStat);
                        }
                    }

                    newItem.Details = newItemDetail;
                }

                main.Items.Add(newItem);
                main.OnCharStatusUpdate("Generated Item " + newItem.Name + ";" + newItem.ID + " " + ((cur != 0) ? Math.Round((double)(cur / max), 2) * 100 : 0).ToString() + "%");
            }
        }