1 | # encoding: UTF-8 |
||
2 | |||
3 | 1 | View Code Duplication | def heros |
0 ignored issues
–
show
Duplication
introduced
by
![]() |
|||
4 | 806 | total_heros = Dir['./data/heroes/*'].length |
|
5 | 806 | [*0..(total_heros - 1)].map do |i| |
|
6 | 92690 | h = load_yaml("/heroes/#{i}") |
|
7 | 92690 | h['nivel'] = 1 unless h['nivel'] |
|
8 | 92690 | h['ciudad'] = 'Jadessvärd' unless h['ciudad'] |
|
9 | 92690 | h['id'] = i |
|
10 | 92690 | Hero.new(h) |
|
11 | end |
||
12 | end |
||
13 | |||
14 | 1 | def hero(id) |
|
15 | 805 | heros[id] |
|
16 | end |
||
17 | |||
18 | 1 | def jugadores |
|
19 | (heros + renegados).map(&:jugador).uniq |
||
20 | end |
||
21 | |||
22 | 1 | def narrados(n) |
|
23 | narrados = heros.select { |p| p.historia if p.historia == n } |
||
24 | narrados.sort_by { |p| p.premio ? p.premio : 3 } |
||
25 | end |
||
26 | |||
27 | 1 | def nomalize_pj(pj) |
|
28 | normalization = { |
||
29 | '%C3%A1' => 'á', |
||
30 | '%C3%A9' => 'é', |
||
31 | '%C3%AD' => 'í', |
||
32 | '%C3%B3' => 'ó' |
||
33 | } |
||
34 | pj.gsub(/%C3%A1|%C3%A9|%C3%AD|%C3%B3/) { |match| normalization[match] } |
||
35 | end |
||
36 |