| Total Complexity | 4 |
| Total Lines | 38 |
| Duplicated Lines | 0 % |
| Changes | 0 | ||
| 1 | # frozen_string_literal: true |
||
| 6 | class Material < Util |
||
| 7 | def name |
||
| 8 | material(id)['name'] |
||
| 9 | end |
||
| 10 | |||
| 11 | def description |
||
| 12 | material(id)['description'] |
||
| 13 | end |
||
| 14 | |||
| 15 | # returns from heros.materiales, the list of (maybe repeated) |
||
| 16 | # ids of the heros with self.id material available |
||
| 17 | def disponibles |
||
| 18 | total = [] |
||
| 19 | heros.each do |h| |
||
| 20 | next unless h.materiales |
||
| 21 | |||
| 22 | h.materiales.each do |matt| |
||
| 23 | total << h.id if matt == id |
||
| 24 | end |
||
| 25 | end |
||
| 26 | total |
||
| 27 | end |
||
| 28 | |||
| 29 | def usado_en |
||
| 30 | usado = [] |
||
| 31 | profesions.each do |prof| |
||
| 32 | %w[aprendiz artesano maestro].each do |grado| |
||
| 33 | prof.send(grado).each do |receta| |
||
| 34 | next unless receta['matts'] |
||
| 35 | next unless receta['matts'].include?(id) |
||
| 36 | |||
| 37 | usado << { prof: id, grado: grado, receta: receta } |
||
| 38 | end |
||
| 39 | end |
||
| 40 | end |
||
| 41 | usado |
||
| 42 | end |
||
| 43 | end |
||
| 44 |