Giter VIP home page Giter VIP logo

w3gjs's Introduction

w3gjs

Conventional Commits Build Status Test Coverage Maintainability

Parser

From scratch asynchronous, fully typed and tested TypeScript implementation of a w3g parser for WarCraft 3 replay files.

You can use the subcomponents to create your own parser that suits your requirements or just use the high-level parser output that is best suited for standard game mode game analysis.

It does not fully support replays of game version <= 1.14.

Installation

  npm install w3gjs

Usage

Check out the examples folder of this repository to find usage examples for both typescript and javascript.

For detailed API documentation check out https://pbug90.github.io/w3gjs Please keep in mind that as of now, parallel parsing with the same W3GReplay instance is not yet supported. Instantiate multiple instances or parse replays sequentially.

High Level API

High level API is best suited to parse standard melee replays.

const W3GReplay = require("w3gjs").default;
const parser = new W3GReplay();

(async () => {
  const result = await parser.parse("replay.w3g");
  console.log(result);
})().catch(console.error);

Low Level API

Low level API allows you to either implement your own logic on top of the ReplayParser class by extending it or to register callbacks to listen for parser events as it encounters the different kinds of blocks in a replay.

In previous versions, multiple events were emitted. In version 2 there are exactly two events.

basic_replay_information provides you with metadata about the replay that was parsed from the header information.

The gamedatablock event provides you with all blocks that make up the actual game data, fully parsed and in correct order. You can check their id property to distinguish the blocks from each other. For more information, consult the auto-generated docs for properties of specific blocks.

const ReplayParser = require("w3gjs/dist/lib/parsers/ReplayParser").default;
const fs = require("fs")(async () => {
  const buffer = fs.readFileSync("./reforged1.w3g");
  const parser = new ReplayParser();
  parser.on("basic_replay_information", (info) => console.log(info));
  parser.on("gamedatablock", (block) => console.log(block));
  const result = await parser.parse(buffer);
  console.log(result);
})().catch(console.error);

Contributing

There is no point in hiding the implementation of tools that the community can use. So please feel free to discuss in the issues section or provide a pull request if you think you can improve this parser.

Issues

If you have an issue using this library please use the issue section and provide an example replay file.

License

MIT license, see LICENSE.md file.

w3gjs's People

Contributors

pbug90 avatar dependabot[bot] avatar davidmente avatar tylerkerr avatar jfght avatar stannnnn 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.