node-gamedig/lib/game-resolver.js
Pedro Ivo Hudson 1f10ad0608
feat: add checking for older GIDs (#496)
* feat: add new games.extra.old_id

* add extra.old_id; standard release_year

* add option dontCheckOldIDs

* update naming, README, CHANGELOG

* Update CONTRIBUTING.md

* fix games.js

* add tool for checking duplicates

* update GAMES_LIST

* fix anchor links

* fix notes in generated game list

* Update GAMES_LIST.md

* Update GAMES_LIST.md

* add Game Object Example in CONTRIBUTING

* Update find_id_duplicates.js

* check skipOldIDs only once

* remove old ids; tweaks GAMES_LIST

* add MIGRATION document WIP

* Update GAMES_LIST.md

* update Halo Online name

* revert changes tool/generate

* remove extra line

* Update GAMES_LIST.md

* roll back GAME_LIST

* Update GAMES_LIST.md

* OMG

* WAT

* ok... hopefully the last change

* Update GAMES_LIST.md

* add MIGRATION ids

* roll back CONTRIBUTING

* Update CHANGELOG.md

* update skipOldIDs to checkOldIDs

* Update MIGRATION.md

* add migration note on README
2024-01-22 22:16:58 +02:00

27 lines
508 B
JavaScript

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