Пример #1
0
        public static void WriteCastingItemIcon(StreamWriter sw, CastLog cl, SkillData skillList, PhaseData phase, bool last)
        {
            SkillItem   skill    = skillList.Get(cl.SkillId);
            GW2APISkill skillApi = skill?.ApiSkill;
            float       offset   = (cl.Time - phase.Start) / 1000f;

            if ((skillApi != null && skillApi.slot != "Weapon_1") || skillApi == null)
            {
                sw.Write("{" +
                         "source: '" + skill.Icon + "'," +
                         "xref: 'x'," +
                         "yref: 'y'," +
                         "x: " + Math.Max(offset, 0.0f) + "," +
                         "y: 0," +
                         "sizex: 1.1," +
                         "sizey: 1.1," +
                         "xanchor: 'left'," +
                         "yanchor: 'bottom'" +
                         "}");
            }

            if (!last)
            {
                sw.Write(",");
            }
        }
        private GW2APISkill GetGW2APISKill(string path)
        {
            //System.Threading.Thread.Sleep(100);
            if (APIClient == null)
            {
                GetAPIClient();
            }
            GW2APISkill         skill    = null;
            HttpResponseMessage response = APIClient.GetAsync(path).Result;

            if (response.IsSuccessStatusCode)
            {
                //skill = response.Content.ReadAsAsync<GW2APISkill>().Result;
                skill = response.Content.ReadAsAsync <GW2APISkill>().Result;

                /*if (skillCheck.categories != null)
                 * {
                 *  int stop = 0;
                 * }*/
            }
            else
            {//try again after a wait
                System.Threading.Thread.Sleep(1000);
                response = APIClient.GetAsync(path).Result;
                if (response.IsSuccessStatusCode)
                {
                    //skill = response.Content.ReadAsAsync<GW2APISkill>().Result;
                    skill = response.Content.ReadAsAsync <GW2APISkill>().Result;
                }
            }
            return(skill);
        }
        private GW2APISkill GetGW2APISKill(string path)
        {
            //System.Threading.Thread.Sleep(100);
            if (APIClient == null)
            {
                GetAPIClient();
            }
            GW2APISkill         skill    = null;
            HttpResponseMessage response = APIClient.GetAsync(path).Result;

            if (response.IsSuccessStatusCode)
            {
                skill = response.Content.ReadAsAsync <GW2APISkill>().Result;
            }
            else  //try again after a wait
            {
                System.Threading.Thread.Sleep(1000);
                response = APIClient.GetAsync(path).Result;
                if (response.IsSuccessStatusCode)
                {
                    skill = response.Content.ReadAsAsync <GW2APISkill>().Result;
                }
            }
            return(skill);
        }
Пример #4
0
        public void RetryWriteSkillListtoFile()
        {
            if (new FileInfo(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)
                             + "/Content/SkillList.txt").Length != 0)
            {
                Console.WriteLine("Reading Skilllist");

                //Get list from local XML
                using (var reader = new StreamReader(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)
                                                     + "/Content/SkillList.txt"))
                {
                    Type[] tyList = { typeof(List <GW2APISkillCheck>), typeof(List <GW2APISkillDetailed>) };


                    XmlSerializer deserializer = new XmlSerializer(typeof(SkillList), tyList);
                    _listOfSkills = (SkillList)deserializer.Deserialize(reader);

                    reader.Close();
                }
            }
            Console.WriteLine("Getting APi");
            //Get list from API
            GetAPIClient();

            HttpResponseMessage response = APIClient.GetAsync("/v2/skills").Result;

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

                foreach (int id in idArray)
                {
                    if (_listOfSkills.Items.FirstOrDefault(x => x.id == id) == null)
                    {
                        GW2APISkill curSkill = new GW2APISkill();
                        curSkill = GetGW2APISKill("/v2/skills/" + id);
                        if (curSkill != null)
                        {
                            _listOfSkills.Items.Add(curSkill);
                        }
                        else
                        {
                            Console.WriteLine("Fail to get response");//fail to retrieve
                        }
                    }
                }
                Stream stream = System.IO.File.OpenWrite(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)
                                                         + "/Content/SkillList.txt");
                Type[] tyList = { typeof(List <GW2APISkillCheck>), typeof(List <GW2APISkillDetailed>) };

                XmlSerializer xmlSer = new XmlSerializer(typeof(List <GW2APISkill>), tyList);
                xmlSer.Serialize(stream, _listOfSkills.Items);
                stream.Close();
            }
        }
        private Dictionary <long, List <JsonSkill> > BuildRotation(List <CastLog> cls)
        {
            Dictionary <long, List <JsonSkill> > res = new Dictionary <long, List <JsonSkill> >();
            SkillData skillList = _log.SkillData;

            foreach (CastLog cl in cls)
            {
                SkillItem   skill     = skillList.Get(cl.SkillId);
                GW2APISkill skillApi  = skill?.ApiSkill;
                string      skillName = skill.Name;
                _skillNames[cl.SkillId] = skillName;
                JsonSkill jSkill = new JsonSkill
                {
                    Time     = (int)cl.Time,
                    Duration = cl.ActualDuration
                };
                if (_devMode)
                {
                    if (!_skillIcons.ContainsKey(cl.SkillId))
                    {
                        string skillIcon = skill.Icon;
                        if (skillIcon.Length > 0)
                        {
                            _skillIcons[cl.SkillId] = skillIcon;
                        }
                    }
                    int timeGained = 0;
                    if (cl.EndActivation == ParseEnum.Activation.CancelFire && cl.ActualDuration < cl.ExpectedDuration)
                    {
                        timeGained = cl.ExpectedDuration - cl.ActualDuration;
                    }
                    else if (cl.EndActivation == ParseEnum.Activation.CancelCancel)
                    {
                        timeGained = -cl.ActualDuration;
                    }
                    jSkill.ED = new JsonSkill.JsonExtraSkill()
                    {
                        UQ = cl.StartActivation == ParseEnum.Activation.Quickness ? 1 : 0,
                        TS = timeGained,
                        A  = skillApi != null && skillApi.slot == "Weapon_1" ? 1 : 0
                    };
                }
                if (res.TryGetValue(cl.SkillId, out var list))
                {
                    list.Add(jSkill);
                }
                else
                {
                    res[cl.SkillId] = new List <JsonSkill>()
                    {
                        jSkill
                    };
                }
            }

            return(res);
        }
Пример #6
0
        public GW2APISkill GetSkill(long id)
        {
            GW2APISkill skill = GetSkillList().Items.FirstOrDefault(x => x.id == id);

            //if (skill == null) {
            //    string path = "/v2/skills/" + id;
            //    skill = GetGW2APISKill(path);
            //}
            return(skill);
        }
Пример #7
0
        public List <int> WriteSkillListToFile()
        {
            //used for wiritng new XMLs
            FileStream fcreate = File.Open(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)
                                           + "/Content/SkillList.txt", FileMode.Create);

            fcreate.Close();


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

            ListOfSkills = new SkillList();
            HttpResponseMessage response = APIClient.GetAsync("/v2/skills").Result;

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

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

                foreach (int id in idArray)
                {
                    GW2APISkill curSkill = new GW2APISkill();
                    curSkill = GetGW2APISKill("/v2/skills/" + id);
                    if (curSkill != null)
                    {
                        ListOfSkills.Items.Add(curSkill);
                    }
                    else
                    {
                        Console.WriteLine("Fail to get response");//fail to retrieve
                        failedList.Add(id);
                    }
                }
                Stream stream = System.IO.File.OpenWrite(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)
                                                         + "/Content/SkillList.txt");
                Type[] tyList = { typeof(List <GW2APISkillCheck>), typeof(List <GW2APISkillDetailed>) };

                XmlSerializer xmlSer = new XmlSerializer(typeof(List <GW2APISkill>), tyList);
                xmlSer.Serialize(stream, ListOfSkills.Items);
                stream.Close();
            }
            return(failedList);
        }
Пример #8
0
        private Dictionary <string, List <JsonSkill> > BuildRotation(List <CastLog> cls)
        {
            Dictionary <string, List <JsonSkill> > res = new Dictionary <string, List <JsonSkill> >();
            SkillData skillList = _log.SkillData;

            foreach (CastLog cl in cls)
            {
                SkillItem   skill     = skillList.Get(cl.SkillId);
                GW2APISkill skillApi  = skill?.ApiSkill;
                string      skillName = skill.Name;
                _skillNames["s" + cl.SkillId] = skillName;
                int timeGained = 0;
                if (cl.EndActivation == ParseEnum.Activation.CancelFire && cl.ActualDuration < cl.ExpectedDuration)
                {
                    timeGained = cl.ExpectedDuration - cl.ActualDuration;
                }
                else if (cl.EndActivation == ParseEnum.Activation.CancelCancel)
                {
                    timeGained = -cl.ActualDuration;
                }
                JsonSkill jSkill = new JsonSkill
                {
                    Time       = (int)cl.Time,
                    Duration   = cl.ActualDuration,
                    TimeGained = timeGained,
                    AutoAttack = skillApi != null && skillApi.slot == "Weapon_1" ? 1 : 0,
                    Quickness  = cl.StartActivation == ParseEnum.Activation.Quickness ? 1 : 0
                };
                if (res.TryGetValue("s" + cl.SkillId, out var list))
                {
                    list.Add(jSkill);
                }
                else
                {
                    res["s" + cl.SkillId] = new List <JsonSkill>()
                    {
                        jSkill
                    };
                }
            }

            return(res);
        }
Пример #9
0
        private GW2APISkill GetGW2APISKill(string path)
        {
            //System.Threading.Thread.Sleep(100);
            if (APIClient == null)
            {
                GetAPIClient();
            }
            GW2APISkill         skill    = null;
            HttpResponseMessage response = APIClient.GetAsync(path).Result;

            if (response.IsSuccessStatusCode)
            {
                //skill = response.Content.ReadAsAsync<GW2APISkill>().Result;
                GW2APISkillCheck skillCheck = response.Content.ReadAsAsync <GW2APISkillCheck>().Result;

                /*if (skillCheck.categories != null)
                 * {
                 *  int stop = 0;
                 * }*/
                if (skillCheck.facts != null)
                {
                    bool block = true;
                    foreach (GW2APIfacts fact in skillCheck.facts)
                    {
                        if (fact.type == "Unblockable" || fact.type == "StunBreak")//Unblockable changing value from an int to a bool has caused so much chaos
                        {
                            skill = skillCheck;
                            block = false;
                            break;
                        }
                    }
                    if (block)
                    {
                        response = APIClient.GetAsync(path).Result;
                        if (response.IsSuccessStatusCode)
                        {
                            skill = response.Content.ReadAsAsync <GW2APISkillDetailed>().Result;
                        }
                    }
                }
                else
                {
                    skill = skillCheck;
                }
            }
            else
            {//try again after a wait
                System.Threading.Thread.Sleep(1000);
                response = APIClient.GetAsync(path).Result;
                if (response.IsSuccessStatusCode)
                {
                    //skill = response.Content.ReadAsAsync<GW2APISkill>().Result;
                    GW2APISkillCheck skillCheck = response.Content.ReadAsAsync <GW2APISkillCheck>().Result;
                    if (skillCheck.facts != null)
                    {
                        bool block = true;
                        foreach (GW2APIfacts fact in skillCheck.facts)
                        {
                            if (fact.type == "Unblockable" || fact.type == "StunBreak")//Unblockable changing value from an int to a bool has caused so much chaos
                            {
                                skill = skillCheck;
                                block = false;
                                break;
                            }
                        }
                        if (block == false)
                        {
                            response = APIClient.GetAsync(path).Result;
                            if (response.IsSuccessStatusCode)
                            {
                                skill = response.Content.ReadAsAsync <GW2APISkillDetailed>().Result;
                            }
                        }
                    }
                    else
                    {
                        skill = skillCheck;
                    }
                }
            }
            return(skill);
        }
        public void RetryWriteSkillListtoFile()
        {
            if (new FileInfo(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)
                             + "/Content/SkillList.json").Length != 0)
            {
                Console.WriteLine("Reading Skilllist");
                using (StreamReader reader = new StreamReader(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)
                                                              + "/Content/SkillList.json"))
                {
                    JsonSerializer serializer = new JsonSerializer()
                    {
                        ContractResolver = new DefaultContractResolver()
                        {
                            NamingStrategy = new CamelCaseNamingStrategy()
                        }
                    };
                    _listOfSkills.Items = (List <GW2APISkill>)serializer.Deserialize(reader, typeof(List <GW2APISkill>));
                    reader.Close();
                }
            }
            Console.WriteLine("Getting APi");
            //Get list from API
            GetAPIClient();

            HttpResponseMessage response = APIClient.GetAsync("/v2/skills").Result;

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

                foreach (int id in idArray)
                {
                    if (_listOfSkills.Items.FirstOrDefault(x => x.Id == id) == null)
                    {
                        GW2APISkill curSkill = new GW2APISkill();
                        curSkill = GetGW2APISKill("/v2/skills/" + id);
                        if (curSkill != null)
                        {
                            _listOfSkills.Items.Add(curSkill);
                        }
                        else
                        {
                            Console.WriteLine("Fail to get response");//fail to retrieve
                        }
                    }
                }
                StreamWriter writer = new StreamWriter(System.IO.Path.GetDirectoryName(System.Reflection.Assembly.GetEntryAssembly().Location)
                                                       + "/Content/SkillList.json");

                var serializer = new JsonSerializer
                {
                    NullValueHandling    = NullValueHandling.Ignore,
                    Formatting           = Newtonsoft.Json.Formatting.Indented,
                    DefaultValueHandling = DefaultValueHandling.Ignore,
                    ContractResolver     = new DefaultContractResolver()
                    {
                        NamingStrategy = new CamelCaseNamingStrategy()
                    }
                };
                serializer.Serialize(writer, _listOfSkills.Items);
                writer.Close();
            }
        }
        public static void WriteCastingItem(StreamWriter sw, CastLog cl, SkillData skillList, PhaseData phase)
        {
            GW2APISkill skill     = skillList.Get(cl.SkillId)?.ApiSkill;
            string      skillName = skill == null?skillList.GetName(cl.SkillId) : skill.name;

            float dur;

            if (skillName == "Dodge")
            {
                dur = 0.5f;
            }
            else if (cl.SkillId == SkillItem.WeaponSwapId)
            {
                skillName = "Weapon Swap";
                dur       = 0.1f;
            }
            else
            {
                dur = cl.ActualDuration / 1000f;
            }
            skillName = skillName.Replace("\"", "");
            float offset = (cl.Time - phase.Start) / 1000f;
            float xVal   = dur;

            if (offset < 0.0f)
            {
                xVal += offset;
            }
            xVal = Math.Min(xVal, (phase.End - cl.Time) / 1000f);
            sw.Write("{");
            {
                sw.Write(cl.SkillId == -5 ? "y: ['1']," : "y: ['1.5'],");

                sw.Write(
                    "x: ['" + xVal + "']," +
                    "base:'" + Math.Max(offset, 0.0f) + "'," +
                    "name: \"" + skillName + " " + dur + "s\"," +   //get name should be handled by api
                    "orientation:'h'," +
                    "mode: 'markers'," +
                    "type: 'bar',");
                if (skill != null)
                {
                    sw.Write(skill.slot == "Weapon_1" ? "width:'0.5'," : "width:'1',");
                }
                else
                {
                    sw.Write("width:'1',");
                }
                sw.Write("hoverinfo: 'name'," +
                         "hoverlabel:{namelength:'-1'},");
                sw.Write("marker: {");
                {
                    if (cl.EndActivation == ParseEnum.Activation.CancelFire)
                    {
                        sw.Write("color: 'rgb(40,40,220)',");
                    }
                    else if (cl.EndActivation == ParseEnum.Activation.CancelCancel)
                    {
                        sw.Write("color: 'rgb(220,40,40)',");
                    }
                    else if (cl.EndActivation == ParseEnum.Activation.Reset)
                    {
                        sw.Write("color: 'rgb(40,220,40)',");
                    }
                    else
                    {
                        sw.Write("color: 'rgb(220,220,0)',");
                    }
                    sw.Write("width: '5',");
                    sw.Write("line:{");
                    {
                        if (cl.StartActivation == ParseEnum.Activation.Normal)
                        {
                            sw.Write("color: 'rgb(20,20,20)',");
                        }
                        else if (cl.StartActivation == ParseEnum.Activation.Quickness)
                        {
                            sw.Write("color: 'rgb(220,40,220)',");
                        }
                        sw.Write("width: '1'");
                    }
                    sw.Write("}");
                }
                sw.Write("},");
                sw.Write("showlegend: false");
            }
            sw.Write(" },");
        }
        public static void WriteCastingItemIcon(StreamWriter sw, CastLog cl, SkillData skillList, PhaseData phase, bool last)
        {
            string      skillIcon = "";
            GW2APISkill skill     = skillList.Get(cl.SkillId)?.ApiSkill;

            if (skill != null && cl.SkillId != -2)
            {
                float offset = (cl.Time - phase.Start) / 1000f;
                if (skill.slot != "Weapon_1")
                {
                    skillIcon = skill.icon;
                    sw.Write("{" +
                             "source: '" + skillIcon + "'," +
                             "xref: 'x'," +
                             "yref: 'y'," +
                             "x: " + Math.Max(offset, 0.0f) + "," +
                             "y: 0," +
                             "sizex: 1.1," +
                             "sizey: 1.1," +
                             "xanchor: 'left'," +
                             "yanchor: 'bottom'" +
                             "}");
                }
            }
            else
            {
                string skillName = cl.SkillId == SkillItem.WeaponSwapId ? "Weapon Swap" : skillList.GetName(cl.SkillId);
                if (skillName == "Dodge")
                {
                    skillIcon = GetLink("Dodge");
                }
                else if (skillName == "Resurrect")
                {
                    skillIcon = GetLink("Resurrect");
                }
                else if (skillName == "Bandage")
                {
                    skillIcon = GetLink("Bandage");
                }
                else if (cl.SkillId == SkillItem.WeaponSwapId)
                {
                    skillIcon = GetLink("Swap");
                }

                sw.Write("{" +
                         "source: '" + skillIcon + "'," +
                         "xref: 'x'," +
                         "yref: 'y'," +
                         "x: " + (cl.Time - phase.Start) / 1000f + "," +
                         "y: 0," +
                         "sizex: 1.1," +
                         "sizey: 1.1," +
                         "xanchor: 'left'," +
                         "yanchor: 'bottom'" +
                         "}");
            }
            if (!last)
            {
                sw.Write(",");
            }
        }
Пример #13
0
        private Dictionary <long, List <JsonSkill> > BuildRotation(List <CastLog> cls)
        {
            Dictionary <long, List <JsonSkill> > res = new Dictionary <long, List <JsonSkill> >();
            SkillData skillList = _log.SkillData;

            foreach (CastLog cl in cls)
            {
                GW2APISkill skill     = skillList.Get(cl.SkillId)?.ApiSkill;
                string      skillName = skill == null?skillList.GetName(cl.SkillId) : skill.name;

                if (cl.SkillId == SkillItem.WeaponSwapId)
                {
                    skillName = "Weapon Swap";
                }
                _skillNames[cl.SkillId] = skillName;
                JsonSkill jSkill = new JsonSkill
                {
                    Time     = (int)cl.Time,
                    Duration = cl.ActualDuration
                };
                if (_devMode)
                {
                    if (!_skillIcons.ContainsKey(cl.SkillId))
                    {
                        string skillIcon = "";
                        if (skill != null && cl.SkillId != -2)
                        {
                            skillIcon = skill.icon;
                        }
                        else
                        {
                            if (skillName == "Dodge")
                            {
                                skillIcon = HTMLHelper.GetLink("Dodge");
                            }
                            else if (skillName == "Resurrect")
                            {
                                skillIcon = HTMLHelper.GetLink("Resurrect");
                            }
                            else if (skillName == "Bandage")
                            {
                                skillIcon = HTMLHelper.GetLink("Bandage");
                            }
                            else if (cl.SkillId == SkillItem.WeaponSwapId)
                            {
                                skillIcon = HTMLHelper.GetLink("Swap");
                            }
                        }
                        if (skillIcon.Length > 0)
                        {
                            _skillIcons[cl.SkillId] = skillIcon;
                        }
                    }
                    int timeGained = 0;
                    if (cl.EndActivation == ParseEnum.Activation.CancelFire && cl.ActualDuration < cl.ExpectedDuration)
                    {
                        timeGained = cl.ExpectedDuration - cl.ActualDuration;
                    }
                    else if (cl.EndActivation == ParseEnum.Activation.CancelCancel)
                    {
                        timeGained = -cl.ActualDuration;
                    }
                    jSkill.ED = new JsonSkill.JsonExtraSkill()
                    {
                        UQ = cl.StartActivation == ParseEnum.Activation.Quickness ? 1 : 0,
                        TS = timeGained,
                        A  = skill != null && skill.slot == "Weapon_1" ? 1 : 0
                    };
                }
                if (res.TryGetValue(cl.SkillId, out var list))
                {
                    list.Add(jSkill);
                }
                else
                {
                    res[cl.SkillId] = new List <JsonSkill>()
                    {
                        jSkill
                    };
                }
            }

            return(res);
        }