Ecosyste.ms: Awesome
An open API service indexing awesome lists of open source software.
https://github.com/binocarlos/decked
Generate a list of playing cards based on a configurable pack
https://github.com/binocarlos/decked
Last synced: 10 days ago
JSON representation
Generate a list of playing cards based on a configurable pack
- Host: GitHub
- URL: https://github.com/binocarlos/decked
- Owner: binocarlos
- License: mit
- Created: 2014-05-22T12:28:21.000Z (over 10 years ago)
- Default Branch: master
- Last Pushed: 2014-08-20T14:45:19.000Z (over 10 years ago)
- Last Synced: 2024-11-07T12:04:39.066Z (13 days ago)
- Language: JavaScript
- Size: 160 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 0
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
decked
======[![Travis](http://img.shields.io/travis/binocarlos/decked.svg?style=flat)](https://travis-ci.org/binocarlos/decked)
Generate a list of playing cards based on a configurable pack
## installation
node:
```
$ npm install decked
```component:
```
$ component install binocarlos/decked
```## usage
Each card in a deck is represented by an object:
```js
{
suit:'diamond',
number:11,
name:'jack'
}
```The number of a jack is 11, queen is 12, king is 13 and ace is 14 or 1 depending on the 'ace' config option (high or low)
The suit property is one of:
* heart
* diamond
* club
* spade
* jokerAn ordered array of cards is returned.
```js
var decked = require('decked')var deck = decked({
// is ace 1 or 14
ace:'high',// will the deck have 2 jokers inside (card number 0)
jokers:2})
var cards = deck()
console.log(cards.length)
// 54 (because we included the jokers)
```You can pass a filter into the cards function to create a deck with only certain cards in:
```js
// a filter that will remove diamonds
var noDiamonds = deck(function(card){
return card.suit != 'diamond'
})// a filter that only returns face cards
var faceCards = deck(function(card){
return card.number >= 11
})
```## api
### `var deck = decked(config)`
create a new deck of cards with the given config options:
* ace ('low' | 'high') - sets the numeric value of the ace to 1 or 14
* jokers (true | false) - should the deck contain 2 jokers or not### `var deck = decked.sequence(config)`
create a sequence with each number having 4 cards (1 per suit)
config is:
* low - the start of the sequence (0)
* high - the end of the sequence (10)### `var cards = deck(filter)`
get an array of card objects with an optional filter (which can be an array of filters)
## license
MIT