sc2reader
sc2reader copied to clipboard
Feature request: Load mmr
Replays include MMR info. It would be good to load it as a player attribute
So I have to admit that I"m not sure if the top of the header whether this is available in replays or not. Is this what scaled_rating is, or is that something else? https://github.com/ggtracker/sc2reader/blob/6fcd7f6a1ccc4f067024a9762014f05d3ba5395c/sc2reader/readers.py#L61
It is available in the player information file, replay.gamemetadata.json within the mpq archive. The file looks like this:
"Duration": 1996, "Players": [ { "PlayerID": 1, "MMR": 2988, "APM": 58.000000, "Result": "Win", "SelectedRace": "Prot", "AssignedRace": "Prot" }
I was successfully able to extract this information using mpq archive:
archive = mpyq.MPQArchive(replay.filename)
jsondata = archive.read_file("replay.gamemetadata.json").decode("utf-8")
obj = json.loads(jsondata)
mmr = obj['Players'][0]['MMR']
`
The scaled_rating is the player's mmr in most cases via some basic tests.
Besides, it seems currently the lib does not read "replay.gamemetadata.json" file. While most of the info in it is duplicated, the 'APM' of each player is not included. It may be better to include this file's info for potential uses.