mirror of
https://github.com/gamedig/node-gamedig.git
synced 2024-10-07 01:13:52 +02:00
ad9adff06c
* Redo imports and exports for lib * Redo imports and exports for bim * Redo imports and exports for games * Remove remaining module.exports * Use export default in lib * Use export default in protocols * Fix import in genreadme.js * Make package module and solve __dirname * Fix minecraft protocol imports * Fix imports on games and make binary runnable * Renamed protocol class exports to lowercase * Export promises class as default * Update README.md to use imports instead of require * Update CHANGELOG to mention the changes. * Remove Valve unused imports * Fix iconv import
39 lines
1.2 KiB
JavaScript
39 lines
1.2 KiB
JavaScript
import Core from './core.js';
|
|
|
|
export default class assettocorsa extends Core {
|
|
async run(state) {
|
|
const serverInfo = await this.request({
|
|
url: `http://${this.options.address}:${this.options.port}/INFO`,
|
|
responseType: 'json'
|
|
});
|
|
const carInfo = await this.request({
|
|
url: `http://${this.options.address}:${this.options.port}/JSON|${parseInt(Math.random() * 999999999999999, 10)}`,
|
|
responseType: 'json'
|
|
});
|
|
|
|
if (!serverInfo || !carInfo || !carInfo.Cars) {
|
|
throw new Error('Query not successful');
|
|
}
|
|
|
|
state.maxplayers = serverInfo.maxclients;
|
|
state.name = serverInfo.name;
|
|
state.map = serverInfo.track;
|
|
state.password = serverInfo.pass;
|
|
state.gamePort = serverInfo.port;
|
|
state.raw.carInfo = carInfo.Cars;
|
|
state.raw.serverInfo = serverInfo;
|
|
|
|
for (const car of carInfo.Cars) {
|
|
if (car.IsConnected) {
|
|
state.players.push({
|
|
name: car.DriverName,
|
|
car: car.Model,
|
|
skin: car.Skin,
|
|
nation: car.DriverNation,
|
|
team: car.DriverTeam
|
|
});
|
|
}
|
|
}
|
|
}
|
|
}
|