npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

brawlhalla-replay-reader

v1.0.3

Published

A module/CLI tool for parsing replay files for Brawlhalla

Downloads

20

Readme

brawlhalla-replay-reader

Version Downloads License

brawlhalla-replay-reader is a module for parsing replay files for Brawlhalla.

Installation

You can install brawlhalla-replay-reader for use as a module through the command line using npm or yarn.

npm install brawlhalla-replay-reader

If you wish to install the CLI tool we recommend installing it globally:

npm install -g brawlhalla-replay-reader

Please note this will add the tool to your environment path for usage anywhere.

Usage

CLI Tool

Assuming the tool has been installed globally, you can run the tool using:

replay-reader -h

This will give you a brief help page.

In order to export your latest replay simply run:

replay-reader export latest

This will write an export of your latest replay to replay.json.

To export a select replay simply replace latest with the name of the file (with or without the .replay extension) (Make sure to add quotation marks!)

replay-reader export "[6.05] ShipreckFalls"

To specify the output directory use the --out or -o option:

replay-reader export -o out.json latest

This will write the output to out.json!

To specify a custom Brawlhalla replays directory use the --dir or -d option:

replay-reader export -d C:/BrawlhallaReplays/ latest

As a module

import { ReplayData } from "brawlhalla-replay-reader";

// or

import * as ReplayReader from "brawlhalla-replay-reader";

The main class exported by this project is ReplayData.

It contains a static method ReadReplay which takes the replay file data as an argument. See the example below:

import { readFileSync } from "fs";
import { homedir } from "os";
import { ReplayData } from "brawlhalla-replay-reader";

const replayName = "[6.05] VoidMinor.replay";
const replayPath = homedir() + `/BrawlhallaReplays/${replayName}`;

const replayData = readFileSync(replayPath);

const replay = ReplayData.ReadReplay(replayData);

From there you can simply interact with the replay object as much as you would like.

For example to print all deaths:

const entities = replay.entities;

for (const death of replay.deaths) {
  const entity = entities.find((e) => e.id == death.entityId);
  if (!entity) {
    throw new Error(`Unable to find entity with id ${death.entityId}`);
  }

  console.log(`${entity.name} died at ${death.timestamp / 1000}s`);
}

Documentation

ReplayData.ReadReplay(data: Buffer): ReplayData

A static method for reading a replay from a buffer.

const replayData = readFileSync(replayPath);

const replay = ReplayData.ReadReplay(replayData);

> {
  length: 252624,
  results: { '1': 1, '2': 1, '3': 2, '4': 2 },
  deaths: [
    { entityId: 4, timestamp: 44416 },
    ...
  ],
  inputs: {
    '1': [
      { timestamp: 0, inputState: 0 },
      { timestamp: 6208, inputState: 8 },
      ...
    ],
    ...
  },
  randomSeed: 69330341,
  version: 209,
  playlistId: 7,
  onlineGame: true,
  levelId: 186,
  heroCount: 1,
  entities: [
    {
      id: 1,
      name: 'electroz',
      data: {
        colourId: 2,
        spawnBotId: 1,
        emitterId: 1,
        playerThemeId: 1,
        taunts: [
          12, 43, 64, 68,
          12, 12, 12, 12
        ],
        winTaunt: 64,
        loseTaunt: 64,
        unknown1: [ 0, 2048, 17, 0 ],
        avatarId: 41,
        team: 1,
        unknown2: 1648171893,
        heroes: [
          HeroData {
            heroId: 52,
            costumeId: 432,
            stance: 1,
            weaponSkins: 65864684
          }
        ],
        bot: false
      }
    },
    ...
  ],
  playlistName: 'PlaylistType_2v2Ranked_DisplayName',
  gameSettings: {
    flags: 3,
    maxPlayers: 4,
    duration: 480,
    roundDuration: 0,
    startingLives: 3,
    scoringType: 2,
    scoreToWin: 0,
    gameSpeed: 100,
    damageRatio: 100,
    levelSetID: 4
  }
}

Documentation - Types

ReplayData

The root replay object.

{
  length: number;
  results: {
    [entityId: number]: number
  };
  deaths: Death[];
  inputs: {
    [entityId: number]: Input[]
  };
  randomSeed: number;
  version: number;
  playlistId: number;
  playlistName: string | undefined;
  onlineGame: boolean;
  gameSettings: GameSettings | undefined;
  levelId: number;
  heroCount: number;
  entities: Entity[];
}

Death

Object containing data on an entity death

{
  entityId: number;
  timestamp: number;
}

Input

Timestamped input.
Input state is bitmap of possible keys being pressed.

{
  timestamp: number;
  inputState: number;
}

GameSettings

Data about game/match settings.

{
  flags: number;
  maxPlayers: number;
  duration: number;
  roundDuration: number;
  startingLives: number;
  scoringType: number;
  scoreToWin: number;
  gameSpeed: number;
  damageRatio: number;
  levelSetID: number;
}

Entity

Data about an entity in a match

{
  id: number;
  name: string;
  data: PlayerData;
}

PlayerData

Data about a specific player

{
  colourId: number;
  spawnBotId: number;
  emitterId: number;
  playerThemeId: number;
  taunts: number[];
  winTaunt: number;
  loseTaunt: number;
  unknown1: number[];
  avatarId: number;
  team: number;
  unknown2: number;
  heroes: HeroData[];
  bot: boolean;
}

HeroData

Data about a legend selection.

{
  heroId: number;
  costumeId: number;
  stance: number;
  weaponSkins: number;
}

Contributing

Interested in contributing to brawlhalla-replay-reader?

Contributions are welcome, and are accepted via pull requests. Please review these guidelines before submitting any pull requests.

Help

Installing dependencies:

npm install

Compile:

npm run build

License

All code in this repository is licensed under MIT.