mirror of
https://github.com/tribufu/node-gamedig
synced 2026-06-01 09:42:41 +00:00
Update readme with new games
This commit is contained in:
parent
088369ea9d
commit
1eecba1fdb
3 changed files with 28 additions and 13 deletions
|
|
@ -1,77 +0,0 @@
|
|||
var gbxremote = require('gbxremote'),
|
||||
async = require('async');
|
||||
|
||||
module.exports = require('./core').extend({
|
||||
init: function() {
|
||||
this._super();
|
||||
this.options.port = 5000;
|
||||
this.gbxclient = false;
|
||||
},
|
||||
reset: function() {
|
||||
this._super();
|
||||
if(this.gbxclient) {
|
||||
this.gbxclient.terminate();
|
||||
this.gbxclient = false;
|
||||
}
|
||||
},
|
||||
run: function() {
|
||||
var self = this;
|
||||
|
||||
var cmds = [
|
||||
['Connect'],
|
||||
['Authenticate', this.options.login,this.options.password],
|
||||
['GetStatus'],
|
||||
['GetPlayerList',500,0],
|
||||
['GetServerOptions'],
|
||||
['GetCurrentChallengeInfo'],
|
||||
['GetCurrentGameInfo']
|
||||
];
|
||||
var results = [];
|
||||
|
||||
async.eachSeries(cmds, function(cmdset,c) {
|
||||
var cmd = cmdset[0];
|
||||
var params = cmdset.slice(1);
|
||||
|
||||
if(cmd == 'Connect') {
|
||||
var client = self.gbxclient = gbxremote.createClient(self.options.port,self.options.host, function(err) {
|
||||
if(err) return self.error('GBX error '+JSON.stringify(err));
|
||||
c();
|
||||
});
|
||||
client.on('error',function(){});
|
||||
} else {
|
||||
self.gbxclient.methodCall(cmd, params, function(err, value) {
|
||||
if(err) return self.error('XMLRPC error '+JSON.stringify(err));
|
||||
results.push(value);
|
||||
c();
|
||||
});
|
||||
}
|
||||
}, function() {
|
||||
var state = {};
|
||||
|
||||
var gamemode = '';
|
||||
var igm = results[5].GameMode;
|
||||
if(igm == 0) gamemode="Rounds";
|
||||
if(igm == 1) gamemode="Time Attack";
|
||||
if(igm == 2) gamemode="Team";
|
||||
if(igm == 3) gamemode="Laps";
|
||||
if(igm == 4) gamemode="Stunts";
|
||||
if(igm == 5) gamemode="Cup";
|
||||
|
||||
state.name = self.stripColors(results[3].Name);
|
||||
state.password = (results[3].Password != 'No password');
|
||||
state.maxplayers = results[3].CurrentMaxPlayers;
|
||||
state.map = self.stripColors(results[4].Name);
|
||||
state.gametype = gamemode;
|
||||
|
||||
state.players = [];
|
||||
results[2].forEach(function(player) {
|
||||
state.players.push({name:self.stripColors(player.Name)});
|
||||
});
|
||||
|
||||
console.log(state);
|
||||
});
|
||||
},
|
||||
stripColors: function(str) {
|
||||
return str.replace(/\$([0-9a-f][^\$]?[^\$]?|[^\$]?)/g,'');
|
||||
}
|
||||
});
|
||||
Loading…
Add table
Add a link
Reference in a new issue