Summary: Constants | Inherited Constants | Fields | Methods | Inherited Methods | [Expand All]
public interface

# TurnBasedMatch

implements Freezable<TurnBasedMatch> Participatable Parcelable

com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatch

Known Indirect Subclasses TurnBasedMatchEntity
TurnBasedMatchEntity | Data object representing the data for a turn-based match.

## Class Overview

Data interface for turn-based specific match functionality.

## Summary

Constants
int | MATCH_STATUS_ACTIVE | Constant returned by `getStatus()` indicating that the match has started.
int | MATCH_STATUS_AUTO_MATCHING | Constant returned by `getStatus()` indicating that one or more slots are waiting to be filled by auto-matching.
int | MATCH_STATUS_CANCELED | Constant returned by `getStatus()` indicating that the match was canceled by one of the participants.
int | MATCH_STATUS_COMPLETE | Constant returned by `getStatus()` indicating that the match has finished.
int | MATCH_STATUS_EXPIRED | Constant returned by `getStatus()` indicating that the match expired.
int | MATCH_TURN_STATUS_COMPLETE | Turn status constant for matches which have been completed.
int | MATCH_TURN_STATUS_INVITED | Turn status constant for matches which the current player has been invited to.
int | MATCH_TURN_STATUS_MY_TURN | Turn status constant for matches where it is the current player's turn.
int | MATCH_TURN_STATUS_THEIR_TURN | Turn status constant for matches where it is not the current player's turn.
int | MATCH_VARIANT_DEFAULT | Constant used to indicate that the variant for a match is unspecified.

[Expand] Inherited Constants
From interface android.os.Parcelable
int | CONTENTS_FILE_DESCRIPTOR |
int | PARCELABLE_WRITE_RETURN_VALUE |

Fields
public static final int[] | MATCH_TURN_STATUS_ALL | Array of all the turn status constants.

Public Methods
abstract boolean | canRematch() Return whether or not this match can be rematched.
abstract Bundle | getAutoMatchCriteria() Retrieves the automatch criteria used to create or join this match, if any.
abstract int | getAvailableAutoMatchSlots() Return the maximum number of available automatch slots for this match.
abstract long | getCreationTimestamp()
abstract String | getCreatorId()
abstract byte[] | getData() Return the current (game-specific) data for this match.
abstract String | getDescription()
abstract void | getDescription(CharArrayBuffer dataOut) Loads the match description into the given `CharArrayBuffer`.
abstract Participant | getDescriptionParticipant() Get the participant representing the primary opponent in the match.
abstract String | getDescriptionParticipantId() Get the ID of another participant in the match that can be used when describing the participants the user is playing with.
abstract Game | getGame()
abstract long | getLastUpdatedTimestamp() Return the timestamp at which the match was last modified.
abstract String | getLastUpdaterId() Return the ID of the participant who updated the match most recently.
abstract String | getMatchId()
abstract int | getMatchNumber() Return the match sequence number for this match.
abstract Participant | getParticipant(String participantId) Get a participant in a match by its ID.
abstract String | getParticipantId(String playerId) Get the participant ID for a given player.
abstract ArrayList<String> | getParticipantIds() Get the IDs of the participants of the given match.
abstract int | getParticipantStatus(String participantId) Get the status of a participant in a match.
abstract String | getPendingParticipantId() Return the ID of the participant that is considered pending.
abstract byte[] | getPreviousMatchData() Return the match data from the previous match, if available.
abstract String | getRematchId() Return the match ID of the rematch that was created from this match, if any.
abstract int | getStatus()
abstract int | getTurnStatus()
abstract int | getVariant()
abstract int | getVersion() Return the current version of the match.
abstract boolean | isLocallyModified() Return whether or not this match has been locally modified.

[Expand] Inherited Methods
From interface com.google.android.gms.common.data.Freezable
abstract TurnBasedMatch | freeze() Freeze a volatile representation into an immutable representation.
abstract boolean | isDataValid() Check to see if this object is valid for use.
From interface com.google.android.gms.games.multiplayer.Participatable
abstract ArrayList<Participant> | getParticipants() Retrieve the `Participant`s for this object.
From interface android.os.Parcelable
abstract int | describeContents()
abstract void | writeToParcel(Parcel arg0, int arg1)

## Constants

#### public static final int MATCH_STATUS_ACTIVE

Constant returned by `getStatus()` indicating that the match has started.

Constant Value: 1 (0x00000001)

#### public static final int MATCH_STATUS_AUTO_MATCHING

Constant returned by `getStatus()` indicating that one or more slots are waiting to be filled by auto-matching.

Constant Value: 0 (0x00000000)

#### public static final int MATCH_STATUS_CANCELED

Constant returned by `getStatus()` indicating that the match was canceled by one of the participants.

Constant Value: 4 (0x00000004)

#### public static final int MATCH_STATUS_COMPLETE

Constant returned by `getStatus()` indicating that the match has finished.

Constant Value: 2 (0x00000002)

#### public static final int MATCH_STATUS_EXPIRED

Constant returned by `getStatus()` indicating that the match expired.

Constant Value: 3 (0x00000003)

#### public static final int MATCH_TURN_STATUS_COMPLETE

Turn status constant for matches which have been completed.

Constant Value: 3 (0x00000003)

#### public static final int MATCH_TURN_STATUS_INVITED

Turn status constant for matches which the current player has been invited to.

Constant Value: 0 (0x00000000)

#### public static final int MATCH_TURN_STATUS_MY_TURN

Turn status constant for matches where it is the current player's turn.

Constant Value: 1 (0x00000001)

#### public static final int MATCH_TURN_STATUS_THEIR_TURN

Turn status constant for matches where it is not the current player's turn.

Constant Value: 2 (0x00000002)

#### public static final int MATCH_VARIANT_DEFAULT

Constant used to indicate that the variant for a match is unspecified.

Constant Value: -1 (0xffffffff)

## Fields

#### public static final int[] MATCH_TURN_STATUS_ALL

Array of all the turn status constants.

## Public Methods

#### public abstract boolean canRematch ()

Return whether or not this match can be rematched. This will return true when the match has complete and has not already been rematched.

##### Returns

- Whether or not this match can be rematched.

#### public abstract Bundle getAutoMatchCriteria ()

Retrieves the automatch criteria used to create or join this match, if any. May be null if the match has no automatch properties.

##### Returns

- A bundle containing the automatch criteria for this match.

#### public abstract int getAvailableAutoMatchSlots ()

Return the maximum number of available automatch slots for this match. If automatch criteria were not specified during match creation, or if all slots have been filled, this will return 0.

##### Returns

- The maximum number of additional players that can be added to this match.

#### public abstract long getCreationTimestamp ()

##### Returns

- The server timestamp at which the match was created.

#### public abstract String getCreatorId ()

##### Returns

- The ID of the participant who created this Match.

#### public abstract byte[] getData ()

Return the current (game-specific) data for this match.

##### Returns

- Byte array representing the current (game-specific) match state data.

#### public abstract String getDescription ()

##### Returns

- Description of this match.

#### public abstract void getDescription (CharArrayBuffer dataOut)

Loads the match description into the given `CharArrayBuffer`.

##### Parameters

dataOut | The buffer to load the data into.

#### public abstract Participant getDescriptionParticipant ()

Get the participant representing the primary opponent in the match.

Note that this will return `null` if there is no primary opponent. This could happen if an automatch slot has not been filled.

##### Returns

- The participant representing the primary opponent in the match.

#### public abstract String getDescriptionParticipantId ()

Get the ID of another participant in the match that can be used when describing the participants the user is playing with. For example, in a four player match this might be used to state "Martha (and 2 others)".

Note that this will return `null` if there is no primary opponent. This could happen if an automatch slot has not been filled.

##### Returns

- The participant ID of the primary opponent in the match.

#### public abstract Game getGame ()

##### Returns

- The `Game` object that owns this Match. Note that this should not be cached separately from the Match itself, since the data underlying this object may change.

#### public abstract long getLastUpdatedTimestamp ()

Return the timestamp at which the match was last modified.

##### Returns

- The server timestamp at which the match was last modified.

#### public abstract String getLastUpdaterId ()

Return the ID of the participant who updated the match most recently.

##### Returns

- The ID of the last participant who updated this Match object.

#### public abstract String getMatchId ()

##### Returns

- The ID of this Match.

#### public abstract int getMatchNumber ()

Return the match sequence number for this match. This number starts at 1, and increases every time a rematch is created.

##### Returns

- The match sequence number for this match.

#### public abstract Participant getParticipant (String participantId)

Get a participant in a match by its ID. Note that the participant ID must correspond to a participant in this match, or this method will throw an exception.

##### Parameters

participantId | Match-local ID of the participant to retrieve status for.

##### Returns

- The participant corresponding to the given ID.

##### Throws

| IllegalStateException} if the participant is not a participant in this match.

#### public abstract String getParticipantId (String playerId)

Get the participant ID for a given player. This will only return a non-null ID if the player is actually a participant in the match and that player's identity is visible to the current player. Note that this will always return non-null for the current player.

To find the player ID for the current player, use `getCurrentPlayerId(GoogleApiClient)`.

##### Parameters

playerId | Player ID to find participant ID for.

##### Returns

- The participant ID corresponding to given player, or null if none found.

#### public abstract ArrayList<String> getParticipantIds ()

Get the IDs of the participants of the given match.

##### Returns

- The IDs of the participants in this match. These are returned in the participant order of the match. Note that these are not stable across matches.

#### public abstract int getParticipantStatus (String participantId)

Get the status of a participant in a match. Note that the participant ID must correspond to a participant in this match, or this method will throw an exception.

##### Parameters

participantId | Match-local ID of the participant to retrieve status for.

##### Returns

- The current status of the participant in this match. One of `STATUS_INVITED`, `STATUS_JOINED`, `STATUS_DECLINED`, `STATUS_LEFT`, or `STATUS_NOT_INVITED_YET`.

##### Throws

| IllegalStateException} if the participant is not a participant in this match.

#### public abstract String getPendingParticipantId ()

Return the ID of the participant that is considered pending. If no participant is considered pending (ie, the match is over, etc), this function will return null.

##### Returns

- The ID of the participant that is considered pending, if any. Returns null if no participant is pending.

#### public abstract byte[] getPreviousMatchData ()

Return the match data from the previous match, if available. Note that this is only provided on the first turn of a rematched match.

##### Returns

- Byte array of data from the previous match of a rematch, or null if not available.

#### public abstract String getRematchId ()

Return the match ID of the rematch that was created from this match, if any. This will only be non-null if a rematch has been created.

##### Returns

- The match ID of the rematch, or null if no rematch exists.

#### public abstract int getStatus ()

##### Returns

- The current status of the match. One of `MATCH_STATUS_AUTO_MATCHING`, `MATCH_STATUS_ACTIVE`, `MATCH_STATUS_COMPLETE`, `MATCH_STATUS_EXPIRED`, or `MATCH_STATUS_CANCELED`.

#### public abstract int getTurnStatus ()

##### Returns

- The turn status of the match for the current player. One of `MATCH_TURN_STATUS_INVITED`, `MATCH_TURN_STATUS_MY_TURN`, `MATCH_TURN_STATUS_THEIR_TURN`, or `MATCH_TURN_STATUS_COMPLETE`.

#### public abstract int getVariant ()

##### Returns

- Variant specified for this match, if any. A variant is an optional developer-controlled parameter describing the type of game to play, ranging from 1-1023 (inclusive). If this match had no variant specified, returns `MATCH_VARIANT_DEFAULT`.

#### public abstract int getVersion ()

Return the current version of the match.

##### Returns

- The current version of the match.

#### public abstract boolean isLocallyModified ()

Return whether or not this match has been locally modified. If this is true, the local device has match state which has not successfully synced to the server yet. In this state, further mutations to the match will fail with a status of `STATUS_MATCH_ERROR_LOCALLY_MODIFIED`.

##### Returns

- Whether this match has local modifications or not.