Cards¶
patiencepilot.cards ¶
Playing card primitives.
Color ¶
Bases: Enum
A playing card color.
Source code in src/patiencepilot/cards.py
9 10 11 12 13 | |
Suit ¶
Bases: Enum
A French-suited playing card suit.
Source code in src/patiencepilot/cards.py
16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
from_code
classmethod
¶
from_code(code: str) -> Suit
Return the suit represented by a compact one-letter code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
One of |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/patiencepilot/cards.py
36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 | |
Rank ¶
Bases: IntEnum
A playing card rank from ace through king.
Source code in src/patiencepilot/cards.py
54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
from_code
classmethod
¶
from_code(code: str) -> Rank
Return the rank represented by a compact code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
One of |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/patiencepilot/cards.py
82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 | |
Card
dataclass
¶
A standard playing card.
Source code in src/patiencepilot/cards.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 | |
from_code
classmethod
¶
from_code(code: str) -> Card
Return the card represented by a compact code.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
code
|
str
|
A rank code followed by a suit code, such as |
required |
Raises:
| Type | Description |
|---|---|
ValueError
|
If |
Source code in src/patiencepilot/cards.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 | |
__str__ ¶
__str__() -> str
Return the compact card code.
Source code in src/patiencepilot/cards.py
137 138 139 | |
standard_deck ¶
standard_deck() -> tuple[Card, ...]
Return a standard 52-card deck in deterministic order.
Source code in src/patiencepilot/cards.py
142 143 144 | |