Card
Represents a Flesh and Blood card.
Note
fab
treats all prints and versions of a card as under the same Card
object. If any change is made to the card's body text or attributes
between prints, it can be assumed that fab
lists the latest print of the
card.
Attributes:
Name | Type | Description |
---|---|---|
body |
Optional[str]
|
The full body text of the card, excluding flavor text. |
cost |
int | str | None
|
The resource cost of the card. |
defense |
int | str | None
|
The defense value of the card. |
flavor_text |
Optional[str]
|
Any lore text printed on the body of the card. |
full_name |
str
|
The full name of the card, including pitch value. |
grants |
list[str]
|
A list of keywords this card grants to other cards. |
health |
Optional[int]
|
The health value of the card. |
identifiers |
list[str]
|
The list of card identifiers, such as |
image_urls |
list[str]
|
A list of card image URLs. |
intelligence |
Optional[int]
|
The intelligence value of the card. |
keywords |
list[str]
|
A list of keywords associated with the card, such as |
legality |
dict[str, bool]
|
Whether this card is currently legal for various formats (see |
name |
str
|
The name of the card, excluding pitch value. |
pitch |
Optional[int]
|
The pitch value of the card. |
power |
int | str | None
|
The (attack) power of the card. |
rarities |
list[str]
|
The list of rarities associated with each card identifier. |
sets |
list[str]
|
The list of card set codes associated with the card. |
tags |
list[str]
|
A collection of user-defined tags. |
type_text |
str
|
The full type box text of the card. |
types |
list[str]
|
The list of types present in the card's type box. |
Source code in fab/card.py
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 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 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 365 366 367 368 369 370 371 372 373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 406 407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 422 423 424 425 426 427 428 429 430 431 432 433 434 435 436 437 438 439 440 441 442 443 444 445 446 447 448 449 450 451 452 453 454 455 456 457 458 |
|
__getitem__(key)
¶
Allows one to access fields of a card via dictionary syntax.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
key |
str
|
The name of the class attribute to fetch. |
required |
Returns:
Type | Description |
---|---|
Any
|
The value associated with the specified field. |
Source code in fab/card.py
96 97 98 99 100 101 102 103 104 105 106 |
|
__hash__()
¶
Computes the hash representation of the card.
Returns:
Type | Description |
---|---|
Any
|
The hash representation of the card. |
Source code in fab/card.py
108 109 110 111 112 113 114 115 |
|
__str__()
¶
Computes the JSON string representation of the card.
This is an alias of the to_json()
method.
Returns:
Type | Description |
---|---|
str
|
The JSON string representation of the card. |
Source code in fab/card.py
117 118 119 120 121 122 123 124 125 126 |
|
from_full_name(full_name, catalog=None)
staticmethod
¶
Creates a new card from its full name.
Note
To instantiate the card this way, a card catalog (CardList
) must be
provided, defaulting to card.CARD_CATALOG
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
full_name |
str
|
The full name of the card (including pitch value, if applicable). |
required |
catalog |
Optional[CardList]
|
The card catalog to use as a reference, defaulting to |
None
|
Returns:
Type | Description |
---|---|
Card
|
A new |
Source code in fab/card.py
128 129 130 131 132 133 134 135 136 137 138 139 140 141 142 143 144 145 146 147 148 149 |
|
from_identifier(identifier, catalog=None)
staticmethod
¶
Creates a new card from its identifier.
Note
To instantiate the card this way, a card catalog (CardList
) must be
provided, defaulting to card.CARD_CATALOG
.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
identifier |
str
|
The identifier of the card. |
required |
catalog |
Optional[CardList]
|
The card catalog to use as a reference, defaulting to |
None
|
Returns:
Type | Description |
---|---|
Card
|
A new |
Source code in fab/card.py
151 152 153 154 155 156 157 158 159 160 161 162 163 164 165 166 167 168 169 170 171 172 |
|
from_json(jsonstr)
staticmethod
¶
Creates a new card from the specified JSON string.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
jsonstr |
str
|
The JSON string representation to parse. |
required |
Returns:
Type | Description |
---|---|
Card
|
A new |
Source code in fab/card.py
174 175 176 177 178 179 180 181 182 183 184 185 |
|
image(height=314, index=-1, width=225)
¶
Display an image of this card, optionally providing an alternative index to use.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
height |
int
|
The height to scale the resulting image to, in pixels. |
314
|
index |
int
|
The target |
-1
|
width |
int
|
The width to scale the resulting image to, in pixels. |
225
|
Returns:
Type | Description |
---|---|
Any
|
The image representation of the card. |
Source code in fab/card.py
187 188 189 190 191 192 193 194 195 196 197 198 199 200 201 |
|
is_action()
¶
Whether this card is an action card.
Returns:
Type | Description |
---|---|
bool
|
Whether the card contains the Action type. |
Source code in fab/card.py
203 204 205 206 207 208 209 210 |
|
is_attack()
¶
Whether this card is an attack card.
Returns:
Type | Description |
---|---|
bool
|
Whether the card contains the Attack type. |
Source code in fab/card.py
212 213 214 215 216 217 218 219 |
|
is_attack_reaction()
¶
Whether this card is an attack reaction card.
Returns:
Type | Description |
---|---|
bool
|
Whether the card contains the Attack Reaction type. |
Source code in fab/card.py
221 222 223 224 225 226 227 228 |
|
is_aura()
¶
Whether this card is an aura card.
Returns:
Type | Description |
---|---|
bool
|
Whether the card contains the Aura type. |
Source code in fab/card.py
230 231 232 233 234 235 236 237 |
|
is_blue()
¶
Whether this is a blue card.
Returns:
Type | Description |
---|---|
bool
|
Whether this card pitches for 3 resources. |
Source code in fab/card.py
239 240 241 242 243 244 245 246 |
|
is_defense_reaction()
¶
Whether this card is a defense reaction card.
Returns:
Type | Description |
---|---|
bool
|
Whether the card contains the Defense Reaction type. |
Source code in fab/card.py
248 249 250 251 252 253 254 255 |
|
is_equipment()
¶
Whether this card is an equipment card.
Returns:
Type | Description |
---|---|
bool
|
Whether the card contains the Equipment type. |
Source code in fab/card.py
257 258 259 260 261 262 263 264 |
|
is_hero()
¶
Whether this card is a hero card.
Returns:
Type | Description |
---|---|
bool
|
Whether the card contains the Hero type. |
Source code in fab/card.py
266 267 268 269 270 271 272 273 |
|
is_instant()
¶
Whether this card is an instant card.
Returns:
Type | Description |
---|---|
bool
|
Whether the card contains the Instant type. |
Source code in fab/card.py
275 276 277 278 279 280 281 282 |
|
is_item()
¶
Whether this card is an item card.
Returns:
Type | Description |
---|---|
bool
|
Whether the card contains the Item type. |
Source code in fab/card.py
284 285 286 287 288 289 290 291 |
|
is_legal(format=None)
¶
Whether this card is legal for the specified format, or if format
is
None
, returns False
if this card is banned in any format.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
format |
Optional[str]
|
The code of the card format to check, or |
None
|
Returns:
Type | Description |
---|---|
bool
|
Whether the card is legal. |
Source code in fab/card.py
293 294 295 296 297 298 299 300 301 302 303 304 305 306 307 308 |
|
is_reaction()
¶
Whether this card is an attack or defense reaction card.
Returns:
Type | Description |
---|---|
bool
|
Whether the card contains the Attack Reaction or Defense Reaction types. |
Source code in fab/card.py
310 311 312 313 314 315 316 317 |
|
is_red()
¶
Whether this is a red card.
Returns:
Type | Description |
---|---|
bool
|
Whether this card pitches for 1 resource. |
Source code in fab/card.py
319 320 321 322 323 324 325 326 |
|
is_token()
¶
Whether this card is a token card.
Returns:
Type | Description |
---|---|
bool
|
Whether the card contains the Token type. |
Source code in fab/card.py
328 329 330 331 332 333 334 335 |
|
is_weapon()
¶
Whether this card is a weapon card.
Returns:
Type | Description |
---|---|
bool
|
Whether the card contains the Weapon type. |
Source code in fab/card.py
337 338 339 340 341 342 343 344 |
|
is_yellow()
¶
Whether this is a yellow card.
Returns:
Type | Description |
---|---|
bool
|
Whether this card pitches for 2 resources. |
Source code in fab/card.py
346 347 348 349 350 351 352 353 |
|
keys()
¶
Returns the dictionary keys associated with this card class.
Returns:
Type | Description |
---|---|
list[str]
|
The |
Source code in fab/card.py
355 356 357 358 359 360 361 362 |
|
rarity_names()
¶
Returns the full names of the rarities associated with this card.
Returns:
Type | Description |
---|---|
list[str]
|
A |
Source code in fab/card.py
364 365 366 367 368 369 370 371 |
|
render(heading_level='###', icon_size=11)
¶
Renders this card into a markdown representation.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
heading_level |
str
|
Specifies the initial heading level of the card. |
'###'
|
icon_size |
int
|
Specified the target width of icon images. |
11
|
Returns:
Type | Description |
---|---|
Any
|
The IPython-rendered markdown output. |
Source code in fab/card.py
373 374 375 376 377 378 379 380 381 382 383 384 385 386 387 388 389 390 391 392 393 394 395 396 397 398 399 400 401 402 403 404 405 |
|
render_body(icon_size=11)
¶
Renders the body text of this card as markdown output.
Parameters:
Name | Type | Description | Default |
---|---|---|---|
icon_size |
int
|
Specified the target width of icon images. |
11
|
Returns:
Type | Description |
---|---|
Any
|
The IPython-rendered markdown output. |
Source code in fab/card.py
407 408 409 410 411 412 413 414 415 416 417 418 419 420 421 |
|
tcgplayer_url()
¶
Computes the TCG Player URL for the card.
Returns:
Type | Description |
---|---|
str
|
The URL used to search for the card on TCG Player. |
Source code in fab/card.py
423 424 425 426 427 428 429 430 |
|
to_dict()
¶
Converts this card into a raw python dictionary.
Returns:
Type | Description |
---|---|
dict[str, Any]
|
A copy of the raw |
Source code in fab/card.py
432 433 434 435 436 437 438 439 |
|
to_json()
¶
Computes the card's JSON string representation.
Returns:
Type | Description |
---|---|
str
|
A JSON string representation of the card. |
Source code in fab/card.py
441 442 443 444 445 446 447 448 |
|
to_series()
¶
Converts the card into a pandas Series object.
Returns:
Type | Description |
---|---|
Series
|
A pandas |
Source code in fab/card.py
450 451 452 453 454 455 456 457 458 |
|