-
Notifications
You must be signed in to change notification settings - Fork 11
/
Copy pathindex.js
33 lines (27 loc) · 1.15 KB
/
index.js
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
const assert = require('assert');
const cards = require('./src/cards');
const decks = require('./src/decks');
const moderator = require('./src/moderator');
const game = require('./src/game');
const languages = require('./src/languages');
exports.getCards = cards.getAll;
exports.getDecks = decks.getAll;
exports.getModes = game.mode;
exports.getDeck = decks.get;
exports.getScriptFromDeck = moderator.getScriptFromDeck;
exports.getLanguages = languages.getLanguages;
exports.translateDeck = languages.translateDeck;
exports.translations = require('./src/data/translations');
exports.filterLevels = moderator.levels;
exports.getGame = (players, options = {}) => {
const language = options.language || 'en';
const mode = options.mode || game.mode.NORMAL;
const { deck } = options;
const deckName = options.deckName || 'all';
assert(players > 0, 'Players must be greater than 0.');
if (deck) {
return game.create(players, language, cards.inCustomDeck(deck), mode);
}
assert(!options.deckName || decks.exists(deckName), `Deck ${deckName} is not defined.`);
return game.create(players, language, cards.inDeck(deckName), mode);
};