Skip to content

TokenLayout

src.layouts.TokenLayout

Bases: NormalLayout

Token card layout for token game pieces.

Source code in src\layouts.py
1464
1465
1466
1467
1468
1469
1470
1471
1472
1473
1474
1475
1476
1477
1478
1479
1480
1481
1482
1483
1484
1485
1486
1487
1488
1489
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
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
    """

    @auto_prop_cached
    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 ''

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

    @auto_prop_cached
    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

display_name: str

Functions

card_count() -> Optional[int]

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

Source code in src\layouts.py
1490
1491
1492
1493
1494
1495
1496
1497
1498
1499
@auto_prop_cached
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)

collector_data() -> str

Source code in src\layouts.py
1476
1477
1478
1479
1480
1481
1482
1483
@auto_prop_cached
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 ''

set() -> str

Source code in src\layouts.py
1485
1486
1487
1488
@auto_prop_cached
def set(self) -> str:
    """str: Use parent set code if provided."""
    return self.set_data.get('code_parent', super().set).upper()