| Total Complexity | 6 |
| Total Lines | 35 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 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 |