From 0a305c0f414e67ae935973c8a6ae1bc4897312b5 Mon Sep 17 00:00:00 2001 From: Torsten Hellwig Date: Sun, 3 Dec 2023 22:52:44 +0100 Subject: [PATCH] Minor opponents reorganization --- opponents.py | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/opponents.py b/opponents.py index cca0e6c..2888890 100644 --- a/opponents.py +++ b/opponents.py @@ -84,7 +84,7 @@ def get_opponent(self, if not bots: raise NoOpponentException - for bot in sorted(bots, key=lambda bot: abs(bot.rating_diffs[matchmaking_type.perf_type])): + for bot in bots: if bot in self.busy_bots: continue @@ -112,9 +112,10 @@ def add_timeout(self, success: bool, game_duration: timedelta, matchmaking_type: timeout *= matchmaking_type.multiplier * opponent_multiplier if opponent_data.release_time > datetime.now(): - timeout += opponent_data.release_time - datetime.now() + opponent_data.release_time += timeout + else: + opponent_data.release_time = datetime.now() + timeout - opponent_data.release_time = datetime.now() + timeout release_str = opponent_data.release_time.isoformat(sep=' ', timespec='seconds') print(f'{bot.username} will not be challenged to a new game pair before {release_str}.') @@ -152,7 +153,7 @@ def bot_filter(bot: Bot) -> bool: return True - return list(filter(bot_filter, bots)) + return sorted(filter(bot_filter, bots), key=lambda bot: abs(bot.rating_diffs[matchmaking_type.perf_type])) def _find(self, perf_type: Perf_Type, username: str) -> Opponent: try: