| Total Complexity | 10 |
| Total Lines | 49 |
| Duplicated Lines | 0 % |
| Coverage | 27.59% |
| Changes | 0 | ||
| 1 | # Engarce = objetos engarzables: gemas, joyas y runas |
||
| 2 | 1 | class Engarce < Hash |
|
| 3 | 1 | attr_accessor :id, :name, :fits |
|
| 4 | |||
| 5 | 1 | def initialize(args) |
|
| 6 | args.each do |k, v| |
||
| 7 | instance_variable_set("@#{k}".to_sym, v) unless v.nil? |
||
| 8 | end |
||
| 9 | end |
||
| 10 | |||
| 11 | 1 | def item |
|
| 12 | self.class.to_s.downcase |
||
| 13 | end |
||
| 14 | |||
| 15 | 1 | def img_path |
|
| 16 | "'../../images/treasures/#{item}s/#{name}.png'" |
||
| 17 | end |
||
| 18 | |||
| 19 | 1 | def big_img |
|
| 20 | "'../../images/items/#{item}s/#{name}.png'" |
||
| 21 | end |
||
| 22 | |||
| 23 | 1 | def bonificador(item) |
|
| 24 | if item.fits == 'arma' |
||
| 25 | fits[item.categoria] || fits['arma'] || 'Armas sin implementar' |
||
| 26 | elsif item.fits == 'armadura' |
||
| 27 | fits[item.categoria] || fits['pecho'] || 'Armaduras sin implementar' |
||
| 28 | elsif fits[item.fits] |
||
| 29 | fits[item.fits] |
||
| 30 | elsif item.class == Proteccion |
||
| 31 | fits['armadura'] || 'Sin bonificador' |
||
| 32 | else |
||
| 33 | 'Sin efecto' |
||
| 34 | end |
||
| 35 | end |
||
| 36 | |||
| 37 | # returns from heros.tesoro, the list of (maybe repeated) |
||
| 38 | # ids of the heros with self.id gem/runa/joya available |
||
| 39 | 1 | def disponibles |
|
| 40 | total = [] |
||
| 41 | heros.each do |h| |
||
| 42 | next unless h.tesoro |
||
| 43 | next unless h.tesoro[item + 's'] |
||
| 44 | h.tesoro[item + 's'].each do |e| |
||
| 45 | (total << h.id) if e == id |
||
| 46 | end |
||
| 47 | end |
||
| 48 | total |
||
| 49 | end |
||
| 50 | end |
||
| 51 |