card-games-utils
Version:
Utility package for card games
32 lines • 1.47 kB
TypeScript
/**
* Class to perform normal operations on any kind of Deck of cards
* @class
*/
export declare class CardDeck {
/**
* @method
* @static
*
* shuffle the array of items(cards)
*
* @template T - generic type of item(card) in the array.
* @param {T[]} cards - The array of items(cards) to be shuffled.
* @returns {T[]} - A new array with the items(cards) shuffled randomly.
*/
static shuffleCards<T>(cards: T[]): T[];
/**
* @method
* @static
* Distributes specified number of cards per player to given number of players.
*
* @template T - generic type of item(card) in the array.
* @param {T[]} cards - the array of items(cards) to be distributed.
* @param {number} numberOfPlayers - the number of players to distribute cards to.
* @param {number} cardPerPlayer - the number of cards to be distributed per player.
* @param {boolean} shouldDealAround - optional boolean flag, if true, distributes one card per player on each iteration. else distributes all needed cards to player at once and going to another player
* @returns {T[][]} - returns 2-dimensional array of cards distributed to each player.
* @throws {Error} - if there are not enough cards to distribute among players.
*/
static distributeCards<T>(cards: T[], numberOfPlayers: number, cardPerPlayer: number, shouldDealAround?: boolean): [T[][], T[]];
}
//# sourceMappingURL=CardDeck.d.ts.map