gamble.models.cards

deck of cards submodule

Classes

BlackJackDeck([num_decks])

a standard blackjack shoe

Card([value, suit])

playing card model

Deck([cards, shuffle, default_draw_count])

playing card deck model

EuchreDeck(**_)

deck specifically for euchre

Hand(cards)

playing card hand model

MultiDeck([num_decks])

deck consisting of multiple standard decks

Rank(value, name)

hand ranks

Suit(name, char, symbol, value, color, unicode)

suit

Value(char, name, value)

value

class gamble.models.cards.BlackJackDeck(num_decks: int = 8)[source]

Bases: gamble.models.cards.MultiDeck

a standard blackjack shoe

Parameters:

num_decks (int) – the number of standard decks to combine into this blackjack shoe

class gamble.models.cards.Card(value: gamble.models.cards.Value = Value(char='A', name='ace', value=1), suit: gamble.models.cards.Suit = Suit(name='spades', char='S', symbol='♠', value=0, color=0, unicode=127136))[source]

Bases: object

playing card model

Parameters:
class Suits[source]

Bases: object

card suit enum

classmethod all() list[gamble.models.cards.Suit][source]

get all suits in this enum

Returns:

a list of the suit objects

Return type:

list[gamble.models.cards.Suit]

classmethod dict() dict[str, gamble.models.cards.Suit][source]

dict of char -> Suit

Returns:

a dictionary of all the card values

Return type:

dict[str, gamble.models.cards.Suit]

class Values[source]

Bases: object

card value enum

classmethod all() list[gamble.models.cards.Value][source]

get all suits

Returns:

a list of all the values in this enum

Return type:

list[gamble.models.cards.Value]

classmethod dict() dict[str, gamble.models.cards.Value][source]

dict of char -> Value

Returns:

a dictionary of card characters to their Value representations

Return type:

dict[str, gamble.models.cards.Value]

__eq__(other: object) bool[source]

equal to dunder method

Parameters:

other (object) – another card to compare against

Returns:

true if this card is the same as other

Return type:

bool

__ge__(other: gamble.models.cards.Card) bool[source]

greater than or equal to dunder method

Parameters:

other (gamble.models.cards.Card) – another card to compare against

Returns:

true if this card is greater than or equal to other

Return type:

bool

__gt__(other: gamble.models.cards.Card) bool[source]

greater than dunder method

Parameters:

other (gamble.models.cards.Card) – another card to compare against

Returns:

true if this card is greater than other

Return type:

bool

__le__(other: gamble.models.cards.Card) bool[source]

less than or equal to dunder method

Parameters:

other (gamble.models.cards.Card) – another card to compare against

Returns:

true if less than or equal to other

Return type:

bool

__lt__(other: gamble.models.cards.Card) bool[source]

less than dunder method

Parameters:

other (gamble.models.cards.Card) – another card to compare against

Returns:

true if this card is less than other

Return type:

bool

__repr__() str[source]

representation of this card

Returns:

a repr of this card

Return type:

str

__str__() str[source]

string representation of this card

Returns:

a string of this card

Return type:

str

property color: int

returns the color of the card

Returns:

the color enum int for this card

property full_name: str

returns the full name for this card

Returns:

the full name of this card

classmethod get(text: str) gamble.models.cards.Card[source]

get a card by text representation

Parameters:

text (str) – a string representation of a card value and suit

Returns:

the created card, if the string was valid

Return type:

gamble.models.cards.Card

property is_black: bool

is_black property

Returns:

if this card is in a black suit

property is_red: bool

is_red property

Returns:

if this card is in a red suit

property unicode: str

get the fun little unicode card for this card

Returns:

the nice looking unicode char for the suit of this card

class gamble.models.cards.Deck(cards: list[gamble.models.cards.Card] | None = None, shuffle: bool = True, default_draw_count: int = 1)[source]

Bases: object

playing card deck model

Parameters:
  • cards (list[gamble.models.cards.Card] | None) – a list of cards for this deck

  • shuffle (bool) – if we should start with the deck shuffled

  • default_draw_count (int) –

__contains__(item: object) bool[source]

dunder contains method

Parameters:

item (object) – the item to check for in this deck

Returns:

true if this deck contains the given object

Return type:

bool

__getitem__(index: int) gamble.models.cards.Card[source]

get the card at the given index in the deck

Returns:

the card at the given index

Parameters:

index (int) –

Return type:

gamble.models.cards.Card

__repr__() str[source]

term representation of a deck

Returns:

a repr representation of this deck

Return type:

str

__str__() str[source]

string representation of a deck

Returns:

a string representation of this deck

Return type:

str

property bottom: gamble.models.cards.Card

the bottom card of the deck

Returns:

a card off the bottom of the deck

property cards_left: int

number of cards left in the deck

Returns:

the number of cards left

clear() None[source]

clear the deck of all cards

Return type:

None

default_deck(cards: list[gamble.models.cards.Card]) None[source]

load the standard 52 cards into the given set of cards

Parameters:

cards (list[gamble.models.cards.Card]) –

Return type:

None

draw(times: int = -1) gamble.models.cards.Card | list[gamble.models.cards.Card][source]

draws the given number of cards from the deck

Parameters:

times (int) – the number of times to draw

Returns:

a card or list of cards drawn

Return type:

gamble.models.cards.Card | list[gamble.models.cards.Card]

draw_hand(size: int = 5) gamble.models.cards.Hand[source]

draw a hand from this deck

Parameters:

size (int) – the size of hand to draw

Returns:

a hand object of size size

Return type:

gamble.models.cards.Hand

shuffle(times: int = 1) None[source]

shuffle the deck

Parameters:

times (int) – the number of times to shuffle the deck

Return type:

None

property top: gamble.models.cards.Card

the top card of the deck

Returns:

a card off the top of the deck

class gamble.models.cards.EuchreDeck(**_: Any)[source]

Bases: gamble.models.cards.Deck

deck specifically for euchre

Parameters:

_ (Any) –

class gamble.models.cards.Hand(cards: list[gamble.models.cards.Card])[source]

Bases: object

playing card hand model

Parameters:

cards (list[gamble.models.cards.Card]) – a list of card objects for this hand

class Ranks[source]

Bases: object

hand ranks for poker

__gt__(other: gamble.models.cards.Hand) bool[source]

greater than dunder method

Parameters:

other (gamble.models.cards.Hand) – another hand to compare against

Returns:

true if this hand is greater than the other

Return type:

bool

__len__() int[source]

dunder len method

Returns:

the number of cards in this hand

Return type:

int

__lt__(other: gamble.models.cards.Hand) bool[source]

less than dunder method

Parameters:

other (gamble.models.cards.Hand) – another hand to compare against

Returns:

true if this hand is less than the other

Return type:

bool

__repr__() str[source]

repr of the hand

Returns:

this hand as repr

Return type:

str

__str__() str[source]

string representation of the hand

Returns:

this hand as a string

Return type:

str

classmethod get(text: str) gamble.models.cards.Hand[source]

get a hand by text representations

Parameters:

text (str) – a text representation of a hand

Returns:

a hand, if the string was valid

Return type:

gamble.models.cards.Hand

property is_flush: bool

check if the hand is a flush

Returns:

true if flush

property is_four_of_a_kind: bool

check if the hand is four of a kind

Returns:

true if four of a kind

property is_full_house: bool

check if the hand is a full house

Returns:

true if full house

property is_one_pair: bool

check if the hand contains one pair

Returns:

true if is one pair

property is_royal_flush: bool

check if the hand is a royal flush

Returns:

true if royal flush

property is_straight: bool

check if the hand is a straight

Returns:

true if straight

property is_straight_flush: bool

check if the hand is a straight flush

Returns:

true if straight flush

property is_three_of_a_kind: bool

check if the hand is three of a kind

Returns:

true if is three of a kind

property is_two_pair: bool

check if the hand contains two pair

Returns:

true if is two pair

property rank: gamble.models.cards.Rank

get the rank of this hand

Returns:

a rank object representing the rank of this hand

class gamble.models.cards.MultiDeck(num_decks: int = 2)[source]

Bases: gamble.models.cards.Deck

deck consisting of multiple standard decks

Parameters:

num_decks (int) – the number of standard decks to combine into one deck

class gamble.models.cards.Rank(value: int, name: str)[source]

Bases: object

hand ranks

Parameters:
  • value (int) – the integer value of the rank

  • name (str) – the name of the rank

class gamble.models.cards.Suit(name: str, char: str, symbol: str, value: int, color: int, unicode: int)[source]

Bases: object

suit

Parameters:
  • name (str) – the name of this suit

  • char (str) – the ascii character representation for this suit

  • symbol (str) – the unicode symbol char for this suit

  • value (int) – the value of the suit

  • color (int) – the color of the suit

  • unicode (int) – the unicode id for this suit as an int

class gamble.models.cards.Value(char: str, name: str, value: int)[source]

Bases: object

value

Parameters:
  • char (str) – the ascii character representation for this value

  • name (str) – the name of the card

  • value (int) – the value of the card as an int