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
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
d2ade062a69fd666059f5d92c710dba1311dc1abfdbe8832af87ebeffc24b9f0
|
|
| MD5 |
6cb31ba8dfcdf7d099a264e5adebe320
|
|
| BLAKE2b-256 |
f178a98ab25ab91f4e127134359b43ddaf3895100535a06735ea8d136bcea33d
|
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
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
8840a3d03912fc8417e87e5dc3d98a4fb09f04c3c409d911456fb1403b339314
|
|
| MD5 |
bf51df1f0a061be86955b55c12d2d5bd
|
|
| BLAKE2b-256 |
ed6fa91963864d18e28c9cc55e7a86c744f026040fc2ad4fc2e53e452dbd10ce
|