Example #1
0
        public Player(dynamic o, dynamic timeline, string patch)
        {
            ParticipantId    = o.participantId;
            SelectedChampion = Caches.ChampionsCache.Get((int)o.championId.Value);
            Rank             = (string)o.highestAchievedSeasonTier.Value;
            Runes            = new List <Rune>();
            if (o.runes != null)
            {
                foreach (var rune in o.runes)
                {
                    for (int i = 0; i < (int)rune.rank.Value; i++)
                    {
                        Runes.Add(Caches.RunesCache.Get((int)rune.runeId.Value));
                    }
                }
            }
            Role               = EnumHelpers.ParseRole((string)o.timeline.role);
            Lane               = EnumHelpers.ParseLane((string)o.timeline.lane);
            Finalstats         = new FinalStats(o.stats, patch);
            Finalstats.TotalMr = (int)(Finalstats.Items.Sum(item => item.ItemStats.MR) + SelectedChampion.Stat.MagicResist + SelectedChampion.Stat.MagicResistPerLv * (int)o.stats.champLevel.Value + Runes.Sum(r => r.MagicResist) + Runes.Sum(r => r.MagicResistPerLevel) * (int)o.stats.champLevel.Value);
            Finalstats.TotalAp = (int)(Finalstats.Items.Sum(item => item.ItemStats.AP) + Runes.Sum(r => r.Ap) + Runes.Sum(r => r.ApPerLevel) * (int)o.stats.champLevel.Value);
            if (Finalstats.Items.Any(i => i.Name == "Rabadon's Deathcap"))
            {
                if (patch.StartsWith("5.11"))
                {
                    Finalstats.TotalAp = (int)(Finalstats.TotalAp * 1.30);
                }
                else
                {
                    Finalstats.TotalAp = (int)(Finalstats.TotalAp * 1.35);
                }
            }
            TimeLine     = new List <TimeLineFrame>();
            ItemTimeLine = new List <ItemTimeLineFrame>();

            if (timeline.frame != null)
            {
                foreach (var frame in timeline.frames)
                {
                    try
                    {
                        foreach (var participantFrame in frame.participantFrames)
                        {
                            try
                            {
                                if (participantFrame.Value.participantId == ParticipantId)
                                {
                                    TimeLineFrame t = new TimeLineFrame(participantFrame.Value, (int)frame.timestamp.Value);
                                    TimeLine.Add(t);
                                    break;
                                }
                            }
                            catch { }
                        }
                    }
                    catch { }
                    try
                    {
                        foreach (var eventframe in frame.events)
                        {
                            try
                            {
                                if (eventframe.participantId != null)
                                {
                                    if (eventframe.participantId.Value == ParticipantId)
                                    {
                                        string s = eventframe.eventType.Value;
                                        if (s.Contains("ITEM"))
                                        {
                                            ItemTimeLineFrame t = new ItemTimeLineFrame(eventframe, (int)frame.timestamp.Value);
                                            ItemTimeLine.Add(t);
                                        }
                                    }
                                }
                            }
                            catch
                            {
                            }
                        }
                    }
                    catch { }
                }
            }
        }
Example #2
0
        public Player(dynamic o, dynamic timeline, string patch)
        {
            ParticipantId = o.participantId;
            SelectedChampion = Caches.ChampionsCache.Get((int)o.championId.Value);
            Rank = (string)o.highestAchievedSeasonTier.Value;
            Runes = new List<Rune>();
            if (o.runes != null)
            {
                foreach (var rune in o.runes)
                {
                    for (int i = 0; i < (int)rune.rank.Value; i++)
                        Runes.Add(Caches.RunesCache.Get((int)rune.runeId.Value));
                }
            }
            Role = EnumHelpers.ParseRole((string)o.timeline.role);
            Lane = EnumHelpers.ParseLane((string)o.timeline.lane);
            Finalstats = new FinalStats(o.stats, patch);
            Finalstats.TotalMr = (int)(Finalstats.Items.Sum(item => item.ItemStats.MR) + SelectedChampion.Stat.MagicResist + SelectedChampion.Stat.MagicResistPerLv * (int)o.stats.champLevel.Value + Runes.Sum(r => r.MagicResist) + Runes.Sum(r => r.MagicResistPerLevel) * (int)o.stats.champLevel.Value);
            Finalstats.TotalAp = (int)(Finalstats.Items.Sum(item => item.ItemStats.AP) + Runes.Sum(r => r.Ap) + Runes.Sum(r => r.ApPerLevel) * (int)o.stats.champLevel.Value);
            if (Finalstats.Items.Any(i => i.Name == "Rabadon's Deathcap"))
            {
                if (patch.StartsWith("5.11"))
                    Finalstats.TotalAp = (int)(Finalstats.TotalAp * 1.30);
                else
                    Finalstats.TotalAp = (int)(Finalstats.TotalAp * 1.35);
            }
            TimeLine = new List<TimeLineFrame>();
            ItemTimeLine = new List<ItemTimeLineFrame>();

            if (timeline.frame != null)
            {
                foreach (var frame in timeline.frames)
                {
                    try
                    {
                        foreach (var participantFrame in frame.participantFrames)
                        {
                            try
                            {
                                if (participantFrame.Value.participantId == ParticipantId)
                                {
                                    TimeLineFrame t = new TimeLineFrame(participantFrame.Value, (int)frame.timestamp.Value);
                                    TimeLine.Add(t);
                                    break;
                                }
                            }
                            catch { }
                        }
                    }
                    catch { }
                    try
                    {
                        foreach (var eventframe in frame.events)
                        {
                            try
                            {
                                if (eventframe.participantId != null)
                                {
                                    if (eventframe.participantId.Value == ParticipantId)
                                    {
                                        string s = eventframe.eventType.Value;
                                        if (s.Contains("ITEM"))
                                        {
                                            ItemTimeLineFrame t = new ItemTimeLineFrame(eventframe, (int)frame.timestamp.Value);
                                            ItemTimeLine.Add(t);
                                        }
                                    }
                                }
                            }
                            catch
                            {

                            }
                        }
                    }
                    catch { }
                }
            }
        }