about summary refs log tree commit diff stats
path: root/app/models
diff options
context:
space:
mode:
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