Exemple #1
0
        /// <summary>
        /// Consume a match.
        /// </summary>
        public async Task ConsumeMatchDetail(RiotSharp.MatchEndpoint.MatchDetail match)
        {
            long matchId = match.MatchId;

            Console.WriteLine("Processing match " + matchId);

            match.Participants.ForEach(participant =>
            {
                int championId = participant.ChampionId;
                bool isWinner  = match.Teams.FirstOrDefault(t => participant.TeamId == t.TeamId).Winner;

                ChampionWinCount.AddOrUpdate(championId,
                                             id => { return(new ChampionWinData()
                    {
                        Wins = isWinner ? 1 : 0, Matches = 1
                    }); },
                                             (id, winData) => { winData.Increment(isWinner); return(winData); }
                                             );
            });
        }
Exemple #2
0
        void SaveReplay(SmartWebClient client, int ChunkId)
        {
            //Sometimes chunk 1 isn't retrieved so get it again... it's like 7 kb so np
            // Download Chunk 0
            DownloadChunk(client, 1);

            // Download Current Chunk id
            DownloadChunk(client, ChunkId);

            if (OnStatusChanged != null)
            {
                OnStatusChanged("Saving replay");
            }

            // End Stats
            string stat = client.DownloadString(
                String.Format("{0}/consumer/{1}/{2}/{3}/token", Server + "/observer-mode/rest",
                              "endOfGameStats",
                              Region,
                              GameId));


            string sum = CurrentReplay.SummonerName;

            CurrentReplay.ParseStats(Convert.FromBase64String(stat));
            CurrentReplay.SummonerName = sum;

            // Last Chunk Info End
            string token = client.DownloadString(
                String.Format("{0}/consumer/{1}/{2}/{3}/0/token", Server + "/observer-mode/rest",
                              "getLastChunkInfo",
                              Region,
                              GameId));

            CurrentReplay.ParseLastChunkInfo(token);

            // Last game meta data
            token = client.DownloadString(
                String.Format("{0}/consumer/{1}/{2}/{3}/token", this.Server + "/observer-mode/rest",
                              "getGameMetaData",
                              Region,
                              GameId));
            ReplayInfo flags = ReplayInfo.StandardFormat | ReplayInfo.Ghostblade;


            if (CurrentReplay.IsPBE)
            {
                flags |= ReplayInfo.PBE;
            }


            if (string.IsNullOrEmpty(CurrentReplay.SummonerName) || CurrentReplay.SummonerName == "Spectator")
            {
                flags |= ReplayInfo.Spectator;
                if (CurrentReplay.GameStats.TeamPlayerParticipantStats.Count > 0)
                {
                    CurrentReplay.SummonerName = CurrentReplay.GameStats.TeamPlayerParticipantStats[0].SummonerName;
                }

                else if (CurrentReplay.GameStats.OtherTeamPlayerParticipantStats.Count > 0)
                {
                    CurrentReplay.SummonerName = CurrentReplay.GameStats.OtherTeamPlayerParticipantStats[0].SummonerName;
                }
            }
            CurrentReplay.ParseMetaData(token);
            CurrentReplay.MetaData.clientBackFetchingEnabled = true;
            CurrentReplay.MetaData.clientBackFetchingFreq    = 50;
            CurrentReplay.MetaData.pendingAvailableChunkInfo.Clear();
            CurrentReplay.MetaData.pendingAvailableKeyFrameInfo.Clear();
            if (!CurrentReplay.IsPBE)
            {
                try
                {
                    RiotSharp.MatchEndpoint.MatchDetail det = API.GetMatch(RiotTool.PlatformToRegion(Region), GameId); // TODO ADD COMPRESSION FLAG
                    CurrentReplay.PlayerInfos.Map   = (byte)det.MapType;
                    CurrentReplay.PlayerInfos.Queue = (byte)det.QueueType;
                }
                catch
                {
                    CurrentReplay.PlayerInfos.Map   = 11;
                    CurrentReplay.PlayerInfos.Queue = 4;
                }
            }
            try
            {
                CurrentReplay.Save(CurrentReplay.Signer != null, flags);
            }
            catch (Exception ex)
            {
                if (OnFailedToSave != null)
                {
                    OnFailedToSave(ex);
                }
            }
            if (OnReplayRecorded != null)
            {
                OnReplayRecorded();
            }

            Recording = false;
        }