Exemplo n.º 1
0
        public async Task Run(string[] args)
        {
            logger = new ConsoleLogger();

            IDataSource source1 = new MHArmory.AthenaAssDataSource.DataSource(logger, null, null);
            IDataSource source2 = new MHArmory.ArmoryDataSource.DataSource(logger);

            await Equals(source1, source2);
        }
Exemplo n.º 2
0
        public async Task Run(string[] args)
        {
            ILogger logger = new ConsoleLogger();

            //var httpClient = new HttpClient();
            //Task<string> fetchWeaponsTask = httpClient.GetStringAsync("https://mhw-db.com/weapons?p={\"slug\":false,\"crafting\":false,\"assets\":false}");

            IDataSource source = new MHArmory.AthenaAssDataSource.DataSource(logger, null, null);

            IList <IArmorPiece> armorPieces = (await source.GetArmorPieces()).OrderBy(x => x.Id).ToList();
            IList <ISkill>      skills      = (await source.GetSkills()).OrderBy(x => x.Id).ToList();
            IList <ICharm>      charms      = (await source.GetCharms()).OrderBy(x => x.Id).ToList();
            IList <IJewel>      jewels      = (await source.GetJewels()).OrderBy(x => x.Id).ToList();

            IList <IAbility> abilities = skills
                                         .SelectMany(x => x.Abilities)
                                         .Distinct(AbilityEqualityComparer.Default)
                                         .OrderBy(x => x.Id)
                                         .ToList();

            string solutionPath = Common.FindSolutionPath();

            if (solutionPath == null)
            {
                throw new InvalidOperationException($"Could not find solution path for '{Common.SolutionFilename}'");
            }

            string outputPath = Path.Combine(solutionPath, "MHArmory", "data");

            if (Directory.Exists(outputPath) == false)
            {
                Directory.CreateDirectory(outputPath);
            }

            //--------------------------------------------------------------------------

            Common.SerializeJson(Path.Combine(outputPath, $"{nameof(abilities)}.json"), Export(abilities));

            //--------------------------------------------------------------------------

            IEnumerable <IArmorPiece> heads  = armorPieces.Where(x => x.Type == EquipmentType.Head);
            IEnumerable <IArmorPiece> chests = armorPieces.Where(x => x.Type == EquipmentType.Chest);
            IEnumerable <IArmorPiece> arms   = armorPieces.Where(x => x.Type == EquipmentType.Gloves);
            IEnumerable <IArmorPiece> waists = armorPieces.Where(x => x.Type == EquipmentType.Waist);
            IEnumerable <IArmorPiece> legs   = armorPieces.Where(x => x.Type == EquipmentType.Legs);

            Common.SerializeJson(Path.Combine(outputPath, $"{nameof(heads)}.json"), Export(heads));
            Common.SerializeJson(Path.Combine(outputPath, $"{nameof(chests)}.json"), Export(chests));
            Common.SerializeJson(Path.Combine(outputPath, $"{nameof(arms)}.json"), Export(arms));
            Common.SerializeJson(Path.Combine(outputPath, $"{nameof(waists)}.json"), Export(waists));
            Common.SerializeJson(Path.Combine(outputPath, $"{nameof(legs)}.json"), Export(legs));

            //--------------------------------------------------------------------------

            IList <IArmorSetSkill> armorSetSkills = armorPieces
                                                    .Where(x => x.ArmorSetSkills != null && x.ArmorSetSkills.Length > 0)
                                                    .SelectMany(x => x.ArmorSetSkills)
                                                    .Distinct(new LambdaEqualityComparer <IArmorSetSkill>((x, y) => x.Id == y.Id, x => x.Id))
                                                    .OrderBy(x => x.Id)
                                                    .ToList();

            Common.SerializeJson(Path.Combine(outputPath, $"{nameof(armorSetSkills)}.json"), Export(armorSetSkills));

            //--------------------------------------------------------------------------

            IList <IFullArmorSet> fullArmorSets = armorPieces
                                                  .Select(x => x.FullArmorSet)
                                                  .Where(x => x != null)
                                                  .Distinct(new LambdaEqualityComparer <IFullArmorSet>((x, y) => x.Id == y.Id, x => x.Id))
                                                  .OrderBy(x => x.Id)
                                                  .ToList();

            Common.SerializeJson(Path.Combine(outputPath, $"{nameof(fullArmorSets)}.json"), Export(fullArmorSets));

            //--------------------------------------------------------------------------

            IList <ICharmLevel> charmLevels = charms
                                              .SelectMany(x => x.Levels)
                                              .Distinct(new LambdaEqualityComparer <ICharmLevel>((x, y) => x.Id == y.Id, x => x.Id))
                                              .OrderBy(x => x.Id)
                                              .ToList();

            Common.SerializeJson(Path.Combine(outputPath, $"{nameof(charmLevels)}.json"), Export(charmLevels));

            //--------------------------------------------------------------------------

            Common.SerializeJson(Path.Combine(outputPath, $"{nameof(charms)}.json"), Export(charms));

            //--------------------------------------------------------------------------

            Common.SerializeJson(Path.Combine(outputPath, $"{nameof(skills)}.json"), Export(skills));

            //--------------------------------------------------------------------------

            Common.SerializeJson(Path.Combine(outputPath, $"{nameof(jewels)}.json"), Export(jewels));
        }