SparkLeaderboard
Provides access to the entries of a leaderboard.
e.g.
var leaderboard = Spark.getLeaderboards().getLeaderboard(shortCode);
getDescription
signature getDescription()
returns string
Returns the description of this leaderboard.
example
var desc = Spark.getLeaderboards().getLeaderboard(shortCode).getDescription();
getName
signature getName()
returns string
Returns the name of this leaderboard.
example
var shortCode = Spark.getLeaderboards().getLeaderboard(shortCode).getName();
getShortCode
signature getShortCode()
returns string
Returns the shortCode of this leaderboard.
example
var shortCode = Spark.getLeaderboards().getLeaderboard(shortCode).getShortCode();
getEntryCount
signature getEntryCount()
returns number
Returns the total number of entries in this leaderboard.
example
var count = Spark.getLeaderboards().getLeaderboard(shortCode).getEntryCount();
getEntryCountForIdentifier
signature getEntryCountForIdentifier(string identifier)
returns number
Returns the total number of entries in this leaderboard for the specified identifier.
The later can be the userId of a player or the id of a team.
example
var count = Spark.getLeaderboards().getLeaderboard(shortCode).getEntryCountForIdentifier("myPlayerId");
getEntries
signature getEntries()
returns SparkLeaderboardCursor
Returns a cursor over all the entries in this leaderboard.
example
var cursor = Spark.getLeaderboards().getLeaderboard(shortCode).getEntries();
signature getEntries(number count, number offset)
returns SparkLeaderboardCursor
Returns a cursor over count entries in this leaderboard, starting at offset.
params
count - the number of entries over which to obtain a cursor.
offset - the number of entries to skip before the start of the cursor.
example
var cursor = Spark.getLeaderboards().getLeaderboard(shortCode).getEntries(mycount, myoffset);
isPartitioned
signature isPartitioned()
returns boolean
Returns true if this leaderboard has or can have partitions.
example
var isPartitioned = Spark.getLeaderboards().getLeaderboard(shortCode).isPartitioned();
isPartition
signature isPartition()
returns boolean
Returns true if this leaderboard is a single partition of a parent leaderboard.
example
var isPartitioned = Spark.getLeaderboards().getLeaderboard(shortCode).isPartition();
getPartitions
signature getPartitions()
returns SparkLeaderboardPartition[]
Returns an array containing the partitions of this leaderboard if it is partitioned, otherwise an empty array is returned.
example
var partitions = Spark.getLeaderboards().getLeaderboard(shortCode).getPartitions();
drop
signature drop()
returns void
Deletes the underlying data for this leaderboard, making it like new.
example
Spark.getLeaderboards().getLeaderboard(shortCode).drop();
signature drop(boolean deleteRunningTotalData)
returns void
See #drop. Additionally deletes the underlying running total data, resetting any record of players' scores.
example
leaderboard.drop(true);
getEntriesForIdentifier
signature getEntriesForIdentifier(string identifier, JSON customIdFilter)
returns SparkLeaderboardEntry[]
Returns the array of leaderboard entries that correspond to the supplied identifier and customIdFilter
If the customIdFilter is null, the method returns all the entries in the leaderboard for the suplied identifier
example
leaderboard.getEntriesForIdentifier(myPlayerId, {});
getEntriesFromPlayer
signature getEntriesFromPlayer(string playerId, number count)
returns SparkLeaderboardCursor
Returns a cursor over the leaderboard entries starting from the highest score of the supplied playerId
example
leaderboard.getEntriesFromPlayer(myPlayerId, 50);
getEntriesFromPlayerForCustomId
signature getEntriesFromPlayerForCustomId(string playerId, number count, JSON customIdFilter)
returns SparkLeaderboardCursor
Returns a cursor over the leaderboard entries starting from the highest score of the supplied playerId and customIdFilter
If the customId filter is not an object with valid ID fields, it will return an empty cursor
example
leaderboard.getEntriesFromPlayerForCustomId(myPlayerId, 50, {carType:"raceCar"});
getIdFields
signature getIdFields()
returns string[]
Returns the list of custom ID fields that are defined on the leaderboard
example
leaderboard.getIdFields();
getScoreFields
signature getScoreFields()
returns string[]
Returns the list of fields that are defined on the leaderboard
example
leaderboard.getScoreFields();
deleteAllEntries
signature deleteAllEntries(string identifier, boolean deleteRunningTotals)
returns boolean
Deletes all entries from the leaderboard that correspond to this identifier. If your leaderboard has custom IDs set up,
it will delete the entries for all the custom IDs
This method only works for realtime leaderboards
If deleteRunningTotals is true, all running total data for these entries will also be deleted
deleting running totals may affect other leaderbaords using the same running totals
example
leaderboard.deleteEntry(myPlayerId, true);
deleteEntriesForCustomId
signature deleteEntriesForCustomId(string identifier, boolean deleteRunningTotals, JSON customIdFilter)
returns boolean
Deletes the entries from the leaderboard that match the specified customIdFilter.
This method only works for realtime leaderboards
If deleteRunningTotals is true, all running total data for this leaderboard will also be deleted
deleting running totals may affect other leaderbaords using the same running totals
example
leaderboard.deleteEntriesForCustomId(myPlayerId, true, {"carType":"raceCar"});
deleteEntry
signature deleteEntry(string identifier, boolean deleteRunningTotals)
returns boolean
DEPRECATED use leaderboard.deleteAllEntries(identifier, deleteRunningTotals)
or leaderboard.deleteEntriesForCustomId(identifier, deleteRunningTotals, customIdFilter).
Deletes the entry from the leaderboard that correspond to this identifier.
This method is not supported for leaderboards with custom IDs and will throw an java.lang.UnsupportedOperationException
This method only works for realtime leaderboards
If deleteRunningTotals is true, all running total data for these entries will also be deleted
deleting running totals may affect other leaderbaords using the same running totals
example
leaderboard.deleteEntry(myPlayerId, true);
getPropertySet
signature getPropertySet()
returns JSON
validity All Scripts
Returns the property set associated with this leaderboard
getRankForScore
signature getRankForScore(JSON score)
returns number
Returns the rank a given score would be at on this Global leaderboard, without it actually being entered into the leaderboard.
Calling this on a Team or Social leaderboard will return null.
example
var rank = leaderboard.getRankForScore({"score" : 123});
rebuildLeaderboard
signature rebuildLeaderboard(boolean awardAchievements)
returns void
Drops the current leaderboard and it rebuilds it from the running totals.
The current leaderboard may not have valid ranks for the duration of this process.
You can only rebuild realtime leaderboards. You cannot rebuild partitioned leaderboards, you can only rebuild the individual partitions.
If the flag awardAchievements is set to true, at the end of the rebuild process the appropriate achievements will be awarded
Please use with care, because during the rebuild process any new data coming from the players might temporarily have incorrect ranks
example
leaderboard.rebuildLeaderboard(true);