2019-01-10 13:03:07 +01:00
|
|
|
const Core = require('./core');
|
2018-02-13 10:24:40 +01:00
|
|
|
|
2019-01-07 01:52:03 +01:00
|
|
|
class Kspdmp extends Core {
|
2019-01-10 13:03:07 +01:00
|
|
|
async run(state) {
|
2020-07-05 06:28:03 +02:00
|
|
|
const json = await this.request({
|
|
|
|
url: 'http://'+this.options.address+':'+this.options.port,
|
|
|
|
responseType: 'json'
|
2019-01-10 13:03:07 +01:00
|
|
|
});
|
2018-02-13 10:24:40 +01:00
|
|
|
|
2019-01-10 13:03:07 +01:00
|
|
|
for (const one of json.players) {
|
|
|
|
state.players.push({name:one.nickname,team:one.team});
|
|
|
|
}
|
2018-02-13 10:24:40 +01:00
|
|
|
|
2019-01-10 13:03:07 +01:00
|
|
|
for (const key of Object.keys(json)) {
|
|
|
|
state.raw[key] = json[key];
|
|
|
|
}
|
|
|
|
state.name = json.server_name;
|
|
|
|
state.maxplayers = json.max_players;
|
2019-01-12 12:45:09 +01:00
|
|
|
state.gamePort = json.port;
|
2019-01-10 13:03:07 +01:00
|
|
|
if (json.players) {
|
|
|
|
const split = json.players.split(', ');
|
|
|
|
for (const name of split) {
|
|
|
|
state.players.push({name:name});
|
2018-02-13 10:24:40 +01:00
|
|
|
}
|
2019-01-10 13:03:07 +01:00
|
|
|
}
|
2018-02-13 10:24:40 +01:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
module.exports = Kspdmp;
|