Deck
Card
¶
Bases: object
Card class
Example use
from automation.simulation.deck import Card
Card("SA") == Card("S","A")
> True
Attributes:
Name | Type | Description |
---|---|---|
suit |
str
|
one of [D,C,H,S,R,B] for Diamond, Club, Heart, Spade, Red, Black |
val |
str
|
one of [A, K, Q, J, T] for Ace to Ten. Or 2 to 9. |
val_number |
int
|
integer corresponding to above value |
color |
str
|
either R or B for red or black |
Source code in automation/simulator/deck.py
11 12 13 14 15 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 52 53 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 101 102 103 104 105 106 107 108 109 110 111 112 |
|
suit_symbol
property
¶
Symbol for each suit, including red and black for jokers
val_number
property
¶
Integer value for number, to permit calculations
color
property
¶
R or B
__repr__()
¶
Result of print(card)
Source code in automation/simulator/deck.py
87 88 89 |
|
__add__(x)
¶
Result of card + integer. Loops around
Source code in automation/simulator/deck.py
91 92 93 94 |
|
__sub__(x)
¶
Result of card - integer. Loops around
Source code in automation/simulator/deck.py
96 97 98 99 |
|
__eq__(x)
¶
Returns true if two cards are the same
Source code in automation/simulator/deck.py
101 102 103 |
|
__hash__()
¶
Returns unique value to represent card
Source code in automation/simulator/deck.py
105 106 107 |
|
range(DR)
¶
Returns list of cards in a DR
Source code in automation/simulator/deck.py
109 110 111 112 |
|
Deck
¶
Bases: object
Full deck of cards
Example use
from automation.simulation.deck import Deck
d=Deck()
d.draw()
> ♦️ A
d.check(TC=Card("S","A"),DR=3)
> [INFO]: Drew ♦️ 8 vs ♠️ A with DR 3: Miss
Attributes:
Name | Type | Description |
---|---|---|
suits |
tuple
|
all suits in deck |
vals |
tuple
|
all values in deck |
cards |
list
|
source deck |
discards |
list
|
discard pile |
hand |
list
|
jokers and fate cards in hand |
Source code in automation/simulator/deck.py
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 140 141 142 143 144 145 146 147 148 149 150 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 192 193 194 195 196 197 198 199 200 201 202 203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 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 266 267 268 269 270 271 272 273 274 275 276 277 278 279 280 281 282 283 284 285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 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 358 359 360 361 362 363 364 |
|
__repr__()
¶
Result of print(Deck)
Source code in automation/simulator/deck.py
159 160 161 162 163 164 165 166 |
|
shuffle(limit=None)
¶
Shuffle N from discard to deck
If limit provided, only shuffle those from discard. If no limit, reshuffle all discarded. Add jokers back to hand.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
limit |
int
|
Number of cards to shuffle back into deck. Defaults to None. |
None
|
Source code in automation/simulator/deck.py
168 169 170 171 172 173 174 175 176 177 178 179 180 181 182 183 184 185 186 |
|
TC: Card
property
¶
Target card
Returns:
Name | Type | Description |
---|---|---|
Card |
Card
|
Current Target Card from deck. Not applicable to GM decks. |
draw_TC()
¶
Draw a new target card
Source code in automation/simulator/deck.py
199 200 201 |
|
draw()
¶
Draw a card, if available. Otherwise returns None.
Returns:
Name | Type | Description |
---|---|---|
Card |
Card | None
|
description |
Source code in automation/simulator/deck.py
203 204 205 206 207 208 209 210 211 212 213 214 215 216 217 218 219 220 |
|
discard(n, return_string=False, **_)
¶
Draw n cards, return none. Discard/hand as normal
Parameters:
Name | Type | Description | Default |
---|---|---|---|
n |
int
|
Number of cards to discard. If "all", uses discards all remaining. |
required |
return_string |
bool
|
Return a string reflecting result. Defaults to False. |
False
|
Returns:
Type | Description |
---|---|
str | None
|
str | None: If return_string, report "Drew X" |
Source code in automation/simulator/deck.py
228 229 230 231 232 233 234 235 236 237 238 239 240 241 242 243 244 245 246 247 |
|
exchange_fate(return_string=False)
¶
Move fate card from hand. If Ace, add to discard
Parameters:
Name | Type | Description | Default |
---|---|---|---|
return_string |
bool
|
Default to False |
False
|
Source code in automation/simulator/deck.py
249 250 251 252 253 254 255 256 257 258 259 260 261 262 263 264 265 |
|
check(TC, DR, mod=0, upper_lower='none', draw_n=1, upper_lower_int=0, draw_all=False, return_val=False, return_string=False, verbose=True)
¶
Log string corresponding to check 'Hit/Miss/Color/Suit' etc
Parameters:
Name | Type | Description | Default |
---|---|---|---|
TC |
Card
|
Target card |
required |
DR |
int
|
(int): Difficulty Range |
required |
mod |
int
|
DR modifier |
0
|
upper_lower |
str
|
'upper' or 'lower' Hand ('u' or 'l'). Default neither. |
'none'
|
draw_n |
int
|
How many to draw. If upper/lower, default 2. Otherwise 1. |
1
|
upper_lower_int |
int
|
Instead of passing upper_lower and draw_n, use positive/negative for upper/lower with int of draw_n -1. for example, -1 for draw 2 lower |
0
|
draw_all |
bool
|
If upper hand, draw all before stopping. Default false. |
False
|
return_val |
bool
|
Return the integer of the result. Default False. |
False
|
return_string |
bool
|
Return the string describing what happened. Default False. |
False
|
verbose |
bool
|
Log the result string as a debug item |
True
|
Returns:
Type | Description |
---|---|
tuple[int, str] | str
|
tuple | str: If return_string, returns a tuple containing the result as a string, followed by the result value. If return_val, only integer result. |
Source code in automation/simulator/deck.py
292 293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 309 310 311 312 313 314 315 316 317 318 319 320 321 322 323 324 325 326 327 328 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 358 359 360 361 362 363 364 |
|