Load the cards based on the config
This commit is contained in:
parent
6bbd8d68c0
commit
6088128b7d
1 changed files with 11 additions and 7 deletions
|
|
@ -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}"`)
|
||||||
|
}
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue