Replace party `ready` check with match confirmation
- Ngôn ngữ chính
- Python
- Star
- 72
- Fork
- 84
- Merge trung bình
- 5 giờ 11 phút
- Pull request đã merge (30 ngày)
- 1
Mô tả
## Overview
For the purposes of a matchmaker it makes more sense to perform the "are players ready to start" check when a match is found instead of when the party is entered into the queue. I suggest that we add a `match_info` message that look something like this:
```json
{
"command": "match_info",
"expires_at": "2020-06-18 20:30:26.677218",
"players_total": 4,
"players_ready": 1,
"ready": false
}
```
Where `expires_at` is a timestamp in ISO format and `ready` refers the the ready state of the player that the message is being sent to (this way the client can synchronize its UI state with the server).
The client can display this information and provide a "Ready up" button. When a player clicks the button, the client will send a `match_ready` command that will look something like this:
```json
{
"command": "match_ready"
}
```
Once all players have readied up, the server will start the match launching procedure. If some players fail to ready up by the expiry time (say `20` seconds from when the match was found) then the match will be cancelled, the server will send a `match_cancelled` message and return both searches to the matchmaker queue (notifying the client with a `search_info` command).
## Implementation
I suggest writing a small wrapper around a future that will keep track of which players have readied up:
```python3
class MatchOffer:
def __init__(self, players, expires_at):
...
def ready_player(self, player):
...
async def wait_ready(self):
...
def to_dict(self):
"""Return contents of `match_info` message."""
```
and adding a weak reference to it on the `Player` objects. Then the player object can also get a method
```python3
def ready_match(self):
...
```
which will check if the player has a match offer and proxy the call to `ready_player`.
### Multiqueue support
To support players joining multiple queues at the same time we'll also need to modify the `Search` object and add a property which signals whether the search should be included in the matching phase, or if it is currently "busy" waiting for players to accept a match offer.
Hướng dẫn đóng góp
Đánh giá
Issue này chưa được đánh giá.