Deck¶
Deck wrapper with an overview class.
-
class
pyartifact.deck.
Deck
(deck_contents)[source]¶ Class for holding information about a deck. To use this, all sets must be loaded.
As this library isn’t supposed to be a fully fledged deck constructor, accessing deck_contents directly is recommended.
Compared to the out-of-the-box data encoded in the deck string, this object enriches them with an additional key instance that holds an instance of the deck from
pyartifact.Cards
As of now, the deck object does no validations, the rules to follow are:
- Some cards have includes, that are automatically added to the deck and they shouldn’t be in the cards portion of deck contents.
- Abilities and Passive abilities aren’t able to be included in a deck, as they come with another cards and are more of a traits than cards.
- Heroes have their own part of deck contents, don’t put them into the cards section
Deck code versions
Deck codes currently have two versions. We are able to load both, but only dump to version 2.
Version Heroes Cards Deck name 1 yes yes no 2 yes yes 63 characters When loading version 1, this library will still provide a name, which will be an empty string.
Parameters: deck_contents ( DeckContents
) – dict of deck contents-
cards
¶ List of dictionaries with all the cards and their information
Return type: List
[CardDeckType
]
-
deck_code
¶ Returns the latest version of the deck code.
Return type: str
-
dumps
()[source]¶ Returns the latest version of the deck code, same as deck_code property. For people who are used to json/yaml api :).
Return type: str
-
expand_cards
(hero_includes=True)[source]¶ Expands all the cards in the deck into a list of their instances, once for each count.
Parameters: hero_includes ( bool
) – Whether also expand auto-includes coming with the heroesReturn type: List
[Union
[Item
,Hero
,Ability
,PassiveAbility
,Improvement
,Creep
,Spell
]]
-
classmethod
from_code
(deck_code)[source]¶ Constructs the deck object from a deck code string.
Deck.from_code(deck_code) does the exact same thing as Deck.loads(deck_code)
Parameters: deck_code ( str
) – Version 1 or 2 deck codeReturn type: Deck
-
heroes
¶ List of dictionaries with all the heroes and their information
Return type: List
[HeroDeckType
]
-
classmethod
loads
(deck_code)¶ Constructs the deck object from a deck code string.
Deck.from_code(deck_code) does the exact same thing as Deck.loads(deck_code)
Parameters: deck_code ( str
) – Version 1 or 2 deck codeReturn type: Deck
-
name
¶ Name of the deck or an empty string of there is no name.
Return type: str
-
classmethod
new
(name, heroes, cards)[source]¶ Constructs the deck object from the insides of deck contents, for when you can’t be bothered to make a dict.
Parameters: - name (
str
) – Name of the deck - heroes (
List
[HeroDeckType
]) – List of dictionaries holding information about the heroes - cards (
List
[CardDeckType
]) – List of dictionaries holding information about the cards
- name (
-
static
new_card_dict
(card, count)[source]¶ Construction of a card dict compatible with the encoding process and Deck object internals
Parameters: - card (
Union
[Item
,Hero
,Ability
,PassiveAbility
,Improvement
,Creep
,Spell
]) – Instance of a card - count (
int
) – How many copies are in the deck
Return type: CardDeckType
- card (
-
class
pyartifact.deck.
Overview
(deck)[source]¶ A helper object for quick glances over the deck contents.
Parameters: deck ( Deck
) – An instantiated deck object-
creeps
(return_filter=False)[source]¶ All the creeps in the deck.
Parameters: return_filter ( bool
) – Whether to return apyartifact.CardFilter
object or just a List of cardsReturn type: Union
[List
[Creep
],CardFilter
]
-
heroes
(return_filter=False)[source]¶ All the heroes in the deck, sorted by their turns of deployment.
Parameters: return_filter ( bool
) – Whether to return apyartifact.CardFilter
object or just a List of cardsReturn type: Union
[List
[Hero
],CardFilter
]
-
improvements
(return_filter=False)[source]¶ All the improvements in the deck.
Parameters: return_filter ( bool
) – Whether to return apyartifact.CardFilter
object or just a List of cardsReturn type: Union
[List
[Improvement
],CardFilter
]
-
items
(sub_type=None, return_filter=False)[source]¶ All the items in the deck.
Parameters: - sub_type (
Optional
[str
]) – Whether to list only certain sub type of the items - return_filter (
bool
) – Whether to return apyartifact.CardFilter
object or just a List of cards
Return type: Union
[List
[Item
],CardFilter
]- sub_type (
-
items_per_subtype
()[source]¶ A more detailed overview of items on the deck in a form of defaultdict(list) where each key is a sub type and it’s value is a list of those items.
Return type: Dict
[str
,List
[Item
]]
-
spells
(return_filter=False)[source]¶ All the spells in the deck.
Parameters: return_filter ( bool
) – Whether to return apyartifact.CardFilter
object or just a List of cardsReturn type: Union
[List
[Spell
],CardFilter
]
-