Deck

from dgisim import Deck, MutableDeck, FrozenDeck

A data structure for a deck. A deck contains a sequence of characters and a dictionary of cards.

class Deck

An abstract class representing a deck of cards.

cards: dict[type[Card], int]
chars: Sequence[type[Character]]
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.

abstract property immutable: bool
Returns:

True if the deck is immutable.

to_frozen() FrozenDeck
Returns:

An immutable copy of the deck.

to_json() str
Returns:

A JSON string representing the deck.

to_mutable() MutableDeck
Returns:

A mutable copy of the deck.

class MutableDeck(chars: 'list[type[Character]]', cards: 'dict[type[Card], int]')

Bases: Deck

cards: dict[type[Card], int]
chars: list[type[Character]]
classmethod decoding(encoding: list[int], encoding_plan: EncodingPlan) None | Self
Returns:

A deck parsed from the given list of integers.

classmethod from_json(data: str) None | Self
Returns:

A deck parsed from the given JSON string.

property immutable: bool
Returns:

True if the deck is immutable.

class FrozenDeck(chars: 'tuple[type[Character], ...]', cards: 'HashableDict[type[Card], int]')

Bases: Deck

cards: HashableDict[type[Card], int]
chars: tuple[type[Character], ...]
classmethod decoding(encoding: list[int], encoding_plan: EncodingPlan) None | Self
Returns:

A deck parsed from the given list of integers.

classmethod from_json(data: str) None | Self
Returns:

A deck parsed from the given JSON string.

property immutable: bool
Returns:

True if the deck is immutable.