Giter Site home page Giter Site logo

fossabot / star-replay Goto Github PK

View Code? Open in Web Editor NEW

This project forked from rogiel/star-replay

0.0 1.0 0.0 291 KB

A PHP 5.5+ library that parses StarCraft II replay files into a rich object oriented graph.

Home Page: https://www.rogiel.com/en/portfolio/star-replay

License: BSD 2-Clause "Simplified" License

PHP 99.20% Python 0.80%

star-replay's Introduction

Star Replay

FOSSA Status

This library allows you to read StarCraft II replay files from PHP.

A object-oriented API is provided to browse through all metadata and events available on replays.

Features

  • Read .SC2Replay files from all public game versions (data is mined from s2protocol)
  • Game events: Streams events using PHP 5 generators
  • Lazy parsing: Parses only structures you require

Installation

The recommended way of installing this library is using Composer.

composer require "rogiel/star-replay"

This library uses php-mpq to parse and extract compressed information inside replays.

Example

use Rogiel\StarReplay\Replay;
use Rogiel\StarReplay\Event\Game\CameraSaveEvent;

$replay = new Replay('test.SC2Replay');

echo "Version: " . $replay->getHeader()->getVersion() . "\n";
echo "Map: " . $replay->getMatchInformation()->getTitle() . "\n";
echo "Players:\n";
foreach($replay->getPlayers() as $id => $player) {
	echo "\tPlayer ".$id.": ".$player->getName()."\n";
}

echo "Camera hotkeys:\n";
foreach($replay->getGameEvents() as $timestamp => $event) {
	if($event instanceof CameraSaveEvent) {
		$player = $replay->getPlayers()->getPlayer($event->getHeader()->getUserID());
		echo "\tPlayer ". $player->getName() ." saved a new camera #". $event->getWhich() ." at point ". $event->getTarget() ."\n";
	}
	// since we are using generators, the events will stream linearly from begining to end
}

License

FOSSA Status

star-replay's People

Contributors

fossabot avatar rogiel avatar

Watchers

 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.