Exemple #1
0
        public static UploadMetaData Generate(GameMetaData gameMetaData, GameStats game)
        {
            var metaData = new UploadMetaData();
            var players  = GetPlayerInfo(game);

            if (players != null)
            {
                if (game.GameType == GameType.GT_BATTLEGROUNDS)
                {
                    metaData.Players = players;
                }
                else
                {
                    metaData.Player1 = players.FirstOrDefault(x => x.Id == 1);
                    metaData.Player2 = players.FirstOrDefault(x => x.Id == 2);
                }
            }
            if (!string.IsNullOrEmpty(gameMetaData?.ServerInfo?.Address))
            {
                metaData.ServerIp = gameMetaData.ServerInfo.Address;
            }
            if (gameMetaData?.ServerInfo?.Port > 0)
            {
                metaData.ServerPort = gameMetaData.ServerInfo.Port.ToString();
            }
            if (gameMetaData?.ServerInfo?.GameHandle > 0)
            {
                metaData.GameHandle = gameMetaData.ServerInfo.GameHandle.ToString();
            }
            if (gameMetaData?.ServerInfo?.ClientHandle > 0)
            {
                metaData.ClientHandle = gameMetaData.ServerInfo.ClientHandle.ToString();
            }
            if (!string.IsNullOrEmpty(gameMetaData?.ServerInfo?.SpectatorPassword))
            {
                metaData.SpectatePassword = gameMetaData.ServerInfo.SpectatorPassword;
            }
            if (!string.IsNullOrEmpty(gameMetaData?.ServerInfo?.AuroraPassword))
            {
                metaData.AuroraPassword = gameMetaData.ServerInfo.AuroraPassword;
            }
            if (!string.IsNullOrEmpty(gameMetaData?.ServerInfo?.Version))
            {
                metaData.ServerVersion = gameMetaData.ServerInfo.Version;
            }
            if (game?.StartTime > DateTime.MinValue)
            {
                metaData.MatchStart = game.StartTime.ToString("o");
            }
            if (game != null)
            {
                metaData.GameType = game.GameType != GameType.GT_UNKNOWN ? (int)HearthDbConverter.GetBnetGameType(game.GameType, game.Format) : (int)HearthDbConverter.GetGameType(game.GameMode, game.Format);
            }
            if (game?.Format != null)
            {
                metaData.Format = (int)HearthDbConverter.GetFormatType(game.Format);
            }
            metaData.SpectatorMode    = game?.GameMode == GameMode.Spectator;
            metaData.Reconnected      = gameMetaData?.Reconnected ?? false;
            metaData.Resumable        = gameMetaData?.ServerInfo?.Resumable ?? false;
            metaData.FriendlyPlayerId = game?.FriendlyPlayerId > 0 ? game.FriendlyPlayerId : (int?)null;
            var scenarioId = game?.ScenarioId ?? gameMetaData?.ServerInfo?.Mission;

            if (scenarioId > 0)
            {
                metaData.ScenarioId = scenarioId;
            }
            var build = gameMetaData?.HearthstoneBuild;

            if (build == null || build == 0)
            {
                build = game?.HearthstoneBuild;
            }
            if ((build == null || build == 0) && game != null)
            {
                build = BuildDates.GetByDate(game.StartTime);
            }
            if (build > 0)
            {
                metaData.HearthstoneBuild = build;
            }
            if (game?.BrawlSeasonId > 0)
            {
                metaData.BrawlSeason = game.BrawlSeasonId;
            }
            if (game?.RankedSeasonId > 0)
            {
                metaData.LadderSeason = game.RankedSeasonId;
            }
            if (gameMetaData?.TwitchVodData != null)
            {
                metaData.TwitchVod = gameMetaData.TwitchVodData;
            }
            if (game?.LeagueId > 0)
            {
                metaData.LeagueId = game.LeagueId;
            }
            return(metaData);
        }
Exemple #2
0
        public static UploadMetaData Generate(string[] log, GameMetaData gameMetaData, GameStats game)
        {
            var metaData   = new UploadMetaData();
            var playerInfo = GetPlayerInfo(log, game);

            if (playerInfo != null)
            {
                metaData.Player1 = playerInfo.Player1;
                metaData.Player2 = playerInfo.Player2;
            }
            if (!string.IsNullOrEmpty(gameMetaData?.ServerInfo?.Address))
            {
                metaData.ServerIp = gameMetaData.ServerInfo.Address;
            }
            if (gameMetaData?.ServerInfo?.Port > 0)
            {
                metaData.ServerPort = gameMetaData.ServerInfo.Port.ToString();
            }
            if (gameMetaData?.ServerInfo?.GameHandle > 0)
            {
                metaData.GameHandle = gameMetaData.ServerInfo.GameHandle.ToString();
            }
            if (gameMetaData?.ServerInfo?.ClientHandle > 0)
            {
                metaData.ClientHandle = gameMetaData.ServerInfo.ClientHandle.ToString();
            }
            if (!string.IsNullOrEmpty(gameMetaData?.ServerInfo?.SpectatorPassword))
            {
                metaData.SpectatePassword = gameMetaData.ServerInfo.SpectatorPassword;
            }
            if (!string.IsNullOrEmpty(gameMetaData?.ServerInfo?.AuroraPassword))
            {
                metaData.AuroraPassword = gameMetaData.ServerInfo.AuroraPassword;
            }
            if (!string.IsNullOrEmpty(gameMetaData?.ServerInfo?.Version))
            {
                metaData.ServerVersion = gameMetaData.ServerInfo.Version;
            }
            if (game?.StartTime > DateTime.MinValue)
            {
                metaData.MatchStart = game.StartTime.ToString("o");
            }
            if (game != null)
            {
                metaData.GameType = game.GameType != GameType.GT_UNKNOWN ? (int)HearthDbConverter.GetBnetGameType(game.GameType, game.Format) : (int)HearthDbConverter.GetGameType(game.GameMode, game.Format);
            }
            if (game?.Format != null)
            {
                metaData.Format = (int)HearthDbConverter.GetFormatType(game.Format);
            }
            metaData.SpectatorMode    = game?.GameMode == GameMode.Spectator;
            metaData.Reconnected      = gameMetaData?.Reconnected ?? false;
            metaData.Resumable        = gameMetaData?.ServerInfo?.Resumable ?? false;
            metaData.FriendlyPlayerId = game?.FriendlyPlayerId > 0 ? game.FriendlyPlayerId : (playerInfo?.FriendlyPlayerId > 0 ? playerInfo?.FriendlyPlayerId : null);
            var scenarioId = game?.ScenarioId ?? gameMetaData?.ServerInfo?.Mission;

            if (scenarioId > 0)
            {
                metaData.ScenarioId = scenarioId;
            }
            var build = gameMetaData?.HearthstoneBuild ?? game?.HearthstoneBuild ?? (game != null ? BuildDates.GetByDate(game.StartTime) : null);

            if (build > 0)
            {
                metaData.HearthstoneBuild = build;
            }
            if (game?.BrawlSeasonId > 0)
            {
                metaData.BrawlSeason = game.BrawlSeasonId;
            }
            if (game?.RankedSeasonId > 0)
            {
                metaData.LadderSeason = game.RankedSeasonId;
            }
            return(metaData);
        }