From a65972d34188d14dca10193950732d506d931e8c Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 25 Sep 2017 00:05:38 -0400 Subject: Added met location data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note that the met location for Pokémon from Orre is completely incorrect. --- app/models/pokeviewer/location.rb | 5 +++++ app/models/pokeviewer/pokemon.rb | 36 ++++++++++++++++++++++++++++++++++++ 2 files changed, 41 insertions(+) create mode 100644 app/models/pokeviewer/location.rb (limited to 'app/models') 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 @@ +module Pokeviewer + class Location < ApplicationRecord + validates :name, presence: true + end +end 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 end end + def outsider? + (ot_name != trainer.name) or (ot_number != trainer.number) + end + + def location + if (met_type == :normal) or (met_type == :hatched) + Location.find_by_id(met_location) + else + nil + end + end + + def display_ot_number + ot_number.to_s.rjust(5, '0') + end + + def display_met + if met_type == :normal + if outsider? + "Apparently met in #{location.name} at Lv. #{met_level}." + else + "Met in #{location.name} at Lv. #{met_level}." + end + elsif met_type == :hatched + if outsider? + "Apparently hatched in #{location.name} at Lv. 5." + else + "Hatched in #{location.name} at Lv. 5." + end + elsif met_type == :npc_trade + "Met in a trade." + elsif met_type == :fateful_encounter + "Obtained in a fateful encounter at Lv. #{met_level}." + end + end + private def set_uuid -- cgit 1.4.1