Skip to content

Commit ce4d1af

Browse files
committed
Add support for listing leaderboards
1 parent 5a58c14 commit ce4d1af

File tree

4 files changed

+96
-1
lines changed

4 files changed

+96
-1
lines changed

Runtime/Client/LootLockerEndPoints.cs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -230,6 +230,7 @@ public class LootLockerEndPoints
230230

231231
// Leaderboards
232232
[Header("Leaderboards")]
233+
public static EndPointClass listLeaderboards = new EndPointClass("leaderboards/", LootLockerHTTPMethod.GET);
233234
public static EndPointClass getMemberRank = new EndPointClass("leaderboards/{0}/member/{1}", LootLockerHTTPMethod.GET);
234235
public static EndPointClass getByListOfMembers = new EndPointClass("leaderboards/{0}/members", LootLockerHTTPMethod.POST);
235236
public static EndPointClass getAllMemberRanks = new EndPointClass("leaderboards/member/{0}?count={1}", LootLockerHTTPMethod.GET);

Runtime/Game/LootLockerSDKManager.cs

Lines changed: 26 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4895,6 +4895,32 @@ public static void ListExecutedTriggers(Action<LootLockerListAllTriggersResponse
48954895
#endregion
48964896

48974897
#region Leaderboard
4898+
/// <summary>
4899+
/// List leaderboards with details on each leaderboard
4900+
/// </summary>
4901+
/// <param name="count">How many leaderboards to get in one request</param>
4902+
/// <param name="after">Return leaderboards after this specified index</param>
4903+
/// <param name="onComplete">onComplete Action for handling the response of type LootLockerGetMemberRankResponse</param>
4904+
public static void ListLeaderboards(int count, int after, Action<LootLockerListLeaderboardsResponse> onComplete)
4905+
{
4906+
if (!CheckInitialized())
4907+
{
4908+
onComplete?.Invoke(LootLockerResponseFactory.SDKNotInitializedError<LootLockerListLeaderboardsResponse>());
4909+
return;
4910+
}
4911+
4912+
string endpoint = LootLockerEndPoints.listLeaderboards.endPoint;
4913+
4914+
if(count > 0 || after > 0)
4915+
endpoint += endpoint.Contains("?") ? "&" : "?";
4916+
if (count > 0)
4917+
endpoint += $"count={count}&";
4918+
if (after > 0)
4919+
endpoint += $"after={after}&";
4920+
4921+
LootLockerServerRequest.CallAPI(endpoint, LootLockerEndPoints.listLeaderboards.httpMethod, onComplete: (serverResponse) => { LootLockerResponse.Deserialize(onComplete, serverResponse); });
4922+
}
4923+
48984924
/// <summary>
48994925
/// Get the current ranking for a specific player on a leaderboard.
49004926
/// </summary>

Runtime/Game/Requests/EntitlementRequests.cs.meta

Lines changed: 10 additions & 1 deletion
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

Runtime/Game/Requests/LeaderboardRequest.cs

Lines changed: 59 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,50 @@ namespace LootLocker.Requests
77
//==================================================
88
// Data Definitions
99
//==================================================
10+
public class LootLockerLeaderboardDetails
11+
{
12+
/// <summary>
13+
/// The date the Leaderboard was created.
14+
/// </summary>
15+
public string created_at { get; set; }
16+
/// <summary>
17+
/// The date the Leaderboard was last updated.
18+
/// </summary>
19+
public string updated_at { get; set; }
20+
/// <summary>
21+
/// The Leaderboards Key.
22+
/// </summary>
23+
public string key { get; set; }
24+
/// <summary>
25+
/// The direction of the Leaderboard (Ascending / Descending).
26+
/// </summary>
27+
public string direction_method { get; set; }
28+
/// <summary>
29+
/// The name of the Leaderboard.
30+
/// </summary>
31+
public string name { get; set; }
32+
/// <summary>
33+
/// The type of the Leaderboard (Player / Generic).
34+
/// </summary>
35+
public string type { get; set; }
36+
/// <summary>
37+
/// Will the score be overwritten even if it was less than the original score.
38+
/// </summary>
39+
public bool overwrite_score_on_submit { get; set; }
40+
/// <summary>
41+
/// Does the Leaderboard have metadata.
42+
/// </summary>
43+
public bool has_metadata { get; set; }
44+
/// <summary>
45+
/// Schedule of the Leaderboard.
46+
/// </summary>
47+
public LootLockerLeaderboardSchedule schedule { get; set; }
48+
/// <summary>
49+
/// A List of rewards tied to the Leaderboard.
50+
/// </summary>
51+
public LootLockerLeaderboardReward[] rewards { get; set; }
52+
}
53+
1054
public class LootLockerPlayer
1155
{
1256
public int id { get; set; }
@@ -180,6 +224,21 @@ public class LootLockerGetByListMembersRequest
180224
// Response Definitions
181225
//==================================================
182226

227+
// <summary>
228+
// </summary>
229+
public class LootLockerListLeaderboardsResponse : LootLockerResponse
230+
{
231+
/// <summary>
232+
/// Pagination data to use for subsequent requests
233+
/// </summary>
234+
LootLockerPaginationResponse<int> pagination;
235+
236+
// <summary>
237+
// List of details for the requested leaderboards
238+
// </summary>
239+
LootLockerLeaderboardDetails[] items;
240+
}
241+
183242
public class LootLockerGetMemberRankResponse : LootLockerResponse
184243
{
185244
// we are doing thisfor legacy reasons, since it is no longer being set on the backend

0 commit comments

Comments
 (0)