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

dcss-lobby

v1.3.2

Published

Connects to a DCSS WebTiles server and gives you all game events - the same which are shown in the lobby.

Downloads

4

Readme

dcss-lobby

dcss-lobby connects to a DCSS WebTiles server and gives you all game events - the same which are shown in the lobby.

Features

  • automatic conversion of messages to game events
  • configurable reconnect after timeout
  • filter events
  • multiple sinks
  • noise protection

Usage

const Lobby = require('dcss-lobby');

const lobby = new Lobby.Lobby('CUE', 'https://underhound.eu:8080/', {
    reconnect:      true,
    bulkProcessing: 3,
});

lobby.setSink(new Lobby.Sink.Console());
lobby.connect();

You can find a complete example in example/.

Example output

[CUE] OdinFK ist nun ein "Firebug".
[CUE] Freyura ist von D:4 nach D:5 gegangen.
[CUE] P0WERM0DE ist nun ein "Chopper".
[CUE] PentaManta ist von D:2 nach D:3 gegangen.
[CUE] iamserjio hat einen Meilenstein geschafft: "killed Jessica.".
[CUE] P0WERM0DE hat einen Meilenstein geschafft: "became a worshipper of Makhleb.".
[CUE] Freyura ist nun Level 8.
[CUE] OdinFK ist von D:4 nach D:5 gegangen.
[CUE] P0WERM0DE ist nun Level 7 und ist von D:4 nach D:5 gegangen.
[CUE] Ge0ff ist von Crypt:3 nach Crypt:2 gegangen.
[CUE] Ge0ff ist von Crypt:2 nach Crypt:3 gegangen.
[CUE] iamserjio ist nun Level 6.
[CUE] Artagas ist von Elf:2 nach Desolation gegangen.
[CUE] iamserjio wird nicht mehr beobachtet.
[CUE] iamserjio  im Dungeon dcss-git als OpCK mit XL 6 pausiert auf der Suche nach dem Orb.
[CUE] FreshCat ist von Dis:4 nach Dis:5 gegangen.
[CUE] iamserjio ist im Dungeon dcss-git als OpCK mit XL 1 auf der Suche nach dem Orb.
[CUE] KamiKatze ist im Dungeon dcss-0.23 als CeHu mit XL 2 auf der Suche nach dem Orb.
[CUE] P0WERM0DE ist nun Level 8.
[CUE] P0WERM0DE ist von D:5 nach D:6 gegangen und hat einen Meilenstein geschafft: "killed Eustachio.".
[CUE] iamserjio ist nun ein "Skirmisher".
[CUE] dstrtn ist von D:3 nach D:2 gegangen.

Installation

npm install dcss-lobby

Architecture

Client wraps the WebSocket connection. The WebSocket connection transmits messages. The MessageParser parses the messages and creates Message-Objects. These objects are stored in a MessageStore. The MessageBulk tries to summarize messages to reduce spam. After the MessageBulk got max messages, the messages are given to Translator, which converts the messages to game Event objects and puts them on the Emitter. The Emitter filters and formats events and puts them in a sink e. g. console.

Lobby is the main interaction object. It handles all the above mentioned things. A lobby needs the shortcut for a DCSS WebTiles server and the servers WebSocket URL and can have an optionally configuration object:

const lobby = new Lobby(/* server shortcut */ 'CUE', /* server url */ 'https://underhound.eu:8080/', {
    reconnect: boolean // do reconnect after disconnect
    bulkProcessing: number // number of max messages in MessageBulk
});

You can filter the events you are interested in:


class EverySecond {

    constructor() {
        this.toggle = false;
    }

    filter(/* Event */ event) {
        this.toggle = !this.toggle;
        return this.toggle;
    }

}


class OnlyUpdateEventsFromSyranez {

    filter(/* Update */ event) {
        return event.username === 'syranez';
    }

}

// Filter is triggered on every event
lobby.setFilter(new EverySecond());

// Filter is triggered only on update events
lobby.setFilterForType(/* event type */ 'update', new OnlyUpdateEventsFromSyranez());

You can format the events you are interested in:


class UpdateFormatter {

    format(/* Update */ event) {
        return `Hey, new update from ${event.username}! \o/`;
    }

}

// format the Update event
lobby.setFormatterForType(/* event type */ 'update', new UpdateFormatter());

You can then output the event. If the event was previously formatted, the Sink will get a string not an Event.


// for all (formatted) events
lobby.setSink(new Lobby.Sink.Console());

// for (formatted) event types
lobby.setSinkForType('update', new Lobby.Sink.Console());

Game Event Types

start

Emitted if someone starts or continues a game.

key | meaning ----|-------- username | Name of player xl | Experience Level title | Current title spectator_count | Count of spectators idle_time | Idle time char | Character place | Current location game_id | Game version id | Process id of current game

Source: src/event/start.js

update

Emitted if something interesting happend in someones game.

key | meaning ----|-------- username | Name of player game_id | Game version id | Process id of current game diff | Array with all changes switchedBranch() | Returns true if player switched the dungeon branch, otherwise false

diff is an array with all changes where change is an object with this

key | meaning ----|-------- key | Name of changed value (can be: xl, title, spectator_count, idle_time, char, place) oldValue | Value before newValue | current value

Source: src/event/update.js

stop

Emitted if the game is stopped.

key | meaning ----|-------- username | Name of player xl | Experience Level title | Current title spectator_count | Count of spectators idle_time | Idle time char | Character place | Current location game_id | Game version id | Process id of current game

Source: src/event/stop.js

License

MIT

[//]: