Skip to main content
Version: 6.0.0

GetAllLeaderboards

public BackndPlayerLeaderboardTableReturnObject GetAllLeaderboards();

BackndPlayerLeaderboardTableReturnObject

GetReturnValueByPlayerLeaderboardTableList

If an error occurred, null is returned.

BackndPlayerLeaderboardTableReturnObject bro = Backnd.Leaderboard.Player.GetAllLeaderboards();

foreach(var playerLeaderboardTable in bro.GetReturnValueByPlayerLeaderboardTableList()) {
Debug.Log(playerLeaderboardTable.ToString());
}

BackndPlayerLeaderboardTableItem

public class BackndPlayerLeaderboardTableItem
{
public string rankType;
public string date;
public string uuid;
public string order;
public bool isReset;
public string title;
public string table;
public string column;

public DateTime rankStartDateAndTime;
public DateTime rankEndDateAndTime;

public string extraDataColumn;
public string extraDataType;
}

Description

Returns all user rankings generated in BACKND Console as a list.
The list contains the following information:

  • Ranking name
  • Ranking uuid
  • Ranking cycle
  • Whether to initialize data when initializing the ranking
  • How to sort ranking
  • Table used in the ranking
  • Column used in the ranking
  • Additional fields used in the ranking

Example

Synchronous

Backnd.Leaderboard.Player.GetAllLeaderboards();

Asynchronous

Backnd.Leaderboard.Player.GetAllLeaderboards(callback=>
{
// Post-process
});

Return cases

Success cases

When the lookup is successful
statusCode : 200

returnValue : refer to GetReturnValuetoJSON

Error cases

When the ranking does not exist
statusCode : 404
errorCode : NotFoundException

GetReturnValuetoJSON

{
"rows": [
{
// Rank type. 'user' in case of user ranking
"rankType": {
"S": "user"
},
// Exists only for one-time rankings.
// Start date of ranking
"rankStartDateAndTime": {
"S": "2021-03-14T15:00:00.000Z"
},
// Exists only for one-time rankings.
// End date of ranking
"rankEndDateAndTime": {
"S": "2021-03-15T05:00:00.000Z"
},
// Ranking period
// day : daily
// week : weekly
// month : monthly
// infinity : accumulative ranking
// custom : one-time ranking
"date": {
"S": "custom"
},
// Ranking uuid
"uuid": {
"S": "90c25d70-8535-11eb-b01b-af47a424fd52"
},
// How to sort ranking
// desc : descending order
// asc : ascending order
"order": {
"S": "desc"
},
// Whether to initialize the column used for the ranking upon initialization
"isReset": {
"BOOL": false
},
// Ranking name
"title": {
"S": "User ranking"
},
// Name of the table used in the ranking
"table" : {
"S": "scoreTable"
},
// Name of the column used as ranking score
"column" : {
"S":"score"
},
// Name of the column used as an additional field of the ranking(exists only when the additional item is registered)
"extraDataColumn" : {
"S":"deck"
},
// Data type of the column used as an additional field of the ranking(exists only when the additional item is registered)
// https://developer.thebackend.io/sdk-docs/backend/base/knowhow/object-for-return/data-structure/
"extraDataType" : {
"S":"M"
}
},
// and etc...
]
}

Sample code

public class RankTableItem
{
public string rankType;
public string date;
public string uuid;
public string order;
public bool isReset;
public string title;
public string table;
public string column;

//Exists only for one-time rankings
public DateTime rankStartDateAndTime;
public DateTime rankEndDateAndTime;

//Exits only when there are additional fields
public string extraDataColumn;
public string extraDataType;

public override string ToString()
{
string str = $"rankType:{rankType}\n" +
$"date:{date}\n" +
$"uuid:{uuid}\n" +
$"order:{order}\n" +
$"isReset:{isReset}\n" +
$"title:{title}\n" +
$"table:{table}\n" +
$"column:{column}\n";

if(rankStartDateAndTime != DateTime.MinValue)
{
str += $"rankStartDateAndTime:{rankStartDateAndTime}\n" +
$"rankEndDateAndTime:{rankEndDateAndTime}\n";
}

if(extraDataColumn != null)
{
str += $"extraDataColumn:{extraDataColumn}\n" +
$"extraDataType:{extraDataType}\n";
}

return str;
}
}
public void GetAllLeaderboardsTest()
{
List<RankTableItem> rankTableItemList = new List<RankTableItem>();

BackndPlayerLeaderboardTableReturnObject bro = Backnd.Leaderboard.Player.GetAllLeaderboards();

if(bro.IsSuccess())
{
BACKND.LitJson.JsonData rankTableListJson = bro.FlattenRows();

for(int i = 0; i < rankTableListJson.Count; i++)
{
RankTableItem rankTableItem = new RankTableItem();


rankTableItem.rankType = rankTableListJson[i]["rankType"].ToString();
rankTableItem.date = rankTableListJson[i]["date"].ToString();
rankTableItem.uuid = rankTableListJson[i]["uuid"].ToString();
rankTableItem.order = rankTableListJson[i]["order"].ToString();
rankTableItem.isReset = rankTableListJson[i]["isReset"].ToString() == "true" ? true : false;
rankTableItem.title = rankTableListJson[i]["title"].ToString();
rankTableItem.table = rankTableListJson[i]["table"].ToString();
rankTableItem.column = rankTableListJson[i]["column"].ToString();

if(rankTableListJson[i].ContainsKey("rankStartDateAndTime"))
{
rankTableItem.rankStartDateAndTime = DateTime.Parse(rankTableListJson[i]["rankStartDateAndTime"].ToString());
rankTableItem.rankEndDateAndTime = DateTime.Parse(rankTableListJson[i]["rankEndDateAndTime"].ToString());
}

if(rankTableListJson[i].ContainsKey("extraDataColumn"))
{
rankTableItem.extraDataColumn = rankTableListJson[i]["extraDataColumn"].ToString();
rankTableItem.extraDataType = rankTableListJson[i]["extraDataType"].ToString();
}

rankTableItemList.Add(rankTableItem);
Debug.Log(rankTableItem.ToString());
}
}
}