From 6dff23b065bd933ff2f571d2264c86902173d40b Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Fri, 29 Sep 2017 18:36:57 -0400 Subject: Added ribbons Gift ribbons currently partially work: the correct ribbon image and name is shown, but the ribbon description is not yet extracted from the game and thus is just blank. --- .../javascripts/pokeviewer/pokemon.js.coffee | 12 +- app/assets/stylesheets/pokeviewer/pokemon.css.scss | 46 ++-- app/jobs/pokeviewer/extract_save_data_job.rb | 18 ++ app/models/pokeviewer/revision.rb | 298 ++++++++++++++++++++- app/views/pokeviewer/pokemon/index.html.haml | 8 +- app/views/pokeviewer/pokemon/show.html.haml | 13 +- 6 files changed, 367 insertions(+), 28 deletions(-) (limited to 'app') diff --git a/app/assets/javascripts/pokeviewer/pokemon.js.coffee b/app/assets/javascripts/pokeviewer/pokemon.js.coffee index f82f196..28a1ec1 100644 --- a/app/assets/javascripts/pokeviewer/pokemon.js.coffee +++ b/app/assets/javascripts/pokeviewer/pokemon.js.coffee @@ -1,7 +1,7 @@ $ -> - $(".pc-pokemon").mouseover -> - $(this).children(".pc-data").show() - $(".pc-pokemon").mouseout -> - $(this).children(".pc-data").hide() - $(".pc-pokemon").mousemove (event) -> - $(this).children(".pc-data").offset({left: event.pageX + 16, top: event.pageY - 16}) + $(".pkv-has-hover").mouseover -> + $(this).children(".pkv-hover").show() + $(".pkv-has-hover").mouseout -> + $(this).children(".pkv-hover").hide() + $(".pkv-has-hover").mousemove (event) -> + $(this).children(".pkv-hover").offset({left: event.pageX + 16, top: event.pageY - 16}) diff --git a/app/assets/stylesheets/pokeviewer/pokemon.css.scss b/app/assets/stylesheets/pokeviewer/pokemon.css.scss index 2a75730..f44b499 100644 --- a/app/assets/stylesheets/pokeviewer/pokemon.css.scss +++ b/app/assets/stylesheets/pokeviewer/pokemon.css.scss @@ -152,21 +152,19 @@ body { } } -.pc-pokemon { - .pc-data { - display: none; - background-color: #111; - color: #fff; - z-index: 1; - padding: .5em; - box-shadow: 0px 0px 2px 1px #B3B3B3; - border-radius: 4px; - position: absolute; - - .pc-data-name { - font-weight: bold; - white-space: pre; - } +.pkv-hover { + display: none; + background-color: #111; + color: #fff; + z-index: 1; + padding: .5em; + box-shadow: 0px 0px 2px 1px #B3B3B3; + border-radius: 4px; + position: absolute; + + .pc-data-name { + font-weight: bold; + white-space: pre; } } @@ -203,7 +201,6 @@ body { .pd-details { color: white; - font-size: bold; padding: .25em .5em; } @@ -355,4 +352,21 @@ body { stroke-linejoin: butt; } } + + .pokemon-ribbons { + .pd-details { + background-color: #ffc8c8; + } + + ul { + display: flex; + flex-wrap: wrap; + padding: 0; + margin: 0.5em; + + li { + display: block; + } + } + } } diff --git a/app/jobs/pokeviewer/extract_save_data_job.rb b/app/jobs/pokeviewer/extract_save_data_job.rb index be8f64d..f7b8f8f 100644 --- a/app/jobs/pokeviewer/extract_save_data_job.rb +++ b/app/jobs/pokeviewer/extract_save_data_job.rb @@ -109,6 +109,24 @@ module Pokeviewer rev.move_4_pp_bonuses = param["moves"][3]["ppBonuses"] end + rev.cool_ribbons = param["coolRibbons"] + rev.beauty_ribbons = param["beautyRibbons"] + rev.cute_ribbons = param["cuteRibbons"] + rev.smart_ribbons = param["smartRibbons"] + rev.tough_ribbons = param["toughRibbons"] + rev.champion_ribbon = param.fetch "championRibbon", false + rev.winning_ribbon = param.fetch "winningRibbon", false + rev.victory_ribbon = param.fetch "victoryRibbon", false + rev.artist_ribbon = param.fetch "artistRibbon", false + rev.effort_ribbon = param.fetch "effortRibbon", false + rev.marine_ribbon = param.fetch "marineRibbon", false + rev.land_ribbon = param.fetch "landRibbon", false + rev.sky_ribbon = param.fetch "skyRibbon", false + rev.country_ribbon = param.fetch "countryRibbon", false + rev.national_ribbon = param.fetch "nationalRibbon", false + rev.earth_ribbon = param.fetch "earthRibbon", false + rev.world_ribbon = param.fetch "worldRibbon", false + if pk.revisions.empty? or rev.diff?(pk.revisions.last) rev.save! end diff --git a/app/models/pokeviewer/revision.rb b/app/models/pokeviewer/revision.rb index 44388ca..4481bf0 100644 --- a/app/models/pokeviewer/revision.rb +++ b/app/models/pokeviewer/revision.rb @@ -8,7 +8,11 @@ module Pokeviewer :special_attack, :special_defense, :speed, :coolness, :beauty, :cuteness, :smartness, :toughness, :sheen, :hold_item, :move_1_id, :move_2_id, :move_3_id, :move_4_id, :move_1_pp_bonuses, :move_2_pp_bonuses, - :move_3_pp_bonuses, :move_4_pp_bonuses + :move_3_pp_bonuses, :move_4_pp_bonuses, :cool_ribbons, :beauty_ribbons, + :cute_ribbons, :smart_ribbons, :tough_ribbons, :champion_ribbon, + :winning_ribbon, :victory_ribbon, :artist_ribbon, :effort_ribbon, + :marine_ribbon, :land_ribbon, :sky_ribbon, :country_ribbon, + :national_ribbon, :earth_ribbon, :world_ribbon belongs_to :pokemon acts_as_sequenced scope: :pokemon_id @@ -103,5 +107,297 @@ module Pokeviewer greater_than_or_equal_to: 0, less_than_or_equal_to: 3, only_integer: true} + + validates :cool_ribbons, presence: true, + numericality: { + greater_than_or_equal_to: 0, + less_than_or_equal_to: 4, + only_integer: true} + + validates :beauty_ribbons, presence: true, + numericality: { + greater_than_or_equal_to: 0, + less_than_or_equal_to: 4, + only_integer: true} + + validates :cute_ribbons, presence: true, + numericality: { + greater_than_or_equal_to: 0, + less_than_or_equal_to: 4, + only_integer: true} + + validates :smart_ribbons, presence: true, + numericality: { + greater_than_or_equal_to: 0, + less_than_or_equal_to: 4, + only_integer: true} + + validates :tough_ribbons, presence: true, + numericality: { + greater_than_or_equal_to: 0, + less_than_or_equal_to: 4, + only_integer: true} + + def ribbons + result = [] + + if cool_ribbons >= 1 + result << { + filename: "cool-ribbon.png", + name: "Cool Ribbon", + description: "Cool Contest Normal Rank Winner!" + } + end + + if cool_ribbons >= 2 + result << { + filename: "cool-ribbon-super.png", + name: "Cool Ribbon Super", + description: "Cool Contest Super Rank Winner!" + } + end + + if cool_ribbons >= 3 + result << { + filename: "cool-ribbon-hyper.png", + name: "Cool Ribbon Hyper", + description: "Cool Contest Hyper Rank Winner!" + } + end + + if cool_ribbons == 4 + result << { + filename: "cool-ribbon-master.png", + name: "Cool Ribbon Master", + description: "Cool Contest Master Rank Winner!" + } + end + + if beauty_ribbons >= 1 + result << { + filename: "beauty-ribbon.png", + name: "Beauty Ribbon", + description: "Beauty Contest Normal Rank Winner!" + } + end + + if beauty_ribbons >= 2 + result << { + filename: "beauty-ribbon-super.png", + name: "Beauty Ribbon Super", + description: "Beauty Contest Super Rank Winner!" + } + end + + if beauty_ribbons >= 3 + result << { + filename: "beauty-ribbon-hyper.png", + name: "Beauty Ribbon Hyper", + description: "Beauty Contest Hyper Rank Winner!" + } + end + + if beauty_ribbons == 4 + result << { + filename: "beauty-ribbon-master.png", + name: "Beauty Ribbon Master", + description: "Beauty Contest Master Rank Winner!" + } + end + + if cute_ribbons >= 1 + result << { + filename: "cute-ribbon.png", + name: "Cute Ribbon", + description: "Cute Contest Normal Rank Winner!" + } + end + + if cute_ribbons >= 2 + result << { + filename: "cute-ribbon-super.png", + name: "Cute Ribbon Super", + description: "Cute Contest Super Rank Winner!" + } + end + + if cute_ribbons >= 3 + result << { + filename: "cute-ribbon-hyper.png", + name: "Cute Ribbon Hyper", + description: "Cute Contest Hyper Rank Winner!" + } + end + + if cute_ribbons == 4 + result << { + filename: "cute-ribbon-master.png", + name: "Cute Ribbon Master", + description: "Cute Contest Master Rank Winner!" + } + end + + if smart_ribbons >= 1 + result << { + filename: "smart-ribbon.png", + name: "Smart Ribbon", + description: "Smart Contest Normal Rank Winner!" + } + end + + if smart_ribbons >= 2 + result << { + filename: "smart-ribbon-super.png", + name: "Smart Ribbon Super", + description: "Smart Contest Super Rank Winner!" + } + end + + if smart_ribbons >= 3 + result << { + filename: "smart-ribbon-hyper.png", + name: "Smart Ribbon Hyper", + description: "Smart Contest Hyper Rank Winner!" + } + end + + if smart_ribbons == 4 + result << { + filename: "smart-ribbon-master.png", + name: "Smart Ribbon Master", + description: "Smart Contest Master Rank Winner!" + } + end + + if tough_ribbons >= 1 + result << { + filename: "tough-ribbon.png", + name: "Tough Ribbon", + description: "Tough Contest Normal Rank Winner!" + } + end + + if tough_ribbons >= 2 + result << { + filename: "tough-ribbon-super.png", + name: "Tough Ribbon Super", + description: "Tough Contest Super Rank Winner!" + } + end + + if tough_ribbons >= 3 + result << { + filename: "tough-ribbon-hyper.png", + name: "Tough Ribbon Hyper", + description: "Tough Contest Hyper Rank Winner!" + } + end + + if tough_ribbons == 4 + result << { + filename: "tough-ribbon-master.png", + name: "Tough Ribbon Master", + description: "Tough Contest Master Rank Winner!" + } + end + + if champion_ribbon + result << { + filename: "champion-ribbon.png", + name: "Champion Ribbon", + description: "Champion-beating, Hall of Fame Member Ribbon" + } + end + + if winning_ribbon + result << { + filename: "winning-ribbon.png", + name: "Winning Ribbon", + description: "Ribbon for clearing LV50 at the Battle Tower." + } + end + + if victory_ribbon + result << { + filename: "victory-ribbon.png", + name: "Victory Ribbon", + description: "Won for clearing LV100 at the Battle Tower." + } + end + + if artist_ribbon + result << { + filename: "artist-ribbon.png", + name: "Artist Ribbon", + description: "Ribbon for being chosen as a super sketch model." + } + end + + if effort_ribbon + result << { + filename: "effort-ribbon.png", + name: "Effort Ribbon", + description: "Ribbon awarded for being a hard worker." + } + end + + if marine_ribbon + result << { + filename: "marine-ribbon.png", + name: "Marine Ribbon", + description: "" + } + end + + if land_ribbon + result << { + filename: "land-ribbon.png", + name: "Land Ribbon", + description: "" + } + end + + if sky_ribbon + result << { + filename: "sky-ribbon.png", + name: "Sky Ribbon", + description: "" + } + end + + if country_ribbon + result << { + filename: "country-ribbon.png", + name: "Country Ribbon", + description: "" + } + end + + if national_ribbon + result << { + filename: "national-ribbon.png", + name: "National Ribbon", + description: "" + } + end + + if earth_ribbon + result << { + filename: "earth-ribbon.png", + name: "Earth Ribbon", + description: "" + } + end + + if world_ribbon + result << { + filename: "world-ribbon.png", + name: "World Ribbon", + description: "" + } + end + + result + end end end diff --git a/app/views/pokeviewer/pokemon/index.html.haml b/app/views/pokeviewer/pokemon/index.html.haml index 7cee27a..f16f0bc 100644 --- a/app/views/pokeviewer/pokemon/index.html.haml +++ b/app/views/pokeviewer/pokemon/index.html.haml @@ -17,12 +17,12 @@ - box.contents.each_slice(6) do |row| %tr - row.each do |p| - %td.pc-pokemon + %td.pc-pokemon.pkv-has-hover - if p.nil? .spacer - else = link_to image_tag(p.icon_path), p - .pc-data + .pc-data.pkv-hover .pc-data-name= p.revisions.last.nickname .pc-data-ot OT/ @@ -33,9 +33,9 @@ %h2 Pokémon Not In Any Game %ul.pokemon-list - @unaccounted.each do |p| - %li.pc-pokemon + %li.pc-pokemon.pkv-has-hover = link_to image_tag(p.icon_path), p - .pc-data + .pc-data.pkv-hover .pc-data-name= p.revisions.last.nickname .pc-data-ot OT/ diff --git a/app/views/pokeviewer/pokemon/show.html.haml b/app/views/pokeviewer/pokemon/show.html.haml index 3a04914..e90148e 100644 --- a/app/views/pokeviewer/pokemon/show.html.haml +++ b/app/views/pokeviewer/pokemon/show.html.haml @@ -76,4 +76,15 @@ %span.pokemon-nature<= @pokemon.nature.titlecase nature. %p= @pokemon.display_met - = condition_diagram @pokemon.revisions.last + .pokemon-contest + .pd-details Contest Condition + = condition_diagram @pokemon.revisions.last + .pokemon-ribbons + .pd-details Ribbons + %ul + - @pokemon.revisions.last.ribbons.each do |ribbon| + %li.pkv-has-hover + = image_tag("pokeviewer/ribbons/#{ribbon[:filename]}") + .pkv-hover + .pc-data-name= ribbon[:name] + = ribbon[:description] -- cgit 1.4.1