From a7060addea52af313ed85336dc37949ad8e69f05 Mon Sep 17 00:00:00 2001 From: Kelly Rauchenberger Date: Sat, 30 Sep 2017 08:23:48 -0400 Subject: Added gift ribbon descriptions MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit This is basically just for completeness because it is unknown whether gift ribbons other than the National Ribbon and Earth Ribbon from Pokémon Colosseum were ever distributed. --- app/jobs/pokeviewer/extract_save_data_job.rb | 30 ++++++++++++++++++++++++++++ app/models/pokeviewer/gift_ribbon.rb | 5 +++++ app/models/pokeviewer/revision.rb | 14 ++++++------- app/models/pokeviewer/trainer.rb | 18 +++++++++++++++++ 4 files changed, 60 insertions(+), 7 deletions(-) create mode 100644 app/models/pokeviewer/gift_ribbon.rb (limited to 'app') diff --git a/app/jobs/pokeviewer/extract_save_data_job.rb b/app/jobs/pokeviewer/extract_save_data_job.rb index f7b8f8f..b60a8c5 100644 --- a/app/jobs/pokeviewer/extract_save_data_job.rb +++ b/app/jobs/pokeviewer/extract_save_data_job.rb @@ -22,6 +22,36 @@ module Pokeviewer end end + if args.key? "marineRibbon" + game.marine_ribbon = GiftRibbon.find_by_id(args["marineRibbon"]) + end + + if args.key? "landRibbon" + game.land_ribbon = GiftRibbon.find_by_id(args["landRibbon"]) + end + + if args.key? "skyRibbon" + game.sky_ribbon = GiftRibbon.find_by_id(args["skyRibbon"]) + end + + if args.key? "countryRibbon" + game.country_ribbon = GiftRibbon.find_by_id(args["countryRibbon"]) + end + + if args.key? "nationalRibbon" + game.national_ribbon = GiftRibbon.find_by_id(args["nationalRibbon"]) + end + + if args.key? "earthRibbon" + game.earth_ribbon = GiftRibbon.find_by_id(args["earthRibbon"]) + end + + if args.key? "worldRibbon" + game.world_ribbon = GiftRibbon.find_by_id(args["worldRibbon"]) + end + + game.save! if game.changed? + args["boxes"].each_with_index do |box_name,index| box = Box.find_or_initialize_by(trainer: game, number: index) box.name = box_name diff --git a/app/models/pokeviewer/gift_ribbon.rb b/app/models/pokeviewer/gift_ribbon.rb new file mode 100644 index 0000000..f8f4fa5 --- /dev/null +++ b/app/models/pokeviewer/gift_ribbon.rb @@ -0,0 +1,5 @@ +module Pokeviewer + class GiftRibbon < ApplicationRecord + validates :description, presence: true + end +end diff --git a/app/models/pokeviewer/revision.rb b/app/models/pokeviewer/revision.rb index 4481bf0..ab4dfd3 100644 --- a/app/models/pokeviewer/revision.rb +++ b/app/models/pokeviewer/revision.rb @@ -345,7 +345,7 @@ module Pokeviewer result << { filename: "marine-ribbon.png", name: "Marine Ribbon", - description: "" + description: pokemon.trainer.gift_ribbon_description(:marine_ribbon) } end @@ -353,7 +353,7 @@ module Pokeviewer result << { filename: "land-ribbon.png", name: "Land Ribbon", - description: "" + description: pokemon.trainer.gift_ribbon_description(:land_ribbon) } end @@ -361,7 +361,7 @@ module Pokeviewer result << { filename: "sky-ribbon.png", name: "Sky Ribbon", - description: "" + description: pokemon.trainer.gift_ribbon_description(:sky_ribbon) } end @@ -369,7 +369,7 @@ module Pokeviewer result << { filename: "country-ribbon.png", name: "Country Ribbon", - description: "" + description: pokemon.trainer.gift_ribbon_description(:country_ribbon) } end @@ -377,7 +377,7 @@ module Pokeviewer result << { filename: "national-ribbon.png", name: "National Ribbon", - description: "" + description: pokemon.trainer.gift_ribbon_description(:national_ribbon) } end @@ -385,7 +385,7 @@ module Pokeviewer result << { filename: "earth-ribbon.png", name: "Earth Ribbon", - description: "" + description: pokemon.trainer.gift_ribbon_description(:earth_ribbon) } end @@ -393,7 +393,7 @@ module Pokeviewer result << { filename: "world-ribbon.png", name: "World Ribbon", - description: "" + description: pokemon.trainer.gift_ribbon_description(:world_ribbon) } end diff --git a/app/models/pokeviewer/trainer.rb b/app/models/pokeviewer/trainer.rb index f890d61..7862c1e 100644 --- a/app/models/pokeviewer/trainer.rb +++ b/app/models/pokeviewer/trainer.rb @@ -16,6 +16,14 @@ module Pokeviewer enumerize :game, in: [:ruby, :sapphire, :firered, :leafgreen, :emerald], predicates: true + belongs_to :marine_ribbon, class_name: "GiftRibbon", optional: true + belongs_to :land_ribbon, class_name: "GiftRibbon", optional: true + belongs_to :sky_ribbon, class_name: "GiftRibbon", optional: true + belongs_to :country_ribbon, class_name: "GiftRibbon", optional: true + belongs_to :national_ribbon, class_name: "GiftRibbon", optional: true + belongs_to :earth_ribbon, class_name: "GiftRibbon", optional: true + belongs_to :world_ribbon, class_name: "GiftRibbon", optional: true + def display_number number.to_s.rjust(5, '0') end @@ -23,5 +31,15 @@ module Pokeviewer def party pokemon.where(box: nil).order("slot ASC") end + + def gift_ribbon_description(ribbon) + gift_ribbon = send ribbon + + if gift_ribbon.nil? + "" + else + gift_ribbon.description + end + end end end -- cgit 1.4.1