Card Generator

The Base Card Generation Module

class CardGambler[source]

The Pokecard Generator class.

Parameters

assets_path (str) – The path to the asset folder.

get_card()[source]

Gets the image of a specific card.

Parameters
  • suit (str) – The suit of the card.

  • card (str) – The card number.

Returns

The image of the card.

Return type

PIL.Image.Image

static get_deck()[source]

Gets a deck generated from a list of cards.

Parameters
  • cards (List[PIL.Image.Image]) – The list of cards to generate the deck from.

  • sep (Optional[str]) – The seperation width, defaults to “auto”

  • reverse (Optional[bool]) – Stack the cards in reverse?, defaults to False

Returns

The deck image.

Return type

PIL.Image.Image

get_closed_deck()[source]

Gets a deck of closed cards.

Parameters
  • sep (Optional[int]) – The seperation width, defaults to 5

  • num_cards (Optional[int]) – Number of cards, defaults to 12

Returns

The closed deck image.

Return type

PIL.Image.Image

get_random_card()[source]

Alias for get_random_cards() with num_cards = 1.

Returns

Random card.

Return type

PIL.Image.Image

get_random_cards()[source]

Gets a list of random cards.

Parameters
  • num_cards (Optional[int]) – Number of cards, defaults to 4

  • joker_chance (Optional[float]) – Chance of including a Joker, defaults to 0.05

Returns

A list of random cards.

Return type

List[PIL.Image.Image]

get_random_deck()[source]

Gets a deck generated from a list of random cards.

Parameters

num_cards (Optional[int]) – Number of cards, defaults to 12

Returns

The deck image consisting of random cards.

Return type

PIL.Image.Image