Skip to content

Commit a68dc10

Browse files
authored
Merge pull request #190 from NumberPigeon/mmr
Feat: add mmr for Players and Observers
2 parents 0c79fc9 + 50a137e commit a68dc10

File tree

1 file changed

+9
-0
lines changed

1 file changed

+9
-0
lines changed

sc2reader/objects.py

Lines changed: 9 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,15 @@ def __init__(self, uid, init_data):
285285
#: This is deprecated because it doesn't actually work.
286286
self.recorder = None
287287

288+
#: The user's mmr at the time of the game
289+
#: Currently, there are three cases observed for a user that does not have a current mmr:
290+
#: 1. The user has no 'scaled_rating' key in their init_data,
291+
#: 2. The user has a None value for their 'scaled_rating' key, or
292+
#: 3. The user has a negative rating, often -36400.
293+
#: For ease of use, this property will return None in both cases.
294+
matchmaking_rating = int(init_data.get("scaled_rating") or 0)
295+
self.mmr = matchmaking_rating if matchmaking_rating > 0 else None
296+
288297
@property
289298
def url(self):
290299
"""

0 commit comments

Comments
 (0)