0.1.1 • Published 3 years ago

plain-cards v0.1.1

Weekly downloads
7
License
MIT
Repository
github
Last release
3 years ago

Plain Cards

Plain Cards is a small Typescript library for representing a deck of plain (playing) cards for use in card game apps or wherever.

Installation

npm install --save plain-cards

Usage

Creating a new deck

Return a new instance of the Deck with shuffled cards:

import Deck from "plain-cards";

const deck = new Deck();

Properties

NameTypeDescription
cardsCard[]List of cards remaining in the deck.
sizenumberNumber of cards remaining in the deck.

Methods

NameSignatureDescription
shuffle() => Card[]Shuffles the cards within the deck. Also returns the newly shuffled cards.
draw(count = 1) => Card[]Removes and returns the top card from the deck. Passing a number for count will return that many cards.
peek(count = 1) => CardReturns the card at the top of the deck. Passing a number for count will return that card in the order of the deck. Note: Unlike draw this does not remove the card from the deck.
cut(count: number) => Card[]Cut the deck at a card given by count. Also returns the new order of the cards