-
Notifications
You must be signed in to change notification settings - Fork 0
II.B. Player
As we said before, every instance of the Player class is linked to an actual Player playing to your game. Therefore, some messages are sent and received by this class, we will call them events and we will see the list just after.
Just one thing before we present you how a match works and the list of events. The Player class have a userIndex
attribute, this is a unique identifier for the player which is generated like so:
Player + unique id
This can be overwritten by overriding the method getPlayerIndex
of the Match class.
Matches are always composed by teams even if they contain only one player.
As presented in the previous chapter, the Match class has a lot of attributes, and they are not all very explicit so we will see them one by one now.
Specifies the maximum number of player the match can handle.
Specifies the minimum number of player before the match can start. This means, when all the players are ready, if there is at least minUser player in the match, the match will start.
Specifies the map in which the match must be started.
Specifies the match type, this is helpful is you have different modes in your game.
Specifies the password, the players have to give in order to join the match, if it's leaved empty, there's no password and the match is public.
Specifies the number of players in each team. If you don't override anything, this number is 1.
Specifies the max gap between two team. This is useful to make real matchmaking if you have a score for each of your player and you don't want that two players with an enormous score difference could be in the same match. If you don't override anything, this will be set to 0.
Just to know if we can add another team in this match.
Just to know if the match has start. When a match has been started, if you didn't override anything, no other team can join it.
Specifies the game server that is handling this match.
Specifies the different teams that composed this match. Each team is composed of
- grade: the grade (score) of the team for advanced matchmaking
- id: the team id
-
state: the state of the team
- 0: the team has not joined the match yet
- 1: the team has joined the match
-
players: the list of players composing the team with attributes:
- client: the Player object of the player
- key: the key of the player to use to join the match on the game server
-
state: the state of the player
- 0: the player team has not joined the match yet
- 1: the player team has joined the match
- 2: the player is ready
Call when the player wants to find a match. This will look for the matches that correspond to the criteria and add the player inside a match or create a new match.
{
"maxUser": "number",
"minUser": "number",
"map": "string",
"type": "string"
}
Call when the player wants to cancel the search of a match. In the reality, it has no effect as the research is synchronous but you can override the search to make it asynchronous.
{}
Call to create a new match.
{
"maxUser": "number",
"minUser": "number",
"map": "string",
"type": "string",
"password": "string",
"nbPlayersPerTeam": "number",
"allowedGap": "number"
}
Call when the player has found a match and now accept to join it. You can force it if you don't want to let the player choose if he accept or not the match.
{
"matchId": "number",
"password": "string"
}
Call when the player has found a match but refuses to join it.
{}
Call when the player has join the match and is ready to start.
{}
Call when the player leaves the match.
{}
Call when the player disconnects
This event has no data.
Sent when a match has been found.
{
"matchId": "number",
}
Sent when a match has been created.
{
"matchId": "number",
}
Sent when the match specified cannot be found.
{}
Sent when the given password to join a match is wrong.
{}
Sent when a match has been joined.
{
"matchId": "number",
"userId": "string",
"teamId": "string"
}
Sent when a new team has joined the match.
{
"players": {
"userId": "string",
"ready": "bool"
}[],
"teamId": "string"
}
Sent has a confirmation that the player has change his status to ready.
{
"matchId": "number",
}
Sent when a player updated his status to ready.
{
"userId": "string"
}
Sent when a player leaved the match.
{
"userId": "string"
}
Sent when a team leaved the match.
{
"teamId": "string"
}
Sent when every player is ready and a game server has been found.
{
"key": "string",
"map": "string",
"type": "string"
}