feat: Add Farming Simulator 22/19 (#531)
* Added token paramter * Added Farming Simulator 2022 * Fixed order * Undo debug line * Update Farming Simulator 22 support (By @Vito0912 #531) * Added Farming Simulator 2019 support * Revert change * Update release year for Farming Simulator 2019 * Update mods array to raw.mods in farmingsimulator.js * Update Farming Simulator naming in GAMES_LIST.md * Missed some names * Add server version to state.raw and eslint
This commit is contained in:
parent
321f35999e
commit
3a17184862
|
@ -4,6 +4,8 @@
|
||||||
* Euro Truck Simulator 2 (2012) - Added support (By @podrivo #523)
|
* Euro Truck Simulator 2 (2012) - Added support (By @podrivo #523)
|
||||||
* Eco - Fixed querying servers using reverse queries and player names (By @Vito0912 #526)
|
* Eco - Fixed querying servers using reverse queries and player names (By @Vito0912 #526)
|
||||||
* Factorio (2016) - Added support (By @Vito0912 #527)
|
* Factorio (2016) - Added support (By @Vito0912 #527)
|
||||||
|
* Farming Simulator 22 (2021) - Added support (By @Vito0912 #531)
|
||||||
|
* Farming Simulator 19 (2018) - Added support (By @Vito0912 #531)
|
||||||
|
|
||||||
## 5.0.0-beta.2
|
## 5.0.0-beta.2
|
||||||
* Fixed support for projects using `require`.
|
* Fixed support for projects using `require`.
|
||||||
|
|
|
@ -122,6 +122,8 @@
|
||||||
| factorio | Factorio | |
|
| factorio | Factorio | |
|
||||||
| farcry | Far Cry | |
|
| farcry | Far Cry | |
|
||||||
| farcry2 | Far Cry 2 | |
|
| farcry2 | Far Cry 2 | |
|
||||||
|
| farmingsimulator19 | Farming Simulator 19 | [Notes](#farmingsimulator) |
|
||||||
|
| farmingsimulator22 | Farming Simulator 22 | [Notes](#farmingsimulator) |
|
||||||
| fear | F.E.A.R. | |
|
| fear | F.E.A.R. | |
|
||||||
| ffow | Frontlines: Fuel of War | |
|
| ffow | Frontlines: Fuel of War | |
|
||||||
| fof | Fistful of Frags | [Valve Protocol](#valve) |
|
| fof | Fistful of Frags | [Valve Protocol](#valve) |
|
||||||
|
@ -347,7 +349,6 @@
|
||||||
* DirtyBomb
|
* DirtyBomb
|
||||||
* Doom - Skulltag
|
* Doom - Skulltag
|
||||||
* Doom - ZDaemon
|
* Doom - ZDaemon
|
||||||
* Farming Simulator
|
|
||||||
* Freelancer
|
* Freelancer
|
||||||
* Ghost Recon
|
* Ghost Recon
|
||||||
* GRAV Online
|
* GRAV Online
|
||||||
|
@ -443,6 +444,10 @@ Conan Exiles never responds to player query.
|
||||||
### <a name="minecraft">Minecraft
|
### <a name="minecraft">Minecraft
|
||||||
Many Minecraft servers do not respond with players data.
|
Many Minecraft servers do not respond with players data.
|
||||||
|
|
||||||
|
### <a name='farmingsimulator'>Farming Simulator
|
||||||
|
Farming Simulator servers need a token (reffered as code in the game). It can be obtained at your server's web interface (http://ip:port/settings.html). It can be passed to GameDig with the additional option: `token`. It does only work for your own server.
|
||||||
|
The response includes much information about the server. Currently, only the fields about server information (name, map, version, etc.), players and mods are parsed.
|
||||||
|
|
||||||
Protocols with Additional Notes
|
Protocols with Additional Notes
|
||||||
---
|
---
|
||||||
|
|
||||||
|
|
|
@ -7,7 +7,7 @@ import { GameDig } from './../lib/index.js'
|
||||||
|
|
||||||
const argv = Minimist(process.argv.slice(2), {
|
const argv = Minimist(process.argv.slice(2), {
|
||||||
boolean: ['pretty', 'debug', 'givenPortOnly', 'requestRules', 'requestRulesRequired', 'requestPlayersRequired', 'stripColors', 'portCache', 'noBreadthOrder', 'checkOldIDs'],
|
boolean: ['pretty', 'debug', 'givenPortOnly', 'requestRules', 'requestRulesRequired', 'requestPlayersRequired', 'stripColors', 'portCache', 'noBreadthOrder', 'checkOldIDs'],
|
||||||
string: ['guildId', 'listenUdpPort', 'ipFamily'],
|
string: ['guildId', 'listenUdpPort', 'ipFamily', 'token'],
|
||||||
default: {
|
default: {
|
||||||
stripColors: true,
|
stripColors: true,
|
||||||
portCache: true
|
portCache: true
|
||||||
|
|
16
lib/games.js
16
lib/games.js
|
@ -1186,6 +1186,22 @@ export const games = {
|
||||||
protocol: 'ase'
|
protocol: 'ase'
|
||||||
}
|
}
|
||||||
},
|
},
|
||||||
|
farmingsimulator19: {
|
||||||
|
name: 'Farming Simulator 19',
|
||||||
|
release_year: 2018,
|
||||||
|
options: {
|
||||||
|
port: 8080,
|
||||||
|
protocol: 'farmingsimulator'
|
||||||
|
}
|
||||||
|
},
|
||||||
|
farmingsimulator22: {
|
||||||
|
name: 'Farming Simulator 22',
|
||||||
|
release_year: 2021,
|
||||||
|
options: {
|
||||||
|
port: 8080,
|
||||||
|
protocol: 'farmingsimulator'
|
||||||
|
}
|
||||||
|
},
|
||||||
fof: {
|
fof: {
|
||||||
name: 'Fistful of Frags',
|
name: 'Fistful of Frags',
|
||||||
release_year: 2014,
|
release_year: 2014,
|
||||||
|
|
|
@ -0,0 +1,55 @@
|
||||||
|
import Core from './core.js'
|
||||||
|
import cheerio from 'cheerio'
|
||||||
|
|
||||||
|
export default class farmingsimulator extends Core {
|
||||||
|
async run (state) {
|
||||||
|
if (!this.options.port) this.options.port = 8080
|
||||||
|
if (!this.options.token) throw new Error(`No token provided. You can get it from http://${this.options.host}:${this.options.port}/settings.html`)
|
||||||
|
|
||||||
|
const request = await this.request({
|
||||||
|
url: `http://${this.options.host}:${this.options.port}/feed/dedicated-server-stats.xml?code=${this.options.token}`,
|
||||||
|
responseType: 'text'
|
||||||
|
})
|
||||||
|
|
||||||
|
const $ = cheerio.load(request, {
|
||||||
|
xmlMode: true
|
||||||
|
})
|
||||||
|
|
||||||
|
const serverInfo = $('Server')
|
||||||
|
const playerInfo = serverInfo.find('Slots')
|
||||||
|
|
||||||
|
state.name = serverInfo.attr('name')
|
||||||
|
state.map = serverInfo.attr('mapName')
|
||||||
|
state.numplayers = playerInfo.attr('numUsed')
|
||||||
|
state.maxplayers = playerInfo.attr('capacity')
|
||||||
|
|
||||||
|
$('Player').each(function () {
|
||||||
|
if ($(this).attr('isUsed') === 'true') {
|
||||||
|
state.players.push({
|
||||||
|
name: $(this).text(),
|
||||||
|
raw: {
|
||||||
|
isAdmin: $(this).attr('isAdmin') === 'true',
|
||||||
|
uptime: parseInt($(this).attr('uptime'), 10)
|
||||||
|
}
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
state.raw.mods = []
|
||||||
|
$('Mod').each(function () {
|
||||||
|
if ($(this).attr('name') !== undefined) {
|
||||||
|
state.raw.mods.push({
|
||||||
|
name: $(this).text(),
|
||||||
|
short_name: $(this).attr('name'),
|
||||||
|
author: $(this).attr('author'),
|
||||||
|
version: $(this).attr('version'),
|
||||||
|
hash: $(this).attr('hash')
|
||||||
|
})
|
||||||
|
}
|
||||||
|
})
|
||||||
|
|
||||||
|
state.raw.version = serverInfo.attr('version')
|
||||||
|
|
||||||
|
// TODO: Add state.raw
|
||||||
|
}
|
||||||
|
}
|
|
@ -11,6 +11,7 @@ import eco from './eco.js'
|
||||||
import eldewrito from './eldewrito.js'
|
import eldewrito from './eldewrito.js'
|
||||||
import epic from './epic.js'
|
import epic from './epic.js'
|
||||||
import factorio from './factorio.js'
|
import factorio from './factorio.js'
|
||||||
|
import farmingsimulator from './farmingsimulator.js'
|
||||||
import ffow from './ffow.js'
|
import ffow from './ffow.js'
|
||||||
import fivem from './fivem.js'
|
import fivem from './fivem.js'
|
||||||
import gamespy1 from './gamespy1.js'
|
import gamespy1 from './gamespy1.js'
|
||||||
|
@ -56,8 +57,8 @@ import dayz from './dayz.js'
|
||||||
import theisleevrima from './theisleevrima.js'
|
import theisleevrima from './theisleevrima.js'
|
||||||
|
|
||||||
export {
|
export {
|
||||||
armagetron, ase, asa, assettocorsa, battlefield, buildandshoot, cs2d, discord, doom3, eco, epic, factorio, ffow, fivem, gamespy1,
|
armagetron, ase, asa, assettocorsa, battlefield, buildandshoot, cs2d, discord, doom3, eco, epic, factorio, farmingsimulator, ffow,
|
||||||
gamespy2, gamespy3, geneshift, goldsrc, hexen2, jc2mp, kspdmp, mafia2mp, mafia2online, minecraft,
|
fivem, gamespy1, gamespy2, gamespy3, geneshift, goldsrc, hexen2, jc2mp, kspdmp, mafia2mp, mafia2online, minecraft,
|
||||||
minecraftbedrock, minecraftvanilla, mumble, mumbleping, nadeo, openttd, palworld, quake1, quake2, quake3, rfactor, samp,
|
minecraftbedrock, minecraftvanilla, mumble, mumbleping, nadeo, openttd, palworld, quake1, quake2, quake3, rfactor, samp,
|
||||||
savage2, starmade, starsiege, teamspeak2, teamspeak3, terraria, tribes1, tribes1master, unreal2, ut3, valve,
|
savage2, starmade, starsiege, teamspeak2, teamspeak3, terraria, tribes1, tribes1master, unreal2, ut3, valve,
|
||||||
vcmp, ventrilo, warsow, eldewrito, beammpmaster, beammp, dayz, theisleevrima
|
vcmp, ventrilo, warsow, eldewrito, beammpmaster, beammp, dayz, theisleevrima
|
||||||
|
|
Loading…
Reference in New Issue