Пример #1
0
        // Public Methods
        public string getProf(string build, GW2APIController apiController)
        {
            if (is_elite == 0xFFFFFFFF)
            {
                if ((prof & 0xffff0000) == 0xffff0000)
                {
                    return("GDG");
                }
                else
                {
                    return("NPC");
                }
            }
            else if (is_elite == 0)
            {
                switch (prof)
                {
                case 1:
                    return("Guardian");

                case 2:
                    return("Warrior");

                case 3:
                    return("Engineer");

                case 4:
                    return("Ranger");

                case 5:
                    return("Thief");

                case 6:
                    return("Elementalist");

                case 7:
                    return("Mesmer");

                case 8:
                    return("Necromancer");

                case 9:
                    return("Revenant");
                }
            }
            else if (Convert.ToInt32(build.Substring(4, 8)) < 20170914)
            {
                if (is_elite == 1)
                {
                    switch (prof + 9)
                    {
                    case 10:
                        return("Dragonhunter");

                    case 11:
                        return("Berserker");

                    case 12:
                        return("Scrapper");

                    case 13:
                        return("Druid");

                    case 14:
                        return("Daredevil");

                    case 15:
                        return("Tempest");

                    case 16:
                        return("Chronomancer");

                    case 17:
                        return("Reaper");

                    case 18:
                        return("Herald");
                    }
                }
            }
            else if (Convert.ToInt32(build.Substring(4, 8)) >= 20170914)
            {
                if (is_elite == 1)
                {
                    switch (prof + 9)
                    {
                    case 10:
                        return("Dragonhunter");

                    case 11:
                        return("Berserker");

                    case 12:
                        return("Scrapper");

                    case 13:
                        return("Druid");

                    case 14:
                        return("Daredevil");

                    case 15:
                        return("Tempest");

                    case 16:
                        return("Chronomancer");

                    case 17:
                        return("Reaper");

                    case 18:
                        return("Herald");
                    }
                }
                else
                if (is_elite > 1)
                {
                    switch (is_elite)
                    {
                    case 55:
                        return("Soulbeast");

                    case 56:
                        return("Weaver");

                    case 57:
                        return("Holosmith");

                    case 58:
                        return("Deadeye");

                    case 59:
                        return("Mirage");

                    case 60:
                        return("Scourge");

                    case 61:
                        return("Spellbreaker");

                    case 62:
                        return("Firebrand");

                    case 63:
                        return("Renegade");
                    }

                    GW2APISpec spec = apiController.GetSpec((int)is_elite);
                    if (spec.elite)
                    {
                        return(spec.name);
                    }
                    else
                    {
                        return(spec.profession);
                    }
                }
            }

            return(null);
        }
Пример #2
0
        // Public Methods
        public string getProf(string build)
        {
            if (is_elite == -1)
            {
                if ((ID & 0xffff0000) == 0xffff0000)
                {
                    return("GDG");
                }
                else
                {
                    return("NPC");
                }
            }
            else if (is_elite == 0)
            {
                switch (prof)
                {
                case 1:
                    return("Guardian");

                case 2:
                    return("Warrior");

                case 3:
                    return("Engineer");

                case 4:
                    return("Ranger");

                case 5:
                    return("Thief");

                case 6:
                    return("Elementalist");

                case 7:
                    return("Mesmer");

                case 8:
                    return("Necromancer");

                case 9:
                    return("Revenant");
                }
            }
            else if (Convert.ToInt32(build.Substring(4, 8)) < 20170914)
            {
                if (is_elite == 1)
                {
                    switch (prof + 9)
                    {
                    case 10:
                        return("Dragonhunter");

                    case 11:
                        return("Berserker");

                    case 12:
                        return("Scrapper");

                    case 13:
                        return("Druid");

                    case 14:
                        return("Daredevil");

                    case 15:
                        return("Tempest");

                    case 16:
                        return("Chronomancer");

                    case 17:
                        return("Reaper");

                    case 18:
                        return("Herald");
                    }
                }
            }
            else if (Convert.ToInt32(build.Substring(4, 8)) >= 20170914)
            {
                if (is_elite == 1)
                {
                    switch (prof + 9)
                    {
                    case 10:
                        return("Dragonhunter");

                    case 11:
                        return("Berserker");

                    case 12:
                        return("Scrapper");

                    case 13:
                        return("Druid");

                    case 14:
                        return("Daredevil");

                    case 15:
                        return("Tempest");

                    case 16:
                        return("Chronomancer");

                    case 17:
                        return("Reaper");

                    case 18:
                        return("Herald");
                    }
                }
                else
                if (is_elite > 1)
                {
                    switch (is_elite)
                    {
                    case 55:
                        return("Soulbeast");

                    case 56:
                        return("Weaver");

                    case 57:
                        return("Holosmith");

                    case 58:
                        return("Deadeye");

                    case 59:
                        return("Mirage");

                    case 60:
                        return("Scourge");

                    case 61:
                        return("Spellbreaker");

                    case 62:
                        return("Firebrand");

                    case 63:
                        return("Renegade");
                    }
                    //Connecting to API everytime would be bad so
                    HttpClient APIClient = null;
                    if (APIClient == null)
                    {
                        APIClient             = new HttpClient();
                        APIClient.BaseAddress = new Uri("https://api.guildwars2.com");
                        APIClient.DefaultRequestHeaders.Accept.Clear();
                        APIClient.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json"));
                    }

                    //System.Threading.Thread.Sleep(100);
                    GW2APISpec          spec     = null;
                    HttpResponseMessage response = APIClient.GetAsync("/v2/specializations/" + is_elite).Result;
                    if (response.IsSuccessStatusCode)
                    {
                        spec = response.Content.ReadAsAsync <GW2APISpec>().Result;
                        if (spec.elite)
                        {
                            return(spec.name);
                        }
                        else
                        {
                            return(spec.profession);
                        }
                    }
                }
            }

            return(null);
        }