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.
|
||||
*/
|
||||
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}"`)
|
||||
}
|
||||
};
|
||||
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue