From eae1c764df31b5e5aa2a2d8315b2b5c0997babf4 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Wed, 4 Oct 2017 23:09:37 -0400 Subject: Pokémon now show the Poké Ball that they're in MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Also fixed a bug with viewing Pokémon that aren't in any game. --- app/jobs/pokeviewer/extract_save_data_job.rb | 1 + app/models/pokeviewer/pokemon.rb | 9 +++++++++ app/views/pokeviewer/pokemon/show.html.haml | 3 ++- 3 files changed, 12 insertions(+), 1 deletion(-) (limited to 'app') 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 r.nature = Pokemon.nature.values[param["nature"]] r.gender = param["gender"] r.second_ability = param["secondAbility"] + r.pokeball = Pokemon.pokeball.values[param["pokeball"] - 1] # Handle Unown form 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 @@ module Pokeviewer class Pokemon < ApplicationRecord extend Enumerize + extend ActiveModel::Naming belongs_to :species @@ -69,6 +70,10 @@ module Pokeviewer :l, :m, :n, :o, :p, :q, :r, :s, :t, :u, :v, :w, :x, :y, :z, :question, :exclamation] + validates :pokeball, presence: true + enumerize :pokeball, in: [:master, :ultra, :great, :poke, :safari, :net, + :dive, :nest, :repeat, :timer, :luxury, :premier] + def to_param uuid end @@ -191,6 +196,10 @@ module Pokeviewer end end + def pokeball_icon_path + "pokeviewer/items/#{Pokemon.pokeball.values.find_index(pokeball) + 1}.png" + end + private 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 @@ -.pokemon{ class: "in-#{@pokemon.trainer.game}" } +.pokemon{ class: (not @pokemon.trainer.nil?) && "in-#{@pokemon.trainer.game}" } .pokemon-basics .pokemon-species-id= "No. #{@pokemon.species_id}" .pokemon-species-name= @pokemon.species.name @@ -90,6 +90,7 @@ = ribbon[:description] .pokemon-etc .pd-details Misc + = image_tag(@pokemon.pokeball_icon_path) - unless @pokemon.revisions.last.item.nil? .pd-hold-item.pkv-has-hover = image_tag(@pokemon.revisions.last.item.icon_path) -- cgit 1.4.1