Class: MtgCardMaker::LayerFactory

Inherits:
Object
  • Object
show all
Defined in:
lib/mtg_card_maker/layer_factory.rb

Overview

Centralized factory for creating card layers that eliminates duplication between BaseCard and SpriteSheetService. This factory handles the creation of all layer types with proper configuration and dependencies.

Examples:

layers = MtgCardMaker::LayerFactory.create_layers_for_card(card, mask_id, card_config)
layers.each { |layer| template.add_layer(layer) }

Since:

  • 0.1.0

Class Method Summary collapse

Instance Method Summary collapse

Constructor Details

#initialize(card, mask_id, card_config) ⇒ LayerFactory

Initialize a new layer factory

Parameters:

  • card (BaseCard)

    the card instance

  • mask_id (String)

    the mask ID for art window

  • card_config (Object)

    the card configuration object

Since:

  • 0.1.0



37
38
39
40
41
42
# File 'lib/mtg_card_maker/layer_factory.rb', line 37

def initialize(card, mask_id, card_config)
  @card = card
  @mask_id = mask_id
  @card_config = card_config
  @color_scheme = card.color_scheme
end

Class Method Details

.create_layers_for_card(card, mask_id, card_config) ⇒ Array<BaseLayer>

Create all layers for a card using the factory pattern

Parameters:

  • card (BaseCard)

    the card instance

  • mask_id (String)

    the mask ID for art window

  • card_config (Object)

    the card configuration object

Returns:

  • (Array<BaseLayer>)

    an array of all card layers

Since:

  • 0.1.0



28
29
30
# File 'lib/mtg_card_maker/layer_factory.rb', line 28

def self.create_layers_for_card(card, mask_id, card_config)
  new(card, mask_id, card_config).create_layers
end

Instance Method Details

#create_layersArray<BaseLayer>

Create all layers for the card in the correct order

Returns:

  • (Array<BaseLayer>)

    an array of all card layers in rendering order

Since:

  • 0.1.0



47
48
49
50
51
52
53
54
55
56
57
# File 'lib/mtg_card_maker/layer_factory.rb', line 47

def create_layers
  [
    create_border_layer,
    create_frame_layer,
    create_name_layer,
    create_art_layer,
    create_type_line_layer,
    create_text_box_layer,
    create_power_layer
  ]
end