Skip to content

Commit

Permalink
compatible_with_seek() needs rating value only
Browse files Browse the repository at this point in the history
  • Loading branch information
gbtami committed Dec 22, 2024
1 parent 8bc61b2 commit 3d4cad6
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 2 deletions.
9 changes: 8 additions & 1 deletion server/user.py
Original file line number Diff line number Diff line change
Expand Up @@ -149,6 +149,12 @@ def update_online(self):
or len(self.tournament_sockets) > 0
)

def get_rating_value(self, variant: str, chess960: bool) -> int:
try:
return int(round(self.perfs[variant + ("960" if chess960 else "")]["gl"]["r"], 0))
except KeyError:
return 1500

def get_rating(self, variant: str, chess960: bool) -> Rating:
if variant in self.perfs:
gl = self.perfs[variant + ("960" if chess960 else "")]["gl"]
Expand Down Expand Up @@ -371,7 +377,8 @@ def compatible_with_other_user(self, other_user):
)

def compatible_with_seek(self, seek):
self_rating = self.get_rating(seek.variant, seek.chess960).rating_prov[0]
self_rating = self.get_rating_value(seek.variant, seek.chess960)
print(self.username, seek.variant, seek.chess960, self_rating)
seek_user = self.app_state.users[seek.creator.username]
return (
(seek_user.username not in self.blocked)
Expand Down
2 changes: 1 addition & 1 deletion server/wsl.py
Original file line number Diff line number Diff line change
Expand Up @@ -156,7 +156,7 @@ async def handle_create_seek(app_state, ws, user, data):
# auto pairing games are always rated, so anon seek will never match!
if not user.anon:
variant_tc = (seek.variant, seek.chess960, seek.base, seek.inc, seek.byoyomi_period)
if variant_tc in app_state.auto_pairings[variant_tc]:
if variant_tc in app_state.auto_pairings:
matching_user = find_matching_user(app_state, user, variant_tc)

auto_paired = False
Expand Down

0 comments on commit 3d4cad6

Please sign in to comment.