| Total Complexity | 6 |
| Total Lines | 33 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | # frozen_string_literal: true |
||
| 4 | class Magia < Hash |
||
| 5 | attr_accessor :id, :name, :efecto, :potencia, :tipo, :subtipo, |
||
| 6 | :diablura, :duracion, :alcance, :maestría, :ardid, |
||
| 7 | :summun, :chakra # Only in plegarias |
||
| 8 | |||
| 9 | def initialize(args) |
||
| 10 | args.each do |k, v| |
||
| 11 | instance_variable_set("@#{k}".to_sym, v) unless v.nil? |
||
| 12 | end |
||
| 13 | end |
||
| 14 | |||
| 15 | def nivel |
||
| 16 | ((id / 6) + 1).to_i |
||
| 17 | end |
||
| 18 | |||
| 19 | def img_path |
||
| 20 | "/images/magia/#{elemento}s#{nivel}/#{name}.png" |
||
| 21 | end |
||
| 22 | |||
| 23 | def color |
||
| 24 | colors = %w[FF6633 CCFFFF CC9966 44CCFF CC9999 EED6AF |
||
| 25 | 99FFCC CC4545 FAEE96 E0FFFF 688426] |
||
| 26 | elems = %w[fuego aire tierra agua sombra arena |
||
| 27 | elfico sangre plegaria hielo execración] |
||
| 28 | # Returns color code by position in colors array |
||
| 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 |