private void SetMatch() { var playersList = ReplayMatch.ReplayMatchPlayers.ToList(); var matchAwardDictionary = ReplayMatch.ReplayMatchAward.ToDictionary(x => x.PlayerId, x => x.Award); // load up correct build information HeroesIcons.LoadHeroesBuild(ReplayMatch.ReplayBuild); var playerParties = PlayerParties.FindPlayerParties(playersList); foreach (var player in playersList) { if (player.Team == 4) { continue; } MatchPlayerBase matchPlayerBase = new MatchPlayerBase(InternalService, Website, player); matchPlayerBase.SetPlayerInfo(player.IsAutoSelect, playerParties, matchAwardDictionary); // add to collection if (player.Team == 0) { MatchOverviewTeam1List.Add(matchPlayerBase); } else if (player.Team == 1) { MatchOverviewTeam2List.Add(matchPlayerBase); } if (player.PlayerId == UserProfile.PlayerId) { UserHero = player.Character; UserHeroImage = HeroesIcons.Heroes().GetHeroPortrait(player.Character); WinnerResult = player.IsWinner ? "Win" : "Loss"; } } GameMode = HeroesHelpers.GameModes.GetStringFromGameMode(ReplayMatch.GameMode); MapName = ReplayMatch.MapName; TimeStamp = ReplayMatch.TimeStamp.Value; GameLength = ReplayMatch.ReplayLength; Build = ReplayMatch.ReplayBuild; ReplayId = ReplayMatch.ReplayId; }
private void PlayerRelatedData() { Player[] players = GetPlayers(); foreach (var player in players.Select((value, index) => new { value, index })) { if (player.value == null) { continue; } ReplayAllHotsPlayer hotsPlayer = new ReplayAllHotsPlayer { BattleTagName = HeroesHelpers.BattleTags.GetBattleTagName(player.value.Name, player.value.BattleTag), BattleNetId = player.value.BattleNetId, BattleNetRegionId = player.value.BattleNetRegionId, BattleNetSubId = player.value.BattleNetSubId, BattleNetTId = player.value.BattleNetTId, AccountLevel = player.value.AccountLevel, LastSeen = Replay.Timestamp, LastSeenBefore = null, Seen = 1, }; long playerId; // check if player is already in the database, update if found, otherwise add a new record if (ReplaysDb.HotsPlayer.IsExistingRecord(ReplaysContext, hotsPlayer)) { playerId = ReplaysDb.HotsPlayer.UpdateRecord(ReplaysContext, hotsPlayer); } else { playerId = ReplaysDb.HotsPlayer.CreateRecord(ReplaysContext, hotsPlayer); } if (player.value.Character == null && Replay.GameMode == GameMode.Custom) { player.value.Team = 4; player.value.Character = "None"; ReplayMatchPlayer replayPlayer = new ReplayMatchPlayer { ReplayId = ReplayId, PlayerId = playerId, Character = player.value.Character, CharacterLevel = player.value.CharacterLevel, Difficulty = player.value.Difficulty.ToString(), Handicap = player.value.Handicap, IsAutoSelect = player.value.IsAutoSelect, IsSilenced = player.value.IsSilenced, IsWinner = player.value.IsWinner, MountAndMountTint = player.value.MountAndMountTint, PartyValue = player.value.PartyValue, PlayerNumber = -1, SkinAndSkinTint = player.value.SkinAndSkinTint, Team = player.value.Team, AccountLevel = player.value.AccountLevel, }; ReplaysDb.MatchPlayer.CreateRecord(ReplaysContext, replayPlayer); } else { if (!HeroesIcons.Heroes().HeroNameTranslation(player.value.Character, out string character)) { if (!AutoTranslateHeroNameByTalent(player.value.Talents, out character)) { throw new TranslationException(RetrieveAllMapAndHeroNames()); } } ReplayMatchPlayer replayPlayer = new ReplayMatchPlayer { ReplayId = ReplayId, PlayerId = playerId, Character = character, CharacterLevel = player.value.CharacterLevel, Difficulty = player.value.Difficulty.ToString(), Handicap = player.value.Handicap, IsAutoSelect = player.value.IsAutoSelect, IsSilenced = player.value.IsSilenced, IsWinner = player.value.IsWinner, MountAndMountTint = player.value.MountAndMountTint, PartyValue = player.value.PartyValue, PlayerNumber = player.index, SkinAndSkinTint = player.value.SkinAndSkinTint, Team = player.value.Team, AccountLevel = player.value.AccountLevel, }; ReplaysDb.MatchPlayer.CreateRecord(ReplaysContext, replayPlayer); AddScoreResults(player.value.ScoreResult, playerId); AddPlayerTalents(player.value.Talents, playerId, character); AddMatchAwards(player.value.ScoreResult.MatchAwards, playerId); } AddPlayerHeroes(player.value.PlayerCollectionDictionary, playerId); } // end foreach loop for players }