public void CanHandleNoResultsForKey(LeaderboardFilterType filterType, int userIndex, int offset, int limit)
        {
            // Arrange
            var token = $"{System.Reflection.MethodBase.GetCurrentMethod().Name}_{filterType}_{userIndex}_{offset}_{limit}";

            TestNoStandingsResult(token, filterType, userIndex, offset, limit);
        }
Ejemplo n.º 2
0
 public void OnTypeChange()
 {
     selectedType++;
     if (selectedType >= LeaderboardFilterType.MAX)
         selectedType = 0;
     UpdateLeaderboardsUI(typesList.transform, (int)selectedType);
     linkedGameController.RefreshLeaderboardsData(selectedWorld, selectedType);
 }
Ejemplo n.º 3
0
 /// <summary>
 /// Gathers the current standings in relation to the actor with the id provided using the filter, multiplePerActor, pageNumber and positionCount settings provided for the leaderboard which uses the token provided.
 /// </summary>
 /// <param name="token">The unique identifier for the Leaderboard</param>
 /// <param name="actorId">The id of the actor the current standings are being gathered for</param>
 /// <param name="filter">The Filter type to order standings by</param>
 /// <param name="multiplePerActor">If the leaderboard allows for actors to appear multiple times</param>
 /// <param name="pageNumber">The page offset to gather positions from</param>
 /// <param name="positionCount">The amount of positions to gather standings for</param>
 /// <param name="standings">Callback which returns the Leaderboard standings</param>
 /// <param name="globalLeaderboard">**Optional** Whether the leaderboard is global or in game scope. (default: false)</param>
 public void GetLeaderboardStandings(string token, int actorId, LeaderboardFilterType filter, bool multiplePerActor, int pageNumber, int positionCount, Action <List <LeaderboardStandingsResponse> > standings, bool globalLeaderboard = false)
 {
     GetLeaderboardDetails(token,
                           leaderboard =>
     {
         GetLeaderboardStandings(leaderboard, actorId, filter, multiplePerActor, pageNumber, positionCount, standings);
     }, globalLeaderboard);
 }
        private void TestNoStandingsResult(string token, LeaderboardFilterType filterType, int userIndex, int offset, int limit)
        {
            // Arrange
            var leaderboard = CreateLeaderboard(token, EvaluationDataType.Long, LeaderboardType.Cumulative, $"{token}_ExpectedNoDataMatch");

            // Act
            var filter    = CreateLeaderboardStandingsRequest(leaderboard.Token, leaderboard.GameId, filterType, Fixture.SortedUsers[userIndex].Id, offset, limit);
            var standings = _leaderboardCoreController.GetStandings(leaderboard, filter).ToArray();

            // Assert
            Assert.Empty(standings);
        }
Ejemplo n.º 5
0
    public IEnumerator LoadToUI(World world, LeaderboardFilterType filter)
    {
        WorldRecordData worldUserData = localDataController.GetWorldRecord(world.name);

        ui.SetAsLoading();
        ui.ClearScoresList();
        if (worldUserData != null)
            ui.PushScore(1, "YOU", worldUserData.topSpeed, worldUserData.topTime);
        else
            ui.PushScore(-1, "No scores available", 0.0f, 0.0f);
        ui.ShowScores();
        yield return true;
    }
Ejemplo n.º 6
0
 /// <summary>
 /// Gathers information for leaderboard and displays the interface if it has been provided.
 /// </summary>
 /// <param name="token">The unique identifier for the Leaderboard</param>
 /// <param name="filter">The Filter type to order standings by</param>
 /// <param name="multiplePerActor">If the leaderboard allows for actors to appear multiple times</param>
 /// <param name="pageNumber">**Optional** The page number to start from (default: 0)</param>
 /// <param name="globalLeaderboard">**Optional** Whether the leaderboard is global or in game scope. (default: false)</param>
 public void Display(string token, LeaderboardFilterType filter, bool multiplePerActor, int pageNumber = 0, bool globalLeaderboard = false)
 {
     _currentFilter     = filter;
     _multiplePerActor  = multiplePerActor;
     CurrentLeaderboard = null;
     CurrentStandings.Clear();
     GetLeaderboardDetails(token,
                           leaderboard =>
     {
         if (leaderboard != null)
         {
             CurrentLeaderboard = leaderboard;
             GetCurrentLeaderboardStandings(pageNumber,
                                            result =>
             {
                 _interface?.Display(result);
             });
         }
         else
         {
             _interface?.Display(false);
         }
     }, globalLeaderboard);
 }
Ejemplo n.º 7
0
        public static Request <Models.LeaderboardEntryList> GetEntries(string leaderboardName, int limit, LeaderboardFilterType filter, LeaderboardStartAt startAt)
        {
            if (Core.IsInitialized())
            {
                return(new Request <Models.LeaderboardEntryList>(CAPI.ovr_Leaderboard_GetEntries(leaderboardName, limit, filter, startAt)));
            }

            return(null);
        }
Ejemplo n.º 8
0
 /// <summary>
 /// Change the leaderboard filter currently being used
 /// </summary>
 /// <param name="filter">The filter to use for display leaderboard standings</param>
 protected void UpdateFilter(LeaderboardFilterType filter)
 {
     SUGARManager.leaderboard.Display(SUGARManager.leaderboard.CurrentLeaderboard.Token, filter, SUGARManager.leaderboard.MultiplePerActor);
 }
        private StandingsRequest CreateLeaderboardStandingsRequest(string token, int gameId, LeaderboardFilterType filterType, int actorId = 0, int limit = 0, int offset = 0)
        {
            var filter = new StandingsRequest
            {
                LeaderboardToken      = token,
                GameId                = gameId,
                LeaderboardFilterType = filterType,
                PageLimit             = limit,
                PageOffset            = offset
            };

            if (actorId != 0)
            {
                filter.ActorId = actorId;
            }

            return(filter);
        }
Ejemplo n.º 10
0
        /// <summary>
        /// Gathers the current standings in relation to the actor with the id provided using the filter, multiplePerActor, pageNumber and positionCount settings provided for the leaderboard provided.
        /// </summary>
        /// <param name="leaderboard">The leaderboard standings are being gathered for</param>
        /// <param name="actorId">The id of the actor the current standings are being gathered for</param>
        /// <param name="filter">The Filter type to order standings by</param>
        /// <param name="multiplePerActor">If the leaderboard allows for actors to appear multiple times</param>
        /// <param name="pageNumber">The page offset to gather positions from</param>
        /// <param name="positionCount">The amount of positions to gather standings for</param>
        /// <param name="standings">Callback which returns the Leaderboard standings</param>
        public void GetLeaderboardStandings(LeaderboardResponse leaderboard, int actorId, LeaderboardFilterType filter, bool multiplePerActor, int pageNumber, int positionCount, Action <List <LeaderboardStandingsResponse> > standings)
        {
            SUGARManager.unity.StartSpinner();
            if (SUGARManager.UserSignedIn && leaderboard != null)
            {
                var request = new LeaderboardStandingsRequest
                {
                    LeaderboardToken      = leaderboard.Token,
                    GameId                = leaderboard.GameId,
                    ActorId               = actorId,
                    LeaderboardFilterType = filter,
                    PageLimit             = positionCount,
                    PageOffset            = pageNumber,
                    MultiplePerActor      = filter != LeaderboardFilterType.Near ? multiplePerActor : false
                };

                SUGARManager.client.Leaderboard.CreateGetLeaderboardStandingsAsync(request,
                                                                                   response =>
                {
                    SUGARManager.unity.StopSpinner();
                    var leaderboardStandingsResponses = response.ToList();
                    foreach (var r in leaderboardStandingsResponses)
                    {
                        if (leaderboard.LeaderboardType == LeaderboardType.Earliest || leaderboard.LeaderboardType == LeaderboardType.Latest)
                        {
                            r.Value = DateTime.Parse(r.Value).ToString(Localization.SelectedLanguage);
                        }
                    }
                    response = leaderboardStandingsResponses.Where(r => r.Ranking > 0);
                    standings(response.ToList());
                },
                                                                                   exception =>
                {
                    SUGARManager.unity.StopSpinner();
                    Debug.LogError($"Failed to get leaderboard standings. {exception}");
                    standings(null);
                });
            }
            else
            {
                SUGARManager.unity.StopSpinner();
                standings(null);
            }
        }
Ejemplo n.º 11
0
 /// <summary>
 /// Gathers the current standings in relation to the actor with the id provided using the filter, multiplePerActor, pageNumber and positionCount settings provided for the leaderboard provided.
 /// </summary>
 /// <param name="leaderboard">The leaderboard standings are being gathered for</param>
 /// <param name="actor">The actor the current standings are being gathered for</param>
 /// <param name="filter">The Filter type to order standings by</param>
 /// <param name="multiplePerActor">If the leaderboard allows for actors to appear multiple times</param>
 /// <param name="pageNumber">The page offset to gather positions from</param>
 /// <param name="positionCount">The amount of positions to gather standings for</param>
 /// <param name="standings">Callback which returns the Leaderboard standings</param>
 public void GetLeaderboardStandings(LeaderboardResponse leaderboard, ActorResponse actor, LeaderboardFilterType filter, bool multiplePerActor, int pageNumber, int positionCount, Action <List <LeaderboardStandingsResponse> > standings)
 {
     if (actor != null)
     {
         GetLeaderboardStandings(leaderboard, actor.Id, filter, multiplePerActor, pageNumber, positionCount, standings);
     }
     else
     {
         standings(null);
     }
 }
Ejemplo n.º 12
0
        /// <summary>
        /// Gathers the current standings in relation to the Current User or Group (whichever is valid for the leaderboard) using the filter, multiplePerActor, pageNumber and positionCount settings provided for the leaderboard provided.
        /// </summary>
        /// <param name="leaderboard">The leaderboard standings are being gathered for</param>
        /// <param name="filter">The Filter type to order standings by</param>
        /// <param name="multiplePerActor">If the leaderboard allows for actors to appear multiple times</param>
        /// <param name="pageNumber">The page offset to gather positions from</param>
        /// <param name="positionCount">The amount of positions to gather standings for</param>
        /// <param name="standings">Callback which returns the Leaderboard standings</param>
        public void GetLeaderboardStandings(LeaderboardResponse leaderboard, LeaderboardFilterType filter, bool multiplePerActor, int pageNumber, int positionCount, Action <List <LeaderboardStandingsResponse> > standings)
        {
            var actor = leaderboard == null ? null : leaderboard.ActorType == ActorType.Group || filter == LeaderboardFilterType.GroupMembers || filter == LeaderboardFilterType.Alliances ? SUGARManager.CurrentGroup : SUGARManager.CurrentUser;

            GetLeaderboardStandings(leaderboard, actor, filter, multiplePerActor, pageNumber, positionCount, standings);
        }
Ejemplo n.º 13
0
 /// <summary>
 /// Gathers all of the current standings in relation to the actor with the id provided using the filter and multiplePerActor settings provided for the leaderboard provided.
 /// </summary>
 /// <param name="leaderboard">The leaderboard standings are being gathered for</param>
 /// <param name="actorId">The id of the actor the current standings are being gathered for</param>
 /// <param name="filter">The Filter type to order standings by</param>
 /// <param name="multiplePerActor">If the leaderboard allows for actors to appear multiple times</param>
 /// <param name="standings">Callback which returns the Leaderboard standings</param>
 public void GetLeaderboardStandings(LeaderboardResponse leaderboard, int actorId, LeaderboardFilterType filter, bool multiplePerActor, Action <List <LeaderboardStandingsResponse> > standings)
 {
     GetLeaderboardStandings(leaderboard, actorId, filter, multiplePerActor, 0, 0, standings);
 }
Ejemplo n.º 14
0
 /// <summary>
 /// Gathers all of the current standings in relation to the actor with the id provided using the filter and multiplePerActor settings provided for the leaderboard which uses the token provided.
 /// </summary>
 /// <param name="token">The unique identifier for the Leaderboard</param>
 /// <param name="actorId">The id of the actor the current standings are being gathered for</param>
 /// <param name="filter">The Filter type to order standings by</param>
 /// <param name="multiplePerActor">If the leaderboard allows for actors to appear multiple times</param>
 /// <param name="standings">Callback which returns the Leaderboard standings</param>
 /// <param name="globalLeaderboard">**Optional** Whether the leaderboard is global or in game scope. (default: false)</param>
 public void GetLeaderboardStandings(string token, int actorId, LeaderboardFilterType filter, bool multiplePerActor, Action <List <LeaderboardStandingsResponse> > standings, bool globalLeaderboard = false)
 {
     GetLeaderboardStandings(token, actorId, filter, multiplePerActor, 0, 0, standings, globalLeaderboard);
 }
Ejemplo n.º 15
0
 public static extern ulong ovr_Leaderboard_GetEntries(string leaderboardName, int limit, LeaderboardFilterType filter, LeaderboardStartAt startAt);
Ejemplo n.º 16
0
 public void RefreshLeaderboardsData(int worldId, LeaderboardFilterType type)
 {
     StartCoroutine(leaderboards.LoadToUI(generator.worlds[worldId].blueprint, type));
 }