Skip to content

feat: Add game type alias #487

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 5 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
1 change: 1 addition & 0 deletions README.md
Original file line number Diff line number Diff line change
Expand Up @@ -59,6 +59,7 @@ Confused on how this works, or you want to see more? Checkout the [examples](/ex
| **portCache** | boolean | true | After you queried a server, the second time you query that exact server (identified by specified ip and port), first add an attempt to query with the last successful port. |
| **noBreadthOrder** | boolean | false | Enable the behaviour of retrying an attempt X times followed by the next attempt X times, otherwise try attempt A, then B, then A, then B until reaching the X retry count of each. |
| **checkOldIDs** | boolean | false | Also checks the old ids amongst the current ones. |
| **checkAlias** | boolean | false | Also checks for alternative game ids. |

## Query Response

Expand Down
2 changes: 1 addition & 1 deletion bin/gamedig.js
Original file line number Diff line number Diff line change
Expand Up @@ -6,7 +6,7 @@ import Minimist from 'minimist'
import { GameDig } from './../lib/index.js'

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', 'checkAlias'],
string: ['guildId', 'listenUdpPort', 'ipFamily', 'token'],
default: {
stripColors: true,
Expand Down
6 changes: 6 additions & 0 deletions lib/game-resolver.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,6 +13,12 @@ export const lookup = (options) => {

let game = games[type]

if (options.checkAlias) {
Object.keys(games).forEach((id) => {
if (games[id]?.extra?.alias) game = games[id]
})
}

if (options.checkOldIDs) {
Object.keys(games).forEach((id) => {
if (games[id]?.extra?.old_id === type) {
Expand Down
10 changes: 7 additions & 3 deletions tools/generate_games_list.js
Original file line number Diff line number Diff line change
Expand Up @@ -21,12 +21,16 @@ sortedGamesIds.forEach(key => {
})

let generated = ''
generated += '| GameDig Type ID | Name | See Also\n'
generated += '|---|---|---\n'
generated += '| GameDig Type ID | Alias | Name | See Also\n'
generated += '|---|---|---|---\n'

for (const id in sortedGames) {
const game = sortedGames[id]
generated += '| ' + id.padEnd(10, ' ') + ' | ' + game.name
if (!game?.extra?.alias) {
game.alias = ' '
}
generated += '| ' + id.padEnd(10, ' ') + ' | ' + game.alias + ' | ' + game.name

const notes = []
if (game?.extra?.doc_notes) {
notes.push('[Notes](#' + game.extra.doc_notes + ')')
Expand Down