Notation¶
patiencepilot.notation ¶
Canonical notation and JSON-compatible serialization.
SerializedMove ¶
Bases: TypedDict
JSON-compatible serialized move payload.
Source code in src/patiencepilot/notation.py
33 34 35 36 37 | |
SerializedStackCard ¶
Bases: TypedDict
JSON-compatible authoritative tableau card payload.
Source code in src/patiencepilot/notation.py
40 41 42 43 44 | |
SerializedGameState ¶
Bases: TypedDict
JSON-compatible authoritative game-state payload.
Source code in src/patiencepilot/notation.py
47 48 49 50 51 52 53 54 55 56 57 | |
SerializedPlayerStackCard ¶
Bases: TypedDict
JSON-compatible player-view tableau card payload.
Source code in src/patiencepilot/notation.py
60 61 62 63 64 | |
SerializedUnknownCardConstraints ¶
Bases: TypedDict
JSON-compatible unknown-card constraint payload.
Source code in src/patiencepilot/notation.py
67 68 69 70 71 72 | |
SerializedPlayerView ¶
Bases: TypedDict
JSON-compatible player-known state payload.
Source code in src/patiencepilot/notation.py
75 76 77 78 79 80 81 82 83 84 85 86 | |
ValidationDiagnostic
dataclass
¶
A validation diagnostic suitable for UI display.
Source code in src/patiencepilot/notation.py
89 90 91 92 93 94 95 | |
ValidationResult
dataclass
¶
Structured validation result for notation and payload checks.
Source code in src/patiencepilot/notation.py
98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 | |
move_to_id ¶
move_to_id(move: Move) -> str
Return the canonical compact identifier for move.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
move
|
Move
|
Structured move to identify. |
required |
Raises:
| Type | Description |
|---|---|
NotationError
|
If the move contains invalid notation values. |
Source code in src/patiencepilot/notation.py
117 118 119 120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 | |
move_from_id ¶
move_from_id(move_id: str) -> Move
Parse a canonical compact move identifier.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
move_id
|
str
|
Identifier such as |
required |
Raises:
| Type | Description |
|---|---|
NotationError
|
If the identifier cannot be parsed. |
Source code in src/patiencepilot/notation.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 187 188 189 190 191 | |
serialize_move ¶
serialize_move(move: Move) -> SerializedMove
Return a JSON-compatible serialized move payload.
Source code in src/patiencepilot/notation.py
194 195 196 | |
deserialize_move ¶
deserialize_move(data: Mapping[str, object]) -> Move
Return a move from a JSON-compatible serialized payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Mapping[str, object]
|
Mapping with an |
required |
Raises:
| Type | Description |
|---|---|
NotationError
|
If the payload is missing or has an invalid |
Source code in src/patiencepilot/notation.py
199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 | |
state_to_text ¶
state_to_text(state: GameState) -> str
Return canonical text notation for an authoritative state.
Source code in src/patiencepilot/notation.py
219 220 221 222 223 224 225 226 227 228 229 230 231 | |
state_from_text ¶
state_from_text(text: str) -> GameState
Return a state parsed from canonical text notation.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
text
|
str
|
State notation produced by :func: |
required |
Raises:
| Type | Description |
|---|---|
NotationError
|
If the notation cannot be parsed or validated. |
Source code in src/patiencepilot/notation.py
234 235 236 237 238 239 240 241 242 243 244 245 246 247 248 249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 | |
serialize_state ¶
serialize_state(state: GameState) -> SerializedGameState
Return a JSON-compatible authoritative state payload.
Source code in src/patiencepilot/notation.py
268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 | |
deserialize_state ¶
deserialize_state(data: Mapping[str, object]) -> GameState
Return a state from a JSON-compatible payload.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
data
|
Mapping[str, object]
|
State payload created by :func: |
required |
Raises:
| Type | Description |
|---|---|
NotationError
|
If the payload cannot be parsed or validated. |
Source code in src/patiencepilot/notation.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 | |
migrate_state_payload ¶
migrate_state_payload(
data: Mapping[str, object],
) -> dict[str, object]
Return a best-effort alpha migration to schema version 1.
Source code in src/patiencepilot/notation.py
311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 | |
serialize_player_view ¶
serialize_player_view(
view: PlayerView,
) -> SerializedPlayerView
Return a JSON-compatible player-known state payload.
Source code in src/patiencepilot/notation.py
329 330 331 332 333 334 335 336 337 338 339 340 341 342 343 344 345 346 347 348 349 350 351 352 353 354 355 356 357 | |
deserialize_player_view ¶
deserialize_player_view(
data: Mapping[str, object],
) -> PlayerView
Return a player-known view from a JSON-compatible payload.
Source code in src/patiencepilot/notation.py
360 361 362 363 364 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 | |
validate_move_id ¶
validate_move_id(move_id: str) -> ValidationResult
Validate a move identifier without raising.
Source code in src/patiencepilot/notation.py
386 387 388 389 390 391 392 | |
validate_serialized_move ¶
validate_serialized_move(
data: Mapping[str, object],
) -> ValidationResult
Validate a serialized move payload without raising.
Source code in src/patiencepilot/notation.py
395 396 397 398 399 400 401 | |
validate_serialized_state ¶
validate_serialized_state(
data: Mapping[str, object],
) -> ValidationResult
Validate a serialized state payload without raising.
Source code in src/patiencepilot/notation.py
404 405 406 407 408 409 410 | |
validate_state_text ¶
validate_state_text(text: str) -> ValidationResult
Validate state text notation without raising.
Source code in src/patiencepilot/notation.py
413 414 415 416 417 418 419 | |