Skip to main content
Version: 5.15.0

GetLeaderboardByScore

BackendGuildLeaderboardByScoreReturnObject GetLeaderboardByScore(string leaderboardUuid, int score);
BackendGuildLeaderboardByScoreReturnObject GetLeaderboardByScore(string leaderboardUuid, long score);

Parameters

ValueTypeDescription
leaderboardUuidstringuuid of the ranking to look up
scoreint/longScore to look up

The leaderboardUuid value can be checked using the following methods:

Description

Among the rank holders registered in the ranking, looks up the rank holder with the score value and rank holders above and below that score using a uuid value.

  • If there are multiple guilds with the looked-up score, all guilds will be looked up.
  • Even if there are multiple guilds above and below the score, only one guild above and below will be looked up.
  • This method cannot be called via SendQueue.

BackendGuildLeaderboardByScoreReturnObject

namespace BackEnd.Leaderboard
{
public class GuildLeaderboardItem
{
public string guildInDate;
public string guildName;
public string score;
public string index;
public string rank;
}

public class BackendGuildLeaderboardByScoreReturnObject : BackendGuildLeaderboardReturnObject
{
public long GetTotalCount();
public List<UserLeaderboardItem> GetUserLeaderboardList();
public List<UserLeaderboardItem> GetPreviousUserLeaderboardList();
public List<UserLeaderboardItem> GetNextUserLeaderboardList();
}
}

Example

Synchronous


int score = 0; // Score to look up

BackEnd_TEST.Leaderboard.BackendGuildLeaderboardByScoreReturnObject bro = null;

bro = Backend.Leaderboard.Guild.GetLeaderboardByScore("01920444-612d-7802-8e30-f983de5220a9", score);

Debug.Log("Total number of guilds registered to the leaderboard : " + bro.GetTotalCount());

// Guild with higher rank than the searched score
foreach (BackEnd_TEST.Leaderboard.GuildLeaderboardItem item in bro.GetNextGuildLeaderboardList())
{
Debug.Log($"Rank {item.rank} : {item.guildName}");
Debug.Log(item.ToString());
}

foreach (BackEnd_TEST.Leaderboard.GuildLeaderboardItem item in bro.GetGuildLeaderboardList())
{
Debug.Log($"Rank {item.rank} : {item.guildName}");
Debug
}

// Guild with lower rank than the searched score
foreach (BackEnd_TEST.Leaderboard.GuildLeaderboardItem item in bro.GetPreviousGuildLeaderboardList())
{
Debug.Log($"Rank {item.rank} : {item.guildName}");
Debug.Log(item.ToString());
}

Asynchronous

int score = 0; // Score to look up
Backend.Leaderboard.Guild.GetLeaderboardByScore("leaderboardUuid", score, bro => {
Debug.Log(bro.GetTotalCount());

// Guild with higher rank than the searched score
foreach (BackEnd_TEST.Leaderboard.GuildLeaderboardItem item in bro.GetNextGuildLeaderboardList())
{
Debug.Log($"Rank {item.rank} : {item.guildName}");
Debug.Log(item.ToString());
}

foreach (BackEnd_TEST.Leaderboard.GuildLeaderboardItem item in bro.GetGuildLeaderboardList())
{
Debug.Log($"Rank {item.rank} : {item.guildName}");
Debug.Log(item.ToString());
}

// Guild with lower rank than the searched score
foreach (BackEnd_TEST.Leaderboard.GuildLeaderboardItem item in bro.GetPreviousGuildLeaderboardList())
{
Debug.Log($"Rank {item.rank} : {item.guildName}");
Debug.Log(item.ToString());
}
});

ReturnCase

Success cases

When the lookup is successful
statusCode : 200
message : Success
returnValue : refer to GetReturnValuetoJSON

When the lookup is successful but the guild of the ranking is not registered
statusCode : 200
message : Success
returnValue : {"rows":[],"previousRank":{"NULL":true},"nextRank":{"NULL":true},"totalCount":0}

When the lookup is successful but there is no guild with that score
statusCode : 200
message : Success
returnValue : refer to GetReturnValuetoJSON

Error cases

When the uuid is null or string.Empty
statusCode : 400
errorCode : ValidationException
message : leaderboardUuid is null or empty

When there is an attempt to look up with a non-existent uuid
StatusCode : 404
ErrorCode : NotFoundException
Message : leaderboard not found, leaderboard cannot be found

GetReturnValuetoJSON

When the guild with the score and guilds above and below that score all exist

{
"rows": [
{
"guildName": "usa5G",
"guildInDate": "2024-09-18T08:44:59.499Z",
"rank": 24,
"index": 23,
"score": "5"
},
{
"guildName": "japan5G",
"guildInDate": "2024-09-18T08:42:09.000Z",
"rank": 24,
"index": 23,
"score": "5"
}
],
"previousRank": [
{
"guildName": "japan3G",
"guildInDate": "2024-09-12T05:04:37.350Z",
"rank": 23,
"index": 22,
"score": "6"
}
],
"nextRank": [
{
"guildName": "usa4G",
"guildInDate": "2024-09-18T08:44:53.785Z",
"rank": 26,
"index": 25,
"score": "4"
}
],
"totalCount": 36
}

When there are no guilds with the score but there is a guild with a higher score

{
"rows": [],
"previousRank": [
{
"guildName": "japan1G",
"guildInDate": "2024-09-18T08:41:46.845Z",
"rank": 36,
"index": 35,
"score": "1"
}
],
"nextRank": {
"NULL": true
},
"totalCount": 36
}

When there are no guilds with the score but there is a guild with a lower score

{
"rows": [],
"previousRank": {
"NULL": true
},
"nextRank": [
{
"guildName": "match9G",
"guildInDate": "2024-05-08T07:17:22.915Z",
"rank": 1,
"index": 0,
"score": "36"
}
],
"totalCount": 36
}