Skip to content

TokenLayout

src.layouts.TokenLayout

Bases: NormalLayout

Token card layout for token game pieces.

Source code in src\layouts.py
class TokenLayout(NormalLayout):
    """Token card layout for token game pieces."""

    @property
    def display_name(self) -> str:
        """str: Add Token for display on GUI."""
        return f"{self.name} Token"

    """
    * Collector Info
    """

    @cached_property
    def collector_data(self) -> str:
        """str: Formatted collector info line, rarity letter is always T, e.g. 050/230 T."""
        if self.card_count:
            return f'{str(self.collector_number).zfill(3)}/{str(self.card_count).zfill(3)} T'
        if self.collector_number_raw:
            return f'T {str(self.collector_number).zfill(4)}'
        return ''

    @cached_property
    def set(self) -> str:
        """str: Use parent set code if provided."""
        return self.set_data.get('code_parent', super().set).upper()

    @cached_property
    def card_count(self) -> Optional[int]:
        """Optional[int]: Use token count for token cards."""

        # Skip if collector mode doesn't require it or if collector number is bad
        if CFG.collector_mode != CollectorMode.Normal or not self.collector_number_raw:
            return

        # Prefer printed count, fallback to card count, skip if count isn't found
        return self.set_data.get('count_tokens', None)

Attributes

art_file: Path

artist: str

Card artist name, prioritizes user provided artist name. Controls for duplicate last names.

background: str

Identity of the background.

card: dict

Main card data object to pull most relevant data from.

card_count: Optional[int]

Optional[int]: Use token count for token cards.

collector_data: str

collector_number: int

collector_number_raw: Optional[str]

str | None: Card number assigned within release set. Raw string representation, allows non-digits.

color_identity: list[str]

Commander relevant color identity array, e.g. [W, U].

color_indicator: str

Color indicator identity array, e.g. [W, U].

creator: str

date: date

display_name: str

file: CardDetails

Dictionary containing parsed art file details.

first_print: dict

Card data fetched from Scryfall representing the first print of this card.

flavor_text: str

Card flavor text, alternate language version shares the same key.

frame: FrameDetails

Dictionary containing calculated frame information.

frame_effects: list[str]

Array of frame effects, e.g. nyxtouched, snow, etc.

identity: str

Frame appropriate color identity of the card.

input_name: str

Card name, version provided in art file name.

is_alt_lang: bool

True if language selected isn't English.

is_artifact: bool

True if card is an Artifact.

is_basic_land: bool

True if card is a Basic Land.

is_colorless: bool

True if card is colorless or devoid.

is_companion: bool

True if card is a Companion.

is_creature: bool

True if card is a Creature.

is_emblem: bool

is_front: bool

True if card is front face.

is_hybrid: bool

True if card is a hybrid frame.

is_land: bool

True if card is a Land.

is_legendary: bool

True if card is Legendary.

is_miracle: bool

True if card is a 'Miracle' card.

is_nyx: bool

True if card has Nyx enchantment background texture.

is_promo: bool

True if card is a promotional print.

is_snow: bool

True if card is a 'Snow' card.

is_token: bool

is_vehicle: bool

True if card is a Vehicle.

keywords: list[str]

Array of keyword abilities, e.g. Flying, Haste, etc.

lang: str

Card print language, uppercase enforced, falls back to settings defined value.

mana_cost: Optional[str]

Scryfall formatted card mana cost.

name: str

Card name, supports alternate language source.

name_raw: str

Card name, enforced English representation.

nickname: str

Nickname, typically set inside template logic but can be passed in filename.

oracle_text: str

Card rules text, supports alternate language source.

oracle_text_raw: str

Card rules text, enforced English representation.

other_face: dict

Card data from opposing face if provided.

other_face_frame: Union[FrameDetails, dict]

Calculated frame information of opposing face, if provided.

other_face_left: Optional[str]

Abridged type of the opposing side to display on bottom MDFC bar.

other_face_mana_cost: str

Mana cost of opposing face.

other_face_oracle_text: str

Rules text of opposing face.

other_face_oracle_text_raw: str

Rules text of opposing face.

other_face_power: str

Creature power of opposing face, if provided.

other_face_right: str

Mana cost or mana ability of opposing side, depending on land or nonland.

other_face_toughness: str

Creature toughness of opposing face, if provided.

other_face_twins: str

Name and title box identity of opposing face.

other_face_type_line: str

Type line of opposing face.

other_face_type_line_raw: str

Type line of opposing face, English language enforced.

pinlines: str

Identity of the pinlines.

power: str

Creature power, if provided.

promo_types: list[str]

list[str]: Promo types this card matches, e.g. stamped, datestamped, etc.

rarity: str

Card rarity, interprets 'special' rarities based on card data.

rarity_letter: str

First letter of card rarity, uppercase enforced.

rarity_raw: str

Card rarity, doesn't interpret 'special' rarities.

rules_text: str

Utility definition comprised of rules and flavor text as available.

scryfall: dict

Card data fetched from Scryfall.

scryfall_scan: str

Scryfall large image scan, if available.

set: str

set_data: dict

Set data from the current hexproof.io data file.

set_type: str

subtypes: list[str]

Subtypes represented, e.g. Elf, Human, Goblin, etc.

supertypes: list[str]

Supertypes represented, e.g. Basic, Legendary, Snow, etc.

symbol_code: str

Code used to match a symbol to this card's set. Provided by hexproof.io.

symbol_svg: Optional[Path]

SVG path definition for card's expansion symbol.

template_file: Path

Template PSD file path, replaced before render process.

toughness: str

Creature toughness, if provided.

transform_icon: str

Transform icon if provided, data possibly deprecated in modern practice.

twins: str

Identity of the name and title boxes.

type_line: str

Card type line, supports alternate language source.

type_line_raw: str

Card type line, enforced English representation.

types: list[str]

Main cards types represented, e.g. Sorcery, Instant, Creature, etc.

types_raw: list[str]

List of types extracted from the raw typeline.

watermark: Optional[str]

Name of the card's watermark file that is actually used, if provided.

watermark_basic: Optional[Path]

Optional[Path]: Path to basic land watermark, if card is a Basic Land.

watermark_raw: Optional[str]

Name of the card's watermark from raw Scryfall data, if provided.

watermark_svg: Optional[Path]

Path to the watermark SVG file, if provided.