From a65972d34188d14dca10193950732d506d931e8c Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Mon, 25 Sep 2017 00:05:38 -0400 Subject: Added met location data MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Note that the met location for Pokémon from Orre is completely incorrect. --- app/assets/stylesheets/pokeviewer/pokemon.css.scss | 50 +++++++++++++++++++--- app/controllers/pokeviewer/pokemon_controller.rb | 2 +- app/jobs/pokeviewer/extract_save_data_job.rb | 7 +++ app/models/pokeviewer/location.rb | 5 +++ app/models/pokeviewer/pokemon.rb | 36 ++++++++++++++++ app/views/pokeviewer/pokemon/show.html.haml | 49 ++++++++++++--------- 6 files changed, 121 insertions(+), 28 deletions(-) create mode 100644 app/models/pokeviewer/location.rb (limited to 'app') diff --git a/app/assets/stylesheets/pokeviewer/pokemon.css.scss b/app/assets/stylesheets/pokeviewer/pokemon.css.scss index 332cb18..83fac45 100644 --- a/app/assets/stylesheets/pokeviewer/pokemon.css.scss +++ b/app/assets/stylesheets/pokeviewer/pokemon.css.scss @@ -141,6 +141,9 @@ font-family: 'Power Green'; display: flex; margin: 1em; + border: 1px solid #777; + border-radius: 5px; + background-color: #fafafa; .male { color: blue; @@ -155,16 +158,49 @@ white-space: pre; } - .pokemon-ivs { - margin: 0 1em; + .pd-details { + color: white; + font-size: bold; + padding: .25em .5em; + } + + .pd-contents { + p { + margin: .25em; + } + } + + .pokemon-basics { + margin: .5em; + } + + .pokemon-memo { + border-left: 1px solid #aaa; + background-color: #e7e8ff; + + .pd-details { + background-color: #2068e0; + } + } - th { - text-align: center; - padding-right: .5em; + .pokemon-stats { + border-left: 1px solid #aaa; + + .pd-details { + background-color: #d078f8; } - td { - text-align: right; + table { + margin: 0 1em; + + th { + text-align: center; + padding-right: .5em; + } + + td { + text-align: right; + } } } } diff --git a/app/controllers/pokeviewer/pokemon_controller.rb b/app/controllers/pokeviewer/pokemon_controller.rb index ef421ac..44ee791 100644 --- a/app/controllers/pokeviewer/pokemon_controller.rb +++ b/app/controllers/pokeviewer/pokemon_controller.rb @@ -7,7 +7,7 @@ module Pokeviewer end def show - @pokemon = Pokemon.find_by_uuid params[:id] + @pokemon = Pokemon.find_by_uuid! params[:id] end end end diff --git a/app/jobs/pokeviewer/extract_save_data_job.rb b/app/jobs/pokeviewer/extract_save_data_job.rb index 3409a5f..be8f64d 100644 --- a/app/jobs/pokeviewer/extract_save_data_job.rb +++ b/app/jobs/pokeviewer/extract_save_data_job.rb @@ -39,9 +39,16 @@ module Pokeviewer if param["metLevel"] == 0 r.met_type = :hatched + r.met_location = param["metLocation"] + elsif param["metLocation"] == 254 + r.met_type = :npc_trade + elsif param["metLocation"] == 255 + r.met_type = :fateful_encounter + r.met_level = param["metLevel"] else r.met_type = :normal r.met_level = param["metLevel"] + r.met_location = param["metLocation"] end r.shiny = param["shiny"] diff --git a/app/models/pokeviewer/location.rb b/app/models/pokeviewer/location.rb new file mode 100644 index 0000000..e497cbc --- /dev/null +++ b/app/models/pokeviewer/location.rb @@ -0,0 +1,5 @@ +module Pokeviewer + class Location < ApplicationRecord + validates :name, presence: true + end +end diff --git a/app/models/pokeviewer/pokemon.rb b/app/models/pokeviewer/pokemon.rb index d14ea87..e493c66 100644 --- a/app/models/pokeviewer/pokemon.rb +++ b/app/models/pokeviewer/pokemon.rb @@ -101,6 +101,42 @@ module Pokeviewer end end + def outsider? + (ot_name != trainer.name) or (ot_number != trainer.number) + end + + def location + if (met_type == :normal) or (met_type == :hatched) + Location.find_by_id(met_location) + else + nil + end + end + + def display_ot_number + ot_number.to_s.rjust(5, '0') + end + + def display_met + if met_type == :normal + if outsider? + "Apparently met in #{location.name} at Lv. #{met_level}." + else + "Met in #{location.name} at Lv. #{met_level}." + end + elsif met_type == :hatched + if outsider? + "Apparently hatched in #{location.name} at Lv. 5." + else + "Hatched in #{location.name} at Lv. 5." + end + elsif met_type == :npc_trade + "Met in a trade." + elsif met_type == :fateful_encounter + "Obtained in a fateful encounter at Lv. #{met_level}." + end + end + private def set_uuid diff --git a/app/views/pokeviewer/pokemon/show.html.haml b/app/views/pokeviewer/pokemon/show.html.haml index a38d641..18a6788 100644 --- a/app/views/pokeviewer/pokemon/show.html.haml +++ b/app/views/pokeviewer/pokemon/show.html.haml @@ -7,24 +7,33 @@ .pokemon-ot OT/ %span{ class: @pokemon.ot_gender }>= @pokemon.ot_name - .pokemon-id= "ID/#{@pokemon.ot_number}" + .pokemon-id= "ID/#{@pokemon.display_ot_number}" .pokemon-level= "Lv. #{@pokemon.revisions.last.level}" - %table.pokemon-ivs - %tr - %th HP - %td= @pokemon.revisions.last.hp - %tr - %th Attack - %td= @pokemon.revisions.last.attack - %tr - %th Defense - %td= @pokemon.revisions.last.defense - %tr - %th Sp. Atk - %td= @pokemon.revisions.last.special_attack - %tr - %th Sp. Def - %td= @pokemon.revisions.last.special_defense - %tr - %th Speed - %td= @pokemon.revisions.last.speed + .pokemon-memo + .pd-details Trainer Memo + .pd-contents + %p + %span.pokemon-nature<= @pokemon.nature.titlecase + nature. + %p= @pokemon.display_met + .pokemon-stats + .pd-details Stats + %table.pd-contents + %tr + %th HP + %td= @pokemon.revisions.last.hp + %tr + %th Attack + %td= @pokemon.revisions.last.attack + %tr + %th Defense + %td= @pokemon.revisions.last.defense + %tr + %th Sp. Atk + %td= @pokemon.revisions.last.special_attack + %tr + %th Sp. Def + %td= @pokemon.revisions.last.special_defense + %tr + %th Speed + %td= @pokemon.revisions.last.speed -- cgit 1.4.1