node-gamedig/lib/game-resolver.js

22 lines
409 B
JavaScript

import { games } from './games.js'
export const lookup = (type) => {
if (!type) { throw Error('No game specified') }
if (type.startsWith('protocol-')) {
return {
protocol: type.substring(9)
}
}
let game = games[type]
Object.keys(games).forEach((id) => {
if (games[id].alias) game = games[id]
})
if (!game) { throw Error('Invalid game: ' + type) }
return game.options
}