Update config to nest card information within a separate object.
This commit is contained in:
parent
f6a8495316
commit
9743e1a53a
2 changed files with 14 additions and 7 deletions
|
|
@ -70,17 +70,17 @@ export class Game {
|
||||||
*/
|
*/
|
||||||
|
|
||||||
// parse the questions from the CSV
|
// parse the questions from the CSV
|
||||||
let data = readFileSync(conf.game.cards.questions, `utf-8`).replace(/\r/g, ``);
|
let data = readFileSync(conf.game.cards.questions.fingerprint, `utf-8`).replace(/\r/g, ``);
|
||||||
let questions: question_deck[] = [];
|
let questions: question_deck[] = [];
|
||||||
for (var line of data.split(`\n`).slice(1)) {
|
for (var line of data.split(`\n`).slice(conf.game.cards.questions.header_rows)) {
|
||||||
questions.push(line.split(`,`)[0]);
|
questions.push(line.split(`,`)[conf.game.cards.questions.column]);
|
||||||
};
|
};
|
||||||
this._questions = new Deck(questions);
|
this._questions = new Deck(questions);
|
||||||
|
|
||||||
// Parse the object deck from CSV
|
// Parse the object deck from CSV
|
||||||
let objectsCSV = readFileSync(conf.game.cards.objects, `utf-8`).replace(/\r/g, ``);
|
let objectsCSV = readFileSync(conf.game.cards.objects.fingerprint, `utf-8`).replace(/\r/g, ``);
|
||||||
let objects: object_deck[] = [];
|
let objects: object_deck[] = [];
|
||||||
for (var line of objectsCSV.split(`\n`).slice(1)) {
|
for (var line of objectsCSV.split(`\n`).slice(conf.game.cards.objects.header_rows)) {
|
||||||
objects.push(line.split(`,`));
|
objects.push(line.split(`,`));
|
||||||
};
|
};
|
||||||
this._objects = new Deck(objects);
|
this._objects = new Deck(objects);
|
||||||
|
|
|
||||||
11
server/src/types/config.d.ts
vendored
11
server/src/types/config.d.ts
vendored
|
|
@ -18,8 +18,15 @@ interface config {
|
||||||
cards: {
|
cards: {
|
||||||
type: `csv` | `sheets`;
|
type: `csv` | `sheets`;
|
||||||
key?: string;
|
key?: string;
|
||||||
questions: string;
|
questions: {
|
||||||
objects: string;
|
fingerprint: string;
|
||||||
|
column: number;
|
||||||
|
header_rows: number;
|
||||||
|
};
|
||||||
|
objects: {
|
||||||
|
fingerprint: string;
|
||||||
|
header_rows: number;
|
||||||
|
};
|
||||||
};
|
};
|
||||||
};
|
};
|
||||||
}
|
}
|
||||||
Loading…
Add table
Add a link
Reference in a new issue