gonzo_card_games.CardDeck module

class gonzo_card_games.CardDeck.Card(value: str, suit: str)[source]

Bases: object

A class representing a single playing card.

isFaceCard() bool[source]

Checks if the card is a face card (jack, queen, king, ace).

Returns

Boolean indicating if the card is a face card or not.

sameSuit(card2: Card) bool[source]

Checks if two Card objects have the same suit.

Parameters

card2: Card

The other Card object to compare with.

Returns

Boolean indicating if both cards have the same suit.

sameValue(card2: Card) bool[source]

Checks if two Card objects have the same value.

Parameters

card2: Card

The other Card object to compare with.

Returns

Boolean indicating if both cards have the same value.

property suit: str

Returns the suit of the card.

property value: str

Returns the value of the card.

class gonzo_card_games.CardDeck.CardDeck(nDecks: int = 1)[source]

Bases: object

A class representing a card deck containing one or more sets of standard 52 playing cards.

add_card(card: Card, onTop=False) None[source]

Adds a card into the deck.

Parameters

card: Card

The card to be added back to the deck.

onTop: bool, optional

If True, adds the card to the top of the deck; otherwise, adds it to the bottom (default: False)

property cards: list[Card]

Returns the list of cards in the deck.

combine_decks(other_deck: CardDeck, onTop=False) None[source]

Adds another CardDeck to the current deck.

Parameters

other_deck: CardDeck

The CardDeck to be added to the current deck.

onTop: bool, optional

If True, adds the other deck on top of the current deck; otherwise, adds it to the bottom (default: False)

deal_card(fromBottom=False) Card[source]

Deals a single card from the deck.

Parameters

fromBottom: bool, optional

If True, deals the card from the bottom of the deck; otherwise, deals from the top (default: False)

Returns

Card object if available.

deal_deck(nPiles: int) list[CardDeck][source]

Deals the as much of the deck as possible into specified number of piles.

Parameters

nPiles: int

The number of piles to deal the deck into.

Returns

A list of CardDeck objects, each containing an equal number of cards.

insert_card(card: Card, index: int) None[source]

Inserts a card at the specified index in the deck.

Parameters

card: Card

The card to be inserted.

index: int

The index at which to insert the card.

property nCards: int

Returns the current number of cards in the deck.

pull_card(index: int) Card[source]

Pulls a card at the specified index out of the deck.

Parameters

index: int

The index of the card to retrieve.

Returns

Card object at the specified index.

see_card(index: int) Card[source]

Returns copy of card at the specified index of the deck.

Parameters

index: int

The index of the card to view.

Returns

Copy of card object at the specified index.

shuffle() None[source]

Shuffles the deck of cards.