about summary refs log tree commit diff stats
path: root/app/models/move.rb
diff options
context:
space:
mode:
authorStar Rauchenberger <fefferburbia@gmail.com>2024-12-07 11:49:49 -0500
committerStar Rauchenberger <fefferburbia@gmail.com>2024-12-07 11:49:49 -0500
commit56f5841d4b9c12296cdfcaeff174b2627d59afc8 (patch)
tree4f7da4ebbe5ee15a1594b26466ed78e2cf10de35 /app/models/move.rb
parentc1b0443ba2aebdbd39291ddab0c189f3f4831320 (diff)
downloadpokeviewer-56f5841d4b9c12296cdfcaeff174b2627d59afc8.tar.gz
pokeviewer-56f5841d4b9c12296cdfcaeff174b2627d59afc8.tar.bz2
pokeviewer-56f5841d4b9c12296cdfcaeff174b2627d59afc8.zip
Migrate to full rails app
Diffstat (limited to 'app/models/move.rb')
-rw-r--r--app/models/move.rb31
1 files changed, 31 insertions, 0 deletions
diff --git a/app/models/move.rb b/app/models/move.rb new file mode 100644 index 0000000..cbc8422 --- /dev/null +++ b/app/models/move.rb
@@ -0,0 +1,31 @@
1class Move < ApplicationRecord
2 extend Enumerize
3
4 has_many :revision_moves
5 has_many :revisions, through: :revision_moves
6
7 validates :name, presence: true, uniqueness: true
8
9 validates :pp, presence: true,
10 numericality: { greater_than_or_equal_to: 1, only_integer: true }
11
12 TYPES = [:normal, :fighting, :flying, :poison, :ground,
13 :rock, :bug, :ghost, :steel, :mystery, :fire, :water, :grass, :electric,
14 :psychic, :ice, :dragon, :dark]
15
16 validates :move_type, presence: true
17 enumerize :move_type, in: TYPES, predicates: true
18
19 validates :rs_description, presence: true
20 validates :frlg_description, presence: true
21
22 def description(game)
23 if game == :emerald and not emerald_description.nil?
24 emerald_description
25 elsif game == :firered or game == :leafgreen
26 frlg_description
27 else
28 rs_description
29 end
30 end
31end