Episodes
AfterGameCommenced
await AfterGameCommenced
Waits until the game has commenced. If the game has already commenced, returns immediately. See CommenceGame.
AfterGameConcluded
await AfterGameConcluded
Waits until the game has concluded. If the game has already concluded, returns immediately. See ConcludeGame.
CommenceGame
CommenceGame(noLock?=)
Marks this moment as the start point of the game. Replays will start from this point. Spectators will also be preferentially assigned to a game that has commenced.
This function will also lock the game (same as calling LockGame),
preventing new human players from joining,
unless the noLock
parameter is truthy.
ConcludeGame
ConcludeGame
Marks this moment as the end point of the game. Replays will end at this point. Spectators will automatically be reassigned to another game once the game they are watching has concluded.
CurrentReplayId
CurrentReplayId -> string
Returns a string containing the unique ID for the current game.
This can be used with a ReplayIntent to watch a replay of the current game.
Only games that involve the server will have a replay.
The server is involved in any game where maxHumanPlayers
is set, even if it is set to 1
.
If the server is not recording a replay of the game, returns null
.
await CurrentReplayId -> string
Waits for the replay ID of the current game to change, then returns the new ID. This does not currently happen in any situation but is reserved for future use.
FetchUserEpisodeHistory
await FetchUserEpisodeHistory([userId], limit?=) -> episodes
Returns an Array containing up to limit
entries of the most recent published episodes for a user.
Each element in the Array will be a Map representing one episode.
The data is whatever was passed into PublishUserEpisode
at the time the episode was published, and so is entirely defined by you.
userId
is the user to fetch the episode history for. If nullish, returnsundefined
.limit
is capped at100
, which is also the default value.
GameCommenced
GameCommenced -> boolean
Returns whether the game has commenced or not. See CommenceGame.
await GameCommenced -> boolean
Waits until the GameCommenced
property changes, then returns the new value.
GameConcluded
GameConcluded -> boolean
Returns whether the game has concluded or not. See ConcludeGame.
await GameConcluded -> boolean
Waits until the GameConcluded
property changes, then returns the new value.
GameStartTimestamp
GameStartTimestamp -> timestamp
Returns a timestamp representing the date and time the current game started.
PublishUserEpisode
owner.PublishUserEpisode(pastEpisode?) -> string
Publishes the current game episode to a particular user's episode history. The episode can be retrieved in future games or on pages using FetchUserEpisodeHistory.
The pastEpisode
argument must be a Map containing the data to be published.
It is up to you as the game developer to choose what data to store
that is relevant to your game,
but you likely want to store a list of players in the game, and perhaps who is the winner.
All values inside the Map must be Sendable,
if they are not, an error string will be returned.
The episode data must not exceed a total of 4 KB. If it does, the episode will not be published and an error string will be returned.
If there are no errors, the function will return null
.
ReplayIntent
ReplayIntent(episodeId, showOnlyIfExists?=) -> intent
Returns an intent to watch the replay for a particular episode. Attach the intent to a button Button to trigger it.
episodeId
(String): The identifier of the episode to replay. If this is nullish, the intent will make the button disabled. This must have come from CurrentReplayId in either the current or a previous game.showOnlyIfExists
(Boolean): The button will only be shown if the replay actually exists. It may take a second or two to verify that the replay exists and so there will be a short delay before showing the button. This is useful in historical lists of replays where some of the replays may have expired already.
SpectateIntent
SpectateIntent -> intent
Returns an intent to go to the spectate interface for your game. The spectate interface allows people to watch live games. Intents can be triggered by a button Button press.