Deck
from dgisim import Deck, FrozenDeck, MutableDeck
__eq__ is implemented so that two decks are equal if they have the same
data.
- class Deck
An abstract class representing a deck of cards.
- abstract classmethod decoding(encoding: list[int], encoding_plan: EncodingPlan) None | Self
- Returns:
A deck parsed from the given list of integers.
- encoding(encoding_plan: EncodingPlan) list[int]
- Returns:
A list of integers representing the deck.
- abstract classmethod from_json(data: str) None | Self
- Returns:
A deck parsed from the given JSON string.
- to_frozen() FrozenDeck
- Returns:
An immutable copy of the deck.
- to_mutable() MutableDeck
- Returns:
A mutable copy of the deck.
Usage Example
from dgisim import FrozenDeck, MutableDeck, HashableDict
from dgisim import char
from dgisim import card
deck1 = FrozenDeck(
chars = (char.Bennett, char.Klee, char.Keqing),
cards = HashableDict({
card.TeyvatFriedEgg: 2,
card.TandooriRoastChicken: 2,
card.LotusFlowerCrisp: 2,
}),
)
deck2 = MutableDeck(
chars = [char.Bennett, char.Klee, char.Keqing],
cards = {
card.TeyvatFriedEgg: 2,
card.TandooriRoastChicken: 2,
card.LotusFlowerCrisp: 2,
},
)