Skip to main content

Display playing cards in ASCII format.

Project description

Ascii Cards

A Python script that generates ASCII art playing cards. Can print out multiple cards in one line, allowing for more flexibility with text based card games. Suits and ranks are adjustable.

Returns a string of playing cards when given a 2D list containing a card's rank and suit.

Due to the cards needing to stay proportional, cards only work when the passed height parameter is an odd number.

Features

  • Displays an ASCII art version of playing cards.
  • Supports any single or double character value for rank.
  • Supports any single character value for Suits.
  • Adjustable size of cards.
  • Displays a blank card.

Requirements

Python 3.x.

Install

pip install py-ascii-cards

How to use

To display cards.

import ascii_cards

print(ascii_cards.display_cards([["A", "♣"]]))

┌─────┐
│A    │
│  ♣  │
│    A│
└─────┘

print(ascii_cards.display_cards([["A", "♠"], ["10", "♥"]]))

┌─────┐ ┌─────┐
│A    │ │10   │
│  ♠  │ │  ♥  │
│    A│ │   10│
└─────┘ └─────┘

Can also display a single blank card.

print(ascii_cards.display_blank_card())

┌─────┐
│░░░░░│
│░░░░░│
│░░░░░│
└─────┘

Can also display a blank card in the display_cards function if passed a rank of the value "hidden".

print(ascii_cards.display_cards([["2", "♠"], ["hidden", "hidden"], ["8", '♥']]))

┌─────┐ ┌─────┐ ┌─────┐
│2    │ │░░░░░│ │8    │
│  ♠  │ │░░░░░│ │  ♥  │
│    2│ │░░░░░│ │    8│
└─────┘ └─────┘ └─────┘

Can adjust the size of the cards by passing it a height after the cards to display. Important to note that to stay proportional, the cards will only work if the passed height parameter is an odd number above 5.

print(ascii_cards.display_cards([["2", "♠"], ["hidden", "hidden"], ["8", '♥']], 7))

┌───────┐ ┌───────┐ ┌───────┐
│2      │ │░░░░░░░│ │8      │
│       │ │░░░░░░░│ │       │
│   ♠   │ │░░░░░░░│ │   ♥   │
│       │ │░░░░░░░│ │       │
│      2│ │░░░░░░░│ │      8│
└───────┘ └───────┘ └───────┘

Project details


Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

py_ascii_cards-0.1.1.tar.gz (4.6 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

py_ascii_cards-0.1.1-py3-none-any.whl (4.6 kB view details)

Uploaded Python 3

File details

Details for the file py_ascii_cards-0.1.1.tar.gz.

File metadata

  • Download URL: py_ascii_cards-0.1.1.tar.gz
  • Upload date:
  • Size: 4.6 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for py_ascii_cards-0.1.1.tar.gz
Algorithm Hash digest
SHA256 d2ade062a69fd666059f5d92c710dba1311dc1abfdbe8832af87ebeffc24b9f0
MD5 6cb31ba8dfcdf7d099a264e5adebe320
BLAKE2b-256 f178a98ab25ab91f4e127134359b43ddaf3895100535a06735ea8d136bcea33d

See more details on using hashes here.

File details

Details for the file py_ascii_cards-0.1.1-py3-none-any.whl.

File metadata

  • Download URL: py_ascii_cards-0.1.1-py3-none-any.whl
  • Upload date:
  • Size: 4.6 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.2.0 CPython/3.13.9

File hashes

Hashes for py_ascii_cards-0.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 8840a3d03912fc8417e87e5dc3d98a4fb09f04c3c409d911456fb1403b339314
MD5 bf51df1f0a061be86955b55c12d2d5bd
BLAKE2b-256 ed6fa91963864d18e28c9cc55e7a86c744f026040fc2ad4fc2e53e452dbd10ce

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page