about summary refs log tree commit diff stats
path: root/app/models/item.rb
diff options
context:
space:
mode:
Diffstat (limited to 'app/models/item.rb')
-rw-r--r--app/models/item.rb41
1 files changed, 41 insertions, 0 deletions
diff --git a/app/models/item.rb b/app/models/item.rb new file mode 100644 index 0000000..269cf97 --- /dev/null +++ b/app/models/item.rb
@@ -0,0 +1,41 @@
1class Item < ApplicationRecord
2 validates :name, presence: true
3
4 belongs_to :move, optional: true
5 validates :move, presence: true, if: :tm?
6
7 validates :rs_description, presence: true, unless: :tm?
8 validates :frlg_description, presence: true, unless: :tm?
9
10 def description(game)
11 if game == :emerald
12 if not emerald_description.nil?
13 emerald_description
14 elsif not rs_description.nil?
15 rs_description
16 else
17 move.description game
18 end
19 elsif game == :firered or game == :leafgreen
20 if not frlg_description.nil?
21 frlg_description
22 else
23 move.description game
24 end
25 else
26 if not rs_description.nil?
27 rs_description
28 else
29 move.description game
30 end
31 end
32 end
33
34 def icon_path
35 if tm?
36 "items/tms/#{move.move_type}.png"
37 else
38 "items/#{id}.png"
39 end
40 end
41end