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 ++++++ ...0170929221317_create_pokeviewer_gift_ribbons.rb | 9 +++ .../20170930021856_add_gift_ribbons_to_trainer.rb | 34 +++++++++++ db/seeds.rb | 65 ++++++++++++++++++++++ test/dummy/db/schema.rb | 22 +++++++- 8 files changed, 189 insertions(+), 8 deletions(-) create mode 100644 app/models/pokeviewer/gift_ribbon.rb create mode 100644 db/migrate/20170929221317_create_pokeviewer_gift_ribbons.rb create mode 100644 db/migrate/20170930021856_add_gift_ribbons_to_trainer.rb 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 diff --git a/db/migrate/20170929221317_create_pokeviewer_gift_ribbons.rb b/db/migrate/20170929221317_create_pokeviewer_gift_ribbons.rb new file mode 100644 index 0000000..deedc80 --- /dev/null +++ b/db/migrate/20170929221317_create_pokeviewer_gift_ribbons.rb @@ -0,0 +1,9 @@ +class CreatePokeviewerGiftRibbons < ActiveRecord::Migration[5.1] + def change + create_table :pokeviewer_gift_ribbons do |t| + t.string :description, null: false + + t.timestamps + end + end +end diff --git a/db/migrate/20170930021856_add_gift_ribbons_to_trainer.rb b/db/migrate/20170930021856_add_gift_ribbons_to_trainer.rb new file mode 100644 index 0000000..2a5f9b3 --- /dev/null +++ b/db/migrate/20170930021856_add_gift_ribbons_to_trainer.rb @@ -0,0 +1,34 @@ +class AddGiftRibbonsToTrainer < ActiveRecord::Migration[5.1] + def change + change_table :pokeviewer_trainers do |t| + t.references :marine_ribbon, null: true + t.references :land_ribbon, null: true + t.references :sky_ribbon, null: true + t.references :country_ribbon, null: true + t.references :national_ribbon, null: true + t.references :earth_ribbon, null: true + t.references :world_ribbon, null: true + end + + add_foreign_key :pokeviewer_trainers, :pokeviewer_gift_ribbons, + column: :marine_ribbon_id + + add_foreign_key :pokeviewer_trainers, :pokeviewer_gift_ribbons, + column: :land_ribbon_id + + add_foreign_key :pokeviewer_trainers, :pokeviewer_gift_ribbons, + column: :sky_ribbon_id + + add_foreign_key :pokeviewer_trainers, :pokeviewer_gift_ribbons, + column: :country_ribbon_id + + add_foreign_key :pokeviewer_trainers, :pokeviewer_gift_ribbons, + column: :national_ribbon_id + + add_foreign_key :pokeviewer_trainers, :pokeviewer_gift_ribbons, + column: :earth_ribbon_id + + add_foreign_key :pokeviewer_trainers, :pokeviewer_gift_ribbons, + column: :world_ribbon_id + end +end diff --git a/db/seeds.rb b/db/seeds.rb index 221538e..500e3c6 100644 --- a/db/seeds.rb +++ b/db/seeds.rb @@ -954,4 +954,69 @@ module Pokeviewer Location.create(id: 210, name: "Altering Cave") Location.create(id: 211, name: "Navel Rock") Location.create(id: 212, name: "Trainer Hill") + + GiftRibbon.create(id: 1, description: "2003 REGIONAL TOURNEY CHAMPION RIBBON") + GiftRibbon.create(id: 2, description: "2003 NATIONAL TOURNEY CHAMPION RIBBON") + GiftRibbon.create(id: 3, description: "2003 GLOBAL CUP CHAMPION RIBBON") + GiftRibbon.create(id: 4, description: "2003 REGIONAL TOURNEY Runner-up RIBBON") + GiftRibbon.create(id: 5, description: "2003 NATIONAL TOURNEY Runner-up RIBBON") + GiftRibbon.create(id: 6, description: "2003 GLOBAL CUP Runner-up RIBBON") + GiftRibbon.create(id: 7, description: "2003 REGIONAL TOURNEY Semifinalist RIBBON") + GiftRibbon.create(id: 8, description: "2003 NATIONAL TOURNEY Semifinalist RIBBON") + GiftRibbon.create(id: 9, description: "2003 GLOBAL CUP Semifinalist RIBBON") + GiftRibbon.create(id: 10, description: "2004 REGIONAL TOURNEY CHAMPION RIBBON") + GiftRibbon.create(id: 11, description: "2004 NATIONAL TOURNEY CHAMPION RIBBON") + GiftRibbon.create(id: 12, description: "2004 GLOBAL CUP CHAMPION RIBBON") + GiftRibbon.create(id: 13, description: "2004 REGIONAL TOURNEY Runner-up RIBBON") + GiftRibbon.create(id: 14, description: "2004 NATIONAL TOURNEY Runner-up RIBBON") + GiftRibbon.create(id: 15, description: "2004 GLOBAL CUP Runner-up RIBBON") + GiftRibbon.create(id: 16, description: "2004 REGIONAL TOURNEY Semifinalist RIBBON") + GiftRibbon.create(id: 17, description: "2004 NATIONAL TOURNEY Semifinalist RIBBON") + GiftRibbon.create(id: 18, description: "2004 GLOBAL CUP Semifinalist RIBBON") + GiftRibbon.create(id: 19, description: "2005 REGIONAL TOURNEY CHAMPION RIBBON") + GiftRibbon.create(id: 20, description: "2005 NATIONAL TOURNEY CHAMPION RIBBON") + GiftRibbon.create(id: 21, description: "2005 GLOBAL CUP CHAMPION RIBBON") + GiftRibbon.create(id: 22, description: "2005 REGIONAL TOURNEY Runner-up RIBBON") + GiftRibbon.create(id: 23, description: "2005 NATIONAL TOURNEY Runner-up RIBBON") + GiftRibbon.create(id: 24, description: "2005 GLOBAL CUP Runner-up RIBBON") + GiftRibbon.create(id: 25, description: "2005 REGIONAL TOURNEY Semifinalist RIBBON") + GiftRibbon.create(id: 26, description: "2005 NATIONAL TOURNEY Semifinalist RIBBON") + GiftRibbon.create(id: 27, description: "2005 GLOBAL CUP Semifinalist RIBBON") + GiftRibbon.create(id: 28, description: "POKéMON BATTLE CUP CHAMPION RIBBON") + GiftRibbon.create(id: 29, description: "POKéMON BATTLE CUP Runner-up RIBBON") + GiftRibbon.create(id: 30, description: "POKéMON BATTLE CUP Semifinalist RIBBON") + GiftRibbon.create(id: 31, description: "POKéMON BATTLE CUP Participation RIBBON") + GiftRibbon.create(id: 32, description: "POKéMON LEAGUE CHAMPION RIBBON") + GiftRibbon.create(id: 33, description: "POKéMON LEAGUE Runner-up RIBBON") + GiftRibbon.create(id: 34, description: "POKéMON LEAGUE Semifinalist RIBBON") + GiftRibbon.create(id: 35, description: "POKéMON LEAGUE Participation RIBBON") + GiftRibbon.create(id: 36, description: "ADVANCE CUP CHAMPION RIBBON") + GiftRibbon.create(id: 37, description: "ADVANCE CUP Runner-up RIBBON") + GiftRibbon.create(id: 38, description: "ADVANCE CUP Semifinalist RIBBON") + GiftRibbon.create(id: 39, description: "ADVANCE CUP Participation RIBBON") + GiftRibbon.create(id: 40, description: "POKéMON Tournament Participation RIBBON") + GiftRibbon.create(id: 41, description: "POKéMON Event Participation RIBBON") + GiftRibbon.create(id: 42, description: "POKéMON Festival Participation RIBBON") + GiftRibbon.create(id: 43, description: "Difficulty-clearing Commemorative RIBBON") + GiftRibbon.create(id: 44, description: "RIBBON awarded for clearing all difficulties.") + GiftRibbon.create(id: 45, description: "100-straight Win Commemorative RIBBON") + GiftRibbon.create(id: 46, description: "DARKNESS TOWER Clear Commemorative RIBBON") + GiftRibbon.create(id: 47, description: "RED TOWER Clear Commemorative RIBBON") + GiftRibbon.create(id: 48, description: "BLACKIRON TOWER Clear Commemorative RIBBON") + GiftRibbon.create(id: 49, description: "FINAL TOWER Clear Commemorative RIBBON") + GiftRibbon.create(id: 50, description: "Legend-making Commemorative RIBBON") + GiftRibbon.create(id: 51, description: "POKéMON CENTER TOKYO Commemorative RIBBON") + GiftRibbon.create(id: 52, description: "POKéMON CENTER OSAKA Commemorative RIBBON") + GiftRibbon.create(id: 53, description: "POKéMON CENTER NAGOYA Commemorative RIBBON") + GiftRibbon.create(id: 54, description: "POKéMON CENTER NY Commemorative RIBBON") + GiftRibbon.create(id: 55, description: "Summer Holidays RIBBON") + GiftRibbon.create(id: 56, description: "Winter Holidays RIBBON") + GiftRibbon.create(id: 57, description: "Spring Holidays RIBBON") + GiftRibbon.create(id: 58, description: "Evergreen RIBBON") + GiftRibbon.create(id: 59, description: "Special Holiday RIBBON") + GiftRibbon.create(id: 60, description: "Hard Worker RIBBON") + GiftRibbon.create(id: 61, description: "Lots of Friends RIBBON") + GiftRibbon.create(id: 62, description: "Full of Energy RIBBON") + GiftRibbon.create(id: 63, description: "A commemorative RIBBON for a loved POKéMON.") + GiftRibbon.create(id: 64, description: "RIBBON that shows love for POKéMON.") end diff --git a/test/dummy/db/schema.rb b/test/dummy/db/schema.rb index 1dfb59a..9530010 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: 20170929211529) do +ActiveRecord::Schema.define(version: 20170930021856) do create_table "pokeviewer_boxes", force: :cascade do |t| t.integer "trainer_id", null: false @@ -22,6 +22,12 @@ ActiveRecord::Schema.define(version: 20170929211529) do t.index ["trainer_id"], name: "index_pokeviewer_boxes_on_trainer_id" end + create_table "pokeviewer_gift_ribbons", force: :cascade do |t| + t.string "description", null: false + t.datetime "created_at", null: false + t.datetime "updated_at", null: false + end + create_table "pokeviewer_locations", force: :cascade do |t| t.string "name", null: false t.datetime "created_at", null: false @@ -129,7 +135,21 @@ ActiveRecord::Schema.define(version: 20170929211529) do t.integer "number", null: false t.datetime "created_at", null: false t.datetime "updated_at", null: false + t.integer "marine_ribbon_id" + t.integer "land_ribbon_id" + t.integer "sky_ribbon_id" + t.integer "country_ribbon_id" + t.integer "national_ribbon_id" + t.integer "earth_ribbon_id" + t.integer "world_ribbon_id" + t.index ["country_ribbon_id"], name: "index_pokeviewer_trainers_on_country_ribbon_id" + t.index ["earth_ribbon_id"], name: "index_pokeviewer_trainers_on_earth_ribbon_id" + t.index ["land_ribbon_id"], name: "index_pokeviewer_trainers_on_land_ribbon_id" + t.index ["marine_ribbon_id"], name: "index_pokeviewer_trainers_on_marine_ribbon_id" t.index ["name", "number"], name: "index_pokeviewer_trainers_on_name_and_number", unique: true + t.index ["national_ribbon_id"], name: "index_pokeviewer_trainers_on_national_ribbon_id" + t.index ["sky_ribbon_id"], name: "index_pokeviewer_trainers_on_sky_ribbon_id" + t.index ["world_ribbon_id"], name: "index_pokeviewer_trainers_on_world_ribbon_id" end end -- cgit 1.4.1