whist.core.card¶
Card related classes
Module Contents¶
Classes¶
Generic enumeration. |
|
Suits in a playing card deck |
|
Ranks in a playing card deck |
|
A playing card |
- class whist.core.card._OrderedEnum¶
Bases:
enum.EnumGeneric enumeration.
Derive from this class to define new enumerations.
- classmethod by_ordinal(cls, ordinal: int) → _OrderedEnum¶
Get enum constant by ordinal.
- Parameters
ordinal – ordinal
- Returns
enum constant
- property ordinal(self) → int¶
Get the ordinal.
- Returns
ordinal
- __ge__(self, other: Any) → bool¶
Return self>=value.
- __gt__(self, other: Any) → bool¶
Return self>value.
- __le__(self, other: Any) → bool¶
Return self<=value.
- __lt__(self, other: Any) → bool¶
Return self<value.
- class whist.core.card.Suit¶
Bases:
_OrderedEnumSuits in a playing card deck
- CLUBS = ['♣', 'clubs']¶
- DIAMONDS = ['♦', 'diamonds']¶
- HEARTS = ['♥', 'hearts']¶
- SPADES = ['♠', 'spades']¶
- classmethod by_label(cls, label: str, search_symbols: bool = False) → Suit¶
Get suit by label.
- Parameters
label – label
search_symbols – True if the suit symbols should be searched as well
- Returns
suit
- property symbol(self) → str¶
Get the suit symbol.
- Returns
suit symbol
- property label(self) → str¶
Get the suit label.
- Returns
suit label
- __str__(self) → str¶
Return str(self).
- class whist.core.card.Rank¶
Bases:
_OrderedEnumRanks in a playing card deck
- 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 = ['J', 'jack']¶
- Q = ['Q', 'queen']¶
- K = ['K', 'king']¶
- A = ['A', 'ace']¶
- classmethod by_label(cls, label: str, search_short_labels: bool = False) → Rank¶
Get rank by label.
- Parameters
label – rank
search_short_labels – True if the rank short labels should be searched as well
- Returns
label
- property short_label(self) → str¶
Get the short version of the rank label.
- Returns
short version of rank label
- property label(self) → str¶
Get the rank label.
- Returns
rank label
- __str__(self) → str¶
Return str(self).