Magia   A
last analyzed

Complexity

Total Complexity 3

Size/Duplication

Total Lines 26
Duplicated Lines 0 %

Test Coverage

Coverage 45.45%

Importance

Changes 0
Metric Value
dl 0
loc 26
ccs 5
cts 11
cp 0.4545
rs 10
c 0
b 0
f 0
wmc 3

3 Methods

Rating   Name   Duplication   Size   Complexity  
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 1
class Magia < Hash
3 1
  attr_accessor :id, :name, :efecto, :potencia,
4
                :diablura, :duracion, :alcance, :tipo, :maestría, :ardid,
5
                :summun, :chakra # Only in plegarias
6
7 1
  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 1
  def img_path
14
    "'../../images/magia/#{elemento}s#{nivel}/#{name}.png'"
15
  end
16
17 1
  def color # Returns color code by position in colors array
18
    colors = %w(FF6633 CCFFFF CC9966 44CCFF CC9999
19
                EED6AF 99FFCC CC4545 FAEE96 E0FFFF
20
                688426)
21
    elems  = %w(fuego aire tierra agua sombra
22
                arena elfico sangre plegaria hielo
23
                execración)
24
25
    'background-color:#' + colors[elems.find_index(elemento)]
26
  end
27
end
28