This module provides a very flexible interface for interacting with the Underlords Game Coordinator. It's designed to work with a node-steam-user SteamUser instance.
This is based off of node-tf2.
You will need node-steam-user v4.2.0 or later and Node.js v8 or later.
First, install it from npm:
$ npm install dota-underlords
Require the module and call its constructor with your SteamUser instance:
const SteamUser = require('steam-user');
const Underlords = require('dota-underlords');
let user = new SteamUser();
let underlords = new Underlords(user);
To initialize your GC connection, just launch Underlords via SteamUser normally:
client.gamesPlayed([1046930]);
Underlords will emit a connectedToGC
event when the game coordinator connection has been successfully
established. You shouldn't try to do anything before you receive that event.
There are some enums that are used by various methods and events. You can find them in enums.js
.
There are a few useful read-only properties available to you.
true
if we're currently connected to the GC, false
otherwise. You should only call methods when we have an active GC session.
When instantiating your underlords instance, you need to pass your active Steam.SteamClient instance as the sole parameter, as shown here:
var underlords = new Underlords(steamClient);
steamid
- The numeric SteamID of the Steam account to pull profile data for.callback
- Called if all parameters are valid when Steam responds to us.
steamid
- The numeric SteamID of the Steam account to pull profile data for.rows
- The amount numbers of matches.callback
- Called if all parameters are valid when Steam responds to us.
Note: This method ONlY works for your account
match_id
- You can get the match number from therequestMatches
method.callback
- Called if all parameters are valid when Steam responds to us.
Emitted when a GC connection is established. You shouldn't use any methods before you receive this. Note that this may be received (after it's first emitted) without any disconnectedFromGC event being emitted. In this case, the GC simply restarted.
reason
- A value from theGCConnectionStatus
enum
Emitted when we're disconnected from the GC for any reason. underlords will automatically try to reconnect and will emit connectedToGC
when reconnected.
Example usage:
const Underlords = require('dota-underlords');
let underlordsClient = new Underlords(steamUser);
underlordsClient.on('disconnectedFromGC', (reason) => {
if (reason == underlordsClient.GCConnectionStatus.GC_GOING_DOWN) {
console.log('GC going down');
}
});
status
- A value from theGCConnectionStatus
enumdata
- The raw data that was received
Emitted when we receive the status of our connection to the GC. Exactly when this is emitted is currently unknown. This may be removed in the future.