예제 #1
0
        /// <summary>
        /// Generate the items datafile.
        /// </summary>
        private static void GenerateItems()
        {
            Console.WriteLine();
            Console.Write(@"Generated items datafile... ");

            s_counter = 0;
            s_percentOld = 0;
            s_text = String.Empty;
            s_startTime = DateTime.Now;

            // Create custom market groups that don't exist in EVE
            s_injectedMarketGroups = new List<InvMarketGroup>
                                         {
                                             new InvMarketGroup
                                                 {
                                                     Name = "Various Non-Market",
                                                     Description = "Non-Market Items",
                                                     ID = DBConstants.RootNonMarketGroupID,
                                                     ParentID = null,
                                                     IconID = null
                                                 },
                                             new InvMarketGroup
                                                 {
                                                     Name = "Unique Designs",
                                                     Description = "Ships of a unique design",
                                                     ID = DBConstants.RootUniqueDesignsGroupID,
                                                     ParentID = DBConstants.ShipsGroupID,
                                                     IconID = 1443
                                                 },
                                             new InvMarketGroup
                                                 {
                                                     Name = "Unique Shuttles",
                                                     Description = "Fast ships of a unique design",
                                                     ID = DBConstants.UniqueDesignShuttlesGroupID,
                                                     ParentID = DBConstants.RootUniqueDesignsGroupID,
                                                     IconID = null
                                                 },
                                             new InvMarketGroup
                                                 {
                                                     Name = "Unique Battleships",
                                                     Description = "Battleships ships of a unique design",
                                                     ID = DBConstants.UniqueDesignBattleshipsGroupID,
                                                     ParentID = DBConstants.RootUniqueDesignsGroupID,
                                                     IconID = null
                                                 },
                                         };

            // Manually set some items attributes
            s_types[11].Published = true;
            s_types[12].Published = true;
            s_types[13].Published = true;
            s_types[2014].Published = true;
            s_types[2015].Published = true;
            s_types[2016].Published = true;
            s_types[2017].Published = true;
            s_types[2063].Published = true;
            s_types[30889].Published = true;
            s_types[27029].Published = true;
            s_types[32077].Published = true;

            // Set some attributes to items because their MarketGroupID is NULL
            foreach (InvType srcItem in s_types.Where(x => x.Published && x.MarketGroupID == null))
            {
                // Set some ships market group and race
                switch (srcItem.ID)
                {
                    case 13202: // Megathron Federate Issue
                    case 26840: // Raven State Issue
                    case 26842: // Tempest Tribal Issue
                        srcItem.MarketGroupID = DBConstants.UniqueDesignBattleshipsGroupID;
                        srcItem.RaceID = (int)Race.Faction;
                        break;
                    case 21097: // Goru's Shuttle
                    case 21628: // Guristas Shuttle
                    case 30842: // Interbus Shuttle
                        srcItem.MarketGroupID = DBConstants.UniqueDesignShuttlesGroupID;
                        srcItem.RaceID = (int)Race.Faction;
                        break;

                        // Set some items market group to support blueprints
                    case 21815:
                    case 23882:
                    case 24289:
                    case 27029:
                    case 27038:
                    case 29203:
                    case 29226:
                    case 10260:
                    case 19758:
                    case 10257:
                    case 10258:
                    case 32077:
                    case 30424:
                    case 30839:
                    case 30422:
                    case 30342:
                    case 30420:
                    case 30328:
                    case 21054:
                    case 17761:
                    case 23883:
                    case 29202:
                    case 21510:
                    case 22335:
                    case 22333:
                    case 22337:
                    case 22339:
                    case 22923:
                    case 22329:
                    case 22327:
                    case 22325:
                    case 22331:
                        srcItem.MarketGroupID = DBConstants.RootNonMarketGroupID;
                        break;
                }

                // Set some items market group to support blueprints
                if (srcItem.ID > 28685 && srcItem.ID < 28694)
                    srcItem.MarketGroupID = DBConstants.RootNonMarketGroupID;

                // Adding planets to support attribute browsing for command centers
                if (srcItem.GroupID == DBConstants.PlanetGroupID)
                    srcItem.MarketGroupID = DBConstants.RootNonMarketGroupID;
            }

            var groups = new Dictionary<int, SerializableMarketGroup>();

            // Create the market groups
            foreach (InvMarketGroup srcGroup in s_marketGroups.Concat(s_injectedMarketGroups))
            {
                var group = new SerializableMarketGroup {ID = srcGroup.ID, Name = srcGroup.Name};
                groups[srcGroup.ID] = group;

                // Add the items in this group
                var items = new List<SerializableItem>();
                foreach (InvType srcItem in s_types
                    .Where(x => x.Published && (x.MarketGroupID.GetValueOrDefault() == srcGroup.ID)))
                {
                    CreateItem(srcItem, items);
                }

                // If this is an implant group, we add the implants with no market groups in this one.
                if (srcGroup.ParentID == DBConstants.SkillHardwiringImplantGroupID || srcGroup.ParentID == DBConstants.AttributeEnhancersImplantsGroupID)
                {
                    string slotString = srcGroup.Name.Substring("Implant Slot ".Length);
                    int slot = Int32.Parse(slotString);

                    // Enumerate all implants without market groups
                    foreach (InvType srcItem in s_types
                        .Where(x => x.MarketGroupID == null
                        && s_groups[x.GroupID].CategoryID == DBConstants.ImplantCategoryID
                        && x.GroupID != DBConstants.CyberLearningImplantsGroupID)
                        )
                    {
                        // Check the slot matches
                        DgmTypeAttribute slotAttrib = s_typeAttributes.Get(srcItem.ID, DBConstants.ImplantSlotPropertyID);
                        if (slotAttrib != null && slotAttrib.GetIntValue() == slot)
                            CreateItem(srcItem, items);
                    }
                }

                // Store the items
                group.Items = items.OrderBy(x => x.Name).ToArray();
            }

            // Create the parent-children groups relations
            foreach (SerializableMarketGroup group in groups.Values)
            {
                IEnumerable<SerializableMarketGroup> children =
                    s_marketGroups.Concat(s_injectedMarketGroups).Where(x => x.ParentID.GetValueOrDefault() == group.ID)
                        .Select(x => groups[x.ID]);
                group.SubGroups = children.OrderBy(x => x.Name).ToArray();
            }

            // Pick the family
            SetItemFamilyByMarketGroup(groups[DBConstants.BlueprintsGroupID], ItemFamily.Bpo);
            SetItemFamilyByMarketGroup(groups[DBConstants.ShipsGroupID], ItemFamily.Ship);
            SetItemFamilyByMarketGroup(groups[DBConstants.ImplantsGroupID], ItemFamily.Implant);
            SetItemFamilyByMarketGroup(groups[DBConstants.DronesGroupID], ItemFamily.Drone);
            SetItemFamilyByMarketGroup(groups[DBConstants.StarbaseStructuresGroupID], ItemFamily.StarbaseStructure);

            // Sort groups
            IOrderedEnumerable<SerializableMarketGroup> rootGroups =
                s_marketGroups.Concat(s_injectedMarketGroups).Where(x => !x.ParentID.HasValue).Select(x => groups[x.ID])
                    .OrderBy(x => x.Name);

            s_endTime = DateTime.Now;
            Console.WriteLine(String.Format(" in {0}", s_endTime.Subtract(s_startTime)).TrimEnd('0'));

            // Serialize
            var datafile = new ItemsDatafile();
            datafile.MarketGroups = rootGroups.ToArray();
            Util.SerializeXML(datafile, DatafileConstants.ItemsDatafile);
        }
예제 #2
0
파일: Items.cs 프로젝트: RapidFiring/evemon
        /// <summary>
        /// Generate the items datafile.
        /// </summary>
        internal static void GenerateDatafile()
        {
            Stopwatch stopwatch = Stopwatch.StartNew();
            Util.ResetCounters();

            Console.WriteLine();
            Console.Write(@"Generating items datafile... ");

            // Move non existing makret group to custom market group
            ConfigureNonExistingMarketGroupItems();

            // Create custom market groups that don't exist in EVE
            ConfigureNullMarketItems();

            Dictionary<int, SerializableMarketGroup> groups = new Dictionary<int, SerializableMarketGroup>();

            // Create the market groups
            CreateMarketGroups(groups);

            // Create the parent-children groups relations
            foreach (SerializableMarketGroup group in groups.Values)
            {
                IEnumerable<SerializableMarketGroup> children = Database.InvMarketGroupsTable.Concat(
                    s_injectedMarketGroups).Where(x => x.ParentID.GetValueOrDefault() == group.ID).Select(
                        x => groups[x.ID]).OrderBy(x => x.Name);

                group.SubGroups.AddRange(children);
            }

            // Pick the family
            SetItemFamilyByMarketGroup(groups[DBConstants.BlueprintsMarketGroupID], ItemFamily.Blueprint);
            SetItemFamilyByMarketGroup(groups[DBConstants.ShipsMarketGroupID], ItemFamily.Ship);
            SetItemFamilyByMarketGroup(groups[DBConstants.ImplantsMarketGroupID], ItemFamily.Implant);
            SetItemFamilyByMarketGroup(groups[DBConstants.DronesMarketGroupID], ItemFamily.Drone);
            SetItemFamilyByMarketGroup(groups[DBConstants.StarbaseStructuresMarketGroupID], ItemFamily.StarbaseStructure);

            // Sort groups
            IEnumerable<SerializableMarketGroup> rootGroups = Database.InvMarketGroupsTable.Concat(s_injectedMarketGroups).Where(
                x => !x.ParentID.HasValue).Select(x => groups[x.ID]).OrderBy(x => x.Name);

            // Reset the custom market groups
            s_nullMarketItems.ForEach(srcItem => srcItem.MarketGroupID = null);

            // Serialize
            ItemsDatafile datafile = new ItemsDatafile();
            datafile.MarketGroups.AddRange(rootGroups);

            Util.DisplayEndTime(stopwatch);

            // DEBUG: Find which items have not been generated
            if (Debugger.IsAttached)
            {
                var itemids = groups.Values.SelectMany(x => x.Items).Select(y => y.ID).ToList();
                var diff = Database.InvTypesTable.Where(item => !itemids.Contains(item.ID)).ToList();

                if (diff.Any())
                    Console.WriteLine("{0} items were not generated.", diff.Count);
            }

            Util.SerializeXml(datafile, DatafileConstants.ItemsDatafile);
        }