コード例 #1
0
ファイル: LevelsClient.cs プロジェクト: mysidia/LiveSplit-Sid
        public IEnumerable <Leaderboard> GetRecords(string levelId,
                                                    int?top                  = null, bool skipEmptyLeaderboards = false,
                                                    int?elementsPerPage      = null,
                                                    LeaderboardEmbeds embeds = default(LeaderboardEmbeds))
        {
            var parameters = new List <string>()
            {
                embeds.ToString()
            };

            if (top.HasValue)
            {
                parameters.Add(string.Format("top={0}", top.Value));
            }
            if (skipEmptyLeaderboards)
            {
                parameters.Add("skip-empty=true");
            }
            if (elementsPerPage.HasValue)
            {
                parameters.Add(string.Format("max={0}", elementsPerPage.Value));
            }

            var uri = GetLevelsUri(string.Format("/{0}/records{1}",
                                                 Uri.EscapeDataString(levelId),
                                                 parameters.ToParameters()));

            return(baseClient.DoPaginatedRequest <Leaderboard>(uri,
                                                               x => Leaderboard.Parse(baseClient, x)));
        }
コード例 #2
0
        public IEnumerable <Leaderboard> GetRecords(
            string gameId,
            int?top = null,
            LeaderboardScope scope = LeaderboardScope.All,
            bool includeMiscellaneousCategories = true,
            bool skipEmptyLeaderboards          = false,
            int?elementsPerPage      = null,
            LeaderboardEmbeds embeds = default)
        {
            var parameters = new List <string>()
            {
                embeds.ToString()
            };

            if (top.HasValue)
            {
                parameters.Add(string.Format("top={0}", top.Value));
            }

            if (scope != LeaderboardScope.All)
            {
                parameters.Add(scope.ToParameter());
            }

            if (!includeMiscellaneousCategories)
            {
                parameters.Add("miscellaneous=false");
            }

            if (skipEmptyLeaderboards)
            {
                parameters.Add("skip-empty=true");
            }

            if (elementsPerPage.HasValue)
            {
                parameters.Add(string.Format("max={0}", elementsPerPage.Value));
            }

            var uri = GetGamesUri(string.Format("/{0}/records{1}",
                                                Uri.EscapeDataString(gameId),
                                                parameters.ToParameters()));

            return(baseClient.DoPaginatedRequest <Leaderboard>(uri,
                                                               x => Leaderboard.Parse(baseClient, x)));
        }
コード例 #3
0
        private Leaderboard getLeaderboard(
            string uri, int? top = null,
            string platformId = null, string regionId = null,
            EmulatorsFilter emulatorsFilter = EmulatorsFilter.NotSet, bool filterOutRunsWithoutVideo = false,
            TimingMethod? orderBy = null,
            IEnumerable<VariableValue> variableFilters = null,
            LeaderboardEmbeds embeds = default(LeaderboardEmbeds))
        {
            var parameters = new List<string>() { embeds.ToString() };

            if (top.HasValue)
                parameters.Add(string.Format("top={0}", top.Value));
            if (!string.IsNullOrEmpty(platformId))
                parameters.Add(string.Format("platform={0}", Uri.EscapeDataString(platformId)));
            if (!string.IsNullOrEmpty(regionId))
                parameters.Add(string.Format("region={0}", Uri.EscapeDataString(regionId)));
            if (emulatorsFilter != EmulatorsFilter.NotSet)
                parameters.Add(string.Format("emulators={0}",
                    emulatorsFilter == EmulatorsFilter.OnlyEmulators ? "true" : "false"));
            if (filterOutRunsWithoutVideo)
                parameters.Add("video-only=true");
            if (orderBy.HasValue)
            {
                var timing = orderBy.Value.ToAPIString();
                parameters.Add(string.Format("timing={0}", timing));
            }
            if (variableFilters != null)
            {
                foreach (var variableValue in variableFilters)
                {
                    parameters.Add(string.Format("var-{0}={1}",
                        Uri.EscapeDataString(variableValue.VariableID),
                        Uri.EscapeDataString(variableValue.ID)));
                }
            }

            var innerUri = GetLeaderboardsUri(string.Format("{0}{1}",
                uri,
                parameters.ToParameters()));

            var result = baseClient.DoRequest(innerUri);
            return Leaderboard.Parse(baseClient, result.data);
        }
コード例 #4
0
        public Leaderboard GetLeaderboardForFullGameCategory(
            string gameId, string categoryId,
            int? top = null,
            string platformId = null, string regionId = null,
            EmulatorsFilter emulatorsFilter = EmulatorsFilter.NotSet, bool filterOutRunsWithoutVideo = false,
            TimingMethod? orderBy = null,
            IEnumerable<VariableValue> variableFilters = null,
            LeaderboardEmbeds embeds = default(LeaderboardEmbeds))
        {
            var uri = string.Format("/{0}/category/{1}",
                Uri.EscapeDataString(gameId),
                Uri.EscapeDataString(categoryId));

            return getLeaderboard(uri,
                top,
                platformId, regionId,
                emulatorsFilter, filterOutRunsWithoutVideo,
                orderBy, variableFilters,
                embeds);
        }
コード例 #5
0
        public IEnumerable<Leaderboard> GetRecords(string categoryId,
            int? top = null, bool skipEmptyLeaderboards = false,
            int? elementsPerPage = null,
            LeaderboardEmbeds embeds = default(LeaderboardEmbeds))
        {
            var parameters = new List<string>() { embeds.ToString() };

            if (top.HasValue)
                parameters.Add(string.Format("top={0}", top.Value));
            if (skipEmptyLeaderboards)
                parameters.Add("skip-empty=true");
            if (elementsPerPage.HasValue)
                parameters.Add(string.Format("max={0}", elementsPerPage.Value));

            var uri = GetCategoriesUri(string.Format("/{0}/records{1}",
                Uri.EscapeDataString(categoryId),
                parameters.ToParameters()));

            return baseClient.DoPaginatedRequest<Leaderboard>(uri,
                x => Leaderboard.Parse(baseClient, x));
        }
コード例 #6
0
        public Leaderboard GetLeaderboardForFullGameCategory(
            string gameId, string categoryId,
            int?top           = null,
            string platformId = null, string regionId = null,
            EmulatorsFilter emulatorsFilter             = EmulatorsFilter.NotSet, bool filterOutRunsWithoutVideo = false,
            TimingMethod?orderBy                        = null, DateTime?filterOutRunsAfter = null,
            IEnumerable <VariableValue> variableFilters = null,
            LeaderboardEmbeds embeds                    = default(LeaderboardEmbeds))
        {
            var uri = string.Format("/{0}/category/{1}",
                                    Uri.EscapeDataString(gameId),
                                    Uri.EscapeDataString(categoryId));

            return(getLeaderboard(uri,
                                  top,
                                  platformId, regionId,
                                  emulatorsFilter, filterOutRunsWithoutVideo,
                                  orderBy, filterOutRunsAfter,
                                  variableFilters,
                                  embeds));
        }
コード例 #7
0
        private Leaderboard getLeaderboard(
            string uri, int?top                         = null,
            string platformId                           = null, string regionId = null,
            EmulatorsFilter emulatorsFilter             = EmulatorsFilter.NotSet, bool filterOutRunsWithoutVideo = false,
            TimingMethod?orderBy                        = null, DateTime?filterOutRunsAfter = null,
            IEnumerable <VariableValue> variableFilters = null,
            LeaderboardEmbeds embeds                    = default(LeaderboardEmbeds))
        {
            var parameters = new List <string>()
            {
                embeds.ToString()
            };

            if (top.HasValue)
            {
                parameters.Add(string.Format("top={0}", top.Value));
            }
            if (!string.IsNullOrEmpty(platformId))
            {
                parameters.Add(string.Format("platform={0}", Uri.EscapeDataString(platformId)));
            }
            if (!string.IsNullOrEmpty(regionId))
            {
                parameters.Add(string.Format("region={0}", Uri.EscapeDataString(regionId)));
            }
            if (emulatorsFilter != EmulatorsFilter.NotSet)
            {
                parameters.Add(string.Format("emulators={0}",
                                             emulatorsFilter == EmulatorsFilter.OnlyEmulators ? "true" : "false"));
            }
            if (filterOutRunsWithoutVideo)
            {
                parameters.Add("video-only=true");
            }
            if (orderBy.HasValue)
            {
                var timing = orderBy.Value.ToAPIString();
                parameters.Add(string.Format("timing={0}", timing));
            }
            if (filterOutRunsAfter.HasValue)
            {
                var date = filterOutRunsAfter.Value.ToString("yyyy-MM-dd", CultureInfo.InvariantCulture);
                parameters.Add(string.Format("date={0}",
                                             Uri.EscapeDataString(date)));
            }
            if (variableFilters != null)
            {
                foreach (var variableValue in variableFilters)
                {
                    if (variableValue != null)
                    {
                        parameters.Add(string.Format("var-{0}={1}",
                                                     Uri.EscapeDataString(variableValue.VariableID),
                                                     Uri.EscapeDataString(variableValue.ID)));
                    }
                }
            }

            var innerUri = GetLeaderboardsUri(string.Format("{0}{1}",
                                                            uri,
                                                            parameters.ToParameters()));

            var result = baseClient.DoRequest(innerUri);

            return(Leaderboard.Parse(baseClient, result.data));
        }