Class: Punk::Image

Inherits:
Pixelart::Image
  • Object
show all
Defined in:
lib/punks/punks.rb

Constant Summary collapse

NAMES =
['punk', 'punks']
DEFAULT_ATTRIBUTES =
['Male 2']

Class Method Summary collapse

Class Method Details

.generate(*values, style: nil, patch: nil) ⇒ Object



49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
# File 'lib/punks/punks.rb', line 49

def self.generate( *values, style: nil, patch: nil )

if values[0].is_a?( String )
  #####  add style option / hack - why? why not?
  if style
    values =  if style.downcase.index( 'natural') && style.downcase.index( '2')
                ["#{values[0]} (N2)"] + values[1..-1]
              elsif style.downcase[0] == 'n'  ## starting with n - always assume natural(s)
               ## auto-add (N) for Natural to archetype
                ["#{values[0]} (N)"] + values[1..-1]
              else
                puts "!! ERROR - unknown punk style #{style}; sorry"
                exit 1
              end
  end

###### hack for black&white
##   auto-add b&w (black&white) to all attribute names e.g.
##      Eyes   =>  Eyes B&W
##      Smile  =>  Smile B&W
##      ....
 archetype_key =  Sheet.normalize_key( values[0] )
  if archetype_key.end_with?( 'bw' ) ||  ## e.g. B&W
     archetype_key.end_with?( '1bit')    ## e.g. 1-Bit or 1Bit

     values = [values[0]] + values[1..-1].map do |attribute|
        if attribute.is_a?( Pixelart::Image )
           attribute
        else
           attribute_key = Sheet.normalize_key( attribute )
           if ['wildhair'].include?( attribute_key )   ## pass through known b&w attributes by "default"
              attribute
           elsif attribute_key.index( "black" )
              attribute ## pass through as-is
           else
             "#{attribute} B&W"
           end
        end
    end

    pp values
 end

    # note: female mouth by default has "custom" colors (not black)
    #          for every 1/2/3/4 (human) skin tone and for zombie
    #   auto-"magically" add mapping
    #
    #  todo/check/fix - add more "contraints"
    #    for mapping to only kick-in for "basic" versions
    #      and not "colored" e.g. golden and such - why? why not?
    #
    #    move this mapping here to "post-lookup" processing
    #   to get/incl. more "meta" attribute info  - why? why not?
    if archetype_key.index( 'female1' ) ||
  archetype_key.index( 'female2' ) ||
  archetype_key.index( 'female3' ) ||
  archetype_key.index( 'female4' ) ||
  archetype_key.index( 'zombiefemale' )

 values = [values[0]] + values[1..-1].map do |attribute|
   if attribute.is_a?( Pixelart::Image )
     attribute
   else
     attribute_key = Sheet.normalize_key( attribute )

     if attribute_key == 'smile' || attribute_key == 'frown'
        attribute +=   if    archetype_key.index( 'zombiefemale' ) then ' Zombie'
                       elsif archetype_key.index( 'female1' )      then ' 1'
                       elsif archetype_key.index( 'female2' )      then ' 2'
                       elsif archetype_key.index( 'female3' )      then ' 3'
                       elsif archetype_key.index( 'female4' )      then ' 4'
                       else
                         puts "!! ERROR - smile or frown (mouth expression) not supported for archetype:"
                         pp values
                         exit 1
                       end
      end
      attribute
   end
 end
    end
   end

  generator.generate( *values, style: style, patch: patch )
end

.generatorObject



39
40
41
# File 'lib/punks/punks.rb', line 39

def self.generator
  @generator ||= GeneratorEx.use( Sheet.builtin, image_class: Image )
end