Skip to main content
Version: 6.0.0

GetMyLeaderboard

public BackndPlayerLeaderboardReturnObject GetMyLeaderboard(string rankUuid);
public BackndPlayerLeaderboardReturnObject GetMyLeaderboard(string rankUuid, int gap);

Note

Old version rankings cannot use this method.

BackndPlayerLeaderboardReturnObject

GetReturnValueByLeaderboardPlayerList

If an error occurred, null is returned.

BackndPlayerLeaderboardReturnObject bro = Backnd.Leaderboard.Player.GetMyLeaderboard("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

ValueTypeDescriptionDefault
rankUuidstringuuid of the ranking to look up-
gapintNumber of rank holders above/below to be looked up together(0 - 100)0

The rankUuid value can be checked using the following methods:

Description

Looks up your rank in the ranking using a uuid value.

  • If there is a tie between users(with the same rank), users with the same ranks may be returned when the gap method is used for the lookup.

Example

Synchronous

// Look up your own rank only
Backnd.Leaderboard.Player.GetMyLeaderboard("rankUuid");

// Look up the ranking including three users above and below
// If you are the 4th, the 1st - 7th users are looked up.
Backnd.Leaderboard.Player.GetMyLeaderboard("rankUuid", 3);

Asynchronous

// Look up your own rank only
Backnd.Leaderboard.Player.GetMyLeaderboard("rankUuid", callback => {
// Post-process
});

// Look up the ranking including three users above and below
// If you are the 4th, the 1st - 7th users are looked up.
Backnd.Leaderboard.Player.GetMyLeaderboard("rankUuid", 5, callback => {
// Post-process
});

Return cases

Success cases

When you are in the ranking and the lookup is successful
statusCode : 200

returnValue : refer to GetReturnValuetoJSON

Error cases

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

When your rank does not exist
statusCode : 404
errorCode : NotFoundException

When there is an attempt to look up with a non-existent uuid
statusCode : 404
errorCode : NotFoundException

GetReturnValuetoJSON

When the gap is 0

{
"rows": [
{
// Gamer inDate of the user
"gamerInDate": {
"S": "2021-03-11T06:37:30.934Z"
},
// User's nickname
"nickname": {
"S": "Nickname No. 0"
},
// Additional field
// Name and value of the column are displayed.
// 'extraScore' if the column name of the additional field is 'extraScore'
"extraScore": {
"N": "0"
},
// 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": 101
},
// offset
"index": {
"N": 98
},
// User's rank
"rank": {
"N": 99
}
}
],
// Total number of rank holders registered in the ranking
"totalCount": 100
}

When the gap is 1

{
"rows": [
// User whose rank is 1 place higher than your rank
{
"gamerInDate": {
"S": "2021-03-11T06:37:32.616Z"
},
"nickname": {
"S": "Nickname No. 22"
},
"extraScore": {
"N": "2346"
},
"score": {
"N": "102"
},
"index": {
"N": 97
},
"rank": {
"N": 98
}
},
// Yourself
{
"gamerInDate": {
"S": "2021-03-11T06:37:30.934Z"
},
"nickname": {
"S": "Nickname No. 0"
},
"extraScore": {
"N": "0"
},
"score": {
"N": 101
},
"index": {
"N": 98
},
"rank": {
"N": 99
}
},
// User whose rank is 1 place lower than your rank
{
"gamerInDate": {
"S": "2021-03-11T06:37:31.838Z"
},
"nickname": {
"S": "Nickname No. 44"
},
"extraScore": {
"N": "2323"
},
"score": {
"N": 100
},
"index": {
"N": 99
},
"rank": {
"N": 100
}
}
],
"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.GetMyLeaderboard(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());
}
}
}