Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Issue/#675 Matchmaking requests from RabbitMQ #788

Draft
wants to merge 3 commits into
base: develop
Choose a base branch
from

Conversation

Askaholic
Copy link
Collaborator

I changed a few things from the issue. Mostly I'm using name keys instead of ids for everything except players because that's what the ladder service expects in client messages already.

Probably need to refactor the rating_type on Game objects to allow unrated games by setting rating_type to None.

Closes #675

@codecov
Copy link

codecov bot commented May 7, 2021

Codecov Report

Attention: 12 lines in your changes are missing coverage. Please review.

Comparison is base (ea2b7d3) 94.61% compared to head (6677516) 96.55%.

❗ Current head 6677516 differs from pull request most recent head d3ed7da. Consider uploading reports for the commit d3ed7da to get more accurate results

Additional details and impacted files
Files Coverage Δ
server/game_service.py 99.02% <ø> (+0.55%) ⬆️
server/gameconnection.py 95.01% <100.00%> (+3.75%) ⬆️
server/games/game.py 95.75% <94.73%> (+2.77%) ⬆️
server/message_queue_service.py 96.15% <87.50%> (-1.75%) ⬇️
server/ladder_service.py 96.02% <91.66%> (ø)

... and 62 files with indirect coverage changes

Copy link
Contributor

@eoinnoble eoinnoble left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Much of this is beyond my understanding, but what I do understand seems correct. I think we need to get more of the branches covered, and I have some very minor stylistic suggestions.

server/games/game.py Show resolved Hide resolved
server/ladder_service.py Outdated Show resolved Hide resolved
server/ladder_service.py Outdated Show resolved Hide resolved
Comment on lines 394 to 414
map_name = request["map_name"]
game_name = request["game_name"]
participants = request["participants"]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Maybe keep the queue_name logic in one block and pull these out of the request closer to where they're being used.

server/ladder_service.py Outdated Show resolved Hide resolved
Comment on lines 408 to 441
player_ids = [participant["player_id"] for participant in participants]
missing_players = [
id for id in player_ids if self.player_service[id] is None
]
if missing_players:
raise Exception(
"players_not_found",
*[{"player_id": id} for id in missing_players]
)

all_players = [
self.player_service[player_id] for player_id in player_ids
]
non_idle_players = [
player for player in all_players
if player.state != PlayerState.IDLE
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Certainly not a big deal but feels like we can probably reduce some of this looping?

Suggested change
player_ids = [participant["player_id"] for participant in participants]
missing_players = [
id for id in player_ids if self.player_service[id] is None
]
if missing_players:
raise Exception(
"players_not_found",
*[{"player_id": id} for id in missing_players]
)
all_players = [
self.player_service[player_id] for player_id in player_ids
]
non_idle_players = [
player for player in all_players
if player.state != PlayerState.IDLE
]
all_players = []
missing_players = []
non_idle_players = []
for participant in participants:
player_id = participant["player_id"]
player = self.player_service[player_id]
if self.player_service[player_id]:
all_players.append(player)
if player.state != PlayerState.IDLE:
non_idle_players.append(player)
else:
missing_players.append(player_id)
if missing_players:
raise Exception(
"players_not_found",
*[{"player_id": id} for id in missing_players]
)

Comment on lines 428 to 448
[
{"player_id": player.id, "state": player.state.name}
for player in all_players
]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Did you want to unpack this list like you did when there were missing_players?

Comment on lines 434 to 452
queue = self.queues[queue_name] if queue_name else None
featured_mod = featured_mod or queue.featured_mod
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

It would be easier on my poor brain if these two lines were closer in the code to where we're grabbing initial values.

Comment on lines 436 to 454
host = all_players[0]
guests = all_players[1:]
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do we need to check anywhere that len(all_players) >= 2?

@Askaholic Askaholic force-pushed the issue/#675-matchmaking-from-rabbitmq branch from 6677516 to 4b597cc Compare August 6, 2021 03:07
@Askaholic Askaholic force-pushed the issue/#675-matchmaking-from-rabbitmq branch from 4b597cc to 8c3e205 Compare August 29, 2021 06:59
@Askaholic Askaholic force-pushed the issue/#675-matchmaking-from-rabbitmq branch 2 times, most recently from b2502a0 to e61dc25 Compare October 31, 2021 04:08
@Brutus5000
Copy link
Member

Recap of additionally required gw features as discussed in chat:

  • map name instead of map id (for map generator maps)
  • access to game settings such as
    • full share settings
    • maybe unit restrictions
    • game args (I want to override player names)
  • usage of gw as exclusive queue (if you join it you can't join another queue or game)

@Askaholic Askaholic force-pushed the issue/#675-matchmaking-from-rabbitmq branch 3 times, most recently from 0e463ea to 9fbac70 Compare December 25, 2023 20:49
@Askaholic Askaholic force-pushed the issue/#675-matchmaking-from-rabbitmq branch from 9fbac70 to 04b0524 Compare December 25, 2023 21:13
@Askaholic
Copy link
Collaborator Author

Askaholic commented Dec 25, 2023

This branch now supports:

  • map name instead of map id (for map generator maps)
  • access to game settings such as
    • full share settings
    • maybe unit restrictions
      not supported by the game
    • game args (I want to override player names)
      not supported by the game
  • usage of gw as exclusive queue (if you join it you can't join another queue or game)

The autolobby system already supports setting arbitrary game options, but only for scalar values. Unit restrictions are represented as a nested value under the RestrictedCategories game option key. The lobby server is able to pass this on to the client, but I'm not sure how the client will translate that to a command line argument to the game, and the game doesn't have code to parse a dictionary or list value there anyway.

The player name is not part of the game options, so it would not be able to be set in this way. Supporting that would require starting on the lua side to figure out how that value should be passed in. I would also think this is not a blocker for an initial GW implementation.

Since these rabbitmq requests come from an external service which must be treated as a black box by the lobby server, there is no way for the lobby server to know if a player is in queue for GW or not, so we can't build any 'exclusive queue' logic around it.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

RFC: Take matchmaking requests from RabbitMQ
3 participants