cards API Documentation

The cards package give a lot of the basic necessities for any card game.

Deck

the Deck module is cool

class cards.deck.Deck

A collection of cards that can execute common actions, like drawing, inserting, and shuffling.

draw()

Draw the top card of the deck.

insert_to_bottom(card)

Insert a card at the bottom of the deck.

insert_to_top(card)

Insert a card at the top of the deck.

num_cards

Return the number of cards in the deck.

remove(card_to_remove)

Removes the first card that it finds that matches the given criteria.

remove_all(card_to_remove)

Remove all cards matching the given card, suit, or rank.

shuffle()

Randomize order of the cards in the deck.

Playing Cards

class cards.playing_cards.Card

Abstract class for cards.

flavor_text

Get flavor text.

name

Get name.

text

Get text.

class cards.playing_cards.StandardPlayingCard(rank, suit)

“Standard French playing card.

rank

Get rank.

suit

Get suit.

Five Card Hand

class cards.five_card_hand.FiveCardHand(cards)

General class for hands with five cards.

get_cards_as_string()

Return a string representing the five-card-hand.

get_cards_high_to_low(ordering=['2', '3', '4', '5', '6', '7', '8', '9', '10', 'Jack', 'Queen', 'King', 'Ace'])

Return cards from highest rank to lowest.

has_matches()

Return a boolean telling whether or not there are multiple cards of the same rank.

rank_counts

Get rank counts.

same_strength(other)

Evaluates if two poker hands have the same strength.

strength

Get hand strength.

suit_counts

Get suit counts.

Ranks

cards.ranks.get_all_ranks()

Return all ranks.

cards.ranks.get_faces()

Return face cards.

cards.ranks.get_larger_ranks(rank)

Gets the ranks that are larger than the given rank.

cards.ranks.get_rank_symbol(rank)

Return the truncated symbol that represents the rank.

cards.ranks.get_royals()

Return the royal ranks.

cards.ranks.get_smaller_ranks(rank)

Gets the ranks that are smaller than the given rank.

cards.ranks.next_larger_rank(rank, ordered_rankings)

Return the next larger rank in the ordering. Raise an exception if it’s the highest ranking.

Classify

cards.classify_hand.classify(hand, is_straight_function=<function is_straight_ace_low_high>)

Takes a list of cards or a FiveCardHand and classifies it as one of the poker hands, returning an object of that type containing the given cards.

Indices and tables