-
Notifications
You must be signed in to change notification settings - Fork 37
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
Give each lobby a leader. A leader is a useful concept to have in many game types. Implementing leader election in the game itself is much harder. After this we can add support for the leader to be able to change the lobby data. For example making it private when a game starts.
- Loading branch information
1 parent
81d49b6
commit c8612a4
Showing
15 changed files
with
450 additions
and
23 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,82 @@ | ||
Feature: Lobbies have a leader that can control the lobby | ||
|
||
Background: | ||
Given the "signaling" backend is running | ||
And the "testproxy" backend is running | ||
|
||
|
||
Scenario: Other players see the creator as the leader | ||
Given "blue" is connected as "h5yzwyizlwao" and ready for game "4307bd86-e1df-41b8-b9df-e22afcf084bd" | ||
And "yellow" is connected as "3t3cfgcqup9e" and ready for game "4307bd86-e1df-41b8-b9df-e22afcf084bd" | ||
And "blue" creates a lobby | ||
And "blue" receives the network event "lobby" with the argument "prb67ouj837u" | ||
|
||
When "yellow" connects to the lobby "prb67ouj837u" | ||
Then "yellow" receives the network event "lobby" with the arguments: | ||
"""json | ||
[ | ||
"prb67ouj837u", | ||
{ | ||
"code": "prb67ouj837u", | ||
"peers": [ | ||
"3t3cfgcqup9e", | ||
"h5yzwyizlwao" | ||
], | ||
"playerCount": 2, | ||
"public": false, | ||
"maxPlayers": 0, | ||
"customData": null, | ||
"leader": "h5yzwyizlwao", | ||
"term": 1 | ||
} | ||
] | ||
""" | ||
|
||
|
||
Scenario: A new leader is elected when the current leader disconnects | ||
Given "blue,yellow,green" are joined in a lobby for game "4307bd86-e1df-41b8-b9df-e22afcf084bd" | ||
And "blue" is the leader of the lobby | ||
|
||
When "blue" disconnects | ||
Then "yellow" becomes the leader of the lobby | ||
And "yellow" receives the network event "leader" with the argument "3t3cfgcqup9e" | ||
And "green" receives the network event "leader" with the argument "3t3cfgcqup9e" | ||
|
||
|
||
Scenario: Joining an empty lobby makes you the leader | ||
Given "blue" is connected as "h5yzwyizlwao" and ready for game "4307bd86-e1df-41b8-b9df-e22afcf084bd" | ||
And these lobbies exist: | ||
| code | game | playerCount | public | custom_data | | ||
| 1qva9vyurwbb | 4307bd86-e1df-41b8-b9df-e22afcf084bd | 0 | true | {"map": "de_nuke"} | | ||
|
||
When "blue" connects to the lobby "1qva9vyurwbb" | ||
And "blue" receives the network event "lobby" with the arguments: | ||
"""json | ||
[ | ||
"1qva9vyurwbb", | ||
{ | ||
"code": "1qva9vyurwbb", | ||
"peers": [ | ||
"h5yzwyizlwao" | ||
], | ||
"playerCount": 1, | ||
"public": true, | ||
"maxPlayers": 0, | ||
"customData": { | ||
"map": "de_nuke" | ||
}, | ||
"leader": "h5yzwyizlwao", | ||
"term": 1 | ||
} | ||
] | ||
""" | ||
|
||
|
||
Scenario: A player reconnects when a websocket gets a leader event | ||
Given "blue,yellow,green" are joined in a lobby for game "4307bd86-e1df-41b8-b9df-e22afcf084bd" | ||
|
||
When "yellow" disconnected from the signaling server | ||
And "blue" disconnected from the signaling server | ||
|
||
Then "yellow" receives the network event "signalingreconnected" | ||
And "yellow" receives the network event "leader" with the argument "ka9qy8em4vxr" |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Oops, something went wrong.