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.
*/
private async loadDeck() {
if (config.game.fuel_deck.type == "file:json") {
let cards = JSON.parse(
await fs.readFile(
path.join(process.cwd(), "cards.json"),
path.join(process.cwd(), config.game.fuel_deck.location),
`utf-8`
)
);
this._deck = new Deck(cards);
} else {
throw new Error(`Unsupported data format for the cards: "${config.game.fuel_deck.type}"`)
}
};