Skip to content

ClassicTemplate

src.templates.normal.ClassicTemplate

Bases: NormalTemplate

A template for 7th Edition frame. Lacks some of the Normal Template features.

Source code in src\templates\normal.py
303
304
305
306
307
308
309
310
311
312
313
314
315
316
317
318
319
320
321
322
323
324
325
326
327
328
329
330
331
332
333
334
335
336
337
338
339
340
341
342
343
344
345
346
347
348
349
350
351
352
353
354
355
356
357
358
359
360
361
362
363
364
365
366
367
368
369
370
371
372
373
374
375
376
377
378
379
380
381
382
383
384
385
386
387
388
389
390
391
392
393
394
395
396
397
398
399
400
401
402
403
404
405
406
407
408
409
410
411
412
413
414
415
416
417
418
419
420
421
422
423
424
425
426
427
428
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
445
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
463
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
484
485
486
487
488
489
490
491
492
493
494
495
496
497
498
499
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
524
525
526
527
528
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
549
550
551
552
553
554
555
556
class ClassicTemplate(NormalTemplate):
    """A template for 7th Edition frame. Lacks some of the Normal Template features."""
    frame_suffix = 'Classic'

    """
    * Frame Details
    """

    @auto_prop_cached
    def template_suffix(self) -> str:
        """Add Promo if promo star enabled."""
        return 'Promo' if self.is_promo_star else ''

    """
    * Settings
    """

    @auto_prop_cached
    def is_promo_star(self) -> bool:
        """bool: Whether to enable the Promo Star overlay."""
        return CFG.get_setting(
            section='FRAME',
            key='Promo.Star',
            default=False)

    @auto_prop_cached
    def is_extended(self) -> bool:
        """bool: Whether to render using Extended Art framing."""
        return CFG.get_setting(
            section='FRAME',
            key='Extended.Art',
            default=False)

    @auto_prop_cached
    def is_align_collector_left(self) -> bool:
        """CollectorAlign: Which collector alignment to use."""
        return CFG.get_setting(
            section='TEXT',
            key='Collector.Align.Left',
            default=False)

    """
    * Bool Properties
    """

    @auto_prop_cached
    def is_content_aware_enabled(self) -> bool:
        """Force enabled if Extended Art is toggled."""
        return True if self.is_extended else super().is_content_aware_enabled

    """
    * Frame Layers
    """

    @auto_prop_cached
    def pinlines_layer(self) -> ArtLayer:
        """Only use split colors for land and hybrid cards, otherwise gold."""
        return psd.getLayer(
            self.background if len(self.pinlines) == 2 and not self.is_hybrid and not self.is_land else self.pinlines,
            LAYERS.LAND if self.is_land else LAYERS.NONLAND)

    """
    * Text Layers
    """

    @auto_prop_cached
    def text_layer_rules(self) -> ArtLayer:
        """ArtLayer: Does not change depending on Creature/Noncreature."""
        return psd.getLayer(LAYERS.RULES_TEXT, self.text_group)

    @auto_prop_cached
    def text_layer_type(self) -> ArtLayer:
        """ArtLayer: Card typeline text layer, used shifted version when color indicator is present."""
        if self.is_type_shifted:
            return psd.getLayer(LAYERS.TYPE_LINE_SHIFT, self.text_group)
        return psd.getLayer(LAYERS.TYPE_LINE, self.text_group)

    """
    * References
    """

    @auto_prop_cached
    def collector_reference(self) -> ReferenceLayer:
        """ReferenceLayer: Reference used to position the collector info."""
        return psd.get_reference_layer(LAYERS.COLLECTOR_REFERENCE, self.legal_group)

    @auto_prop_cached
    def textbox_reference(self) -> ArtLayer:
        """ArtLayer: Separately positioned box for 'Land' cards."""
        return psd.get_reference_layer(
            LAYERS.TEXTBOX_REFERENCE_LAND if self.is_land
            else LAYERS.TEXTBOX_REFERENCE,
            self.text_group)

    @auto_prop_cached
    def expansion_reference(self) -> ArtLayer:
        """ArtLayer: Separately positioned box for 'Land' cards."""
        return psd.getLayer(
            f"{LAYERS.EXPANSION_REFERENCE} {LAYERS.LAND}" if self.is_land
            else LAYERS.EXPANSION_REFERENCE,
            self.text_group)

    """
    * Masks
    """

    @auto_prop_cached
    def border_mask(self) -> ArtLayer:
        """ArtLayer: Contains a mask used to change the border to an Extended Art border."""
        return psd.getLayer(LAYERS.EXTENDED, LAYERS.MASKS)

    """
    * Layout Data Methods
    """

    def process_layout_data(self) -> None:
        """Remove rarity letter from collector data."""
        super().process_layout_data()
        self.layout.collector_data = self.layout.collector_data[:-2] if (
                '/' in self.layout.collector_data
        ) else self.layout.collector_data[2:]

    """
    * Collector Info Methods
    """

    def collector_info(self) -> None:
        """Format and add the collector info at the bottom."""

        # Which collector info mode?
        if CFG.collector_mode in [
            CollectorMode.Default, CollectorMode.Modern
        ] and self.layout.collector_data:
            layers = self.collector_info_authentic()
        elif CFG.collector_mode == CollectorMode.ArtistOnly:
            layers = self.collector_info_artist_only()
        else:
            layers = self.collector_info_basic()

        # Shift collector text
        if self.is_align_collector_left:
            [psd.align_left(n, ref=self.collector_reference.dims) for n in layers]

    def collector_info_basic(self) -> list[ArtLayer]:
        """Called to generate basic collector info."""

        # Get artist and info layers
        artist = psd.getLayer(LAYERS.ARTIST, self.legal_group)
        info = psd.getLayer(LAYERS.SET, self.legal_group)

        # Fill optional promo star
        if self.is_collector_promo:
            psd.replace_text(info, "•", MagicIcons.COLLECTOR_STAR)

        # Apply the collector info
        if self.layout.lang != 'en':
            psd.replace_text(info, 'EN', self.layout.lang.upper())
        psd.replace_text(artist, "Artist", self.layout.artist)
        psd.replace_text(info, 'SET', self.layout.set)
        return [artist, info]

    def collector_info_authentic(self) -> list[ArtLayer]:
        """Classic presents authentic collector info differently."""

        # Hide basic 'Set' layer
        psd.getLayer(LAYERS.SET, self.legal_group).visible = False

        # Get artist and info layers, reveal info layer
        artist = psd.getLayer(LAYERS.ARTIST, self.legal_group)
        info = psd.getLayer(LAYERS.COLLECTOR, self.legal_group)
        info.visible = True

        # Fill optional promo star
        if self.is_collector_promo:
            psd.replace_text(info, "•", MagicIcons.COLLECTOR_STAR)

        # Apply the collector info
        psd.replace_text(artist, 'Artist', self.layout.artist)
        psd.replace_text(info, 'SET', self.layout.set)
        psd.replace_text(info, 'NUM', self.layout.collector_data)
        return [artist, info]

    def collector_info_artist_only(self) -> list[ArtLayer]:
        """Called to generate 'Artist Only' collector info."""

        # Collector layers
        artist = psd.getLayer(LAYERS.ARTIST, self.legal_group)
        psd.getLayer(LAYERS.SET, self.legal_group).visible = False

        # Apply the collector info
        psd.replace_text(artist, "Artist", self.layout.artist)
        return [artist]

    """
    * Frame Layer Methods
    """

    def enable_frame_layers(self):
        """Enable layers which create the frame of the card. Simplified, does not support Legendary Crown."""

        # Resize expansion symbol
        if self.expansion_symbol_layer:
            self.expansion_symbol_layer.resize(90, 90, AnchorPosition.MiddleCenter)
            if self.is_land:
                self.expansion_symbol_layer.translate(0, 8)

        # Simple one image background
        self.pinlines_layer.visible = True

        # Add the promo star
        if self.is_promo_star:
            psd.getLayerSet("Promo Star", LAYERS.TEXT_AND_ICONS).visible = True

        # Make Extended Art modifications
        if self.is_extended:
            # Copy extended mask to Border
            psd.copy_layer_mask(self.border_mask, self.border_group)

            # Enable extended mask on Pinlines
            psd.enable_mask(self.pinlines_layer.parent)
            psd.enable_vector_mask(self.pinlines_layer.parent)

    """
    * Text Layer Methods
    """

    def rules_text_and_pt_layers(self):
        """Does not require a separate text area definition for Creature cards."""

        # Add rules text
        self.text.append(
            FormattedTextArea(
                layer=self.text_layer_rules,
                contents=self.layout.oracle_text,
                flavor=self.layout.flavor_text,
                centered=self.is_centered,
                reference=self.textbox_reference,
                divider=self.divider_layer))

        # Add Power / Toughness
        if self.is_creature:
            self.text.append(
                TextField(
                    layer=self.text_layer_pt,
                    contents=f'{self.layout.power}/'
                             f'{self.layout.toughness}'))

    """
    * Hook Methods
    """

    def hook_large_mana(self) -> None:
        """Adjust mana cost position for large symbols."""
        self.text_layer_mana.translate(0, -5)

Attributes

frame_suffix = 'Classic'

  • Frame Details

Functions

border_mask() -> ArtLayer

Source code in src\templates\normal.py
409
410
411
412
@auto_prop_cached
def border_mask(self) -> ArtLayer:
    """ArtLayer: Contains a mask used to change the border to an Extended Art border."""
    return psd.getLayer(LAYERS.EXTENDED, LAYERS.MASKS)

collector_info() -> None

Format and add the collector info at the bottom.

Source code in src\templates\normal.py
429
430
431
432
433
434
435
436
437
438
439
440
441
442
443
444
def collector_info(self) -> None:
    """Format and add the collector info at the bottom."""

    # Which collector info mode?
    if CFG.collector_mode in [
        CollectorMode.Default, CollectorMode.Modern
    ] and self.layout.collector_data:
        layers = self.collector_info_authentic()
    elif CFG.collector_mode == CollectorMode.ArtistOnly:
        layers = self.collector_info_artist_only()
    else:
        layers = self.collector_info_basic()

    # Shift collector text
    if self.is_align_collector_left:
        [psd.align_left(n, ref=self.collector_reference.dims) for n in layers]

collector_info_artist_only() -> list[ArtLayer]

Called to generate 'Artist Only' collector info.

Source code in src\templates\normal.py
485
486
487
488
489
490
491
492
493
494
def collector_info_artist_only(self) -> list[ArtLayer]:
    """Called to generate 'Artist Only' collector info."""

    # Collector layers
    artist = psd.getLayer(LAYERS.ARTIST, self.legal_group)
    psd.getLayer(LAYERS.SET, self.legal_group).visible = False

    # Apply the collector info
    psd.replace_text(artist, "Artist", self.layout.artist)
    return [artist]

collector_info_authentic() -> list[ArtLayer]

Classic presents authentic collector info differently.

Source code in src\templates\normal.py
464
465
466
467
468
469
470
471
472
473
474
475
476
477
478
479
480
481
482
483
def collector_info_authentic(self) -> list[ArtLayer]:
    """Classic presents authentic collector info differently."""

    # Hide basic 'Set' layer
    psd.getLayer(LAYERS.SET, self.legal_group).visible = False

    # Get artist and info layers, reveal info layer
    artist = psd.getLayer(LAYERS.ARTIST, self.legal_group)
    info = psd.getLayer(LAYERS.COLLECTOR, self.legal_group)
    info.visible = True

    # Fill optional promo star
    if self.is_collector_promo:
        psd.replace_text(info, "•", MagicIcons.COLLECTOR_STAR)

    # Apply the collector info
    psd.replace_text(artist, 'Artist', self.layout.artist)
    psd.replace_text(info, 'SET', self.layout.set)
    psd.replace_text(info, 'NUM', self.layout.collector_data)
    return [artist, info]

collector_info_basic() -> list[ArtLayer]

Called to generate basic collector info.

Source code in src\templates\normal.py
446
447
448
449
450
451
452
453
454
455
456
457
458
459
460
461
462
def collector_info_basic(self) -> list[ArtLayer]:
    """Called to generate basic collector info."""

    # Get artist and info layers
    artist = psd.getLayer(LAYERS.ARTIST, self.legal_group)
    info = psd.getLayer(LAYERS.SET, self.legal_group)

    # Fill optional promo star
    if self.is_collector_promo:
        psd.replace_text(info, "•", MagicIcons.COLLECTOR_STAR)

    # Apply the collector info
    if self.layout.lang != 'en':
        psd.replace_text(info, 'EN', self.layout.lang.upper())
    psd.replace_text(artist, "Artist", self.layout.artist)
    psd.replace_text(info, 'SET', self.layout.set)
    return [artist, info]

collector_reference() -> ReferenceLayer

Source code in src\templates\normal.py
384
385
386
387
@auto_prop_cached
def collector_reference(self) -> ReferenceLayer:
    """ReferenceLayer: Reference used to position the collector info."""
    return psd.get_reference_layer(LAYERS.COLLECTOR_REFERENCE, self.legal_group)

enable_frame_layers()

Enable layers which create the frame of the card. Simplified, does not support Legendary Crown.

Source code in src\templates\normal.py
500
501
502
503
504
505
506
507
508
509
510
511
512
513
514
515
516
517
518
519
520
521
522
523
def enable_frame_layers(self):
    """Enable layers which create the frame of the card. Simplified, does not support Legendary Crown."""

    # Resize expansion symbol
    if self.expansion_symbol_layer:
        self.expansion_symbol_layer.resize(90, 90, AnchorPosition.MiddleCenter)
        if self.is_land:
            self.expansion_symbol_layer.translate(0, 8)

    # Simple one image background
    self.pinlines_layer.visible = True

    # Add the promo star
    if self.is_promo_star:
        psd.getLayerSet("Promo Star", LAYERS.TEXT_AND_ICONS).visible = True

    # Make Extended Art modifications
    if self.is_extended:
        # Copy extended mask to Border
        psd.copy_layer_mask(self.border_mask, self.border_group)

        # Enable extended mask on Pinlines
        psd.enable_mask(self.pinlines_layer.parent)
        psd.enable_vector_mask(self.pinlines_layer.parent)

expansion_reference() -> ArtLayer

Source code in src\templates\normal.py
397
398
399
400
401
402
403
@auto_prop_cached
def expansion_reference(self) -> ArtLayer:
    """ArtLayer: Separately positioned box for 'Land' cards."""
    return psd.getLayer(
        f"{LAYERS.EXPANSION_REFERENCE} {LAYERS.LAND}" if self.is_land
        else LAYERS.EXPANSION_REFERENCE,
        self.text_group)

hook_large_mana() -> None

Adjust mana cost position for large symbols.

Source code in src\templates\normal.py
554
555
556
def hook_large_mana(self) -> None:
    """Adjust mana cost position for large symbols."""
    self.text_layer_mana.translate(0, -5)

is_align_collector_left() -> bool

Source code in src\templates\normal.py
336
337
338
339
340
341
342
@auto_prop_cached
def is_align_collector_left(self) -> bool:
    """CollectorAlign: Which collector alignment to use."""
    return CFG.get_setting(
        section='TEXT',
        key='Collector.Align.Left',
        default=False)

is_content_aware_enabled() -> bool

Force enabled if Extended Art is toggled.

Source code in src\templates\normal.py
348
349
350
351
@auto_prop_cached
def is_content_aware_enabled(self) -> bool:
    """Force enabled if Extended Art is toggled."""
    return True if self.is_extended else super().is_content_aware_enabled

is_extended() -> bool

Source code in src\templates\normal.py
328
329
330
331
332
333
334
@auto_prop_cached
def is_extended(self) -> bool:
    """bool: Whether to render using Extended Art framing."""
    return CFG.get_setting(
        section='FRAME',
        key='Extended.Art',
        default=False)

is_promo_star() -> bool

Source code in src\templates\normal.py
320
321
322
323
324
325
326
@auto_prop_cached
def is_promo_star(self) -> bool:
    """bool: Whether to enable the Promo Star overlay."""
    return CFG.get_setting(
        section='FRAME',
        key='Promo.Star',
        default=False)

pinlines_layer() -> ArtLayer

Only use split colors for land and hybrid cards, otherwise gold.

Source code in src\templates\normal.py
357
358
359
360
361
362
@auto_prop_cached
def pinlines_layer(self) -> ArtLayer:
    """Only use split colors for land and hybrid cards, otherwise gold."""
    return psd.getLayer(
        self.background if len(self.pinlines) == 2 and not self.is_hybrid and not self.is_land else self.pinlines,
        LAYERS.LAND if self.is_land else LAYERS.NONLAND)

process_layout_data() -> None

Remove rarity letter from collector data.

Source code in src\templates\normal.py
418
419
420
421
422
423
def process_layout_data(self) -> None:
    """Remove rarity letter from collector data."""
    super().process_layout_data()
    self.layout.collector_data = self.layout.collector_data[:-2] if (
            '/' in self.layout.collector_data
    ) else self.layout.collector_data[2:]

rules_text_and_pt_layers()

Does not require a separate text area definition for Creature cards.

Source code in src\templates\normal.py
529
530
531
532
533
534
535
536
537
538
539
540
541
542
543
544
545
546
547
548
def rules_text_and_pt_layers(self):
    """Does not require a separate text area definition for Creature cards."""

    # Add rules text
    self.text.append(
        FormattedTextArea(
            layer=self.text_layer_rules,
            contents=self.layout.oracle_text,
            flavor=self.layout.flavor_text,
            centered=self.is_centered,
            reference=self.textbox_reference,
            divider=self.divider_layer))

    # Add Power / Toughness
    if self.is_creature:
        self.text.append(
            TextField(
                layer=self.text_layer_pt,
                contents=f'{self.layout.power}/'
                         f'{self.layout.toughness}'))

template_suffix() -> str

Add Promo if promo star enabled.

Source code in src\templates\normal.py
311
312
313
314
@auto_prop_cached
def template_suffix(self) -> str:
    """Add Promo if promo star enabled."""
    return 'Promo' if self.is_promo_star else ''

text_layer_rules() -> ArtLayer

Source code in src\templates\normal.py
368
369
370
371
@auto_prop_cached
def text_layer_rules(self) -> ArtLayer:
    """ArtLayer: Does not change depending on Creature/Noncreature."""
    return psd.getLayer(LAYERS.RULES_TEXT, self.text_group)

text_layer_type() -> ArtLayer

Source code in src\templates\normal.py
373
374
375
376
377
378
@auto_prop_cached
def text_layer_type(self) -> ArtLayer:
    """ArtLayer: Card typeline text layer, used shifted version when color indicator is present."""
    if self.is_type_shifted:
        return psd.getLayer(LAYERS.TYPE_LINE_SHIFT, self.text_group)
    return psd.getLayer(LAYERS.TYPE_LINE, self.text_group)

textbox_reference() -> ArtLayer

Source code in src\templates\normal.py
389
390
391
392
393
394
395
@auto_prop_cached
def textbox_reference(self) -> ArtLayer:
    """ArtLayer: Separately positioned box for 'Land' cards."""
    return psd.get_reference_layer(
        LAYERS.TEXTBOX_REFERENCE_LAND if self.is_land
        else LAYERS.TEXTBOX_REFERENCE,
        self.text_group)