diff options
author | Star Rauchenberger <fefferburbia@gmail.com> | 2024-12-07 11:49:49 -0500 |
---|---|---|
committer | Star Rauchenberger <fefferburbia@gmail.com> | 2024-12-07 11:49:49 -0500 |
commit | 56f5841d4b9c12296cdfcaeff174b2627d59afc8 (patch) | |
tree | 4f7da4ebbe5ee15a1594b26466ed78e2cf10de35 /app/models/item.rb | |
parent | c1b0443ba2aebdbd39291ddab0c189f3f4831320 (diff) | |
download | pokeviewer-56f5841d4b9c12296cdfcaeff174b2627d59afc8.tar.gz pokeviewer-56f5841d4b9c12296cdfcaeff174b2627d59afc8.tar.bz2 pokeviewer-56f5841d4b9c12296cdfcaeff174b2627d59afc8.zip |
Migrate to full rails app
Diffstat (limited to 'app/models/item.rb')
-rw-r--r-- | app/models/item.rb | 41 |
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 @@ | |||
1 | class 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 | ||
41 | end | ||