Exemplo n.º 1
0
        /// <summary>
        /// Process all of the data loaded into the database.
        /// </summary>
        public static void Process()
        {
            // Go through all of the items in the database and calculate the Filter ID
            // if the Filter ID is not already assigned. (manual assignment should always override this)
            foreach (var data in Items.AllItems)
            {
                Objects.AssignFilterID(data);
                Objects.AssignFactionID(data);
            }

            // Merge the Item Data into the Containers.
            foreach (var container in Objects.AllContainers.Values)
            {
                Process(container, 1, 1);
            }

            // Sort World Drops by Name
            var worldDrops = Objects.GetNull("WorldDrops");

            if (worldDrops != null)
            {
                SortByName(worldDrops);
            }

            // Build the Unsorted Container.
            List <object> listing;
            int           requireSkill;
            var           unsorted = new List <object>();

            Objects.AllContainers["Unsorted"] = unsorted;
            var tierLists = new Dictionary <int, TierList>();

            for (int tierID = 1; tierID <= 8; ++tierID)
            {
                unsorted.Add(new Dictionary <string, object>
                {
                    { "tierID", tierID },
                    { "g", (tierLists[tierID] = new TierList()).Groups },
                });
            }
            foreach (var item in Items.AllItemsWithoutReferences)
            {
                TierList tier;
                if (item.TryGetValue("lvl", out object lvlRef) && lvlRef is int level)
                {
                    if (level < 61)
                    {
                        tier = tierLists[1];             // Classic
                    }
                    else if (level < 71)
                    {
                        tier = tierLists[2];                    // Burning Crusade
                    }
                    else if (level < 81)
                    {
                        tier = tierLists[3];                    // Wrath of the Lich King
                    }
                    else if (level < 86)
                    {
                        tier = tierLists[4];                    // Cataclysm
                    }
                    else if (level < 91)
                    {
                        tier = tierLists[5];                    // Mists of Pandaria
                    }
                    else if (level < 101)
                    {
                        tier = tierLists[6];                     // Warlords of Draenor
                    }
                    else if (level < 111)
                    {
                        tier = tierLists[7];                     // Legion
                    }
                    else
                    {
                        tier = tierLists[8];    // Battle For Azeroth
                    }
                }
                else if (item.TryGetValue("itemID", out object itemIDRef))
                {
                    var itemID = Convert.ToInt32(itemIDRef);
                    if (itemID < 22727)
                    {
                        tier = tierLists[1];                 // Classic
                    }
                    else if (itemID < 29205)
                    {
                        tier = tierLists[2];                        // Burning Crusade
                    }
                    else if (itemID < 37649)
                    {
                        tier = tierLists[3];                        // Wrath of the Lich King
                    }
                    else if (itemID < 72019)
                    {
                        tier = tierLists[4];                        // Cataclysm
                    }
                    else if (itemID < 100855)
                    {
                        tier = tierLists[5];                         // Mists of Pandaria
                    }
                    else if (itemID < 130731)
                    {
                        tier = tierLists[6];                         // Warlords of Draenor
                    }
                    else if (itemID < 156823)
                    {
                        tier = tierLists[7];                         // Legion
                    }
                    else
                    {
                        tier = tierLists[8];    // Battle For Azeroth
                    }
                }
                else
                {
                    tier = tierLists[1];
                }

                if (item.TryGetValue("f", out object objRef))
                {
                    int filterID = Convert.ToInt32(objRef);
                    if (filterID >= 0 && (filterID < 56 || filterID > 90))
                    {
                        switch ((Objects.Filters)filterID)
                        {
                        /*
                         * case Objects.Filters.Invalid:
                         * case Objects.Filters.Ignored:
                         * case Objects.Filters.Toy:
                         * case Objects.Filters.Illusion:
                         * case Objects.Filters.Mount:
                         * case Objects.Filters.Quest:
                         * case Objects.Filters.Holiday:
                         */
                        case Objects.Filters.Recipe:
                        {
                            if (!tier.FilteredLists.TryGetValue(filterID, out listing))
                            {
                                tier.Groups.Add(new Dictionary <string, object>
                                    {
                                        { "f", filterID },
                                        { "g", listing = tier.FilteredLists[filterID] = new List <object>() }
                                    });
                            }
                            if (item.TryGetValue("requireSkill", out object requireSkillRef))
                            {
                                requireSkill = Convert.ToInt32(requireSkillRef);
                                if (!tier.ProfessionLists.TryGetValue(requireSkill, out List <object> sublisting))
                                {
                                    listing.Add(new Dictionary <string, object>
                                        {
                                            { "professionID", requireSkill },
                                            { "g", listing = tier.ProfessionLists[requireSkill] = new List <object>() }
                                        });
                                }
                                else
                                {
                                    listing = sublisting;
                                }
                            }
                            else
                            {
                                if (!tier.ProfessionLists.TryGetValue(-1, out List <object> sublisting))
                                {
                                    listing.Add(new Dictionary <string, object>
                                        {
                                            { "f", (int)Objects.Filters.Miscellaneous },
                                            { "g", listing = tier.ProfessionLists[-1] = new List <object>() }
                                        });
                                }
                                else
                                {
                                    listing = sublisting;
                                }
                            }

                            if (item.TryGetValue("itemID", out int itemID))
                            {
                                var newItem = new Dictionary <string, object>
                                {
                                    { "itemID", itemID },
                                };
                                Items.MergeInto(itemID, item, newItem);
                                listing.Add(newItem);
                            }
                            break;
                        }

                        default:
                        {
                            item.Remove("spellID");
                            if ((item.TryGetValue("q", out objRef) && Convert.ToInt32(objRef) >= 2) ||
                                (filterID == 101 || filterID == 102 || filterID == 100 || filterID == 108 || filterID == 10))
                            {
                                if (!tier.FilteredLists.TryGetValue(filterID, out listing))
                                {
                                    tier.Groups.Add(new Dictionary <string, object>
                                        {
                                            { "f", filterID },
                                            { "g", listing = tier.FilteredLists[filterID] = new List <object>() }
                                        });
                                }

                                if (item.TryGetValue("itemID", out int itemID))
                                {
                                    var newItem = new Dictionary <string, object>
                                    {
                                        { "itemID", itemID },
                                    };
                                    Items.MergeInto(itemID, item, newItem);
                                    listing.Add(newItem);
                                }
                            }
                            break;
                        }
                        }
                    }
                }
            }

            // Merge the Item Data into the Containers again.
            foreach (var container in Objects.AllContainers.Values)
            {
                Process(container, 1, 1);
            }
        }