InventoryItem
Represents a particular instance of a Flesh and Blood card, for inventory purposes.
Note
Unlike normal Card objects, InventoryItem objects represent a
card's unique identifier, edition, rarity, and foiling.
Attributes:
| Name | Type | Description |
|---|---|---|
edition |
str
|
The edition code associated with the card (see |
foiling |
str
|
The foiling code associated with the card (see |
identifier |
str
|
The unique identifier associated with the card. |
rarity |
str
|
The rarity code associated with the card (see |
Source code in fab/inventory.py
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 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 | |
__getitem__(key)
¶
Allows one to access fields of an inventory item via dictionary syntax.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
key |
str
|
The name of the class attribute to fetch. |
required |
Returns:
| Type | Description |
|---|---|
str
|
The value associated with the specified field. |
Source code in fab/inventory.py
41 42 43 44 45 46 47 48 49 50 51 | |
__hash__()
¶
Computes the hash representation of the inventory item.
Returns:
| Type | Description |
|---|---|
Any
|
The hash representation of the inventory item. |
Source code in fab/inventory.py
53 54 55 56 57 58 59 60 | |
__str__()
¶
Computes the string representation of the inventory item.
This is an alias to the to_str() method.
Returns:
| Type | Description |
|---|---|
str
|
The string representation of the inventory item. |
Source code in fab/inventory.py
62 63 64 65 66 67 68 69 70 71 | |
from_json(jsonstr)
staticmethod
¶
Creates a new inventory card from the specified JSON string.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
jsonstr |
str
|
The JSON string representation to parse. |
required |
Returns:
| Type | Description |
|---|---|
InventoryItem
|
The parsed |
Source code in fab/inventory.py
73 74 75 76 77 78 79 80 81 82 83 84 | |
from_list(data)
staticmethod
¶
Creates a new inventory card from its list representation.
Returns:
| Type | Description |
|---|---|
InventoryItem
|
The new inventory item. |
Source code in fab/inventory.py
86 87 88 89 90 91 92 93 94 95 96 97 98 99 100 101 | |
from_str(data)
staticmethod
¶
Creates a new inventory card from its string representation.
Returns:
| Type | Description |
|---|---|
InventoryItem
|
The new inventory item. |
Source code in fab/inventory.py
120 121 122 123 124 125 126 127 128 129 130 131 132 133 134 135 136 | |
from_tuple(data)
staticmethod
¶
Creates a new inventory card from its tuple representation.
Returns:
| Type | Description |
|---|---|
InventoryItem
|
The new inventory item. |
Source code in fab/inventory.py
103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 | |
keys()
¶
Returns the dictionary keys associated with this inventory item.
Returns:
| Type | Description |
|---|---|
list[str]
|
The |
Source code in fab/inventory.py
138 139 140 141 142 143 144 145 | |
to_card(catalog=None)
¶
Converts this unique card representation into a generic card representation.
Note
To instantiate the card this way, a card catalog (CardList) must be
provided, defaulting to card.CARD_CATALOG.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
catalog |
Optional[CardList]
|
The card catalog to use as a reference, defaulting to |
None
|
Returns:
| Type | Description |
|---|---|
Card
|
A |
Source code in fab/inventory.py
147 148 149 150 151 152 153 154 155 156 157 158 159 160 161 162 | |
to_dict()
¶
Converts this inventory item into a raw python dictionary.
Returns:
| Type | Description |
|---|---|
dict[str, str]
|
A copy of the raw |
Source code in fab/inventory.py
164 165 166 167 168 169 170 171 | |
to_json()
¶
Computes the inventory item's JSON string representation.
Returns:
| Type | Description |
|---|---|
str
|
A JSON string representation of the inventory item. |
Source code in fab/inventory.py
173 174 175 176 177 178 179 180 | |
to_list()
¶
Converts this inventory item into a list of field strings.
Returns:
| Type | Description |
|---|---|
list[str]
|
A |
Source code in fab/inventory.py
182 183 184 185 186 187 188 189 | |
to_str()
¶
Computes the string representation of the inventory item.
This is a string of the form:
{edition}-{identifier}-{rarity}-{foiling}
Returns:
| Type | Description |
|---|---|
str
|
The string representation of the inventory item. |
Source code in fab/inventory.py
191 192 193 194 195 196 197 198 199 200 201 202 203 204 | |
to_tuple()
¶
Converts this inventory item into a tuple of field strings.
Returns:
| Type | Description |
|---|---|
tuple[str, str, str, str]
|
A |
Source code in fab/inventory.py
206 207 208 209 210 211 212 213 | |