Beispiel #1
0
        /// <summary>
        /// Creates a LCLeaderboard with a statistic name.
        /// </summary>
        /// <param name="statisticName"></param>
        /// <param name="order"></param>
        /// <param name="updateStrategy"></param>
        /// <param name="versionChangeInterval"></param>
        /// <returns></returns>
        public static async Task <LCLeaderboard> CreateLeaderboard(string statisticName,
                                                                   LCLeaderboardOrder order = LCLeaderboardOrder.Descending,
                                                                   LCLeaderboardUpdateStrategy updateStrategy = LCLeaderboardUpdateStrategy.Better,
                                                                   LCLeaderboardVersionChangeInterval versionChangeInterval = LCLeaderboardVersionChangeInterval.Week)
        {
            if (string.IsNullOrEmpty(statisticName))
            {
                throw new ArgumentNullException(nameof(statisticName));
            }
            Dictionary <string, object> data = new Dictionary <string, object> {
                { "statisticName", statisticName },
                { "order", order.ToString().ToLower() },
                { "versionChangeInterval", versionChangeInterval.ToString().ToLower() },
                { "updateStrategy", updateStrategy.ToString().ToLower() },
            };
            string path = "leaderboard/leaderboards";
            Dictionary <string, object> result = await LCCore.HttpClient.Post <Dictionary <string, object> >(path,
                                                                                                             data : data);

            LCLeaderboard leaderboard = new LCLeaderboard();

            leaderboard.Merge(result);
            return(leaderboard);
        }
Beispiel #2
0
        /// <summary>
        /// Gets the LCLeaderboard with the given name.
        /// </summary>
        /// <param name="statisticName"></param>
        /// <returns></returns>
        public static Task <LCLeaderboard> GetLeaderboard(string statisticName)
        {
            LCLeaderboard leaderboard = CreateWithoutData(statisticName);

            return(leaderboard.Fetch());
        }