Skip to content

Commit ce38298

Browse files
committed
feat: add mmr for User class
1 parent ccef488 commit ce38298

File tree

1 file changed

+15
-0
lines changed

1 file changed

+15
-0
lines changed

sc2reader/objects.py

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -285,6 +285,21 @@ 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+
if (
295+
"scaled_rating" in init_data
296+
and init_data["scaled_rating"] is not None
297+
and init_data["scaled_rating"] > 0
298+
):
299+
self.mmr = init_data["scaled_rating"]
300+
else:
301+
self.mmr = None
302+
288303
@property
289304
def url(self):
290305
"""

0 commit comments

Comments
 (0)