GetLeaderboard
public BackndPlayerLeaderboardReturnObject GetLeaderboard(string rankUuid);
public BackndPlayerLeaderboardReturnObject GetLeaderboard(string rankUuid, int limit);
public BackndPlayerLeaderboardReturnObject GetLeaderboard(string rankUuid, int limit, int offset);
Old version rankings cannot use this method.
BackndPlayerLeaderboardReturnObject
GetReturnValueByLeaderboardPlayerList
If an error occurred, null is returned.
BackndPlayerLeaderboardReturnObject bro = Backnd.Leaderboard.Player.GetLeaderboard("rankUuid");
foreach(BackndPlayerLeaderboardItem item in bro.GetReturnValueByLeaderboardPlayerList()) {
Debug.Log(item.ToString());
}
BackndPlayerLeaderboardItem
public class BackndPlayerLeaderboardItem
{
public string gamerInDate;
public string nickname;
public string score;
public string index;
public string rank;
public string extraData = string.Empty;
public string extraName = string.Empty;
public string totalCount;
}
Parameters
Value | Type | Description | Default |
---|---|---|---|
rankUuid | string | uuid of the ranking to look up | - |
limit | int | Number of rank holders to look up(1 - 100) | 10 |
offset | int | Starting point of the ranking to look up(0 or more) | 0 |
The rankUuid value can be checked using the following methods:
- Create a ranking in BACKND Console and check the uuid value from the information of the ranking
- Check the uuid value using the Look up ranking information of all users method
Description
Looks up the list of rank holders registered in the ranking using a uuid value.
In the case of joint ranks, gamer_ids(member numbers) are sorted lexicographically according to the set rank-sorting criteria(ascending/descending order).
Example
Synchronous
// Look up the 1st - 10th rank holders in the rankUuid ranking
Backnd.Leaderboard.Player.GetLeaderboard("rankUuid");
// Look up the 1st - 100th rank holders in the rankUuid ranking
Backnd.Leaderboard.Player.GetLeaderboard("rankUuid", 100);
// Look up the 11th - 20th rank holders in the rankUuid ranking
Backnd.Leaderboard.Player.GetLeaderboard("rankUuid", 10, 10);
Asynchronous
// Look up the 1st - 10th rank holders in the rankUuid ranking
Backnd.Leaderboard.Player.GetLeaderboard("rankUuid", callback=> {
// Post-process
});
// Look up the 1st - 100th rank holders in the rankUuid ranking
Backnd.Leaderboard.Player.GetLeaderboard("rankUuid", 100, callback=> {
// Post-process
});
// Look up the 11th - 20th rank holders in the rankUuid ranking
Backnd.Leaderboard.Player.GetLeaderboard("rankUuid", 10, 10, callback=> {
// Post-process
});
Return cases
Success cases
When the lookup is successful
statusCode : 200
returnValue : refer to GetReturnValuetoJSON
When the lookup is successful but the rank holder is not in the lookup range
statusCode : 200
returnValue : {"rows":[]}
Error cases
When the uuid is null or string.Empty
statusCode : 400
errorCode : ValidationException
When the uuid does not exist
statusCode : 404
errorCode : NotFoundException
GetReturnValuetoJSON
{
"rows": [
{
// Gamer inDate of the user
"gamerInDate": {
"S": "2021-03-11T06:38:46.817Z"
},
// User's nickname
"nickname": {
"S": "Nicknames"
},
// Additional field
// Name and value of the column are displayed.
// 'extraScore' if the column name of the additional field is 'extraScore'
"extraScore": {
"N": "4577"
},
// Score
// Column names are unified as 'score'.
// It will be called 'score' even if the column name of the ranking field is 'power.'
"score": {
"N": "199"
},
// offset
"index": {
"N": 0
},
// User's rank
"rank": {
"N": 1
}
},
// and etc...
],
// Total number of rank holders registered in the ranking
"totalCount":100
}
Sample code
public class LeaderboardItem
{
public string gamerInDate;
public string nickname;
public string score;
public string index;
public string rank;
public string extraData = string.Empty;
public string extraName = string.Empty;
public string totalCount;
public override string ToString()
{
string str = $"UserinDate:{gamerInDate}\nNikckname:{nickname}\nScore:{score}\nSort:{index}\nPlacement:{rank}\nTotal:{totalCount}\n";
if(extraName != string.Empty)
{
str += $"{extraName}:{extraData}\n";
}
return str;
}
}
public void GetMyLeaderboardTest()
{
string userUuid = "81272320-8c40-112b-b174-d9233f6bd0e8";
int limit = 100;
List<LeaderboardItem> rankItemList = new List<LeaderboardItem>();
BackndPlayerLeaderboardReturnObject bro = Backnd.Leaderboard.Player.GetLeaderboard(userUuid, limit);
if(bro.IsSuccess())
{
BACKND.LitJson.JsonData rankListJson = bro.GetFlattenJSON();
string extraName = string.Empty;
for(int i = 0; i < rankListJson["rows"].Count; i++)
{
LeaderboardItem rankItem = new LeaderboardItem();
rankItem.gamerInDate = rankListJson["rows"][i]["gamerInDate"].ToString();
rankItem.nickname = rankListJson["rows"][i]["nickname"].ToString();
rankItem.score = rankListJson["rows"][i]["score"].ToString();
rankItem.index = rankListJson["rows"][i]["index"].ToString();
rankItem.rank = rankListJson["rows"][i]["rank"].ToString();
rankItem.totalCount = rankListJson["totalCount"].ToString();
if(rankListJson["rows"][i].ContainsKey(rankItem.extraName))
{
rankItem.extraData = rankListJson["rows"][i][rankItem.extraName].ToString();
}
rankItemList.Add(rankItem);
Debug.Log(rankItem.ToString());
}
}
}