Hide

TurnBasedMatchEntity

public final class TurnBasedMatchEntity extends Object
implements TurnBasedMatch Parcelable
java.lang.Object
   ↳ com.google.android.gms.games.multiplayer.turnbased.TurnBasedMatchEntity

Data object representing the data for a turn-based match. This is immutable, and therefore safe to cache or store. Note, however, that the data it represents may grow stale.

This class exists solely to support parceling these objects and should not be used directly.

Inherited Constant Summary

Field Summary

public static final Creator<TurnBasedMatchEntity> CREATOR

Inherited Field Summary

Public Method Summary

boolean
int
boolean
equals(Object obj)
TurnBasedMatch
freeze()
Bundle
int
long
String
byte[]
String
void
Participant
String
Game
long
String
String
int
Participant
getParticipant(String participantId)
String
ArrayList<String>
int
getParticipantStatus(String participantId)
ArrayList<Participant>
String
byte[]
String
int
int
int
int
int
boolean
boolean
String
void
writeToParcel(Parcel out, int flags)

Fields

public static final Creator<TurnBasedMatchEntity> CREATOR

Public Methods

public 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 int describeContents ()

public boolean equals (Object obj)

public TurnBasedMatch freeze ()

Freeze a volatile representation into an immutable representation. Objects returned from this call are safe to cache.

Note that the output of freeze may not be identical to the parent object, but should be equal. In other words:

 
 Freezable f1 = new Freezable();
 Freezable f2 = f1.freeze();
 f1 == f2 may not be true.
 f1.equals(f2) will be true.
 
 

Returns
  • A concrete implementation of the data object.

public 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 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 long getCreationTimestamp ()

public String getCreatorId ()

public byte[] getData ()

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

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

public String getDescription ()

public void getDescription (CharArrayBuffer dataOut)

Loads the match description into the given CharArrayBuffer.

Parameters
dataOut The buffer to load the data into.

public 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 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 Game getGame ()

public long getLastUpdatedTimestamp ()

Return the timestamp at which the match was last modified.

Returns
  • The server timestamp at which the match was last modified.

public 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 String getMatchId ()

public 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 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.

public 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 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 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

public ArrayList<Participant> getParticipants ()

Retrieve the Participants for this object. This is a list of all Participants applicable to the given object.

Returns

public 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 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 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 int getStatus ()

public int getTurnStatus ()

public int getVariant ()

public int getVersion ()

Return the current version of the match.

Returns
  • The current version of the match.

public int hashCode ()

public boolean isDataValid ()

Check to see if this object is valid for use. If the object is still volatile, this method will indicate whether or not the object can be safely used. The output of a call to freeze() will always be valid.

Returns
  • whether or not the object is valid for use.

public 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.

public String toString ()

public void writeToParcel (Parcel out, int flags)