blob: d6fe104026afd7e4162a69bebe610ba37c584a03 (
plain) (
blame)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
|
module PokedexHelper
def pokedex_table(all_species, trainers)
final_result = "".html_safe
all_species.each do |species|
noted_trainers = species.pokedex_entries.to_a
if noted_trainers.empty?
poke_name = "???"
poke_image = image_tag "icons/0.png"
else
poke_name = species.name
poke_image = image_tag "icons/#{species.id}.png"
end
result = "".html_safe
result << tag.th("\##{species.id}")
result << tag.th(poke_name)
result << tag.th(poke_image)
trainers.each do |trainer|
if !noted_trainers.empty? and noted_trainers.first.trainer_id == trainer.id
nt = noted_trainers.shift
if nt.caught
result << tag.td(trainer.display_number,
class: ["pkvd-caught", trainer.game])
else
result << tag.td(trainer.display_number,
class: ["pkvd-seen", trainer.game])
end
else
result << tag.td(trainer.display_number, class: "pkvd-unseen")
end
end
result << tag.td(
species.current_revisions.map {
|p| link_to p.nickname, p.pokemon }.join(", ").html_safe)
final_result << tag.tr(result)
end
tag.table(final_result, class: "pkvd-table")
end
end
|