Beispiel #1
0
        public GameState(MatchDetail match)
        {
            // TODO: track champion lanes/roles/etc.
            Teams = match.Teams.ToDictionary(
                t => t.TeamId,
                t => new TeamState(t.TeamId,
                    match.Participants.Where(p => p.TeamId == t.TeamId).Select(p => p.ChampionId)));

            ParticipantMap = match.Participants.ToDictionary(
                p => p.ParticipantId,
                p => p.ChampionId);
        }
        void LoadEvents()
        {
            try
            {
                string cachefile = Application.StartupPath + @"\Temp\" + META.gameKey.gameId + "-" + META.gameKey.platformId + ".cached";


                StringBuilder sb = new StringBuilder();
                RiotSharp.StaticDataEndpoint.ItemListStatic items = RiotSharp.StaticRiotApi.GetInstance(SettingsManager.Settings.ApiKey).GetItems(RiotTool.PlatformToRegion(META.gameKey.platformId));
                RiotSharp.MatchEndpoint.MatchDetail         m     = Program.MainFormInstance.API.GetMatch(RiotTool.PlatformToRegion(META.gameKey.platformId), META.gameKey.gameId, true, cachefile, true);
                foreach (Participant p in m.Participants)
                {
                    parts.Add(p.ParticipantId, FindParticipant(p.ChampionId, p.TeamId));
                }


                foreach (Frame f in m.Timeline.Frames)
                {
                    sb.AppendLine("***" + string.Format("{0:0}:{1:00}", f.Timestamp.Minutes, f.Timestamp.Seconds) + "***********************************************************************************");
                    if (f.Events != null)
                    {
                        foreach (Event ev in f.Events)
                        {
                            sb.AppendLine(EventToString(ev, items));
                        }
                    }
                }
                metroTabControl1.Invoke(new MethodInvoker(delegate
                {
                    nsTextBox1.Text = sb.ToString();

                    metroTabControl1.TabPages.Add(metroTabPage4);
                    metroTabControl1.SelectedIndex = 0;
                }));
                sb.Length = 0;
                sb        = null;
            }
            catch
            {
            }
        }
Beispiel #3
0
        public static BuildSet GetMatchBuild(MatchDetail match, Participant participant)
        {
            if (PotentialUpgrades == null) InitializePotentialUpgrades();
            var set = new BuildSet() { HasMatchData = true };
            set.TimeSince = GetTimeSince(match.MatchCreation);

            var timeline = match.Timeline;
            var allPurchasedItems = getAllPurchasedItems(timeline, participant.ParticipantId);

            set.InitialPurchase = getStartingItems(timeline, participant.ParticipantId);
            set.FinalBuild = getFinalBuild(participant);
            set.RushItem = getRushItem(allPurchasedItems.ToList(), set.InitialPurchase.Items.ToList());

            var allConsumables = getConsumables(allPurchasedItems.ToList());
            if(allConsumables.Count > 0) set.Consumables = (getPurchaseSet("Consumables", allConsumables, includePrice: false));

            set.FullBuild = set.FinalBuild.Items.Count == 7 && !(set.FinalBuild.Items.Any(x => PotentialUpgrades.ContainsKey(x.Id.ToString())));
            set.Id = match.MatchId;
            set.MatchDataFetched = true;
            return set;
        }
Beispiel #4
0
 /// <summary>
 /// Save a match.
 /// </summary>
 public static void SaveMatch(MatchDetail match)
 {
     string filename = GetMatchPath(match);
     CompressedJson.WriteToFile(filename, match);
 }
Beispiel #5
0
 /// <summary>
 /// Get the path to a match file.
 /// </summary>
 public static string GetMatchPath(MatchDetail match)
 {
     return GetMatchPath(match.MatchVersion, match.MatchId);
 }
Beispiel #6
0
 private PlayedMatch ConvertPlayedMatch(MatchDetail match)
 {
     Func<RiotSharp.MatchEndpoint.Participant, Shared.Models.MatchHistory.Participant> convertParticipant = f => new Shared.Models.MatchHistory.Participant
     {
         SummonerId = match.ParticipantIdentities.First(d => d.ParticipantId == f.ParticipantId).Player.SummonerId,
         Lane = this.ConvertLane(f.Timeline.Lane),
         Role = this.ConvertRole(f.Timeline.Role),
         ChampionId = f.ChampionId,
         Assists = f.Stats.Assists,
         Kills = f.Stats.Kills,
         Deaths = f.Stats.Deaths,
         Creeps = f.Stats.MinionsKilled,
         DestroyedWards = f.Stats.WardsKilled,
         PlacedWards = f.Stats.WardsPlaced,
     };
     return new PlayedMatch
     {
         Duration = match.MatchDuration,
         CreationDate = match.MatchCreation,
         MatchId = match.MatchId,
         PurpleTeam = new Shared.Models.MatchHistory.Team
         {
             Winner = match.Teams.First(f => f.TeamId == 200).Winner,
             Participants = match.Participants
                 .Where(f => f.TeamId == 200)
                 .Select(convertParticipant)
                 .ToList()
         },
         BlueTeam = new Shared.Models.MatchHistory.Team
         {
             Winner = match.Teams.First(f => f.TeamId == 100).Winner,
             Participants = match.Participants
                 .Where(f => f.TeamId == 100)
                 .Select(convertParticipant)
                 .ToList()
         },
         Region = this.ConvertRegion(match.Region)
     };
 }