Exemple #1
0
        private static GW2APISpec GetGW2APISpec(string path)
        {
            GW2APISpec spec = null;
            //path = "/v2/specializations/" + isElite
            HttpResponseMessage response = APIClient.GetAsync(new Uri(path, UriKind.Relative)).Result;

            if (response.IsSuccessStatusCode)
            {
                spec = JsonConvert.DeserializeObject <GW2APISpec>(response.Content.ReadAsStringAsync().Result);
            }
            return(spec);
        }
Exemple #2
0
        public static List <int> WriteSpecListToFile()
        {
            FileStream fcreate = File.Open(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)
                                           + "/Content/SpecList.json", FileMode.Create);

            fcreate.Close();


            Console.WriteLine("Getting API");
            //Get list from API
            GetAPIClient();

            _listofSpecs = new SpecList();
            HttpResponseMessage response = APIClient.GetAsync(new Uri("/v2/specializations", UriKind.Relative)).Result;

            int[] idArray;
            var   failedList = new List <int>();

            if (response.IsSuccessStatusCode)
            {
                // Get Skill ID list
                idArray = JsonConvert.DeserializeObject <int[]>(response.Content.ReadAsStringAsync().Result);

                foreach (int id in idArray)
                {
                    var curSpec = new GW2APISpec();
                    curSpec = GetGW2APISpec("/v2/specializations/" + id);
                    if (curSpec != null)
                    {
                        _listofSpecs.Items.Add(curSpec);
                    }
                    else
                    {
                        Console.WriteLine("Failed to get response");//fail to retrieve
                        failedList.Add(id);
                    }
                }
                var writer = new StreamWriter(Path.GetDirectoryName(System.Reflection.Assembly.GetExecutingAssembly().Location)
                                              + "/Content/SpecList.json");

                var serializer = new JsonSerializer
                {
                    NullValueHandling = NullValueHandling.Ignore,
                    Formatting        = Formatting.None,
                    ContractResolver  = GeneralHelper.ContractResolver
                };
                serializer.Serialize(writer, _listofSpecs.Items);
                writer.Close();
            }
            return(failedList);
        }
        private string GetAgentProfString(uint prof, uint elite, ParserController operation)
        {
            // non player
            if (elite == 0xFFFFFFFF)
            {
                if ((prof & 0xffff0000) == 0xffff0000)
                {
                    return("GDG");
                }
                else
                {
                    return("NPC");
                }
            }
            // base profession
            else if (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");
                }
            }
            // old elite
            else if (elite == 1)
            {
                switch (prof)
                {
                case 1:
                    return("Dragonhunter");

                case 2:
                    return("Berserker");

                case 3:
                    return("Scrapper");

                case 4:
                    return("Druid");

                case 5:
                    return("Daredevil");

                case 6:
                    return("Tempest");

                case 7:
                    return("Chronomancer");

                case 8:
                    return("Reaper");

                case 9:
                    return("Herald");
                }
            }
            // new way
            else
            {
                GW2APISpec spec = _apiController.GetAPISpec((int)elite);
                if (spec == null)
                {
                    operation.UpdateProgressWithCancellationCheck("Missing or outdated GW2 API Cache or unknown player spec");
                    return("Unknown");
                }
                if (spec.Elite)
                {
                    return(spec.Name);
                }
                else
                {
                    return(spec.Profession);
                }
            }
            throw new EvtcAgentException("Unexpected profession pattern in evtc");
        }
Exemple #4
0
        public static string GetAgentProfString(string build, GW2APIController apiController, uint prof, uint elite)
        {
            if (elite == 0xFFFFFFFF)
            {
                if ((prof & 0xffff0000) == 0xffff0000)
                {
                    return("GDG");
                }
                else
                {
                    return("NPC");
                }
            }
            else if (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 (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 (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 (elite > 1)
                {
                    switch (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)elite);
                    if (spec.Elite)
                    {
                        return(spec.Name);
                    }
                    else
                    {
                        return(spec.Profession);
                    }
                }
            }
            return(null);
        }
Exemple #5
0
        public static string GetAgentProfString(uint prof, uint elite)
        {
            // non player
            if (elite == 0xFFFFFFFF)
            {
                if ((prof & 0xffff0000) == 0xffff0000)
                {
                    return("GDG");
                }
                else
                {
                    return("NPC");
                }
            }
            // base profession
            else if (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");
                }
            }
            // old elite
            else if (elite == 1)
            {
                switch (prof)
                {
                case 1:
                    return("Dragonhunter");

                case 2:
                    return("Berserker");

                case 3:
                    return("Scrapper");

                case 4:
                    return("Druid");

                case 5:
                    return("Daredevil");

                case 6:
                    return("Tempest");

                case 7:
                    return("Chronomancer");

                case 8:
                    return("Reaper");

                case 9:
                    return("Herald");
                }
            }
            // new way
            else
            {
                GW2APISpec spec = GetSpec((int)elite);
                if (spec.Elite)
                {
                    return(spec.Name);
                }
                else
                {
                    return(spec.Profession);
                }
            }
            throw new InvalidDataException("Error Encountered: Unknown profession");
        }
Exemple #6
0
        public static GW2APISpec GetSpec(int id)
        {
            GW2APISpec spec = GetSpecList().Items.FirstOrDefault(x => x.Id == id);

            return(spec);
        }