@@ -339,20 +339,27 @@ def start_search(
339339 on_matched = on_matched
340340 )
341341
342- for player in players :
342+ self ._add_search_to_queue (search , queue )
343+
344+ def _add_search_to_queue (
345+ self ,
346+ search : Search ,
347+ queue : MatchmakerQueue ,
348+ ):
349+ for player in search .players :
343350 player .state = PlayerState .SEARCHING_LADDER
344351
345352 self .write_rating_progress (player , queue .rating_type )
346353
347354 player .write_message ({
348355 "command" : "search_info" ,
349- "queue_name" : queue_name ,
356+ "queue_name" : queue . name ,
350357 "state" : "start"
351358 })
352359
353- self ._searches [player ][queue_name ] = search
360+ self ._searches [player ][queue . name ] = search
354361
355- self ._logger .info ("%s started searching for %s" , search , queue_name )
362+ self ._logger .info ("%s started searching for %s" , search , queue . name )
356363
357364 asyncio .create_task (queue .search (search ))
358365
@@ -418,26 +425,28 @@ def _clear_search(
418425 return search
419426
420427 def write_rating_progress (self , player : Player , rating_type : str ) -> None :
421- if player not in self ._informed_players :
422- self ._informed_players .add (player )
423- _ , deviation = player .ratings [rating_type ]
428+ if player in self ._informed_players :
429+ return
424430
425- if deviation > 490 :
426- player .write_message ({
427- "command" : "notice" ,
428- "style" : "info" ,
429- "text" : (
430- "<i>Welcome to the matchmaker</i><br><br><b>The "
431- "matchmaking system needs to calibrate your skill level; "
432- "your first few games may be more imbalanced as the "
433- "system attempts to learn your capability as a player."
434- "</b><br><b>"
435- "Afterwards, you'll be more reliably matched up with "
436- "people of your skill level: so don't worry if your "
437- "first few games are uneven. This will improve as you "
438- "play!</b>"
439- )
440- })
431+ self ._informed_players .add (player )
432+ _ , deviation = player .ratings [rating_type ]
433+
434+ if deviation > 490 :
435+ player .write_message ({
436+ "command" : "notice" ,
437+ "style" : "info" ,
438+ "text" : (
439+ "<i>Welcome to the matchmaker</i><br><br><b>The "
440+ "matchmaking system needs to calibrate your skill level; "
441+ "your first few games may be more imbalanced as the "
442+ "system attempts to learn your capability as a player."
443+ "</b><br><b>"
444+ "Afterwards, you'll be more reliably matched up with "
445+ "people of your skill level: so don't worry if your "
446+ "first few games are uneven. This will improve as you "
447+ "play!</b>"
448+ )
449+ })
441450
442451 def on_match_found (
443452 self ,
@@ -504,16 +513,29 @@ async def confirm_match(
504513 player .state = PlayerState .IDLE
505514 player .write_message (msg )
506515
507- # Return any player that accepted the match back to the queue
508- # TODO: make this work with parties
516+ # Return any search that fully accepted the match back to the queue
509517 for search in (s1 , s2 ):
510- for player in search .players :
511- if player in unready_players :
512- self .cancel_search (player )
513- else :
514- search .unmatch ()
515- player .state = PlayerState .SEARCHING_LADDER
516- asyncio .create_task (queue .search (search ))
518+ search_players = search .players
519+ search_unready_players = [
520+ player
521+ for player in unready_players
522+ if player in search_players
523+ ]
524+ if not search_unready_players :
525+ search .unmatch ()
526+ self ._add_search_to_queue (search , queue )
527+ self ._logger .debug (
528+ "%s auto requeued after failed match" ,
529+ search
530+ )
531+ else :
532+ for player in search_players :
533+ player .write_message ({
534+ "command" : "match_notice" ,
535+ "unready_players" : [
536+ p .id for p in search_unready_players
537+ ]
538+ })
517539
518540 self .violation_service .register_violations (unready_players )
519541
0 commit comments