Class: MtgCardMaker::BaseCard
- Inherits:
-
Object
- Object
- MtgCardMaker::BaseCard
- Defined in:
- lib/mtg_card_maker/base_card.rb
Overview
Base class for all Magic: The Gathering card types that provides common functionality with simplified configuration. This class handles the creation of complete MTG cards with all necessary layers (frames, text, art, etc.) using predefined dimensions and layouts.
Constant Summary collapse
- DEFAULTS =
Fixed defaults for card layout and dimensions
{ layers: { border: { x: 0, y: 0, width: 630, height: 880 }, frame: { x: 10, y: 10, width: 610, height: 860 }, name_area: { x: 30, y: 40, width: 570, height: 50 }, art_layer: { x: 40, y: 95, width: 550, height: 400, corner_radius: { x: 5, y: 5 } }, type_area: { x: 30, y: 500, width: 570, height: 40 }, text_box: { x: 40, y: 545, width: 550, height: 265 }, power_area: { x: 455, y: 790, width: 140, height: 40 } }, mask_id: 'artWindowMask', frame_stroke_width: 2 }.freeze
Instance Attribute Summary collapse
-
#art ⇒ String?
readonly
The URL or path for the card artwork.
-
#border_color ⇒ String?
readonly
The border color.
-
#color_scheme ⇒ ColorScheme
readonly
The color scheme for the card.
-
#flavor_text ⇒ String?
readonly
The flavor text (italic text at bottom).
-
#mana_cost ⇒ String?
readonly
The mana cost in MTG notation (e.g., “R”, “1U”).
-
#name ⇒ String?
readonly
The card name.
-
#power ⇒ String?
readonly
The power value for creatures.
-
#rules_text ⇒ String?
readonly
The card description/rules text.
-
#toughness ⇒ String?
readonly
The toughness value for creatures.
-
#type_line ⇒ String?
readonly
The card type (e.g., “Instant”, “Creature”).
Instance Method Summary collapse
- #art_window_config ⇒ Object
- #card_height ⇒ Object
-
#card_width ⇒ Object
Delegate dimension methods to DEFAULTS for LayerFactory compatibility.
- #dimensions_for_layer(layer_name) ⇒ Object
- #frame_stroke_width ⇒ Object
-
#initialize(config) ⇒ BaseCard
constructor
Initialize a new card with the given configuration.
-
#save(filename) ⇒ void
Save the card to an SVG file.
- #use_color_scheme(color) ⇒ Object
Constructor Details
#initialize(config) ⇒ BaseCard
Initialize a new card with the given configuration
124 125 126 127 128 |
# File 'lib/mtg_card_maker/base_card.rb', line 124 def initialize(config) assign_attributes(config) @template = Template.new add_layers end |
Instance Attribute Details
#art ⇒ String? (readonly)
Returns the URL or path for the card artwork.
109 110 111 |
# File 'lib/mtg_card_maker/base_card.rb', line 109 def art @art end |
#border_color ⇒ String? (readonly)
Returns the border color.
103 104 105 |
# File 'lib/mtg_card_maker/base_card.rb', line 103 def border_color @border_color end |
#color_scheme ⇒ ColorScheme (readonly)
Returns the color scheme for the card.
106 107 108 |
# File 'lib/mtg_card_maker/base_card.rb', line 106 def color_scheme @color_scheme end |
#flavor_text ⇒ String? (readonly)
Returns the flavor text (italic text at bottom).
94 95 96 |
# File 'lib/mtg_card_maker/base_card.rb', line 94 def flavor_text @flavor_text end |
#mana_cost ⇒ String? (readonly)
Returns the mana cost in MTG notation (e.g., “R”, “1U”).
85 86 87 |
# File 'lib/mtg_card_maker/base_card.rb', line 85 def mana_cost @mana_cost end |
#name ⇒ String? (readonly)
Returns the card name.
82 83 84 |
# File 'lib/mtg_card_maker/base_card.rb', line 82 def name @name end |
#power ⇒ String? (readonly)
Returns the power value for creatures.
97 98 99 |
# File 'lib/mtg_card_maker/base_card.rb', line 97 def power @power end |
#rules_text ⇒ String? (readonly)
Returns the card description/rules text.
91 92 93 |
# File 'lib/mtg_card_maker/base_card.rb', line 91 def rules_text @rules_text end |
#toughness ⇒ String? (readonly)
Returns the toughness value for creatures.
100 101 102 |
# File 'lib/mtg_card_maker/base_card.rb', line 100 def toughness @toughness end |
#type_line ⇒ String? (readonly)
Returns the card type (e.g., “Instant”, “Creature”).
88 89 90 |
# File 'lib/mtg_card_maker/base_card.rb', line 88 def type_line @type_line end |
Instance Method Details
#art_window_config ⇒ Object
164 165 166 |
# File 'lib/mtg_card_maker/base_card.rb', line 164 def art_window_config DEFAULTS[:layers][:art_layer] end |
#card_height ⇒ Object
154 155 156 |
# File 'lib/mtg_card_maker/base_card.rb', line 154 def card_height CARD_HEIGHT end |
#card_width ⇒ Object
Delegate dimension methods to DEFAULTS for LayerFactory compatibility
149 150 151 |
# File 'lib/mtg_card_maker/base_card.rb', line 149 def card_width CARD_WIDTH end |
#dimensions_for_layer(layer_name) ⇒ Object
159 160 161 |
# File 'lib/mtg_card_maker/base_card.rb', line 159 def dimensions_for_layer(layer_name) DEFAULTS[:layers][layer_name.to_sym] || {} end |
#frame_stroke_width ⇒ Object
169 170 171 |
# File 'lib/mtg_card_maker/base_card.rb', line 169 def frame_stroke_width DEFAULTS[:frame_stroke_width] end |
#save(filename) ⇒ void
This method returns an undefined value.
Save the card to an SVG file
134 135 136 |
# File 'lib/mtg_card_maker/base_card.rb', line 134 def save(filename) @template.save(filename) end |
#use_color_scheme(color) ⇒ Object
139 140 141 142 143 144 145 |
# File 'lib/mtg_card_maker/base_card.rb', line 139 def use_color_scheme(color) if color ColorScheme.new(color) else DEFAULT_COLOR_SCHEME end end |