gameinstancemanager - TogetherGames/Public-Corona-Lua GitHub Wiki
together.GameInstanceManager
The GameInstanceManager is used for fetching and finding matches that exist for the current game.
table GameInstances
Stores all the GameInstances contained in the Manager.
Adds a GameInstance to the manager internally without persistence.
Note
This method is deprecated
Returns void
GameInstanceManager:Add( gameInstance )
TogetherGameInstance gameInstance
Instance of a GameInstance to add internally
--------------------------------------------------------------------------------Finds the GameInstance with the specified GameInstanceID if it exists, otherwise returns nil.
Returns TogetherGameInstance
GameInstanceManager:FindByGameInstanceID( gameInstanceID )
number gameInstanceID
The ID of the GameInstance to find
--------------------------------------------------------------------------------Gets the number of GameInstances currently managed internally.
Returns number
GameInstanceManager:GetCount( )
Gets the GameInstance at the specified index if it exists, otherwise return nil.
Returns TogetherGameInstance
GameInstanceManager:Get( index )
number index
The index of the GameInstance to find
--------------------------------------------------------------------------------Returns the index of the specified GameInstance if it exists, otherwise returns nil.
Returns number
GameInstanceManager:IndexOf( gameInstance )
TogetherGameInstance gameInstance
Instance of the GameInstance to find the index of
--------------------------------------------------------------------------------Returns the index of the GameInstance with the specified GameInstanceID if it exists, otherwise returns -1.
Returns number
GameInstanceManager:IndexOfByGameInstanceID( gameInstanceID )
number gameInstanceID
The ID of the GameInstance to find the index of
--------------------------------------------------------------------------------Removes a GameInstance from the internally managed list. This does not delete the GameInstance from the Game persistently.
Note
This method is deprecated
Returns void
GameInstanceManager:Remove( index )
number index
The index of the GameInstance to be removed internally
--------------------------------------------------------------------------------Creates a new GameInstance. Upon success, this will automatically update the internal list.
Returns void
GameInstanceManager:Create( gameInstanceType, gameInstanceSubType, roomID, maxUsers, passTurn, gameInstanceProperties, gameInstanceUserProperties, callbackFunc )
string gameInstanceType
The type of GameInstance to create. Potentially, a Game could have several types of GameInstance types within it. Type is limited to 16 characters.
[string](#) gameInstanceSubTypeThe subtype of the GameInstance that will be created. Potentially, a Game could have several sub types within it. SubType is limited to 16 characters.
[number](#) roomIDThe ID of the room the rematch GameInstance is created in. Pass 0 to bypass room creation.
[number](#) maxUsersThe max number of users the GameInstance supports. Pass in 2 for a two player game.
[boolean](#) passTurnA boolean indicating whether the turn should be passed immediately onto the next User. When true, the TurnUserID will actually be set to nil. When the next User joins the GameInstance, the TurnUserID will be set to them.
[PropertyCollection](./propertycollection) gameInstancePropertiesThe properties to assign to the GameInstance. Pass nil to assign no properties to the GameInstance.
[PropertyCollection](./propertycollection) gameInstanceUserPropertiesThe properties to assign to your GameInstanceUser. Pass nil to assign no properties to the GameInstanceUser.
[function](#) callbackFuncThe function to call upon completion.
--------------------------------------------------------------------------------Creates a rematch of a GameInstance. Upon success, this will automatically update the internal list. If the GameInstance is not already finished, it will be finished and a leaderboard will be generated.
Returns void
GameInstanceManager:CreateRematch( originalGameInstanceID, gameInstanceType, gameInstanceSubType, roomID, maxUsers, winningUserID, turnUserID, includeLeftGameUsers, rematchMessage, originalGameProps, origianlGameWinningUserProps, rematchGameProps, callbackFunc )
number originalGameInstanceID
The ID of the original GameInstance we're creating a rematch from.
[string](#) gameInstanceTypeThe type of GameInstance to create. Potentially, a Game could have several types of GameInstance types within it. Type is limited to 16 characters.
[string](#) gameInstanceSubTypeThe subtype of the GameInstance that will be created. Potentially, a Game could have several subtypes within it. SubType is limited to 16 characters.
[number](#) roomIDThe ID of the room the rematch GameInstance is created in. Pass in 0 for no room.
[number](#) maxUsersThe max number of users the GameInstance supports. Pass in 2 for a two player game.
[number](#) winningUserIDThe ID of the User that has won the GameInstance.
[number](#) turnUserIDThe ID of the User whose initial turn it is.
[boolean](#) includeLeftGameUsersA boolean dictating whether users that have left the original game should be included in the rematched GameInstance.
[string](#) rematchMessageThe notification message to send to all other users that are a member of the rematched GameInstance. Pass "" to have no notification message sent.
[PropertyCollection](./propertycollection) originalGamePropsThe final properties of the original GameInstance.
[PropertyCollection](./propertycollection) origianlGameWinningUserPropsThe properties of the winning User of the original GameInstance.
[PropertyCollection](./propertycollection) rematchGamePropsThe properties of the rematch GameInstance. Pass in nil to assign no properties to the rematched GameInstance.
[function](#) callbackFuncThe function to call upon completion.
--------------------------------------------------------------------------------Deletes a GameInstance. Upon success, this will automatically update the internal list.
Returns void
GameInstanceManager:Delete( gameInstanceID, callbackFunc )
number gameInstanceID
The ID of the GameInstance to delete.
[function](#) callbackFuncThe function to call upon completion.
--------------------------------------------------------------------------------Gets all GameInstances. Upon success, this will automatically update the internal list.
Returns void
GameInstanceManager:GetAll( userID, stateMask, maxCount, getGameInstanceProperties, friendsOnly, gameInstanceType, gameInstanceSubtype, callbackFunc )
number userID
The ID of the User who must be a member of a GameInstance retrieved. Pass 0 to fetch all games regardless of membership within them.
[table](#) stateMaskA table containing the GameInstance States to retrieve. The following stateMask table members are examined:
waitingForPlayers | Waiting for players to join the game. |
inProgress | Players are currently playing the game. |
finished | Game has been finished and a leaderboard was generated. |
possibleRematch | A rematched Game waiting for enough players to join. |
forfeit | Game was forfeited by a User. |
-- To get all GameInstances that are playable. local stateMasks = { waitingForPlayers=true, inProgress=true }; -- To get all GameInstances regardless of State. local stateMasks = { waitingForPlayers=true, inProgress=true, finished=true, possibleRematch=true, forfeit=true };[number](#) maxCount
The maximum number of GameInstance to retrieve.
[boolean](#) getGameInstancePropertiesSet TRUE to retrieve the property collections of each game instance, FALSE to retrieve the instances without properties.
[boolean](#) friendsOnlySet TRUE to retrieve only gamesin which you and your friends are joined in
[string](#) gameInstanceTypeSet to retrieve only games with this type, pass nil to ignore.
[string](#) gameInstanceSubtypeSet to retrieve only games with this subtype, pass nil to ignore.
[function](#) callbackFuncThe function to call upon completion.
--------------------------------------------------------------------------------Gets all the GameInstances in a duel. Upon success, this will automatically update the internal list.
Returns void
GameInstanceManager:GetAllInDuel( gameInstanceDuelID, callbackFunc )
number gameInstanceDuelID
The ID of the duel to retrieve all GameInstances for.
[function](#) callbackFuncThe function to call upon completion.
--------------------------------------------------------------------------------Joins an existing GameInstance. Upon success, this will automatically update the internal list.
Returns void
GameInstanceManager:Join( gameInstanceID, gameInstanceUserProperties, callbackFunc )
number gameInstanceID
The ID of the specific GameInstance to join.
[PropertyCollection](./propertycollection) gameInstanceUserPropertiesThe properties to assign the User joining the GameInstance.
[function](#) callbackFuncThe function to call upon completion.
--------------------------------------------------------------------------------Joins a random existing GameInstance. Upon success, this will automatically update the internal list.
Returns void
GameInstanceManager:JoinRandom( gameInstanceType, gameInstanceSubType, gameInstanceUserProperties, callbackFunc )
string gameInstanceType
The type of GameInstance to join.
[string](#) gameInstanceSubTypeThe sub-type (if any) of GameInstance to join.
[TogetherPropertyCollection](./togetherpropertycollection) gameInstanceUserPropertiesThe properties to assign the User joining the GameInstance.
[function](#) callbackFuncThe function to call upon completion.
--------------------------------------------------------------------------------