Exemple #1
0
        public async Task <BaseMatchResult> GetMatch(Enumeration.GameMode gameMode, Guid id, string gamerTag)
        {
            BaseMatchResult match = null;

            switch (gameMode)
            {
            case Enumeration.GameMode.Arena:
                var arenaMatch = await _statsRepository.GetArenaMatch(id);

                match = await GetMatchResult(arenaMatch, gamerTag);

                break;

            case Enumeration.GameMode.Campaign:
                var campaignMatch = await _statsRepository.GetCampaignMatch(id);

                match = GetMatchResult(campaignMatch, gamerTag);
                break;

            case Enumeration.GameMode.Custom:
                var customMatch = await _statsRepository.GetCustomMatch(id);

                match = await GetMatchResult(customMatch, gamerTag);

                break;

            case Enumeration.GameMode.Warzone:
                MatchEvents matchEvents = await _statsRepository.GetEventsForMatch(id);

                var warzoneMatch = await _statsRepository.GetWarzoneMatch(id);

                match = await GetMatchResult(warzoneMatch, gamerTag, matchEvents);

                break;

            default:
                return(null);
            }

            if (match != null)
            {
                match.GameMode = gameMode;
                match.Id       = id;
            }
            return(match);
        }
Exemple #2
0
        public async Task <string> GetMatch(Enumeration.GameMode gameMode, Guid id, string gamerTag)
        {
            if (_settings.CacheResults)
            {
                var result = await _db.FindAsync <MatchResultData>(id.ToString());

                if (result != null)
                {
                    return(result.Data);
                }
            }
            MatchEvents matchEvents = await _statsRepository.GetEventsForMatch(id);

            matchEvents.GameEvents = matchEvents.GameEvents.Where(e => e.EventName == Enumeration.EventType.Death).ToList();
            MatchResult match = null;

            switch (gameMode)
            {
            case Enumeration.GameMode.Arena:
                var arenaMatch = await _statsRepository.GetArenaMatch(id);

                match = await GetMatchResult(arenaMatch, gamerTag, matchEvents);

                break;

            case Enumeration.GameMode.Campaign:
                var campaignMatch = await _statsRepository.GetCampaignMatch(id);

                match = GetMatchResult(campaignMatch, gamerTag, matchEvents);
                break;

            case Enumeration.GameMode.Custom:
                var customMatch = await _statsRepository.GetCustomMatch(id);

                match = await GetMatchResult(customMatch, gamerTag, matchEvents);

                break;

            case Enumeration.GameMode.Warzone:
                var warzoneMatch = await _statsRepository.GetWarzoneMatch(id);

                match = await GetMatchResult(warzoneMatch, gamerTag, matchEvents);

                break;

            default:
                return(null);
            }

            if (match != null)
            {
                match.GameMode = gameMode;
                match.Id       = id;
            }

            var matchResult = new MatchResultData(id.ToString(), match);

            if (_settings.CacheResults)
            {
                _db.InsertAsync(matchResult);
                await _db.CommitChanges();
            }
            return(matchResult.Data);
        }