Completed
Branch master (e351fa)
by Borja
10:43 queued 07:19
created

Magia   A

Complexity

Total Complexity 6

Size/Duplication

Total Lines 35
Duplicated Lines 0 %

Importance

Changes 0
Metric Value
dl 0
loc 35
rs 10
c 0
b 0
f 0
wmc 6

5 Methods

Rating   Name   Duplication   Size   Complexity  
A nivel() 0 3 1
A kind() 0 4 2
A initialize() 0 5 1
A img_path() 0 3 1
A color() 0 10 1
1
# Todos los hechizos disponibles en el juego
2
class Magia < Hash
3
  attr_accessor :id, :name, :efecto, :potencia, :tipo, :subtipo,
4
                :diablura, :duracion, :alcance, :maestría, :ardid,
5
                :summun, :chakra # Only in plegarias
6
7
  def initialize(args)
8
    args.each do |k, v|
9
      instance_variable_set("@#{k}".to_sym, v) unless v.nil?
10
    end
11
  end
12
  
13
  def nivel
14
    ((id / 6) + 1).to_i
15
  end
16
17
  def img_path
18
    "/images/magia/#{elemento}s#{nivel}/#{name}.png"
19
  end
20
21
  def color # Returns color code by position in colors array
22
    colors = %w(FF6633 CCFFFF CC9966 44CCFF CC9999
23
                EED6AF 99FFCC CC4545 FAEE96 E0FFFF
24
                688426)
25
    elems  = %w(fuego aire tierra agua sombra
26
                arena elfico sangre plegaria hielo
27
                execración)
28
29
    'background-color:#' + colors[elems.find_index(elemento)]
30
  end
31
  
32
  def kind
33
    elems = %w(fuego aire tierra agua)
34
    elems.include?(elemento) ? 'elemental' : 'sagrada'
35
  end
36
end
37