From 6088128b7d03e9870e493102b2cf7b63225e821a Mon Sep 17 00:00:00 2001 From: Oliver Akins Date: Mon, 7 Mar 2022 23:37:20 -0600 Subject: [PATCH] Load the cards based on the config --- server/src/objects/Game.ts | 18 +++++++++++------- 1 file changed, 11 insertions(+), 7 deletions(-) diff --git a/server/src/objects/Game.ts b/server/src/objects/Game.ts index 447099f..7d7f9ba 100644 --- a/server/src/objects/Game.ts +++ b/server/src/objects/Game.ts @@ -45,13 +45,17 @@ export class Game { * definitions. */ private async loadDeck() { - let cards = JSON.parse( - await fs.readFile( - path.join(process.cwd(), "cards.json"), - `utf-8` - ) - ); - this._deck = new Deck(cards); + if (config.game.fuel_deck.type == "file:json") { + let cards = JSON.parse( + await fs.readFile( + 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}"`) + } };