GetMyRank
public BackendReturnObject GetMyRank(string rankUuid);
public BackendReturnObject GetMyRank(string rankUuid, int gap);
Note
Old version rankings cannot use this method.
Parameters
Value | Type | Description | Default |
---|---|---|---|
rankUuid | string | uuid of the ranking to look up | - |
gap | int | Number of rank holders above/below to be looked up together(0 - 100) | 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 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
Backend.URank.User.GetMyRank("rankUuid");
// Look up the ranking including three users above and below
// If you are the 4th, the 1st - 7th users are looked up.
Backend.URank.User.GetMyRank("rankUuid", 3);
Asynchronous
// Look up your own rank only
Backend.URank.User.GetMyRank("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.
Backend.URank.User.GetMyRank("rankUuid", 5, callback => {
// Post-process
});
SendQueue
// Look up your own rank only
SendQueue.Enqueue(Backend.URank.User.GetMyRank, "rankUuid", callback => {
// Post-process
});
// Look up the ranking including three users above and below
// If there are 10 users in the ranking and you are the 9th,
// the 6th - 10th users are looked up.
SendQueue.Enqueue(Backend.URank.User.GetMyRank, "rankUuid", 3, 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 RankItem
{
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 GetMyRankTest()
{
string userUuid = "81272320-8c40-112b-b174-d9233f6bd0e8";
int limit = 100;
List<RankItem> rankItemList = new List<RankItem>();
BackendReturnObject bro = Backend.URank.User.GetMyRank(userUuid, limit);
if(bro.IsSuccess())
{
LitJson.JsonData rankListJson = bro.GetFlattenJSON();
string extraName = string.Empty;
for(int i = 0; i < rankListJson["rows"].Count; i++)
{
RankItem rankItem = new RankItem();
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());
}
}
}