about summary refs log tree commit diff stats
path: root/app
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-10-10 22:46:46 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-10-10 22:46:46 -0400
commit0f32f526b73ecfd10012c0db9d7c4a4f15251a73 (patch)
treed456a80075b3a0680fa34214c51f47355ca24d43 /app
parent09ed6a6c7567bbd01dc236570982bf7ea31e11e6 (diff)
downloadpokeviewer-0f32f526b73ecfd10012c0db9d7c4a4f15251a73.tar.gz
pokeviewer-0f32f526b73ecfd10012c0db9d7c4a4f15251a73.tar.bz2
pokeviewer-0f32f526b73ecfd10012c0db9d7c4a4f15251a73.zip
Added type and ability data to species model
Diffstat (limited to 'app')
-rw-r--r--app/models/pokeviewer/ability.rb7
-rw-r--r--app/models/pokeviewer/move.rb8
-rw-r--r--app/models/pokeviewer/pokemon.rb8
-rw-r--r--app/models/pokeviewer/species.rb10
4 files changed, 30 insertions, 3 deletions
diff --git a/app/models/pokeviewer/ability.rb b/app/models/pokeviewer/ability.rb new file mode 100644 index 0000000..594b18c --- /dev/null +++ b/app/models/pokeviewer/ability.rb
@@ -0,0 +1,7 @@
1module Pokeviewer
2 class Ability < ApplicationRecord
3 validates :name, presence: true, uniqueness: true
4
5 validates :description, presence: true
6 end
7end
diff --git a/app/models/pokeviewer/move.rb b/app/models/pokeviewer/move.rb index 3ef6a9c..c63493a 100644 --- a/app/models/pokeviewer/move.rb +++ b/app/models/pokeviewer/move.rb
@@ -10,10 +10,12 @@ module Pokeviewer
10 validates :pp, presence: true, 10 validates :pp, presence: true,
11 numericality: { greater_than_or_equal_to: 1, only_integer: true } 11 numericality: { greater_than_or_equal_to: 1, only_integer: true }
12 12
13 validates :move_type, presence: true 13 TYPES = [:normal, :fighting, :flying, :poison, :ground,
14 enumerize :move_type, in: [:normal, :fighting, :flying, :poison, :ground,
15 :rock, :bug, :ghost, :steel, :mystery, :fire, :water, :grass, :electric, 14 :rock, :bug, :ghost, :steel, :mystery, :fire, :water, :grass, :electric,
16 :psychic, :ice, :dragon, :dark], predicates: true 15 :psychic, :ice, :dragon, :dark]
16
17 validates :move_type, presence: true
18 enumerize :move_type, in: TYPES, predicates: true
17 19
18 validates :rs_description, presence: true 20 validates :rs_description, presence: true
19 validates :frlg_description, presence: true 21 validates :frlg_description, presence: true
diff --git a/app/models/pokeviewer/pokemon.rb b/app/models/pokeviewer/pokemon.rb index 268a417..1b690f5 100644 --- a/app/models/pokeviewer/pokemon.rb +++ b/app/models/pokeviewer/pokemon.rb
@@ -200,6 +200,14 @@ module Pokeviewer
200 "pokeviewer/items/#{Pokemon.pokeball.values.find_index(pokeball) + 1}.png" 200 "pokeviewer/items/#{Pokemon.pokeball.values.find_index(pokeball) + 1}.png"
201 end 201 end
202 202
203 def ability
204 if second_ability
205 species.ability_2
206 else
207 species.ability_1
208 end
209 end
210
203 private 211 private
204 212
205 def set_uuid 213 def set_uuid
diff --git a/app/models/pokeviewer/species.rb b/app/models/pokeviewer/species.rb index c69fd21..429e762 100644 --- a/app/models/pokeviewer/species.rb +++ b/app/models/pokeviewer/species.rb
@@ -1,7 +1,17 @@
1module Pokeviewer 1module Pokeviewer
2 class Species < ApplicationRecord 2 class Species < ApplicationRecord
3 extend Enumerize
4
3 has_many :pokemon, dependent: :restrict_with_exception 5 has_many :pokemon, dependent: :restrict_with_exception
4 6
5 validates :name, presence: true, uniqueness: true 7 validates :name, presence: true, uniqueness: true
8
9 validates :type_1, presence: true
10
11 enumerize :type_1, in: Move::TYPES
12 enumerize :type_2, in: Move::TYPES
13
14 belongs_to :ability_1, class_name: "Ability"
15 belongs_to :ability_2, class_name: "Ability", optional: true
6 end 16 end
7end 17end