about summary refs log tree commit diff stats
path: root/app/helpers/pokeviewer/pokemon_helper.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/helpers/pokeviewer/pokemon_helper.rb')
-rw-r--r--app/helpers/pokeviewer/pokemon_helper.rb208
1 files changed, 0 insertions, 208 deletions
diff --git a/app/helpers/pokeviewer/pokemon_helper.rb b/app/helpers/pokeviewer/pokemon_helper.rb deleted file mode 100644 index 4c2f9de..0000000 --- a/app/helpers/pokeviewer/pokemon_helper.rb +++ /dev/null
@@ -1,208 +0,0 @@
1require 'victor'
2
3module Pokeviewer
4 module PokemonHelper
5
6 def condition_diagram(revision)
7 svg = Victor::SVG.new width: 420, height: 430
8
9 center_x = 200
10 center_y = 200
11 radius = 160
12
13 angle = -Math::PI / 2.0
14 incr = (2 * Math::PI) / 5
15
16 data = [
17 [:cool, revision.coolness],
18 [:beauty, revision.beauty],
19 [:cute, revision.cuteness],
20 [:smart, revision.smartness],
21 [:tough, revision.toughness]
22 ]
23
24 outline = data.map do |c|
25 x_offset = radius * Math.cos(angle)
26 y_offset = radius * Math.sin(angle)
27
28 svg.circle(
29 cx: (center_x + x_offset),
30 cy: (center_y + y_offset),
31 r: 53,
32 class: "pkcv-#{c[0]}-circle")
33
34 if c[0] == :cool
35 text_y = center_y + (radius + 20) * Math.sin(angle)
36 else
37 text_y = center_y + (radius + 60) * Math.sin(angle)
38 end
39
40 svg.text(c[0].upcase,
41 x: (center_x + (radius + 60) * Math.cos(angle)),
42 y: text_y,
43 class: "pkcv-label-outline")
44
45 svg.text(c[0].upcase,
46 x: (center_x + (radius + 60) * Math.cos(angle)),
47 y: text_y,
48 class: "pkcv-label")
49
50 angle += incr
51
52 [center_x + x_offset, center_y + y_offset]
53 end
54
55 svg.polygon(
56 points: outline.map { |point| point * "," } * " ",
57 class: "pkcv-outline")
58
59 points = data.map do |c|
60 svg.line(
61 x1: center_x,
62 y1: center_y,
63 x2: center_x + radius * Math.cos(angle),
64 y2: center_y + radius * Math.sin(angle),
65 class: "pkcv-line")
66
67 datapoint = c[1]
68 datapoint = 0.01 if datapoint < 1
69 datapoint /= 10.0
70 datapoint **= (1.0/3.0)
71
72 x_offset = (radius - 3) * Math.cos(angle) * datapoint
73 y_offset = (radius - 3) * Math.sin(angle) * datapoint
74
75 angle += incr
76
77 [center_x + x_offset, center_y + y_offset]
78 end
79
80 svg.polygon(
81 points: points.map { |point| point * "," } * " ",
82 class: "pkcv-data")
83
84 svg.rect(
85 x: -40,
86 y: 460,
87 rx: 10,
88 ry: 10,
89 width: 490,
90 height: 60,
91 class: "pkcv-sheen-bg")
92
93 if revision.sheen > 0
94 svg.rect(
95 x: -37,
96 y: 460,
97 width: revision.sheen * 490 / 10 - 6,
98 height: 60,
99 class: "pkcv-sheen-data")
100 end
101
102 svg.rect(
103 x: -40,
104 y: 460,
105 rx: 10,
106 ry: 10,
107 width: 490,
108 height: 60,
109 class: "pkcv-sheen-border")
110
111 svg.text("SHEEN",
112 x: -20,
113 y: 500,
114 class: "pkcv-sheen-label")
115
116 tag.svg(svg.to_s.html_safe,
117 viewBox: "-80 -30 570 560",
118 width: "100%",
119 class: "pokemon-condition")
120 end
121
122 def image_for_type(type)
123 image_tag "pokeviewer/types/#{type}.gif", class: "pkv-type"
124 end
125
126 def move_details(revision, index)
127 move = revision.send "move_#{index}".intern
128
129 if move
130 move_name = move.name
131 move_type = image_for_type move.move_type
132 move_pp = revision.send "move_#{index}_pp".intern
133 move_pp = "#{move_pp}/#{move_pp}"
134 else
135 move_name = "-"
136 move_type = ""
137 move_pp = "--/--"
138 end
139
140 tag.tr(
141 tag.th(move_type) +
142 tag.td(move_name)) +
143 tag.tr(
144 tag.th("") +
145 tag.td(
146 tag.div(
147 tag.span(
148 "PP",
149 class: 'pp-label') +
150 tag.span(
151 move_pp,
152 class: 'pp-value') +
153 tag.div(
154 "",
155 class: 'clear'),
156 class: 'tb-only')))
157 end
158
159 def display_met(pokemon)
160 met_type = pokemon.met_type
161
162 if met_type == :normal or met_type == :hatched
163 result = "".html_safe
164
165 if met_type == :normal
166 if pokemon.outsider?
167 result << "Apparently met"
168 else
169 result << "Met"
170 end
171 else
172 if pokemon.outsider?
173 result << "Apparently hatched"
174 else
175 result << "Hatched"
176 end
177 end
178
179 result << " in "
180
181 pokemon.location.name.split(" ").each_with_index do |w, i|
182 result << "&nbsp;".html_safe if i > 0
183 result << w
184 end
185
186 result << " at Lv.&nbsp;".html_safe
187
188 if met_type == :hatched
189 result << "5"
190 else
191 result << pokemon.met_level.to_s
192 end
193
194 result << "."
195
196 result
197 elsif met_type == :npc_trade
198 "Met in a trade."
199 elsif met_type == :fateful_encounter
200 "Met in a fateful encounter at Lv.&nbsp;".html_safe +
201 pokemon.met_level.to_s
202 elsif met_type == :orre
203 "Met in a trade."
204 end
205 end
206
207 end
208end