More release dates and readme cleanup

This commit is contained in:
mmorrison 2019-02-07 00:37:33 -06:00
parent 0c19c734b1
commit ab6e9064d2
3 changed files with 202 additions and 196 deletions

View file

@ -3,7 +3,9 @@ const Path = require('path'),
class GameResolver {
constructor() {
this.games = this._readGames();
const loaded = this._readGames();
this.gamesByKey = loaded.gamesByKey;
this.games = loaded.games;
}
lookup(type) {
@ -15,7 +17,7 @@ class GameResolver {
};
}
const game = this.games.get(type);
const game = this.gamesByKey.get(type);
if(!game) throw Error('Invalid game: '+type);
return game.options;
}
@ -24,11 +26,15 @@ class GameResolver {
let out = '';
out += '| GameDig Type ID | Name | Notes\n';
out += '|---|---|---\n';
for(const [key,game] of this.games.entries()) {
if (!game.pretty) {
continue;
}
out += "| " + ("`"+key+"`").padEnd(10, " ") + " "
const sorted = this.games
.filter(game => game.pretty)
.sort((a,b) => {
return a.pretty.localeCompare(b.pretty);
});
for(const game of sorted) {
let keysOut = game.keys.map(key => '`'+key+'`').join('<br>');
out += "| " + keysOut.padEnd(10, " ") + " "
+ "| " + game.pretty;
if(game.extra.doc_notes)
out += " | [Notes](#"+game.extra.doc_notes+")";
@ -40,7 +46,9 @@ class GameResolver {
_readGames() {
const gamesFile = Path.normalize(__dirname+'/../games.txt');
const lines = fs.readFileSync(gamesFile,'utf8').split('\n');
const games = new Map();
const gamesByKey = new Map();
const games = [];
for (let line of lines) {
// strip comments
@ -50,17 +58,25 @@ class GameResolver {
if(!line) continue;
const split = line.split('|');
const gameId = split[0].trim();
const keys = split[0].trim().split(',');
const name = split[1].trim();
const options = this._parseList(split[3]);
options.protocol = split[2].trim();
const extra = this._parseList(split[4]);
games.set(gameId, {
pretty: split[1].trim(),
const game = {
keys: keys,
pretty: name,
options: options,
extra: this._parseList(split[4])
});
extra: extra
};
for (const key of keys) {
gamesByKey.set(key, game);
}
games.push(game);
}
return games;
return { gamesByKey, games };
}
_parseList(str) {