about summary refs log tree commit diff stats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/assets/stylesheets/pokeviewer/pokemon.css.scss50
-rw-r--r--app/controllers/pokeviewer/pokemon_controller.rb2
-rw-r--r--app/jobs/pokeviewer/extract_save_data_job.rb7
-rw-r--r--app/models/pokeviewer/location.rb5
-rw-r--r--app/models/pokeviewer/pokemon.rb36
-rw-r--r--app/views/pokeviewer/pokemon/show.html.haml49
6 files changed, 121 insertions, 28 deletions
diff --git a/app/assets/stylesheets/pokeviewer/pokemon.css.scss b/app/assets/stylesheets/pokeviewer/pokemon.css.scss index 332cb18..83fac45 100644 --- a/app/assets/stylesheets/pokeviewer/pokemon.css.scss +++ b/app/assets/stylesheets/pokeviewer/pokemon.css.scss
@@ -141,6 +141,9 @@
141 font-family: 'Power Green'; 141 font-family: 'Power Green';
142 display: flex; 142 display: flex;
143 margin: 1em; 143 margin: 1em;
144 border: 1px solid #777;
145 border-radius: 5px;
146 background-color: #fafafa;
144 147
145 .male { 148 .male {
146 color: blue; 149 color: blue;
@@ -155,16 +158,49 @@
155 white-space: pre; 158 white-space: pre;
156 } 159 }
157 160
158 .pokemon-ivs { 161 .pd-details {
159 margin: 0 1em; 162 color: white;
163 font-size: bold;
164 padding: .25em .5em;
165 }
166
167 .pd-contents {
168 p {
169 margin: .25em;
170 }
171 }
172
173 .pokemon-basics {
174 margin: .5em;
175 }
176
177 .pokemon-memo {
178 border-left: 1px solid #aaa;
179 background-color: #e7e8ff;
180
181 .pd-details {
182 background-color: #2068e0;
183 }
184 }
160 185
161 th { 186 .pokemon-stats {
162 text-align: center; 187 border-left: 1px solid #aaa;
163 padding-right: .5em; 188
189 .pd-details {
190 background-color: #d078f8;
164 } 191 }
165 192
166 td { 193 table {
167 text-align: right; 194 margin: 0 1em;
195
196 th {
197 text-align: center;
198 padding-right: .5em;
199 }
200
201 td {
202 text-align: right;
203 }
168 } 204 }
169 } 205 }
170} 206}
diff --git a/app/controllers/pokeviewer/pokemon_controller.rb b/app/controllers/pokeviewer/pokemon_controller.rb index ef421ac..44ee791 100644 --- a/app/controllers/pokeviewer/pokemon_controller.rb +++ b/app/controllers/pokeviewer/pokemon_controller.rb
@@ -7,7 +7,7 @@ module Pokeviewer
7 end 7 end
8 8
9 def show 9 def show
10 @pokemon = Pokemon.find_by_uuid params[:id] 10 @pokemon = Pokemon.find_by_uuid! params[:id]
11 end 11 end
12 end 12 end
13end 13end
diff --git a/app/jobs/pokeviewer/extract_save_data_job.rb b/app/jobs/pokeviewer/extract_save_data_job.rb index 3409a5f..be8f64d 100644 --- a/app/jobs/pokeviewer/extract_save_data_job.rb +++ b/app/jobs/pokeviewer/extract_save_data_job.rb
@@ -39,9 +39,16 @@ module Pokeviewer
39 39
40 if param["metLevel"] == 0 40 if param["metLevel"] == 0
41 r.met_type = :hatched 41 r.met_type = :hatched
42 r.met_location = param["metLocation"]
43 elsif param["metLocation"] == 254
44 r.met_type = :npc_trade
45 elsif param["metLocation"] == 255
46 r.met_type = :fateful_encounter
47 r.met_level = param["metLevel"]
42 else 48 else
43 r.met_type = :normal 49 r.met_type = :normal
44 r.met_level = param["metLevel"] 50 r.met_level = param["metLevel"]
51 r.met_location = param["metLocation"]
45 end 52 end
46 53
47 r.shiny = param["shiny"] 54 r.shiny = param["shiny"]
diff --git a/app/models/pokeviewer/location.rb b/app/models/pokeviewer/location.rb new file mode 100644 index 0000000..e497cbc --- /dev/null +++ b/app/models/pokeviewer/location.rb
@@ -0,0 +1,5 @@
1module Pokeviewer
2 class Location < ApplicationRecord
3 validates :name, presence: true
4 end
5end
diff --git a/app/models/pokeviewer/pokemon.rb b/app/models/pokeviewer/pokemon.rb index d14ea87..e493c66 100644 --- a/app/models/pokeviewer/pokemon.rb +++ b/app/models/pokeviewer/pokemon.rb
@@ -101,6 +101,42 @@ module Pokeviewer
101 end 101 end
102 end 102 end
103 103
104 def outsider?
105 (ot_name != trainer.name) or (ot_number != trainer.number)
106 end
107
108 def location
109 if (met_type == :normal) or (met_type == :hatched)
110 Location.find_by_id(met_location)
111 else
112 nil
113 end
114 end
115
116 def display_ot_number
117 ot_number.to_s.rjust(5, '0')
118 end
119
120 def display_met
121 if met_type == :normal
122 if outsider?
123 "Apparently met in #{location.name} at Lv. #{met_level}."
124 else
125 "Met in #{location.name} at Lv. #{met_level}."
126 end
127 elsif met_type == :hatched
128 if outsider?
129 "Apparently hatched in #{location.name} at Lv. 5."
130 else
131 "Hatched in #{location.name} at Lv. 5."
132 end
133 elsif met_type == :npc_trade
134 "Met in a trade."
135 elsif met_type == :fateful_encounter
136 "Obtained in a fateful encounter at Lv. #{met_level}."
137 end
138 end
139
104 private 140 private
105 141
106 def set_uuid 142 def set_uuid
diff --git a/app/views/pokeviewer/pokemon/show.html.haml b/app/views/pokeviewer/pokemon/show.html.haml index a38d641..18a6788 100644 --- a/app/views/pokeviewer/pokemon/show.html.haml +++ b/app/views/pokeviewer/pokemon/show.html.haml
@@ -7,24 +7,33 @@
7 .pokemon-ot 7 .pokemon-ot
8 OT/ 8 OT/
9 %span{ class: @pokemon.ot_gender }>= @pokemon.ot_name 9 %span{ class: @pokemon.ot_gender }>= @pokemon.ot_name
10 .pokemon-id= "ID/#{@pokemon.ot_number}" 10 .pokemon-id= "ID/#{@pokemon.display_ot_number}"
11 .pokemon-level= "Lv. #{@pokemon.revisions.last.level}" 11 .pokemon-level= "Lv. #{@pokemon.revisions.last.level}"
12 %table.pokemon-ivs 12 .pokemon-memo
13 %tr 13 .pd-details Trainer Memo
14 %th HP 14 .pd-contents
15 %td= @pokemon.revisions.last.hp 15 %p
16 %tr 16 %span.pokemon-nature<= @pokemon.nature.titlecase
17 %th Attack 17 nature.
18 %td= @pokemon.revisions.last.attack 18 %p= @pokemon.display_met
19 %tr 19 .pokemon-stats
20 %th Defense 20 .pd-details Stats
21 %td= @pokemon.revisions.last.defense 21 %table.pd-contents
22 %tr 22 %tr
23 %th Sp. Atk 23 %th HP
24 %td= @pokemon.revisions.last.special_attack 24 %td= @pokemon.revisions.last.hp
25 %tr 25 %tr
26 %th Sp. Def 26 %th Attack
27 %td= @pokemon.revisions.last.special_defense 27 %td= @pokemon.revisions.last.attack
28 %tr 28 %tr
29 %th Speed 29 %th Defense
30 %td= @pokemon.revisions.last.speed 30 %td= @pokemon.revisions.last.defense
31 %tr
32 %th Sp. Atk
33 %td= @pokemon.revisions.last.special_attack
34 %tr
35 %th Sp. Def
36 %td= @pokemon.revisions.last.special_defense
37 %tr
38 %th Speed
39 %td= @pokemon.revisions.last.speed