Akeuroo Card Deck

Version 2.0.0

A library used for creating a card deck, which provides useful classes and methods for a user who wants to create card games.


Use the package manager pip to install this package:

pip install akeuroo-deck


Start by importing Deck and Hand from akeuroo-deck:

from akeuroo_deck import Deck, Hand

Instantiate the Deck like the following:

deck = Deck()

There are two classes you can use, Deck and Hand, the following information will be about them:

Deck has two methods, which are draw and shuffle.

The instance of Deck and the shuffle() should not be included inside any loops (unless you need it to). If you were to draw a card from the Deck, the card may not be removed as the order would be repeatedly changing and the deck would be restarting.

Method draw will return a Card object, you can access a cards rank, value, and the suit like the following:

deck = Deck()
card = deck.draw()
card_info = (card.suit.value, card.rank.name, card.rank.value)

Method shuffle will shuffle the deck:

deck = Deck()

Hand is callable, and has 3 attributes, cards, value and all

Hand will do the most job for you when it comes to storing the hand of n amount of player, and you will be able to access the cards easily.

To let the Hand class have access to the cards, I would recommend to draw every card into the Hand object instead.
When calling Hand keep in mind that it only takes a Card object and not a list of cards!
This would look something like:

deck = Deck()

player_hand = Hand()
player_hand(deck.draw()) # Since Hand is callable we can just draw the card directly into it

Attribute cards will return a list of all the Card objects in the hand of this class:

player_hand = Hand()

Attribute value will return a sum of integers of all the values for each card in the hand:

player_hand = Hand()

Attribute all will return a list of suit, rank name and rank value:

player_hand = Hand()

A Code Example:

from akeuroo_deck import Deck, Hand

deck = Deck() # Instantiate the Deck outside of a loop
deck.shuffle() # Shuffle the Deck directly after it

class Player:
    def __init__(self):
        self.hand = Hand() # Creating the hand of the player which inherits from the Hand class

    def draw(self):
        self.hand(deck.draw()) # Letting the player draw a card and the Card object will be directly sent into the hand

class Game:
    def __init__(self):
        x = input("Do you wanna draw a card? (yes/no): ")
        if x == "yes":
            player.draw() # If the player wants to draw a card, we call the player.draw() method
            # If the player doesn't want to draw a card, we simply print out the information the hand of the player currently has

player = Player()
while True:


  • Akeuroo

Licence & Copyright

MIT License

Copyright (c) 2021 akeuroo


View Github