Skip to main content

A dependancy free deck, card, and hand manager.

Project description

Vox Cards

This is an easy to use dependancy free deck manager, making it easy to develope the logic of card games without worrying about creating ways to handle the decks, cards, and hands.

Installation

Install using pip: py -m pip install vox_cards

Basic Usage

import vox_cards.deck as cards

deck = cards.Deck(2) # Pass the number of hands to construct this deck with.

deck.deal() # The default number of cards to deal is 7

player_1, player_2 = deck.hands

for card in player_1: # Print all cards in the first hand.
    print(card.full) # Prints the full name of the card (i.e. "10 of Clubs").

Keep in mind that hands are iterable, but only return the cards they hold. With that in mind, there is also the ability for hands to draw and discard cards.

# This will draw the top 2 cards for each palyer, then discard 2 cards at random.
player_1.draw(2)
player_1.discard(2)

player_2.draw(2)
player_2.discard(2)


# You can also pass a card instance to hand.discard for discarding specific card(s).
player_1.discard(player_1.cards[0])
player_2.discard(player_2.cards[0])
More complex use case

Here is a more complex use case that features the main components of this module. It doesn't use any logic, but hopefully it gives you an idea of some use cases for this project.

import vox_cards.deck as cards

deck = cards.Deck(3)

for _ in range(3):
    deck.shuffle()

player_1, player_2, river = deck.hands

for _ in range(2):
    player_1.draw()
    player_2.draw()

river.draw(3)
river.draw()
river.draw()

print("\nPlayer 1's hand:")
for card in player_1:
    print(card.full)

print("\nPlayer 2's hand:")
for card in player_2:
    print(card.full)

print("\n\nAnd the river is:")
for card in river:
    print(card.full)

Here is the output for the code above:

>>>py example.py
Player 1's hand:
Queen of Spades
Jack of Spades

Player 2's hand:
6 of Clubs
8 of Spades


And the river is:
6 of Hearts
8 of Clubs
5 of Hearts
4 of Hearts
9 of Spades

Looks like player 2 wins with a 2-pair, how fitting.

Documentation

This entire project is still a WIP and has not been officially released yet. Full documentation will come for this project whenever it has been released in a stable state. Until then, refer to the usage examples and the github repo for most use cases.

For a full list of everything you can do, view the docs

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

vox_cards-0.1.8.tar.gz (5.7 kB view details)

Uploaded Source

Built Distribution

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

vox_cards-0.1.8-py3-none-any.whl (6.7 kB view details)

Uploaded Python 3

File details

Details for the file vox_cards-0.1.8.tar.gz.

File metadata

  • Download URL: vox_cards-0.1.8.tar.gz
  • Upload date:
  • Size: 5.7 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.1

File hashes

Hashes for vox_cards-0.1.8.tar.gz
Algorithm Hash digest
SHA256 3c5200adf879895eed0d5a018fb42a876fc51cd8b5e1599c42c278fc94898853
MD5 ae763c9159acc406f1f0f8480b8b446a
BLAKE2b-256 4005b592c02fc58718cf98f8e6920363630c78b25b075799fc9ea27934a04071

See more details on using hashes here.

File details

Details for the file vox_cards-0.1.8-py3-none-any.whl.

File metadata

  • Download URL: vox_cards-0.1.8-py3-none-any.whl
  • Upload date:
  • Size: 6.7 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/45.1.0 requests-toolbelt/0.9.1 tqdm/4.42.0 CPython/3.8.1

File hashes

Hashes for vox_cards-0.1.8-py3-none-any.whl
Algorithm Hash digest
SHA256 5b74e460b430bc9faf4457a9208eaeb3556e09e17feec6c94b1a0c71d6acfb3a
MD5 8d5ec0f542e7473e0844bbfbe906e609
BLAKE2b-256 c4a59812a7bd74ad3910dbb8e8ce1aef8397eda6b2e16c4c6282dba4e7fc4711

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