UNPKG

card-factory

Version:

A comprehensive library for card manipulation

28 lines (27 loc) 823 B
export default class Player { _deck; _piles; name; constructor(name, deck, piles, cardInitializer) { this._deck = deck; this.name = name; this._piles = piles.map(({ name, options }) => { if (options === undefined) options = {}; // Need somewhere to put all the cards to start the game... could be 1 spot per player if (name === cardInitializer) { return deck.createPileElement(name, deck.cards, options); } return deck.createPileElement(name, [], options); }); } get piles() { return this._piles; } get deck() { return this._deck; } getPile = (name) => { return this._piles.filter((element) => element.pile.name === name)[0]; }; }