示例#1
0
        public async Task <PalicoArmor> GetPalicoArmor(string address)
        {
            var page = await context.OpenAsync(address);

            var    basicinfo   = page.QuerySelector("[itemprop=\"gameItem\"]");
            string name        = basicinfo.FirstElementChild.TextContent;
            string description = basicinfo.Children[1].TextContent;

            ConsoleWriters.StartingPageMessage($"Started on the {name} palico armor.");
            var leads  = page.QuerySelectorAll(".lead");
            int rarity = leads[0].TextContent.ToInt();
            int price  = leads[1].TextContent.ToInt();

            int[]       defense_info = page.QuerySelector(".table").Children[1].QuerySelectorAll("td").Select(d => d.TextContent.ToInt()).ToArray();
            PalicoArmor armor        = new PalicoArmor()
            {
                pa_name        = name,
                pa_description = description,
                pa_rarity      = rarity,
                pa_price       = price,
                pa_defense     = defense_info[0],
                pa_fire        = defense_info[1],
                pa_water       = defense_info[2],
                pa_thunder     = defense_info[3],
                pa_ice         = defense_info[4],
                pa_dragon      = defense_info[5],
                craft_items    = new List <PalicoCraftItem>()
            };
            var craft_table = page.QuerySelector(".table-sm").FirstElementChild.QuerySelectorAll("td");

            armor.craft_items = GetPalicoCrafts(craft_table, armor.pa_name, "armor");
            ConsoleWriters.CompletionMessage($"Finished adding the {name} palico armor!");
            return(armor);
        }
示例#2
0
        public async Task GetArmor(string address)
        {
            IConfiguration   config  = Configuration.Default.WithDefaultLoader(l => l.IsResourceLoadingEnabled = true).WithCss();
            IBrowsingContext context = BrowsingContext.New(config);
            var page = await context.OpenAsync(address);

            SetInfo setinfo = GetSetInfo(page);

            ConsoleWriters.StartingPageMessage($"Starting the {setinfo.armor_set} set.");
            var tables        = page.QuerySelectorAll(".table");
            var defense_trs   = tables[0].QuerySelectorAll("tbody tr").SkipLast(1);
            var skill_table   = tables[1].Children[1].Children.ToArray();
            var create_table  = tables[2].Children[1].Children.ToArray();
            var upgrade_table = tables[4].Children[1].Children.ToArray();

            // Skip the last tr, because that is the total
            foreach (var tr in defense_trs)
            {
                DefenseInfo    definfo  = GetArmorPieceDefenseInfo(tr);
                int            tr_index = tr.ParentElement.Children.Index(tr);
                ArmorSkillInfo asi      = GetArmorSkills(skill_table[tr_index]);
                Armor          piece    = new Armor()
                {
                    armor_name        = definfo.armor_name,
                    armor_set         = setinfo.armor_set,
                    armor_description = setinfo.piece_descriptions[tr_index],
                    rarity            = setinfo.rarity,
                    max_upgrade       = setinfo.max_upgrade,
                    monster_id        = setinfo.monster_id,
                    is_blademaster    = setinfo.is_blademaster,
                    is_gunner         = setinfo.is_gunner,
                    is_male           = setinfo.is_male,
                    is_female         = setinfo.is_female,
                    min_armor_defense = definfo.min_defense,
                    max_armor_defense = definfo.max_defense,
                    fire_def          = definfo.fire_defense,
                    water_def         = definfo.water_defense,
                    thunder_def       = definfo.thunder_defense,
                    ice_def           = definfo.ice_defense,
                    dragon_def        = definfo.dragon_def,
                    slots             = asi.slots,
                };
                await db.InsertAsync(piece);

                foreach (ArmorSkill skill in asi.skills)
                {
                    skill.armor_id = piece.armor_id;
                }
                await Task.WhenAll(
                    db.InsertAllAsync(asi.skills),
                    db.InsertAllAsync(GetArmorScraps(create_table[tr_index], "create", piece.armor_id)),
                    db.InsertAllAsync(GetArmorScraps(upgrade_table[tr_index], "upgrade", piece.armor_id)),
                    db.InsertAllAsync(GetArmorCrafts(create_table[tr_index], piece.armor_id)),
                    db.InsertAllAsync(GetArmorUpgradeItems(upgrade_table[tr_index], piece.armor_id))
                    );
            }
            ConsoleWriters.CompletionMessage($"Finished with the {setinfo.armor_set} set!");
        }
示例#3
0
        public PalicoSkill GetPalicoSkill(IElement tr)
        {
            string name = tr.Children[0].TextContent;

            ConsoleWriters.StartingPageMessage($"Retrieving the palico skill {name}.");
            string type = "";

            switch (tr.Children[1].FirstElementChild.ClassList[2])
            {
            case "text-danger":
                type = "offensive";
                break;

            case "text-info":
                type = "defensive";
                break;

            case "text-warning":
                type = "passive";
                break;
            }
            int memory = 0;

            foreach (var span in tr.Children[1].Children)
            {
                memory += 1;
            }
            int    level       = tr.Children[2].TextContent.ToInt();
            string description = tr.Children[3].TextContent;

            ConsoleWriters.CompletionMessage($"Finished with the palico skill {name}!");
            return(new PalicoSkill()
            {
                ps_description = description,
                ps_learn_level = level,
                ps_memory_req = memory,
                ps_name = name,
                ps_type = type
            });
        }
示例#4
0
        static void Main(string[] args)
        {
            Stopwatch stopwatch = new Stopwatch();

            stopwatch.Start();
            TimeSpan timeSpan = new TimeSpan();

            if (args.Contains("--items") || args.Contains("--all") || args.Length == 0)
            {
                var itemManager = new Items();
                itemManager.GetItemList().Wait();
                timeSpan = TimeSpan.FromSeconds(Convert.ToInt32(stopwatch.Elapsed.TotalSeconds));
                Console.WriteLine("\n\nFinished with items! Took " + timeSpan.ToString("c") + ".\n\n");
                stopwatch.Reset();
                stopwatch.Start();
            }

            if (args.Contains("--monsters") || args.Contains("--all") || args.Length == 0)
            {
                var monManager = new Monsters();
                Console.WriteLine("Starting monster data retrieval.");
                monManager.GetMonsters().Wait();
                timeSpan = TimeSpan.FromSeconds(Convert.ToInt32(stopwatch.Elapsed.TotalSeconds));
                Console.WriteLine("Done with monsters! Took " + timeSpan.ToString("c") + ".\n\n");
                stopwatch.Reset();
                stopwatch.Start();
            }

            if (args.Contains("--quests") || args.Contains("--all") || args.Length == 0)
            {
                var questManager = new Quests();
                Console.WriteLine("Starting quest data retrieval.");
                questManager.GetQuests("http://mhgen.kiranico.com/quest/village").Wait();
                questManager.GetQuests("http://mhgen.kiranico.com/quest/guild").Wait();
                questManager.GetQuests("http://mhgen.kiranico.com/quest/arena").Wait();
                questManager.GetQuests("http://mhgen.kiranico.com/quest/training").Wait();
                questManager.GetQuests("http://mhgen.kiranico.com/quest/special-permit").Wait();
                timeSpan = TimeSpan.FromSeconds(Convert.ToInt32(stopwatch.Elapsed.TotalSeconds));
                Console.WriteLine("Done with all quests! Took " + timeSpan.ToString("c") + ".\n\n");
                stopwatch.Reset();
                stopwatch.Start();
            }

            if (args.Contains("--weapons") || args.Contains("--all") || args.Length == 0)
            {
                Stopwatch indiv_weapon_watch = new Stopwatch();
                var       weaponManager      = new Weapons();
                string[]  weaponurls         = new string[] {
                    "heavybowgun",
                    "lightbowgun",
                    "bow",
                    "gunlance",
                    "chargeblade",
                    "switchaxe",
                    "huntinghorn",
                    "dualblades",
                    "greatsword",
                    "longsword",
                    "swordshield",
                    "hammer",
                    "lance",
                    "insectglaive"
                };
                indiv_weapon_watch.Start();
                foreach (string category in weaponurls)
                {
                    ConsoleWriters.InfoMessage($"Starting {category} retrieval...");
                    weaponManager.GetWeapons($"http://mhgen.kiranico.com/{category}").Wait();
                    timeSpan = TimeSpan.FromSeconds(Convert.ToInt32(indiv_weapon_watch.Elapsed.TotalSeconds));
                    ConsoleWriters.InfoMessage($"Done with {category}s! Took {timeSpan.ToString("c")}.\n\n");
                    indiv_weapon_watch.Restart();
                }
                indiv_weapon_watch.Stop();
                timeSpan = TimeSpan.FromSeconds(Convert.ToInt32(stopwatch.Elapsed.TotalSeconds));
                ConsoleWriters.InfoMessage("Done with all weapons! Took " + timeSpan.ToString("c") + ".\n\n");
                stopwatch.Restart();
            }

            if (args.Contains("--skills") || args.Contains("--all") || args.Length == 0)
            {
                var skillManager = new Skills();
                ConsoleWriters.InfoMessage("Starting skill retrieval...\n\n");
                skillManager.GetSkills("http://mhgen.kiranico.com/skill").Wait();
                timeSpan = TimeSpan.FromSeconds(Convert.ToInt32(stopwatch.Elapsed.TotalSeconds));
                ConsoleWriters.InfoMessage("Done with all skills! Took " + timeSpan.ToString("c") + ".\n\n");
                stopwatch.Restart();
            }

            if (args.Contains("--arts") || args.Contains("--all") || args.Length == 0)
            {
                var artManager = new HunterArts();
                ConsoleWriters.InfoMessage("Starting hunter art retrieval...\n\n");
                artManager.GetArts("http://mhgen.kiranico.com/hunter-art").Wait();
                timeSpan = TimeSpan.FromSeconds(Convert.ToInt32(stopwatch.Elapsed.TotalSeconds));
                ConsoleWriters.InfoMessage("Done with all hunter arts! Took " + timeSpan.ToString("c") + ".\n\n");
                stopwatch.Restart();
            }

            if (args.Contains("--decorations") || args.Contains("--all") || args.Length == 0)
            {
                var decoManager = new Decorations();
                ConsoleWriters.InfoMessage("Starting decoration retrieval...\n\n");
                decoManager.GetDecorations("http://mhgen.kiranico.com/decoration").Wait();
                timeSpan = TimeSpan.FromSeconds(Convert.ToInt32(stopwatch.Elapsed.TotalSeconds));
                ConsoleWriters.InfoMessage("Done with all decorations! Took " + timeSpan.ToString("c") + ".\n\n");
                stopwatch.Restart();
            }

            if (args.Contains("--armor") || args.Contains("--all") || args.Length == 0)
            {
                var armor = new Armors();
                for (int i = 1; i < 9; i++)
                {
                    armor.GetArmors($"http://mhgen.kiranico.com/armor?rare={i}").Wait();
                }
                timeSpan = TimeSpan.FromSeconds(Convert.ToInt32(stopwatch.Elapsed.TotalSeconds));
                ConsoleWriters.InfoMessage("Done with all armors! Took " + timeSpan.ToString("c") + ".\n\n");
                stopwatch.Restart();
            }

            if (args.Contains("--palico-skills") || args.Contains("--all") || args.Length == 0)
            {
                var palico = new Palicoes();
                ConsoleWriters.StartingPageMessage("Starting palico skill retrieval...\n\n");
                palico.GetPalicoSkills("http://mhgen.kiranico.com/palico-skill").Wait();
                timeSpan = TimeSpan.FromSeconds(Convert.ToInt32(stopwatch.Elapsed.TotalSeconds));
                ConsoleWriters.InfoMessage("Done with all palico skills! Took " + timeSpan.ToString("c") + ".\n\n");
                stopwatch.Restart();
            }

            if (args.Contains("--palico-armor") || args.Contains("--all") || args.Length == 0)
            {
                var palico = new Palicoes();
                ConsoleWriters.StartingPageMessage("Starting palico armor retrieval...\n\n");
                for (int i = 1; i < 5; i++)
                {
                    palico.GetPalicoArmors($"http://mhgen.kiranico.com/palico-armor?page={i}").Wait();
                }
                timeSpan = TimeSpan.FromSeconds(Convert.ToInt32(stopwatch.Elapsed.TotalSeconds));
                ConsoleWriters.InfoMessage("Done with all palico armors! Took " + timeSpan.ToString("c") + ".\n\n");
                stopwatch.Restart();
            }

            if (args.Contains("--palico-weapons") || args.Contains("--all") || args.Length == 0)
            {
                var palico = new Palicoes();
                ConsoleWriters.StartingPageMessage("Starting palico weapon retrieval...\n\n");
                palico.GetPalicoWeapons("http://mhgen.kiranico.com/palico-weapon").Wait();
                timeSpan = TimeSpan.FromSeconds(Convert.ToInt32(stopwatch.Elapsed.TotalSeconds));
                ConsoleWriters.InfoMessage("Done with all palico weapons! Took " + timeSpan.ToString("c") + ".\n\n");
                stopwatch.Restart();
            }
            stopwatch.Stop();
        }
示例#5
0
        public async Task <PalicoWeapon> GetPalicoWeapon(string address, string weapon_type, string weapon_damage_type)
        {
            var page = await context.OpenAsync(address);

            var    basicinfo   = page.QuerySelector("[itemprop=\"gameItem\"]");
            string name        = basicinfo.FirstElementChild.TextContent;
            string description = basicinfo.Children[1].TextContent;

            ConsoleWriters.StartingPageMessage($"Started on the {name} palico weapon.");
            var leads  = page.QuerySelectorAll(".lead");
            int rarity = leads[0].TextContent.ToInt();
            int price  = leads[1].TextContent.ToInt();

            var damage_tr = page.QuerySelector(".table").QuerySelectorAll("tr")[1];

            var    melee_data        = damage_tr.FirstElementChild.QuerySelectorAll("div");
            int    melee_dmg         = melee_data[0].TextContent.ToInt();
            int    melee_affinity    = melee_data[1].TextContent.ToInt();
            string sharpness         = damage_tr.QuerySelector("span").ClassName;
            string melee_element     = "none";
            int    melee_elem_amount = 0;

            if (damage_tr.Children[2].TextContent.Replace(" ", "") != "")
            {
                melee_element     = damage_tr.Children[2].TextContent.Trim().Split(' ')[1];
                melee_elem_amount = damage_tr.Children[2].TextContent.ToInt();
            }

            var    boom_data        = damage_tr.Children[3].QuerySelectorAll("div");
            int    boom_dmg         = boom_data[0].TextContent.ToInt();
            int    boom_affinity    = boom_data[1].TextContent.ToInt();
            string boom_element     = "none";
            int    boom_elem_amount = 0;

            if (damage_tr.Children[4].TextContent.Replace(" ", "") != "")
            {
                boom_element     = damage_tr.Children[4].TextContent.Trim().Split(' ')[1];
                boom_elem_amount = damage_tr.Children[4].TextContent.ToInt();
            }
            int defense = damage_tr.LastElementChild.TextContent.ToInt();

            PalicoWeapon weapon = new PalicoWeapon()
            {
                pw_name                  = name,
                pw_description           = description,
                pw_affinity              = melee_affinity,
                pw_boomerang_affinity    = boom_affinity,
                pw_boomerang_damage      = boom_dmg,
                pw_boomerang_element     = boom_element,
                pw_boomerang_element_amt = boom_elem_amount,
                pw_damage                = melee_dmg,
                pw_damage_type           = weapon_damage_type,
                pw_defense               = defense,
                pw_element               = melee_element,
                pw_element_amt           = melee_elem_amount,
                pw_price                 = price,
                pw_rarity                = rarity,
                pw_sharpness             = sharpness,
                pw_type                  = weapon_type
            };

            var craft_table = page.QuerySelector(".table-sm").FirstElementChild.QuerySelectorAll("td");

            weapon.craft_items = GetPalicoCrafts(craft_table, name, "weapon");
            ConsoleWriters.CompletionMessage($"Finished adding the {name} palico weapon!");
            return(weapon);
        }