about summary refs log tree commit diff stats
path: root/app/models
diff options
context:
space:
mode:
authorKelly Rauchenberger <fefferburbia@gmail.com>2017-09-24 11:23:27 -0400
committerKelly Rauchenberger <fefferburbia@gmail.com>2017-09-24 11:23:27 -0400
commit2405727d7d62fce31102520167cde42ee688c198 (patch)
treefbbf85f42ca6f0c17573974ca9c265a0d5aaf060 /app/models
parent0df34b64734e686f399ad7081c9b4e4921f75d64 (diff)
downloadpokeviewer-2405727d7d62fce31102520167cde42ee688c198.tar.gz
pokeviewer-2405727d7d62fce31102520167cde42ee688c198.tar.bz2
pokeviewer-2405727d7d62fce31102520167cde42ee688c198.zip
Started working on UI
This commit imports a lot of assets from veekun, as well as a font from
http://www.victoryroad.net/showthread.php?t=1507
Diffstat (limited to 'app/models')
-rw-r--r--app/models/pokeviewer/pokemon.rb46
-rw-r--r--app/models/pokeviewer/revision.rb2
-rw-r--r--app/models/pokeviewer/trainer.rb3
3 files changed, 47 insertions, 4 deletions
diff --git a/app/models/pokeviewer/pokemon.rb b/app/models/pokeviewer/pokemon.rb index 3b750ac..1410d37 100644 --- a/app/models/pokeviewer/pokemon.rb +++ b/app/models/pokeviewer/pokemon.rb
@@ -15,7 +15,8 @@ module Pokeviewer
15 numericality: { greater_than_or_equal_to: 0, only_integer: true } 15 numericality: { greater_than_or_equal_to: 0, only_integer: true }
16 16
17 validates :met_level, presence: true, 17 validates :met_level, presence: true,
18 numericality: { greater_than_or_equal_to: 1, only_integer: true } 18 numericality: { greater_than_or_equal_to: 1, only_integer: true },
19 if: Proc.new { |a| a.met_type == :normal }
19 20
20 validates :met_type, presence: true 21 validates :met_type, presence: true
21 enumerize :met_type, in: [:normal, :hatched, :npc_trade, :fateful_encounter] 22 enumerize :met_type, in: [:normal, :hatched, :npc_trade, :fateful_encounter]
@@ -31,12 +32,53 @@ module Pokeviewer
31 32
32 enumerize :unown_letter, in: [:a, :b, :c, :d, :e, :f, :g, :h, :i, :j, :k, 33 enumerize :unown_letter, in: [:a, :b, :c, :d, :e, :f, :g, :h, :i, :j, :k,
33 :l, :m, :n, :o, :p, :q, :r, :s, :t, :u, :v, :w, :x, :y, :z, 34 :l, :m, :n, :o, :p, :q, :r, :s, :t, :u, :v, :w, :x, :y, :z,
34 :question_mark, :exclamation_mark] 35 :question, :exclamation]
35 36
36 def to_param 37 def to_param
37 uuid 38 uuid
38 end 39 end
39 40
41 def icon_path
42 "pokeviewer/icons/#{species_id}.png"
43 end
44
45 def sprite_path
46 shininess = "normal"
47 if shiny
48 shininess = "shiny"
49 end
50
51 game = "ruby-sapphire"
52 unless trainer.nil?
53 if (trainer.firered? or trainer.leafgreen?) and (species_id <= 156 or species_id == 216 or species_id == 386)
54 game = "firered-leafgreen"
55 elsif trainer.emerald?
56 game = "emerald"
57 end
58 end
59
60 form = ""
61 if species_id == 201
62 # Handle Unown forms
63 form = "-#{unown_letter}"
64 elsif species_id == 386
65 # Handle Deoxys forms
66 if trainer.firered?
67 form = "-attack"
68 elsif trainer.leafgreen?
69 form = "-defense"
70 elsif trainer.emerald?
71 form = "-speed"
72 end
73 end
74
75 if game == "emerald"
76 "pokeviewer/sprites/emerald/#{shininess}/#{species_id}#{form}.gif"
77 else
78 "pokeviewer/sprites/#{game}/#{shininess}/#{species_id}#{form}.png"
79 end
80 end
81
40 private 82 private
41 83
42 def set_uuid 84 def set_uuid
diff --git a/app/models/pokeviewer/revision.rb b/app/models/pokeviewer/revision.rb index 4cafd07..44388ca 100644 --- a/app/models/pokeviewer/revision.rb +++ b/app/models/pokeviewer/revision.rb
@@ -4,7 +4,7 @@ module Pokeviewer
4 class Revision < ApplicationRecord 4 class Revision < ApplicationRecord
5 include ActiveRecord::Diff 5 include ActiveRecord::Diff
6 6
7 diff :nickname, :experience, :level, :hp, :attack, :defense, 7 diff :nickname, :level, :hp, :attack, :defense,
8 :special_attack, :special_defense, :speed, :coolness, :beauty, :cuteness, 8 :special_attack, :special_defense, :speed, :coolness, :beauty, :cuteness,
9 :smartness, :toughness, :sheen, :hold_item, :move_1_id, :move_2_id, 9 :smartness, :toughness, :sheen, :hold_item, :move_1_id, :move_2_id,
10 :move_3_id, :move_4_id, :move_1_pp_bonuses, :move_2_pp_bonuses, 10 :move_3_id, :move_4_id, :move_1_pp_bonuses, :move_2_pp_bonuses,
diff --git a/app/models/pokeviewer/trainer.rb b/app/models/pokeviewer/trainer.rb index 1cef881..edfbd25 100644 --- a/app/models/pokeviewer/trainer.rb +++ b/app/models/pokeviewer/trainer.rb
@@ -12,6 +12,7 @@ module Pokeviewer
12 message: "and number should be pairwise unique" } 12 message: "and number should be pairwise unique" }
13 13
14 validates :game, presence: true 14 validates :game, presence: true
15 enumerize :game, in: [:ruby, :sapphire, :firered, :leafgreen, :emerald] 15 enumerize :game, in: [:ruby, :sapphire, :firered, :leafgreen, :emerald],
16 predicates: true
16 end 17 end
17end 18end