ggtracker / sc2reader

Extracts gameplay information from Starcraft II replay files
http://pypi.python.org/pypi/sc2reader
MIT License
145 stars 144 forks source link

Feature request: Load mmr #89

Open il8677 opened 5 years ago

il8677 commented 5 years ago

Replays include MMR info. It would be good to load it as a player attribute

StoicLoofah commented 5 years ago

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

il8677 commented 5 years ago

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'] `

NumberPigeon commented 1 year ago

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.