mirror of
https://github.com/gamedig/node-gamedig.git
synced 2024-11-17 09:18:31 +01:00
Add Assetto Corsa support
This commit is contained in:
parent
211c2d1635
commit
9db659b86b
3 changed files with 43 additions and 0 deletions
|
@ -100,6 +100,7 @@ Games List
|
|||
| `armacwa` | ARMA: Cold War Assault (2011)
|
||||
| `armar` | ARMA: Resistance (2011)
|
||||
| `armagetron` | Armagetron Advanced (2001)
|
||||
| `assettocorsa` | Assetto Corsa (2014)
|
||||
| `atlas` | Atlas (2018)
|
||||
| `baldursgate` | Baldur's Gate (1998)
|
||||
| `bat1944` | Battalion 1944 (2018)
|
||||
|
|
|
@ -6,6 +6,7 @@ aoe2|Age of Empires 2 (1999)|ase|port_query=27224
|
|||
alienarena|Alien Arena (2004)|quake2|port_query=27910
|
||||
alienswarm|Alien Swarm (2010)|valve|port=27015
|
||||
arkse|Ark: Survival Evolved (2017)|valve|port=7777,port_query=27015
|
||||
assettocorsa|Assetto Corsa (2014)|assettocorsa|port=9610
|
||||
atlas|Atlas (2018)|valve|port=5761,port_query_offset=51800
|
||||
avp2|Aliens versus Predator 2 (2001)|gamespy1|port=27888
|
||||
avp2010|Aliens vs. Predator (2010)|valve|port=27015
|
||||
|
|
41
protocols/assettocorsa.js
Normal file
41
protocols/assettocorsa.js
Normal file
|
@ -0,0 +1,41 @@
|
|||
const Core = require('./core');
|
||||
|
||||
class AssettoCorsa extends Core {
|
||||
async run(state) {
|
||||
const serverInfo = await this.request({
|
||||
json: true,
|
||||
uri: `http://${this.options.address}:${this.options.port}/INFO`
|
||||
});
|
||||
const carInfo = await this.request({
|
||||
json: true,
|
||||
uri: `http://${this.options.address}:${this.options.port}/JSON|${parseInt(Math.random() * 999999999999999, 10)}`
|
||||
});
|
||||
|
||||
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;
|
||||
|
||||
state.players = carInfo.Cars.reduce((r, e) => {
|
||||
if (e.IsConnected) {
|
||||
r.push({
|
||||
name: e.DriverName,
|
||||
car: e.Model,
|
||||
skin: e.Skin,
|
||||
nation: e.DriverNation,
|
||||
team: e.DriverTeam
|
||||
});
|
||||
}
|
||||
return r;
|
||||
}, state.players);
|
||||
}
|
||||
}
|
||||
|
||||
module.exports = AssettoCorsa;
|
Loading…
Reference in a new issue