Module: leaderboard
Table of contents
Functions
- getConnectedPlayersEntriesAsync
- getEntriesAsync
- getEntryCountAsync
- getLeaderboardAsync
- getPlayerEntryAsync
- sendEntryAsync
Functions
getConnectedPlayersEntriesAsync
▸ getConnectedPlayersEntriesAsync(name
, count
, offset
): Promise
<LeaderboardEntry
[]>
Gets a list of leaderboard entries of connected players in the leaderboard.
Example
Parameters
Name | Type | Description |
---|---|---|
name |
string |
Name of the leaderboard. |
count |
number |
Number of entries to get. |
offset |
number |
Offset from the first entry (top rank) to start the count from. Default is 0. |
Returns
Promise
<LeaderboardEntry
[]>
Array of LeaderboardEntry.
Throws
INVALID_PARAM
NOT_SUPPORTED
RETHROW_FROM_PLATFORM
getEntriesAsync
▸ getEntriesAsync(name
, count
, offset?
): Promise
<LeaderboardEntry
[]>
Gets a list of leaderboard entries in the leaderboard.
Example
Parameters
Name | Type | Default value | Description |
---|---|---|---|
name |
string |
undefined |
Name of the leaderboard. |
count |
number |
undefined |
Number of entries to get. |
offset |
number |
0 |
Offset from the first entry (top rank) to start the count from. Default is 0. |
Returns
Promise
<LeaderboardEntry
[]>
Array of LeaderboardEntry.
Throws
INVALID_PARAM
NOT_SUPPORTED
RETHROW_FROM_PLATFORM
getEntryCountAsync
▸ getEntryCountAsync(name
): Promise
<number
>
Gets the total number of entries in the leaderboard.
Example
Parameters
Name | Type | Description |
---|---|---|
name |
string |
Name of the leaderboard. |
Returns
Promise
<number
>
Number of entries.
Throws
INVALID_PARAM
NOT_SUPPORTED
RETHROW_FROM_PLATFORM
getLeaderboardAsync
▸ getLeaderboardAsync(name
): Promise
<Leaderboard
>
Gets the leaderboard with the given name. Access the leaderboard API via the Leaderboard returned here.
Example
Wortal.leaderboard.getLeaderboardAsync('global')
.then(leaderboard => console.log(leaderboard.name());
Parameters
Name | Type | Description |
---|---|---|
name |
string |
Name of the leaderboard. |
Returns
Promise
<Leaderboard
>
Throws
INVALID_PARAM
NOT_SUPPORTED
RETHROW_FROM_PLATFORM
getPlayerEntryAsync
▸ getPlayerEntryAsync(name
): Promise
<LeaderboardEntry
>
Gets the player's entry in the leaderboard.
Example
Parameters
Name | Type | Description |
---|---|---|
name |
string |
Name of the leaderboard. |
Returns
Promise
<LeaderboardEntry
>
LeaderboardEntry for the player.
Throws
INVALID_PARAM
NOT_SUPPORTED
RETHROW_FROM_PLATFORM
sendEntryAsync
▸ sendEntryAsync(name
, score
, details?
): Promise
<LeaderboardEntry
>
Sends an entry to be added to the leaderboard, or updated if already existing. Will only update if the score is a higher than the player's previous entry.
Example
Parameters
Name | Type | Default value | Description |
---|---|---|---|
name |
string |
undefined |
Name of the leaderboard. |
score |
number |
undefined |
Score for the entry. |
details |
string |
"" |
Optional additional details about the entry. |
Returns
Promise
<LeaderboardEntry
>
The new entry if one was created, updated entry if the score is higher, or the old entry if no new high score was achieved.
Throws
INVALID_PARAM
NOT_SUPPORTED
RETHROW_FROM_PLATFORM