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

hearthstone-observer

v0.0.3

Published

Watches and parses Hearthstone log files. Raises events based on parsed data.

Downloads

5

Readme

Hearthstone Observer

Watches Hearthstone log files and emits events, acting as a basic API for Hearthstone. As of right now, this only works on Windows, there is no reason it shouldn't work on OSX, I just don't have a Mac.

Getting Started

$ npm install hearthstone-observer --save

Require it and listen for events:

var ho = require('hearthstone-observer');
var observer = ho.observe();

observer.on('hs-match-result', function(data) {
    console.log('hearthstone match ended');
});

Samples

sample.js has some basic examples, to run clone the repo and run:

$ DEBUG=hs-observer-sample
$ node sample.js

On Windows

$ set DEBUG=hs-observer-sample
$ node sample.js

Events

  • hs-observer-error hearthstone-observer uses a very simple state object to track players, the state being invalid is the only error right now.
  • hs-match-start also means the state object has been (re)initialized.
  • hs-entity-created everything in a Hearthstone match is an entity and gets an id when it is created. If the entity has been revealed (played), it can be looked up, otherwise only the id and owner are known.
  • hs-player-created raised after the player's hero, hero power, and friendliness are determined.
  • hs-match-result raised when a match ends, a result can be WON, LOST, or CONCEDED. Separate events are raised for lost and conceded.
  • hs-mulligan-start raised when the mulligan stage starts, no player data is attached.
  • hs-turn-start raised when a turn starts, the player whose turn is starting is attached.
  • hs-turn-end raised when a turn ends, the player whose turn is ending is attached.
  • hs-attack raised when a minion or player attacks, always has a target.
  • hs-card-played raised when a card is played. If the card played has a target (e.g. a target-able spell or a minion with a target-able battle cry), the target will be included. Opponent secrets are the only played cards that can't be identified when played.
  • hs-minion-died raised when a minion dies.

Methods

  • observe() instantiates a HearthstoneObserver object and calls go().
  • go() starts watching the specified log files, this is called internally by observe().
  • getCard(cardId) looks up a card in cards.json by cardId.

Development

Clone the repo and run:

$ npm install
  • The regex patterns are stored in hearthstone-observer-constants.js
  • Add a pattern you want to look for in the watchFor array.
  • Add a prototype method in index.js that has the same name as your pattern pre-pended with __
  • To see debug messages run $ DEBUG=hs-observer or on Windows $ set DEBUG=hs-observer
  • To see verbose debugging messages run $ DEBUG=hs-observer-verbose or on Windows $ set DEBUG=hs-observer-verbose
  • To run tests $ npm test