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 +++-- .../20170925013807_create_pokeviewer_locations.rb | 9 + db/seeds.rb | 214 +++++++++++++++++++++ test/dummy/db/schema.rb | 8 +- 9 files changed, 351 insertions(+), 29 deletions(-) create mode 100644 app/models/pokeviewer/location.rb create mode 100644 db/migrate/20170925013807_create_pokeviewer_locations.rb 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 diff --git a/db/migrate/20170925013807_create_pokeviewer_locations.rb b/db/migrate/20170925013807_create_pokeviewer_locations.rb new file mode 100644 index 0000000..9070077 --- /dev/null +++ b/db/migrate/20170925013807_create_pokeviewer_locations.rb @@ -0,0 +1,9 @@ +class CreatePokeviewerLocations < ActiveRecord::Migration[5.1] + def change + create_table :pokeviewer_locations do |t| + t.string :name, null: false + + t.timestamps + end + end +end diff --git a/db/seeds.rb b/db/seeds.rb index 7fd61a0..221538e 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -740,4 +740,218 @@ module Pokeviewer Move.create(id: 3, name: "Double Slap", pp: 10) Move.create(id: 2, name: "Karate Chop", pp: 25) Move.create(id: 1, name: "Pound", pp: 35) + + Location.create(id: 0, name: "Littleroot Town") + Location.create(id: 1, name: "Oldale Town") + Location.create(id: 2, name: "Dewford Town") + Location.create(id: 3, name: "Lavaridge Town") + Location.create(id: 4, name: "Fallarbor Town") + Location.create(id: 5, name: "Verdanturf Town") + Location.create(id: 6, name: "Pacifidlog Town") + Location.create(id: 7, name: "Petalburg City") + Location.create(id: 8, name: "Slateport City") + Location.create(id: 9, name: "Mauville City") + Location.create(id: 10, name: "Rustboro City") + Location.create(id: 11, name: "Fortree City") + Location.create(id: 12, name: "Lilycove City") + Location.create(id: 13, name: "Mossdeep City") + Location.create(id: 14, name: "Sootopolis City") + Location.create(id: 15, name: "Ever Grande City") + Location.create(id: 16, name: "Route 101") + Location.create(id: 17, name: "Route 102") + Location.create(id: 18, name: "Route 103") + Location.create(id: 19, name: "Route 104") + Location.create(id: 20, name: "Route 105") + Location.create(id: 21, name: "Route 106") + Location.create(id: 22, name: "Route 107") + Location.create(id: 23, name: "Route 108") + Location.create(id: 24, name: "Route 109") + Location.create(id: 25, name: "Route 110") + Location.create(id: 26, name: "Route 111") + Location.create(id: 27, name: "Route 112") + Location.create(id: 28, name: "Route 113") + Location.create(id: 29, name: "Route 114") + Location.create(id: 30, name: "Route 115") + Location.create(id: 31, name: "Route 116") + Location.create(id: 32, name: "Route 117") + Location.create(id: 33, name: "Route 118") + Location.create(id: 34, name: "Route 119") + Location.create(id: 35, name: "Route 120") + Location.create(id: 36, name: "Route 121") + Location.create(id: 37, name: "Route 122") + Location.create(id: 38, name: "Route 123") + Location.create(id: 39, name: "Route 124") + Location.create(id: 40, name: "Route 125") + Location.create(id: 41, name: "Route 126") + Location.create(id: 42, name: "Route 127") + Location.create(id: 43, name: "Route 128") + Location.create(id: 44, name: "Route 129") + Location.create(id: 45, name: "Route 130") + Location.create(id: 46, name: "Route 131") + Location.create(id: 47, name: "Route 132") + Location.create(id: 48, name: "Route 133") + Location.create(id: 49, name: "Route 134") + Location.create(id: 50, name: "Underwater") + Location.create(id: 51, name: "Underwater") + Location.create(id: 52, name: "Underwater") + Location.create(id: 53, name: "Underwater") + Location.create(id: 54, name: "Underwater") + Location.create(id: 55, name: "Granite Cave") + Location.create(id: 56, name: "Mt. Chimney") + Location.create(id: 57, name: "Safari Zone") + Location.create(id: 58, name: "Battle Frontier") + Location.create(id: 59, name: "Petalburg Woods") + Location.create(id: 60, name: "Rusturf Tunnel") + Location.create(id: 61, name: "Abandoned Ship") + Location.create(id: 62, name: "New Mauville") + Location.create(id: 63, name: "Meteor Falls") + Location.create(id: 64, name: "Meteor Falls") + Location.create(id: 65, name: "Mt. Pyre") + Location.create(id: 66, name: "Hideout") + Location.create(id: 67, name: "Shoal Cave") + Location.create(id: 68, name: "Seafloor Cavern") + Location.create(id: 69, name: "Underwater") + Location.create(id: 70, name: "Victory Road") + Location.create(id: 71, name: "Mirage Island") + Location.create(id: 72, name: "Cave of Origin") + Location.create(id: 73, name: "Southern Island") + Location.create(id: 74, name: "Fiery Path") + Location.create(id: 75, name: "Fiery Path") + Location.create(id: 76, name: "Jagged Pass") + Location.create(id: 77, name: "Jagged Pass") + Location.create(id: 78, name: "Sealed Chamber") + Location.create(id: 79, name: "Underwater") + Location.create(id: 80, name: "Scorched Slab") + Location.create(id: 81, name: "Island Cave") + Location.create(id: 82, name: "Desert Ruins") + Location.create(id: 83, name: "Ancient Tomb") + Location.create(id: 84, name: "Inside of Truck") + Location.create(id: 85, name: "Sky Pillar") + Location.create(id: 86, name: "Secret Base") + Location.create(id: 87, name: "Ferry") + Location.create(id: 88, name: "Pallet Town") + Location.create(id: 89, name: "Viridian City") + Location.create(id: 90, name: "Pewter City") + Location.create(id: 91, name: "Cerulean City") + Location.create(id: 92, name: "Lavender Town") + Location.create(id: 93, name: "Vermilion City") + Location.create(id: 94, name: "Celadon City") + Location.create(id: 95, name: "Fuchsia City") + Location.create(id: 96, name: "Cinnabar Island") + Location.create(id: 97, name: "Indigo Plateau") + Location.create(id: 98, name: "Saffron City") + Location.create(id: 99, name: "Route 4") + Location.create(id: 100, name: "Route 10") + Location.create(id: 101, name: "Route 1") + Location.create(id: 102, name: "Route 2") + Location.create(id: 103, name: "Route 3") + Location.create(id: 104, name: "Route 4") + Location.create(id: 105, name: "Route 5") + Location.create(id: 106, name: "Route 6") + Location.create(id: 107, name: "Route 7") + Location.create(id: 108, name: "Route 8") + Location.create(id: 109, name: "Route 9") + Location.create(id: 110, name: "Route 10") + Location.create(id: 111, name: "Route 11") + Location.create(id: 112, name: "Route 12") + Location.create(id: 113, name: "Route 13") + Location.create(id: 114, name: "Route 14") + Location.create(id: 115, name: "Route 15") + Location.create(id: 116, name: "Route 16") + Location.create(id: 117, name: "Route 17") + Location.create(id: 118, name: "Route 18") + Location.create(id: 119, name: "Route 19") + Location.create(id: 120, name: "Route 20") + Location.create(id: 121, name: "Route 21") + Location.create(id: 122, name: "Route 22") + Location.create(id: 123, name: "Route 23") + Location.create(id: 124, name: "Route 24") + Location.create(id: 125, name: "Route 25") + Location.create(id: 126, name: "Viridian Forest") + Location.create(id: 127, name: "Mt. Moon") + Location.create(id: 128, name: "S.S. Anne") + Location.create(id: 129, name: "Underground Path") + Location.create(id: 130, name: "Underground Path") + Location.create(id: 131, name: "Diglett's Cave") + Location.create(id: 132, name: "Victory Road") + Location.create(id: 133, name: "Rocket Hideout") + Location.create(id: 134, name: "Silph Co.") + Location.create(id: 135, name: "Pokémon Mansion") + Location.create(id: 136, name: "Safari Zone") + Location.create(id: 137, name: "Pokémon League") + Location.create(id: 138, name: "Rock Tunnel") + Location.create(id: 139, name: "Seafoam Islands") + Location.create(id: 140, name: "Pokémon Tower") + Location.create(id: 141, name: "Cerulean Cave") + Location.create(id: 142, name: "Power Plant") + Location.create(id: 143, name: "One Island") + Location.create(id: 144, name: "Two Island") + Location.create(id: 145, name: "Three Island") + Location.create(id: 146, name: "Four Island") + Location.create(id: 147, name: "Five Island") + Location.create(id: 148, name: "Seven Island") + Location.create(id: 149, name: "Six Island") + Location.create(id: 150, name: "Kindle Road") + Location.create(id: 151, name: "Treasure Beach") + Location.create(id: 152, name: "Cape Brink") + Location.create(id: 153, name: "Bond Bridge") + Location.create(id: 154, name: "Three Isle Port") + Location.create(id: 155, name: "Sevii Isle 6") + Location.create(id: 156, name: "Sevii Isle 7") + Location.create(id: 157, name: "Sevii Isle 8") + Location.create(id: 158, name: "Sevii Isle 9") + Location.create(id: 159, name: "Resort Gorgeous") + Location.create(id: 160, name: "Water Labyrinth") + Location.create(id: 161, name: "Five Isle Meadow") + Location.create(id: 162, name: "Memorial Pillar") + Location.create(id: 163, name: "Outcast Island") + Location.create(id: 164, name: "Green Path") + Location.create(id: 165, name: "Water Path") + Location.create(id: 166, name: "Ruin Valley") + Location.create(id: 167, name: "Trainer Tower") + Location.create(id: 168, name: "Canyon Entrance") + Location.create(id: 169, name: "Sevault Canyon") + Location.create(id: 170, name: "Tanoby Ruins") + Location.create(id: 171, name: "Sevii Isle 22") + Location.create(id: 172, name: "Sevii Isle 23") + Location.create(id: 173, name: "Sevii Isle 24") + Location.create(id: 174, name: "Navel Rock") + Location.create(id: 175, name: "Mt. Ember") + Location.create(id: 176, name: "Berry Forest") + Location.create(id: 177, name: "Icefall Cave") + Location.create(id: 178, name: "Rocket Warehouse") + Location.create(id: 179, name: "Trainer Tower") + Location.create(id: 180, name: "Dotted Hole") + Location.create(id: 181, name: "Lost Cave") + Location.create(id: 182, name: "Pattern Bush") + Location.create(id: 183, name: "Altering Cave") + Location.create(id: 184, name: "Tanoby Chambers") + Location.create(id: 185, name: "Three Isle Path") + Location.create(id: 186, name: "Tanoby Key") + Location.create(id: 187, name: "Birth Island") + Location.create(id: 188, name: "Monean Chamber") + Location.create(id: 189, name: "Liptoo Chamber") + Location.create(id: 190, name: "Weepth Chamber") + Location.create(id: 191, name: "Dilford Chamber") + Location.create(id: 192, name: "Scufib Chamber") + Location.create(id: 193, name: "Rixy Chamber") + Location.create(id: 194, name: "Viapois Chamber") + Location.create(id: 195, name: "Ember Spa") + Location.create(id: 196, name: "Celadon Dept.") + Location.create(id: 197, name: "Aqua Hideout") + Location.create(id: 198, name: "Magma Hideout") + Location.create(id: 199, name: "Mirage Tower") + Location.create(id: 200, name: "Birth Island") + Location.create(id: 201, name: "Faraway Island") + Location.create(id: 202, name: "Artisan Cave") + Location.create(id: 203, name: "Marine Cave") + Location.create(id: 204, name: "Underwater") + Location.create(id: 205, name: "Terra Cave") + Location.create(id: 206, name: "Underwater") + Location.create(id: 207, name: "Underwater") + Location.create(id: 208, name: "Underwater") + Location.create(id: 209, name: "Desert Underpass") + Location.create(id: 210, name: "Altering Cave") + Location.create(id: 211, name: "Navel Rock") + Location.create(id: 212, name: "Trainer Hill") end diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index e7322e9..fa3b3f7 100644 --- a/test/dummy/db/schema.rb +++ b/test/dummy/db/schema.rb @@ -10,7 +10,7 @@ # # It's strongly recommended that you check this file into your version control system. -ActiveRecord::Schema.define(version: 20170924224550) do +ActiveRecord::Schema.define(version: 20170925013807) do create_table "pokeviewer_boxes", force: :cascade do |t| t.integer "trainer_id", null: false @@ -22,6 +22,12 @@ ActiveRecord::Schema.define(version: 20170924224550) do t.index ["trainer_id"], name: "index_pokeviewer_boxes_on_trainer_id" end + create_table "pokeviewer_locations", force: :cascade do |t| + t.string "name", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "pokeviewer_moves", force: :cascade do |t| t.string "name", limit: 191, null: false t.integer "pp", null: false -- cgit 1.4.1