Skip to content

goto-bus-stop/recanalyst

Repository files navigation

RecAnalyst

Packagist License Build Status Gitter chat

RecAnalyst is a PHP package for analyzing Age of Empires II recorded games.

It supports recorded game files from:

  • The Age of Kings
  • The Conquerors
  • UserPatch
  • Forgotten Empires
  • HD Editions (optionally with expansions)

And reads data such as:

  • Game settings
  • Players
  • Chat messages
  • Research and Age Advancing times
  • Map data (terrain, elevation)
  • Initial units
  • Achievements (UserPatch only)
  • Tributes

License - Credits - Contributing - Requirements - Installation - Configuration - Usage Examples - API Documentation - Limitations

$rec = new \RecAnalyst\RecordedGame('recorded_game.mgx2');
$rec->mapImage()->save('minimap.png');
foreach ($rec->players() as $player) {
    printf("%s (%s)", $player->name, $player->civName());
}

License

GPL-3. See COPYING.

Credits

Originally forked from Biegleux's work:
v2.1.0 © 2007-2010 biegleux <biegleux@gmail.com>
Original project homepage
Original project documentation

See also references.md.

Contributing

RecAnalyst is looking for contributors. Please see the Issues List for bugs or missing features and help implement them by opening a PR!

RecAnalyst is an OPEN Open Source Project:

Individuals making significant and valuable contributions are given commit-access to the project to contribute as they see fit. This project is more like an open wiki than a standard guarded open source project.

See the Contributing Guide for more.

Requirements

RecAnalyst works with PHP 5.6+ and PHP 7. The Imagick or GD extensions need to be installed to generate map images.

Installation

With Composer:

composer require recanalyst/recanalyst

Configuration

RecAnalyst ships with translations and image files for researches and civilizations.

If you're using RecAnalyst with Laravel, scroll down to learn about Laravel integration.

RecAnalyst contains a basic Translator class for standalone use. By default, RecAnalyst uses the English language files from Age of Empires II: HD Edition.

RecAnalyst contains icons for civilizations, units and researches in the resources/images folder. If you're using RecAnalyst standalone, and want to use the icons, you can copy that folder into your own project. You can then refer to the different categories of icons in the following ways:

Category URL
Civilizations '/path/to/resources/images/civs/'.$colorId.'/'.$civId.'.png'
Researches '/path/to/resources/images/researches/'.$researchId.'.png'

Laravel

Add the RecAnalyst service provider to your config/app.php:

'providers' => [
    RecAnalyst\Laravel\ServiceProvider::class,
],

RecAnalyst will automatically pick up the appropriate translations for your Laravel app configuration.

To copy the civilization and research icons to your public folder:

php artisan vendor:publish --tag=public

You can then refer to the different categories of icons in the following ways:

Category URL
Civilizations public_path('vendor/recanalyst/civs/'.$colorId.'/'.$civId.'.png')
Researches public_path('vendor/recanalyst/researches/'.$researchId.'.png')

API Documentation

To get started, the Usage Examples might be helpful.

Full API documentation is available at https://goto-bus-stop.github.io/recanalyst/doc/v4.2.0.

Limitations

These are some things to take into account when writing your own applications with RecAnalyst:

  • Achievements data is only available in multiplayer UserPatch 1.4 (.mgz) games. It isn't saved in single player recordings nor in any other game version.
  • RecAnalyst cannot be used to find the state of the recorded game at any point except the very start. This is because AoC stores a list of actions, so to reconstruct the game state at a given point, the game has to be simulated exactly. See #1.
  • Rarely, Age of Empires fails to save Resign actions just before the end of the game. In those cases, RecAnalyst cannot determine the resignTime property for players. See #35.