about summary refs log tree commit diff stats
path: root/app/models
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-09-25 00:05:38 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-09-25 00:05:38 -0400
commita65972d34188d14dca10193950732d506d931e8c (patch)
tree2212ac8682f97f07751370a898ad651af8b64a5b /app/models
parentb0dee0af0a4235eb9756532e807db5c8b701ce45 (diff)
downloadpokeviewer-a65972d34188d14dca10193950732d506d931e8c.tar.gz
pokeviewer-a65972d34188d14dca10193950732d506d931e8c.tar.bz2
pokeviewer-a65972d34188d14dca10193950732d506d931e8c.zip
Added met location data
Note that the met location for Pokémon from Orre is completely
incorrect.
Diffstat (limited to 'app/models')
-rw-r--r--app/models/pokeviewer/location.rb5
-rw-r--r--app/models/pokeviewer/pokemon.rb36
2 files changed, 41 insertions, 0 deletions
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