diff options
-rw-r--r-- | app/jobs/pokeviewer/extract_save_data_job.rb | 1 | ||||
-rw-r--r-- | app/models/pokeviewer/pokemon.rb | 9 | ||||
-rw-r--r-- | app/views/pokeviewer/pokemon/show.html.haml | 3 | ||||
-rw-r--r-- | db/migrate/20171004203404_add_pokeball_to_pokemon.rb | 9 | ||||
-rw-r--r-- | test/dummy/db/schema.rb | 3 |
5 files changed, 23 insertions, 2 deletions
diff --git a/app/jobs/pokeviewer/extract_save_data_job.rb b/app/jobs/pokeviewer/extract_save_data_job.rb index f94ce74..e9e0231 100644 --- a/app/jobs/pokeviewer/extract_save_data_job.rb +++ b/app/jobs/pokeviewer/extract_save_data_job.rb | |||
@@ -96,6 +96,7 @@ module Pokeviewer | |||
96 | r.nature = Pokemon.nature.values[param["nature"]] | 96 | r.nature = Pokemon.nature.values[param["nature"]] |
97 | r.gender = param["gender"] | 97 | r.gender = param["gender"] |
98 | r.second_ability = param["secondAbility"] | 98 | r.second_ability = param["secondAbility"] |
99 | r.pokeball = Pokemon.pokeball.values[param["pokeball"] - 1] | ||
99 | 100 | ||
100 | # Handle Unown form | 101 | # Handle Unown form |
101 | if r.species_id == 201 | 102 | if r.species_id == 201 |
diff --git a/app/models/pokeviewer/pokemon.rb b/app/models/pokeviewer/pokemon.rb index 18d1533..268a417 100644 --- a/app/models/pokeviewer/pokemon.rb +++ b/app/models/pokeviewer/pokemon.rb | |||
@@ -1,6 +1,7 @@ | |||
1 | module Pokeviewer | 1 | module Pokeviewer |
2 | class Pokemon < ApplicationRecord | 2 | class Pokemon < ApplicationRecord |
3 | extend Enumerize | 3 | extend Enumerize |
4 | extend ActiveModel::Naming | ||
4 | 5 | ||
5 | belongs_to :species | 6 | belongs_to :species |
6 | 7 | ||
@@ -69,6 +70,10 @@ module Pokeviewer | |||
69 | :l, :m, :n, :o, :p, :q, :r, :s, :t, :u, :v, :w, :x, :y, :z, | 70 | :l, :m, :n, :o, :p, :q, :r, :s, :t, :u, :v, :w, :x, :y, :z, |
70 | :question, :exclamation] | 71 | :question, :exclamation] |
71 | 72 | ||
73 | validates :pokeball, presence: true | ||
74 | enumerize :pokeball, in: [:master, :ultra, :great, :poke, :safari, :net, | ||
75 | :dive, :nest, :repeat, :timer, :luxury, :premier] | ||
76 | |||
72 | def to_param | 77 | def to_param |
73 | uuid | 78 | uuid |
74 | end | 79 | end |
@@ -191,6 +196,10 @@ module Pokeviewer | |||
191 | end | 196 | end |
192 | end | 197 | end |
193 | 198 | ||
199 | def pokeball_icon_path | ||
200 | "pokeviewer/items/#{Pokemon.pokeball.values.find_index(pokeball) + 1}.png" | ||
201 | end | ||
202 | |||
194 | private | 203 | private |
195 | 204 | ||
196 | def set_uuid | 205 | def set_uuid |
diff --git a/app/views/pokeviewer/pokemon/show.html.haml b/app/views/pokeviewer/pokemon/show.html.haml index 4485932..e3bee11 100644 --- a/app/views/pokeviewer/pokemon/show.html.haml +++ b/app/views/pokeviewer/pokemon/show.html.haml | |||
@@ -1,4 +1,4 @@ | |||
1 | .pokemon{ class: "in-#{@pokemon.trainer.game}" } | 1 | .pokemon{ class: (not @pokemon.trainer.nil?) && "in-#{@pokemon.trainer.game}" } |
2 | .pokemon-basics | 2 | .pokemon-basics |
3 | .pokemon-species-id= "No. #{@pokemon.species_id}" | 3 | .pokemon-species-id= "No. #{@pokemon.species_id}" |
4 | .pokemon-species-name= @pokemon.species.name | 4 | .pokemon-species-name= @pokemon.species.name |
@@ -90,6 +90,7 @@ | |||
90 | = ribbon[:description] | 90 | = ribbon[:description] |
91 | .pokemon-etc | 91 | .pokemon-etc |
92 | .pd-details Misc | 92 | .pd-details Misc |
93 | = image_tag(@pokemon.pokeball_icon_path) | ||
93 | - unless @pokemon.revisions.last.item.nil? | 94 | - unless @pokemon.revisions.last.item.nil? |
94 | .pd-hold-item.pkv-has-hover | 95 | .pd-hold-item.pkv-has-hover |
95 | = image_tag(@pokemon.revisions.last.item.icon_path) | 96 | = image_tag(@pokemon.revisions.last.item.icon_path) |
diff --git a/db/migrate/20171004203404_add_pokeball_to_pokemon.rb b/db/migrate/20171004203404_add_pokeball_to_pokemon.rb new file mode 100644 index 0000000..9568d10 --- /dev/null +++ b/db/migrate/20171004203404_add_pokeball_to_pokemon.rb | |||
@@ -0,0 +1,9 @@ | |||
1 | class AddPokeballToPokemon < ActiveRecord::Migration[5.1] | ||
2 | def change | ||
3 | change_table :pokeviewer_pokemon do |t| | ||
4 | t.string :pokeball, null: false, default: :poke | ||
5 | end | ||
6 | |||
7 | change_column_default :pokeviewer_pokemon, :pokeball, nil | ||
8 | end | ||
9 | end | ||
diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index b1c02e3..5ae8e1d 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb | |||
@@ -10,7 +10,7 @@ | |||
10 | # | 10 | # |
11 | # It's strongly recommended that you check this file into your version control system. | 11 | # It's strongly recommended that you check this file into your version control system. |
12 | 12 | ||
13 | ActiveRecord::Schema.define(version: 20171003191205) do | 13 | ActiveRecord::Schema.define(version: 20171004203404) do |
14 | 14 | ||
15 | create_table "pokeviewer_gift_ribbons", force: :cascade do |t| | 15 | create_table "pokeviewer_gift_ribbons", force: :cascade do |t| |
16 | t.string "description", null: false | 16 | t.string "description", null: false |
@@ -68,6 +68,7 @@ ActiveRecord::Schema.define(version: 20171003191205) do | |||
68 | t.integer "box" | 68 | t.integer "box" |
69 | t.integer "slot" | 69 | t.integer "slot" |
70 | t.integer "location_id" | 70 | t.integer "location_id" |
71 | t.string "pokeball", null: false | ||
71 | t.index ["key"], name: "index_pokeviewer_pokemon_on_key", unique: true | 72 | t.index ["key"], name: "index_pokeviewer_pokemon_on_key", unique: true |
72 | t.index ["species_id"], name: "index_pokeviewer_pokemon_on_species_id" | 73 | t.index ["species_id"], name: "index_pokeviewer_pokemon_on_species_id" |
73 | t.index ["trainer_id"], name: "index_pokeviewer_pokemon_on_trainer_id" | 74 | t.index ["trainer_id"], name: "index_pokeviewer_pokemon_on_trainer_id" |