Class: PlayerApi
player.PlayerApi
Player wrapper class. Handles player ID and profile images.
Implements
Constructors
constructor
• new PlayerApi(client
): PlayerApi
Parameters
Name | Type |
---|---|
client |
Client |
Returns
Properties
client
• Private
client: Client
name
• Private
name: null
| string
photo
• Private
photo: null
| string
platformSpecificId
• Private
platformSpecificId: null
| string
playerType
• Private
playerType: null
| PlayerType
Methods
getConnectedPlayers
▸ getConnectedPlayers(): Promise
<Player
[]>
Retrieve a list of players connected to this player. The list is limited to the players who have played the game and thus will not contain all friends of the player.
Returns
Promise
<Player
[]>
getData
▸ getData(keys
): Promise
<Record
<string
, any
>>
Retrieve the player’s persistent data.
Parameters
Name | Type | Description |
---|---|---|
keys |
string [] |
List of keys to retrieve the data for |
Returns
Promise
<Record
<string
, any
>>
getID
▸ getID(): null
| GlobalPlayerId
Get the player’s globally unique ID.
Returns
null
| GlobalPlayerId
Implementation of
getName
▸ getName(): null
| string
Get the player’s name.
Returns
null
| string
Implementation of
getPhoto
▸ getPhoto(): null
| string
Get the player’s photo URL.
Returns
null
| string
Implementation of
getType
▸ getType(): null
| PlayerType
Returns
null
| PlayerType
Implementation of
init
▸ init(platformSpecificId
, name
, photo
, playerType?
): void
Parameters
Name | Type | Default value |
---|---|---|
platformSpecificId |
null | string |
undefined |
name |
null | string |
undefined |
photo |
null | string |
undefined |
playerType |
null | PlayerType |
null |
Returns
void
log
▸ log(event
, parameters
): void
Parameters
Name | Type |
---|---|
event |
string |
parameters |
Object |
Returns
void
setData
▸ setData(data
): Promise
<void
>
Store the player’s persistent data. The data is saved to a cloud storage on platforms that provide one, such as Facebook. Other platforms will simply use the local storage.
When the local storage is used the keys in the data are stored “as is” to local storage. Make sure any other use of the local storage does not conflict with the keys used in the player data.
Parameters
Name | Type |
---|---|
data |
Object |
Returns
Promise
<void
>