Skip to content

ClassVectorTemplate

src.templates.classes.ClassVectorTemplate

Bases: VectorNyxMod, ClassMod, VectorTemplate

Class template using vector shape layers and automatic pinlines / multicolor generation.

Source code in src\templates\classes.py
212
213
214
215
216
217
218
219
220
221
222
223
224
225
226
227
228
229
230
231
232
233
234
235
236
237
238
239
240
241
242
243
244
245
246
247
248
249
250
251
252
253
254
255
256
257
258
259
260
261
262
263
264
265
266
267
268
269
270
271
272
273
274
275
276
277
278
279
280
281
282
283
284
285
286
287
288
289
290
291
292
293
294
295
296
297
298
299
300
301
302
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
class ClassVectorTemplate (VectorNyxMod, ClassMod, VectorTemplate):
    """Class template using vector shape layers and automatic pinlines / multicolor generation."""

    """
    * Bool
    """

    @auto_prop_cached
    def is_name_shifted(self) -> bool:
        """Back face TF symbol is on right side."""
        return bool(self.is_transform and self.is_front)

    """
    * Colors
    """

    @auto_prop_cached
    def textbox_colors(self) -> list[str]:
        """list[str]: Support back side texture names."""
        colors = list(self.identity) if self.is_within_color_limit else [self.pinlines]
        # Is this card a back face transform?
        if self.is_transform and not self.is_front:
            return [f'{n} {LAYERS.BACK}' for n in colors]
        return colors

    @auto_prop_cached
    def crown_colors(self) -> Union[list[int], list[dict]]:
        """Return RGB notation or Gradient dict notation for adjustment layers."""
        return psd.get_pinline_gradient(
            colors=self.pinlines, color_map=self.crown_color_map)

    """
    * Groups
    """

    @auto_prop_cached
    def crown_group(self) -> LayerSet:
        """Use inner shape group for Legendary Crown."""
        return psd.getLayerSet(LAYERS.SHAPE, [self.docref, LAYERS.LEGENDARY_CROWN])

    @auto_prop_cached
    def textbox_group(self) -> LayerSet:
        """Must enable textbox group."""
        if group := psd.getLayerSet(LAYERS.TEXTBOX, self.docref):
            group.visible = True
            return group

    """
    * Layers
    """

    @auto_prop_cached
    def twins_layer(self) -> Optional[ArtLayer]:
        # Use Back face versions for back side Transform
        return psd.getLayer(
            f"{self.twins} {LAYERS.BACK}" if self.is_transform and not self.is_front else self.twins,
            self.twins_group)

    """
    * References
    """

    @auto_prop_cached
    def art_reference(self) -> ArtLayer:
        return psd.getLayer(LAYERS.ART_FRAME + " Left")

    @auto_prop_cached
    def textbox_reference(self) -> Optional[ArtLayer]:
        if self.is_front and self.is_flipside_creature:
            return psd.get_reference_layer(
                f'{LAYERS.TEXTBOX_REFERENCE} {LAYERS.TRANSFORM_FRONT}',
                self.class_group)
        return psd.get_reference_layer(LAYERS.TEXTBOX_REFERENCE, self.class_group)

    @auto_prop_cached
    def textbox_position_reference(self) -> Optional[ArtLayer]:
        return psd.getLayer(LAYERS.ART_FRAME + " Right")

    """
    * Blending Masks
    """

    @auto_prop_cached
    def textbox_masks(self) -> list[ArtLayer]:
        """Blends the textbox colors."""
        return [psd.getLayer(LAYERS.HALF, [self.mask_group, LAYERS.TEXTBOX])]

    @auto_prop_cached
    def background_masks(self) -> list[ArtLayer]:
        """Blends the background colors."""
        return [psd.getLayer(LAYERS.HALF, [self.mask_group, LAYERS.BACKGROUND])]

    """
    * Shapes
    """

    @auto_prop_cached
    def border_shape(self) -> Optional[ArtLayer]:
        """Support a Normal and Legendary border for front-face Transform."""
        if self.is_transform and self.is_front:
            return psd.getLayer(
                f"{LAYERS.LEGENDARY if self.is_legendary else LAYERS.NORMAL} {LAYERS.TRANSFORM_FRONT}",
                self.border_group)
        return super().border_shape

    @auto_prop_cached
    def pinlines_shapes(self) -> list[LayerSet]:
        """Support front and back face Transform pinlines, and optional Legendary pinline shape."""
        shapes = [psd.getLayerSet(LAYERS.LEGENDARY, [self.pinlines_group, LAYERS.SHAPE])] if self.is_legendary else []
        return [
            # Normal or Transform pinline
            psd.getLayerSet(
                (LAYERS.TRANSFORM_FRONT if self.is_front else LAYERS.TRANSFORM_BACK)
                if self.is_transform else LAYERS.NORMAL,
                [self.pinlines_group, LAYERS.SHAPE]
            ), *shapes
        ]

    @auto_prop_cached
    def twins_shape(self) -> ArtLayer:
        """Support both front and back face Transform shapes."""
        return psd.getLayer(
            (LAYERS.TRANSFORM_FRONT if self.is_front else LAYERS.TRANSFORM_BACK)
            if self.is_transform else LAYERS.NORMAL,
            [self.twins_group, LAYERS.SHAPE])

    @auto_prop_cached
    def outline_shape(self):
        """Outline for the textbox and art."""
        return psd.getLayer(
            LAYERS.TRANSFORM_FRONT if self.is_transform and self.is_front else LAYERS.NORMAL,
            LAYERS.OUTLINE)

    @auto_prop_cached
    def enabled_shapes(self) -> list[Union[ArtLayer, LayerSet, None]]:
        """Add support for outline shape and multiple pinlines shapes."""
        return [
            *self.pinlines_shapes,
            self.outline_shape,
            self.border_shape,
            self.twins_shape
        ]

    """
    * Masks to Enable
    """

    @auto_prop_cached
    def pinlines_mask(self) -> list[Union[ArtLayer, LayerSet]]:
        """Mask hiding pinlines effects inside textbox and art frame."""
        return [
            psd.getLayer(
                LAYERS.TRANSFORM_FRONT if self.is_transform and self.is_front else LAYERS.NORMAL,
                [self.mask_group, LAYERS.PINLINES]),
            self.pinlines_group
        ]

    @auto_prop_cached
    def enabled_masks(self) -> list[Union[dict, list, ArtLayer, LayerSet, None]]:
        """Support a pinlines mask."""
        return [self.pinlines_mask]

    """
    * Frame Layer Methods
    """

    def enable_frame_layers(self) -> None:
        super().enable_frame_layers()

        # Merge the textbox and shift it to right half
        psd.merge_group(self.textbox_group)
        psd.align_horizontal(
            layer=self.active_layer,
            ref=self.textbox_position_reference)

    """
    * Class Frame Layer Methods
    """

    def frame_layers_classes(self):
        """Enable layers relating to Class type cards."""

        # Enable class group, disable saga banner
        self.class_group.visible = True
        psd.getLayerSet("Banner Top").visible = False

Functions

background_masks() -> list[ArtLayer]

Blends the background colors.

Source code in src\templates\classes.py
299
300
301
302
@auto_prop_cached
def background_masks(self) -> list[ArtLayer]:
    """Blends the background colors."""
    return [psd.getLayer(LAYERS.HALF, [self.mask_group, LAYERS.BACKGROUND])]

border_shape() -> Optional[ArtLayer]

Support a Normal and Legendary border for front-face Transform.

Source code in src\templates\classes.py
308
309
310
311
312
313
314
315
@auto_prop_cached
def border_shape(self) -> Optional[ArtLayer]:
    """Support a Normal and Legendary border for front-face Transform."""
    if self.is_transform and self.is_front:
        return psd.getLayer(
            f"{LAYERS.LEGENDARY if self.is_legendary else LAYERS.NORMAL} {LAYERS.TRANSFORM_FRONT}",
            self.border_group)
    return super().border_shape

crown_colors() -> Union[list[int], list[dict]]

Return RGB notation or Gradient dict notation for adjustment layers.

Source code in src\templates\classes.py
237
238
239
240
241
@auto_prop_cached
def crown_colors(self) -> Union[list[int], list[dict]]:
    """Return RGB notation or Gradient dict notation for adjustment layers."""
    return psd.get_pinline_gradient(
        colors=self.pinlines, color_map=self.crown_color_map)

crown_group() -> LayerSet

Use inner shape group for Legendary Crown.

Source code in src\templates\classes.py
247
248
249
250
@auto_prop_cached
def crown_group(self) -> LayerSet:
    """Use inner shape group for Legendary Crown."""
    return psd.getLayerSet(LAYERS.SHAPE, [self.docref, LAYERS.LEGENDARY_CROWN])

enabled_masks() -> list[Union[dict, list, ArtLayer, LayerSet, None]]

Support a pinlines mask.

Source code in src\templates\classes.py
369
370
371
372
@auto_prop_cached
def enabled_masks(self) -> list[Union[dict, list, ArtLayer, LayerSet, None]]:
    """Support a pinlines mask."""
    return [self.pinlines_mask]

enabled_shapes() -> list[Union[ArtLayer, LayerSet, None]]

Add support for outline shape and multiple pinlines shapes.

Source code in src\templates\classes.py
345
346
347
348
349
350
351
352
353
@auto_prop_cached
def enabled_shapes(self) -> list[Union[ArtLayer, LayerSet, None]]:
    """Add support for outline shape and multiple pinlines shapes."""
    return [
        *self.pinlines_shapes,
        self.outline_shape,
        self.border_shape,
        self.twins_shape
    ]

frame_layers_classes()

Enable layers relating to Class type cards.

Source code in src\templates\classes.py
391
392
393
394
395
396
def frame_layers_classes(self):
    """Enable layers relating to Class type cards."""

    # Enable class group, disable saga banner
    self.class_group.visible = True
    psd.getLayerSet("Banner Top").visible = False

is_name_shifted() -> bool

Back face TF symbol is on right side.

Source code in src\templates\classes.py
219
220
221
222
@auto_prop_cached
def is_name_shifted(self) -> bool:
    """Back face TF symbol is on right side."""
    return bool(self.is_transform and self.is_front)

outline_shape()

Outline for the textbox and art.

Source code in src\templates\classes.py
338
339
340
341
342
343
@auto_prop_cached
def outline_shape(self):
    """Outline for the textbox and art."""
    return psd.getLayer(
        LAYERS.TRANSFORM_FRONT if self.is_transform and self.is_front else LAYERS.NORMAL,
        LAYERS.OUTLINE)

pinlines_mask() -> list[Union[ArtLayer, LayerSet]]

Mask hiding pinlines effects inside textbox and art frame.

Source code in src\templates\classes.py
359
360
361
362
363
364
365
366
367
@auto_prop_cached
def pinlines_mask(self) -> list[Union[ArtLayer, LayerSet]]:
    """Mask hiding pinlines effects inside textbox and art frame."""
    return [
        psd.getLayer(
            LAYERS.TRANSFORM_FRONT if self.is_transform and self.is_front else LAYERS.NORMAL,
            [self.mask_group, LAYERS.PINLINES]),
        self.pinlines_group
    ]

pinlines_shapes() -> list[LayerSet]

Support front and back face Transform pinlines, and optional Legendary pinline shape.

Source code in src\templates\classes.py
317
318
319
320
321
322
323
324
325
326
327
328
@auto_prop_cached
def pinlines_shapes(self) -> list[LayerSet]:
    """Support front and back face Transform pinlines, and optional Legendary pinline shape."""
    shapes = [psd.getLayerSet(LAYERS.LEGENDARY, [self.pinlines_group, LAYERS.SHAPE])] if self.is_legendary else []
    return [
        # Normal or Transform pinline
        psd.getLayerSet(
            (LAYERS.TRANSFORM_FRONT if self.is_front else LAYERS.TRANSFORM_BACK)
            if self.is_transform else LAYERS.NORMAL,
            [self.pinlines_group, LAYERS.SHAPE]
        ), *shapes
    ]

textbox_colors() -> list[str]

list[str]: Support back side texture names.

Source code in src\templates\classes.py
228
229
230
231
232
233
234
235
@auto_prop_cached
def textbox_colors(self) -> list[str]:
    """list[str]: Support back side texture names."""
    colors = list(self.identity) if self.is_within_color_limit else [self.pinlines]
    # Is this card a back face transform?
    if self.is_transform and not self.is_front:
        return [f'{n} {LAYERS.BACK}' for n in colors]
    return colors

textbox_group() -> LayerSet

Must enable textbox group.

Source code in src\templates\classes.py
252
253
254
255
256
257
@auto_prop_cached
def textbox_group(self) -> LayerSet:
    """Must enable textbox group."""
    if group := psd.getLayerSet(LAYERS.TEXTBOX, self.docref):
        group.visible = True
        return group

textbox_masks() -> list[ArtLayer]

Blends the textbox colors.

Source code in src\templates\classes.py
294
295
296
297
@auto_prop_cached
def textbox_masks(self) -> list[ArtLayer]:
    """Blends the textbox colors."""
    return [psd.getLayer(LAYERS.HALF, [self.mask_group, LAYERS.TEXTBOX])]

twins_shape() -> ArtLayer

Support both front and back face Transform shapes.

Source code in src\templates\classes.py
330
331
332
333
334
335
336
@auto_prop_cached
def twins_shape(self) -> ArtLayer:
    """Support both front and back face Transform shapes."""
    return psd.getLayer(
        (LAYERS.TRANSFORM_FRONT if self.is_front else LAYERS.TRANSFORM_BACK)
        if self.is_transform else LAYERS.NORMAL,
        [self.twins_group, LAYERS.SHAPE])