{"id":13795058,"url":"https://github.com/happyleavesaoc/aoc-mgz","last_synced_at":"2025-05-15T15:05:45.085Z","repository":{"id":27891419,"uuid":"31382929","full_name":"happyleavesaoc/aoc-mgz","owner":"happyleavesaoc","description":"Age of Empires II recorded game parsing and summarization in Python 3.","archived":false,"fork":false,"pushed_at":"2025-04-27T14:09:31.000Z","size":17866,"stargazers_count":209,"open_issues_count":5,"forks_count":46,"subscribers_count":19,"default_branch":"master","last_synced_at":"2025-04-27T14:16:39.270Z","etag":null,"topics":["aoc","aoe2","aoe2record","mgz","parser","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":"mit","status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/happyleavesaoc.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":"LICENSE","code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2015-02-26T18:49:05.000Z","updated_at":"2025-04-27T14:09:34.000Z","dependencies_parsed_at":"2024-01-07T06:23:29.051Z","dependency_job_id":"b1beb4d9-6f89-4a51-9b00-84e35b8f15f7","html_url":"https://github.com/happyleavesaoc/aoc-mgz","commit_stats":{"total_commits":394,"total_committers":22,"mean_commits":17.90909090909091,"dds":"0.14213197969543145","last_synced_commit":"2d38f29c0c666fd91a141f27be678006003b4c94"},"previous_names":[],"tags_count":33,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happyleavesaoc%2Faoc-mgz","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happyleavesaoc%2Faoc-mgz/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happyleavesaoc%2Faoc-mgz/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/happyleavesaoc%2Faoc-mgz/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/happyleavesaoc","download_url":"https://codeload.github.com/happyleavesaoc/aoc-mgz/tar.gz/refs/heads/master","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":254364270,"owners_count":22058878,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["aoc","aoe2","aoe2record","mgz","parser","python"],"created_at":"2024-08-03T23:00:51.716Z","updated_at":"2025-05-15T15:05:44.101Z","avatar_url":"https://github.com/happyleavesaoc.png","language":"Python","funding_links":[],"categories":["Information"],"sub_categories":[],"readme":"# mgz\n\nAge of Empires II recorded game parsing and summarization in Python 3.\n\n## Supported Versions\n\n- Age of Kings (`.mgl`)\n- The Conquerors (`.mgx`)\n- Userpatch 1.4 (`.mgz`)\n- Userpatch 1.5 (`.mgz`)\n- HD Edition \u003e= 4.6 (`.aoe2record`)\n- Definitive Edition (`.aoe2record`)\n\n## Architecture\n\nThe core functionality of `mgz` is a parser that produces a Python data structure based on a recorded game file. It also offers abstracted representations that make it easier to use the data.\n\n### Parsers\n\n`mgz` offers two parsers, `fast` and `full`. The `fast` parser skips data that is rarely needed, while the `full` parser tries to parse as much as possible. Naturally, the `fast` parser is faster than the `full` parser.\nThe `full` parser can do just about everything, the `fast` only maybe 80-90%. The `summary` will automatically try the `fast` parser and fall back to the `full` parser if needed.\n\n### Abstractions\n\nAbstractions take parser output as input and return an object with normalized data that is easier to use for most cases. There are two abstractions available, `summary` and `model`. The `summary` abstraction attempts to expose the maximum amount of usable data. The `model` abstraction is more limited but automatically performs more lookups.\n\n## Support\n\n| Version | model | summary | fast (header) | fast (body) | full (header) | full (body) | \n| --- | :-: | :-: | :-: | :-: | :-: | :-: |\n| Age of Kings (`.mgl`) | | ✓ | | ✓ | ✓ | |\n| The Conquerors (`.mgx`) | | ✓ | | ✓ | ✓ | |\n| Userpatch \u003c= 1.4 (`.mgz`) | | ✓ | | ✓ | ✓ | ✓ |\n| Userpatch 1.5 (`.mgz`) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |\n| HD Edition \u003e= 4.6 | | ✓ | | ✓ | ✓ | ✓ |\n| HD Edition 5.8 | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |\n| Definitive Edition \u003c= 13.34 (`.aoe2record`) | | ✓ | | ✓ | ✓ | ✓ |\n| Definitive Edition \u003e 13.34, \u003c= 26.21 (`.aoe2record`) | ✓ | ✓ | ✓ | ✓ | ✓ | ✓ |\n| Definitive Edition \u003e 26.21 (`.aoe2record`) | ✓ | ✓ | ✓ | ✓ | ✓ | |\n\n## Examples\n\n#### Full Parser (header) + Fast Parser (body)\n\n```python\nimport os\nfrom mgz import header, fast\n\nwith open('/path/to/file', 'rb') as data:\n    eof = os.fstat(data.fileno()).st_size\n    header.parse_stream(data)\n    fast.meta(data)\n    while data.tell() \u003c eof:\n        fast.operation(data)\n```\n\n### Summary\n\n```python\nfrom mgz.summary import Summary\n\nwith open('/path/to/file', 'rb') as data:\n    s = Summary(data)\n    s.get_map()\n    s.get_platform()\n    # ... etc\n```\n\n### Model\n\n```python\nfrom mgz.model import parse_match\n\nwith open('/path/to/file', 'rb') as data:\n    match = parse_match(data)\n    match.map.name\n    match.file.perspective.number\n    # ... etc\n```\n\n## To JSON\n\n```python\nimport json\nfrom mgz.model import parse_match, serialize\n\nwith open('/path/to/file', 'rb') as h:\n    match = parse_match(h)\n    print(json.dumps(serialize(match), indent=2))\n```\n\n## Frequently Asked Questions\n\n**Q:** Where are the end-of-game achievements/statistics?\n\n**A:** In the `postgame` action, available only from Userpatch version.\n\n**Q:** How can I tell the number of resources/kills/etc at a certain point?\n\n**A:** You can't, without replaying the match in-game.\n\n**Q:** How does a recorded game file work?\n\n**A:** The first portion (the `header`) is a snapshot of the initial game state. The second portion (the `body`) is a list of moves made by players. The game loads the header, then applies each move to mutate the state according to the game rules.\n\n**Q:** How can I install this package?\n\n**A:** `pip install mgz`\n\n## Contribution\n - Pull requests \u0026 patches welcome\n\n## Resources\n - aoc-mgx-format: https://github.com/stefan-kolb/aoc-mgx-format\n - recage: https://github.com/goto-bus-stop/recage\n - recanalyst: http://sourceforge.net/p/recanalyst/\n - genie-rs: https://github.com/SiegeEngineers/genie-rs/tree/default/crates/genie-rec\n - bari-mgx-format: https://web.archive.org/web/20090215065209/http://members.at.infoseek.co.jp/aocai/mgx_format.html\n","project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhappyleavesaoc%2Faoc-mgz","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fhappyleavesaoc%2Faoc-mgz","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fhappyleavesaoc%2Faoc-mgz/lists"}