about summary refs log tree commit diff stats
path: root/app
diff options
context:
space:
mode:
Diffstat (limited to 'app')
-rw-r--r--app/jobs/pokeviewer/extract_save_data_job.rb4
-rw-r--r--app/models/pokeviewer/location.rb2
-rw-r--r--app/models/pokeviewer/pokemon.rb12
3 files changed, 8 insertions, 10 deletions
diff --git a/app/jobs/pokeviewer/extract_save_data_job.rb b/app/jobs/pokeviewer/extract_save_data_job.rb index 546e6d2..99d71f1 100644 --- a/app/jobs/pokeviewer/extract_save_data_job.rb +++ b/app/jobs/pokeviewer/extract_save_data_job.rb
@@ -69,7 +69,7 @@ module Pokeviewer
69 69
70 if param["metLevel"] == 0 70 if param["metLevel"] == 0
71 r.met_type = :hatched 71 r.met_type = :hatched
72 r.met_location = param["metLocation"] 72 r.location_id = param["metLocation"]
73 elsif param["metLocation"] == 254 73 elsif param["metLocation"] == 254
74 r.met_type = :npc_trade 74 r.met_type = :npc_trade
75 elsif param["metLocation"] == 255 75 elsif param["metLocation"] == 255
@@ -78,7 +78,7 @@ module Pokeviewer
78 else 78 else
79 r.met_type = :normal 79 r.met_type = :normal
80 r.met_level = param["metLevel"] 80 r.met_level = param["metLevel"]
81 r.met_location = param["metLocation"] 81 r.location_id = param["metLocation"]
82 end 82 end
83 83
84 r.shiny = param["shiny"] 84 r.shiny = param["shiny"]
diff --git a/app/models/pokeviewer/location.rb b/app/models/pokeviewer/location.rb index e497cbc..db37df2 100644 --- a/app/models/pokeviewer/location.rb +++ b/app/models/pokeviewer/location.rb
@@ -1,5 +1,7 @@
1module Pokeviewer 1module Pokeviewer
2 class Location < ApplicationRecord 2 class Location < ApplicationRecord
3 has_many :pokemon, dependent: :nullify
4
3 validates :name, presence: true 5 validates :name, presence: true
4 end 6 end
5end 7end
diff --git a/app/models/pokeviewer/pokemon.rb b/app/models/pokeviewer/pokemon.rb index 6c33406..9f0b4af 100644 --- a/app/models/pokeviewer/pokemon.rb +++ b/app/models/pokeviewer/pokemon.rb
@@ -24,6 +24,10 @@ module Pokeviewer
24 validates :met_type, presence: true 24 validates :met_type, presence: true
25 enumerize :met_type, in: [:normal, :hatched, :npc_trade, :fateful_encounter] 25 enumerize :met_type, in: [:normal, :hatched, :npc_trade, :fateful_encounter]
26 26
27 belongs_to :location, optional: true
28 validates :location, presence: true,
29 if: Proc.new { |c| c.met_type == :normal or c.met_type == :hatched}
30
27 validates :gender, presence: true 31 validates :gender, presence: true
28 enumerize :gender, in: [:genderless, :female, :male] 32 enumerize :gender, in: [:genderless, :female, :male]
29 33
@@ -105,14 +109,6 @@ module Pokeviewer
105 (trainer.nil?) or (ot_name != trainer.name) or (ot_number != trainer.number) 109 (trainer.nil?) or (ot_name != trainer.name) or (ot_number != trainer.number)
106 end 110 end
107 111
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 112 def display_ot_number
117 ot_number.to_s.rjust(5, '0') 113 ot_number.to_s.rjust(5, '0')
118 end 114 end