GetLeaderboardByScore
BackndGuildLeaderboardReturnObject GetLeaderboardByScore(string rankUuid, int score); BackndGuildLeaderboardReturnObject GetLeaderboardByScore(string rankUuid, long score);
Old version rankings cannot use this method.
BackndGuildLeaderboardReturnObject
GetReturnValueByGuildLeaderboardList
If an error occurred, null is returned.
BackndGuildLeaderboardReturnObject bro = Backnd.Leaderboard.Guild.GetLeaderboardByScore("rankUuid", 10);
foreach(BackndGuildLeaderboardItem item in bro.GetReturnValueByGuildLeaderboardList()) {
Debug.Log(item.ToString());
}
BackndGuildLeaderboardItem
public class BackndGuildLeaderboardItem
{
public string guildInDate;
public string guildName;
public string score;
public string index;
public string rank;
public string totalCount;
}
Parameters
Value | Type | Description |
---|---|---|
rankUuid | string | uuid of the ranking to look up |
score | int/long | Score to look up |
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 guilds method
Description
Among the guilds registered in the ranking, looks up the guild with the score value and guilds 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.
Example
Synchronous
var score = 0; //Score to look up
Backnd.Leaderboard.Guild.GetLeaderboardByScore("rankUuid", score);
Asynchronous
var score = 0; //Score to look up
Backnd.Leaderboard.Guild.GetLeaderboardByScore("rankUuid", score, 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 guild of the ranking is not registered
statusCode : 200
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
returnValue : refer to GetReturnValuetoJSON
Error cases
When the uuid is null or string.Empty
statusCode : 400
errorCode : ValidationException
When there is an attempt to look up with a non-existent uuid
statusCode : 404
errorCode : NotFoundException
GetReturnValuetoJSON
When the guild with the score and guilds above and below that score all exist
{
"rows": [
{
// Guild name
"guildName": {
"S": "guilds0"
},
// Guild inDate
"guildInDate": {
"S": "2021-03-11T03:23:24.914Z"
},
// Score
// All 'score,' regardless of meta rankings and goods rankings.
"score": {
"N": "9999"
},
// offset
"index": {
"N": 1
},
// Guild rank
"rank": {
"N": 2
},
// and etc...
// Guilds with the same score are returned together.
}
],
// When the previousRank does not exist
"previousRank": {
"NULL": true
},
// When the previousRank exists
// Only 1 guild will be looked up.
"previousRank": [
{
"guildName": {
"S": "guilds1"
},
"guildInDate": {
"S": "2021-03-11T03:24:06.402Z"
},
"score": {
"N": 10000
},
"index": {
"N": 0
},
"rank": {
"N": 1
}
}
],
// When the nextRank does not exist
"nextRank": {
"NULL": true
},
// When the nextRank exists
// Only 1 guild will be looked up.
"nextRank": [
{
"guildName": {
"S": "guilds2"
},
"guildInDate": {
"S": "2021-03-11T03:24:05.378Z"
},
"score": {
"N": 5000
},
"index": {
"N": 2
},
"rank": {
"N": 3
}
}
],
// Total number of guilds registered in the ranking
"totalCount": 3
}
When there are no guilds with the score but there is a guild with a higher score
{
"rows": [ ],
// When the previousRank exists
// Only 1 guild will be looked up.
"previousRank": [
{
"guildName": {
"S": "guilds1"
},
"guildInDate": {
"S": "2021-03-11T03:24:06.402Z"
},
"score": {
"N": 10000
},
"index": {
"N": 0
},
"rank": {
"N": 1
}
}
],
// When the nextRank does not exist
"nextRank": {
"NULL": true
},
// Total number of guilds in the ranking
"totalCount": 907
}
Sample code
public class GuildLeaderboardItem
{
public string guildInDate;
public string guildName;
public string score;
public string index;
public string rank;
public string totalCount;
public override string ToString()
{
return $"guildInDate:{guildInDate}\nGuild name:{guildName}\nScore:{score}\nSort:{index}\nRank:{rank}\nTotal:{totalCount}\n";
}
}
public void GetLeaderboardByScoreTest()
{
SDKTester.InitializeFullTest();
int score = 1815817124;
List<GuildLeaderboardItem> rankItemList = new List<GuildLeaderboardItem>();
BackndGuildLeaderboardReturnObject bro = Backnd.Leaderboard.Guild.GetLeaderboardByScore(guildRankUUID, score);
if(bro.IsSuccess())
{
BACKND.LitJson.JsonData rankListJson = bro.GetFlattenJSON();
for(int i = 0; i < rankListJson["previousRank"].Count; i++)
{
GuildLeaderboardItem rankItem = new GuildLeaderboardItem();
rankItem.guildInDate = rankListJson["previousRank"][i]["guildInDate"].ToString();
rankItem.guildName = rankListJson["previousRank"][i]["guildName"].ToString();
rankItem.score = rankListJson["previousRank"][i]["score"].ToString();
rankItem.index = rankListJson["previousRank"][i]["index"].ToString();
rankItem.rank = rankListJson["previousRank"][i]["rank"].ToString();
rankItem.totalCount = rankListJson["totalCount"].ToString();
rankItemList.Add(rankItem);
Debug.Log(rankItem.ToString());
}
for(int i = 0; i < rankListJson["rows"].Count; i++)
{
GuildLeaderboardItem rankItem = new GuildLeaderboardItem();
rankItem.guildInDate = rankListJson["rows"][i]["guildInDate"].ToString();
rankItem.guildName = rankListJson["rows"][i]["guildName"].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();
rankItemList.Add(rankItem);
Debug.Log(rankItem.ToString());
}
for(int i = 0; i < rankListJson["nextRank"].Count; i++)
{
GuildLeaderboardItem rankItem = new GuildLeaderboardItem();
rankItem.guildInDate = rankListJson["nextRank"][i]["guildInDate"].ToString();
rankItem.guildName = rankListJson["nextRank"][i]["guildName"].ToString();
rankItem.score = rankListJson["nextRank"][i]["score"].ToString();
rankItem.index = rankListJson["nextRank"][i]["index"].ToString();
rankItem.rank = rankListJson["nextRank"][i]["rank"].ToString();
rankItem.totalCount = rankListJson["totalCount"].ToString();
rankItemList.Add(rankItem);
Debug.Log(rankItem.ToString());
}
}
}