Load the cards based on the config

This commit is contained in:
Oliver Akins 2022-03-07 23:37:20 -06:00
parent 6bbd8d68c0
commit 6088128b7d
No known key found for this signature in database
GPG key ID: 3C2014AF9457AF99

View file

@ -45,13 +45,17 @@ export class Game {
* definitions. * definitions.
*/ */
private async loadDeck() { private async loadDeck() {
let cards = JSON.parse( if (config.game.fuel_deck.type == "file:json") {
await fs.readFile( let cards = JSON.parse(
path.join(process.cwd(), "cards.json"), await fs.readFile(
`utf-8` path.join(process.cwd(), config.game.fuel_deck.location),
) `utf-8`
); )
this._deck = new Deck(cards); );
this._deck = new Deck(cards);
} else {
throw new Error(`Unsupported data format for the cards: "${config.game.fuel_deck.type}"`)
}
}; };