whist_core.cards.card
Card related classes
Classes
Create a collection of name/value pairs. |
|
Suits in a playing card deck |
|
Ranks in a playing card deck |
|
A playing card |
Module Contents
- class whist_core.cards.card._CardEnum(_, short_name=None)
Bases:
enum.EnumCreate a collection of name/value pairs.
Example enumeration:
>>> class Color(Enum): ... RED = 1 ... BLUE = 2 ... GREEN = 3
Access them by:
attribute access:
>>> Color.RED <Color.RED: 1>
value lookup:
>>> Color(1) <Color.RED: 1>
name lookup:
>>> Color['RED'] <Color.RED: 1>
Enumerations can be iterated over, and know how many members they have:
>>> len(Color) 3
>>> list(Color) [<Color.RED: 1>, <Color.BLUE: 2>, <Color.GREEN: 3>]
Methods can be added to enumerations, and members can have their own attributes – see the documentation for details.
- Parameters:
_ (str)
short_name (Optional[str])
- __short_name = None
- property ordinal: int
Get the ordinal.
- Returns:
ordinal
- Return type:
int
- property long_name: str
Get the long version of the name.
- Returns:
long version of name
- Return type:
str
- property short_name: str
Get the short version of the name.
- Returns:
short version of name
- Return type:
str
- __lt__(other)
- Parameters:
other (Any)
- Return type:
bool
- __str__()
- Return type:
str
- class whist_core.cards.card.Suit(_, short_name=None)
Bases:
_CardEnumSuits in a playing card deck
- Parameters:
_ (str)
short_name (Optional[str])
- CLUBS = ('clubs', '♣')
- DIAMONDS = ('diamonds', '♦')
- HEARTS = ('hearts', '♥')
- SPADES = ('spades', '♠')
- class whist_core.cards.card.Rank(_, short_name=None)
Bases:
_CardEnumRanks in a playing card deck
- Parameters:
_ (str)
short_name (Optional[str])
- NUM_2 = '2'
- NUM_3 = '3'
- NUM_4 = '4'
- NUM_5 = '5'
- NUM_6 = '6'
- NUM_7 = '7'
- NUM_8 = '8'
- NUM_9 = '9'
- NUM_10 = '10'
- J = ('jack', 'J')
- Q = ('queen', 'Q')
- K = ('king', 'K')
- A = ('ace', 'A')
- class whist_core.cards.card.Card
Bases:
pydantic.BaseModelA playing card
- property short_name: str
Get the short name of this card.
- Returns:
short name
- Return type:
str
- property name: str
Get the name of this card.
- Returns:
name
- Return type:
str
- dict(*args, **kwargs)
Returns the dictionary. See BaseModel for details.
- model_dump(*args, **kwargs)
Returns the dictionary. See BaseModel for details.
- __lt__(other)
Checks if the other card is lower than this card.
- Parameters:
other (Any)
- Return type:
bool
- __str__()
Returns string representation of this card.
- Return type:
str