Skip to content

Commit

Permalink
Added matchmaking (#74)
Browse files Browse the repository at this point in the history
* Fixed issue with CanSubscribeBot callback
* Added matchmaking functionality
  • Loading branch information
britzl authored Jul 19, 2019
1 parent 596c322 commit 380821f
Show file tree
Hide file tree
Showing 13 changed files with 974 additions and 48 deletions.
56 changes: 49 additions & 7 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ Add the following lines to your game.project file:
[fb_instant]
stretch_canvas = 1
```
`stretch_canvas = 0` if you want to fit canvas into the browser window bounds.
`stretch_canvas = 0` if you want to fit canvas into the browser window bounds.

`stretch_canvas = 1` if you want to stretch canvas.

Expand Down Expand Up @@ -872,6 +872,36 @@ The ```callback``` function is expected to accept the following values:



## Matchmaking

### fbinstant.check_can_player_match_async(callback)
Checks if the current player is eligible for the matchPlayerAsync API.

**PARAMETERS**
* ```callback``` (function) - Function to call when the check has completed

The ```callback``` function is expected to accept the following values:

* ```self``` (userdata) - Script self reference
* ```can_match``` (boolean) - true if the player is eligible to match with other players and false otherwise
* ```error``` (string) - Error code if something went wrong

### fbinstant.match_player(match_tag, switch_context_when_matched, offline_match, callback)
Attempts to match the current player with other users looking for people to play with.

**PARAMETERS**
* ```match_tag``` (string) - Optional extra information about the player used to group them with similar players
* ```switch_context_when_matched``` (boolean) - Optional extra parameter that specifies whether the player should be immediately switched to the new context when a match is found
* ```offline_match``` (boolean) - Optional extra parameter that specifies whether to start a match asynchronously.
* ```callback``` (function) - Function to call when the player has been added to a group thread and switched into the thread's context.

The ```callback``` function is expected to accept the following values:

* ```self``` (userdata) - Script self reference
* ```error``` (string) - Error code if something went wrong



## Constants

### Context
Expand Down Expand Up @@ -922,12 +952,24 @@ For fbinstant.get_stores() activity store status


### Error Codes
#### fbinstant.ADS_FREQUENT_LOAD
#### fbinstant.ADS_NO_FILL
#### fbinstant.ADS_NOT_LOADED
#### fbinstant.ADS_TOO_MANY_INSTANCES
#### fbinstant.RATE_LIMITED
#### fbinstant.INVALID_PARAM
#### fbinstant.ERROR_ADS_FREQUENT_LOAD
#### fbinstant.ERROR_ADS_NO_FILL
#### fbinstant.ERROR_ADS_NOT_LOADED
#### fbinstant.ERROR_ADS_TOO_MANY_INSTANCES
#### fbinstant.ERROR_RATE_LIMITED
#### fbinstant.ERROR_INVALID_PARAM
#### fbinstant.ERROR_ANALYTICS_POST_EXCEPTION
#### fbinstant.ERROR_CLIENT_REQUIRES_UPDATE
#### fbinstant.ERROR_CLIENT_UNSUPPORTED_OPERATION
#### fbinstant.ERROR_INVALID_OPERATION
#### fbinstant.ERROR_LEADERBOARD_NOT_FOUND
#### fbinstant.ERROR_LEADERBOARD_WRONG_CONTEXT
#### fbinstant.ERROR_NETWORK_FAILURE
#### fbinstant.ERROR_PAYMENTS_NOT_INITIALIZED
#### fbinstant.ERROR_PENDING_REQUEST
#### fbinstant.ERROR_SAME_CONTEXT
#### fbinstant.ERROR_UNKNOWN
#### fbinstant.ERROR_USER_INPUT


# Tic Tac Toe example
Expand Down
58 changes: 58 additions & 0 deletions apitester/apitester.collection
Original file line number Diff line number Diff line change
Expand Up @@ -509,3 +509,61 @@ embedded_instances {
z: 1.0
}
}
embedded_instances {
id: "match_player"
data: "components {\n"
" id: \"screen\"\n"
" component: \"/monarch/screen.script\"\n"
" position {\n"
" x: 0.0\n"
" y: 0.0\n"
" z: 0.0\n"
" }\n"
" rotation {\n"
" x: 0.0\n"
" y: 0.0\n"
" z: 0.0\n"
" w: 1.0\n"
" }\n"
" properties {\n"
" id: \"screen_id\"\n"
" value: \"match_player\"\n"
" type: PROPERTY_TYPE_HASH\n"
" }\n"
"}\n"
"embedded_components {\n"
" id: \"collectionproxy\"\n"
" type: \"collectionproxy\"\n"
" data: \"collection: \\\"/apitester/match_player/match_player.collection\\\"\\n"
"exclude: false\\n"
"\"\n"
" position {\n"
" x: 0.0\n"
" y: 0.0\n"
" z: 0.0\n"
" }\n"
" rotation {\n"
" x: 0.0\n"
" y: 0.0\n"
" z: 0.0\n"
" w: 1.0\n"
" }\n"
"}\n"
""
position {
x: 0.0
y: 0.0
z: 0.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale3 {
x: 1.0
y: 1.0
z: 1.0
}
}
37 changes: 37 additions & 0 deletions apitester/match_player/match_player.collection
Original file line number Diff line number Diff line change
@@ -0,0 +1,37 @@
name: "match_player"
scale_along_z: 0
embedded_instances {
id: "go"
data: "components {\n"
" id: \"match_player\"\n"
" component: \"/apitester/match_player/match_player.gui\"\n"
" position {\n"
" x: 0.0\n"
" y: 0.0\n"
" z: 0.0\n"
" }\n"
" rotation {\n"
" x: 0.0\n"
" y: 0.0\n"
" z: 0.0\n"
" w: 1.0\n"
" }\n"
"}\n"
""
position {
x: 0.0
y: 0.0
z: 0.0
}
rotation {
x: 0.0
y: 0.0
z: 0.0
w: 1.0
}
scale3 {
x: 1.0
y: 1.0
z: 1.0
}
}
Loading

0 comments on commit 380821f

Please sign in to comment.