Skip to content

Utils

scooze.utils

ComparableObject

A simple base class to support comparable objects.

HashableObject

Bases: ComparableObject, Hashable

A simple base class to support hashable objects.

DictDiff

Bases: ComparableObject

Represents a diff between two dicts.

Attributes:

Name Type Description
contents dict[Any, tuple[int, int]]

The contents of this diff.

get_diff(d1: dict, d2: dict, NO_KEY: Any = 0) -> DictDiff classmethod

Generate a diff between two dicts.

Parameters:

Name Type Description Default
d1 dict

The first dict.

required
d2 dict

The second dict.

required
NO_KEY Any

Default value to use when a key is in one dict, but not the other.

0

Returns:

Type Description
DictDiff

A dict with all keys from both dicts. The values are tuple(v, v)

DictDiff

for the values in each dict.

is_empty()

Determines if this diff is empty.

max_relentless_quantity(name: str) -> int

Given a card name, what is the maximum quantity of a card in a deck?

max_card_quantity(fmt: Format) -> int

Given a Format, what is the maximum quantity of a card in a deck?

main_size(fmt: Format) -> tuple[int, int]

Given a Format, what are the required min and max size for a main deck?

side_size(fmt: Format) -> tuple[int, int]

Given a Format, what are the min and max size for a sideboard?

cmdr_size(fmt: Format) -> tuple[int, int]

Given a Format, what are the min and max size for a command zone?

attractions_size(fmt: Format) -> tuple[int, int]

Given a Format, what are the min and max size for the attraction deck?

  • Attraction decks must contain at least 10 attraction cards in constructed. They must be unique.
  • Attraction decks must contain at least 3 attraction cards in limited. They do not need to be unique.

stickers_size(fmt: Format) -> tuple[int, int]

Given a Format, what are the min and max size for the sticker deck?

  • Sticker decks must contain at least 10 unique sheets in constructed. 3 are randomly chosen at the start of each game.
  • Sticker decks in limited may contain up to 3 sheets from among those opened. There could be repeats.

parse_symbols(cost: str) -> Counter[CostSymbol]

Parse a string containing one or more cost symbols, in standard oracle text form (e.g. "{4}{G}").

Parameters:

Name Type Description Default
cost str

String representing a mana cost, or rules text that may have one or more symbols.

required

Returns:

Type Description
Counter[CostSymbol]

A mapping of cost symbols to the number of times they appear in that string.

scooze.enums

CaseInsensitiveEnumMeta

Bases: EnumMeta

An extension of the classic Python EnumMeta to support case-insensitive fields.

ExtendedEnum

Bases: Enum

An extension of the classic Python Enum to support additional functionality.

list() classmethod

Get a list of this Enum's field names.

DbCollection

Bases: ExtendedEnum, StrEnum

Collections in the scooze database.