private void FillMatchLogData(MatchDetailsResponse response, MatchTimeLineResponse timelineResponse, MatchResultDbClass matchResult) { var participantStats = response.participants; if (participantStats != null) { foreach (var participantStat in participantStats) { var entry = new ParticipantStatsEntry() { ParticipantId = participantStat.participantId, ChampionId = participantStat.championId, TeamId = participantStat.teamId, Spell1 = participantStat.spell1Id, Spell2 = participantStat.spell2Id, Role = participantStat.timeline.role, Lane = participantStat.timeline.lane, Kills = participantStat.stats.kills, Deaths = participantStat.stats.deaths, Assists = participantStat.stats.assists, TotalMinionsKilled = participantStat.stats.totalMinionsKilled, TotalDamageDealt = participantStat.stats.totalDamageDealt, TotalDamageDealtToChampions = participantStat.stats.totalDamageDealtToChampions, MagicDamageDealt = participantStat.stats.magicDamageDealt, MagicDamageDealtToChampions = participantStat.stats.magicDamageDealtToChampions, PhysicalDamageDealt = participantStat.stats.physicalDamageDealt, PhysicalDamageDealtToChampions = participantStat.stats.physicalDamageDealtToChampions, GoldEarned = participantStat.stats.goldEarned, GoldSpent = participantStat.stats.goldSpent, ChampLevel = participantStat.stats.champLevel, WardsPlaced = participantStat.stats.wardsPlaced, WardsKilled = participantStat.stats.wardsKilled, }; matchResult.ParticipantStats.Add(entry); } } else { throw new ArgumentNullException(nameof(participantStats)); } var frames = timelineResponse.frames; var interval = timelineResponse.frameInterval; var kills = new int[10]; var deaths = new int[10]; var assists = new int[10]; var uprightTurretsStatus = 2047; var dwnleftTurretsStatus = 2047; var uprightInhibitorsStatus = 7; var dwnleftInhibitorsStatus = 7; foreach (var frame in frames) { var gold = new int[10]; var logEntry = new MatchTimeLineEntry { timestamp = TimeSpan.FromMilliseconds(frame.timestamp), }; foreach (var frameParticipantFrame in frame.participantFrames) { var participant = frameParticipantFrame.Key; // какой чувак var gld = frameParticipantFrame.Value.totalGold; gold[participant - 1] = gld; } logEntry.gold = gold.ToArray(); matchResult.MatchLog.Add(logEntry); var frameEvents = frame.events; if (frameEvents != null && frameEvents.Length > 0) { foreach (var evnt in frameEvents) { ProcessMatchEvent( matchResult, evnt, logEntry, ref kills, ref deaths, ref assists, ref gold, ref dwnleftTurretsStatus, ref dwnleftInhibitorsStatus, ref uprightTurretsStatus, ref uprightInhibitorsStatus); } } logEntry.DWNLEFT_InhibitorsStatus = dwnleftInhibitorsStatus; logEntry.DWNLEFT_TurretsStatus = dwnleftTurretsStatus; logEntry.UPRIGHT_InhibitorsStatus = uprightInhibitorsStatus; logEntry.UPRIGHT_TurretsStatus = uprightTurretsStatus; logEntry.kills = kills.ToArray(); logEntry.deaths = deaths.ToArray(); logEntry.assists = assists.ToArray(); } }
public bool ProcessClassicMatchResultsResponse(MatchDetailsResponse response, MatchTimeLineResponse timelineResponse, DbAdapterBase Adapter) { if (response == null) { LoggersAdapter.Warn($"Пришел пустой {nameof(response)}"); throw new ArgumentNullException(nameof(response)); } if (timelineResponse == null) { LoggersAdapter.Warn($"Пришел пустой {nameof(timelineResponse)}"); throw new ArgumentNullException(nameof(timelineResponse)); } var teamDlStats = response.teams[0]; var teamUrStats = response.teams[1]; var matchResult = new MatchResultDbClass { Duration = TimeSpan.FromSeconds(response.gameDuration), GameType = response.gameType, Id = response.gameId, }; FillCommonResultData(teamDlStats, teamUrStats, matchResult); FillMatchLogData(response, timelineResponse, matchResult); if (SaveMatchInfo(matchResult, Adapter)) { return(true); } LoggersAdapter.Info($"Не удалось сохранить информацию о матче в БД. Матч {response.gameId}"); return(false); }