1.3.1 • Published 4 years ago

cards-ascii v1.3.1

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

Cards Ascii

Displays all cards in ascii.

Install

yarn add cards-ascii

or

npm install cards-ascii

Usage

let cardsAscii = require("cards-ascii");

API

getAll(width)

Example

let cards = cardsAscii.getAll().map(({ graphic }) => {
    return graphic;
});
  
console.log(cards.join('\n'));

//console.log:
// ┌─────────┐
// |A        │
// |         |
// |         |
// |    ♠    |
// |         |
// |         |
// │        A│
// └─────────┘
// ┌─────────┐
// |2        │
// |         |
// |         |
// |    ♠    |
// |         |
// |         |
// │        2│
// └─────────┘
// and more ...

Custom card width

let cards = cardsAscii.getAll(5).map(({ graphic }) => {
    return graphic;
});
  
console.log(cards.join('\n'));

//console.log:
// ┌───┐
// |K  │
// |   |
// |   |
// | ♣ |
// |   |
// |   |
// │  K│
// └───┘
// and more ...

getAllBySuit(suit)

Example

let cards = cardsAscii.getAllBySuit("heart").map(({ graphic }) => {
    return graphic;
});
  
console.log(cards.join('\n'));

// console.log:
// ┌─────────┐
// |A        │
// |         |
// |         |
// |    ♥    |
// |         |
// |         |
// │        A│
// └─────────┘
// ┌─────────┐
// |2        │
// |         |
// |         |
// |    ♥    |
// |         |
// |         |
// │        2│
// └─────────┘
// ┌─────────┐
// |3        │
// |         |
// |         |
// |    ♥    |
// |         |
// |         |
// │        3│
// └─────────┘

getById(cardId)

Example

let card = cardsAscii.getById(52).graphic;

console.log(card);

// console.log:
// ┌─────────┐
// |K        │
// |         |
// |         |
// |    ♣    |
// |         |
// |         |
// │        K│
// └─────────┘

getAllByNumber(number)

Example

let cards = cardsAscii.getAllByNumber("J").map(({ graphic }) => {
  return graphic;
});

console.log(cards.join("\n"));

// console.log:
// ┌─────────┐
// |J        │
// |         |
// |         |
// |    ♠    |
// |         |
// |         |
// │        J│
// └─────────┘
// ┌─────────┐
// |J        │
// |         |
// |         |
// |    ♥    |
// |         |
// |         |
// │        J│
// └─────────┘
// ┌─────────┐
// |J        │
// |         |
// |         |
// |    ♦    |
// |         |
// |         |
// │        J│
// └─────────┘
// ┌─────────┐
// |J        │
// |         |
// |         |
// |    ♣    |
// |         |
// |         |
// │        J│
// └─────────┘

getByNumberAndSuit(number, suit)

Example

let card = cardsAscii.getByNumberAndSuit(3,"heart").graphic;

console.log(card);

// console.log:
// ┌─────────┐
// |3        │
// |         |
// |         |
// |    ♥    |
// |         |
// |         |
// │        3│
// └─────────┘
1.3.1

4 years ago

1.3.0

4 years ago

1.2.0

4 years ago

1.1.1

4 years ago

1.1.0

4 years ago

1.0.0

4 years ago